/* ============ DESIGN TOKENS ============ */
      [hidden] { display: none !important; }
      :root {
        --ink: #30352c;
        --ink-soft: #4a4f42;
        --muted: #6e7463;
        --line: #e3e7d8;
        --line-strong: #d5dac7;
        --yellow: #efd46b;
        --yellow-deep: #e8bd34;
        --yellow-soft: #f7e9b1;
        --paper: #fcfcf9;
        --card: #ffffff;
        --sage: #a5b38e;
        --sage-soft: #eef1e4;
        --danger: #b3402e;
        --danger-soft: #f9e9e4;
        --ok: #4e7a3f;
        --ok-soft: #eaf2e2;
        --lav: #8d7fb0;
        --lav-soft: #ede9f4;
        --display: "Space Grotesk", "DM Sans", "Avenir Next", "Segoe UI", ui-sans-serif, system-ui, sans-serif;
        --body: "DM Sans", "Avenir Next", "Segoe UI", ui-sans-serif, system-ui, sans-serif;
        --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
        --radius: 14px;
        --radius-sm: 9px;
        --shadow: 0 1px 2px rgba(48, 53, 44, 0.05), 0 8px 28px -12px rgba(48, 53, 44, 0.18);
        --shadow-lift: 0 2px 4px rgba(48, 53, 44, 0.06), 0 16px 40px -14px rgba(48, 53, 44, 0.26);
        --sidebar-w: 262px;
        --soft: #f1f3e8;
        --footer-bg: #fafbf5;
        --sidebar-bg: #f6f7f1;
        --topbar-bg: rgba(252, 252, 249, 0.92);
        --danger-line: #e5c4bb;
        --yellow-hover: #f3dd8d;
        --yellow-ink-deep: #6d5a14;
        --yellow-line: #ecd98a;
        --hero-grad: linear-gradient(135deg, #fdfcf4 0%, #f7f3dd 58%, #f3ead0 100%);
        --hero-border: #ece4c2;
        --hero-chip-bg: rgba(255, 255, 255, 0.75);
        --hero-chip-line: #e8dfb5;
        --hero-chip-text: #6d6428;
        --dot: rgba(48, 53, 44, 0.055);
        color-scheme: light;
      }

      /* ============ BASE — BIGGER, FRIENDLIER TYPE ============ */
      * { box-sizing: border-box; }
      html { font-size: 17px; }
      @media (min-width: 1000px) { html { font-size: 18px; } }
      body {
        margin: 0;
        min-width: 320px;
        background: var(--paper);
        color: var(--ink);
        font-family: var(--body);
        line-height: 1.6;
        font-synthesis: none;
        text-rendering: optimizeLegibility;
        -webkit-font-smoothing: antialiased;
        -webkit-tap-highlight-color: transparent;
      }
      button, input, select, textarea { font: inherit; color: inherit; }
      button { cursor: pointer; transition: background 0.17s, border-color 0.17s, color 0.17s, transform 0.17s, box-shadow 0.17s; }
      button:disabled { cursor: default; }
      a { color: inherit; text-decoration: none; }
      svg { flex-shrink: 0; }
      h1, h2, h3, p { margin: 0; }
      h1, h2, h3 { font-family: var(--display); line-height: 1.22; letter-spacing: -0.015em; }
      ::selection { color: var(--ink-on-accent); background: #f1d982; }
      kbd { color: var(--ink-soft); }

      :focus-visible { outline: 2px solid var(--focus); outline-offset: 3px; border-radius: 4px; }

      /* Custom scrollbars */
      * { scrollbar-width: thin; scrollbar-color: var(--scrollbar) transparent; }
      *::-webkit-scrollbar { width: 10px; height: 10px; }
      *::-webkit-scrollbar-track { background: transparent; }
      *::-webkit-scrollbar-thumb { background: var(--scrollbar); border-radius: 8px; border: 3px solid transparent; background-clip: content-box; }
      *::-webkit-scrollbar-thumb:hover { background: var(--scrollbar-hover); border: 3px solid transparent; background-clip: content-box; }

      .mono { font-family: var(--mono); }
      .eyebrow, .column-label, .breakdown-cap, .sc-cap, .fc-scene-tag, .quiet-tag { text-transform: uppercase; }

      .skip-link {
        z-index: 300; background: var(--yellow); color: var(--ink-on-accent); font-weight: 650;
        border-radius: 8px; padding: 12px 22px; position: fixed; top: -70px; left: 16px;
        transition: top 0.2s;
      }
      .skip-link:focus { top: 12px; }

      /* ============ APP SHELL ============ */
      .app-shell { min-height: 100vh; }

      .mobile-topbar {
        display: none; position: sticky; top: 0; z-index: 60;
        background: var(--topbar-bg); backdrop-filter: blur(10px);
        border-bottom: 1px solid var(--line);
        align-items: center; justify-content: space-between; gap: 12px;
        padding: 10px 16px;
      }
      .menu-btn {
        display: grid; place-items: center; width: 44px; height: 44px;
        background: transparent; border: 1px solid var(--line-strong); border-radius: 10px; color: var(--ink);
      }
      .menu-btn:hover { background: var(--sage-soft); }
      .mobile-brand { display: flex; align-items: center; gap: 9px; font-family: var(--display); font-weight: 700; font-size: 1.1rem; letter-spacing: -0.02em; }
      .topbar-due {
        display: inline-flex; align-items: center; gap: 6px; font-size: 0.8rem; font-weight: 650;
        background: var(--yellow-soft); border: 1px solid var(--yellow-line); color: var(--yellow-ink-deep);
        padding: 6px 11px; border-radius: 999px; cursor: pointer;
      }
      .topbar-due:hover { background: var(--yellow-hover); }
      #view:focus { outline: none; }

      .sidebar {
        z-index: 90; background: var(--sidebar-bg); border-right: 1px solid var(--line);
        flex-direction: column; width: var(--sidebar-w); padding: 26px 16px 18px;
        display: flex; position: fixed; top: 0; bottom: 0; left: 0; overflow-y: auto;
      }
      .sidebar-brand { justify-content: space-between; align-items: center; margin-bottom: 34px; padding: 0 8px; display: flex; }
      .brand {
        font-family: var(--display); letter-spacing: -0.03em; white-space: nowrap;
        align-items: center; gap: 10px; font-size: 1.35rem; font-weight: 700; display: flex;
      }
      .brand-mark { background: var(--yellow); border-radius: 11px; place-items: center; width: 40px; height: 40px; display: grid; box-shadow: inset 0 -2px 0 rgba(48,53,44,0.08); }
      .brand-study { font-weight: 450; color: var(--muted); }
      .brand-dot { color: var(--accent-strong); }

      .workspace-label {
        color: var(--muted); letter-spacing: 0.16em; align-items: center; gap: 8px;
        margin-bottom: 14px; padding: 0 13px; font-size: 0.66rem; font-weight: 700;
        display: flex; text-transform: uppercase;
      }
      .workspace-dot { background: var(--sage); border-radius: 100%; width: 6px; height: 6px; }

      .study-nav { flex-direction: column; gap: 4px; display: flex; }
      .nav-item {
        text-align: left; color: var(--muted); background: 0 0; border: 0; border-radius: 10px;
        align-items: center; gap: 13px; width: 100%; min-height: 48px; padding: 10px 13px;
        font-size: 0.94rem; font-weight: 500; display: flex; position: relative;
      }
      .nav-item:hover { color: var(--ink); background: var(--soft); }
      .nav-item.active { color: var(--selected-text); background: var(--selected-bg); font-weight: 700; box-shadow: inset 0 -2px 0 rgba(48,53,44,0.06); }
      .nav-count {
        text-align: center; min-width: 22px; height: 22px; padding: 0 7px;
        border-radius: 999px; background: var(--soft); color: var(--ink-soft);
        font-size: 0.72rem; font-weight: 700; line-height: 22px; margin-left: auto;
        font-family: var(--mono);
      }
      .nav-item.active .nav-count { background: var(--selected-count-bg); color: var(--selected-text); }
      .nav-section { display: flex; align-items: center; gap: 10px; margin: 16px 4px 6px; font-size: 0.68rem; font-weight: 800; letter-spacing: 0.16em; text-transform: uppercase; color: var(--muted); }
      .nav-section::after { content: ''; flex: 1; height: 1px; background: var(--line); }
      .nav-due-badge {
        position: absolute; top: 7px; right: 9px; width: 10px; height: 10px; border-radius: 50%;
        background: var(--danger); border: 2px solid var(--sidebar-bg);
      }
      .nav-item.active .nav-due-badge { border-color: var(--yellow); }

      .sidebar-foot { margin-top: auto; padding: 18px 10px 4px; display: flex; flex-direction: column; gap: 10px; }

      .sidebar-overlay {
        display: none; position: fixed; inset: 0; z-index: 80;
        background: rgba(48, 53, 44, 0.4); backdrop-filter: blur(2px);
      }
      body.nav-open .sidebar-overlay { display: block; }

      .main-area {
        margin-left: var(--sidebar-w); min-height: 100vh; display: flex; flex-direction: column;
      }
      .view-wrap { flex: 1 0 auto; width: 100%; max-width: 1180px; margin: 0 auto; padding: 34px 36px 46px; }

      .app-footer {
        flex-shrink: 0; margin-top: auto; border-top: 1px solid var(--line);
        padding: 18px 36px calc(18px + env(safe-area-inset-bottom, 0px));
        display: flex; flex-wrap: wrap; gap: 8px 22px; align-items: center; justify-content: space-between;
        color: var(--muted); font-size: 0.8rem; background: var(--footer-bg);
      }
      .app-footer .foot-brand { display: flex; align-items: center; gap: 7px; font-family: var(--display); font-weight: 700; color: var(--muted); }

      @media (max-width: 900px) {
        .mobile-topbar { display: flex; }
        .selection-toolbar { top: calc(60px + 12px); }
        .sidebar {
          transform: translateX(-104%); transition: transform 0.24s ease; width: min(86vw, 300px);
          box-shadow: var(--shadow-lift);
        }
        body.nav-open .sidebar { transform: translateX(0); }
        .main-area { margin-left: 0; }
        .view-wrap { padding: 22px 16px 34px; }
        .app-footer { padding: 14px 16px calc(14px + env(safe-area-inset-bottom, 0px)); }
      }

      /* ============ SHARED UI ============ */
      .eyebrow {
        display: inline-block; color: var(--accent-text); letter-spacing: 0.18em; text-transform: uppercase;
        font-size: 0.72rem; font-weight: 800; margin-bottom: 8px;
      }
      .quiet-tag {
        align-self: center; color: var(--muted); background: #f2f4ea; border: 1px solid var(--line);
        border-radius: 999px; padding: 7px 14px; font-size: 0.76rem; font-weight: 700;
        letter-spacing: 0.09em; text-transform: uppercase; white-space: nowrap;
      }

      .section-toolbar {
        display: flex; gap: 16px; align-items: flex-start; justify-content: space-between;
        margin-bottom: 20px; flex-wrap: wrap;
      }
      .section-toolbar h2 { font-size: 1.55rem; }
      .section-toolbar .section-sub { color: var(--muted); margin-top: 3px; font-size: 0.98rem; }
      .toolbar-actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }

      .button {
        display: inline-flex; align-items: center; justify-content: center; gap: 9px;
        border-radius: 11px; border: 1px solid transparent; font-weight: 650; font-size: 0.95rem;
        padding: 12px 20px; min-height: 47px; line-height: 1.2;
      }
      .button.primary { background: var(--primary-bg); color: var(--primary-text); box-shadow: inset 0 -2px 0 rgba(0,0,0,0.25); }
      .button.primary:hover:not(:disabled) { background: var(--primary-hover); }
      .button.yellow { background: var(--yellow); color: var(--ink-on-accent); box-shadow: inset 0 -2px 0 rgba(48,53,44,0.1); }
      .button.yellow:hover:not(:disabled) { background: #f3dc7e; }
      .button.secondary { background: var(--card); border-color: var(--line-strong); color: var(--ink-soft); }
      .button.secondary:hover:not(:disabled) { border-color: var(--line-strong); background: var(--soft); }
      .button.danger-button { background: var(--card); border-color: var(--danger-line); color: var(--danger); }
      .button.danger-button:hover:not(:disabled) { background: var(--danger-soft); }
      .button:disabled { opacity: 0.45; cursor: not-allowed; box-shadow: none; }
      .button.small-button { min-height: 40px; padding: 8px 14px; font-size: 0.86rem; border-radius: 9px; }
      .text-button {
        display: inline-flex; align-items: center; gap: 7px; background: none; border: 0;
        color: var(--ink-soft); font-weight: 650; font-size: 0.9rem; padding: 9px 11px; border-radius: 8px;
        min-height: 44px;
      }
      .text-button:hover { background: var(--soft); color: var(--ink); }

      .select-wrap { position: relative; display: inline-flex; align-items: center; }
      .select-wrap select {
        appearance: none; -webkit-appearance: none; background: var(--card); border: 1px solid var(--line-strong);
        border-radius: 10px; padding: 11px 40px 11px 14px; font-weight: 600; font-size: 0.92rem;
        color: var(--ink-soft); min-height: 47px; max-width: 100%; cursor: pointer;
      }
      .select-wrap select:hover { border-color: var(--line-strong); }
      .select-wrap svg { position: absolute; right: 13px; pointer-events: none; color: var(--muted); }

      input[type="text"], input[type="search"], textarea {
        background: var(--card); border: 1px solid var(--line-strong); border-radius: 11px;
        padding: 12px 15px; font-size: 1rem; color: var(--ink); width: 100%;
      }
      input[type="text"]:focus, input[type="search"]:focus, textarea:focus, .select-wrap select:focus {
        outline: 2px solid var(--focus); outline-offset: 1px; border-color: var(--focus);
      }
      textarea { resize: vertical; line-height: 1.6; }
      label { font-size: 0.88rem; font-weight: 700; color: var(--ink-soft); }

      .activity-instructions {
        display: flex; align-items: center; gap: 12px; background: var(--sage-soft);
        border: 1px solid var(--line); border-radius: 12px; padding: 13px 17px; margin-bottom: 18px;
        color: var(--sage-text); font-size: 0.95rem;
      }
      .activity-instructions p { flex: 1; }
      .activity-instructions span { font-weight: 800; font-family: var(--mono); font-size: 0.85rem; color: var(--sage-text); white-space: nowrap; }

      .match-progress { height: 9px; background: var(--track); border-radius: 999px; overflow: hidden; margin-bottom: 22px; border: 1px solid var(--line); }
      .match-progress i { display: block; height: 100%; background: linear-gradient(90deg, var(--yellow), var(--yellow-deep)); border-radius: 999px; transition: width 0.35s ease; }

      .technique-footer {
        display: flex; gap: 14px; margin-top: 26px; background: var(--subtle-surface); border: 1px solid var(--line);
        border-radius: 13px; padding: 16px 18px; color: var(--muted); font-size: 0.92rem;
      }
      .technique-footer svg { color: var(--accent-strong); margin-top: 2px; }
      .technique-footer strong { color: var(--ink); display: block; margin-bottom: 2px; font-size: 0.95rem; }
      .technique-footer p { line-height: 1.55; }

      .empty-note { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 18px; color: var(--muted); font-size: 0.92rem; line-height: 1.6; }
      .empty-cta { text-align: center; color: var(--muted); background: var(--card); border: 1.5px dashed var(--line-strong); border-radius: 16px; padding: 38px 24px; font-size: 1rem; max-width: 560px; margin: 24px auto; }
      .empty-cta-art { display: inline-grid; place-items: center; width: 60px; height: 60px; border-radius: 16px; background: var(--yellow-soft); color: var(--accent-text); margin-bottom: 12px; }
      .empty-cta h3 { font-size: 1.25rem; color: var(--ink); margin-bottom: 6px; }
      .empty-cta p { line-height: 1.65; margin-bottom: 18px; }

      /* ============ OVERVIEW ============ */
      .hero { position: relative; overflow: hidden; background: var(--hero-grad); border: 1px solid var(--hero-border); border-radius: 20px; padding: 34px 36px 30px; margin-bottom: 30px; }
      .hero::after {
        content: ""; position: absolute; right: -70px; top: -70px; width: 260px; height: 260px; border-radius: 50%;
        background: radial-gradient(circle, rgba(239, 212, 107, 0.5), rgba(239, 212, 107, 0) 68%);
      }
      .hero h1 { font-size: clamp(1.75rem, 3.4vw, 2.5rem); letter-spacing: -0.025em; max-width: 21ch; }
      .hero .hero-sub { color: var(--ink-soft); margin-top: 10px; max-width: 58ch; font-size: 1.05rem; line-height: 1.65; }
      .hero-actions { display: flex; gap: 11px; margin-top: 22px; flex-wrap: wrap; }
      .hero-chip {
        display: inline-flex; align-items: center; gap: 8px; background: var(--hero-chip-bg);
        border: 1px solid var(--hero-chip-line); border-radius: 999px; padding: 7px 14px; font-size: 0.82rem; font-weight: 700; color: var(--hero-chip-text);
        margin-bottom: 16px;
      }

      .stat-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 13px; margin-bottom: 32px; }
      .stat-tile { background: var(--card); border: 1px solid var(--line); border-radius: 15px; padding: 17px 18px; box-shadow: var(--shadow); }
      .stat-tile .stat-num { font-family: var(--display); font-size: 1.9rem; font-weight: 700; letter-spacing: -0.03em; line-height: 1.1; }
      .stat-tile .stat-label { color: var(--muted); font-size: 0.83rem; font-weight: 600; margin-top: 3px; }
      .stat-tile.accent { background: var(--accent-grad); border-color: var(--yellow-line); }
      .stat-tile.accent .stat-num { color: var(--accent-text); }

      .strategy-heading { display: flex; align-items: baseline; gap: 14px; margin-bottom: 16px; flex-wrap: wrap; }
      .strategy-heading h2 { font-size: 1.45rem; }
      .strategy-heading span { color: var(--muted); font-size: 0.95rem; }
      .strategy-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(255px, 1fr)); gap: 14px; }
      .strategy-card {
        text-align: left; background: var(--card); border: 1px solid var(--line); border-radius: 16px;
        padding: 19px 20px; display: flex; flex-direction: column; gap: 8px; box-shadow: var(--shadow);
        transition: transform 0.18s, box-shadow 0.18s, border-color 0.18s;
      }
      .strategy-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-lift); border-color: var(--line-strong); }
      .strategy-card .sc-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
      .strategy-card h3 { font-size: 1.06rem; }
      .strategy-card p { color: var(--muted); font-size: 0.92rem; line-height: 1.55; flex: 1; }
      .strategy-card .sc-action { display: inline-flex; align-items: center; gap: 6px; color: var(--accent-text); font-weight: 700; font-size: 0.86rem; }
      .activity-icon { border-radius: 10px; display: grid; place-items: center; width: 38px; height: 38px; }
      .activity-icon.yellow { background: var(--yellow-soft); color: var(--accent-text); }
      .activity-icon.sage { background: var(--sage-soft); color: var(--sage-text); }
      .activity-icon.lavender { background: var(--lav-soft); color: var(--lav); }

      /* ============ FLASHCARDS ============ */
      .study-layout { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 22px; align-items: start; }
      @media (max-width: 1080px) { .study-layout { grid-template-columns: 1fr; } }

      .flashcard {
        position: relative; background: var(--card); border: 1px solid var(--line); border-radius: 20px;
        min-height: 430px; padding: 30px 32px; display: flex; flex-direction: column;
        box-shadow: var(--shadow); transform-origin: center;
      }
      .flashcard.flipping { animation: cardpulse 0.3s ease; }
      @keyframes cardpulse { 0% { transform: scale(0.985); } 100% { transform: scale(1); } }
      .flashcard .fc-top { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 14px; }
      .fc-scene-tag { display: inline-flex; align-items: center; gap: 8px; font-family: var(--mono); font-weight: 700; font-size: 0.82rem; color: var(--accent-text); background: var(--yellow-soft); border-radius: 8px; padding: 5px 10px; }
      .fc-actions { display: flex; gap: 4px; }
      .icon-button {
        display: grid; place-items: center; width: 42px; height: 42px; border-radius: 10px;
        border: 1px solid transparent; background: transparent; color: var(--muted);
      }
      .icon-button:hover { background: var(--soft); color: var(--ink); }
      .icon-button.saved { color: var(--accent-text); background: var(--yellow-soft); }
      .fc-art { align-self: center; color: var(--art-ink); margin: 4px 0 10px; }
      .fc-art svg { width: min(300px, 60vw); height: auto; }
      .fc-title { font-size: 1.5rem; text-align: center; letter-spacing: -0.02em; }
      .fc-hint { text-align: center; color: var(--muted); margin-top: 8px; font-size: 0.95rem; }

      .fc-back-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 13px; margin-top: 6px; }
      .fc-block { background: var(--subtle-surface); border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; }
      .fc-block h4 { margin: 0 0 6px; font-size: 0.72rem; letter-spacing: 0.14em; text-transform: uppercase; color: var(--accent-text); font-family: var(--body); }
      .fc-block p { font-size: 0.95rem; line-height: 1.6; color: var(--ink-soft); }
      .fc-fulltitle { font-size: 1.18rem; margin-bottom: 4px; }
      .fc-desc { color: var(--ink-soft); line-height: 1.65; font-size: 1rem; }
      .theme-chips { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 14px; }
      .tag-chip { display:inline-flex; align-items:center; gap:5px; border:1px dashed var(--line-strong); color:var(--ink-soft); background:transparent; border-radius:999px; padding:3px 10px; font-size:0.76rem; font-weight:600; letter-spacing:0.01em; }
      .tile-tags { color:var(--muted); font-size:0.76rem; font-weight:600; font-family:var(--mono); margin-top:2px; }
      .quiz-tagrow { margin-bottom:10px; }
      .quiz-setup { display:grid; grid-template-columns: 1.6fr 1fr; gap:18px; align-items:start; }
      .setup-card { background:var(--card); border:1px solid var(--line); border-radius:16px; padding:22px; }
      .setup-grid { display:grid; grid-template-columns:1fr 1fr; gap:14px; margin-top:12px; }
      .setup-item { display:flex; gap:10px; align-items:flex-start; }
      .setup-icn { flex:none; width:34px; height:34px; border-radius:10px; display:grid; place-items:center; background:var(--soft); color:var(--ink-soft); border:1px solid var(--line); }
      .setup-item b { font-size:0.92rem; display:block; }
      .setup-item p { color:var(--muted); font-size:0.84rem; line-height:1.45; margin-top:2px; }
      .setup-controls .setup-label { display:block; font-size:0.76rem; font-weight:700; text-transform:uppercase; letter-spacing:0.07em; color:var(--muted); margin:12px 0 6px; }
      .setup-controls .select-wrap { width:100%; }
      .setup-controls select { width:100%; }
      .setup-note { color:var(--muted); font-size:0.8rem; margin-top:12px; line-height:1.5; }
      .skill-breakdown { width:100%; max-width:420px; margin:18px auto 6px; text-align:left; border:1px solid var(--line); border-radius:12px; padding:10px 14px; background:var(--card); }
      .skill-row { display:flex; justify-content:space-between; align-items:center; padding:5px 0; font-size:0.86rem; border-bottom:1px dashed var(--line); }
      .skill-row:last-child { border-bottom:0; }
      .skill-row.perfect { color:var(--ok); font-weight:600; }
      .skill-row.weak { color:var(--danger); font-weight:600; }
      .skill-score { font-variant-numeric:tabular-nums; }
      .detail-tagrow { margin-top:14px; }
      .detail-tagrow .answer-label { display: block; font-size: 0.7rem; letter-spacing: 0.15em; text-transform: uppercase; color: var(--accent-text); font-weight: 800; margin-bottom: 5px; }
      .detail-tags { display:flex; flex-wrap:wrap; gap:7px; margin-top:8px; }
      .essay-angle { display:flex; gap:8px; align-items:flex-start; background:var(--soft); border:1px dashed var(--line-strong); border-radius:10px; padding:10px 12px; margin:12px 0 2px; font-size:0.9rem; color:var(--ink-soft); line-height:1.5; }
      .essay-angle b { color:var(--ink); }
      .essay-angle svg { flex:none; margin-top:2px; color:var(--accent-text); }
      @media (max-width: 880px) { .quiz-setup { grid-template-columns: 1fr; } .setup-grid { grid-template-columns: 1fr; } }
      /* ============ polish layer (round 3) ============ */
      .hero { background: var(--hero-grad); }
      .hero::after { width:auto; height:auto; border-radius:0; content: ''; position: absolute; inset: 0; pointer-events: none; background-image: radial-gradient(var(--dot) 1px, transparent 1px); background-size: 17px 17px; mask-image: linear-gradient(180deg, rgba(0,0,0,.5), transparent 68%); }
      .hero > *:not(:first-child) { position: relative; z-index: 1; }
      .hero .hero-chip { position: relative; z-index: 1; background: var(--hero-chip-bg); backdrop-filter: blur(4px); }
      .stat-tile { transition: transform .16s, box-shadow .16s, border-color .16s; }
      .stat-tile:hover { transform: translateY(-2px); box-shadow: var(--shadow-lift); border-color: var(--line-strong); }
      .stat-tile.accent { border-color: var(--yellow-line); box-shadow: 0 0 0 3px rgba(239, 212, 107, 0.22), var(--shadow); }
      .stat-tile.streak { border-color: var(--yellow-line); background: var(--accent-grad); }
      .stat-suffix { font-size: .42em; font-weight: 700; color: var(--muted); margin-left: 4px; }
      .quiz-option:not(:disabled):hover { box-shadow: var(--shadow-lift); border-color: var(--line-strong); }
      .quiz-option:not(:disabled):active { transform: translateY(0); }
      .match-progress i { background: linear-gradient(90deg, #c9b23c, #e8d272); }
      .scene-tile .art, .scene-tile svg.art { transition: transform .2s ease; }
      .scene-tile:hover svg.art { transform: translateY(-2px) scale(1.015); }
      
      .tile-tags i { font-style: normal; }
      .answer-review { width: 100%; max-width: 420px; margin: 10px auto 0; border: 1px solid var(--line); border-radius: 12px; background: var(--card); text-align: left; }
      .answer-review summary { cursor: pointer; padding: 11px 16px; font-weight: 700; font-size: .9rem; color: var(--ink-soft); list-style: none; display: flex; align-items: center; gap: 8px; }
      .answer-review summary::-webkit-details-marker { display: none; }
      .answer-review summary::before { content: '+'; font-family: var(--mono); font-weight: 800; color: var(--accent-text); }
      .answer-review[open] summary::before { content: '\2013'; }
      .answer-review summary:hover { background: var(--soft); }
      .review-list { max-height: 340px; overflow-y: auto; border-top: 1px solid var(--line); }
      .review-row { display: flex; gap: 10px; padding: 11px 14px; border-bottom: 1px dashed var(--line); }
      .review-row:last-child { border-bottom: 0; }
      .review-mark { flex: none; width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; margin-top: 2px; }
      .review-row.ok .review-mark { background: var(--ok-soft); color: var(--ok); }
      .review-row.bad .review-mark { background: var(--danger-soft); color: var(--danger); }
      .review-body { min-width: 0; }
      .review-kind { display: block; font-family: var(--mono); font-size: .68rem; letter-spacing: .05em; color: var(--muted); margin-bottom: 2px; }
      .review-body b { display: block; font-size: .88rem; line-height: 1.4; }
      .review-exp { font-size: .8rem; color: var(--muted); line-height: 1.5; margin-top: 4px; }
      .review-list::-webkit-scrollbar { width: 9px; }
      .review-list::-webkit-scrollbar-thumb { background: var(--line-strong); border-radius: 99px; border: 2px solid var(--card); }
      .review-list::-webkit-scrollbar-track { background: transparent; }
      .theme-chip { background: var(--sage-soft); color: var(--sage-text); border: 1px solid var(--line); padding: 4px 12px; border-radius: 999px; font-size: 0.78rem; font-weight: 700; }
      .analysis-chip { border-style: dashed; letter-spacing: 0.02em; }
      .tile-analysis { font-family: var(--mono); font-size: 0.62rem; font-weight: 700; letter-spacing: 0.09em; text-transform: uppercase; color: var(--muted); }
      .tile-char { display: block; }
      .flip-hint { text-align: center; color: var(--muted); font-size: 0.82rem; margin-top: 14px; }
      .flip-hint kbd { font-family: var(--mono); background: var(--soft); border: 1px solid var(--line-strong); border-bottom-width: 2px; border-radius: 5px; padding: 1px 6px; font-size: 0.76rem; }

      .rate-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: auto; padding-top: 22px; }
      .rate-btn {
        border-radius: 12px; border: 1px solid var(--line-strong); background: var(--card);
        display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 11px 8px; min-height: 62px; font-weight: 700; font-size: 0.95rem;
      }
      .rate-btn small { display: block; font-size: 0.74rem; color: var(--muted); font-weight: 600; }
      .rate-btn:hover { border-color: var(--line-strong); transform: translateY(-1px); box-shadow: var(--shadow); }
      .rate-btn.again { color: var(--danger); } .rate-btn.again:hover { border-color: var(--danger-line); background: var(--danger-soft); }
      .rate-btn.good { color: var(--accent-text); } .rate-btn.good:hover { border-color: var(--yellow-line); background: var(--yellow-soft); }
      .rate-btn.easy { color: var(--ok); } .rate-btn.easy:hover { border-color: var(--ok-line); background: var(--ok-soft); }

      .card-progress { display: flex; align-items: center; gap: 14px; margin-bottom: 14px; }
      .card-progress .card-count { font-family: var(--mono); font-size: 0.85rem; color: var(--muted); font-weight: 700; white-space: nowrap; }
      .card-progress .match-progress { flex: 1; margin-bottom: 0; }

      .complete-card { align-items: center; justify-content: center; text-align: center; gap: 10px; min-height: 380px; }
      .completion-icon {
        width: 64px; height: 64px; border-radius: 50%; background: var(--yellow-soft); color: var(--accent-text);
        display: grid; place-items: center; margin-bottom: 6px;
      }
      .complete-card h3 { font-size: 1.45rem; }
      .complete-card p { color: var(--muted); max-width: 40ch; }

      .flash-aside { display: flex; flex-direction: column; gap: 15px; position: sticky; top: 24px; }
      .aside-card { background: var(--card); border: 1px solid var(--line); border-radius: 15px; padding: 17px 18px; box-shadow: var(--shadow); }
      .aside-card h3 { font-size: 0.98rem; margin-bottom: 10px; }
      .mastery-row { display: flex; align-items: center; gap: 10px; margin-bottom: 9px; font-size: 0.9rem; }
      .mastery-row:last-child { margin-bottom: 0; }
      .mastery-dot { width: 11px; height: 11px; border-radius: 4px; flex-shrink: 0; }
      .mastery-row b { margin-left: auto; font-family: var(--mono); font-size: 0.88rem; }
      .mastery-bar { height: 8px; border-radius: 999px; background: var(--track); overflow: hidden; display: flex; margin-top: 12px; }
      .mastery-bar i { height: 100%; transition: width 0.3s; }
      .kbd-row { display: flex; justify-content: space-between; align-items: center; padding: 7px 0; border-bottom: 1px dashed var(--line); font-size: 0.86rem; color: var(--muted); }
      .kbd-row:last-child { border-bottom: 0; }
      .kbd-row kbd { font-family: var(--mono); font-size: 0.76rem; background: var(--soft); border: 1px solid var(--line-strong); border-bottom-width: 2px; border-radius: 5px; padding: 2px 7px; color: var(--ink-soft); }

      /* ============ MATCHING ============ */
      .matching-grid { display: grid; grid-template-columns: 1fr 52px 1fr; gap: 8px; align-items: stretch; }
      @media (max-width: 760px) { .matching-grid { grid-template-columns: 1fr; } .matching-link { display: none; } }
      .column-label {
        display: flex; justify-content: space-between; align-items: center; letter-spacing: 0.14em;
        text-transform: uppercase; color: var(--muted); font-size: 0.72rem; font-weight: 800; margin: 2px 4px 9px;
      }
      .match-list { display: flex; flex-direction: column; gap: 9px; }
      .match-item {
        text-align: left; background: var(--card); border: 1.5px solid var(--line); border-radius: 13px;
        padding: 13px 15px; display: flex; align-items: center; gap: 12px; min-height: 62px;
        font-size: 0.98rem; line-height: 1.4; transition: border-color 0.15s, background 0.15s, transform 0.15s, opacity 0.2s;
        box-shadow: var(--shadow);
      }
      .match-item strong { font-weight: 700; font-family: var(--display); letter-spacing: -0.01em; font-size: 1rem; }
      .match-item:not(:disabled):hover { border-color: var(--line-strong); transform: translateY(-1px); }
      .match-item.selected { border-color: var(--accent-strong); background: var(--selected-bg); box-shadow: 0 0 0 3px rgba(239, 212, 107, 0.35); }
      .match-item.matched { border-color: var(--ok-line); background: var(--ok-soft); opacity: 0.82; }
      .match-item.matched strong { color: var(--ok); }
      .match-item.wrong { animation: shake 0.4s ease; border-color: var(--danger-line); background: var(--danger-soft); }
      @keyframes shake { 0%, 100% { transform: translateX(0); } 25% { transform: translateX(-6px); } 75% { transform: translateX(6px); } }
      .match-number { font-family: var(--mono); font-size: 0.78rem; font-weight: 700; color: var(--muted); background: var(--soft); border-radius: 7px; padding: 4px 8px; flex-shrink: 0; }
      .match-check { margin-left: auto; color: var(--ok); display: grid; place-items: center; width: 22px; }
      .matching-link { display: grid; place-items: center; color: #c2c8b2; }
      .match-bottom { margin-top: 20px; min-height: 30px; color: var(--muted); font-size: 0.98rem; }
      .match-success {
        display: flex; align-items: center; gap: 15px; background: var(--ok-soft); border: 1px solid var(--ok-line);
        border-radius: 14px; padding: 16px 19px; color: var(--ok);
      }
      .match-success h3 { color: var(--ok); font-size: 1.2rem; }
      .match-success p { font-size: 0.95rem; }
      .error-text { color: var(--danger); font-weight: 600; }

      /* ============ QUIZ ============ */
      .quiz-body h3 { font-size: 1.35rem; margin-bottom: 6px; }
      .quiz-clue { color: var(--ink-soft); font-size: 1.02rem; line-height: 1.65; margin-bottom: 20px; max-width: 72ch; }
      .quiz-clue.scene-name { font-family: var(--display); font-weight: 700; color: var(--ink); font-size: 1.15rem; }
      .quiz-topline { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; gap: 12px; color: var(--muted); font-size: 0.92rem; font-weight: 600; flex-wrap: wrap; }
      .quiz-topline b { color: var(--ink); font-size: 1rem; }
      .quiz-live { font-variant-numeric: tabular-nums; }
      .tile-notedot { display: inline-grid; place-items: center; color: #8a9a6a; margin-left: 2px; }
      .quiz-options { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 11px; }
      .quiz-option {
        text-align: left; background: var(--card); border: 1.5px solid var(--line); border-radius: 13px;
        padding: 15px 16px; display: flex; align-items: center; gap: 13px; min-height: 64px; font-size: 0.98rem;
        font-weight: 600; line-height: 1.45; box-shadow: var(--shadow);
      }
      .quiz-option:not(:disabled):hover { border-color: var(--line-strong); transform: translateY(-1px); }
      .quiz-option:disabled { opacity: 0.88; }
      .quiz-option.correct { border-color: var(--ok-line); background: var(--ok-soft); box-shadow: 0 0 0 3px rgba(165, 179, 142, 0.3); }
      .quiz-option.incorrect { border-color: var(--danger-line); background: var(--danger-soft); }
      .option-letter {
        font-family: var(--mono); font-weight: 800; font-size: 0.85rem; color: var(--muted);
        background: var(--soft); border-radius: 8px; width: 30px; height: 30px; display: grid; place-items: center; flex-shrink: 0;
      }
      .quiz-option.correct .option-letter { background: var(--ok-soft); color: var(--ok); }
      .quiz-option.incorrect .option-letter { background: var(--danger-soft); color: var(--danger); }
      .quiz-option .opt-check { margin-left: auto; }
      .quiz-option.correct .opt-check { color: var(--ok); }
      .quiz-option.incorrect .opt-check { color: var(--danger); }
      .quiz-feedback { border-radius: 13px; padding: 15px 18px; margin-top: 15px; font-size: 0.96rem; line-height: 1.6; animation: rise 0.25s ease; }
      @keyframes rise { from { opacity: 0; transform: translateY(7px); } to { opacity: 1; transform: none; } }
      .quiz-feedback.positive { background: var(--ok-soft); border: 1px solid var(--ok-line); color: var(--ok); }
      .quiz-feedback.negative { background: var(--danger-soft); border: 1px solid var(--danger-line); color: var(--danger); }
      .quiz-feedback strong { display: block; margin-bottom: 3px; }
      .quiz-actions { display: flex; justify-content: flex-end; margin-top: 18px; }
      .quiz-results { text-align: center; background: var(--card); border: 1px solid var(--line); border-radius: 20px; padding: 34px 26px; box-shadow: var(--shadow); }
      .result-top { display: flex; flex-direction: column; align-items: center; gap: 9px; margin-bottom: 20px; }
      .result-top h3 { font-size: 1.5rem; }
      .result-top p { color: var(--muted); max-width: 48ch; }
      .quiz-score { display: flex; align-items: baseline; gap: 7px; font-family: var(--display); }
      .quiz-score b { font-size: 2.9rem; letter-spacing: -0.04em; }
      .quiz-score span { font-size: 1.3rem; color: var(--muted); font-weight: 600; }
      .missed-scenes { text-align: left; display: flex; flex-direction: column; gap: 8px; margin-top: 8px; }
      .revisit-row {
        display: flex; align-items: center; gap: 13px; background: var(--card); border: 1px solid var(--line);
        border-radius: 11px; padding: 11px 15px; font-size: 0.95rem; text-align: left;
      }
      .revisit-row:hover { border-color: var(--line-strong); background: var(--soft); }
      .revisit-row strong { font-family: var(--display); }
      .revisit-row span:last-child { margin-left: auto; display: inline-flex; align-items: center; gap: 6px; color: var(--accent-text); font-weight: 700; font-size: 0.86rem; white-space: normal; }

      /* ============ RECALL ============ */
      .recall-layout { display: grid; grid-template-columns: minmax(0, 1fr) 330px; gap: 22px; align-items: start; }
      @media (max-width: 1000px) { .recall-layout { grid-template-columns: 1fr; } }
      .writing-area { background: var(--card); border: 1px solid var(--line); border-radius: 18px; padding: 24px 26px; box-shadow: var(--shadow); }
      .writing-area h3 { font-size: 1.3rem; margin-bottom: 6px; }
      .writing-prompt { color: var(--muted); font-size: 0.95rem; margin-bottom: 18px; line-height: 1.6; }
      .writing-area textarea { min-height: 220px; }
      .writing-meta { display: flex; justify-content: space-between; align-items: center; gap: 12px; color: var(--muted); font-size: 0.84rem; margin-top: 9px; flex-wrap: wrap; }
      .writing-meta span { display: inline-flex; align-items: center; gap: 6px; }
      .word-target { flex: 1; min-width: 90px; height: 7px; border-radius: 99px; background: var(--soft); border: 1px solid var(--line); overflow: hidden; }
      .word-target i { display: block; height: 100%; background: linear-gradient(90deg, #8a9a6a, #a5b38e); transition: width 0.2s ease; }
      .writing-actions { display: flex; gap: 11px; margin-top: 16px; flex-wrap: wrap; }
      .explanation-reference { position: sticky; top: 24px; }
      .reference-panel { background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 20px 22px; box-shadow: var(--shadow); }
      .reference-panel h3 { font-size: 1.25rem; margin-bottom: 12px; }
      .answer-block { background: var(--subtle-surface); border: 1px solid var(--line); border-radius: 11px; padding: 13px 15px; margin-bottom: 11px; }
      .answer-label { display: block; font-size: 0.7rem; letter-spacing: 0.15em; text-transform: uppercase; color: var(--accent-text); font-weight: 800; margin-bottom: 5px; }
      .answer-block p { font-size: 0.94rem; line-height: 1.6; color: var(--ink-soft); }
      .self-check { margin-top: 14px; display: flex; flex-direction: column; gap: 9px; }
      .self-check strong { font-size: 0.95rem; }
      .self-check label { display: flex; gap: 10px; align-items: flex-start; font-size: 0.92rem; font-weight: 500; color: var(--ink-soft); cursor: pointer; }
      .self-check input[type="checkbox"] { width: 19px; height: 19px; accent-color: #8a9a6a; margin-top: 2px; flex-shrink: 0; }
      .self-check small { color: var(--muted); font-size: 0.8rem; }
      .reference-art { display: grid; place-items: center; padding: 8px 0 14px; color: var(--art-ink); }
      .reference-art svg { width: min(250px, 100%); height: auto; }
      .reference-aside h3 { font-size: 1.2rem; margin-bottom: 6px; }
      .reference-aside p { color: var(--muted); font-size: 0.93rem; line-height: 1.6; }
      .reference-hint { display: flex; gap: 11px; background: var(--yellow-soft); border: 1px solid var(--yellow-line); border-radius: 11px; padding: 12px 14px; color: var(--accent-text); font-size: 0.88rem; margin-top: 15px; }

      /* ============ LIBRARY ============ */
      .library-controls { display: flex; gap: 12px; margin-bottom: 20px; flex-wrap: wrap; align-items: center; }
      .library-controls .search-box { position: relative; flex: 1; min-width: 220px; max-width: 380px; }
      .library-controls .search-box svg { position: absolute; left: 13px; top: 50%; transform: translateY(-50%); color: var(--muted); }
      .library-controls .search-box input { padding-left: 42px; min-height: 47px; }
      .chip-row { display: flex; gap: 7px; flex-wrap: wrap; }
      .filter-chip {
        border: 1px solid var(--line-strong); background: var(--card); border-radius: 999px; padding: 8px 16px;
        font-size: 0.84rem; font-weight: 650; color: var(--muted); min-height: 44px;
      }
      .filter-chip:hover { border-color: var(--line-strong); color: var(--ink); }
      .chip-count { font-weight: 800; font-size: 0.72rem; background: var(--soft); border-radius: 999px; padding: 1px 8px; margin-left: 2px; }
      .filter-chip.active .chip-count { background: rgba(255, 255, 255, 0.22); }
      .active-pills { display: flex; gap: 8px; flex-wrap: wrap; margin: -6px 0 14px; }
      .active-pill {
        display: inline-flex; align-items: center; gap: 7px; border: 1px solid var(--accent-strong); background: var(--yellow-soft);
        color: var(--ink); border-radius: 999px; padding: 7px 8px 7px 14px; font-size: 0.8rem; font-weight: 700;
        cursor: pointer; min-height: 36px;
      }
      .active-pill:hover { border-color: var(--accent-text); }
      .active-pill svg { flex: none; }
      .filter-chip.active { background: var(--selected-bg); border-color: var(--selected-line); color: var(--selected-text); }
      .library-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 14px; }
      .scene-tile {
        text-align: left; background: var(--card); border: 1px solid var(--line); border-radius: 16px;
        padding: 17px 18px; display: flex; flex-direction: column; gap: 9px; box-shadow: var(--shadow);
        transition: transform 0.16s, box-shadow 0.16s, border-color 0.16s;
      }
      .scene-tile:hover { transform: translateY(-3px); box-shadow: var(--shadow-lift); border-color: var(--line-strong); }
      .scene-tile .tile-top { display: flex; align-items: center; justify-content: space-between; }
      .tile-main {
        display: flex; flex-direction: column; gap: 9px; background: none; border: 0; padding: 0;
        text-align: left; font: inherit; color: inherit; cursor: pointer; min-width: 0;
      }
      .choice-copy, .chapter-copy, .selection-toolbar > span { min-width: 0; }
      .tile-main:focus-visible { outline: 2.5px solid var(--focus); outline-offset: 2px; border-radius: 14px; }
      .scene-timestamp { font-family: var(--mono); font-size: 0.74rem; font-weight: 700; color: var(--accent-text); white-space: nowrap; }


      .tile-title { font-size: 1.08rem; line-height: 1.3; font-weight: 700; font-family: var(--display); }
      .scene-tile .tile-num { font-family: var(--mono); font-size: 0.8rem; font-weight: 700; color: var(--muted); }
      .scene-tile .tile-save { width: 44px; height: 44px; }
      .scene-tile svg.art { width: 100%; height: auto; color: var(--art-ink); }
      .scene-tile .tile-title { font-size: 1.08rem; line-height: 1.3; }
      .scene-tile .tile-char { color: var(--muted); font-size: 0.84rem; font-weight: 600; }
      .library-count { color: var(--muted); font-size: 0.88rem; margin-bottom: 14px; }

      /* ============ PROGRESS ============ */
      .progress-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(165px, 1fr)); gap: 13px; margin-bottom: 28px; }
      .scene-status-list { display: flex; flex-direction: column; gap: 8px; max-height: 480px; overflow-y: auto; padding: 3px; margin: -3px; }
      .status-row {
        display: flex; align-items: center; gap: 13px; background: var(--card); border: 1px solid var(--line);
        border-radius: 11px; padding: 11px 15px; font-size: 0.95rem;
      }
      .status-row .mono { color: var(--muted); font-size: 0.8rem; font-weight: 700; }
      .status-row .st-title { font-weight: 650; font-family: var(--display); flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
      .status-pill { border-radius: 999px; font-size: 0.76rem; font-weight: 700; padding: 4px 12px; white-space: nowrap; }
      .status-pill.confident { background: var(--ok-soft); color: var(--ok); }
      .status-pill.learning { background: var(--yellow-soft); color: var(--accent-text); }
      .status-pill.new { background: var(--soft); color: var(--muted); }
      .status-pill.due { background: var(--danger-soft); color: var(--danger); }
      .progress-actions { display: flex; gap: 11px; margin-top: 24px; flex-wrap: wrap; }
      .progress-h2 { font-size: 1.3rem; margin-bottom: 13px; }

      /* ============ WATCH FILM & MOVIE CLIPS ============ */
      .watch-layout { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr); gap: 22px; align-items: start; }
      @media (max-width: 1000px) { .watch-layout { grid-template-columns: 1fr; } }
      .watch-player-wrap { position: sticky; top: 18px; }
      @media (max-width: 1000px) { .watch-player-wrap { position: static; } }
      .film-player {
        width: 100%; aspect-ratio: 16 / 9; background: #101209; border-radius: 17px;
        box-shadow: var(--shadow); border: 1px solid var(--line-strong); display: block;
      }
      .chapter-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; max-height: min(72vh, 760px); overflow-y: auto; padding-right: 4px; }
      .chapter-row {
        display: flex; align-items: center; gap: 13px; width: 100%; text-align: left;
        background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 11px 14px;
        cursor: pointer; transition: border-color 0.15s ease, transform 0.15s ease, background 0.15s ease; color: var(--ink);
      }
      .chapter-row:hover { border-color: var(--accent-strong); transform: translateY(-1px); background: var(--soft); }
      .chapter-time { font-family: var(--mono); font-size: 0.78rem; color: var(--accent-text); font-weight: 700; white-space: nowrap; }
      .chapter-copy { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
      .chapter-copy b { font-size: 0.92rem; }
      .chapter-copy small { color: var(--muted); font-size: 0.78rem; }
      .chapter-play { margin-left: auto; color: var(--muted); flex: none; display: grid; place-items: center; width: 30px; height: 30px; border-radius: 50%; background: var(--soft); transition: background 0.15s ease, color 0.15s ease; }
      .fc-time { font-size: 0.76rem; color: var(--muted); font-weight: 700; margin-left: auto; margin-right: 10px; white-space: nowrap; }
      .match-time { display: block; font-size: 0.72rem; color: var(--muted); font-weight: 600; margin-top: 3px; font-variant-numeric: tabular-nums; }
      .quiz-scene-time { font-size: 0.75rem; color: var(--muted); font-weight: 700; }
      .recall-time { font-size: 0.78rem; color: var(--muted); font-weight: 700; white-space: nowrap; }
      .chapter-row.active { border-color: var(--accent-strong); background: var(--selected-bg); }
      .chapter-row.active .chapter-play { background: var(--yellow-soft); color: var(--accent-text); }

      .chapter-row:hover .chapter-play { background: var(--yellow-soft); color: var(--accent-text); }
      .movie-clip-card { background: var(--subtle-surface); border: 1px solid var(--line); border-radius: 12px; padding: 14px 17px; margin-bottom: 11px; }
      .clip-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 8px; }
      .clip-heading .answer-label { display: block; font-size: 0.7rem; letter-spacing: 0.15em; text-transform: uppercase; color: var(--accent-text); font-weight: 800; margin-bottom: 5px; }
      .clip-timecode { font-family: var(--mono); font-weight: 700; font-size: 1rem; color: var(--ink); margin: 0; }
      .clip-source { font-size: 0.75rem; color: var(--muted); font-weight: 650; white-space: nowrap; }
      .clip-help { font-size: 0.88rem; line-height: 1.6; color: var(--ink-soft); margin: 0 0 12px; }
      .clip-actions { display: flex; gap: 10px; flex-wrap: wrap; }




      /* ============ MODAL & TOAST ============ */
      .modal-backdrop {
        position: fixed; inset: 0; z-index: 200; background: rgba(48, 53, 44, 0.45);
        backdrop-filter: blur(3px); display: grid; place-items: center; padding: 20px; animation: fade 0.18s ease;
      }
      @keyframes fade { from { opacity: 0; } to { opacity: 1; } }
      .modal {
        background: var(--paper); border-radius: 20px; max-width: 680px; width: 100%;
        max-height: min(86vh, 780px); display: flex; flex-direction: column; box-shadow: var(--shadow-lift);
        animation: pop 0.22s cubic-bezier(0.2, 0.9, 0.3, 1.2);
      }
      @keyframes pop { from { opacity: 0; transform: scale(0.94) translateY(10px); } to { opacity: 1; transform: none; } }
      .modal-head {
        display: flex; align-items: flex-start; justify-content: space-between; gap: 14px;
        padding: 22px 24px 14px; border-bottom: 1px solid var(--line);
      }
      .modal-head h2 { font-size: 1.35rem; letter-spacing: -0.02em; }
      .modal-body { padding: 20px 24px; overflow-y: auto; }
      .modal-intro { color: var(--ink-soft); font-size: 1rem; line-height: 1.65; margin-bottom: 18px; }
      .modal .scene-art-lg { display: grid; place-items: center; color: var(--art-ink); margin-bottom: 14px; }
      .modal .scene-art-lg svg { width: min(320px, 80%); }
      .detail-block { background: var(--subtle-surface); border: 1px solid var(--line); border-radius: 12px; padding: 14px 17px; margin-bottom: 11px; }
      .key-line { background: var(--primary-bg); color: var(--primary-text); border-radius: 12px; padding: 15px 18px; margin-bottom: 11px; }
      .key-line .answer-label { display: block; font-size: 0.7rem; letter-spacing: 0.15em; text-transform: uppercase; color: var(--yellow); font-weight: 800; margin-bottom: 5px; }
      .key-line p { font-size: 1.02rem; line-height: 1.6; font-style: italic; margin: 0; }
      .history-note-block { border-left: 3px solid #8a9a6a; }
      .starter-block { border-left: 3px solid var(--accent-strong); }
      .related-list { display: flex; flex-direction: column; gap: 7px; margin-top: 4px; }
      .related-row {
        display: flex; align-items: center; gap: 11px; width: 100%; text-align: left;
        background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 9px 13px;
        cursor: pointer; color: var(--ink); transition: border-color 0.15s ease, transform 0.15s ease;
      }
      .related-row:hover { border-color: var(--accent-strong); transform: translateY(-1px); }
      .related-row .mono { font-size: 0.72rem; color: var(--muted); font-weight: 700; white-space: nowrap; }
      .related-row strong { flex: 1; font-size: 0.86rem; }
      .related-row svg { color: var(--muted); flex: none; }
      .fc-keyline { font-style: italic; color: var(--ink-soft); border-left: 3px solid var(--yellow-deep, var(--accent-strong)); padding-left: 12px; margin: 12px 0 0; font-size: 0.95rem; line-height: 1.6; }

      .detail-block .answer-label { display: block; font-size: 0.7rem; letter-spacing: 0.15em; text-transform: uppercase; color: var(--accent-text); font-weight: 800; margin-bottom: 5px; }
      .detail-block p { font-size: 0.97rem; line-height: 1.65; color: var(--ink-soft); }
      .detail-meta { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; align-items: center; }
      .reset-actions { display: flex; gap: 11px; justify-content: flex-end; flex-wrap: wrap; margin-top: 20px; }

      .toast-root { position: fixed; bottom: calc(22px + env(safe-area-inset-bottom, 0px)); left: 50%; transform: translateX(-50%); z-index: 400; display: flex; flex-direction: column; gap: 9px; align-items: center; width: min(92vw, 480px); pointer-events: none; }
      .toast { pointer-events: auto; }
      .toast {
        background: var(--primary-bg); color: var(--primary-text); border-radius: 12px; padding: 13px 19px;
        font-size: 0.93rem; font-weight: 600; box-shadow: var(--shadow-lift); display: flex; gap: 10px; align-items: center;
        animation: toastin 0.28s cubic-bezier(0.2, 0.9, 0.3, 1.15); max-width: 100%;
      }
      .toast svg { color: var(--yellow); flex-shrink: 0; }
      .toast.leaving { opacity: 0; transform: translateY(8px); transition: opacity 0.25s, transform 0.25s; }
      @keyframes toastin { from { opacity: 0; transform: translateY(12px) scale(0.97); } to { opacity: 1; transform: none; } }

      @media (max-width: 560px) {
        .hero { padding: 24px 20px; }
        .flashcard { padding: 22px 18px; min-height: 400px; }
        .fc-title { font-size: 1.28rem; }
        .rate-row { grid-template-columns: 1fr; }
        .rate-btn { flex-direction: row; justify-content: space-between; min-height: 52px; padding: 10px 16px; }
        .quiz-options { grid-template-columns: 1fr; }
        .section-toolbar h2 { font-size: 1.32rem; }
        .view-wrap { padding: 18px 13px 30px; }
      }

      @media print { .sidebar, .mobile-topbar, .app-footer { display: none !important; } .main-area { margin: 0; } }

      @media (prefers-reduced-motion: reduce) {
        *, *::before, *::after { animation: none !important; transition-duration: 0.01ms !important; }
        html { scroll-behavior: auto !important; }
      }
      /* ============ THEME TOGGLE BUTTONS ============ */
      .theme-toggle {
        display: flex; align-items: center; gap: 9px; width: 100%; justify-content: flex-start;
        background: transparent; border: 1px solid var(--line-strong); color: var(--ink-soft);
        border-radius: 11px; padding: 9px 12px; font-size: 0.85rem; font-weight: 600; margin-bottom: 10px;
      }
      .theme-toggle:hover { background: var(--sage-soft); color: var(--ink); border-color: var(--muted); }
      .topbar-theme {
        display: grid; place-items: center; width: 44px; height: 44px; flex-shrink: 0;
        background: transparent; border: 1px solid var(--line-strong); border-radius: 10px; color: var(--ink);
      }
      .topbar-theme:hover { background: var(--sage-soft); }
      .topbar-theme span { display: none; }
      .theme-toggle svg, .topbar-theme svg { flex-shrink: 0; }

      /* ============ MASTERY BY ESSAY TAG ============ */
      .tagstat-list {
        display: flex; flex-direction: column; gap: 9px; background: var(--card);
        border: 1px solid var(--line); border-radius: 16px; padding: 16px 18px; margin-bottom: 28px;
        box-shadow: var(--shadow);
      }
      .tagstat-row { display: grid; grid-template-columns: minmax(120px, 185px) 62px 1fr 46px auto; align-items: center; gap: 12px; }
      .tagstat-row .tag-chip { justify-self: start; }
      .practice-btn { display: inline-flex; align-items: center; justify-content: center; gap: 5px; height: 34px; padding: 0 11px; border-radius: 9px; border: 1px solid var(--line-strong); background: var(--card); color: var(--ink-soft); font: inherit; font-size: 0.8rem; font-weight: 700; cursor: pointer; transition: transform .15s ease, background .15s ease, border-color .15s ease, color .15s ease; white-space: nowrap; }
      .practice-btn:hover { background: var(--yellow-soft); border-color: var(--yellow-line); color: var(--yellow-ink-deep); transform: translateY(-1px); }
      .practice-btn:active { transform: translateY(0); }
      .tag-chip-btn { font: inherit; cursor: pointer; transition: transform .12s ease, box-shadow .12s ease; }
      .tag-chip-btn:hover { transform: translateY(-1px); box-shadow: 0 3px 10px -4px rgba(0, 0, 0, 0.3); }
      .tagrow-hint { color: var(--muted); font-size: 0.72rem; font-weight: 600; }
      .breakdown-cap { display: block; font-family: var(--mono); font-size: 0.62rem; font-weight: 700; letter-spacing: 0.13em; color: var(--muted); margin-bottom: 7px; }
      .skill-breakdown + .skill-breakdown { margin-top: 10px; }
      .search-box kbd.search-kbd { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); font-family: var(--mono); background: var(--soft); border: 1px solid var(--line-strong); border-bottom-width: 2px; border-radius: 5px; padding: 1px 7px; font-size: 0.72rem; color: var(--muted); pointer-events: none; transition: opacity .12s ease; }
      .search-box:focus-within kbd.search-kbd { opacity: 0; }
      .tile-cue { display: none; }
      .tagstat-n { font-size: 0.78rem; color: var(--muted); white-space: nowrap; }
      .tagstat-barwrap { height: 9px; border-radius: 99px; background: var(--soft); overflow: hidden; }
      .tagstat-bar { display: block; height: 100%; border-radius: 99px; transition: width 0.5s ease; min-width: 2%; }
      .tagstat-pct { font-size: 0.8rem; text-align: right; color: var(--ink-soft); font-variant-numeric: tabular-nums; }
      @media (max-width: 640px) {
        .tagstat-row { grid-template-columns: 1fr auto auto; }
        .tagstat-row .tag-chip { grid-column: 1 / -1; margin-bottom: -4px; }
        .tagstat-n { display: none; }
      }

      /* ============ V2.4 POLISH LAYER ============ */
      /* Frosted modal backdrop */
      .modal-backdrop { background: rgba(38, 41, 32, 0.42); backdrop-filter: blur(5px) saturate(1.08); -webkit-backdrop-filter: blur(5px) saturate(1.08); animation: fadein 0.18s ease; }
      @keyframes fadein { from { opacity: 0; } to { opacity: 1; } }
      /* Focus-visible rings for keyboard users */
      .scene-tile:focus-visible, .filter-chip:focus-visible, .button:focus-visible, .nav-item:focus-visible,
      .rate-btn:focus-visible, .tag-chip-btn:focus-visible, .kbd-help-btn:focus-visible,
      .chapter-row:focus-visible, .match-item:focus-visible, .quiz-option:focus-visible {
        outline: 2.5px solid var(--focus); outline-offset: 2px; border-radius: inherit;
      }
      .scene-tile:focus-visible { border-radius: 14px; }
      /* Mastery rings on library tiles */
      .scene-tile .tile-num { display: inline-flex; align-items: center; gap: 7px; }
      .tile-ring { width: 17px; height: 17px; flex: none; display: inline-block; }
      .tile-ring svg { width: 100%; height: 100%; display: block; transform: rotate(-90deg); }
      .tile-ring .ring-track { fill: none; stroke: var(--line); stroke-width: 3; }
      .tile-ring .ring-fill { fill: none; stroke-width: 3; stroke-linecap: round; transition: stroke-dasharray 0.5s ease, stroke 0.3s ease; }
      .scene-tile:hover .tile-ring .ring-track { stroke: var(--line-strong); }
      /* Mastery chip in scene modal */
      .mastery-chip.mastery-learning { color: var(--accent-text); border-color: #d9bd4a66; background: #efd46b1c; }
      .mastery-chip.mastery-confident { color: var(--ok); border-color: #8a9a6a66; background: #8a9a6a1c; }


      /* Keyboard shortcut cheat sheet */
      .sc-cap { font-family: var(--mono); font-size: 0.68rem; font-weight: 700; letter-spacing: 0.14em; color: var(--accent-text); margin: 18px 0 6px; }
      .sc-cap:first-of-type { margin-top: 4px; }
      .sc-row { display: flex; justify-content: space-between; align-items: center; gap: 16px; padding: 8px 2px; border-bottom: 1px dashed var(--line); font-size: 0.95rem; }
      .sc-row:last-child { border-bottom: 0; }
      .sc-row b { font-weight: 600; color: var(--ink); }
      .sc-keys { display: flex; gap: 6px; flex: none; }
      .sc-keys kbd { font-family: var(--mono); font-size: 0.72rem; background: var(--soft); border: 1px solid var(--line-strong); border-bottom-width: 2px; border-radius: 5px; padding: 1px 7px; color: var(--muted); }
      .modal-head h2 svg { vertical-align: -3px; margin-right: 6px; }

      /* Sidebar keyboard-help button */
      .kbd-help-btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; align-self: flex-start; min-height: 44px; min-width: 44px; padding: 0 13px; border: 1px solid var(--line-strong); border-radius: 10px; background: var(--card); color: var(--ink-soft); cursor: pointer; transition: border-color 0.15s ease, color 0.15s ease, transform 0.15s ease; }
      .kbd-help-btn:hover { border-color: var(--focus); color: var(--ink); transform: translateY(-1px); }
      .kbd-help-btn kbd { font-size: 0.78rem; }


      /* Restore-backup summary facts */
      .restore-facts { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin: 16px 0 18px; }
      .restore-facts .fact { background: var(--soft); border: 1px solid var(--line); border-radius: 11px; padding: 11px 8px 9px; text-align: center; display: flex; flex-direction: column; gap: 2px; }
      .restore-facts .fact b { font-size: 1.35rem; line-height: 1.1; color: var(--ink); }
      .restore-facts .fact span { font-size: 0.74rem; color: var(--muted); letter-spacing: 0.02em; }
      @media (max-width: 560px) { .restore-facts { grid-template-columns: repeat(2, 1fr); } }

      /* ============ PROGRESS REDESIGN ============ */
      .progress-tools { display: flex; gap: 10px; flex-wrap: wrap; }
      .performance-card {
        background: var(--card); border: 1px solid var(--line); border-radius: 18px;
        padding: 22px 24px; box-shadow: var(--shadow); margin-bottom: 26px;
      }
      .performance-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; margin-bottom: 4px; }
      .performance-head h3 { font-size: 1.35rem; letter-spacing: -0.01em; margin-top: 2px; }
      .range-control { display: flex; align-items: center; gap: 10px; font-size: 0.85rem; font-weight: 700; color: var(--muted); }
      .custom-range { display: flex; gap: 12px; flex-wrap: wrap; margin: 14px 0 4px; }
      .custom-range label { display: flex; align-items: center; gap: 8px; font-size: 0.85rem; font-weight: 700; color: var(--muted); }
      .custom-range input[type="date"] {
        font: inherit; color: var(--ink); background: var(--card); border: 1px solid var(--line-strong);
        border-radius: 10px; padding: 10px 12px; min-height: 44px;
      }
      .chart-summary { display: flex; gap: 30px; align-items: baseline; flex-wrap: wrap; margin: 18px 0 8px; }
      .chart-summary .sum { display: flex; align-items: baseline; gap: 9px; }
      .chart-summary .sum b { font-family: var(--display); font-size: 1.7rem; letter-spacing: -0.02em; }
      .chart-summary .sum span { color: var(--muted); font-size: 0.88rem; font-weight: 600; }
      .activity-chart { display: flex; gap: 8px; align-items: stretch; overflow-x: auto; padding: 14px 2px 8px; }
      .activity-column { flex: 1 0 0; min-width: 48px; display: flex; flex-direction: column; align-items: center; gap: 7px; }
      .activity-column > b { font-size: 0.84rem; font-variant-numeric: tabular-nums; }
      .activity-column small { font-size: 0.68rem; color: var(--muted); font-weight: 600; white-space: nowrap; }
      .activity-bar-track {
        height: 104px; width: 100%; max-width: 46px; display: flex; align-items: flex-end;
        background: var(--soft); border: 1px solid var(--line); border-radius: 9px; overflow: hidden;
      }
      .activity-bar-track i { display: block; width: 100%; background: linear-gradient(180deg, #d9b93c, #efd46b); }

      .history-list h4 { font-size: 1.02rem; margin: 20px 0 10px; }
      .history-row {
        display: flex; gap: 12px; align-items: baseline; background: var(--card);
        border: 1px solid var(--line); border-radius: 11px; padding: 10px 14px; margin-bottom: 8px; font-size: 0.9rem;
      }
      .history-row time { color: var(--muted); font-size: 0.78rem; white-space: nowrap; font-variant-numeric: tabular-nums; }
      .history-row span { flex: 1; min-width: 0; }
      .history-row b { font-variant-numeric: tabular-nums; }
      .history-note, .history-empty { color: var(--muted); font-size: 0.9rem; line-height: 1.6; }
      .history-empty { background: var(--card); border: 1px dashed var(--line-strong); border-radius: 12px; padding: 18px; }

      /* ============ SCENE SELECTION REDESIGN ============ */
      .selection-toolbar {
        position: sticky; top: 12px; z-index: 5; display: flex; align-items: center; justify-content: space-between;
        gap: 14px; flex-wrap: wrap; background: var(--card); border: 1px solid var(--line);
        border-radius: 14px; padding: 12px 12px 12px 18px; margin-bottom: 14px; box-shadow: var(--shadow);
      }
      .selection-toolbar > span { font-size: 0.9rem; color: var(--muted); font-weight: 600; }
      .selection-toolbar > span b { color: var(--ink); font-size: 1.05rem; }
      .selection-toolbar > div { display: flex; gap: 6px; }
      .scene-choice-list { display: flex; flex-direction: column; gap: 9px; }
      .scene-choice {
        display: flex; align-items: center; gap: 14px; background: var(--card);
        border: 1px solid var(--line); border-radius: 13px; padding: 12px 16px; cursor: pointer;
        transition: border-color 0.15s ease, background 0.15s ease, transform 0.15s ease;
      }
      .scene-choice:hover { border-color: var(--line-strong); transform: translateY(-1px); }
      .scene-choice.selected { border-color: var(--accent-strong); background: var(--selected-bg); }

      .scene-choice input[type="checkbox"] { width: 21px; height: 21px; accent-color: #8a9a6a; flex: none; cursor: pointer; }
      .choice-number { font-family: var(--mono); font-size: 0.78rem; font-weight: 700; color: var(--muted); background: var(--soft); border-radius: 8px; padding: 5px 9px; flex: none; }
      .choice-copy { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
      .choice-copy b { font-size: 0.95rem; }
      .choice-copy small { color: var(--muted); font-size: 0.78rem; }
      .choice-tags { display: flex; gap: 6px; flex: none; }
      .choice-tags i { font-style: normal; font-size: 0.72rem; font-weight: 700; color: var(--muted); background: var(--soft); border-radius: 999px; padding: 4px 10px; white-space: nowrap; }
      .selection-footer {
        position: sticky; bottom: 12px; z-index: 5; display: flex; align-items: center; justify-content: space-between;
        gap: 14px; flex-wrap: wrap; background: var(--card); border: 1px solid var(--line);
        border-radius: 14px; padding: 12px 12px 12px 18px; margin-top: 14px; box-shadow: var(--shadow-lift);
      }
      .selection-footer > span { font-size: 0.88rem; color: var(--muted); }
      @media (max-width: 640px) {
        .choice-tags { display: none; }
        .performance-card { padding: 18px 16px; }
        .selection-toolbar, .selection-footer { position: static; }
      }

      /* ============ PRINT STUDY PACK ============ */
      .print-only { display: none; }
      @media print {
        :root, html[data-theme="dark"] {
          --paper: #fff; --card: #fff; --soft: #f0f1e6;
          --ink: #1c1e15; --ink-soft: #3a3d31; --muted: #6a6f5c;
          --line: #c9cdbb; --line-strong: #b3b7a4;
          --yellow-soft: #faf3d4; --sage-soft: #eef1e4;
          --sidebar-bg: #fff; --footer-bg: #fff; --topbar-bg: #fff;
          --shadow: none; --shadow-lift: none;
        }
        body { background: #fff !important; }
        .sidebar, .mobile-topbar, .app-footer, .toast-root, .sidebar-overlay,
        .library-controls, .section-toolbar, .chip-row, .library-count,
        .icon-button, .menu-btn, .theme-toggle, .topbar-theme,
        .rate-row, .quiz-actions, .writing-actions, .match-bottom, .clip-actions, .reset-actions,
        .selection-footer, .selection-toolbar, .progress-actions, .quiz-topline .text-button, .active-pills,
        #modalRoot, .modal-backdrop, .modal { display: none !important; }
        .scene-tile, .stat-tile, .detail-block, .movie-clip-card { box-shadow: none !important; }
        .print-only { display: block; }
        .print-head { margin-bottom: 20px; border-bottom: 2px solid #1c1e15; padding-bottom: 10px; }
        .print-head h1 { font-family: var(--display); font-size: 22pt; margin: 0 0 4px; letter-spacing: -0.02em; }
        .print-head p { margin: 0; color: #555; font-size: 9.5pt; }
        .main-area { padding: 0 !important; }
        .library-grid { grid-template-columns: repeat(3, 1fr) !important; gap: 10px !important; }
        .scene-tile { break-inside: avoid; page-break-inside: avoid; border: 1px solid #b8bba9 !important; box-shadow: none !important; }
        .scene-tile:hover { transform: none !important; }
        .scene-tile .tile-title { font-size: 11pt; }
        .scene-tile .tile-cue { display: block; font-size: 8pt; color: #4a4d3e; margin-top: 3px; font-style: italic; line-height: 1.35; }
      }


/* Semantic colors shared by all component states. */
:root {
  --muted:#5f6656;
  --primary-bg:#30352c;--primary-text:#fffdf6;--primary-hover:#454b3d;
  --ink-on-accent:#302b15;--accent-text:#705b17;--accent-strong:#987921;
  --selected-bg:#f7e9b1;--selected-text:#493b10;--selected-line:#987921;--selected-count-bg:#f9efcf;
  --subtle-surface:#f7f8f1;--track:#dce1cf;--focus:#876b17;--scrollbar:#9da58e;--scrollbar-hover:#818b71;
  --sage-text:#496037;--ok:#41632f;--ok-line:#8ca577;--danger:#a03827;
  --art-ink:#525b46;--art-wash:#f7e9b1;--art-detail:#fffdf6;
  --toast-bg:#30352c;--toast-text:#fffdf6;--accent-grad:linear-gradient(150deg,#fffdf2,#fdf4cd);
  --tag-racism:#933f2d;--tag-sexism:#954567;--tag-segregation:#796029;--tag-injustice:#785332;
  --tag-dignity:#6e558e;--tag-education:#496332;--tag-opportunity:#566b2d;--tag-family:#885123;
  --tag-merit:#775c0e;--tag-leadership:#455836;--tag-solidarity:#356551;--tag-technology:#425f67;--tag-coldwar:#883b27;--tag-default:#59624d;
}
html[data-theme="dark"] {
  color-scheme:dark;
  --paper:#151810;--card:#20251b;--soft:#2b3124;--subtle-surface:#282e21;
  --ink:#f0f1e5;--ink-soft:#d3d7c7;--muted:#b1b7a3;--line:#444d39;--line-strong:#67735a;
  --yellow:#efd46b;--yellow-deep:#e8bd34;--yellow-soft:#38351d;--yellow-hover:#494426;--yellow-ink-deep:#f4dea0;--yellow-line:#8e7a3a;
  --primary-bg:#efd46b;--primary-text:#302b15;--primary-hover:#f5dfa1;--ink-on-accent:#302b15;
  --selected-bg:#383a23;--selected-text:#f5e3a8;--selected-line:#a38d48;--selected-count-bg:#48492b;
  --accent-text:#efd67e;--accent-strong:#d7bc62;--track:#59654a;--focus:#f4d678;
  --sage:#b1c899;--sage-soft:#2d3924;--sage-text:#c4d9ac;
  --ok:#b4d79d;--ok-soft:#293921;--ok-line:#708d57;
  --danger:#f2ae9b;--danger-soft:#422b25;--danger-line:#b97560;
  --lav:#d2bde9;--lav-soft:#383047;
  --sidebar-bg:#1b2016;--footer-bg:#1b2016;--topbar-bg:rgba(21,24,16,.96);
  --hero-grad:linear-gradient(135deg,#272f1f,#32331e);--hero-border:#5f613c;
  --hero-chip-bg:#363b26;--hero-chip-line:#72764d;--hero-chip-text:#e8dca6;--dot:rgba(235,241,220,.07);
  --art-ink:#d5dbc6;--art-wash:#41462a;--art-detail:#28301d;
  --toast-bg:#303b25;--toast-text:#f0f1e5;--accent-grad:linear-gradient(150deg,#303821,#39391f);
  --scrollbar:#6e7a60;--scrollbar-hover:#96a582;
  --shadow:0 2px 12px rgba(0,0,0,.2);--shadow-lift:0 8px 24px rgba(0,0,0,.3);
  --tag-racism:#f0b29d;--tag-sexism:#eeb2d0;--tag-segregation:#e6ca91;--tag-injustice:#e7bd91;
  --tag-dignity:#d2bdec;--tag-education:#b5d497;--tag-opportunity:#ccda95;--tag-family:#e9c49b;
  --tag-merit:#ecd382;--tag-leadership:#bcd2a4;--tag-solidarity:#a5d6bf;--tag-technology:#acd4de;--tag-coldwar:#f1b9a3;--tag-default:#c5cfb8;
}
.nav-item.active,.nav-item.active:hover {background:var(--selected-bg);color:var(--selected-text);box-shadow:inset 3px 0 var(--selected-line);}
.quiet-tag {background:var(--soft);color:var(--muted);}
.brand-dot {color:var(--accent-text);}
.nav-item:hover {background:var(--soft);color:var(--ink);}
.nav-item.active .nav-count {background:var(--selected-count-bg);color:var(--selected-text);}
.nav-item.active .nav-due-badge {border-color:var(--selected-bg);}
.button.primary {background:var(--primary-bg);color:var(--primary-text);}
.button.primary:hover:not(:disabled) {background:var(--primary-hover);}
.button:disabled {background:var(--soft);color:var(--muted);border-color:var(--line-strong);opacity:1;}
.tag-chip {--tag-color:var(--tag-default);color:var(--tag-color);border-color:color-mix(in srgb,var(--tag-color) 45%,transparent);background:color-mix(in srgb,var(--tag-color) 7%,var(--card));filter:none;}
.tag-chip-btn {min-height:44px;}
.toast {background:var(--toast-bg);color:var(--toast-text);border:1px solid var(--line-strong);}
.toast svg {color:var(--accent-text);}
.activity-icon.yellow,.icon-button.saved,.chapter-row.active .chapter-play,.chapter-row:hover .chapter-play,.essay-angle svg {color:var(--accent-text);}
.activity-icon.sage {color:var(--sage-text);}
.reference-hint p {color:var(--yellow-ink-deep);}
.word-target {background:var(--track);border-color:var(--line-strong);}
.word-target i {background:var(--sage);}
.ring-track {stroke:var(--line-strong)!important;}
.scene-art,.scene-tile svg.art,.fc-art,.reference-art,.modal .scene-art-lg {color:var(--art-ink);}
.scene-art {stroke:var(--art-ink);}
.icon-button {width:44px;height:44px;}
.topbar-due {min-height:44px;white-space:nowrap;}
.practice-btn,.active-pill,.small-button {min-height:44px;}
.mobile-nav-close {display:none;}
.library-toolbar {display:flex;align-items:center;gap:12px;flex-wrap:wrap;margin-bottom:18px;}
.library-toolbar .search-box {position:relative;flex:1;min-width:220px;}
.search-box > svg {position:absolute;left:14px;top:50%;transform:translateY(-50%);color:var(--muted);}
.search-box input {padding-left:43px;padding-right:48px;min-height:48px;}
.search-clear {position:absolute;right:3px;top:3px;display:grid;place-items:center;width:42px;height:42px;border:0;background:transparent;border-radius:8px;color:var(--muted);}
input[type="search"]::-webkit-search-cancel-button,input[type="search"]::-webkit-search-decoration {appearance:none;display:none;}
.filter-badge {background:var(--selected-bg);color:var(--selected-text);padding:0 7px;border-radius:6px;font-size:.8rem;}
.filter-panel {background:var(--card);border:1px solid var(--line-strong);padding:20px;border-radius:16px;margin-bottom:18px;}
.filter-panel-head {display:flex;gap:12px;justify-content:space-between;align-items:center;margin-bottom:14px;}
.filter-panel-head p {color:var(--muted);font-size:.88rem;}
.filter-groups {display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:20px;}
.filter-group {position:relative;min-width:0;border:0;padding:0;margin:0;}
.filter-group legend {font-size:.88rem;font-weight:750;padding:0;margin-bottom:8px;}
.filter-clear {position:absolute;right:0;top:-39px;font-size:.8rem;}
.filter-options {display:flex;flex-direction:column;gap:5px;}
.filter-option {display:flex;align-items:center;gap:10px;min-height:44px;border:1px solid var(--line);border-radius:9px;padding:8px 11px;font-size:.85rem;font-weight:550;cursor:pointer;}
.filter-option input {width:18px;height:18px;flex:none;accent-color:var(--accent-strong);}
.filter-option span {flex:1;min-width:0;}
.filter-option b {color:var(--muted);font-family:var(--mono);font-size:.75rem;}
.filter-option.selected {background:var(--selected-bg);color:var(--selected-text);border-color:var(--selected-line);}
.filter-option.selected b {color:var(--selected-text);}
.sr-only {position:absolute!important;width:1px;height:1px;padding:0!important;margin:-1px!important;overflow:hidden;clip-path:inset(50%);white-space:nowrap;border:0;}
.filter-disclosure {min-width:0;border:1px solid var(--line);border-radius:12px;padding:8px 12px;background:var(--card);}
.filter-disclosure summary {display:flex;align-items:center;gap:10px;min-height:44px;list-style:none;font-size:.9rem;font-weight:750;cursor:pointer;}
.filter-disclosure summary::-webkit-details-marker {display:none;}
.filter-disclosure summary::before {content:'▸';color:var(--muted);}
.filter-disclosure[open] summary::before {content:'▾';}
.filter-disclosure summary .filter-badge {margin-left:auto;font-size:.7rem;white-space:nowrap;}
.filter-disclosure .filter-clear {position:static;display:block;margin:0 0 8px auto;}
.filter-panel-foot {display:flex;justify-content:flex-end;margin-top:18px;}
.library-count {scroll-margin-top:90px;}
.selection-toolbar > div {flex-wrap:wrap;}
@media(max-width:640px) {.filter-panel-foot .button{width:100%;justify-content:center;}.filter-disclosure{padding:6px 10px;}.selection-toolbar>div{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));width:100%;}.selection-toolbar .text-button{padding:8px;white-space:normal;justify-content:center;}}
.active-pill {max-width:100%;overflow-wrap:anywhere;color:var(--selected-text);background:var(--selected-bg);border-color:var(--selected-line);}
.select-wrap {min-width:0;max-width:100%;}
.select-wrap select {min-width:0;}
.answer-block,.fc-block,.detail-block {background:var(--subtle-surface);border-color:var(--line-strong);}
.match-item {flex-wrap:wrap;}
.match-item strong {flex:1;min-width:0;overflow-wrap:anywhere;}
.match-time {width:100%;margin-left:0;}
.match-check {margin-left:0;}
.match-success {flex-wrap:wrap;}
.chapter-row {flex-wrap:wrap;}
.chapter-time {flex-basis:100%;}
.chapter-copy {flex:1;}
.status-row,.revisit-row,.related-row,.history-row {flex-wrap:wrap;}
.status-row .st-title {flex:1 1 160px;white-space:normal;}
.status-row .mono,.revisit-row .mono,.related-row .mono {flex-basis:100%;white-space:normal;}
.range-control {flex-wrap:wrap;max-width:100%;}
.chart-summary .sum {flex-wrap:wrap;gap:4px 9px;}
.activity-chart {max-width:100%;}
.quiz-option,.match-item {overflow-wrap:anywhere;}
@media (max-width:900px) {
  .mobile-nav-close {display:grid;}
  .sidebar-brand {margin-bottom:22px;}
  .mobile-topbar {gap:8px;padding:8px 12px;}
  .mobile-brand {min-width:0;gap:6px;white-space:nowrap;font-size:1rem;}
  .mobile-brand .brand-mark {width:34px;height:34px;flex:none;}
  .topbar-due {padding:4px 8px;font-size:.75rem;gap:4px;}
  .section-toolbar > .select-wrap {width:100%;}
  .section-toolbar > .select-wrap select {width:100%;}
  .flash-aside,.explanation-reference {position:static;}
}
@media (max-width:640px) {
  .filter-groups {grid-template-columns:1fr;}
  .filter-panel {padding:16px;}
  .filter-panel-head {align-items:flex-start;}
  .library-toolbar .search-box {flex-basis:100%;min-width:0;}
  .library-toolbar > .select-wrap {flex:1;}
  .library-toolbar select {width:100%;}
  .fc-top {flex-wrap:wrap;}
  .fc-time {order:3;flex-basis:100%;margin:0;white-space:normal;}
  .fc-actions {margin-left:auto;}
  .clip-heading {flex-wrap:wrap;}
  .clip-source {white-space:normal;}
  .writing-area {padding:20px 16px;}
  .writing-meta {font-size:.78rem;}
}
@media (max-width:360px) {
  .mobile-brand {font-size:0;gap:0;}
  .mobile-brand .brand-study,.mobile-brand .brand-dot {display:none;}
  .mobile-brand .brand-mark {width:34px;height:34px;}
  .mobile-topbar {gap:8px;}
  .hero-chip {white-space:normal;flex-wrap:wrap;}
  .stat-row {grid-template-columns:repeat(2,minmax(0,1fr));}
  .strategy-grid {grid-template-columns:minmax(0,1fr);}
}
@media (hover:none) {
  .strategy-card:hover,.stat-tile:hover,.scene-tile:hover,.scene-tile:hover svg.art,.match-item:hover,.quiz-option:hover,.rate-btn:hover,.practice-btn:hover,.chapter-row:hover,.related-row:hover,.scene-choice:hover {transform:none;box-shadow:var(--shadow);}
}
.importance-badge {display:inline-flex;align-items:center;gap:8px;flex-wrap:wrap;max-width:100%;font-size:.78rem;font-weight:700;line-height:1.6;color:var(--muted);}
.importance-stars {display:inline-flex;align-items:center;gap:3px;flex-shrink:0;color:var(--accent-text);}
.importance-stars > span {display:inline-flex;}
.importance-stars .filled svg {fill:currentColor;}
.tile-main .importance-badge {margin-top:8px;}
.choice-copy .importance-badge {margin-top:4px;}
.importance-detail .importance-badge {display:flex;margin:8px 0;}
.importance-detail .importance-help {font-size:.85rem;color:var(--muted);}
@media print {
  html,html[data-theme="dark"] {color-scheme:light;--ink:#20251b;--ink-soft:#3d4533;--muted:#515b45;--paper:#fff;--card:#fff;--art-ink:#343d2b;--art-wash:#f3ecd0;--art-detail:#fff;--accent-text:#604d16;}
  .view-wrap {padding:0!important;max-width:none;}
  .library-toolbar,.filter-panel,.active-pills {display:none!important;}
  .scene-tile,.scene-tile .tile-main {color:#20251b!important;background:#fff!important;}
  .scene-tile svg.art {color:#343d2b!important;}
  .scene-tile .scene-timestamp,.tile-char,.tile-analysis,.tile-tags i,.tile-tags b {color:#39422f!important;}
  .tile-notedot,.tile-ring {display:none;}
}
