/* ── Reset ─────────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

/* ── Themes ────────────────────────────────────────────────────────────────── */
:root, [data-theme="luxury"] {
  --bg:           #F5F0EB;
  --surface:      #FFFFFF;
  --sidebar-bg:   #EEEAE4;
  --border:       #DDD7CF;
  --border-light: #EDE8E2;
  --ink:          #2A2520;
  --ink-mid:      #4A4540;
  --ink-muted:    #6B6059;
  --ink-faint:    #9E9189;
  --accent:       #8B7355;
  --accent-dark:  #725F47;
  --accent-tint:  #F0E9DF;
  --topbar-bg:    #2A2520;
  --topbar-ink:   #F5F0EB;
  --audiobar-bg:  #2A2520;
  --tag-p-bg:     #F5EDE0; --tag-p-fg: #7A5C38;
  --tag-s-bg:     #E3EDE3; --tag-s-fg: #3A6A3A;
  --tag-l-bg:     #E3E8F0; --tag-l-fg: #2E4E7A;
  --tag-r-bg:     #F0E3ED; --tag-r-fg: #7A3A68;
  --theme-dot-luxury:  #8B7355;
  --theme-dot-ocean:   #2E7D8C;
  --theme-dot-forest:  #4A7A4A;
  --theme-dot-universe:#9D8FBF;
  --theme-dot-crimson: #A51C30;
}

[data-theme="ocean"] {
  --bg:           #EDF5F8;
  --surface:      #FFFFFF;
  --sidebar-bg:   #DFF0F5;
  --border:       #C4DDE6;
  --border-light: #D8EEF4;
  --ink:          #132535;
  --ink-mid:      #2A4A60;
  --ink-muted:    #4A7A90;
  --ink-faint:    #7AAABB;
  --accent:       #1A7FA0;
  --accent-dark:  #1265820;
  --accent-tint:  #D8F0F8;
  --topbar-bg:    #0D3347;
  --topbar-ink:   #E8F6FA;
  --audiobar-bg:  #0D3347;
  --tag-p-bg:     #D8EEF8; --tag-p-fg: #1A5A7A;
  --tag-s-bg:     #D8F0E8; --tag-s-fg: #1A6A4A;
  --tag-l-bg:     #E8E8F8; --tag-l-fg: #3A3A8A;
  --tag-r-bg:     #F0E8F0; --tag-r-fg: #7A3A7A;
}

[data-theme="forest"] {
  /* Tiffany blue — luminous, glass-like */
  --bg:           #E6F9F7;
  --surface:      #F3FEFE;
  --sidebar-bg:   #D4F4F0;
  --border:       #86E2DA;
  --border-light: #B8EEE8;
  --ink:          #01302E;
  --ink-mid:      #045550;
  --ink-muted:    #208880;
  --ink-faint:    #70C8C0;
  --accent:       #0ABAB5;
  --accent-dark:  #079490;
  --accent-tint:  #BCF4F0;
  --topbar-bg:    #01302E;
  --topbar-ink:   #E6F9F7;
  --audiobar-bg:  #01302E;
  --tag-p-bg:     #B8EEE8; --tag-p-fg: #027070;
  --tag-s-bg:     #B8EEE0; --tag-s-fg: #026855;
  --tag-l-bg:     #B8EEF4; --tag-l-fg: #025060;
  --tag-r-bg:     #D6ECC0; --tag-r-fg: #3A5010;
  --theme-dot-forest: #0ABAB5;
}

[data-theme="universe"] {
  /* Grayish purple on black */
  --bg:           #0A0A0C;
  --surface:      #000000;
  --sidebar-bg:   #0E0D12;
  --border:       #221E2C;
  --border-light: #18141F;
  --ink:          #ECE8F2;
  --ink-mid:      #C6BDD6;
  --ink-muted:    #8E84A2;
  --ink-faint:    #5E566E;
  --accent:       #9D8FBF;
  --accent-dark:  #7E70A0;
  --accent-tint:  #1C1828;
  --topbar-bg:    #060509;
  --topbar-ink:   #ECE8F2;
  --audiobar-bg:  #060509;
  --tag-p-bg:     #1E1828; --tag-p-fg: #B0A0CC;
  --tag-s-bg:     #1A1A26; --tag-s-fg: #A6A2CE;
  --tag-l-bg:     #161A24; --tag-l-fg: #94A6C6;
  --tag-r-bg:     #201826; --tag-r-fg: #C0A4C8;
  --theme-dot-universe: #9D8FBF;
}

