/* ══════════════════════════════════════════════════════
   DESIGN TOKENS
══════════════════════════════════════════════════════ */
:root {
  /* Dark theme (default) */
  --bg-0:        #0d1117;
  --bg-1:        #161b22;
  --bg-2:        #21262d;
  --bg-3:        #30363d;
  --border:      #30363d;
  --border-sub:  #21262d;

  --text-1:      #e6edf3;
  --text-2:      #8b949e;
  --text-3:      #484f58;

  --accent:      #4ecdc4;
  --accent-dim:  rgba(78,205,196,.12);
  --accent-mid:  rgba(78,205,196,.25);

  --warn:        #d29922;
  --warn-dim:    rgba(210,153,34,.15);
  --err:         #f85149;
  --err-dim:     rgba(248,81,73,.15);
  --ok:          #3fb950;
  --royal:       #a855f7;
  --royal-dim:   rgba(168,85,247,.12);
  --royal-mid:   rgba(168,85,247,.25);

  /* Layout */
  --sidebar-w:   272px;
  --header-h:    48px;

  /* Type */
  --font:        -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  --mono:        'SFMono-Regular', Consolas, 'Liberation Mono', monospace;

  /* Radius */
  --r-sm:  4px;
  --r-md:  8px;
  --r-xl:  16px;

  /* Transitions */
  --t-fast: 120ms ease;
  --t-mid:  200ms ease;
}

[data-theme="light"] {
  --bg-0:       #f6f8fa;
  --bg-1:       #ffffff;
  --bg-2:       #f6f8fa;
  --bg-3:       #eaeef2;
  --border:     #d0d7de;
  --border-sub: #eaeef2;
  --text-1:     #1f2328;
  --text-2:     #656d76;
  --text-3:     #9198a1;
  --accent:     #0d6e68;
  --accent-dim: rgba(13,110,104,.08);
  --accent-mid: rgba(13,110,104,.18);
  --royal:       #7c3aed;
  --royal-dim:   rgba(124,58,237,.08);
  --royal-mid:   rgba(124,58,237,.18);
}

/* ══════════════════════════════════════════════════════
   RESET & BASE
══════════════════════════════════════════════════════ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { height: 100%; font-size: 13px; }

body {
  height: 100%;
  font-family: var(--font);
  font-size: 13px;
  line-height: 1.5;
  color: var(--text-1);
  background: var(--bg-0);
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

a { color: var(--accent); text-decoration: none; }
button { cursor: pointer; border: none; background: none; font: inherit; color: inherit; }
input, select, textarea { font: inherit; color: inherit; background: var(--bg-2); border: 1px solid var(--border); border-radius: var(--r-sm); }
textarea { resize: vertical; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
::selection { background: var(--accent-mid); }

/* ══════════════════════════════════════════════════════
   APP SHELL
══════════════════════════════════════════════════════ */
#app {
  display: grid;
  grid-template-rows: var(--header-h) 1fr;
  grid-template-columns: var(--sidebar-w) 1fr;
  height: 100vh;
  overflow: hidden;
}

/* ══════════════════════════════════════════════════════
   HEADER
══════════════════════════════════════════════════════ */
.app-header {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 12px;
  background: var(--bg-1);
  border-bottom: 1px solid var(--border);
  z-index: 50;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 8px;
  width: var(--sidebar-w);
  flex-shrink: 0;
}

.header-center {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
  margin-left: auto;
}

.app-logo {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -.3px;
  color: var(--accent);
  white-space: nowrap;
}
.app-logo span { color: var(--text-2); font-weight: 400; }

.current-lesson-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-1);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mode-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .3px;
  text-transform: uppercase;
  white-space: nowrap;
  flex-shrink: 0;
}
.mode-badge[data-mode="shadow"] { background: var(--accent-dim); color: var(--accent); }
.mode-badge[data-mode="echo"]   { background: var(--warn-dim); color: var(--warn); }
.mode-badge[data-mode="incremental"] { background: var(--royal-dim); color: var(--royal); }
.mode-badge[data-mode="blind"]  { background: var(--err-dim); color: var(--err); }

/* ══════════════════════════════════════════════════════
   SIDEBAR
══════════════════════════════════════════════════════ */
.sidebar {
  grid-column: 1;
  grid-row: 2;
  display: flex;
  flex-direction: column;
  background: var(--bg-1);
  border-right: 1px solid var(--border);
  overflow: hidden;
}

.sidebar-head {
  padding: 10px 10px 6px;
  border-bottom: 1px solid var(--border-sub);
  flex-shrink: 0;
}

.search-wrap {
  position: relative;
  margin-bottom: 8px;
}
.search-wrap svg {
  position: absolute;
  left: 8px;
  top: 50%;
  transform: translateY(-50%);
  width: 13px; height: 13px;
  stroke: var(--text-3);
  pointer-events: none;
}
.search-input {
  width: 100%;
  padding: 6px 8px 6px 28px;
  border-radius: var(--r-sm);
  font-size: 12px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  color: var(--text-1);
  transition: border-color var(--t-fast);
}
.search-input:focus { border-color: var(--accent); outline: none; }
.search-input::placeholder { color: var(--text-3); }

.sidebar-top-bar {
  display: flex;
  gap: 6px;
  align-items: center;
  margin-bottom: 4px;
}
.sidebar-top-bar .search-wrap { flex: 1; margin-bottom: 0; }

.filter-toggle-btn {
  flex-shrink: 0;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: var(--r-sm);
  background: var(--bg-2);
  border: 1px solid var(--border);
  color: var(--text-2);
  cursor: pointer;
  transition: background var(--t-fast), border-color var(--t-fast), color var(--t-fast);
}
.filter-toggle-btn svg { width: 14px; height: 14px; }
.filter-toggle-btn:hover { background: var(--bg-3); color: var(--text-1); }
.filter-toggle-btn.open { background: var(--accent-dim); border-color: var(--accent); color: var(--accent); }
.filter-toggle-btn.has-filters::after {
  content: '';
  position: absolute;
  top: 4px;
  right: 4px;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--accent);
}

.filter-panel {
  display: none;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 6px;
}
.filter-panel.open { display: flex; }

