:root {
  --bg: #09090b;
  --surface: #18181b;
  --surface-2: #27272a;
  --border: #3f3f46;
  --text: #fafafa;
  --text-secondary: #a1a1aa;
  --primary: #6366f1;
  --primary-hover: #818cf8;
  --success: #22c55e;
  --warning: #eab308;
  --danger: #ef4444;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 4px 24px rgba(0, 0, 0, 0.4);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: "Inter", system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

.app {
  max-width: 1080px;
  margin: 0 auto;
  padding: 2rem 1.5rem 3rem;
}

/* Header */
header {
  margin-bottom: 1.75rem;
}

.logo {
  display: flex;
  align-items: center;
  gap: 0.85rem;
}

.logo-icon {
  font-size: 1.75rem;
  color: var(--primary);
  line-height: 1;
}

header h1 {
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.subtitle {
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-top: 0.1rem;
}

/* Status bar */
.status-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 1.25rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.85rem 1.25rem;
  margin-bottom: 1rem;
}

.status-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.85rem;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--warning);
  flex-shrink: 0;
}

.status-dot.ready {
  background: var(--success);
  box-shadow: 0 0 8px rgba(34, 197, 94, 0.4);
}

.status-dot.error {
  background: var(--danger);
}

.status-text {
  color: var(--text-secondary);
  font-weight: 500;
}

/* Progress */
.progress-container {
  margin-bottom: 1.25rem;
}

.progress-track {
  height: 4px;
  background: var(--surface-2);
  border-radius: 2px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--primary), #a78bfa);
  width: 0%;
  transition: width 0.25s ease;
}

.progress-text {
  display: block;
  font-size: 0.75rem;
  color: var(--text-secondary);
  margin-top: 0.4rem;
}

/* Grid */
.main-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.25rem;
}

@media (max-width: 820px) {
  .main-grid {
    grid-template-columns: 1fr;
  }
}

/* Panels */
.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.35rem;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
}

.panel-header h2 {
  font-size: 1.05rem;
  font-weight: 600;
}

.badge {
  font-size: 0.75rem;
  font-weight: 600;
  background: var(--surface-2);
  color: var(--primary);
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
}

/* Form elements */
textarea,
input[type="text"] {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  padding: 0.85rem 1rem;
  font-size: 0.925rem;
  font-family: inherit;
  transition: border-color 0.15s;
}

textarea {
  resize: vertical;
  min-height: 200px;
  line-height: 1.55;
}

textarea:focus,
input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}

textarea::placeholder,
input::placeholder {
  color: #52525b;
}

/* Online Mode */
.online-mode-box {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 1rem 1.1rem;
  margin-bottom: 1rem;
}

.online-mode-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.online-mode-header strong {
  font-size: 0.95rem;
}

.online-desc {
  font-size: 0.8rem;
  color: var(--text-secondary);
  margin-top: 0.15rem;
}

/* Toggle switch */
.switch {
  position: relative;
  display: inline-block;
  width: 48px;
  height: 26px;
  flex-shrink: 0;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.slider {
  position: absolute;
  cursor: pointer;
  inset: 0;
  background: var(--surface-2);
  border-radius: 26px;
  transition: 0.25s;
}

.slider:before {
  position: absolute;
  content: "";
  height: 20px;
  width: 20px;
  left: 3px;
  bottom: 3px;
  background: white;
  border-radius: 50%;
  transition: 0.25s;
}

input:checked + .slider {
  background: var(--primary);
}

input:checked + .slider:before {
  transform: translateX(22px);
}

input:disabled + .slider {
  opacity: 0.4;
  cursor: not-allowed;
}

.online-indicator {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.85rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--border);
  font-size: 0.85rem;
  color: var(--success);
}

.pulse-dot {
  width: 8px;
  height: 8px;
  background: var(--success);
  border-radius: 50%;
  animation: pulse-green 1.4s ease infinite;
}

@keyframes pulse-green {
  0%, 100% { opacity: 1; box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.5); }
  50% { opacity: 0.7; box-shadow: 0 0 0 6px rgba(34, 197, 94, 0); }
}

.divider {
  text-align: center;
  font-size: 0.75rem;
  color: var(--text-secondary);
  margin: 0.75rem 0 1rem;
  position: relative;
}

.divider::before,
.divider::after {
  content: "";
  position: absolute;
  top: 50%;
  width: 38%;
  height: 1px;
  background: var(--border);
}

.divider::before { left: 0; }
.divider::after { right: 0; }

/* Question row */
.question-row {
  display: flex;
  gap: 0.5rem;
}

.question-row input {
  flex: 1;
}

/* Buttons */
.actions {
  display: flex;
  gap: 0.6rem;
  margin-top: 0.9rem;
  flex-wrap: wrap;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  border: none;
  border-radius: var(--radius-sm);
  padding: 0.6rem 1.1rem;
  font-size: 0.875rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--primary);
  color: white;
}

.btn-primary:hover:not(:disabled) {
  background: var(--primary-hover);
}

.btn-ghost {
  background: var(--surface-2);
  color: var(--text);
}

.btn-ghost:hover:not(:disabled) {
  background: #3f3f46;
}

.btn-icon {
  background: var(--surface-2);
  color: var(--text);
  padding: 0.6rem 0.75rem;
}

.btn-icon:hover:not(:disabled) {
  background: #3f3f46;
}

.btn.recording {
  background: var(--danger) !important;
  color: white;
  animation: pulse 1.3s ease infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.75; }
}

.hint {
  font-size: 0.825rem;
  color: var(--text-secondary);
  margin-top: 0.7rem;
}

/* Results */
.result-section {
  margin-top: 1.4rem;
  padding-top: 1.2rem;
  border-top: 1px solid var(--border);
}

.result-section h3 {
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-secondary);
  margin-bottom: 0.65rem;
}

.answer-content {
  background: var(--bg);
  border-radius: var(--radius-sm);
  padding: 1rem 1.1rem;
  line-height: 1.6;
  white-space: pre-wrap;
  font-size: 0.95rem;
}

.sources-list {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}

.source-item {
  background: var(--bg);
  border-radius: var(--radius-sm);
  padding: 0.75rem 0.9rem;
  border-left: 3px solid var(--primary);
  font-size: 0.875rem;
  color: var(--text-secondary);
  line-height: 1.45;
}

.source-score {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--primary);
  background: rgba(99, 102, 241, 0.12);
  padding: 0.1rem 0.4rem;
  border-radius: 4px;
  margin-bottom: 0.3rem;
}

/* Footer */
footer {
  text-align: center;
  margin-top: 2.5rem;
  font-size: 0.8rem;
  color: var(--text-secondary);
}

footer strong {
  color: var(--text);
  font-weight: 500;
}
