  @import url('https://fonts.googleapis.com/css2?family=Noto+Sans+JP:wght@300;400;500;700;900&family=Inter:wght@400;500;600;700;800&display=swap');

  /* ============================================================================
   * listening_styles.css — N3 Listening Lab
   * Warm washi-paper theme matching the redesigned N3Hub homepage.
   * Listening's signature accent: muted purple (its hub card colour).
   * ==========================================================================*/

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

  :root {
    /* base surfaces */
    --bg:        #f6f2ea;
    --bg2:       #f1ece0;
    --paper:     #f3eee2;        /* inset / secondary surface */
    --card:      #fffdf9;        /* primary card surface */
    --card2:     #faf6ec;        /* elevated / hover surface */
    --glass:     #fffdf9;
    --glass-hi:  #faf6ec;

    /* lines & text */
    --border:       #ddd5c4;
    --border-soft:  #eae3d4;
    --muted:        #7d776a;
    --ink:          #1c1a16;
    --text:         #1c1a16;
    --text-bright:  #1c1a16;

    /* accent system — purple primary */
    --accent:       #8a76b8;
    --accent-2:     #3b5ba9;
    --accent-soft:  rgba(138,118,184,0.10);
    --accent-line:  rgba(138,118,184,0.40);
    --grad:         #8a76b8;

    /* semantic colours */
    --green:       #5f9468;  --green-soft:  rgba(95,148,104,0.10);
    --orange:      #b0813f;  --orange-soft: rgba(176,129,63,0.10);
    --blue:        #3b5ba9;  --blue-soft:   rgba(59,91,169,0.09);
    --indigo:      #8a76b8;
    --red:         #c8402f;
    --success:     #5f9468;

    --shadow:    0 1px 2px rgba(30,25,20,0.05);
    --shadow-lg: 0 14px 36px rgba(30,25,20,0.12);
    --glow:      0 0 0 1px rgba(138,118,184,0.25);
    --radius:    10px;
    --radius-sm: 8px;
  }

  html { height: 100%; }
  body {
    font-family: 'Inter', 'Noto Sans JP', sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    font-size: 14px;
    line-height: 1.5;
    overflow-x: hidden;
  }
  .app { display: flex; flex-direction: column; min-height: 100vh; }

  ::-webkit-scrollbar { width: 9px; height: 9px; }
  ::-webkit-scrollbar-track { background: transparent; }
  ::-webkit-scrollbar-thumb { background: #d8d0bf; border-radius: 6px; border: 2px solid transparent; background-clip: padding-box; }
  ::-webkit-scrollbar-thumb:hover { background: #c9c0ab; background-clip: padding-box; }

  /* ── Header ── */
  .header {
    background: var(--glass);
    color: var(--text);
    padding: 0 1.25rem;
    height: 56px;
    display: flex; align-items: center; justify-content: space-between;
    position: sticky; top: 0; z-index: 200;
    gap: 1rem;
    border-bottom: 1px solid var(--border);
  }
  .header-left { display: flex; align-items: center; gap: 10px; }
  .hub-link {
    display: inline-flex; align-items: center; gap: 5px; flex-shrink: 0;
    font-size: 0.72rem; font-weight: 600; text-decoration: none; white-space: nowrap;
    color: var(--muted); background: var(--paper);
    border: 1px solid var(--border); border-radius: 8px; padding: 6px 10px;
    transition: all 0.18s;
  }
  .hub-link:hover {
    color: var(--text); background: var(--accent-soft); border-color: var(--accent-line);
  }
  .header-logo {
    font-size: 1.02rem; font-weight: 800; letter-spacing: -0.02em; white-space: nowrap;
    font-family: 'Noto Sans JP', sans-serif;
    color: var(--ink);
  }
  .header-logo span { color: var(--accent); font-weight: 400; }
  .header-badge {
    background: var(--accent-soft); color: var(--accent); font-size: 0.58rem; font-weight: 700;
    padding: 3px 7px; border-radius: 6px; letter-spacing: 0.08em; flex-shrink: 0;
    border: 1px solid var(--accent-line);
  }
  .header-right { display: flex; align-items: center; gap: 8px; }
  .header-icon-btn {
    width: 34px; height: 34px; border-radius: 9px; border: 1px solid transparent;
    background: var(--paper); color: var(--muted);
    cursor: pointer; font-size: 0.9rem; display: flex; align-items: center; justify-content: center;
    transition: all 0.18s;
  }
  .header-icon-btn:hover, .header-icon-btn.active-hdr {
    background: var(--accent-soft); color: var(--text); border-color: var(--accent-line);
  }
  .header-vv {
    display: flex; align-items: center; gap: 6px;
    font-size: 0.72rem; color: var(--muted); cursor: pointer; transition: all 0.15s;
    padding: 5px 9px; border-radius: 8px;
  }
  .header-vv:hover { color: var(--text); background: var(--paper); }
  .status-dot { width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0; }
  .status-dot.ok { background: var(--green); }
  .status-dot.err { background: var(--red); }
  .status-dot.checking { background: var(--orange); animation: blink 1s infinite; }
  @keyframes blink { 0%,100%{opacity:1} 50%{opacity:0.3} }

  /* ── Session stats bar ── */
  .session-bar {
    background: var(--bg2);
    color: var(--muted);
    padding: 0 1.25rem; height: 36px;
    display: flex; align-items: center; gap: 1.5rem;
    font-size: 0.7rem; border-bottom: 1px solid var(--border-soft);
    overflow-x: auto; white-space: nowrap;
  }
  .session-stat { display: flex; align-items: center; gap: 5px; }
  .session-stat strong { color: var(--text-bright); font-weight: 700; }
  .session-divider { width: 1px; height: 14px; background: var(--border); flex-shrink: 0; }
  .session-reset {
    margin-left: auto; flex-shrink: 0;
    background: var(--card); color: var(--muted);
    border: 1px solid var(--border); border-radius: 8px;
    font-size: 0.66rem; font-weight: 600; padding: 4px 10px; cursor: pointer;
    transition: all 0.15s; font-family: inherit;
  }
  .session-reset:hover { background: rgba(200,64,47,0.08); color: var(--red); border-color: rgba(200,64,47,0.4); }

  /* ── Progress: best score + bookmarks ── */
  .ai-best {
    padding: 1px 6px; border-radius: 5px; font-size: 0.6rem; font-weight: 700;
    background: var(--green-soft); color: var(--green); letter-spacing: 0.02em;
    border: 1px solid rgba(95,148,104,0.3);
  }
  .audio-item.active .ai-best { background: rgba(255,255,255,0.2); color: white; border-color: transparent; }
  .bookmark-btn {
    background: none; border: none; cursor: pointer; font-size: 1.05rem;
    line-height: 1; padding: 0 2px; vertical-align: middle; color: var(--orange);
    transition: transform 0.12s;
  }
  .bookmark-btn:hover { transform: scale(1.25); }
  .bookmark-btn.saved { filter: none; }

  /* ── Layout ── */
  .body-layout { display: flex; flex: 1; min-height: 0; }

  /* ── Left nav (modes) ── */
  .mode-nav {
    width: 70px;
    background: var(--bg2);
    border-right: 1px solid var(--border-soft);
    display: flex; flex-direction: column; align-items: center;
    padding: 12px 0;
    gap: 3px;
    height: calc(100vh - 92px);
    position: sticky; top: 92px;
    overflow-y: auto;
    flex-shrink: 0;
  }
  .mode-nav-btn {
    width: 52px; height: 52px; border-radius: 12px; border: 1px solid transparent;
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    cursor: pointer; background: transparent; color: var(--muted);
    transition: all 0.18s; gap: 3px; padding: 5px; position: relative;
  }
  .mode-nav-btn:hover { background: var(--card); color: var(--text); }
  .mode-nav-btn.active { background: var(--accent-soft); color: var(--text); border-color: var(--accent-line); }
  .mode-nav-btn.active::before {
    content: ''; position: absolute; left: -1px; top: 50%; transform: translateY(-50%);
    width: 3px; height: 26px; background: var(--accent); border-radius: 0 3px 3px 0;
  }
  .mode-nav-icon { font-size: 1.15rem; line-height: 1; }
  .mode-nav-label { font-size: 0.42rem; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase; text-align: center; line-height: 1.2; }
  .mode-nav-divider { width: 32px; height: 1px; background: var(--border); margin: 5px 0; }

  /* ── Sidebar (content list) ── */
  .sidebar {
    width: 274px;
    background: var(--bg2);
    border-right: 1px solid var(--border-soft);
    height: calc(100vh - 92px);
    position: sticky; top: 92px;
    overflow-y: auto;
    flex-shrink: 0;
    display: flex; flex-direction: column;
  }
  .sidebar-header {
    padding: 12px 12px 9px;
    border-bottom: 1px solid var(--border-soft);
    position: sticky; top: 0; background: var(--bg2);
    z-index: 10; flex-shrink: 0;
  }
  .sidebar-search {
    width: 100%; padding: 8px 10px 8px 30px;
    border: 1px solid var(--border); border-radius: 8px;
    font-family: inherit; font-size: 0.78rem; outline: none;
    background: var(--card); color: var(--text);
    transition: all 0.18s;
    margin-bottom: 8px;
  }
  .sidebar-search::placeholder { color: var(--muted); }
  .sidebar-search:focus { border-color: var(--accent); background: var(--card); box-shadow: 0 0 0 3px var(--accent-soft); }
  .sidebar-search-wrap { position: relative; }
  .sidebar-search-icon { position: absolute; left: 9px; top: 50%; transform: translateY(-50%); font-size: 0.8rem; opacity: 0.4; pointer-events: none; }
  .sidebar-filters { display: flex; gap: 4px; flex-wrap: wrap; }
  .filter-chip {
    padding: 4px 10px; border-radius: 999px; border: 1px solid var(--border);
    background: var(--card); font-size: 0.68rem; font-weight: 600; cursor: pointer;
    transition: all 0.15s; color: var(--muted);
  }
  .filter-chip.active { background: var(--accent); color: white; border-color: var(--accent); }
  .filter-chip:hover:not(.active) { border-color: var(--accent-line); color: var(--text); }
  .diff-chip-easy.active   { background: var(--green); border-color: var(--green); }
  .diff-chip-medium.active { background: var(--orange); border-color: var(--orange); }
  .diff-chip-hard.active   { background: var(--red); border-color: var(--red); }
  .sidebar-count { font-size: 0.68rem; color: var(--muted); padding: 7px 12px 2px; flex-shrink: 0; }
  .sidebar-list { padding: 6px; flex: 1; overflow-y: auto; }
  .sidebar-empty { padding: 2rem 1rem; text-align: center; font-size: 0.78rem; color: var(--muted); }

  .audio-item {
    padding: 10px; border-radius: var(--radius-sm); cursor: pointer;
    transition: all 0.15s; margin-bottom: 3px;
    display: flex; align-items: flex-start; gap: 9px;
    border: 1px solid transparent;
  }
  .audio-item:hover { background: var(--card); border-color: var(--border); }
  .audio-item.active { background: var(--accent); color: white; border-color: transparent; }
  .audio-item.active .ai-meta { color: rgba(255,255,255,0.78); }
  .audio-item.active .diff-dot { outline: 2px solid rgba(255,255,255,0.4); }
  .ai-icon { font-size: 1.1rem; flex-shrink: 0; margin-top: 2px; }
  .ai-body { flex: 1; min-width: 0; }
  .ai-title { font-size: 0.83rem; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-family: 'Noto Sans JP', sans-serif; }
  .ai-title-en { font-size: 0.68rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; opacity: 0.6; margin-top: 1px; }
  .ai-meta { font-size: 0.65rem; color: var(--muted); margin-top: 4px; display: flex; gap: 5px; align-items: center; flex-wrap: wrap; }
  .diff-dot { width: 6px; height: 6px; border-radius: 50%; flex-shrink: 0; display: inline-block; }
  .len-badge {
    padding: 1px 6px; border-radius: 5px; font-size: 0.6rem; font-weight: 700;
    background: var(--paper); border: 1px solid var(--border); letter-spacing: 0.04em; color: var(--muted);
  }
  .audio-item.active .len-badge { background: rgba(255,255,255,0.18); border-color: transparent; color: white; }
  .audio-item.active .ai-title-en { opacity: 0.7; }

  /* ── Main content ── */
  .content { flex: 1; padding: 1.6rem 2rem; overflow-y: auto; max-width: 840px; }

  /* ── Setup / VoiceVox panel ── */
  .setup-panel {
    background: var(--accent-soft);
    border: 1px solid var(--accent-line); border-radius: var(--radius);
    padding: 1.25rem; margin-bottom: 1.5rem;
  }
  .setup-panel h3 { font-size: 0.88rem; font-weight: 700; margin-bottom: 8px; color: var(--accent-2); display: flex; align-items: center; gap: 6px; }
  .setup-steps { font-size: 0.79rem; color: var(--text); line-height: 2; }
  .setup-steps code { background: var(--paper); padding: 1px 6px; border-radius: 5px; font-family: monospace; color: var(--accent-2); }
  .url-row { display: flex; gap: 8px; margin-top: 10px; }
  .url-input { flex: 1; padding: 8px 11px; border: 1px solid var(--border); border-radius: 8px; font-family: monospace; font-size: 0.82rem; outline: none; background: var(--card); color: var(--text); }
  .url-input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

  /* ── Audio placeholder zone ── */
  .audio-placeholder {
    background: var(--paper);
    border: 1.5px dashed var(--border); border-radius: var(--radius);
    padding: 1.1rem 1.25rem; margin-bottom: 1.25rem;
    display: flex; align-items: center; gap: 12px;
  }
  .audio-placeholder-icon { font-size: 1.6rem; flex-shrink: 0; opacity: 0.4; }
  .audio-placeholder-text { flex: 1; }
  .audio-placeholder-text strong { font-size: 0.82rem; color: var(--text); display: block; }
  .audio-placeholder-text span { font-size: 0.72rem; color: var(--muted); font-family: monospace; }

  /* ── Content header ── */
  .content-header {
    background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
    padding: 1.3rem 1.5rem; margin-bottom: 1rem; box-shadow: var(--shadow);
    position: relative; overflow: hidden;
  }
  .content-header::before {
    content: ''; position: absolute; top: 0; left: 0; right: 0; height: 3px; background: var(--accent); opacity: 0.75;
  }
  .content-header h1 {
    font-size: 1.35rem; font-weight: 800; letter-spacing: -0.02em; color: var(--text-bright);
    font-family: 'Noto Sans JP', sans-serif;
  }
  .content-header .sub { color: var(--muted); font-size: 0.78rem; margin-top: 4px; }
  .meta-row { display: flex; gap: 6px; margin-top: 12px; flex-wrap: wrap; align-items: center; }
  .meta-tag {
    padding: 4px 10px; border-radius: 7px; font-size: 0.68rem; font-weight: 600;
    border: 1px solid var(--border); background: var(--paper); color: var(--muted);
    display: inline-flex; align-items: center; gap: 4px;
  }
  .meta-tag.diff-easy   { border-color: rgba(95,148,104,0.4);  background: var(--green-soft);  color: var(--green); }
  .meta-tag.diff-medium { border-color: rgba(176,129,63,0.4);  background: var(--orange-soft); color: var(--orange); }
  .meta-tag.diff-hard   { border-color: rgba(200,64,47,0.4);   background: rgba(200,64,47,0.08); color: var(--red); }
  .speaker-chips { display: flex; gap: 6px; margin-top: 10px; flex-wrap: wrap; align-items: center; }
  .speaker-chip {
    display: inline-flex; align-items: center; gap: 5px;
    padding: 4px 11px; border-radius: 999px; font-size: 0.72rem; font-weight: 600;
    border: 1.5px solid; transition: all 0.15s;
  }
  .speaker-avatar { font-size: 0.85rem; }
  .cache-info { margin-left: auto; font-size: 0.68rem; color: var(--muted); display: flex; align-items: center; gap: 5px; }
  .cache-bar-bg { width: 50px; height: 4px; background: var(--border); border-radius: 2px; }
  .cache-bar-fill { height: 100%; background: var(--green); border-radius: 2px; transition: width 0.3s; }

  /* ── Mode tabs ── */
  .mode-tabs {
    display: flex; gap: 3px; background: var(--paper); padding: 4px; border-radius: 9px;
    margin-bottom: 1rem; width: fit-content; border: 1px solid var(--border);
  }
  .mode-tab {
    padding: 7px 18px; border-radius: 7px; border: none; cursor: pointer;
    font-family: inherit; font-size: 0.78rem; font-weight: 600;
    background: transparent; color: var(--muted); transition: all 0.18s;
    white-space: nowrap; display: flex; align-items: center; gap: 5px;
  }
  .mode-tab:hover:not(.active) { color: var(--text); }
  .mode-tab.active { background: var(--accent); color: white; }

  /* ── Playback bar ── */
  .playback-bar {
    background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
    padding: 12px 16px; margin-bottom: 1rem;
    display: flex; align-items: center; gap: 12px; box-shadow: var(--shadow);
    flex-wrap: wrap;
  }
  .play-btn {
    width: 44px; height: 44px; border-radius: 50%; border: none;
    background: var(--accent); color: white; font-size: 1rem;
    cursor: pointer; display: flex; align-items: center; justify-content: center;
    flex-shrink: 0; transition: transform 0.12s, box-shadow 0.18s;
  }
  .play-btn:hover:not(:disabled) { transform: scale(1.08); }
  .play-btn:disabled { background: var(--border); cursor: default; transform: none; box-shadow: none; }
  .play-btn.playing { background: var(--red); }
  .progress-wrap { flex: 1; min-width: 120px; }
  .progress-bg { height: 6px; background: var(--paper); border: 1px solid var(--border); border-radius: 4px; cursor: pointer; overflow: hidden; }
  .progress-fill { height: 100%; background: var(--accent); border-radius: 4px; transition: width 0.18s ease; }
  .progress-info { display: flex; justify-content: space-between; font-size: 0.67rem; color: var(--muted); margin-top: 4px; }
  .speed-group { display: flex; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
  .speed-btn {
    padding: 5px 10px; border: none; border-right: 1px solid var(--border);
    background: var(--card); cursor: pointer; font-family: inherit; font-size: 0.7rem; font-weight: 700;
    color: var(--muted); transition: all 0.12s;
  }
  .speed-btn:last-child { border-right: none; }
  .speed-btn:hover { background: var(--card2); color: var(--text); }
  .speed-btn.active-speed { background: var(--accent); color: white; }
  .ctrl-btn {
    padding: 6px 13px; border-radius: 8px; border: none; cursor: pointer;
    font-family: inherit; font-size: 0.74rem; font-weight: 600; transition: all 0.18s; white-space: nowrap;
  }
  .ctrl-btn-secondary { background: var(--card); color: var(--text); border: 1px solid var(--border); }
  .ctrl-btn-secondary:hover { border-color: var(--accent-line); background: var(--card2); }
  .ctrl-btn-primary { background: var(--accent); color: white; }
  .ctrl-btn-primary:hover { filter: brightness(1.08); }
  .ctrl-btn-primary:disabled { background: var(--border); color: var(--muted); cursor: default; box-shadow: none; }

  /* ── Transcript ── */
  .transcript { display: flex; flex-direction: column; gap: 3px; }
  .line-row {
    display: flex; gap: 10px; padding: 11px 13px; border-radius: var(--radius-sm);
    cursor: pointer; transition: all 0.14s; align-items: flex-start;
    border: 1px solid transparent; position: relative;
  }
  .line-row:hover { background: var(--card); }
  .line-row.active-line { border-color: var(--accent-line); background: var(--accent-soft); }
  .line-row.playing-line { background: var(--accent-soft); box-shadow: inset 3px 0 0 var(--accent); }
  .playing-wave {
    position: absolute; right: 10px; top: 50%; transform: translateY(-50%);
    display: flex; align-items: center; gap: 2px;
  }
  .playing-wave span {
    width: 3px; background: var(--accent); border-radius: 2px; opacity: 0.8;
    animation: wave 0.8s ease-in-out infinite;
  }
  .playing-wave span:nth-child(1) { height: 8px; animation-delay: 0s; }
  .playing-wave span:nth-child(2) { height: 13px; animation-delay: 0.12s; }
  .playing-wave span:nth-child(3) { height: 6px; animation-delay: 0.24s; }
  @keyframes wave { 0%,100%{transform:scaleY(1)} 50%{transform:scaleY(0.4)} }
  .line-num { font-size: 0.62rem; color: var(--muted); min-width: 18px; margin-top: 4px; font-variant-numeric: tabular-nums; }
  .line-sdot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; margin-top: 5px; }
  .line-body { flex: 1; min-width: 0; }
  .line-speaker { font-size: 0.68rem; font-weight: 700; margin-bottom: 2px; opacity: 0.9; }
  .line-jp { font-size: 0.99rem; line-height: 1.65; font-family: 'Noto Sans JP', sans-serif; font-weight: 500; color: var(--text); }
  .line-en { font-size: 0.77rem; color: var(--muted); margin-top: 3px; line-height: 1.4; }
  .line-en.hidden { display: none; }

  /* ── Shadow mode ── */
  .shadowing-tip {
    background: var(--blue-soft); border: 1px solid rgba(59,91,169,0.3); border-radius: var(--radius-sm);
    padding: 11px 14px; font-size: 0.77rem; color: var(--accent-2); margin-bottom: 1rem; line-height: 1.55;
    display: flex; align-items: flex-start; gap: 8px;
  }
  .shadow-card {
    background: var(--card); border: 1px solid var(--border); border-radius: 14px;
    padding: 2.4rem 2rem; text-align: center; box-shadow: var(--shadow); max-width: 560px;
    position: relative; overflow: hidden;
  }
  .shadow-mode-label { font-size: 0.65rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.1em; margin-bottom: 12px; }
  .shadow-dots { display: flex; justify-content: center; gap: 7px; margin-bottom: 1.5rem; flex-wrap: wrap; }
  .shadow-dot { width: 9px; height: 9px; border-radius: 50%; cursor: pointer; flex-shrink: 0; transition: transform 0.12s; background: var(--border); }
  .shadow-dot:hover { transform: scale(1.4); }
  .shadow-dot.done { opacity: 0.4; }
  .shadow-speaker-badge {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 5px 13px; border-radius: 999px; border: 1.5px solid;
    font-size: 0.74rem; font-weight: 700; margin-bottom: 1.2rem;
  }
  .shadow-jp {
    font-size: 1.8rem; font-family: 'Noto Sans JP', sans-serif; font-weight: 700;
    line-height: 1.5; margin-bottom: 1.2rem; letter-spacing: 0.01em; color: var(--text-bright);
    position: relative;
  }
  .shadow-en { font-size: 0.93rem; color: var(--muted); margin-bottom: 1.5rem; line-height: 1.5; animation: fadeSlide 0.2s ease; position: relative; }
  @keyframes fadeSlide { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
  .shadow-nav { display: flex; justify-content: center; gap: 10px; align-items: center; flex-wrap: wrap; position: relative; }
  .shadow-progress { font-size: 0.75rem; color: var(--muted); margin-top: 12px; }
  .shadow-progress-bar { width: 100%; height: 4px; background: var(--paper); border-radius: 2px; margin-top: 8px; overflow: hidden; }
  .shadow-progress-fill { height: 100%; background: var(--accent); border-radius: 2px; transition: width 0.25s; }
  .btn { padding: 9px 19px; border-radius: var(--radius-sm); border: none; cursor: pointer; font-family: inherit; font-size: 0.82rem; font-weight: 600; transition: all 0.18s; }
  .btn-primary { background: var(--accent); color: white; }
  .btn-primary:hover { filter: brightness(1.08); transform: translateY(-1px); }
  .btn-primary:disabled { background: var(--border); color: var(--muted); cursor: default; box-shadow: none; transform: none; }
  .btn-secondary { background: var(--card); color: var(--text); border: 1px solid var(--border); }
  .btn-secondary:hover { border-color: var(--accent-line); background: var(--card2); }
  .reveal-btn {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 7px 16px; background: var(--card); border: 1.5px dashed var(--border);
    border-radius: var(--radius-sm); cursor: pointer; font-family: inherit; font-size: 0.78rem;
    font-weight: 600; color: var(--muted); transition: all 0.18s;
  }
  .reveal-btn:hover { border-color: var(--accent-line); color: var(--text); background: var(--card2); }

  /* ── Quiz ── */
  .quiz-wrap { max-width: 640px; }
  .quiz-intro { font-size: 0.79rem; color: var(--muted); margin-bottom: 1rem; line-height: 1.55; }
  .quiz-card {
    background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
    padding: 1.4rem; margin-bottom: 10px; box-shadow: var(--shadow);
    transition: box-shadow 0.18s, border-color 0.18s;
  }
  .quiz-card:has(.correct) { border-color: rgba(95,148,104,0.5); }
  .quiz-card:has(.wrong) { border-color: rgba(200,64,47,0.5); }
  .quiz-q-type {
    display: inline-flex; align-items: center; gap: 4px;
    font-size: 0.62rem; font-weight: 700; letter-spacing: 0.07em; text-transform: uppercase;
    color: var(--accent-2); background: var(--blue-soft); padding: 3px 9px; border-radius: 6px; margin-bottom: 8px;
    border: 1px solid rgba(59,91,169,0.25);
  }
  .quiz-q { font-size: 0.99rem; font-weight: 600; font-family: 'Noto Sans JP', sans-serif; line-height: 1.5; color: var(--text); }
  .quiz-q-en { font-size: 0.77rem; color: var(--muted); margin-top: 4px; margin-bottom: 14px; }
  .quiz-opts { display: flex; flex-direction: column; gap: 8px; }
  .quiz-opt {
    padding: 11px 15px; border-radius: var(--radius-sm); border: 1px solid var(--border);
    cursor: pointer; text-align: left; background: var(--card); font-family: 'Noto Sans JP', inherit;
    font-size: 0.88rem; transition: all 0.16s; display: flex; align-items: center; gap: 9px; color: var(--text);
  }
  .quiz-opt-label { font-size: 0.7rem; font-weight: 700; color: var(--muted); min-width: 16px; }
  .quiz-opt:hover:not(:disabled) { border-color: var(--accent-line); background: var(--card2); transform: translateX(2px); }
  .quiz-opt.correct { background: var(--green-soft); border-color: var(--green); color: var(--green); animation: correctPop 0.3s ease; }
  .quiz-opt.wrong { background: rgba(200,64,47,0.08); border-color: var(--red); color: var(--red); animation: wrongShake 0.35s ease; }
  .quiz-opt:disabled { cursor: default; }
  .quiz-opt .opt-icon { margin-left: auto; font-size: 0.9rem; }
  @keyframes correctPop { 0%{transform:scale(0.97)} 50%{transform:scale(1.02)} 100%{transform:scale(1)} }
  @keyframes wrongShake { 0%,100%{transform:translateX(0)} 25%{transform:translateX(-4px)} 75%{transform:translateX(4px)} }
  .quiz-result { text-align: center; padding: 2.6rem 2rem; background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
  .quiz-result-emoji { font-size: 3rem; margin-bottom: 10px; }
  .quiz-score { font-size: 3rem; font-weight: 800; letter-spacing: -0.04em; }
  .quiz-score.perfect { color: var(--green); }
  .quiz-score.good { color: var(--blue); }
  .quiz-score.retry { color: var(--red); }
  .quiz-result-msg { font-size: 1.1rem; font-weight: 700; margin: 6px 0; font-family: 'Noto Sans JP', sans-serif; color: var(--text-bright); }
  .quiz-result-sub { color: var(--muted); font-size: 0.82rem; margin-bottom: 1.5rem; }
  .quiz-result-actions { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }

  /* ── Mode overview (welcome) ── */
  .mode-overview {
    background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
    padding: 1.6rem; margin-bottom: 1.25rem; box-shadow: var(--shadow); overflow: hidden; position: relative;
  }
  .mode-overview-accent {
    position: absolute; top: 0; left: 0; right: 0; height: 3px;
  }
  .mode-overview-icon { font-size: 2.3rem; margin-bottom: 10px; }
  .mode-overview h2 { font-size: 1.08rem; font-weight: 700; margin-bottom: 4px; color: var(--text-bright); }
  .mode-overview-jp { font-family: 'Noto Sans JP', sans-serif; font-weight: 400; font-size: 0.88rem; color: var(--muted); }
  .mode-overview .desc { font-size: 0.8rem; color: var(--muted); margin: 8px 0 1.1rem; line-height: 1.6; }
  .mode-stats { display: flex; gap: 8px; flex-wrap: wrap; }
  .mode-stat { background: var(--paper); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 9px 14px; font-size: 0.75rem; flex: 1; min-width: 80px; color: var(--muted); }
  .mode-stat strong { display: block; font-size: 1.25rem; font-weight: 800; margin-bottom: 1px; color: var(--text-bright); }

  /* ── Character roster panel ── */
  .char-panel {
    background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
    padding: 1.3rem; margin-bottom: 1.25rem; box-shadow: var(--shadow);
  }
  .char-panel-title { font-weight: 700; font-size: 0.88rem; margin-bottom: 2px; color: var(--text-bright); }
  .char-panel-sub { font-size: 0.73rem; color: var(--muted); margin-bottom: 12px; }
  .char-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 9px; }
  .char-card {
    background: var(--paper); border: 1px solid var(--border); border-radius: var(--radius-sm);
    padding: 13px 10px; text-align: center;
    transition: all 0.16s;
  }
  .char-card:hover { box-shadow: var(--shadow); transform: translateY(-2px); border-color: var(--accent-line); }
  .char-avatar { font-size: 1.7rem; margin-bottom: 5px; }
  .char-name { font-weight: 700; font-size: 0.82rem; color: var(--text); }
  .char-name-jp { font-size: 0.82rem; font-family: 'Noto Sans JP', sans-serif; color: var(--muted); }
  .char-role { color: var(--muted); font-size: 0.67rem; margin-top: 3px; line-height: 1.35; }
  .char-id { font-size: 0.6rem; color: var(--muted); margin-top: 3px; opacity: 0.6; }
  .char-color-bar { width: 24px; height: 3px; border-radius: 2px; margin: 5px auto 0; }

  /* ── Responsive ── */
  @media (max-width: 960px) {
    .sidebar { width: 234px; }
    .content { padding: 1.25rem 1.5rem; }
  }
  @media (max-width: 780px) {
    .mode-nav { width: 58px; }
    .mode-nav-btn { width: 46px; height: 46px; }
    .sidebar { width: 212px; }
    .content { padding: 1rem 1.25rem; }
    .shadow-card { padding: 1.6rem 1.25rem; }
    .shadow-jp { font-size: 1.45rem; }
  }
  @media (max-width: 580px) {
    .body-layout { flex-direction: column; }
    .mode-nav {
      width: 100%; height: auto; flex-direction: row; flex-wrap: wrap;
      justify-content: flex-start; padding: 6px; position: static;
      border-right: none; border-bottom: 1px solid var(--border-soft);
    }
    .mode-nav-btn.active::before { display: none; }
    .sidebar { width: 100%; height: auto; position: static; border-right: none; border-bottom: 1px solid var(--border-soft); max-height: 260px; }
    .content { max-width: 100%; padding: 1rem; }
    .session-bar { display: none; }
    .hub-link-label { display: none; }   /* arrow only — header gets tight here */
  }

  /* ── Audio Cache Indicator & Download ── */
  .cached-badge {
    display: inline-flex; align-items: center; gap: 3px;
    font-size: 0.62rem; font-weight: 600;
    color: var(--green); background: var(--green-soft);
    padding: 2px 7px; border-radius: 6px; letter-spacing: 0.02em;
    border: 1px solid rgba(95,148,104,0.25);
  }
  .cached-badge::before { content: "✓"; font-weight: 700; }
  .partial-badge {
    display: inline-flex; align-items: center; gap: 3px;
    font-size: 0.62rem; font-weight: 500;
    color: var(--orange); background: var(--orange-soft);
    padding: 2px 7px; border-radius: 6px;
    border: 1px solid rgba(176,129,63,0.25);
  }
  .download-btn {
    display: inline-flex; align-items: center; gap: 5px;
    padding: 6px 11px; font-size: 0.72rem; font-weight: 600;
    color: white; background: var(--green);
    border: none; border-radius: 8px; cursor: pointer;
    transition: all 0.2s ease;
  }
  .download-btn:hover { transform: translateY(-1px); filter: brightness(1.06); }
  .download-btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }
  .clear-cache-btn {
    display: inline-flex; align-items: center; gap: 5px;
    padding: 6px 11px; font-size: 0.72rem; font-weight: 500;
    color: var(--muted); background: var(--card);
    border: 1px solid var(--border); border-radius: 8px; cursor: pointer;
    transition: all 0.2s ease;
  }
  .clear-cache-btn:hover { color: var(--red); border-color: rgba(200,64,47,0.4); background: rgba(200,64,47,0.07); }
  .cache-status-bar {
    display: flex; align-items: center; gap: 10px;
    padding: 7px 13px; background: var(--green-soft);
    border: 1px solid rgba(95,148,104,0.2); border-radius: 8px;
    margin-bottom: 10px; font-size: 0.75rem; color: var(--muted);
  }
  .cache-status-bar strong { color: var(--green); }
  .line-cached-icon { font-size: 0.7rem; color: var(--success); opacity: 0.8; }

  /* ── Practice Mode ── */
  .body-layout.practice-mode { flex-direction: column; }
  .body-layout.practice-mode .sidebar { display: none; }
  .body-layout.practice-mode .mode-nav {
    width: 100%;
    height: auto;
    position: static;
    flex-direction: row;
    flex-wrap: wrap;
    justify-content: flex-start;
    padding: 6px;
    border-right: none;
    border-bottom: 1px solid var(--border-soft);
  }
  .body-layout.practice-mode .mode-nav-btn.active::before { display: none; }
  .body-layout.practice-mode.practice-immersive .mode-nav { display: none; }
  .content.practice-content {
    flex: 1;
    max-width: 100%;
    padding: 0;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    min-height: 0;
  }
  .practice-panel {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    background: var(--bg2);
  }
  .practice-frame {
    width: 100%;
    flex: 1;
    min-height: 0;
    border: 0;
    background: transparent;
    display: block;
  }
  .practice-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--border-soft);
    background: var(--bg2);
    flex-shrink: 0;
  }
  .practice-content-area {
    flex: 1;
    overflow-y: auto;
    padding: 2rem;
  }