.filter-row {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.filter-chip {
  display: inline-flex;
  align-items: center;
  padding: 3px 8px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 500;
  background: var(--bg-2);
  border: 1px solid var(--border);
  color: var(--text-2);
  cursor: pointer;
  transition: background var(--t-fast), border-color var(--t-fast), color var(--t-fast);
  white-space: nowrap;
}
.filter-chip:hover { background: var(--bg-3); color: var(--text-1); }
.filter-chip.active { background: var(--accent-dim); border-color: var(--accent); color: var(--accent); }

.filter-group-label {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: .5px;
  text-transform: uppercase;
  color: var(--text-3);
  padding: 4px 0 2px;
  width: 100%;
}

.lesson-list {
  flex: 1;
  overflow-y: auto;
  padding: 6px 6px;
  scrollbar-width: thin;
  scrollbar-color: var(--bg-3) transparent;
}

.lesson-card {
  display: flex;
  flex-direction: row;
  align-items: flex-start;
  gap: 5px;
  padding: 10px 10px;
  border-radius: var(--r-md);
  cursor: pointer;
  border: 1px solid transparent;
  margin-bottom: 3px;
  transition: background var(--t-fast), border-color var(--t-fast);
  animation: card-appear 0.15s ease-out;
}
.lesson-num-col {
  display: flex;
  flex-direction: column;
  align-items: center;
  flex-shrink: 0;
  gap: 3px;
}
.lesson-num {
  font-size: 9px;
  font-weight: 600;
  color: var(--text-3);
  line-height: 1;
}
.lesson-card.active .lesson-num { color: #388bfd; }
.lesson-card-body {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
  min-width: 0;
}
.lesson-card:hover { background: var(--bg-2); }
.lesson-card.active {
  background: rgba(56, 139, 253, 0.12);
  border-color: #388bfd;
}
[data-theme="light"] .lesson-card.active {
  background: rgba(56, 139, 253, 0.1);
  border-color: #0969da;
}

.lesson-card-title {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 5px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-1);
  line-height: 1.3;
}
.lesson-card.active .lesson-card-title { color: #388bfd; }

.lesson-card-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  align-items: center;
}

.card-dot { font-size: 8px; line-height: 1; cursor: pointer; position: relative; }
.card-dot:hover { opacity: 0.75; }
/* When the status popover is open on a dot, don't dim it (or the popover) on hover. */
.card-dot:has(.dot-reset-tip):hover { opacity: 1; }
.card-dot.none    { color: var(--text-3); }
.card-dot.working { color: var(--warn); }
.card-dot.done    { color: var(--ok); }

/* Style intro-dot as an interactive labeled dropdown selector (Option 2) */
#intro-dot {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  border-radius: 6px; /* standard dropdown rounded corners */
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  user-select: none;
  border: 1px solid var(--border);
  transition: all 0.2s ease;
  background: var(--bg-2);
  font-family: inherit;
  color: var(--text-1);
}

#intro-dot:hover {
  background: var(--bg-3);
  border-color: var(--accent);
}

/* Labeled Prefix "Status: " */
#intro-dot::before {
  content: "Status: ";
  color: var(--text-2);
  font-weight: 400;
  margin-right: 4px;
}

/* Red / Yellow / Green Customizations based on Class */
#intro-dot.none {
  color: var(--text-3); /* dot color */
}
#intro-dot.none::after {
  content: " Not started ▾";
  color: var(--text-1);
  margin-left: 2px;
}

#intro-dot.working {
  color: var(--warn); /* dot color */
}
#intro-dot.working::after {
  content: " In progress ▾";
  color: var(--text-1);
  margin-left: 2px;
}

#intro-dot.done {
  color: var(--ok); /* dot color */
}
#intro-dot.done::after {
  content: " Completed ▾";
  color: var(--text-1);
  margin-left: 2px;
}

/* Status picker popover (shared by sidebar card dot + intro dot) */
.dot-reset-tip {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 4px;
  white-space: nowrap;
  font-size: 11px;
  color: var(--text-1);
  z-index: 100;
  box-shadow: 0 2px 8px rgba(0,0,0,0.3);
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.dot-option {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 8px;
  border: 1px solid transparent;
  border-radius: 4px;
  background: none;
  color: var(--text-2);
  font-size: 11px;
  cursor: pointer;
  white-space: nowrap;
}
.dot-option:hover { background: var(--bg-3); color: var(--text-1); }
.dot-option.active { border-color: var(--accent); color: var(--text-1); }
.dot-option .dot-glyph { font-size: 10px; line-height: 1; }
.dot-option .dot-glyph.none    { color: var(--text-3); }
.dot-option .dot-glyph.working { color: var(--warn); }
.dot-option .dot-glyph.done    { color: var(--ok); }

/* Auto in-progress popover — fixed, positioned under the intro dot via JS.
   Arrow uses --arrow-left (px, offset from popover's left edge) so it points
   exactly at the dot regardless of horizontal clamping. */
.auto-working-tip {
  position: fixed;
  z-index: 200;
  min-width: 250px;
  max-width: 320px;
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 12px 14px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.4);
  display: flex;
  flex-direction: column;
  gap: 10px;
  font-size: 12px;
  color: var(--text-1);
  opacity: 1;
  animation: fadeIn 0.15s ease-out;
}
/* arrow pointing up at the dot (popover sits below the dot) */
.auto-working-tip::before {
  content: '';
  position: absolute;
  top: -8px;
  left: var(--arrow-left, 14px);
  border-width: 0 8px 8px 8px;
  border-style: solid;
  border-color: transparent transparent var(--border) transparent;
}
.auto-working-tip::after {
  content: '';
  position: absolute;
  top: -7px;
  left: calc(var(--arrow-left, 14px) + 1px);
  border-width: 0 7px 7px 7px;
  border-style: solid;
  border-color: transparent transparent var(--bg-1) transparent;
}
/* arrow pointing down (popover sits above the dot) */
.auto-working-tip.above::before {
  top: auto; bottom: -8px;
  border-color: var(--border) transparent transparent transparent;
}
.auto-working-tip.above::after {
  top: auto; bottom: -7px;
  border-color: var(--bg-1) transparent transparent transparent;
}
.auto-working-text { font-size: 12px; line-height: 1.5; color: var(--text-2); }
.auto-working-check {
  display: flex; align-items: center; gap: 6px;
  font-size: 11px; color: var(--text-2); cursor: pointer; user-select: none;
}
.auto-working-tip .btn { align-self: flex-end; }

@keyframes card-appear {
  0%   { opacity: 0; transform: translateX(18px); }
  60%  { opacity: 1; }
  100% { opacity: 1; transform: translateX(0); }
}
@keyframes archive-out {
  0%   { opacity: 1; transform: translateX(0) rotate(0deg);      max-height: 120px; margin-bottom: 3px; }
  45%  { opacity: 1; transform: translateX(-10px) rotate(-1deg); max-height: 120px; margin-bottom: 3px; }
  70%  { opacity: 0; transform: translateX(-60px) rotate(-3deg); max-height: 120px; margin-bottom: 3px; }
  100% { opacity: 0; transform: translateX(-60px) rotate(-3deg); max-height: 0;     margin-bottom: 0; }
}
@keyframes btn-pop {
  0%   { transform: scale(1)    rotate(0deg);   color: var(--text-3); }
  30%  { transform: scale(2.0)  rotate(-15deg); color: var(--accent); }
  60%  { transform: scale(0.85) rotate(5deg);   color: var(--accent); }
  100% { transform: scale(1)    rotate(0deg);   color: var(--text-3); }
}
@keyframes toggle-appear {
  0%   { opacity: 0; transform: scale(0.4) translateY(4px); }
  55%  { opacity: 1; transform: scale(1.18) translateY(-2px); }
  80%  { transform: scale(0.95) translateY(0); }
  100% { opacity: 1; transform: scale(1) translateY(0); }
}

