:root {
  --bg-dark: #090d16;
  --bg-card: #111827;
  --bg-card-hover: #1f2937;
  --border-color: #1e293b;
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --accent-primary: #6366f1;
  --accent-glow: rgba(99, 102, 241, 0.35);
  --accent-emerald: #10b981;
  --accent-amber: #f59e0b;
  --accent-danger: #ef4444;
  --radius-lg: 16px;
  --radius-md: 10px;
}

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

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background-color: var(--bg-dark);
  background-image: 
    radial-gradient(circle at 15% 15%, rgba(99, 102, 241, 0.08) 0%, transparent 40%),
    radial-gradient(circle at 85% 80%, rgba(16, 185, 129, 0.06) 0%, transparent 40%);
  color: var(--text-main);
  min-height: 100vh;
  line-height: 1.5;
}

.app-shell {
  max-width: 1380px;
  margin: 0 auto;
  padding: 20px 24px 40px;
}

/* Topbar */
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-bottom: 20px;
  margin-bottom: 24px;
  border-bottom: 1px solid var(--border-color);
  flex-wrap: wrap;
  gap: 16px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
}

.brand-logo {
  font-size: 28px;
  width: 50px;
  height: 50px;
  border-radius: 14px;
  background: linear-gradient(135deg, #4f46e5, #06b6d4);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 15px var(--accent-glow);
}

.brand h1 {
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.subtitle {
  font-size: 0.82rem;
  color: var(--text-muted);
}

.topbar-controls {
  display: flex;
  align-items: center;
  gap: 12px;
}

.voice-select-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  padding: 6px 12px;
  border-radius: var(--radius-md);
  font-size: 0.85rem;
}

.voice-select-wrap label {
  color: var(--text-muted);
  font-weight: 500;
}

select {
  background: transparent;
  color: var(--text-main);
  border: none;
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  outline: none;
}

select option {
  background: var(--bg-card);
  color: var(--text-main);
}

/* Main Grid */
.main-grid {
  display: grid;
  grid-template-columns: 1.35fr 1fr;
  gap: 24px;
  align-items: start;
}

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

/* Mode Tabs */
.mode-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-bottom: 16px;
}

.mode-tab {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 16px;
  text-align: left;
  color: var(--text-main);
  cursor: pointer;
  transition: all 0.2s ease;
  position: relative;
}

.mode-tab:hover {
  border-color: #334155;
  background: var(--bg-card-hover);
}

.mode-tab.active {
  border-color: var(--accent-primary);
  background: linear-gradient(180deg, rgba(99, 102, 241, 0.14) 0%, rgba(17, 24, 39, 0.95) 100%);
  box-shadow: 0 0 20px rgba(99, 102, 241, 0.15);
}

.mode-badge {
  display: inline-block;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 99px;
  background: rgba(99, 102, 241, 0.2);
  color: #a5b4fc;
  margin-bottom: 6px;
}

.mode-title {
  font-size: 1rem;
  font-weight: 700;
  margin-bottom: 3px;
}

.mode-desc {
  font-size: 0.78rem;
  color: var(--text-muted);
}

/* Topic Bar & AI News Preview */
.topic-bar {
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 14px 16px;
  margin-bottom: 16px;
  font-size: 0.86rem;
}

.topic-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.topic-row label {
  color: var(--text-muted);
  font-weight: 500;
  white-space: nowrap;
}

.topic-row select {
  flex: 1;
  background: #090d16;
  padding: 7px 10px;
  border-radius: 6px;
  border: 1px solid var(--border-color);
}

.ai-news-preview {
  background: #090d16;
  border: 1px solid rgba(99, 102, 241, 0.25);
  border-radius: var(--radius-md);
  padding: 10px 14px;
}

.ai-news-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.8rem;
  color: #a5b4fc;
  margin-bottom: 8px;
}

.ai-news-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 5px;
  max-height: 95px;
  overflow-y: auto;
  font-size: 0.78rem;
  color: #cbd5e1;
}

.ai-news-list li {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding-bottom: 4px;
  border-bottom: 1px dashed rgba(255, 255, 255, 0.06);
}