[data-theme="crimson"] {
  /* Crimson — Harvard style: champagne parchment, oxblood header, crimson accent */
  --bg:           #F9F5EF;
  --surface:      #FFFFFF;
  --sidebar-bg:   #F2ECE4;
  --border:       #DDD4C8;
  --border-light: #EDE8DF;
  --ink:          #1A1008;
  --ink-mid:      #3C2C1C;
  --ink-muted:    #6A5A4A;
  --ink-faint:    #A8988A;
  --accent:       #A51C30;
  --accent-dark:  #8C1628;
  --accent-tint:  #FCEAEC;
  --topbar-bg:    #6E1020;
  --topbar-ink:   #FFFFFF;
  --audiobar-bg:  #6E1020;
  --tag-p-bg:     #FCEAEC; --tag-p-fg: #8C1628;
  --tag-s-bg:     #F7F0E0; --tag-s-fg: #8A6820;
  --tag-l-bg:     #E8F2DC; --tag-l-fg: #2E6020;
  --tag-r-bg:     #ECE8F4; --tag-r-fg: #4A3888;
  --theme-dot-crimson: #A51C30;
}

/* ── Base ──────────────────────────────────────────────────────────────────── */
html, body {
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Helvetica Neue", Arial, sans-serif;
  font-size: 14px;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

/* ── Top Bar ───────────────────────────────────────────────────────────────── */
.topbar {
  position: fixed; top: 0; left: 0; right: 0; height: 52px;
  background: var(--topbar-bg);
  color: var(--topbar-ink);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 20px; z-index: 100;
  border-bottom: 1px solid rgba(0,0,0,0.3);
}
.topbar-left  { display: flex; align-items: center; gap: 12px; }
.topbar-right { display: flex; align-items: center; gap: 14px; }

.logo-mark {
  width: 28px; height: 28px; background: var(--accent);
  border-radius: 6px; display: flex; align-items: center; justify-content: center;
  font-family: Georgia, serif; font-size: 14px; color: var(--topbar-ink);
  flex-shrink: 0;
}
.title-main { font-size: 14px; font-weight: 500; color: var(--topbar-ink); letter-spacing: .02em; }
.title-sub  { font-size: 11px; color: rgba(255,255,255,.38); margin-left: 8px; }
[data-theme="luxury"]  .title-sub,
[data-theme="forest"]  .title-sub { color: rgba(245,245,235,.38); }
[data-theme="crimson"] .title-sub { color: rgba(255,255,255,.45); }

.speed-label { font-size: 11px; color: rgba(255,255,255,.38); letter-spacing: .08em; text-transform: uppercase; }
.speed-group { display: flex; gap: 3px; }
.speed-group.small .speed-btn { padding: 3px 10px; font-size: 12px; }

.speed-btn {
  background: transparent; border: 1px solid rgba(255,255,255,.18);
  color: rgba(255,255,255,.55); padding: 4px 11px; border-radius: 4px;
  font-size: 12px; cursor: pointer; transition: all .15s; font-family: inherit;
}
.speed-btn:hover  { border-color: rgba(255,255,255,.5); color: var(--topbar-ink); }
.speed-btn.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.modal .speed-btn        { border-color: var(--border); color: var(--ink-muted); }
.modal .speed-btn:hover  { border-color: var(--ink-mid); color: var(--ink); }
.modal .speed-btn.active { background: var(--ink); border-color: var(--ink); color: var(--bg); }

.divider-v { width: 1px; height: 20px; background: rgba(255,255,255,.15); }

/* Theme switcher */
.theme-switcher { display: flex; gap: 6px; align-items: center; }
.theme-dot {
  width: 13px; height: 13px; border-radius: 50%; border: 2px solid transparent;
  cursor: pointer; transition: all .15s; flex-shrink: 0;
  background: transparent;
}
.theme-dot[data-theme="luxury"]  { background: var(--theme-dot-luxury); }
.theme-dot[data-theme="ocean"]   { background: var(--theme-dot-ocean); }
.theme-dot[data-theme="forest"]  { background: var(--theme-dot-forest); }
.theme-dot[data-theme="universe"]{ background: var(--theme-dot-universe); }
.theme-dot[data-theme="crimson"] { background: var(--theme-dot-crimson); }
.theme-dot.active,
.theme-dot:hover { border-color: rgba(255,255,255,.7); transform: scale(1.2); }

.hw-btn {
  display: flex; align-items: center; gap: 7px;
  background: var(--accent); border: none; color: #fff;
  padding: 7px 15px; border-radius: 6px; font-size: 13px; font-weight: 500;
  cursor: pointer; transition: background .15s; font-family: inherit;
}
.hw-btn:hover:not(:disabled) { background: var(--accent-dark); }
.hw-btn:disabled { opacity: .35; cursor: default; }
.hw-count {
  background: rgba(255,255,255,.25); color: #fff; font-size: 11px;
  font-weight: 600; padding: 1px 7px; border-radius: 10px; min-width: 20px; text-align: center;
}

/* ── Layout ────────────────────────────────────────────────────────────────── */
.layout { display: flex; margin-top: 52px; min-height: calc(100vh - 52px); }

/* ── Sidebar ───────────────────────────────────────────────────────────────── */
.sidebar {
  width: 256px; flex-shrink: 0; background: var(--sidebar-bg);
  border-right: 1px solid var(--border);
  position: sticky; top: 52px; height: calc(100vh - 52px);
  overflow-y: auto; overflow-x: hidden;
  scrollbar-width: thin; scrollbar-color: var(--border) transparent;
}
.sidebar::-webkit-scrollbar { width: 4px; }
.sidebar::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

.search-section {
  padding: 12px 14px 10px; border-bottom: 1px solid var(--border);
  background: var(--sidebar-bg); position: sticky; top: 0; z-index: 10;
}
.search-wrap {
  display: flex; align-items: center; background: var(--surface);
  border: 1px solid var(--border); border-radius: 7px; padding: 6px 10px;
  gap: 8px; transition: border-color .15s;
}
.search-wrap:focus-within { border-color: var(--accent); }
.search-icon { color: var(--ink-faint); flex-shrink: 0; }
.search-wrap input {
  border: none; outline: none; background: transparent;
  font-size: 13px; color: var(--ink); width: 100%; font-family: inherit;
}
.search-wrap input::placeholder { color: var(--ink-faint); }
.clear-btn { background: none; border: none; color: var(--ink-faint); cursor: pointer; font-size: 11px; }
.clear-btn:hover { color: var(--ink-mid); }

.sidebar-inner { padding: 0 0 20px; }
.sidebar-section { padding: 12px 14px; border-bottom: 1px solid var(--border-light); }
.sidebar-section:last-child { border-bottom: none; }

.filter-label {
  font-size: 11px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase;
  color: var(--ink-muted); margin-bottom: 9px;
  display: flex; justify-content: space-between; align-items: center;
}
.filter-value { font-size: 11px; font-weight: 400; letter-spacing: 0; text-transform: none; color: var(--accent); }

.filter-group-label {
  font-size: 10px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase;
  margin-bottom: 9px; padding: 2px 7px; border-radius: 4px; display: inline-block;
}
.phonetic-label    { background: var(--tag-p-bg); color: var(--tag-p-fg); }
.syntax-label      { background: var(--tag-s-bg); color: var(--tag-s-fg); }
.pattern-label     { background: var(--tag-r-bg); color: var(--tag-r-fg); }
.lexical-label     { background: var(--tag-l-bg); color: var(--tag-l-fg); }
.recurrence-label  { background: var(--tag-s-bg); color: var(--tag-s-fg); }

.filter-select {
  width: 100%; border: 1px solid var(--border); background: var(--surface);
  color: var(--ink); padding: 7px 28px 7px 10px; border-radius: 7px;
  font-size: 13px; font-family: inherit; outline: none; cursor: pointer;
  -webkit-appearance: none; appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%239E9189'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 10px center;
}
.filter-select:focus { border-color: var(--accent); }

.cb-label {
  display: flex; align-items: flex-start; gap: 7px;
  padding: 3px 0; cursor: pointer; font-size: 12.5px; color: var(--ink-mid); line-height: 1.45;
}
.cb-label.inline  { display: inline-flex; margin-right: 14px; align-items: center; }
.cb-label.indent  { padding-left: 10px; }
.cb-label input[type="checkbox"] { width: 13px; height: 13px; accent-color: var(--accent); cursor: pointer; flex-shrink: 0; margin-top: 2px; }
.cb-label em { font-style: normal; color: var(--ink-faint); margin-left: 3px; font-size: 11px; }

.filter-sub-group { margin-top: 8px; border-left: 2px solid var(--border-light); padding-left: 6px; }
.filter-sub-label { font-size: 11px; font-weight: 600; color: var(--ink-muted); margin-bottom: 4px; padding: 2px 0; }

.reset-btn {
  width: 100%; background: none; border: 1px solid var(--border); color: var(--ink-muted);
  padding: 7px; border-radius: 7px; font-size: 12px; font-family: inherit;
  cursor: pointer; transition: all .15s;
}
.reset-btn:hover { border-color: var(--ink-mid); color: var(--ink-mid); }

/* Dual range slider */
.dual-range { position: relative; height: 24px; display: flex; align-items: center; margin-top: 2px; }
.range-track { position: absolute; left: 0; right: 0; height: 3px; background: var(--border); border-radius: 2px; pointer-events: none; }
.range-fill  { position: absolute; height: 100%; background: var(--accent); border-radius: 2px; }
.range-input {
  position: absolute; width: 100%; height: 3px; background: transparent;
  -webkit-appearance: none; appearance: none; pointer-events: none; outline: none;
}
.range-input::-webkit-slider-thumb {
  -webkit-appearance: none; width: 14px; height: 14px; border-radius: 50%;
  background: var(--accent); border: 2px solid var(--surface);
  box-shadow: 0 1px 4px rgba(0,0,0,.2); cursor: pointer; pointer-events: all;
}
.range-input::-moz-range-thumb {
  width: 14px; height: 14px; border-radius: 50%; background: var(--accent);
  border: 2px solid var(--surface); cursor: pointer; pointer-events: all;
}

/* ── Main ──────────────────────────────────────────────────────────────────── */
.main {
  flex: 1; min-width: 0; padding: 16px 24px 80px;
  display: flex; flex-direction: column; gap: 0;
}

/* Selection toolbar */
.select-bar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 0 12px; gap: 8px; flex-wrap: wrap;
}
.select-bar-left { display: flex; gap: 6px; flex-wrap: wrap; }
.sel-btn {
  background: none; border: 1px solid var(--border); color: var(--ink-muted);
  padding: 4px 11px; border-radius: 5px; font-size: 12px; font-family: inherit;
  cursor: pointer; transition: all .15s; white-space: nowrap;
}
.sel-btn:hover { border-color: var(--accent); color: var(--accent); }
.sel-btn.active { background: var(--accent-tint); border-color: var(--accent); color: var(--accent); }
.sel-info { font-size: 12px; color: var(--ink-faint); }

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