.archive-btn {
  display: flex; align-items: center; justify-content: center;
  width: 18px; height: 18px;
  border: none; background: none; cursor: pointer; padding: 0;
  color: var(--text-3);
  opacity: 0; transition: opacity 0.15s;
  flex-shrink: 0;
}
.lesson-card:hover .archive-btn { opacity: 1; }
.archive-btn:hover { color: var(--text-1); }
.archive-btn svg { width: 12px; height: 12px; }
.archive-btn.popping { animation: btn-pop 0.4s cubic-bezier(0.34, 1.56, 0.64, 1); }
.lesson-card.archiving {
  animation: archive-out 0.55s cubic-bezier(0.4, 0, 0.8, 0.6) forwards !important;
  pointer-events: none;
  overflow: hidden;
}
.lesson-card.archived-card { opacity: 0.45; }
.lesson-card.archived-card:hover { opacity: 0.75; background: var(--bg-2); }
.lesson-card.archived-card:hover .archive-btn { opacity: 1; }
.archived-section-label {
  font-size: 10px; font-weight: 600; color: var(--text-3);
  padding: 8px 12px 4px;
  text-transform: uppercase; letter-spacing: 0.05em;
}
.lesson-count { display: flex; align-items: center; }
.archived-toggle {
  margin-left: auto;
  background: none; border: none; cursor: pointer;
  font-size: 11px; color: var(--text-3); padding: 0;
  animation: toggle-appear 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.archived-toggle:hover { color: var(--text-1); }

.lvl-badge {
  display: inline-flex;
  align-items: center;
  padding: 1px 5px;
  border-radius: 3px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .2px;
  text-transform: uppercase;
}
.lvl-badge[data-level="Beginner"]          { background: rgba(35,134,54,.2); color: #3fb950; }
.lvl-badge[data-level="Lower Intermediate"]{ background: rgba(31,111,235,.2); color: #79c0ff; }
.lvl-badge[data-level="Intermediate"]      { background: rgba(137,87,229,.2); color: #d2a8ff; }
.lvl-badge[data-level="Upper Intermediate"]{ background: rgba(210,153,34,.2); color: #e3b341; }

.meta-chip {
  font-size: 10px;
  color: var(--text-3);
  white-space: nowrap;
}

.vocab-pill {
  font-size: 10px;
  font-weight: 600;
  color: var(--accent);
  background: var(--accent-dim);
  border-radius: 3px;
  padding: 1px 5px;
  white-space: nowrap;
}

.lesson-count {
  padding: 6px 10px;
  font-size: 11px;
  color: var(--text-3);
  border-top: 1px solid var(--border-sub);
  flex-shrink: 0;
}

.lesson-list-loading {
  padding: 16px;
  font-size: 12px;
  color: var(--text-3);
  text-align: center;
}

.lesson-list-error {
  padding: 16px;
  font-size: 12px;
  color: #f85149;
  text-align: center;
  line-height: 1.5;
}

/* ══════════════════════════════════════════════════════
   MAIN CONTENT
══════════════════════════════════════════════════════ */
.main-content {
  grid-column: 2;
  grid-row: 2;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--bg-3) transparent;
  background: var(--bg-0);
}

/* Lesson intro / about section */
.lesson-intro {
  padding: 16px 20px 0;
  flex-shrink: 0;
}

.lesson-intro-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}

.lesson-intro-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-1);
  line-height: 1.2;
}

.lesson-intro-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-bottom: 8px;
  align-items: center;
}

.accent-chip {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 2px 7px;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 500;
  background: var(--bg-3);
  color: var(--text-2);
  border: 1px solid var(--border);
}

.stat-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 7px;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 500;
  background: var(--bg-2);
  color: var(--text-3);
  border: 1px solid var(--border-sub);
}

.lesson-description {
  font-size: 12px;
  color: var(--text-2);
  line-height: 1.6;
  margin-bottom: 10px;
}

.vocab-section { margin-bottom: 10px; }


.vocab-grid {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding-top: 6px;
}

.vocab-item {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 4px 8px;
  padding: 5px 8px;
  border-radius: var(--r-sm);
  background: var(--bg-1);
  border: 1px solid var(--border-sub);
  cursor: pointer;
  transition: transform 0.1s ease, background 0.15s ease, border-color 0.15s ease;
}
.vocab-item:hover {
  background: var(--bg-2);
  border-color: var(--accent);
}
.vocab-item:active {
  transform: scale(0.98);
}
.vocab-word { font-size: 13px; font-weight: 600; color: var(--text-1); }
.vocab-phonetic { font-size: 11px; color: var(--accent); font-family: var(--mono); }
.vocab-def { font-size: 11px; color: var(--text-2); line-height: 1.4; }
.vocab-example { flex-basis: 100%; font-size: 11px; color: var(--text-3); font-style: italic; line-height: 1.4; padding-top: 2px; }
.vocab-meaning { font-style: normal; font-weight: 600; color: var(--text-2); }


/* ==========================================================================
   DYNAMIC WORKSPACE VARIABLES (GLASSMORPHIC OBSIDIAN TINTS)
   ========================================================================== */

/* Dark Theme (Default) */
.main-content[data-mode="shadow"] {
  --panel-accent: var(--accent);
  --panel-bg: linear-gradient(180deg, rgba(22, 27, 34, 0.7) 0%, rgba(20, 35, 36, 0.75) 100%);
  --panel-border: rgba(78, 205, 196, 0.16);
  --panel-shadow: rgba(78, 205, 196, 0.04);
  --active-btn-bg: rgba(78, 205, 196, 0.08);
  --active-btn-border: rgba(78, 205, 196, 0.25);
  --tx-current-bg: var(--accent-dim);
  --tx-current-border: var(--accent-mid);
  --tx-current-hl: var(--accent-mid);
  --tx-word-active: rgba(78, 205, 196, 0.35);
  --phrase-hl-bg: rgba(78, 205, 196, 0.18);
}
.main-content[data-mode="echo"] {
  --panel-accent: var(--warn);
  --panel-bg: linear-gradient(180deg, rgba(22, 27, 34, 0.7) 0%, rgba(31, 26, 18, 0.75) 100%);
  --panel-border: rgba(210, 153, 34, 0.16);
  --panel-shadow: rgba(210, 153, 34, 0.04);
  --active-btn-bg: rgba(210, 153, 34, 0.08);
  --active-btn-border: rgba(210, 153, 34, 0.25);
  --tx-current-bg: var(--warn-dim);
  --tx-current-border: rgba(210, 153, 34, 0.25);
  --tx-current-hl: rgba(210, 153, 34, 0.25);
  --tx-word-active: rgba(210, 153, 34, 0.45);
  --phrase-hl-bg: rgba(210, 153, 34, 0.18);
}
.main-content[data-mode="blind"] {
  --panel-accent: var(--err);
  --panel-bg: linear-gradient(180deg, rgba(22, 27, 34, 0.7) 0%, rgba(32, 21, 22, 0.75) 100%);
  --panel-border: rgba(248, 81, 73, 0.16);
  --panel-shadow: rgba(248, 81, 73, 0.04);
  --active-btn-bg: rgba(248, 81, 73, 0.08);
  --active-btn-border: rgba(248, 81, 73, 0.25);
  --tx-current-bg: var(--err-dim);
  --tx-current-border: rgba(248, 81, 73, 0.25);
  --tx-current-hl: rgba(248, 81, 73, 0.25);
  --tx-word-active: rgba(248, 81, 73, 0.45);
  --phrase-hl-bg: rgba(248, 81, 73, 0.18);
}
.main-content[data-mode="incremental"] {
  --panel-accent: var(--royal);
  --panel-bg: linear-gradient(180deg, rgba(22, 27, 34, 0.7) 0%, rgba(29, 21, 35, 0.75) 100%);
  --panel-border: rgba(168, 85, 247, 0.16);
  --panel-shadow: rgba(168, 85, 247, 0.04);
  --active-btn-bg: rgba(168, 85, 247, 0.08);
  --active-btn-border: rgba(168, 85, 247, 0.25);
  --tx-current-bg: var(--royal-dim);
  --tx-current-border: rgba(168, 85, 247, 0.25);
  --tx-current-hl: rgba(168, 85, 247, 0.25);
  --tx-word-active: rgba(168, 85, 247, 0.45);
  --phrase-hl-bg: rgba(168, 85, 247, 0.18);
}