.ai-news-list li:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.ai-news-source {
  color: #34d399;
  font-weight: 600;
  white-space: nowrap;
  font-size: 0.72rem;
}

/* Voice Stage Card */
.voice-stage-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 24px;
  margin-bottom: 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.stage-header {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}

.connection-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  border-radius: 99px;
  font-size: 0.8rem;
  font-weight: 600;
  background: #1e293b;
  color: var(--text-muted);
}

.connection-pill .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #64748b;
}

.connection-pill.connected {
  background: rgba(16, 185, 129, 0.15);
  color: #34d399;
}

.connection-pill.connected .dot {
  background: #10b981;
  box-shadow: 0 0 8px #10b981;
}

.connection-pill.speaking {
  background: rgba(99, 102, 241, 0.2);
  color: #a5b4fc;
}

.connection-pill.speaking .dot {
  background: #6366f1;
  box-shadow: 0 0 8px #6366f1;
}

.timer-display {
  font-family: 'JetBrains Mono', monospace;
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--text-main);
  background: #090d16;
  padding: 6px 16px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
}

/* Phases Stepper */
.phases-stepper {
  width: 100%;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(135px, 1fr));
  gap: 10px;
  margin-bottom: 22px;
}

.phase-step {
  background: #090d16;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 10px;
  font-size: 0.75rem;
  transition: all 0.25s ease;
}

.phase-step.active {
  border-color: var(--accent-primary);
  background: rgba(99, 102, 241, 0.12);
}

.phase-step.done {
  border-color: rgba(16, 185, 129, 0.4);
  opacity: 0.75;
}

.phase-time {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.68rem;
  color: #818cf8;
  font-weight: 700;
  display: block;
  margin-bottom: 2px;
}

.phase-name {
  font-weight: 600;
  color: var(--text-main);
}

/* Orb Container */
.orb-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  margin: 8px 0 20px;
  position: relative;
}

#audioCanvas {
  border-radius: 50%;
}

.orb-state-label {
  margin-top: 8px;
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text-muted);
}

/* Stage Actions */
.stage-actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  justify-content: center;
  margin-bottom: 14px;
}

button {
  font-family: inherit;
  cursor: pointer;
  border: none;
  border-radius: var(--radius-md);
  font-weight: 600;
  transition: all 0.18s ease;
}

.btn-primary {
  background: linear-gradient(135deg, #4f46e5, #6366f1);
  color: white;
  padding: 10px 20px;
  font-size: 0.92rem;
  box-shadow: 0 4px 14px var(--accent-glow);
}

.btn-primary:hover {
  transform: translateY(-1px);
  filter: brightness(1.08);
}

.btn-large {
  padding: 14px 28px;
  font-size: 1rem;
  border-radius: 12px;
}

.btn-secondary {
  background: #1e293b;
  color: var(--text-main);
  border: 1px solid #334155;
  padding: 10px 16px;
  font-size: 0.88rem;
}

.btn-secondary:hover {
  background: #334155;
}

.btn-danger {
  background: rgba(239, 68, 68, 0.15);
  color: #f87171;
  border: 1px solid rgba(239, 68, 68, 0.35);
  padding: 10px 18px;
  font-size: 0.88rem;
}

.btn-danger:hover {
  background: rgba(239, 68, 68, 0.25);
}

.btn-small {
  background: #1e293b;
  color: var(--text-muted);
  padding: 5px 10px;
  font-size: 0.78rem;
}

.btn-small:hover {
  color: var(--text-main);
}

.btn-text-danger {
  background: transparent;
  color: var(--text-muted);
  font-size: 0.75rem;
}

.btn-text-danger:hover {
  color: var(--accent-danger);
}

.headphones-tip {
  font-size: 0.78rem;
  color: var(--text-muted);
  text-align: center;
}

/* Transcript Card */
.transcript-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
}

.transcript-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.transcript-header h3 {
  font-size: 0.95rem;
  font-weight: 600;
}