/* ── Card ──────────────────────────────────────────────────────────────────── */
.card {
  background: var(--surface); border: 1px solid var(--border-light);
  border-radius: 10px; padding: 18px 18px 14px;
  box-shadow: 0 1px 3px rgba(0,0,0,.05), 0 1px 2px rgba(0,0,0,.03);
  transition: box-shadow .15s, border-color .15s;
}
.card:hover { box-shadow: 0 3px 12px rgba(0,0,0,.07); }
.card.selected { border-color: var(--accent); background: var(--accent-tint); }

.card-header {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 10px; margin-bottom: 10px;
}
.card-meta { display: flex; align-items: center; gap: 7px; flex-wrap: wrap; flex: 1; min-width: 0; }
.meta-topic { font-size: 10.5px; font-weight: 700; letter-spacing: .05em; color: var(--accent); text-transform: lowercase; }
.meta-sep   { color: var(--ink-faint); font-size: 11px; }
.meta-date  { font-size: 11px; color: var(--ink-faint); }
.meta-num   { font-size: 11px; color: var(--ink-faint); }
.card-checkbox { width: 15px; height: 15px; accent-color: var(--accent); cursor: pointer; flex-shrink: 0; margin-top: 2px; }

.card-text {
  font-family: Georgia, "Times New Roman", serif;
  font-size: 17px; line-height: 1.7; color: var(--ink); margin: 0 0 12px;
}
.card-notes {
  font-size: 11px; color: var(--tag-r-fg); background: var(--tag-r-bg);
  padding: 3px 8px; border-radius: 4px; margin-bottom: 10px; display: inline-block;
}
.card-footer { display: flex; align-items: center; gap: 7px; flex-wrap: wrap; }