/* Light Theme Overrides */
[data-theme="light"] .main-content[data-mode="shadow"] {
  --panel-accent: var(--accent);
  --panel-bg: linear-gradient(180deg, rgba(255, 255, 255, 0.85) 0%, rgba(240, 248, 247, 0.9) 100%);
  --panel-border: rgba(13, 110, 104, 0.12);
  --panel-shadow: rgba(13, 110, 104, 0.03);
  --active-btn-bg: rgba(13, 110, 104, 0.06);
  --active-btn-border: rgba(13, 110, 104, 0.2);
  --tx-current-bg: var(--accent-dim);
  --tx-current-border: var(--accent-mid);
  --tx-current-hl: var(--accent-mid);
  --tx-word-active: rgba(13, 110, 104, 0.25);
  --phrase-hl-bg: rgba(13, 110, 104, 0.15);
}
[data-theme="light"] .main-content[data-mode="echo"] {
  --panel-accent: var(--warn);
  --panel-bg: linear-gradient(180deg, rgba(255, 255, 255, 0.85) 0%, rgba(252, 247, 240, 0.9) 100%);
  --panel-border: rgba(210, 153, 34, 0.12);
  --panel-shadow: rgba(210, 153, 34, 0.03);
  --active-btn-bg: rgba(210, 153, 34, 0.06);
  --active-btn-border: rgba(210, 153, 34, 0.2);
  --tx-current-bg: rgba(210, 153, 34, 0.08);
  --tx-current-border: rgba(210, 153, 34, 0.2);
  --tx-current-hl: rgba(210, 153, 34, 0.15);
  --tx-word-active: rgba(210, 153, 34, 0.25);
  --phrase-hl-bg: rgba(210, 153, 34, 0.15);
}
[data-theme="light"] .main-content[data-mode="blind"] {
  --panel-accent: var(--err);
  --panel-bg: linear-gradient(180deg, rgba(255, 255, 255, 0.85) 0%, rgba(253, 244, 244, 0.9) 100%);
  --panel-border: rgba(248, 81, 73, 0.12);
  --panel-shadow: rgba(248, 81, 73, 0.03);
  --active-btn-bg: rgba(248, 81, 73, 0.06);
  --active-btn-border: rgba(248, 81, 73, 0.2);
  --tx-current-bg: rgba(248, 81, 73, 0.08);
  --tx-current-border: rgba(248, 81, 73, 0.2);
  --tx-current-hl: rgba(248, 81, 73, 0.15);
  --tx-word-active: rgba(248, 81, 73, 0.25);
  --phrase-hl-bg: rgba(248, 81, 73, 0.12);
}
[data-theme="light"] .main-content[data-mode="incremental"] {
  --panel-accent: var(--royal);
  --panel-bg: linear-gradient(180deg, rgba(255, 255, 255, 0.85) 0%, rgba(249, 245, 255, 0.9) 100%);
  --panel-border: rgba(124, 58, 237, 0.12);
  --panel-shadow: rgba(124, 58, 237, 0.03);
  --active-btn-bg: rgba(124, 58, 237, 0.06);
  --active-btn-border: rgba(124, 58, 237, 0.2);
  --tx-current-bg: var(--royal-dim);
  --tx-current-border: rgba(124, 58, 237, 0.2);
  --tx-current-hl: rgba(124, 58, 237, 0.15);
  --tx-word-active: rgba(124, 58, 237, 0.25);
  --phrase-hl-bg: rgba(124, 58, 237, 0.12);
}

/* ==========================================================================
   MODE SELECTOR (HIGH-END GLASSMORPHIC TAB BAR)
   ========================================================================== */
.mode-selector {
  display: flex;
  gap: 6px;
  padding: 6px;
  margin: 16px 20px 0; /* Flat bottom edge */
  background: rgba(22, 27, 34, 0.45);
  border: 1px solid var(--panel-border, rgba(255, 255, 255, 0.06));
  border-bottom: none; /* Flush attach with .transcript-panel */
  border-top-left-radius: 16px;
  border-top-right-radius: 16px;
  border-bottom-left-radius: 0;
  border-bottom-right-radius: 0;
  flex-shrink: 0;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  transition: background 0.4s cubic-bezier(0.25, 1, 0.5, 1),
              border-color 0.4s cubic-bezier(0.25, 1, 0.5, 1),
              box-shadow 0.4s cubic-bezier(0.25, 1, 0.5, 1);
}

[data-theme="light"] .mode-selector {
  background: rgba(255, 255, 255, 0.5);
}

.mode-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 8px 16px;
  border-radius: 10px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-2);
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.25s cubic-bezier(0.25, 1, 0.5, 1);
  gap: 2px;
  min-height: 44px;
}

.mode-btn:hover {
  color: var(--text-1);
  background: rgba(255, 255, 255, 0.04);
}

[data-theme="light"] .mode-btn:hover {
  background: rgba(0, 0, 0, 0.03);
}

.mode-btn:active {
  transform: scale(0.98);
}

/* Dynamic active state highlights based on current custom variables */
.mode-btn.active[data-mode="shadow"] {
  background: var(--active-btn-bg);
  border-color: var(--active-btn-border);
  color: var(--accent);
}
.mode-btn.active[data-mode="echo"] {
  background: var(--active-btn-bg);
  border-color: var(--active-btn-border);
  color: var(--warn);
}
.mode-btn.active[data-mode="blind"] {
  background: var(--active-btn-bg);
  border-color: var(--active-btn-border);
  color: var(--err);
}
.mode-btn.active[data-mode="incremental"] {
  background: var(--active-btn-bg);
  border-color: var(--active-btn-border);
  color: var(--royal);
}

.mode-btn-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .5px;
  text-transform: uppercase;
}
.mode-btn-desc {
  font-size: 9px;
  font-weight: 400;
  opacity: .75;
}