.transcript-hint {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.transcript-body {
  max-height: 230px;
  overflow-y: auto;
  background: #090d16;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-size: 0.86rem;
  transition: filter 0.25s ease;
}

.transcript-body.blurred {
  filter: blur(6px);
  user-select: none;
}

.transcript-empty {
  color: var(--text-muted);
  font-style: italic;
  text-align: center;
  padding: 20px 0;
}

.msg-turn {
  padding: 8px 12px;
  border-radius: 8px;
  line-height: 1.4;
}

.msg-turn.coach {
  background: rgba(99, 102, 241, 0.12);
  border-left: 3px solid var(--accent-primary);
}

.msg-turn.user {
  background: rgba(16, 185, 129, 0.1);
  border-left: 3px solid var(--accent-emerald);
  align-self: flex-end;
}

.msg-role {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  margin-bottom: 2px;
  color: var(--text-muted);
}

/* Dashboard Right Column */
.dashboard-column {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.dash-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 20px;
}

.dash-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
}

.dash-card-header h2 {
  font-size: 1.02rem;
  font-weight: 700;
}

.streak-badge {
  background: rgba(245, 158, 11, 0.15);
  color: #fbbf24;
  border: 1px solid rgba(245, 158, 11, 0.3);
  padding: 4px 10px;
  border-radius: 99px;
  font-size: 0.78rem;
  font-weight: 700;
}

.unassessed-banner {
  background: rgba(99, 102, 241, 0.1);
  border: 1px dashed var(--accent-primary);
  border-radius: var(--radius-md);
  padding: 14px;
  font-size: 0.85rem;
  color: #cbd5e1;
}

.unassessed-banner p + p {
  margin-top: 6px;
  color: var(--text-muted);
}

.badges-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin-bottom: 18px;
}

.level-box {
  background: #090d16;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
}

.level-box.primary {
  border-color: var(--accent-primary);
  background: rgba(99, 102, 241, 0.1);
}

.level-box .lbl {
  font-size: 0.72rem;
  color: var(--text-muted);
  text-transform: uppercase;
  font-weight: 600;
}

.level-box strong {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text-main);
  margin-top: 2px;
}

.skills-bars {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.skill-row {
  font-size: 0.8rem;
}

.skill-info {
  display: flex;
  justify-content: space-between;
  margin-bottom: 4px;
  color: #cbd5e1;
}

.bar-bg {
  height: 7px;
  background: #090d16;
  border-radius: 99px;
  overflow: hidden;
}

.bar-fill {
  height: 100%;
  background: linear-gradient(90deg, #6366f1, #10b981);
  border-radius: 99px;
  transition: width 0.5s ease;
}

/* Memory Lists */
.card-subdesc {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 12px;
}

.memory-section + .memory-section {
  margin-top: 16px;
}

.memory-section h4 {
  font-size: 0.82rem;
  color: #a5b4fc;
  margin-bottom: 8px;
}

.memory-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 160px;
  overflow-y: auto;
}

.memory-list li {
  background: #090d16;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 0.82rem;
}

.memory-list li strong {
  color: #34d399;
}

.empty-item {
  color: var(--text-muted);
  font-style: italic;
  font-size: 0.8rem;
}

/* History List */
.history-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 180px;
  overflow-y: auto;
}

.history-item {
  background: #090d16;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 0.8rem;
}

.history-item-top {
  display: flex;
  justify-content: space-between;
  font-weight: 600;
  margin-bottom: 4px;
  color: #e2e8f0;
}

.history-date {
  font-size: 0.72rem;
  color: var(--text-muted);
}

/* Modal */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}

.modal-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 24px;
  width: 100%;
  max-width: 460px;
}

.modal-card h3 {
  margin-bottom: 10px;
}

.modal-card p {
  font-size: 0.86rem;
  color: var(--text-muted);
  margin-bottom: 16px;
}

.modal-card input {
  width: 100%;
  padding: 10px 14px;
  border-radius: var(--radius-md);
  border: 1px solid #334155;
  background: #090d16;
  color: var(--text-main);
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.88rem;
  margin-bottom: 10px;
}

.modal-links {
  margin-bottom: 18px;
  font-size: 0.82rem;
}

.modal-links a {
  color: #818cf8;
  text-decoration: none;
}

.modal-links a:hover {
  text-decoration: underline;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.hidden {
  display: none !important;
}