.audio-btn {
  display: flex; align-items: center; gap: 5px; background: none;
  border: 1px solid var(--border); color: var(--ink-mid);
  padding: 4px 11px; border-radius: 14px; font-size: 12px; cursor: pointer;
  transition: all .15s; font-family: inherit;
}
.audio-btn:hover  { border-color: var(--accent); color: var(--accent); }
.audio-btn.playing{ background: var(--accent); border-color: var(--accent); color: #fff; }
.audio-btn-flag   { font-size: 13px; line-height: 1; }

.footer-sep { width: 1px; height: 13px; background: var(--border-light); flex-shrink: 0; }

.tag { font-size: 10px; font-weight: 600; letter-spacing: .07em; text-transform: uppercase;
  padding: 2px 7px; border-radius: 4px; line-height: 1.6; white-space: nowrap; }
.tag-p { background: var(--tag-p-bg); color: var(--tag-p-fg); }
.tag-s { background: var(--tag-s-bg); color: var(--tag-s-fg); }
.tag-l { background: var(--tag-l-bg); color: var(--tag-l-fg); }
.tag-r { background: var(--tag-r-bg); color: var(--tag-r-fg); }

/* ── States ────────────────────────────────────────────────────────────────── */
.loading-state { display: flex; flex-direction: column; align-items: center; padding: 80px 20px; color: var(--ink-faint); gap: 14px; }
.loading-spinner { width: 26px; height: 26px; border: 2px solid var(--border); border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.empty-state  { padding: 80px 20px; text-align: center; color: var(--ink-faint); }
.empty-title  { font-size: 15px; font-weight: 500; color: var(--ink-mid); margin-bottom: 5px; }
.empty-sub    { font-size: 13px; }

/* ── Branding ──────────────────────────────────────────────────────────────── */
.branding {
  padding: 24px 0 4px; font-size: 11px; color: var(--ink-faint);
  text-align: center; letter-spacing: .04em;
}

/* ── Audio Bar ─────────────────────────────────────────────────────────────── */
.audiobar {
  position: fixed; bottom: 0; left: 0; right: 0; height: 64px;
  background: var(--audiobar-bg); display: flex; align-items: center; gap: 14px;
  padding: 0 18px 0 14px; z-index: 200;
  border-top: 1px solid rgba(0,0,0,.3);
}
.ab-play {
  width: 34px; height: 34px; background: var(--accent); border: none; border-radius: 50%;
  display: flex; align-items: center; justify-content: center; cursor: pointer;
  color: #fff; flex-shrink: 0; transition: background .15s;
}
.ab-play:hover { background: var(--accent-dark); }
.ab-info { display: flex; align-items: center; gap: 7px; flex: 0 0 300px; max-width: 340px; overflow: hidden; }
.ab-num  { font-size: 11px; color: rgba(255,255,255,.38); white-space: nowrap; flex-shrink: 0; }
.ab-text { font-family: Georgia, serif; font-size: 13px; color: rgba(255,255,255,.8);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.ab-scrubber-wrap { flex: 1; display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.ab-scrubber {
  width: 100%; height: 3px; cursor: pointer; accent-color: var(--accent);
  background: rgba(255,255,255,.12); border-radius: 2px;
  -webkit-appearance: none; appearance: none; outline: none;
}
.ab-scrubber::-webkit-slider-thumb {
  -webkit-appearance: none; width: 11px; height: 11px; border-radius: 50%;
  background: var(--accent); cursor: pointer;
}
.ab-times { display: flex; justify-content: space-between; font-size: 10px; color: rgba(255,255,255,.3); }
.ab-accent { font-size: 11px; color: rgba(255,255,255,.4); flex-shrink: 0; min-width: 24px; text-align: center; }
.ab-close { background: none; border: none; color: rgba(255,255,255,.3); cursor: pointer; font-size: 13px; padding: 4px; transition: color .15s; }
.ab-close:hover { color: rgba(255,255,255,.6); }

/* ── Modal ─────────────────────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 300;
  display: flex; align-items: center; justify-content: center; padding: 20px;
  backdrop-filter: blur(2px);
}
.modal {
  background: var(--surface); border-radius: 14px; width: 100%; max-width: 440px;
  box-shadow: 0 20px 60px rgba(0,0,0,.2); overflow: hidden;
  border: 1px solid var(--border-light);
}
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 22px 14px; border-bottom: 1px solid var(--border-light);
}
.modal-header h2 { font-size: 15px; font-weight: 500; font-family: Georgia, serif; color: var(--ink); }
.modal-close { background: none; border: none; color: var(--ink-faint); cursor: pointer; font-size: 14px; padding: 2px 5px; }
.modal-close:hover { color: var(--ink-mid); }
.modal-body   { padding: 18px 22px; }
.form-row     { margin-bottom: 18px; }
.form-row:last-child { margin-bottom: 0; }
.form-label   { display: block; font-size: 11px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--ink-muted); margin-bottom: 7px; }
.form-input   { width: 100%; border: 1px solid var(--border); border-radius: 7px; padding: 8px 11px; font-size: 14px; font-family: inherit; color: var(--ink); background: var(--bg); outline: none; transition: border-color .15s; }
.form-input:focus { border-color: var(--accent); background: var(--surface); }
.form-checks  { display: flex; flex-wrap: wrap; }
.form-note    { font-size: 12px; color: var(--ink-faint); margin-top: 10px; }
.modal-footer { display: flex; align-items: center; justify-content: flex-end; gap: 9px; padding: 14px 22px 18px; border-top: 1px solid var(--border-light); }
.modal-cancel { background: none; border: 1px solid var(--border); color: var(--ink-muted); padding: 7px 16px; border-radius: 7px; font-size: 13px; font-family: inherit; cursor: pointer; transition: all .15s; }
.modal-cancel:hover { border-color: var(--ink-mid); color: var(--ink-mid); }
.modal-submit { background: var(--accent); border: none; color: #fff; padding: 7px 18px; border-radius: 7px; font-size: 13px; font-weight: 500; font-family: inherit; cursor: pointer; transition: background .15s; }
.modal-submit:hover { background: var(--accent-dark); }

/* ── Filter toggle (mobile only) ───────────────────────────────────────────── */
.filter-toggle-btn { display: none; }

/* ── Test-bank mobile menu (☰) — mirrors the base.html nav dropdown ─────────── */
.tbm-hbg { display: none; background: none; border: none; color: var(--topbar-ink); font-size: 20px;
           cursor: pointer; padding: 4px 8px; line-height: 1; flex-shrink: 0; }
.tbm-menu { display: none; }
.tbm-item { display: flex; align-items: center; gap: 8px; width: 100%; padding: 11px 16px; font-size: 14px;
            color: var(--ink); text-decoration: none; background: none; border: none;
            border-bottom: 1px solid var(--border-light); font-family: inherit; cursor: pointer; text-align: left; }
.tbm-item:hover { background: var(--accent-tint); }
.tbm-menu > .tbm-item:last-child { border-bottom: none; }
.tbm-ic { width: 22px; font-size: 15px; flex-shrink: 0; text-align: center; }
.tbm-drop-toggle::after { content: '▾'; margin-left: auto; color: var(--ink-faint); }
.tbm-drop.expanded > .tbm-drop-toggle::after { content: '▴'; }
.tbm-sub { display: none; }
.tbm-drop.expanded .tbm-sub { display: block; }
.tbm-sub a { display: block; padding: 8px 16px 8px 46px; font-size: 13px; color: var(--ink-mid);
             text-decoration: none; border-bottom: 1px solid var(--border-light); }
.tbm-sub a:hover { background: var(--accent-tint); color: var(--accent); }

/* ── Mobile ─────────────────────────────────────────────────────────────────── */
@media (max-width: 640px) {
  /* Sidebar: slide-in overlay */
  .sidebar {
    position: fixed;
    top: 52px;
    left: -256px;
    z-index: 150;
    height: calc(100vh - 52px);
    transition: left .25s cubic-bezier(.4,0,.2,1);
    box-shadow: 4px 0 20px rgba(0,0,0,.2);
  }
  .sidebar.open { left: 0; }
  .sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    top: 52px;
    background: rgba(0,0,0,.4);
    z-index: 140;
  }
  .sidebar-backdrop.open { display: block; }

  /* Layout: stack vertically, main takes full width */
  .layout { flex-direction: column; }
  .main { padding: 12px 14px 80px; }

  /* Test bank topbar elements */
  .speed-control { display: none; }
  .theme-switcher { display: none; }   /* theme lives in the ☰ menu context on mobile */
  .filter-toggle-btn {
    display: flex;
    align-items: center;
    gap: 5px;
    background: none;
    border: 1px solid rgba(255,255,255,.25);
    color: var(--topbar-ink);
    padding: 4px 10px;
    border-radius: 5px;
    font-size: 12px;
    font-family: inherit;
    cursor: pointer;
    white-space: nowrap;
    opacity: .8;
    flex-shrink: 0;
  }
  .filter-toggle-btn:hover { opacity: 1; border-color: rgba(255,255,255,.5); }

  /* Mobile ☰ menu shows; opens as a fixed dropdown top-right */
  .tbm-hbg { display: flex; align-items: center; justify-content: center; }
  .tbm-menu { position: fixed; top: 52px; right: 0; width: 224px; max-height: calc(100vh - 52px);
              overflow-y: auto; background: var(--surface); border: 1px solid var(--border);
              border-radius: 0 0 0 12px; box-shadow: -4px 8px 24px rgba(0,0,0,.18); z-index: 200; padding: 6px 0; }
  .tbm-menu.open { display: block; }

  /* Shrink Export/Assign buttons to icon-only */
  .hw-btn { font-size: 0; padding: 6px 8px; gap: 0; }
  .hw-btn svg { display: block; width: 16px; height: 16px; }
  .hw-btn .hw-count { font-size: 10px; }

  /* Audio bar: compact */
  .audiobar { padding: 0 10px; gap: 8px; }
  .ab-info { flex: 0 0 auto; max-width: 120px; min-width: 0; }
  .ab-text { font-size: 12px; }
  .ab-accent { display: none; }
  .ab-num { display: none; }

  /* Cards */
  .card { padding: 14px 14px 12px; }
  .card-text { font-size: 15px; }

  /* Modal: full-width on small screens */
  .modal-overlay { padding: 12px; }
  .modal { max-width: 100%; }

  /* Hide testbank task nav pills that overflow on narrow screens */
  .tabnav-pills { display: none !important; }
  .tasknav { display: none !important; }
  /* Reduce right-side clutter on small phones */
  .theme-switcher { display: none; }
  .divider-v { display: none; }
}