/* ── Player controls ───────────────────────────────── */
.toolbar-player {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.toolbar-divider {
  width: 1px;
  height: 20px;
  background: var(--border);
  flex-shrink: 0;
}

.ctrl-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 5px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg-2);
  color: var(--text-2);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  min-height: 32px;
  white-space: nowrap;
}
.ctrl-btn:hover {
  background: var(--bg-3);
  color: var(--text-1);
  border-color: var(--text-3);
  transform: translateY(-1px);
}
.ctrl-btn:active {
  transform: translateY(0) scale(0.98);
}
.ctrl-btn:disabled {
  opacity: .35;
  cursor: not-allowed;
  transform: none;
}
.ctrl-btn.primary {
  background: linear-gradient(135deg, var(--accent), #3caaa0);
  border: none;
  color: var(--bg-0);
  font-weight: 700;
  min-width: 80px;
  box-shadow: 0 3px 10px rgba(78, 205, 196, 0.25);
}
.ctrl-btn.primary:hover {
  filter: brightness(1.08);
  box-shadow: 0 4px 12px rgba(78, 205, 196, 0.35);
}
.ctrl-btn.active {
  background: var(--accent-dim);
  border-color: var(--accent);
  color: var(--accent);
}
.ctrl-btn.danger { color: var(--err); border-color: var(--err); }
.ctrl-btn.danger:hover { background: var(--err-dim); }
.ctrl-btn svg { width: 14px; height: 14px; flex-shrink: 0; }

.speed-btns {
  display: flex;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  background: var(--bg-2);
}
.speed-btn {
  padding: 5px 10px;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-2);
  background: transparent;
  border: none;
  border-right: 1px solid var(--border);
  cursor: pointer;
  transition: all 0.2s;
  min-height: 32px;
  min-width: 44px;
  text-align: center;
}
.speed-btn:last-child { border-right: none; }
.speed-btn:hover { background: var(--bg-3); color: var(--text-1); }
.speed-btn.active {
  background: var(--accent-dim);
  color: var(--accent);
  font-weight: 700;
}


.ab-controls {
  display: flex;
  align-items: center;
  gap: 4px;
}
.echo-pause-ctrl {
  display: flex;
  align-items: center;
  gap: 4px;
}
#echo-pause-val { font-size: 12px; min-width: 24px; text-align: center; color: var(--text-1); }
.ab-label { font-size: 11px; color: var(--text-3); }
.ab-val {
  display: inline-flex;
  align-items: center;
  padding: 2px 6px;
  border-radius: 3px;
  font-size: 10px;
  font-weight: 700;
  font-family: var(--mono);
  background: var(--bg-3);
  color: var(--text-2);
  min-width: 24px;
  justify-content: center;
}
.ab-val.set { background: var(--accent-dim); color: var(--accent); }
.ab-active-indicator {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 10px;
  color: var(--accent);
  font-weight: 600;
}




/* ==========================================================================
   TRANSCRIPT PANEL (UNIFIED WORKSPACE DECK)
   ========================================================================== */
.transcript-panel {
  margin: 0 20px 20px; /* Zero top margin to lock against .mode-selector */
  padding: 0; /* Clear container padding so toolbar fits flush */
  background: var(--panel-bg);
  border: 1px solid var(--panel-border, var(--border));
  border-top: none; /* Merged flush layout */
  border-radius: 0 0 16px 16px;
  display: flex;
  flex-direction: column;
  gap: 0;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.3), 0 0 24px var(--panel-shadow, transparent);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  transition: background 0.4s cubic-bezier(0.25, 1, 0.5, 1),
              border-color 0.4s cubic-bezier(0.25, 1, 0.5, 1),
              box-shadow 0.4s cubic-bezier(0.25, 1, 0.5, 1);
}

/* Pinned Sticky Desktop Toolbar */
.transcript-toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 18px;
  margin-bottom: 0; /* Flush with content */
  background: rgba(22, 27, 34, 0.25);
  border: none;
  border-bottom: 1px solid var(--panel-border, var(--border)); /* Inline divider border */
  border-radius: 0; /* Integrated deck style */
  flex-shrink: 0;
  flex-wrap: wrap;
  box-shadow: none;
  position: sticky;
  top: 0;
  z-index: 10;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  transition: border-color 0.4s cubic-bezier(0.25, 1, 0.5, 1);
}

[data-theme="light"] .transcript-toolbar {
  background: rgba(255, 255, 255, 0.3);
}

.transcript-lines {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 16px; /* Inner margin padding */
}

.tx-line {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 10px 12px;
  border-radius: var(--r-md);
  border: 1px solid transparent;
  cursor: pointer;
  transition: background var(--t-fast), border-color var(--t-fast);
  position: relative;
  scroll-margin-top: calc(var(--header-h) + 8px);
  scroll-margin-bottom: 80px;
}
.tx-line:hover { background: var(--bg-1); }
.tx-line.current {
  background: var(--tx-current-bg, var(--accent-dim));
  border-color: var(--tx-current-border, var(--accent-mid));
}
.tx-line.hard::before {
  content: '⚑';
  position: absolute;
  right: 10px;
  top: 10px;
  font-size: 10px;
  color: var(--warn);
}

.tx-line-num {
  font-size: 10px;
  font-family: var(--mono);
  color: var(--text-3);
  min-width: 16px;
  text-align: right;
  line-height: 1.6;
  flex-shrink: 0;
  padding-top: 1px;
}
.tx-line.current .tx-line-num { color: var(--panel-accent, var(--accent)); }

.tx-line-body { flex: 1; min-width: 0; }

.tx-line-text {
  font-size: 15px;
  color: var(--text-1);
  line-height: 1.55;
  font-weight: 400;
}
.tx-line.current .tx-line-text { color: var(--text-1); font-weight: 500; }
.tx-line-text mark {
  background: none;
  color: inherit;
  font-weight: 700;
  text-decoration: underline;
  text-underline-offset: 2px;
}
.tx-line.current .tx-line-text mark {
  text-decoration-color: var(--panel-accent, var(--accent));
}
.tx-line-text .phrase-hl {
  background: var(--phrase-hl-bg, rgba(251, 191, 36, 0.18));
  border-radius: 3px;
  padding: 0 2px;
}
.tx-line.current .tx-line-text .phrase-hl {
  background: var(--tx-current-hl, rgba(251, 191, 36, 0.18));
}

/* Custom phrase tooltip hover popup */
.phrase-tooltip {
  position: absolute;
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-left: 3px solid var(--warn); /* Gold highlight border for key phrase notes */
  color: var(--text-1);
  padding: 8px 12px;
  border-radius: var(--r-md);
  font-size: 11px;
  font-weight: 500;
  line-height: 1.4;
  box-shadow: 0 4px 16px rgba(0,0,0,0.3);
  z-index: 250;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--t-fast), transform var(--t-fast);
  transform: translateY(5px);
  max-width: 250px;
  word-wrap: break-word;
}
.phrase-tooltip.show {
  opacity: 1;
  transform: translateY(0);
}
.phrase-tooltip.hidden {
  display: none;
}

.tx-line-text .tx-word {
  border-radius: 3px;
  padding: 0 1px;
  transition: background var(--t-fast);
}
.tx-line-text .tx-word.word-active {
  background: var(--tx-word-active, var(--tx-current-hl));
}

.tx-line-tip {
  font-size: 11px;
  color: var(--text-3);
  margin-top: 4px;
  line-height: 1.4;
  font-style: italic;
  display: none;
}
.tx-line.current .tx-line-tip { display: block; color: var(--text-2); }

.tx-line-actions {
  display: flex;
  gap: 3px;
  flex-shrink: 0;
  opacity: 0;
  transition: opacity var(--t-fast);
  align-items: flex-start;
  padding-top: 2px;
}
.tx-line:hover .tx-line-actions { opacity: 1; }
.tx-line.current .tx-line-actions { opacity: 1; }
.tx-line-actions:has(.is-a, .is-b) { opacity: 1; }

.tx-action {
  display: inline-flex;
  align-items: center;
  padding: 2px 6px;
  border-radius: 3px;
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .3px;
  background: var(--bg-3);
  color: var(--text-3);
  border: none;
  cursor: pointer;
  transition: background var(--t-fast), color var(--t-fast);
  min-height: 22px;
  white-space: nowrap;
}
.tx-action:hover { background: var(--bg-2); color: var(--text-2); }
.tx-action.a-set { color: var(--accent); }
.tx-action.b-set { color: var(--accent); }
.tx-action.a-set.is-a { background: var(--accent); color: var(--bg-0); }
.tx-action.b-set.is-b { background: var(--accent); color: var(--bg-0); }
.tx-action.hard-set { color: var(--warn); }

/* Focus mode */
.transcript-panel.focus-mode .tx-line:not(.current) {
  opacity: .15;
  pointer-events: none;
}
.transcript-panel.focus-mode .tx-line.current .tx-line-text { font-size: 20px; }

/* Blind mode */
.transcript-panel.blind-mode .tx-line-text,
.transcript-panel.blind-mode .tx-line-tip { filter: blur(6px); }
.transcript-panel.blind-mode .tx-line.current .tx-line-text,
.transcript-panel.blind-mode .tx-line.current .tx-line-tip { filter: blur(6px); }

.mpb-focus-btn:disabled {
  opacity: .35;
  cursor: not-allowed;
  transform: none;
}

.reveal-btn-wrap {
  display: none;
  justify-content: center;
  padding: 12px 0 0;
}
.transcript-panel.blind-mode .reveal-btn-wrap { display: flex; }

/* Progressive word fade and reveal in Repeat+ mode */
.transcript-panel[data-mode="incremental"] .current ~ .tx-line .tx-word,
.transcript-panel[data-mode="incremental"] .tx-line.current .tx-word:not(.revealed) {
  opacity: 0.25;
  transition: opacity var(--t-fast);
}

/* AB loop highlight */
.tx-line.in-ab-loop { background: var(--accent-dim); }
.tx-line.in-ab-loop.current { border-color: var(--accent); }
@keyframes echo-pulse { 0%,100% { opacity:.5; } 50% { opacity:1; } }
.tx-line.echo-wait { animation: echo-pulse 1.2s ease-in-out infinite; border-color: var(--tx-current-border, var(--accent-mid)); background: var(--tx-current-bg, var(--accent-dim)); }
.tx-line.echo-wait::after {
  content: 'Repeat Now';
  position: absolute;
  right: 8px;
  bottom: 6px;
  font-size: 9px;
  font-weight: 600;
  text-transform: uppercase;
  color: var(--warn);
  background: var(--warn-dim);
  border: 1px solid var(--warn);
  border-radius: 12px;
  padding: 2px 6px;
  line-height: 1;
  display: flex;
  align-items: center;
  animation: echo-mic-pulse 1.2s ease-in-out infinite;
}
@keyframes echo-mic-pulse {
  0% { transform: scale(1); box-shadow: 0 0 0 0 rgba(210, 153, 34, 0.4); }
  70% { transform: scale(1.05); box-shadow: 0 0 0 6px rgba(210, 153, 34, 0); }
  100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(210, 153, 34, 0); }
}

/* Empty / tts unavailable states */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  flex: 1;
  padding: 40px 20px;
  text-align: center;
}
.empty-icon { font-size: 40px; opacity: .4; }
.empty-title { font-size: 16px; font-weight: 600; color: var(--text-1); }
.empty-desc { font-size: 13px; color: var(--text-2); max-width: 300px; line-height: 1.6; }



/* ══════════════════════════════════════════════════════
   BUTTONS (global variants)
══════════════════════════════════════════════════════ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 6px 12px;
  border-radius: var(--r-sm);
  border: 1px solid var(--border);
  background: var(--bg-2);
  color: var(--text-1);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: background var(--t-fast), border-color var(--t-fast), color var(--t-fast);
  min-height: 32px;
  white-space: nowrap;
}
.btn:hover { background: var(--bg-3); }
.btn.sm { padding: 4px 8px; font-size: 11px; min-height: 26px; }
.btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--bg-0);
  font-weight: 700;
}
.btn.primary:hover { filter: brightness(1.1); background: var(--accent); }
.btn.icon-btn {
  width: 32px; height: 32px;
  padding: 0;
  background: transparent;
  border-color: transparent;
  color: var(--text-2);
}
.btn.icon-btn:hover { background: var(--bg-2); color: var(--text-1); border-color: var(--border); }
.btn.icon-btn svg { width: 16px; height: 16px; }

/* ══════════════════════════════════════════════════════
   SHORTCUTS MODAL
══════════════════════════════════════════════════════ */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: rgba(0,0,0,.6);
  backdrop-filter: blur(2px);
  display: none;
  align-items: center;
  justify-content: center;
}
.modal-backdrop.open { display: flex; }

.modal {
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  padding: 20px;
  max-width: 460px;
  width: 92%;
  max-height: 80vh;
  overflow-y: auto;
  scrollbar-width: thin;
}
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}
.modal-title { font-size: 15px; font-weight: 700; color: var(--text-1); }
.modal-close {
  width: 28px; height: 28px;
  display: flex; align-items: center; justify-content: center;
  border-radius: var(--r-sm);
  background: var(--bg-2);
  border: 1px solid var(--border);
  color: var(--text-2);
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
}
.modal-close:hover { background: var(--bg-3); color: var(--text-1); }

.shortcut-group { margin-bottom: 16px; }
.shortcut-group-title { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .4px; color: var(--text-3); margin-bottom: 8px; }
.shortcut-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 5px 0;
  border-bottom: 1px solid var(--border-sub);
}
.shortcut-row:last-child { border-bottom: none; }
.shortcut-desc { font-size: 12px; color: var(--text-2); }
.shortcut-keys { display: flex; gap: 3px; }
.kbd {
  display: inline-flex;
  align-items: center;
  padding: 2px 6px;
  border-radius: 3px;
  font-size: 11px;
  font-weight: 600;
  font-family: var(--mono);
  background: var(--bg-3);
  border: 1px solid var(--border);
  color: var(--text-2);
}

/* ══════════════════════════════════════════════════════
   HELP MODAL CONTENT
══════════════════════════════════════════════════════ */
.help-intro {
  font-size: 13px;
  color: var(--text-2);
  line-height: 1.6;
  margin-bottom: 18px;
}
.help-section-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: var(--text-3);
  margin: 16px 0 8px;
}
.help-mode-grid { display: flex; flex-direction: column; gap: 10px; }
.help-mode-row { display: flex; align-items: flex-start; gap: 10px; }
.help-mode-badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
  flex-shrink: 0;
  background: var(--bg-3);
  border: 1px solid var(--border);
  color: var(--text-2);
}
.help-mode-badge[data-mode="shadow"] { background: #d1fae5; border-color: #6ee7b7; color: #065f46; }
.help-mode-badge[data-mode="echo"]   { background: #ede9fe; border-color: #c4b5fd; color: #5b21b6; }
.help-mode-badge[data-mode="blind"]  { background: #fee2e2; border-color: #fca5a5; color: #991b1b; }
[data-theme="dark"] .help-mode-badge[data-mode="shadow"] { background: #064e3b; border-color: #059669; color: #6ee7b7; }
[data-theme="dark"] .help-mode-badge[data-mode="echo"]   { background: #2e1065; border-color: #7c3aed; color: #c4b5fd; }
[data-theme="dark"] .help-mode-badge[data-mode="blind"]  { background: #450a0a; border-color: #dc2626; color: #fca5a5; }
.help-mode-desc { font-size: 12px; color: var(--text-2); line-height: 1.55; padding-top: 2px; }

.help-sequence { display: flex; flex-direction: column; gap: 7px; }
.help-seq-step { display: flex; align-items: baseline; gap: 10px; font-size: 12px; color: var(--text-2); }
.help-seq-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--accent-dim);
  border: 1px solid var(--accent-mid);
  font-size: 10px;
  font-weight: 700;
  color: var(--accent);
  flex-shrink: 0;
}

.help-highlights { display: flex; flex-direction: column; gap: 8px; }
.help-hl-row { display: flex; align-items: center; gap: 10px; font-size: 12px; color: var(--text-2); line-height: 1.5; }
.help-mark-demo { font-size: 12px; flex-shrink: 0; background: none; font-weight: 700; text-decoration: underline; text-underline-offset: 2px; width: 68px; text-align: center; }
.help-phrase-demo { font-size: 12px; flex-shrink: 0; background: rgba(251,191,36,0.18); border-radius: 3px; padding: 0 2px; width: 68px; text-align: center; }
.help-hard-demo { font-size: 13px; color: var(--warn); flex-shrink: 0; width: 68px; text-align: center; }
.help-dot-demo { font-size: 12px; flex-shrink: 0; width: 32px; text-align: center; }

.help-tips {
  margin: 0;
  padding-left: 18px;
  font-size: 12px;
  color: var(--text-2);
  line-height: 1.7;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

/* ══════════════════════════════════════════════════════
   MOBILE SIDEBAR DRAWER
══════════════════════════════════════════════════════ */
.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 90;
  background: rgba(0,0,0,.5);
}
.sidebar-backdrop.open { display: block; }

/* ══════════════════════════════════════════════════════
   ANIMATIONS
══════════════════════════════════════════════════════ */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}


/* ==========================================================================
   DYNAMIC MOBILE PLAYBAR ELEMENTS
   ========================================================================== */
#mobile-playbar[data-mode="shadow"] {
  background: rgba(22, 25, 29, 0.85) linear-gradient(to top, rgba(78, 205, 196, 0.04), transparent);
  border-color: rgba(78, 205, 196, 0.22);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35), 0 0 15px rgba(78, 205, 196, 0.04);
}
#mobile-playbar[data-mode="echo"] {
  background: rgba(22, 25, 29, 0.85) linear-gradient(to top, rgba(210, 153, 34, 0.04), transparent);
  border-color: rgba(210, 153, 34, 0.22);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35), 0 0 15px rgba(210, 153, 34, 0.04);
}
#mobile-playbar[data-mode="blind"] {
  background: rgba(22, 25, 29, 0.85) linear-gradient(to top, rgba(248, 81, 73, 0.04), transparent);
  border-color: rgba(248, 81, 73, 0.22);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35), 0 0 15px rgba(248, 81, 73, 0.04);
}
#mobile-playbar[data-mode="incremental"] {
  background: rgba(22, 25, 29, 0.85) linear-gradient(to top, rgba(168, 85, 247, 0.04), transparent);
  border-color: rgba(168, 85, 247, 0.22);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35), 0 0 15px rgba(168, 85, 247, 0.04);
}

[data-theme="light"] #mobile-playbar[data-mode="shadow"] {
  background: rgba(255, 255, 255, 0.85) linear-gradient(to top, rgba(13, 110, 104, 0.02), transparent);
  border-color: rgba(13, 110, 104, 0.18);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.08), 0 0 15px rgba(13, 110, 104, 0.03);
}
[data-theme="light"] #mobile-playbar[data-mode="echo"] {
  background: rgba(255, 255, 255, 0.85) linear-gradient(to top, rgba(210, 153, 34, 0.02), transparent);
  border-color: rgba(210, 153, 34, 0.18);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.08), 0 0 15px rgba(210, 153, 34, 0.03);
}
[data-theme="light"] #mobile-playbar[data-mode="blind"] {
  background: rgba(255, 255, 255, 0.85) linear-gradient(to top, rgba(248, 81, 73, 0.02), transparent);
  border-color: rgba(248, 81, 73, 0.18);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.08), 0 0 15px rgba(248, 81, 73, 0.03);
}
[data-theme="light"] #mobile-playbar[data-mode="incremental"] {
  background: rgba(255, 255, 255, 0.85) linear-gradient(to top, rgba(124, 58, 237, 0.02), transparent);
  border-color: rgba(124, 58, 237, 0.18);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.08), 0 0 15px rgba(124, 58, 237, 0.03);
}

/* Mobile-only elements — hidden on desktop */
#mobile-playbar { display: none; }
#back-btn { display: none; }
.mpb-focus-btn { display: none; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    transition-duration: .01ms !important;
  }
}

/* ══════════════════════════════════════════════════════
   MOBILE RESPONSIVE
══════════════════════════════════════════════════════ */
@media (max-width: 900px) {
  /* Mobile overrides to restore a compact, space-efficient status dot */
  #intro-dot {
    width: 24px;
    height: 24px;
    padding: 0;
    border-radius: 50%; /* Circle */
    justify-content: center;
    font-size: 10px; /* Small clean glyph */
  }

  /* Hide "Status: " text */
  #intro-dot::before {
    display: none !important;
  }

  /* Hide state text and chevrons */
  #intro-dot.none::after,
  #intro-dot.working::after,
  #intro-dot.done::after {
    display: none !important;
  }

  #app {
    grid-template-columns: 1fr;
    grid-template-rows: var(--header-h) 1fr;
    height: 100vh;
    overflow: hidden;
  }

  .sidebar {
    position: fixed;
    left: 0;
    top: var(--header-h);
    bottom: 0;
    z-index: 95;
    width: clamp(180px, 85vw, 320px);
    transform: translateX(-110%);
    transition: transform var(--t-mid);
    grid-column: auto;
    grid-row: auto;
  }
  .sidebar.mobile-open { transform: translateX(0); }

  .main-content {
    grid-column: 1;
    grid-row: 2;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  .app-header {
    position: sticky;
    top: 0;
    z-index: 100;
  }



  .header-left { width: auto; }
  .header-center { display: none; }
  #app.lesson-active #back-btn { display: flex; }

  #mobile-playbar {
    display: flex;
    align-items: center;
    gap: 8px;
    position: fixed;
    bottom: calc(12px + env(safe-area-inset-bottom));
    left: 12px;
    right: 12px;
    z-index: 85;
    padding: 8px 12px;
    border-radius: var(--r-xl);
    border: 1px solid var(--border);
    background: rgba(22, 25, 29, 0.82);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
    transition: all var(--t-fast);
  }

  .mpb-play {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 0 16px;
    min-height: 40px;
    flex: 1;
    min-width: 80px;
    border-radius: 20px;
    background: linear-gradient(135deg, var(--accent), #3caaa0);
    border: none;
    color: var(--bg-0);
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
    box-shadow: 0 3px 12px rgba(78, 205, 196, 0.25);
    transition: all var(--t-fast) cubic-bezier(0.4, 0, 0.2, 1);
    flex-shrink: 0;
  }
  .mpb-play:active {
    transform: scale(0.95);
    filter: brightness(0.95);
  }

  .mpb-speed-cycle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 46px;
    min-height: 40px;
    padding: 0;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--bg-2);
    color: var(--text-2);
    font-size: 11px;
    font-weight: 700;
    cursor: pointer;
    transition: all var(--t-fast);
    flex-shrink: 0;
  }
  .mpb-speed-cycle:active {
    transform: scale(0.94);
  }
  .mpb-speed-cycle.active {
    background: var(--accent-dim);
    color: var(--accent);
    border-color: var(--accent);
  }

  .mpb-ab {
    display: flex;
    align-items: stretch;
    flex-shrink: 0;
    border: 1px solid var(--border);
    border-radius: 12px;
    overflow: hidden;
    background: var(--bg-2);
    height: 40px;
  }
  .mpb-ab-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 34px;
    min-height: 38px;
    border: none;
    border-right: 1px solid var(--border);
    background: transparent;
    color: var(--text-2);
    font-size: 11px;
    font-weight: 700;
    cursor: pointer;
    line-height: 1;
    gap: 2px;
    transition: all var(--t-fast);
  }
  .mpb-ab-btn:active {
    transform: scale(0.94);
  }
  .mpb-ab-btn.set {
    color: var(--accent);
    background: var(--accent-dim);
  }
  .mpb-ab-val {
    font-size: 9px;
    font-weight: 600;
    color: var(--text-3);
    min-height: 9px;
    line-height: 1;
  }
  .mpb-ab-val:empty::before {
    content: '—';
  }
  .mpb-ab-btn.set .mpb-ab-val { color: var(--accent); }
  .mpb-ab-clear {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    border: none;
    background: transparent;
    color: var(--border);
    font-size: 10px;
    cursor: default;
    padding: 0;
    transition: all var(--t-fast);
  }
  .mpb-ab-clear.active {
    color: var(--text-2);
    cursor: pointer;
  }
  .mpb-ab-clear.active:active {
    color: var(--err);
    transform: scale(0.92);
  }

  .mpb-focus-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0 10px;
    min-height: 40px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--bg-2);
    color: var(--text-2);
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--t-fast);
    flex-shrink: 0;
  }
  .mpb-focus-btn:active {
    transform: scale(0.94);
  }
  .mpb-focus-btn.active { background: var(--accent-dim); color: var(--accent); border-color: var(--accent); }

  /* ── Mode selector on mobile ────────────────────── */
  .mode-selector {
    margin: 12px 12px 0; /* Tighter margins on mobile */
    border-top-left-radius: 12px;
    border-top-right-radius: 12px;
    padding: 4px;
    gap: 4px;
  }

  .mode-btn {
    padding: 6px 12px;
    border-radius: 8px;
    min-height: 38px;
    gap: 0;
  }

  .mode-btn-label {
    font-size: 10px;
  }

  .mode-btn-desc {
    display: none; /* Hide descriptions to maximize spacing */
  }

  /* ── Transcript panel on mobile ─────────────────── */
  .transcript-panel {
    margin: 0 12px 20px; /* Flush margins with mode-selector */
    border-bottom-left-radius: 12px;
    border-bottom-right-radius: 12px;
    padding-bottom: 84px; /* Ensure lines clear mobile-playbar */
  }

  .transcript-lines {
    padding: 12px;
  }

  .transcript-panel { padding-bottom: 72px; }

  /* Hide desktop player controls — replaced by the fixed bottom bar */
  .transcript-toolbar { display: none; }
}

@media (max-width: 600px) {
  .app-header {
    padding: 0 8px;
    gap: 8px;
  }
  .header-right {
    gap: 4px;
  }
  #shortcuts-btn {
    display: none !important;
  }
  .app-logo {
    font-size: 17px;
  }
}

/* ══════════════════════════════════════════════════════
   PROFILE PAGE
══════════════════════════════════════════════════════ */
.profile-wrapper {
  max-width: 760px;
  margin: 0 auto;
  padding: 32px 20px 80px;
}
.profile-title {
  font-size: 22px;
  font-weight: 700;
  margin-bottom: 20px;
  color: var(--text-1);
}
.profile-card {
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  padding: 20px;
  margin-bottom: 20px;
}
.profile-card-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-2);
  margin-bottom: 14px;
  text-transform: uppercase;
  letter-spacing: .5px;
}
.profile-field-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 0;
  border-bottom: 1px solid var(--border-sub);
  font-size: 13px;
}
.profile-field-row:last-child {
  border-bottom: none;
}
.profile-label {
  color: var(--text-2);
  font-weight: 500;
}
.profile-value {
  color: var(--text-1);
  font-weight: 600;
}
.profile-stats-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-bottom: 16px;
}
.profile-stat-box {
  background: var(--bg-2);
  border: 1px solid var(--border-sub);
  border-radius: var(--r-md);
  padding: 12px;
  text-align: center;
}
.profile-stat-val {
  font-size: 20px;
  font-weight: 700;
  color: var(--accent);
}
.profile-stat-lbl {
  font-size: 11px;
  color: var(--text-2);
  margin-top: 2px;
}
.profile-lesson-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.profile-lesson-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  background: var(--bg-2);
  border: 1px solid var(--border-sub);
  border-radius: var(--r-sm);
  font-size: 12px;
  color: var(--text-1);
}
.profile-lesson-item a {
  color: var(--text-1);
  font-weight: 600;
}
.profile-lesson-item a:hover {
  color: var(--accent);
}

@media (min-width: 901px) {
}

/* Scrollbar styling */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--bg-3); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--border); }

/* Divider utility */
.divider { width: 1px; height: 18px; background: var(--border); flex-shrink: 0; }

/* Toast (ephemeral confirmation, e.g. after login/signup) */
#toast {
  position: fixed;
  top: 56px;
  left: 50%;
  transform: translateX(-50%) translateY(-10px);
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  color: var(--text-1);
  padding: 10px 16px;
  border-radius: var(--r-md);
  font-size: 12px;
  font-weight: 600;
  box-shadow: 0 4px 16px rgba(0,0,0,0.35);
  z-index: 300;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
  max-width: 90vw;
  text-align: center;
}
#toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* Auth modal status line (red errors, green success) */
.auth-msg { font-size: 12px; min-height: 14px; color: var(--err); }
.auth-msg.success { color: var(--ok); }

/* Destructive button variant */
.btn.danger { color: var(--err); border-color: var(--err); }
.btn.danger:hover { background: var(--err-dim); color: var(--err); }

/* Account menu dropdown (from the header email button) */
.auth-menu {
  position: fixed;
  z-index: 250;
  min-width: 200px;
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  box-shadow: 0 4px 16px rgba(0,0,0,0.35);
  padding: 6px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.auth-menu-name {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-1);
  padding: 6px 8px;
  border-bottom: 1px solid var(--border-sub);
  word-break: break-word;
}
