/* ── CSS Variables & App Shell ──────────────────────────── */
    :root {
      --blue: #4a90e2;
      --orange: #e07b00;
      --green: #2a7a2a;
      /* Theme variables — overridden by [data-theme] */
      --brand: #4a90e2;
      --brand-header: #4a90e2;
      --brand-tint: #f0f7ff;
      --nav-h: 49px;
      --header-h: 50px;
      --sidebar-w: 220px;
      --banner-h: 0px;
      --sab: max(env(safe-area-inset-bottom, 20px), 20px);
      --paragraph-font-family: -apple-system, BlinkMacSystemFont, 'Hiragino Kaku Gothic ProN', sans-serif;
      --paragraph-font-size: 1rem;
    }
    [data-theme="forest"] {
      --brand: #357d5e;
      --brand-header: #357d5e;
      --brand-tint: #eef7f2;
    }
    *, *::before, *::after { box-sizing: border-box; }
    .btn-primary {
      background: var(--brand); color: #fff; border: none;
      border-radius: 8px; cursor: pointer;
      font-size: 0.95rem; font-weight: 600; padding: 0.6rem 1.2rem;
      transition: opacity 0.15s;
    }
    .btn-primary:hover { opacity: 0.88; }
    .btn-primary:disabled { opacity: 0.55; cursor: not-allowed; }
    html, body { overflow: hidden; height: 100%; }
    #app-shell { height: 100dvh; overflow: hidden; overscroll-behavior: none; }
    #app-header {
      position: fixed; top: var(--banner-h); left: 0; right: 0;
      padding-top: env(safe-area-inset-top, 0px);
      background: var(--brand-header); color: #fff;
      z-index: 500; box-shadow: 0 1px 4px rgba(0,0,0,0.15);
    }
    #app-header-inner {
      height: var(--header-h);
      display: flex; align-items: center;
      padding: 0 1rem; gap: 0.75rem;
    }
    #app-title { font-size: 1.1rem; font-weight: 700; letter-spacing: 0.01em; flex: 1; }
    .tab-content {
      display: none; position: fixed;
      top: calc(var(--banner-h) + var(--header-h) + env(safe-area-inset-top, 0px)); left: 0; right: 0;
      bottom: calc(var(--nav-h) + var(--sab));
      overflow-y: auto; overflow-x: hidden; padding: 1rem;
      -webkit-overflow-scrolling: touch;
      transition: bottom 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    }
    .tab-content.active { display: block; }
    #tab-nav {
      position: fixed; bottom: 0; left: 0; right: 0;
      height: calc(var(--nav-h) + var(--sab));
      padding-bottom: var(--sab);
      background: #fff; border-top: 1px solid #e0e0e0;
      display: flex; z-index: 400;
      transform: translateZ(0);
      transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    }
    body.nav-hidden #tab-nav {
      transform: translateY(100%) !important;
    }
    body.nav-hidden .tab-content {
      bottom: 0;
    }
    @media (max-width: 767px) {
      body.nav-hidden #word-panel {
        bottom: 0;
      }
    }
    button, .tab-btn, .stat-item, .rm-btn {
      touch-action: manipulation;
      -webkit-tap-highlight-color: transparent;
    }
    .tab-btn {
      flex: 1; display: flex; flex-direction: column; align-items: center;
      justify-content: center; gap: 2px;
      background: none; border: none; cursor: pointer;
      color: #999; padding: 6px 0;
      transition: color 0.15s; min-height: 44px;
    }
    .tab-btn svg { width: 22px; height: 22px; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
    .tab-btn span { font-size: 0.59rem; }
    .tab-btn.active { color: var(--brand); }
    /* Word manager in words tab – always open, non-collapsible feel */
    #tab-words > details[id="word-manager"] > summary {
      pointer-events: none; list-style: none; cursor: default;
      font-size: 1.05rem; font-weight: bold; color: #333;
      padding: 0 0 0.6rem; border-bottom: 1px solid #eee; margin-bottom: 0.5rem;
    }
    #tab-words > details[id="word-manager"] > summary::before,
    #tab-words > details[id="word-manager"] > summary::-webkit-details-marker { display: none; }
    /* Stats bar mobile: compact 4-column single row */
    @media (max-width: 767px) {
      #study-header-row { margin-bottom: 0.6rem; }
      #stats-bar {
        display: flex;
        flex-direction: row;
        gap: 0;
        padding: 0.25rem 0.3rem;
        margin-bottom: 0;
      }
      .stat-item {
        flex: 1;
        min-width: 0;
        padding: 0.15rem 0.05rem;
        border-radius: 3px;
      }
      .stat-value { font-size: 0.85rem; }
      .stat-label { font-size: 0.5em; }
    }
    /* Settings – user section */
    #settings-user-section { margin-top: 2rem; padding-top: 1.5rem; border-top: 1px solid #eee; }
    #settings-user-section h2 { font-size: 1rem; margin: 0 0 0.75rem; color: #333; }
    #settings-username-display { font-size: 0.85rem; color: #888; margin-bottom: 1rem; }
    .settings-btn {
      display: block; width: 100%; text-align: left;
      padding: 0.65rem 0.9rem; margin-bottom: 0.5rem;
      background: #f5f5f5; border: 1px solid #e0e0e0; border-radius: 8px;
      cursor: pointer; font-size: 0.9rem; color: #333;
    }
    .settings-btn:hover { background: #eaeaea; }
    .settings-btn.danger { color: #c00; border-color: #fcc; background: #fff5f5; }
    .settings-btn.danger:hover { background: #ffe0e0; }
    /* About tab */
    #tab-about { line-height: 1.7; }
    #tab-about h1 { font-size: 1.25rem; margin: 0 0 0.2rem; color: #222; }
    #tab-about .about-subtitle { font-size: 0.88rem; color: #999; margin: 0 0 1.5rem; }
    #tab-about h2 { font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.07em; color: #aaa; margin: 1.5rem 0 0.6rem; }
    .about-step {
      display: flex; gap: 0.75rem; align-items: flex-start;
      margin-bottom: 0.6rem; padding: 0.7rem 0.85rem;
      background: #f8f9fb; border-radius: 8px;
      border-left: 3px solid var(--brand);
    }
    .about-step-num { font-size: 1rem; font-weight: 700; color: var(--brand); flex-shrink: 0; min-width: 1.1rem; line-height: 1.6; }
    .about-step-body strong { display: block; font-size: 0.88rem; color: #222; margin-bottom: 0.1rem; }
    .about-step-body span { font-size: 0.82rem; color: #555; }
    .about-tip { background: #fffbe6; border: 1px solid #ffe58a; border-radius: 6px; padding: 0.55rem 0.85rem; margin-bottom: 0.5rem; font-size: 0.84rem; color: #7a5c00; }
    .about-nav-table { font-size: 0.87rem; color: #444; }
    .about-nav-table tr td:first-child { font-weight: 600; width: 5.5rem; color: #333; padding: 0.2rem 0; }
    .about-nav-table tr td:last-child { color: #666; }
    .about-footer { margin-top: 2rem; padding-top: 1rem; border-top: 1px solid #eee; font-size: 0.76rem; color: #ccc; text-align: center; }
    /* Desktop overrides */
    @media (min-width: 768px) {
      #app-header { left: var(--sidebar-w); }
      #tab-nav {
        top: calc(var(--header-h) + env(safe-area-inset-top, 0px)); bottom: 0; left: 0; right: auto;
        width: var(--sidebar-w); height: auto; flex-direction: column;
        border-top: none; border-right: 1px solid #e0e0e0;
        padding-bottom: 0; background: #fafafa;
        align-items: stretch; padding-top: 0.5rem;
      }
      .tab-btn {
        flex: none; flex-direction: row; justify-content: flex-start;
        gap: 0.65rem; padding: 0.7rem 1rem; font-size: 0.88rem;
        border-radius: 6px; margin: 1px 6px; min-height: 42px;
      }
      .tab-btn svg { width: 18px; height: 18px; }
      .tab-btn span { font-size: 0.88rem; }
      .tab-content { left: var(--sidebar-w); bottom: 0; padding: 1.5rem 2rem; }
    }
    /* ── /App Shell ─────────────────────────────────────────── */
    body {
      font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Arial, sans-serif;
      margin: 0;
      padding: 0;
      line-height: 1.6;
    }
    button {
      margin-right: 0.75rem;
      margin-bottom: 1rem;
      padding: 0.5rem 0.8rem;
      cursor: pointer;
    }
    #paragraph {
      border: none;
      background: #fafafa;
      padding: 1rem 1rem;
      border-radius: 10px;
      font-family: var(--paragraph-font-family);
      font-size: var(--paragraph-font-size);
      line-height: 1.85;
      margin: 0;
      white-space: normal;
    }
    [data-theme="dark"] #paragraph { background: #242427; }
    #paragraph:empty {
      min-height: 200px;
      display: flex;
      align-items: center;
      justify-content: center;
    }
    #paragraph:empty::before {
      content: "Press Study to begin";
      color: #b0b0b0;
      font-style: italic;
      font-size: 0.95em;
      letter-spacing: 0.01em;
    }
    #paragraph.has-story:empty::before { content: "Press Study to continue"; }
    #paragraph.is-generating:empty::before { content: "Generating…"; }
    .word {
      cursor: pointer;
      padding: 0;
      border-radius: 4px;
      user-select: none;
    }
    .word.selected {
      background: #ffe58a;
      position: relative;
    }
    .word.selected[data-reading]:hover::after {
      content: attr(data-reading);
      position: absolute;
      bottom: calc(100% + 4px);
      left: 50%;
      transform: translateX(-50%);
      background: #333;
      color: #fff;
      padding: 2px 7px;
      border-radius: 4px;
      font-size: 0.78em;
      white-space: nowrap;
      pointer-events: none;
      z-index: 10;
    }
    /* Ruby reading text */
    ruby.word { display: inline ruby; }
    ruby.word rt { font-size: 0; line-height: 0; color: #555; text-align: center; transition: font-size 0.1s; }
    ruby.word.selected rt { font-size: 0.55em; line-height: normal; }
    #paragraph.furigana-always { line-height: 2.2; }
    #paragraph.furigana-always ruby.word rt { font-size: 0.55em; line-height: normal; }
    /* Word states */
    .word.known-word { color: #1a7a1a; opacity: 0.75; }
    #paragraph.no-tint .word.known-word { color: inherit; opacity: 1; }
    .word.panel-active { outline: 2px solid var(--brand); outline-offset: 1px; border-radius: 3px; }
    /* Word count badge — inline meta chip */
    #word-count-badge {
      display: none;
      padding: 1px 8px;
      border-radius: 999px;
      font-size: inherit;
      font-weight: 500;
      color: #1a7a1a;
      background: rgba(42, 154, 42, 0.10);
      vertical-align: middle;
    }
    /* Display mode toggle bar */
    #reading-mode-bar { display: flex; align-items: center; gap: 0.4rem; margin: 0.5rem 0 0.75rem; flex-wrap: wrap; }
    .rm-label { font-size: 0.85em; color: #555; margin-right: 0.2rem; }
    .rm-btn { padding: 0.25rem 0.75rem; border: 1px solid #ccc; border-radius: 999px; background: #f5f5f5; color: #444; cursor: pointer; font-size: 0.85em; transition: background 0.15s, color 0.15s, border-color 0.15s; margin: 0; }
    .rm-btn:hover { background: #e8e8e8; }
    .rm-btn.active { background: var(--brand); color: #fff; border-color: var(--brand); }
    /* ── Study landing cards ─────────────────────────────── */
    #study-landing { display: flex; flex-direction: column; gap: 1rem; margin-top: 0.5rem; }
    .study-card { display: flex; align-items: center; gap: 1rem; padding: 1.1rem 1.25rem; border: 1px solid #e0e0e0; border-radius: 12px; background: #fafafa; }
    .study-card-icon { width: 2rem; height: 2rem; flex-shrink: 0; color: #888; display: flex; align-items: center; justify-content: center; }
    .study-card-icon svg { width: 100%; height: 100%; display: block; }
    .study-card-body { flex: 1; min-width: 0; }
    .study-card-body h2 { margin: 0 0 0.2rem; font-size: 1rem; font-weight: 600; }
    .study-card-body p { margin: 0; font-size: 0.85em; color: #666; }
    .study-card-btn { flex-shrink: 0; padding: 0.45rem 1.1rem; border-radius: 8px; border: none; background: var(--brand); color: #fff; font-size: 0.9em; font-weight: 500; cursor: pointer; }
    .study-card-btn:hover { opacity: 0.88; }
    .study-btn { border-radius: 6px; padding: 0.5rem 1.1rem; font-size: 0.95rem; font-weight: 500; cursor: pointer; transition: background-color 0.25s ease, color 0.25s ease, opacity 0.2s ease; border: none; margin-right: 0; margin-bottom: 0; }
    .study-btn-generate { background: #f5f5f5; color: #333; border: 1px solid #e0e0e0; }
    .study-btn-generate:hover { background: #e8e8e8; }
    .study-btn-generating { background: var(--orange); color: #fff; }
    .study-btn-clear { background: #9a2a2a; color: #fff; }
    .study-btn-clear:hover { background: #7a1a1a; }
    .study-btn-submit { background: var(--green); color: #fff; }
    .study-btn-submit:hover { background: #1e681e; }

    /* ── Study stage (action + paragraph + submit grouped card) ───────────── */
    .study-stage {
      background: #fff;
      border: 1px solid #ececec;
      border-radius: 14px;
      padding: 1rem 1rem 0.85rem;
      box-shadow: 0 1px 2px rgba(0,0,0,0.03), 0 4px 16px rgba(0,0,0,0.04);
      display: flex;
      flex-direction: column;
      gap: 0.65rem;
      margin-top: 0.5rem;
    }
    [data-theme="dark"] .study-stage {
      background: #1c1c1e;
      border-color: #2a2a2c;
      box-shadow: 0 1px 2px rgba(0,0,0,0.4), 0 4px 16px rgba(0,0,0,0.25);
    }
    .study-stage-actions {
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 0.5rem;
      flex-wrap: wrap;
    }
    .study-btn-primary {
      background: var(--brand);
      color: #fff;
      border: none;
      border-radius: 8px;
      padding: 0.6rem 1.4rem;
      font-size: 0.98rem;
      font-weight: 600;
      cursor: pointer;
      transition: opacity 0.15s ease, background-color 0.2s ease;
    }
    .study-btn-primary:hover { opacity: 0.9; }
    .study-btn-primary.study-btn-generating { background: var(--orange); }
    .study-btn-primary.study-btn-clear { background: #9a2a2a; }
    .study-btn-ghost {
      display: inline-flex;
      align-items: center;
      gap: 0.35rem;
      background: transparent;
      border: none;
      color: #888;
      font-size: 0.85em;
      padding: 0.4rem 0.55rem;
      border-radius: 6px;
      cursor: pointer;
      transition: background-color 0.15s ease, color 0.15s ease;
    }
    .study-btn-ghost:hover { background: rgba(0,0,0,0.05); color: #555; }
    [data-theme="dark"] .study-btn-ghost:hover { background: rgba(255,255,255,0.06); color: #ccc; }

    .study-stage-meta {
      display: flex;
      align-items: center;
      gap: 0.6rem;
      min-height: 1.1em;
      font-size: 0.78em;
      color: #888;
      letter-spacing: 0.01em;
      padding: 0 0.15rem;
    }
    #story-para-label { color: #aaa; }

    .study-stage-submit {
      min-height: 44px;
      display: flex;
      justify-content: flex-start;
      align-items: center;
      margin-top: 0.15rem;
    }
    #submitBtn {
      opacity: 0;
      pointer-events: none;
      transition: opacity 0.2s ease;
    }
    #submitBtn.is-ready {
      opacity: 1;
      pointer-events: auto;
    }
    #submitBtn.is-submitting {
      background: var(--orange);
    }
    /* Story sync pill */
    #story-sync-pill {
      position: fixed;
      bottom: calc(var(--nav-h) + var(--sab) + 10px);
      right: 14px;
      display: flex;
      align-items: center;
      gap: 5px;
      background: rgba(255,255,255,0.93);
      border: 1px solid #e0e0e0;
      border-radius: 20px;
      padding: 3px 9px 3px 6px;
      font-size: 0.68rem;
      font-weight: 500;
      letter-spacing: 0.03em;
      color: #666;
      z-index: 390;
      pointer-events: none;
      box-shadow: 0 1px 5px rgba(0,0,0,0.07);
      opacity: 0;
      transform: translateY(6px) scale(0.96);
      transition: opacity 0.2s ease, transform 0.2s ease;
    }
    #story-sync-pill.visible {
      opacity: 1;
      transform: translateY(0) scale(1);
    }
    #story-sync-dot {
      width: 6px;
      height: 6px;
      border-radius: 50%;
      flex-shrink: 0;
      background: var(--orange);
    }
    #story-sync-pill.syncing #story-sync-dot {
      animation: sync-pulse 1.1s ease-in-out infinite;
    }
    #story-sync-pill.ready #story-sync-dot {
      background: var(--green);
    }
    @keyframes sync-pulse {
      0%, 100% { opacity: 1; transform: scale(1); }
      50% { opacity: 0.3; transform: scale(0.6); }
    }
    .study-section-topbar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 0.1rem; }
    .study-back-btn { display: inline-flex; align-items: center; gap: 0.3rem; background: none; border: 1px solid #ccc; color: #555; font-size: 0.85em; border-radius: 6px; padding: 0.25rem 0.6rem; cursor: pointer; margin-bottom: 0.75rem; }
    .study-back-btn:hover { border-color: #aaa; color: #333; }
    .study-gear-btn { background: none; border: none; color: #aaa; cursor: pointer; padding: 0.5rem 0.4rem 0.5rem 0; margin: 0; transition: color 0.15s; display: flex; align-items: center; }
    .study-gear-btn svg { width: 1.1rem; height: 1.1rem; display: block; }
    .study-gear-btn:hover { color: #555; }
    .study-card-actions { display: flex; align-items: center; gap: 0.4rem; flex-shrink: 0; }
    .study-card-actions button { margin: 0; }
    .study-gear-card { padding: 0.45rem 0.6rem; color: #aaa; display: flex; align-items: center; border: 1px solid #ccc; border-radius: 6px; }
    .study-gear-card svg { width: 1.15rem; height: 1.15rem; }
    .study-gear-card:hover { color: #555; border-color: #999; }

    /* ── Listening / Podcast ─────────────────────────────── */
    #podcast-player { display: flex; flex-direction: column; gap: 0.85rem; padding-bottom: 11rem; }

    /* Track card */
    #podcast-track-info {
      background: #fff;
      border: 1px solid #e4e4e4;
      border-radius: 12px;
      padding: 1rem 1.15rem;
    }
    #podcast-track-header {
      display: flex; align-items: center; justify-content: flex-end;
      min-height: 1rem; margin-bottom: 0.4rem;
    }
    #podcast-track-num {
      font-size: 0.72em; font-weight: 600;
      color: var(--brand);
      background: #fff;
      border: 1px solid #d6e4f3;
      padding: 0.18rem 0.6rem;
      border-radius: 999px;
      letter-spacing: 0.02em;
      font-variant-numeric: tabular-nums;
    }
    #podcast-track-num:empty { display: none; }
    #podcast-track-text {
      margin: 0;
      font-size: var(--paragraph-font-size);
      line-height: 1.7;
      font-family: var(--paragraph-font-family);
      color: #222;
    }
    #podcast-track-text .speaking { text-decoration: underline; text-decoration-color: var(--orange); text-decoration-thickness: 3px; text-underline-offset: 3px; }

    /* Empty state */
    #podcast-empty {
      display: flex; flex-direction: column; align-items: center;
      text-align: center; padding: 3rem 1rem 4rem; color: #888;
    }
    .podcast-empty-icon { width: 3.25rem; height: 3.25rem; color: #c4c4c4; margin-bottom: 0.85rem; }
    .podcast-empty-icon svg { width: 100%; height: 100%; }
    #podcast-empty h3 { margin: 0 0 0.35rem; font-size: 1.05rem; font-weight: 600; color: #555; }
    #podcast-empty p { margin: 0; font-size: 0.9em; max-width: 22rem; }

    /* Playlist */
    #podcast-playlist { display: flex; flex-direction: column; gap: 0.5rem; margin-top: 0.25rem; }
    .podcast-playlist-item {
      display: flex; align-items: center; gap: 0.85rem;
      padding: 0.7rem 0.9rem;
      border-radius: 10px;
      border: 1px solid #e8e8e8;
      background: #fff;
      cursor: pointer;
      transition: background 0.15s, border-color 0.15s;
    }
    .podcast-playlist-item:hover { background: #fafafa; border-color: #d8d8d8; }
    .podcast-playlist-item.active { background: var(--brand-tint); border-color: var(--brand); }
    .ppl-num {
      flex-shrink: 0;
      width: 1.85rem; height: 1.85rem;
      display: flex; align-items: center; justify-content: center;
      border-radius: 50%;
      font-size: 0.78em; font-weight: 600;
      border: 1.5px solid #d0d0d0;
      color: #888;
      background: #fff;
      font-variant-numeric: tabular-nums;
      transition: background 0.15s, border-color 0.15s, color 0.15s;
    }
    .podcast-playlist-item.active .ppl-num { border-color: var(--brand); color: var(--brand); }
    .podcast-playlist-item.played .ppl-num { background: var(--brand); border-color: var(--brand); color: #fff; }
    .ppl-text {
      flex: 1; min-width: 0;
      font-size: 0.92em; color: #333;
      white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
    }
    .ppl-dur {
      flex-shrink: 0;
      font-size: 0.78em; color: #999;
      font-variant-numeric: tabular-nums;
    }

    .podcast-option-toggle { display: flex; align-items: center; gap: 0.4rem; font-size: 0.85em; color: #555; cursor: pointer; user-select: none; }
    .podcast-option-toggle input { accent-color: var(--brand); width: 15px; height: 15px; }

    /* Voice picker (Listening Settings) */
    #cfg-voice-list { display: flex; flex-direction: column; gap: 0.4rem; margin: 0 0 1rem; }
    .voice-card {
      display: flex; align-items: center; gap: 0.85rem;
      padding: 0.7rem 0.85rem;
      border: 1px solid #e0e0e0; border-radius: 10px;
      background: #fff; cursor: pointer;
      transition: background 0.15s, border-color 0.15s;
    }
    .voice-card:hover { background: #fafafa; border-color: #c8c8c8; }
    .voice-card.selected { background: var(--brand-tint); border-color: var(--brand); }
    .vc-info { flex: 1; min-width: 0; }
    .vc-name { font-size: 0.95em; font-weight: 600; color: #333; }
    .vc-desc { font-size: 0.8em; color: #888; margin-top: 0.1rem; }
    .vc-preview {
      flex-shrink: 0;
      width: 2rem; height: 2rem;
      border: 1px solid #d0d0d0; border-radius: 50%;
      background: #fff; color: #555; cursor: pointer;
      display: inline-flex; align-items: center; justify-content: center;
      margin: 0; padding: 0;
      transition: background 0.15s, color 0.15s, border-color 0.15s;
    }
    .vc-preview:hover { background: var(--brand-tint); color: var(--brand); border-color: var(--brand); }
    .vc-preview.playing { background: var(--brand); color: #fff; border-color: var(--brand); }
    .vc-preview svg { width: 0.85rem; height: 0.85rem; }

    /* Playbar */
    #podcast-playbar {
      position: fixed;
      bottom: var(--nav-h);
      left: 0; right: 0;
      background: #fff;
      border-top: 1px solid #ececec;
      border-top-left-radius: 16px;
      border-top-right-radius: 16px;
      padding: 0.65rem 1rem calc(0.55rem + var(--sab, 0px));
      display: flex; flex-direction: column; gap: 0.4rem;
      z-index: 90;
      box-shadow: 0 -6px 20px rgba(0,0,0,0.06);
    }
    @media (min-width: 768px) {
      #podcast-playbar { left: var(--sidebar-w); }
    }
    body.nav-hidden #podcast-playbar { bottom: 0; }
    body.listening-mode #dict-fab { bottom: calc(9rem + var(--sab)); }
    #podcast-progress-wrap { display: flex; flex-direction: column; gap: 0.05rem; }
    #podcast-seek { width: 100%; accent-color: var(--brand); height: 4px; }
    #podcast-time { font-size: 0.72em; color: #999; text-align: right; font-variant-numeric: tabular-nums; }

    #podcast-controls {
      display: flex; justify-content: center; align-items: center;
      gap: 0.4rem;
    }
    .pb-btn {
      background: none; border: none; cursor: pointer;
      padding: 0.4rem; margin: 0;
      color: #444;
      display: inline-flex; align-items: center; justify-content: center;
      border-radius: 50%;
      transition: background 0.15s, color 0.15s, opacity 0.15s;
    }
    .pb-btn:hover { background: #f2f2f2; color: var(--brand); }
    .pb-btn svg { width: 1.45rem; height: 1.45rem; display: block; }

    .pb-btn-skip { position: relative; }
    .pb-btn-skip svg { width: 1.4rem; height: 1.4rem; }
    .pb-skip-num {
      position: absolute;
      top: 50%; left: 50%;
      transform: translate(-50%, -42%);
      font-size: 0.58em; font-weight: 700;
      color: #444;
      pointer-events: none;
      font-variant-numeric: tabular-nums;
    }
    .pb-btn-skip:hover .pb-skip-num { color: var(--brand); }

    .pb-btn-play {
      background: var(--brand); color: #fff;
      width: 2.85rem; height: 2.85rem;
      padding: 0;
    }
    .pb-btn-play:hover { background: var(--brand); color: #fff; opacity: 0.88; }
    .pb-btn-play svg { width: 1.3rem; height: 1.3rem; }

    /* Secondary row: A↔B loop  ·  speed pills  ·  ⋯ menu */
    #podcast-secondary {
      display: flex; align-items: center; justify-content: space-between;
      gap: 0.4rem; min-height: 2rem;
    }
    #podcast-speed-wrap { display: flex; align-items: center; justify-content: center; flex: 1; min-width: 0; }
    #podcast-speed-btns { display: flex; gap: 0.25rem; flex-wrap: nowrap; justify-content: center; }
    .speed-btn {
      padding: 0.28rem 0.55rem;
      border: 1px solid #e0e0e0;
      border-radius: 999px;
      background: #fff;
      color: #666;
      font-size: 0.78em;
      cursor: pointer; margin: 0;
      font-variant-numeric: tabular-nums;
    }
    .speed-btn:hover { background: #f5f5f5; }
    .speed-btn.active { background: var(--brand); color: #fff; border-color: var(--brand); }

    .pb-secondary {
      flex-shrink: 0;
      background: none; border: none; cursor: pointer;
      padding: 0.35rem 0.55rem; margin: 0;
      color: #888;
      display: inline-flex; align-items: center; gap: 0.3rem;
      border-radius: 8px;
      font-size: 0.76em; font-weight: 600;
      transition: background 0.15s, color 0.15s;
      font-variant-numeric: tabular-nums;
    }
    .pb-secondary:hover { background: #f2f2f2; color: var(--brand); }
    .pb-secondary svg { width: 1rem; height: 1rem; display: block; }
    .pb-secondary.active { color: var(--brand); background: var(--brand-tint); }
    .pb-secondary-icon { padding: 0.4rem; }
    .pb-secondary-icon svg { width: 1.15rem; height: 1.15rem; }
    .pb-loop-state { letter-spacing: 0.02em; }

    /* ⋯ overflow menu */
    .pb-menu {
      position: absolute;
      bottom: calc(100% + 0.4rem); right: 0.75rem;
      background: #fff;
      border: 1px solid #e0e0e0;
      border-radius: 12px;
      box-shadow: 0 8px 28px rgba(0,0,0,0.14);
      padding: 0.4rem;
      min-width: 15rem;
      z-index: 95;
    }
    .pb-menu-item {
      display: flex; align-items: center; justify-content: space-between;
      padding: 0.55rem 0.65rem; gap: 1rem;
      font-size: 0.86em; color: #444;
    }
    .pb-menu-item + .pb-menu-item { border-top: 1px solid #f0f0f0; }
    .pb-menu-item > label { font-weight: 500; color: #555; }
    .pb-menu-item select {
      padding: 0.28rem 0.4rem; font-size: 0.92em;
      border: 1px solid #d0d0d0; border-radius: 6px; background: #fff;
      color: #333;
    }
    .pb-menu-item .podcast-option-toggle { width: 100%; }

    /* ── Reading section layout ───────────────────────────── */
    #reading-section { display: flex; flex-direction: column; }
    #reading-content-row { display: flex; align-items: flex-start; width: 100%; }
    #reading-main { flex: 1; min-width: 0; }

    /* ── Study tab flex row (content col + word panel sidebar) ── */
    @media (min-width: 768px) {
      #tab-study.active { display: flex !important; align-items: flex-start; }
      #study-content-col { flex: 1; min-width: 0; }
    }

    /* ── Word panel — desktop sidebar (reading mode only) ───── */
    @media (min-width: 768px) {
      #word-panel { display: none; }
      body.reading-active #word-panel { display: block; width: 270px; margin-left: 1.25rem; flex-shrink: 0; overflow: hidden; opacity: 1; }
      #wp-inner { width: 270px; border: 1px solid #e0e0e0; border-radius: 8px; background: #fafafa; padding: 1rem; overflow-y: auto; max-height: 80vh; position: sticky; top: 1rem; box-sizing: border-box; }
      #wp-placeholder { display: flex; align-items: center; justify-content: center; min-height: 80px; color: #bbb; font-size: 0.85rem; text-align: center; padding: 1rem; }
      #word-panel.open #wp-placeholder { display: none; }
      #wp-word-content { display: none; }
      #word-panel.open #wp-word-content { display: block; }
      #wp-backdrop { display: none !important; }
      #wp-close { display: none; }
    }

    /* ── Word panel — mobile bottom sheet ────────────────── */
    @media (max-width: 767px) {
      #word-panel { position: fixed; bottom: calc(var(--nav-h) + var(--sab)); left: 0; right: 0; background: #fff; border-radius: 16px 16px 0 0; box-shadow: 0 -4px 24px rgba(0,0,0,0.16); max-height: 80vh; transform: translateY(100%); transition: transform 0.28s cubic-bezier(0.4,0,0.2,1); z-index: 901; }
      #word-panel.open { transform: translateY(0); }
      #wp-inner { overflow-y: auto; max-height: 80vh; padding: 1rem 1.25rem 1.5rem; -webkit-overflow-scrolling: touch; }
      #wp-backdrop { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.35); z-index: 900; }
      #wp-backdrop.visible { display: block; }
    }

    /* ── Word panel contents ──────────────────────────────── */
    #wp-header { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 0.4rem; }
    #wp-header-actions { display: flex; align-items: center; gap: 0.1rem; flex-shrink: 0; }
    #wp-title { display: flex; flex-direction: column; gap: 0.15rem; }
    #wp-surface { font-size: 1.55rem; font-weight: bold; color: #111; line-height: 1.2; }
    #wp-reading { font-size: 1rem; color: #666; }
    #wp-close { background: none; border: none; font-size: 1.3rem; cursor: pointer; color: #aaa; min-width: 36px; min-height: 36px; display: flex; align-items: center; justify-content: center; padding: 0; }
    #wp-close:hover { color: #333; }
    #wp-kebab { background: none; border: none; font-size: 1.2rem; cursor: pointer; color: #aaa; min-width: 32px; min-height: 36px; display: flex; align-items: center; justify-content: center; padding: 0; letter-spacing: 0.05em; }
    #wp-kebab:hover { color: #333; }
    #wp-kebab-menu { position: relative; border: 1px solid #e0e0e0; border-radius: 6px; background: #fff; padding: 0.3rem 0; margin-bottom: 0.5rem; box-shadow: 0 2px 8px rgba(0,0,0,0.08); }
    #wp-kebab-menu button { display: block; width: 100%; text-align: left; background: none; border: none; padding: 0.4rem 0.75rem; font-size: 0.88rem; cursor: pointer; color: #333; }
    #wp-kebab-menu button:hover { background: #f5f5f5; }
    #wp-delete-btn { color: #c00 !important; }
    #wp-pos { display: flex; flex-wrap: wrap; gap: 0.3rem; margin-bottom: 0.35rem; min-height: 1em; }
    .wp-pos-chip { font-size: 0.72em; color: #666; text-transform: uppercase; letter-spacing: 0.04em; background: #f0f0f0; border-radius: 3px; padding: 1px 5px; }
    #wp-badges { display: flex; flex-wrap: wrap; gap: 0.3rem; margin-bottom: 0.55rem; }
    .wp-badge { font-size: 0.75em; font-weight: 600; border-radius: 3px; padding: 1px 6px; letter-spacing: 0.03em; }
    .wp-badge-jlpt { background: #555; color: #fff; }
    .wp-badge-common { background: #e8f5e9; color: #2e7d32; border: 1px solid #c8e6c9; }
    #wp-loading { color: #999; font-size: 0.88em; padding: 0.25rem 0; }
    #wp-error { color: #c00; font-size: 0.85em; margin-bottom: 0.5rem; }
    #wp-senses { margin: 0 0 0.3rem; padding-left: 1.2rem; font-size: 0.93rem; line-height: 1.65; color: #222; }
    #wp-senses li { margin-bottom: 0.15rem; }
    .wp-sense-tags { font-size: 0.82em; color: #bbb; }
    .wp-sense-tag { cursor: default; border-bottom: 1px dotted #ccc; }
    .wp-more-btn { width: 100%; padding: 0.2rem 0; font-size: 0.83em; cursor: pointer; border: none; background: none; color: var(--brand); text-align: left; margin-bottom: 0.25rem; text-decoration: underline; text-underline-offset: 2px; }
    .wp-more-btn:hover { opacity: 0.75; }
    #wp-supplemental { margin-top: 0.75rem; }
    #wp-srs { margin-top: 0.75rem; border-top: 1px solid #eee; padding-top: 0.5rem; }
    .wp-srs-label { font-weight: 600; font-size: 0.88rem; color: #444; }
    .wp-srs-detail { font-size: 0.88rem; color: #888; }
    #wp-srs-actions { display: flex; gap: 0.5rem; margin-top: 0.5rem; }
    #wp-suspend-btn { flex: 1; padding: 0.35rem 0.5rem; font-size: 0.82em; cursor: pointer; border: 1px solid #e6c200; border-radius: 4px; background: #fff8d0; color: #7a5f00; }
    #wp-suspend-btn:hover { background: #fff0a0; }
    #wp-delete-btn { flex: 1; padding: 0.35rem 0.5rem; font-size: 0.82em; cursor: pointer; border: 1px solid #f5c6cb; border-radius: 4px; background: #fff5f5; color: #c00; }
    #wp-delete-btn:hover { background: #ffe0e0; }
    .wp-section-label { font-size: 0.7em; text-transform: uppercase; letter-spacing: 0.07em; color: #aaa; margin: 0.8rem 0 0.3rem; }
    #wp-context { font-size: 0.88rem; line-height: 1.65; color: #444; background: #f4f4f4; border-radius: 4px; padding: 0.4rem 0.6rem; }
    #wp-context mark { background: #ffe58a; border-radius: 2px; padding: 0 1px; font-style: normal; }
    #wp-custom-input { width: 100%; box-sizing: border-box; padding: 0.4rem 0.5rem; font-size: 0.88rem; border: 1px solid #ddd; border-radius: 4px; resize: vertical; font-family: inherit; margin-top: 0.2rem; }
    #wp-custom-save { margin-top: 0.35rem; padding: 0.3rem 0.75rem; font-size: 0.85em; cursor: pointer; border: 1px solid var(--brand); border-radius: 4px; background: var(--brand); color: #fff; }
    #wp-custom-save:hover { opacity: 0.88; }
    #wp-custom-saved { font-size: 0.88rem; color: #444; background: #eef4ff; border-radius: 4px; padding: 0.3rem 0.5rem; margin-bottom: 0.3rem; white-space: pre-wrap; }
    #wp-kanji-wrap { margin-top: 0.9rem; margin-bottom: 0.25rem; border-top: 1px solid #eee; padding-top: 0.7rem; }
    #wp-kanji-row { display: flex; flex-direction: row; flex-wrap: wrap; gap: 0.4rem; }
    .kanji-row-btn { font-size: 1.6rem; line-height: 1; padding: 0.3rem 0.55rem; background: #f0f0f0; border: 1px solid #ddd; border-radius: 6px; cursor: pointer; color: #222; transition: background 0.12s; }
    .kanji-row-btn:hover { background: #e2e2e2; }
    .kanji-row-btn.active { background: #c8e6c9; border-color: #66bb6a; }
    .kanji-row-btn.active:hover { background: #b2dfdb; }
    #wp-kanji-detail { margin-top: 0.5rem; background: #fafafa; border: 1px solid #eee; border-radius: 6px; padding: 0.55rem 0.75rem; display: none; }
    .kanji-detail-char { font-size: 3.5rem; line-height: 1; color: #222; margin-bottom: 0.4rem; }
    .kanji-detail-meanings { font-size: 0.88rem; color: #222; font-weight: 500; margin-bottom: 0.35rem; }
    .kanji-detail-readings { font-size: 0.82rem; color: #555; display: flex; flex-direction: column; gap: 0.2rem; margin-bottom: 0.25rem; }
    .kanji-detail-meta { font-size: 0.75rem; color: #aaa; }
    .wp-kanji-btn { width: 100%; padding: 0.3rem 0.5rem; font-size: 0.82em; cursor: pointer; border: 1px solid #ddd; border-radius: 4px; background: #f7f7f7; color: #555; text-align: left; }
    .wp-kanji-btn:hover { background: #eee; }
    #wp-explain-wrap { margin-top: 0.2rem; }
    #wp-explain-text { font-size: 0.88rem; line-height: 1.65; color: #444; background: #f4f4f4; border-radius: 4px; padding: 0.4rem 0.6rem; white-space: pre-wrap; }
    .wp-explain-save-btn { margin-top: 0.35rem; padding: 0.3rem 0.75rem; font-size: 0.85em; cursor: pointer; border: 1px solid var(--brand); border-radius: 4px; background: var(--brand); color: #fff; }
    .wp-explain-save-btn:hover { opacity: 0.88; }
    #paragraph-wrap {
      position: relative;
    }
    #status {
      font-size: inherit;
      line-height: 1.3;
      color: #888;
      pointer-events: none;
      opacity: 0;
      transition: opacity 0.25s ease;
      white-space: nowrap;
      overflow: hidden;
      text-overflow: ellipsis;
      max-width: 60%;
    }
    #status.status-visible { opacity: 1; }
    #status.status-error { color: #c53030; }
    #status.status-info  { color: #2a6db5; }
    #word-manager {
      margin-top: 0;
      border-top: none;
      padding-top: 0;
    }
    #word-manager h2 {
      font-size: 0.8rem;
      text-transform: uppercase;
      letter-spacing: 0.07em;
      color: #aaa;
      font-weight: 600;
      margin: 0 0 0.85rem;
    }

    /* ── Add word row ── */
    #add-word-row {
      display: flex;
      gap: 0.5rem;
      margin-bottom: 0.85rem;
      align-items: center;
    }
    #add-word-row input {
      flex: 1;
      padding: 0.55rem 0.85rem;
      border: 1px solid #e5e5ea;
      border-radius: 10px;
      font-size: 0.9rem;
      background: #fff;
      outline: none;
      transition: border-color 0.15s;
    }
    #add-word-row input:focus { border-color: var(--brand); }
    #addWordBtn {
      padding: 0.55rem 1.1rem;
      background: var(--brand);
      color: #fff;
      border: none;
      border-radius: 10px;
      font-size: 0.9rem;
      font-weight: 600;
      cursor: pointer;
      white-space: nowrap;
      transition: opacity 0.15s;
    }
    #addWordBtn:active { opacity: 0.82; }

    /* ── Search + filters ── */
    #word-search {
      width: 100%;
      padding: 0.55rem 0.85rem;
      border: 1px solid #e5e5ea;
      border-radius: 10px;
      font-size: 0.9rem;
      background: #fff;
      box-sizing: border-box;
      outline: none;
      transition: border-color 0.15s;
    }
    #word-search:focus { border-color: var(--brand); }

    #deck-filter-wrap {
      display: flex;
      align-items: center;
      gap: 0.5rem;
      margin: 0.5rem 0;
      font-size: 0.88rem;
    }
    #deck-filter-wrap label {
      color: #888;
      font-weight: 600;
      font-size: 0.8rem;
      text-transform: uppercase;
      letter-spacing: 0.05em;
    }
    #deck-filter-wrap select,
    #wordFilterSelect {
      padding: 0.35rem 0.6rem;
      border: 1px solid #e5e5ea;
      border-radius: 8px;
      font-size: 0.88rem;
      background: #fff;
      color: #333;
    }

    /* ── Pie chart card ── */
    #word-pie-wrap {
      display: flex;
      align-items: center;
      gap: 1rem;
      margin: 0 0 0.85rem;
      background: #fff;
      border: 1px solid #e5e5ea;
      border-radius: 10px;
      padding: 0.85rem 1rem;
    }
    #word-pie-legend {
      display: flex;
      flex-direction: column;
      gap: 0.3rem;
      font-size: 0.83rem;
    }
    .pie-legend-item {
      display: flex;
      align-items: center;
      gap: 0.4rem;
      color: #444;
    }
    .pie-legend-total {
      margin-top: 0.25rem;
      border-top: 1px solid #eee;
      padding-top: 0.25rem;
      font-weight: 600;
      color: #222;
    }
    .pie-swatch {
      width: 10px;
      height: 10px;
      border-radius: 2px;
      flex-shrink: 0;
    }

    /* ── Word table ── */
    .col-advanced { display: none; }
    #words-table.show-advanced .col-advanced { display: table-cell; }
    #words-table {
      width: 100%;
      border-collapse: collapse;
      display: none;
      border: 1px solid #e5e5ea;
      border-radius: 10px;
      overflow: hidden;
      margin-top: 0.5rem;
    }
    details#word-manager[open] #words-table {
      display: table;
    }
    #words-table th, #words-table td {
      text-align: left;
      padding: 0.45rem 0.75rem;
      border-bottom: 1px solid #f0f0f0;
      font-size: 0.88rem;
    }
    #words-table td:last-child, #words-table th:last-child { border-right: none; }
    #words-table th {
      background: #f8f9fb;
      font-size: 0.78rem;
      text-transform: uppercase;
      letter-spacing: 0.05em;
      color: #888;
      font-weight: 600;
    }
    #words-table th.sortable { cursor: pointer; user-select: none; }
    #words-table th.sortable:hover { background: #f0f0f0; color: #555; }
    #words-table tbody tr:last-child td { border-bottom: none; }
    #words-table tr.suspended-row td { opacity: 0.5; }
    #words-table tr.note-edit-row td {
      background: var(--brand-tint);
      padding: 0.5rem 0.75rem;
      border-top: none;
    }

    /* ── Note editor ── */
    .note-edit-wrap { display: flex; gap: 0.5rem; align-items: flex-start; }
    .note-edit-wrap textarea {
      flex: 1; min-height: 3rem; padding: 0.35rem 0.6rem;
      border: 1px solid #e5e5ea; border-radius: 8px; font-size: 0.9rem;
      resize: vertical; font-family: inherit; outline: none;
    }
    .note-edit-wrap textarea:focus { border-color: var(--brand); }
    .note-edit-actions { display: flex; flex-direction: column; gap: 0.35rem; }
    .note-save-btn { padding: 0.3rem 0.75rem; background: var(--brand); color: #fff; border: none; border-radius: 8px; cursor: pointer; font-size: 0.85rem; font-weight: 600; }
    .note-save-btn:hover { opacity: 0.88; }
    .note-cancel-btn { padding: 0.3rem 0.75rem; background: none; color: #666; border: 1px solid #e5e5ea; border-radius: 8px; cursor: pointer; font-size: 0.85rem; }

    /* ── Word manager status ── */
    #word-manager-status {
      color: #999;
      font-size: 0.82rem;
      margin-top: 0.5rem;
    }

    /* ── Import section ── */
    #import-words-section {
      margin: 0.85rem 0 0.25rem;
      display: flex;
      flex-wrap: wrap;
      gap: 0.5rem;
      align-items: center;
    }
    #import-words-section label {
      font-size: 0.8rem;
      color: #888;
      font-weight: 600;
      text-transform: uppercase;
      letter-spacing: 0.05em;
      white-space: nowrap;
    }
    #importFileInput { display: none; }
    .deck-btn {
      padding: 0.3rem 0.75rem;
      border: 1px solid #e5e5ea;
      border-radius: 999px;
      background: #fff;
      color: #333;
      cursor: pointer;
      font-size: 0.85rem;
      transition: background 0.15s, border-color 0.15s;
    }
    .deck-btn:hover { background: var(--brand-tint); border-color: var(--brand); color: var(--brand); }
    .deck-btn:disabled { opacity: 0.45; cursor: default; }
    .deck-badge {
      font-size: 0.72rem;
      background: #e9e9eb;
      color: #666;
      padding: 1px 5px;
      border-radius: 4px;
      margin-left: 4px;
      vertical-align: middle;
    }

    /* ── Word selection bar ── */
    #words-sel-bar {
      display: none;
      position: fixed;
      bottom: calc(var(--nav-h) + var(--sab));
      left: 0; right: 0;
      background: #fff;
      border-top: 1px solid #e5e5ea;
      z-index: 200;
      flex-direction: row;
      box-shadow: 0 -2px 12px rgba(0,0,0,0.08);
    }
    #words-sel-bar.active { display: flex; }
    @media (min-width: 768px) {
      #words-sel-bar { left: var(--sidebar-w); bottom: 0; }
    }
    #words-sel-bar button {
      flex: 1;
      min-width: 0;
      padding: 0.65rem 0.15rem;
      border: none;
      border-right: 1px solid #e5e5ea;
      background: none;
      cursor: pointer;
      font-size: 0.76rem;
      font-weight: 600;
      white-space: nowrap;
      overflow: hidden;
      text-overflow: ellipsis;
      margin: 0;
      line-height: 1.3;
      transition: background 0.1s;
    }
    #words-sel-bar button:last-child { border-right: none; }
    #words-sel-bar button:active { background: #f4f4f4; }
    #fab-close-btn   { color: #555; flex: 0.8; }
    #fab-forgot-btn  { color: var(--orange); }
    #fab-knew-btn    { color: var(--brand); }
    #fab-suspend-btn { color: #888; }
    #fab-remove-btn  { color: #c00; }
    #fab-note-btn    { color: #555; }
    #reviews-table {
      width: 100%;
      border-collapse: collapse;
    }
    #reviews-table th, #reviews-table td {
      text-align: left;
      padding: 0.4rem 0.75rem;
      border-bottom: 1px solid #eee;
    }
    #reviews-table th {
      background: #f5f5f5;
    }
    .rating-1 { color: #c00; font-weight: bold; }
    .rating-3 { color: #080; font-weight: bold; }
    #llm-config {
      margin-bottom: 1.25rem;
    }
    #llm-config summary {
      cursor: pointer;
      font-weight: bold;
      color: #555;
      user-select: none;
      margin-bottom: 0.5rem;
    }
    #llm-config-fields {
      display: flex;
      flex-wrap: wrap;
      gap: 1rem;
      align-items: flex-end;
      margin-top: 0.75rem;
      padding: 0.75rem;
      background: #f9f9f9;
      border: 1px solid #e0e0e0;
      border-radius: 6px;
    }
    #llm-config-fields label {
      display: flex;
      flex-direction: column;
      font-size: 0.85em;
      color: #444;
      gap: 0.25rem;
    }
    #llm-config-fields select,
    #llm-config-fields input[type="number"] {
      padding: 0.3rem 0.5rem;
      border: 1px solid #ccc;
      border-radius: 4px;
      font-size: 0.9em;
    }
    #llm-config-fields .checkbox-label {
      flex-direction: row;
      align-items: center;
      gap: 0.4rem;
    }
    #study-header-row {
      display: flex;
      align-items: center;
      gap: 0.5rem;
      margin-bottom: 1.5rem;
    }
    #study-header-row #study-back-read {
      margin-bottom: 0;
    }
    #study-header-row #stats-bar {
      flex: 1;
      min-width: 0;
      margin-bottom: 0;
    }
    #stats-bar {
      display: flex;
      gap: 2rem;
      padding: 0.75rem 1.25rem;
      background: #f5f5f5;
      border: 1px solid #e0e0e0;
      border-radius: 8px;
      transition: gap 0.3s ease, padding 0.3s ease, margin-bottom 0.3s ease;
    }
    #stats-bar.compact {
      gap: 0.75rem;
      padding: 0.3rem 0.75rem;
      margin-bottom: 0.6rem;
    }
    #stats-bar.compact .stat-value { font-size: 1rem; line-height: 1.3; }
    #stats-bar.compact .stat-label { display: none; }
    .stat-item {
      display: flex;
      flex-direction: column;
      align-items: center;
      min-width: 80px;
      cursor: pointer;
      border-radius: 6px;
      padding: 0.25rem 0.5rem;
      transition: background 0.15s;
    }
    @media (max-width: 767px) {
      .stat-item { min-width: 0; padding: 0.15rem 0.25rem; }
    }
    .stat-item:hover {
      background: #e8e8e8;
    }
    .stat-value {
      font-size: clamp(0.75rem, 3.5vw, 1.6rem);
      font-weight: bold;
      color: #333;
      line-height: 1.2;
    }
    .stat-label {
      font-size: 0.75em;
      color: #666;
      text-align: center;
    }
    #fsrs-dashboard {
      margin-top: 0;
      border-top: none;
      padding-top: 0;
    }
    #fsrs-dashboard .stats-section-title {
      margin-bottom: 1rem;
    }
    #fsrs-top-row {
      display: flex;
      gap: 2rem;
      align-items: flex-start;
      flex-wrap: wrap;
      margin-bottom: 1.5rem;
    }
    #fsrs-meter-wrap {
      display: flex;
      flex-direction: column;
      align-items: center;
      gap: 0.4rem;
    }
    #fsrs-meter-wrap svg {
      width: 110px;
      height: 110px;
    }
    #meter-label {
      font-size: 0.8em;
      color: #555;
      text-align: center;
    }
    #fsrs-right {
      display: flex;
      flex-direction: column;
      gap: 1rem;
      flex: 1;
      min-width: 200px;
    }
    #confidence-box {
      display: flex;
      align-items: center;
      gap: 0.6rem;
    }
    #confidence-badge {
      display: inline-block;
      padding: 0.25rem 0.75rem;
      border-radius: 12px;
      font-size: 0.85em;
      font-weight: bold;
      text-transform: uppercase;
      letter-spacing: 0.04em;
    }
    .conf-low  { background: #fde8e8; color: #c00; }
    .conf-medium { background: #fff3d6; color: #a05000; }
    .conf-high { background: #e3f5e1; color: #1a7a1a; }
    #fsrs-stats-summary {
      display: flex;
      gap: 1.5rem;
      flex-wrap: wrap;
    }
    .fsrs-stat {
      display: flex;
      flex-direction: column;
      align-items: center;
      min-width: 90px;
    }
    .fsrs-stat-value {
      font-size: 1.3rem;
      font-weight: bold;
      color: #333;
    }
    .fsrs-stat-label {
      font-size: 0.72em;
      color: #666;
      text-align: center;
    }
    #calibration-section h3 {
      font-size: 0.95em;
      color: #444;
      margin: 0 0 0.6rem;
    }
    .cal-row {
      display: flex;
      align-items: center;
      gap: 0.5rem;
      margin-bottom: 0.35rem;
      font-size: 0.82em;
    }
    .cal-bin-label {
      width: 36px;
      color: #888;
      flex-shrink: 0;
      text-align: right;
    }
    .cal-bars {
      position: relative;
      width: 200px;
      height: 14px;
      background: #f0f0f0;
      border-radius: 3px;
      overflow: hidden;
      flex-shrink: 0;
    }
    .cal-bar-actual {
      position: absolute;
      left: 0;
      top: 0;
      height: 100%;
      background: var(--brand);
      border-radius: 3px;
      transition: width 0.3s;
    }
    .cal-bar-predicted {
      position: absolute;
      top: 3px;
      height: 8px;
      width: 2px;
      background: #e07b00;
      border-radius: 1px;
    }
    .cal-counts {
      color: #aaa;
      flex-shrink: 0;
    }
    /* ── Tooltip ── */
    .tip {
      position: relative;
      cursor: help;
    }
    #fsrs-no-data {
      color: #999;
      font-size: 0.9em;
    }
    #sim-controls {
      display: flex;
      gap: 1rem;
      align-items: center;
      flex-wrap: wrap;
      margin-bottom: 0.75rem;
    }
    #sim-controls label {
      display: flex;
      align-items: center;
      gap: 0.3rem;
      font-size: 0.85em;
      color: #555;
    }
    #sim-controls input[type="number"] {
      width: 68px;
      padding: 0.3rem 0.4rem;
      border: 1px solid #ccc;
      border-radius: 4px;
    }
    #sim-status {
      font-size: 0.88em;
      color: #555;
      min-height: 1.2em;
    }
    #sim-chart {
      width: 100%;
      display: block;
      margin-top: 1rem;
      overflow: visible;
    }
    #tune-result {
      margin-top: 0.75rem;
      font-size: 0.88em;
      color: #333;
      padding: 0.5rem 0.75rem;
      background: #f9f9f9;
      border: 1px solid #e8e8e8;
      border-radius: 6px;
      display: none;
    }
    #sim-config-display {
      margin-top: 0.5rem;
      font-size: 0.8em;
      color: #888;
    }
    /* ── Advanced Settings outer collapsible ── */
    #advanced-settings {
      margin-top: 0;
    }
    #advanced-settings > summary {
      cursor: pointer;
      font-weight: bold;
      color: #333;
      user-select: none;
      padding: 0.5rem 0;
      border-top: none;
      list-style: none;
      display: flex;
      align-items: center;
      gap: 0.4rem;
    }
    #advanced-settings > summary::before {
      content: "▶";
      font-size: 0.7em;
      color: #aaa;
      transition: transform 0.15s;
    }
    #advanced-settings[open] > summary::before {
      transform: rotate(90deg);
    }
    #advanced-settings > summary h2 {
      margin: 0;
      font-size: 1em;
      display: inline;
    }
    #advanced-settings-body {
      padding-top: 0.5rem;
    }
    /* ── Inner collapsibles ── */
    #fsrs-sim, #review-log {
      margin-top: 1rem;
    }
    #fsrs-sim > summary, #review-log > summary {
      cursor: pointer;
      font-weight: bold;
      color: #555;
      user-select: none;
      padding: 0.4rem 0;
      border-top: 1px solid #eee;
      list-style: none;
      display: flex;
      align-items: center;
      gap: 0.4rem;
    }
    #fsrs-sim > summary::before, #review-log > summary::before {
      content: "▶";
      font-size: 0.65em;
      color: #bbb;
      transition: transform 0.15s;
    }
    #fsrs-sim[open] > summary::before, #review-log[open] > summary::before {
      transform: rotate(90deg);
    }
    #fsrs-sim > summary h3, #review-log > summary h3 {
      margin: 0;
      font-size: 0.95em;
      display: inline;
      font-weight: bold;
    }
    #fsrs-sim-body, #review-log-body {
      padding-top: 0.75rem;
    }
    /* ── FSRS tune row (dashboard) ── */
    #fsrs-tune-row {
      display: flex;
      align-items: center;
      gap: 1rem;
      margin-top: 1rem;
      flex-wrap: wrap;
    }
    #fsrs-last-tuned {
      font-size: 0.82em;
      color: #888;
    }
    #fsrs-auto-tune-notice {
      font-size: 0.82em;
      color: #e07b00;
      display: none;
    }
    /* ── Onboarding Wizard ── */
    #ob-wizard {
      position: fixed; inset: 0;
      background: linear-gradient(150deg, #2e6e55 0%, #3d8d6b 100%);
      z-index: 10000;
      display: flex;
      flex-direction: column;
      align-items: center;
      overflow: hidden;
      color: rgba(255,255,255,0.85);
    }
    #ob-wizard.hidden { display: none; }
    #ob-inner {
      display: flex;
      flex-direction: column;
      width: 100%;
      max-width: 480px;
      height: 100%;
      padding: max(1.5rem, env(safe-area-inset-top, 1.5rem)) 1.5rem max(1rem, env(safe-area-inset-bottom, 1rem));
      box-sizing: border-box;
      overflow-x: hidden;
    }
    #ob-dots {
      display: flex; gap: 0.5rem; justify-content: center;
      padding-bottom: 1.5rem; flex-shrink: 0;
    }
    .ob-dot {
      width: 7px; height: 7px; border-radius: 50%;
      background: rgba(255,255,255,0.25);
      transition: background 0.2s, transform 0.2s, width 0.2s;
    }
    .ob-dot.active { background: #ffffff; transform: scale(1.3); }
    .ob-dot.ob-dot-done { background: rgba(255,255,255,0.5); }
    .ob-step { display: none; flex: 1; overflow: hidden; min-height: 0; }
    .ob-step.active { display: flex; flex-direction: column; }
    @keyframes ob-slide-fwd {
      from { opacity: 0; transform: translateX(28px); }
      to   { opacity: 1; transform: translateX(0); }
    }
    @keyframes ob-slide-back {
      from { opacity: 0; transform: translateX(-28px); }
      to   { opacity: 1; transform: translateX(0); }
    }
    .ob-anim-fwd  { animation: ob-slide-fwd  0.22s cubic-bezier(0.4,0,0.2,1); }
    .ob-anim-back { animation: ob-slide-back 0.22s cubic-bezier(0.4,0,0.2,1); }
    .ob-step-body {
      flex: 1; min-height: 0;
      display: flex; flex-direction: column;
    }
    .ob-step-body.ob-scrollable { overflow-y: auto; overflow-x: hidden; -webkit-overflow-scrolling: touch; scrollbar-width: none; }
    .ob-step-body.ob-scrollable::-webkit-scrollbar { display: none; }
    .ob-step-body.ob-centered { justify-content: center; padding-bottom: 2rem; }
    #ob-nav {
      display: flex; justify-content: space-between; align-items: center;
      padding-top: 1rem; flex-shrink: 0;
    }
    .ob-step4-body { overflow-y: auto; overflow-x: hidden; -webkit-overflow-scrolling: touch; scrollbar-width: none; }
    .ob-step4-body::-webkit-scrollbar { display: none; }
    #ob-back-btn {
      background: none; border: none; color: rgba(255,255,255,0.7);
      cursor: pointer; font-size: 0.95rem; padding: 0.5rem 0.25rem;
    }
    #ob-next-btn { min-width: 120px; }
    #ob-wizard .btn-primary {
      background: #ffffff; color: #357d5e; border-color: transparent;
      font-weight: 700;
    }
    #ob-wizard .btn-primary:hover { background: rgba(255,255,255,0.92); }
    /* Step 0 — native lang */
    .ob-multilang {
      font-size: 0.76rem; color: rgba(255,255,255,0.5); text-align: center;
      margin: 0 0 1.75rem; letter-spacing: 0.02em; line-height: 1.6;
    }
    .ob-step-title { font-size: 1.5rem; font-weight: 700; margin: 0 0 0.4rem; color: #ffffff; }
    .ob-step-desc  { font-size: 0.9rem; color: rgba(255,255,255,0.78); margin: 0 0 1.75rem; line-height: 1.5; }
    #ob-wizard p, #ob-wizard span:not([class]) { color: inherit; }
    .ob-skip-login-btn {
      margin-top: 1.5rem;
      background: none; border: none;
      color: rgba(255,255,255,0.55);
      font-size: 0.82rem; cursor: pointer; padding: 0.5rem 0;
      text-decoration: underline; text-underline-offset: 2px;
      transition: color 0.15s;
    }
    .ob-skip-login-btn:hover { color: rgba(255,255,255,0.9); }
    .ob-select-wrap { margin-top: 0.25rem; }
    .ob-select-label {
      font-size: 0.82rem; color: rgba(255,255,255,0.75); display: block;
      margin-bottom: 0.4rem; font-weight: 500;
    }
    .ob-select {
      width: 100%; padding: 0.7rem 2.25rem 0.7rem 0.75rem;
      border: 1.5px solid rgba(255,255,255,0.35); border-radius: 8px;
      font-size: 1rem; background: rgba(0,0,0,0.2); color: #ffffff;
      appearance: none;
      background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23ffffff' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
      background-repeat: no-repeat;
      background-position: right 0.7rem center;
      background-size: 1.1rem;
      cursor: pointer; box-sizing: border-box;
    }
    .ob-select option { background: #2e6e55; color: #ffffff; }
    .ob-select:focus { outline: none; border-color: rgba(255,255,255,0.7); }
    /* Step 1 — intro */
    .ob-logo-row { text-align: center; margin-bottom: 0.3rem; }
    .ob-logo { font-size: 2.5rem; font-weight: 800; letter-spacing: -0.02em; color: #ffffff; margin: 0; }
    .ob-tagline { text-align: center; font-size: 0.92rem; color: rgba(255,255,255,0.6); margin: 0.25rem 0 2.5rem; }
    .ob-feature-list { display: flex; flex-direction: column; gap: 1.2rem; }
    .ob-feature { display: flex; align-items: flex-start; gap: 1rem; }
    .ob-feature-icon {
      width: 38px; height: 38px; flex-shrink: 0;
      display: flex; align-items: center; justify-content: center;
      background: rgba(255,255,255,0.15); border-radius: 9px;
      color: #ffffff;
    }
    .ob-feature-icon svg { width: 18px; height: 18px; }
    .ob-feature-text { display: flex; flex-direction: column; gap: 0.15rem; padding-top: 0.2rem; }
    .ob-feature-text strong { font-size: 0.95rem; color: #ffffff; font-weight: 600; }
    .ob-feature-text span  { font-size: 0.84rem; color: rgba(255,255,255,0.7); line-height: 1.45; }
    /* Step 2 — target + goals */
    .ob-step-subtitle {
      font-size: 0.72rem; font-weight: 700; text-transform: uppercase;
      letter-spacing: 0.08em; color: rgba(255,255,255,0.55); margin: 0 0 0.65rem;
    }
    .ob-lang-grid { display: flex; gap: 0.6rem; margin-bottom: 0.25rem; }
    .ob-lang-card {
      flex: 1; display: flex; flex-direction: column; align-items: center;
      gap: 0.2rem; padding: 0.85rem 0.4rem;
      border: 1.5px solid rgba(255,255,255,0.2); border-radius: 10px;
      cursor: pointer; position: relative; text-align: center;
      background: rgba(255,255,255,0.07);
      transition: border-color 0.15s, background 0.15s;
    }
    .ob-lang-card:hover:not(.ob-soon) { border-color: rgba(255,255,255,0.5); background: rgba(255,255,255,0.14); }
    .ob-lang-card.selected { border-color: #ffffff; background: rgba(255,255,255,0.2); }
    .ob-lang-card.ob-soon  { opacity: 0.4; cursor: default; }
    .ob-lang-flag   { font-size: 1.5rem; }
    .ob-lang-native { font-size: 0.82rem; font-weight: 600; color: #ffffff; }
    .ob-lang-en     { font-size: 0.69rem; color: rgba(255,255,255,0.6); }
    .ob-soon-badge {
      position: absolute; top: 0.3rem; right: 0.3rem;
      background: rgba(255,255,255,0.15); color: rgba(255,255,255,0.7); font-size: 0.6rem;
      padding: 0.1rem 0.35rem; border-radius: 6px; font-weight: 700; letter-spacing: 0.04em;
    }
    .ob-goal-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0.6rem; }
    .ob-goal-card {
      display: flex; flex-direction: column; align-items: center;
      gap: 0.45rem; padding: 0.85rem 0.5rem;
      border: 1.5px solid rgba(255,255,255,0.2); border-radius: 10px;
      cursor: pointer; text-align: center;
      background: rgba(255,255,255,0.07);
      transition: border-color 0.15s, background 0.15s;
    }
    .ob-goal-card:hover { border-color: rgba(255,255,255,0.5); background: rgba(255,255,255,0.14); }
    .ob-goal-card.selected { border-color: #ffffff; background: rgba(255,255,255,0.2); }
    .ob-goal-icon { display: flex; align-items: center; justify-content: center; color: #ffffff; }
    .ob-goal-icon svg { width: 22px; height: 22px; }
    .ob-goal-card span { font-size: 0.8rem; font-weight: 600; color: #ffffff; }
    .ob-jlpt-levels { display: flex; gap: 0.4rem; }
    .ob-jlpt-level {
      flex: 1; display: flex; flex-direction: column; align-items: center;
      border: 1.5px solid rgba(255,255,255,0.2); border-radius: 8px;
      padding: 0.5rem 0.2rem; cursor: pointer;
      background: rgba(255,255,255,0.07);
      transition: border-color 0.15s, background 0.15s;
    }
    .ob-jlpt-level input[type="radio"] { display: none; }
    .ob-jlpt-level span {
      display: flex; flex-direction: column; align-items: center; gap: 0.1rem;
      font-size: 0.78rem; font-weight: 700; color: #ffffff;
    }
    .ob-jlpt-level span small { font-size: 0.58rem; font-weight: 400; color: rgba(255,255,255,0.6); }
    .ob-jlpt-level:has(input:checked) { border-color: #ffffff; background: rgba(255,255,255,0.2); }
    /* Tutorial step */
    #ob-tut-start {
      flex: 1; display: flex; flex-direction: column; justify-content: center;
    }
    .ob-skip-tut-btn {
      display: block; width: 100%; margin-top: 0.9rem;
      background: none; border: none;
      color: rgba(255,255,255,0.5); font-size: 0.82rem;
      cursor: pointer; padding: 0.4rem 0; text-align: center;
      text-decoration: underline; text-underline-offset: 2px;
      transition: color 0.15s;
    }
    .ob-skip-tut-btn:hover { color: rgba(255,255,255,0.85); }
    .ob-tut-hint {
      margin-bottom: 0.5rem !important;
      transition: opacity 0.2s;
    }
    .ob-due-words-bar {
      margin-bottom: 0.55rem;
    }
    .ob-due-label {
      display: block; font-size: 0.68rem; font-weight: 700; text-transform: uppercase;
      letter-spacing: 0.08em; color: rgba(255,255,255,0.55); margin-bottom: 0.38rem;
    }
    .ob-due-chips {
      display: flex; flex-wrap: wrap; gap: 0.35rem;
    }
    .ob-due-chip {
      display: inline-block; padding: 0.2rem 0.6rem;
      background: rgba(255,255,255,0.92); border-radius: 20px;
      color: #2a5e47; font-size: 1rem; font-weight: 600;
    }
    .ob-tut-frame {
      background: rgba(0,0,0,0.18); border-radius: 10px;
      padding: 1rem 1.1rem; border: 1px solid rgba(255,255,255,0.15);
    }
    .ob-tut-para {
      font-size: 1.35rem; line-height: 2; letter-spacing: 0.01em;
      color: #ffffff; word-break: break-word; min-height: 2.5rem;
    }
    .ob-tut-word {
      cursor: pointer; border-radius: 3px;
      padding: 0 1px;
      transition: background 0.1s, color 0.1s;
      display: inline ruby;
    }
    .ob-tut-word:hover { background: rgba(255,255,255,0.18); }
    .ob-tut-word-known { color: #7edc9a; }
    .ob-tut-word-selected { background: #ffe58a; color: #222; }
    ruby.ob-tut-word rt { font-size: 0; line-height: 0; }
    ruby.ob-tut-word.ob-tut-word-selected rt { font-size: 0.55em; line-height: normal; color: #555; }
    .ob-tut-dict {
      margin-top: 0.75rem; padding-top: 0.75rem;
      border-top: 1px solid rgba(255,255,255,0.2);
    }
    .ob-tut-dict-head { display: flex; align-items: baseline; gap: 0.5rem; margin-bottom: 0.2rem; }
    .ob-tut-dict-surface { font-size: 1.1rem; font-weight: 700; color: #ffffff; }
    .ob-tut-dict-reading { font-size: 0.8rem; color: rgba(255,255,255,0.6); }
    .ob-tut-dict-pos {
      font-size: 0.7rem; font-weight: 700; text-transform: uppercase;
      letter-spacing: 0.06em; color: rgba(255,255,255,0.45); margin-bottom: 0.35rem;
    }
    .ob-tut-dict-meanings {
      margin: 0; padding: 0 0 0 1.1rem; list-style: disc;
      font-size: 0.88rem; color: rgba(255,255,255,0.85); line-height: 1.6;
    }
    .ob-tut-explain { display: flex; flex-direction: column; gap: 1rem; }
    .ob-tut-explain-row { display: flex; align-items: flex-start; gap: 0.75rem; }
    .ob-tut-explain-dot {
      width: 12px; height: 12px; border-radius: 50%; flex-shrink: 0; margin-top: 0.22rem;
    }
    .ob-tut-dot-yellow { background: #ffe58a; border: 1px solid rgba(0,0,0,0.15); }
    .ob-tut-dot-green  { background: #7edc9a; }
    .ob-tut-explain-text {
      font-size: 0.88rem; color: rgba(255,255,255,0.82); line-height: 1.55; margin: 0;
    }
    .ob-tut-explain-text strong { color: #ffffff; }
    /* Auth step (step 6) */
    .ob-auth-tabs { display: flex; gap: 0.4rem; margin-bottom: 1.1rem; }
    .ob-auth-tab {
      flex: 1; padding: 0.45rem 0.25rem;
      border: 1.5px solid rgba(255,255,255,0.3); border-radius: 6px;
      background: rgba(255,255,255,0.08); cursor: pointer; font-size: 0.8rem; font-weight: 500;
      color: rgba(255,255,255,0.85);
      transition: background 0.15s;
    }
    .ob-auth-tab.active { background: rgba(255,255,255,0.95); color: #357d5e; border-color: transparent; font-weight: 700; }
    .ob-auth-form { display: none; flex-direction: column; gap: 0.65rem; }
    .ob-auth-form.active { display: flex; }
    .ob-auth-form input {
      padding: 0.6rem 0.75rem;
      border: 1.5px solid rgba(255,255,255,0.3); border-radius: 7px; font-size: 0.95rem;
      background: rgba(0,0,0,0.2); color: #ffffff;
      box-sizing: border-box;
    }
    .ob-auth-form input:focus { outline: none; border-color: rgba(255,255,255,0.7); }
    #ob-wizard ::placeholder { color: rgba(255,255,255,0.45); -webkit-text-fill-color: rgba(255,255,255,0.45); }
    #ob-auth-error { color: #ffd0d0; }
    /* Timezone + JLPT step (step 3) */
    .ob-field-group { margin-bottom: 1rem; }
    .ob-field-label { display: block; font-size: 0.9rem; font-weight: 600; color: #ffffff; margin-bottom: 0.5rem; }
    .ob-jlpt-import-btns { display: flex; flex-direction: column; gap: 0.4rem; }
    .ob-jlpt-import-btn {
      display: flex; align-items: center; gap: 0.75rem; width: 100%;
      padding: 0.6rem 0.85rem; border: 1.5px solid rgba(255,255,255,0.2); border-radius: 10px;
      background: rgba(255,255,255,0.07); cursor: pointer; color: #ffffff;
      transition: border-color 0.15s, background 0.15s; text-align: left;
    }
    .ob-jlpt-import-btn:hover { border-color: rgba(255,255,255,0.45); background: rgba(255,255,255,0.12); }
    .ob-jlpt-import-btn.selected { border-color: #ffffff; background: rgba(255,255,255,0.2); }
    .ob-jlpt-import-btn .ob-deck-check { opacity: 0; margin-left: auto; font-size: 1rem; font-weight: 700; transition: opacity 0.15s; flex-shrink: 0; }
    .ob-jlpt-import-btn.selected .ob-deck-check { opacity: 1; }
    /* Settings intro step (step 4) */
    .ob-settings-icon-wrap {
      width: 64px; height: 64px; margin: 0 auto 1.25rem;
      display: flex; align-items: center; justify-content: center;
      background: rgba(255,255,255,0.15); border-radius: 16px; color: #ffffff;
    }
    .ob-settings-icon-wrap svg { width: 30px; height: 30px; }
    .ob-settings-list {
      list-style: none; padding: 0; margin: 0;
      display: flex; flex-direction: column; gap: 0.6rem;
      text-align: left; width: 100%;
    }
    .ob-settings-list li {
      font-size: 0.88rem; color: rgba(255,255,255,0.85); padding: 0.55rem 0.85rem;
      background: rgba(0,0,0,0.15); border-radius: 8px; line-height: 1.4;
    }
    .ob-settings-list li::before {
      content: "–"; margin-right: 0.5rem; color: rgba(255,255,255,0.5); font-weight: 700;
    }

    /* ── Auth overlay ── */
    #auth-screen {
      position: fixed; inset: 0;
      background: rgba(0,0,0,0.55);
      display: flex; align-items: center; justify-content: center;
      z-index: 9999;
    }
    #auth-screen.hidden { display: none; }
    #auth-box {
      background: #fff; border-radius: 12px; padding: 2rem 2.5rem;
      width: 340px; box-shadow: 0 8px 32px rgba(0,0,0,0.18);
    }
    #auth-box h2 { margin: 0 0 1.2rem; font-size: 1.3rem; }
    .auth-tabs { display: flex; gap: 0.5rem; margin-bottom: 1.4rem; }
    .auth-tab {
      flex: 1; padding: 0.45rem; border: 1px solid #ddd; border-radius: 6px;
      background: #f5f5f5; cursor: pointer; font-size: 0.95rem;
    }
    .auth-tab.active { background: #333; color: #fff; border-color: #333; }
    .auth-form { display: none; flex-direction: column; gap: 0.7rem; }
    .auth-form.active { display: flex; }
    .auth-form input {
      padding: 0.5rem 0.75rem; border: 1px solid #ddd; border-radius: 6px;
      font-size: 0.95rem;
    }
    .auth-form button[type=submit] {
      padding: 0.55rem; background: #333; color: #fff; border: none;
      border-radius: 6px; cursor: pointer; font-size: 0.95rem; margin: 0;
    }
    .auth-form button[type=submit]:hover { background: #555; }
    #auth-error { color: #c00; font-size: 0.88rem; min-height: 1.2em; }
    .auth-link { background: none; border: none; color: #666; font-size: 0.82rem; cursor: pointer; text-decoration: underline; padding: 0; margin-top: -0.1rem; text-align: left; }
    .auth-link:hover { color: #333; }
    .auth-success { color: #2a9a2a; font-size: 0.88rem; margin: 0; }
    #user-bar { display: none; }
    /* ── Hamburger menu (hidden – navigation moved to tab bar) ── */
    #hamburger-btn, #hamburger-menu { display: none !important; }
    /* ── Profile / Admin modals ── */
    .modal-overlay {
      position: fixed; inset: 0;
      background: rgba(0,0,0,0.45);
      display: flex; align-items: center; justify-content: center;
      z-index: 9998;
    }
    .modal-overlay.hidden { display: none; }
    /* ── Toast notification ── */
    #toast {
      position: fixed; bottom: calc(var(--nav-h) + var(--sab) + 0.75rem); left: 50%; transform: translateX(-50%) translateY(2rem);
      background: #2e7d32; color: #fff; padding: 0.65rem 1.4rem;
      border-radius: 8px; font-size: 0.95rem; font-weight: 500;
      box-shadow: 0 4px 16px rgba(0,0,0,0.18);
      opacity: 0; transition: opacity 0.25s, transform 0.25s;
      pointer-events: none; z-index: 9999;
    }
    #toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
    .modal-box {
      background: #fff; border-radius: 12px; padding: 1.75rem 2rem;
      width: 420px; max-width: 92vw;
      box-shadow: 0 8px 32px rgba(0,0,0,0.16);
      max-height: 80vh; overflow-y: auto;
    }
    .modal-box h2 { margin: 0 0 1.2rem; font-size: 1.2rem; }
    .modal-close {
      float: right; background: none; border: none; font-size: 1.3rem;
      cursor: pointer; color: #999; margin: 0; padding: 0; line-height: 1;
    }
    .modal-close:hover { color: #333; }
    /* ── Onboarding modal ── */
    .onboarding-pref-section {
      border: 1px solid #eee; border-radius: 8px; padding: 0.75rem 0.9rem;
      margin-bottom: 0.7rem;
    }
    .onboarding-pref-header {
      display: flex; align-items: center; justify-content: space-between;
      margin-bottom: 0.3rem;
    }
    .onboarding-pref-title { font-weight: 600; font-size: 0.95rem; }
    .onboarding-pref-desc { font-size: 0.85rem; color: #666; margin: 0; }
    .onboarding-soon { opacity: 0.5; pointer-events: none; }
    .onboarding-soon-badge {
      font-size: 0.72rem; background: #eee; color: #888;
      border-radius: 10px; padding: 0.15rem 0.55rem;
    }
    /* ── Demo mode ── */
    #demo-banner {
      position: fixed; top: 0; left: 0; right: 0;
      height: calc(var(--header-h) + env(safe-area-inset-top, 0px));
      padding-top: env(safe-area-inset-top, 0px);
      padding-left: 1rem; padding-right: 1rem;
      background: #7a3b00; color: #fff;
      display: flex; align-items: center; justify-content: center; gap: 1rem;
      font-size: 0.86rem; z-index: 500;
      box-shadow: 0 1px 4px rgba(0,0,0,0.15);
    }
    #demo-banner.hidden { display: none; }
    #demo-banner button {
      padding: 0.22rem 0.7rem; background: #fff; color: #7a3b00;
      border: none; border-radius: 4px; cursor: pointer; font-size: 0.82rem;
      font-weight: 600; white-space: nowrap; flex-shrink: 0;
    }
    #demo-banner button:hover { background: #ffe0b2; }
    .profile-row {
      display: flex; gap: 0.5rem; align-items: center;
      margin-bottom: 0.6rem; font-size: 0.93rem;
    }
    .profile-label { color: #888; width: 70px; flex-shrink: 0; }
    .profile-value { color: #222; font-weight: 500; }
    .role-badge {
      display: inline-block; padding: 0.15rem 0.6rem;
      border-radius: 10px; font-size: 0.78rem; font-weight: bold;
      text-transform: uppercase; letter-spacing: 0.04em;
    }
    .role-user { background: #e8f0fe; color: #1a56db; }
    .role-admin { background: #fde8e8; color: #c00; }
    /* admin tabs */
    .admin-tabs { display: flex; gap: 0.4rem; margin-bottom: 0.75rem; }
    .admin-tab {
      padding: 0.35rem 0.9rem; border: 1px solid #ddd; border-radius: 6px;
      background: #f5f5f5; cursor: pointer; font-size: 0.88rem;
    }
    .admin-tab.active { background: #333; color: #fff; border-color: #333; }
    /* admin tables */
    #admin-users-table, #admin-tokens-table {
      width: 100%; border-collapse: collapse; margin-top: 0.5rem; font-size: 0.88rem;
    }
    #admin-users-table th, #admin-users-table td,
    #admin-tokens-table th, #admin-tokens-table td {
      text-align: left; padding: 0.4rem 0.6rem; border-bottom: 1px solid #eee;
    }
    #admin-users-table th, #admin-tokens-table th { background: #f5f5f5; }
    .role-select { font-size: 0.85rem; padding: 0.2rem 0.4rem; border: 1px solid #ccc; border-radius: 4px; }
    #admin-status { font-size: 0.85rem; color: #555; margin-bottom: 0.25rem; min-height: 1.2em; }
/* ══════════════════════════════════════════════════════
   NEW STYLES: Config tab, FABs, hints, advanced toggle
   ══════════════════════════════════════════════════════ */

/* ── Config back button ───────────────────────────────── */
#config-back-btn {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  background: none;
  border: none;
  color: var(--brand);
  font-size: 1rem;
  padding: 0 0 1.1rem;
  cursor: pointer;
  font-weight: 500;
}
#config-back-btn:active { opacity: 0.6; }

/* ── Config settings list ─────────────────────────────── */
.settings-list {
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid #e5e5ea;
  background: #fff;
}
.settings-list-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 0.85rem 1rem;
  background: #fff;
  border: none;
  border-bottom: 1px solid #e5e5ea;
  cursor: pointer;
  text-align: left;
  font-size: 1rem;
  color: #000;
  -webkit-tap-highlight-color: transparent;
  transition: background 0.1s;
}
.settings-list-item:last-child { border-bottom: none; }
.settings-list-item:active { background: #f0f0f0; }
.sli-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: 7px;
  background: #e9e9eb;
  color: #3a3a3c;
  flex-shrink: 0;
  margin-right: 0.65rem;
}
.sli-icon svg { width: 16px; height: 16px; }
.sli-label { flex: 1; }
.sli-chevron { color: #c7c7cc; flex-shrink: 0; }
.config-page { display: none; }
.config-page.active { display: block; }
.config-subsection { border: 1px solid #e8e8e8; border-radius: 8px; margin-bottom: 0.75rem; }
.config-subsection-title { font-size: 0.85rem; font-weight: 600; color: #444; padding: 0.65rem 0.9rem; cursor: pointer; list-style: none; display: flex; align-items: center; justify-content: space-between; }
.config-subsection-title::-webkit-details-marker { display: none; }
.config-subsection-title::after { content: '›'; font-size: 1.1rem; color: #aaa; transition: transform 0.2s; }
.config-subsection[open] .config-subsection-title::after { transform: rotate(90deg); }
.config-subsection .config-row { padding: 0 0.9rem; }
.config-subsection .config-row:last-child { padding-bottom: 0.75rem; }
.config-page h2 {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: #aaa;
  margin: 0 0 1rem;
  font-weight: 600;
}

/* ── Config section divider ──────────────────────────── */
.config-section-divider {
  height: 1px;
  background: #eee;
  margin: 0.35rem 0 1.1rem;
}

/* ── Config rows ──────────────────────────────────────── */
.config-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.9rem;
  flex-wrap: wrap;
}
.config-row label {
  font-size: 0.9rem;
  color: #333;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  flex-wrap: wrap;
}
/* Labels wrapping a select or number input: disable label-text activation,
   keep only the actual control tappable */
.config-row label:has(select),
.config-row label:has(input[type="number"]),
.config-row label:has(input[type="text"]) {
  pointer-events: none;
}
.config-row label:has(select) select,
.config-row label:has(input[type="number"]) input,
.config-row label:has(input[type="text"]) input {
  pointer-events: auto;
}
.config-row select,
.config-row input[type="number"],
.config-row input[type="text"] {
  padding: 0.3rem 0.5rem;
  border: 1px solid #ddd;
  border-radius: 6px;
  font-size: 0.88rem;
  background: #fafafa;
}
.config-row input[type="checkbox"] { width: 18px; height: 18px; accent-color: var(--brand); flex-shrink: 0; }

/* ── Story Mode config block ─────────────────────────── */
.config-row--story-mode {
  flex-direction: column;
  align-items: flex-start;
  gap: 0.5rem;
}
.story-mode-toggle-row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}
.story-mode-label {
  font-size: 0.9rem;
  font-weight: 600;
  color: #333;
}
.story-mode-desc {
  font-size: 0.82rem;
  color: #666;
  margin: 0;
  line-height: 1.5;
}

/* ── Hint / question-mark tooltips ───────────────────── */
.hint {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--brand-tint);
  color: var(--brand);
  font-size: 0.75rem;
  font-weight: 700;
  cursor: help;
  flex-shrink: 0;
  position: relative;
  vertical-align: middle;
}
/* Standalone hints (siblings of label) float right to avoid adjacent tap targets */
.config-row > .hint {
  margin-left: auto;
}

/* ── Advanced settings hidden state ──────────────────── */
.advanced-only { display: none; }
body.show-advanced .advanced-only { display: flex; }
body.show-advanced .advanced-only-block { display: block; }
.advanced-only-block { display: none; }

/* ── Language flag button (header) ──────────────────── */
#lang-flag-btn {
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
  flex-shrink: 0;
  line-height: 0;
  -webkit-tap-highlight-color: transparent;
}
#lang-flag-btn svg {
  width: 36px;
  height: 24px;
  display: block;
  border-radius: 3px;
}
#lang-flag-btn .lang-flag-emoji {
  font-size: 1.4rem;
  line-height: 1;
  display: block;
}

/* ── Language switcher sheet ─────────────────────────── */
#lang-switcher-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.35);
  z-index: 1100;
}
#lang-switcher-backdrop.visible { display: block; }
#lang-switcher {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  background: #fff;
  border-radius: 16px 16px 0 0;
  box-shadow: 0 -4px 24px rgba(0,0,0,0.16);
  z-index: 1101;
  transform: translateY(100%);
  transition: transform 0.28s cubic-bezier(0.4,0,0.2,1);
  max-height: 70vh;
  overflow-y: auto;
}
#lang-switcher.open { transform: translateY(0); }
#lang-switcher-inner { padding: 1.25rem 1.25rem calc(1.5rem + env(safe-area-inset-bottom,0px)); }
.lang-switcher-heading {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: #aaa;
  font-weight: 600;
  margin: 0 0 0.65rem;
}
.lang-switcher-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.7rem 0.85rem;
  border-radius: 10px;
  cursor: pointer;
  transition: background 0.1s;
  margin-bottom: 0.25rem;
  -webkit-tap-highlight-color: transparent;
}
.lang-switcher-row:active { background: #f4f4f4; }
.lang-switcher-row.active { background: var(--brand-tint); }
.lang-switcher-flag { display: flex; align-items: center; flex-shrink: 0; }
.lang-switcher-flag svg { width: 36px; height: 24px; border-radius: 3px; display: block; }
.lang-flag-emoji { font-size: 1.4rem; line-height: 1; }
.lang-switcher-name { flex: 1; }
.lang-switcher-name strong { display: block; font-size: 0.9rem; color: #222; }
.lang-switcher-name span { font-size: 0.78rem; color: #888; }
.lang-switcher-check { color: var(--brand); font-size: 1rem; }
.lang-switcher-soon {
  font-size: 0.7rem;
  background: #e9e9eb;
  color: #888;
  padding: 2px 6px;
  border-radius: 999px;
  font-weight: 600;
}
#lang-add-btn {
  width: 100%;
  margin-top: 0.75rem;
  padding: 0.65rem;
  border: 1.5px dashed #d0d0d5;
  border-radius: 10px;
  background: none;
  color: var(--brand);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.1s;
}
#lang-add-btn:active { background: var(--brand-tint); }

/* ── Languages list in Import page ──────────────────── */
.cfg-lang-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.6rem 0;
  border-bottom: 1px solid #f0f0f0;
}
.cfg-lang-row:last-child { border-bottom: none; }
.cfg-lang-flag { display: flex; align-items: center; flex-shrink: 0; }
.cfg-lang-flag svg { width: 32px; height: 21px; border-radius: 3px; display: block; }
.cfg-lang-info { flex: 1; }
.cfg-lang-info strong { font-size: 0.9rem; color: #222; display: block; }
.cfg-lang-info span { font-size: 0.78rem; color: #888; }
.cfg-lang-active-badge {
  font-size: 0.72rem;
  background: var(--brand-tint);
  color: var(--brand);
  padding: 2px 7px;
  border-radius: 999px;
  font-weight: 600;
}
.cfg-lang-remove-btn {
  padding: 0.3rem 0.65rem;
  border: 1px solid #fcc;
  border-radius: 8px;
  background: #fff5f5;
  color: #c00;
  font-size: 0.8rem;
  cursor: pointer;
}
.cfg-lang-remove-btn:active { background: #ffe0e0; }

/* ── Advanced settings toggle row ────────────────────── */
#advanced-toggle-row {
  margin-top: 1rem;
  padding: 0.75rem 1rem;
  background: #f8f8f8;
  border-radius: 8px;
  border: 1px solid #e8e8e8;
}
#advanced-toggle-row h3 {
  font-size: 0.85rem;
  color: #555;
  margin: 0 0 0.2rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
#advanced-toggle-row p {
  font-size: 0.78rem;
  color: #999;
  margin: 0 0 0.75rem;
  line-height: 1.5;
}
.toggle-switch-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-size: 0.88rem;
  color: #555;
}
.toggle-switch {
  position: relative;
  width: 40px;
  height: 22px;
  flex-shrink: 0;
}
.toggle-switch input { opacity: 0; width: 0; height: 0; }
.toggle-track {
  position: absolute;
  inset: 0;
  background: #ccc;
  border-radius: 11px;
  cursor: pointer;
  transition: background 0.2s;
}
.toggle-track::before {
  content: "";
  position: absolute;
  width: 16px; height: 16px;
  left: 3px; top: 3px;
  background: #fff;
  border-radius: 50%;
  transition: transform 0.2s;
  box-shadow: 0 1px 3px rgba(0,0,0,0.15);
}
.toggle-switch input:checked + .toggle-track { background: var(--brand); }
.toggle-switch input:checked + .toggle-track::before { transform: translateX(18px); }

/* ── Notifications settings page ────────────────────────── */
.notif-page-note {
  font-size: 0.82rem;
  color: #888;
  margin: -0.25rem 0 1.1rem;
}
.notif-row {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  margin-bottom: 0.25rem;
}
.notif-row-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}
.notif-row-info {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}
.notif-row-title {
  font-size: 0.9rem;
  font-weight: 600;
  color: #222;
}
.notif-row-desc {
  font-size: 0.8rem;
  color: #888;
}
.notif-time-row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding-left: 0.1rem;
}
.notif-time-label {
  font-size: 0.82rem;
  color: #555;
}
.notif-time-row input[type="time"] {
  padding: 0.28rem 0.5rem;
  border: 1px solid #ddd;
  border-radius: 6px;
  font-size: 0.85rem;
  background: #fafafa;
  color: #333;
}

/* ── Profile fields in config tab ─────────────────────── */
#config-profile-fields {
  background: #f8f9fb;
  border-radius: 8px;
  padding: 0.75rem 1rem;
  margin-bottom: 0.75rem;
}
.profile-field-row {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  padding: 0.3rem 0;
  font-size: 0.88rem;
}
.profile-field-row .pf-label { color: #999; width: 60px; flex-shrink: 0; }
.profile-field-row .pf-value { color: #333; font-weight: 500; }

/* ── Floating action buttons (FABs) ──────────────────── */
#quick-add-fab, #dict-fab {
  position: fixed;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 3px 12px rgba(0,0,0,0.22);
  z-index: 450;
  transition: transform 0.15s, box-shadow 0.15s, opacity 0.2s;
  right: 1.25rem;
}
#quick-add-fab:hover, #dict-fab:hover {
  transform: scale(1.07);
  box-shadow: 0 5px 18px rgba(0,0,0,0.28);
}
#quick-add-fab {
  bottom: calc(var(--nav-h) + var(--sab) + 0.75rem);
  background: var(--brand);
  color: #fff;
  font-size: 1.5rem;
  line-height: 1;
}
#quick-add-fab.hidden { opacity: 0; pointer-events: none; }
#dict-fab {
  bottom: calc(var(--nav-h) + var(--sab) + 0.75rem);
  background: var(--orange);
  color: #fff;
  opacity: 0;
  pointer-events: none;
}
#dict-fab.visible { opacity: 1; pointer-events: auto; }
#dict-fab svg { width: 24px; height: 24px; stroke: #fff; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* Desktop: hide FABs (word panel is sidebar, quick-add is in words tab) */
@media (min-width: 768px) and (pointer: fine) {
  #quick-add-fab, #dict-fab { display: none; }
}

/* ── Quick-add modal ──────────────────────────────────── */
#quick-add-modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  z-index: 9000;
  padding-top: calc(env(safe-area-inset-top, 0px) + 0.75rem);
}
#quick-add-modal.hidden { display: none; }
#quick-add-box {
  background: #fff;
  border-radius: 16px;
  padding: 1.25rem 1.25rem 1.5rem;
  width: calc(100% - 2rem);
  max-width: 480px;
  box-shadow: 0 4px 24px rgba(0,0,0,0.22);
}
#quick-add-box h3 { margin: 0 0 0.75rem; font-size: 1rem; color: #333; }
#quick-add-input-row {
  display: flex;
  gap: 0.5rem;
}
#quick-add-word-input {
  flex: 1;
  padding: 0.55rem 0.75rem;
  border: 1px solid #ddd;
  border-radius: 8px;
  font-size: 1rem;
  font-family: inherit;
}
#quick-add-submit {
  padding: 0.55rem 1rem;
  background: var(--brand);
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 0.9rem;
  cursor: pointer;
  white-space: nowrap;
}
#quick-add-submit:hover { opacity: 0.88; }
#quick-add-status { font-size: 0.82rem; color: #666; margin-top: 0.5rem; min-height: 1.2em; }

/* ── Tune button standalone ───────────────────────────── */
#fsrs-tune-section { margin-top: 0.75rem; }
#tune-status { font-size: 0.85rem; color: #555; margin-top: 0.4rem; min-height: 1.2em; }

/* ── Stats tab: sections ──────────────────────────────────── */
.stats-section {
  padding: 1.5rem 0 1.5rem;
  border-top: 2px solid #e0e3e8;
}
.stats-section:first-child { border-top: none; padding-top: 0; }
#stats-tab-extras { border-top: 2px solid #e0e3e8; padding-top: 1.5rem; margin-top: 0; }
.stats-section-title {
  display: flex; align-items: center; gap: 0.45rem;
  font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.07em;
  color: #555; font-weight: 700; margin: 0 0 0.85rem;
}
.stats-section-title svg {
  width: 13px; height: 13px; stroke: currentColor; fill: none;
  stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex-shrink: 0;
}

/* ── KPI cards (streak + reviews today) ────────────────── */
#activity-kpis { display: flex; gap: 0.65rem; margin-bottom: 0.85rem; }
.kpi-card {
  flex: 1; padding: 0.85rem 0.75rem; background: #f5f7fa;
  border-radius: 10px; display: flex; flex-direction: column;
  align-items: center; transition: background 0.2s, color 0.2s;
}
.kpi-value { font-size: 2rem; font-weight: 700; color: inherit; line-height: 1; }
.kpi-label { font-size: 0.7rem; color: #999; margin-top: 0.25rem; text-align: center; }

/* ── Heatmap ─────────────────────────────────────────────── */
#heatmap-container { padding-bottom: 0.25rem; }
#activity-heatmap { display: block; width: 100%; }

/* ── Forecast ────────────────────────────────────────────── */
.forecast-legend {
  display: flex; gap: 0.9rem; font-size: 0.75rem; color: #666;
  margin-bottom: 0.55rem; align-items: center;
}
.legend-swatch {
  width: 10px; height: 10px; border-radius: 2px;
  display: inline-block; margin-right: 0.25rem; flex-shrink: 0;
}
.overdue-swatch { background: var(--orange); }
.scheduled-swatch { background: var(--brand); }
#forecast-container { padding-bottom: 0.25rem; }
#forecast-chart { display: block; width: 100%; }

/* ── Range selector buttons ──────────────────────────────── */
.range-row { display: flex; gap: 0.4rem; margin-top: 0.6rem; flex-wrap: wrap; }
.range-btn {
  padding: 0.22rem 0.65rem; font-size: 0.73rem;
  border: 1px solid #ddd; border-radius: 12px;
  background: transparent; cursor: pointer; color: #777;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.range-btn:hover { border-color: var(--brand); color: var(--brand); }
.range-btn-active { background: var(--brand) !important; color: #fff !important; border-color: var(--brand) !important; }

/* ── Maturity cards ──────────────────────────────────────── */
.maturity-row { display: flex; gap: 0.6rem; margin-top: 0.5rem; }
.maturity-card {
  flex: 1; padding: 0.75rem 0.5rem; border-radius: 10px;
  display: flex; flex-direction: column; align-items: center;
}
.maturity-new { background: #f0f1f3; }
.maturity-young { background: var(--brand-tint); }
.maturity-mature { background: var(--brand); color: #fff; }
.maturity-value { font-size: 1.55rem; font-weight: 700; line-height: 1; }
.maturity-new .maturity-value { color: #555; }
.maturity-young .maturity-value { color: var(--brand); }
.maturity-mature .maturity-value { color: #fff; }
.maturity-label { font-size: 0.68rem; margin-top: 0.22rem; opacity: 0.7; }
.maturity-mature .maturity-label { opacity: 0.85; }
.maturity-legend {
  font-size: 0.68rem; color: #bbb; margin: 0.5rem 0 0;
  line-height: 1.5;
}

/* ── Stats tab extras (duplicated stat cards + pie) ────── */
#stats-tab-extras #stats-bar-clone {
  display: flex;
  gap: 1.5rem;
  padding: 0.75rem 1rem;
  background: #f5f5f5;
  border-radius: 8px;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}
@media (max-width: 767px) {
  #stats-tab-extras #stats-bar-clone { display: grid; grid-template-columns: 1fr 1fr; gap: 0.5rem; }
}
#stats-tab-extras #stats-bar-clone .stat-item { min-width: unset; }

/* ── JLPT deck cards ──────────────────────────────────── */
.jlpt-deck-list { display: flex; flex-direction: column; gap: 0.5rem; }
.jlpt-deck-card {
  display: flex; align-items: center; gap: 0.75rem;
  padding: 0.65rem 0.85rem; border-radius: 10px;
  border: 1px solid rgba(0,0,0,0.08); background: rgba(0,0,0,0.02);
}
.jlpt-deck-badge {
  width: 40px; height: 40px; border-radius: 8px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 0.88rem; color: #fff; letter-spacing: 0.01em;
}
.jlpt-badge-n5 { background: #3d7a5a; }
.jlpt-badge-n4 { background: #2d6490; }
.jlpt-badge-n3 { background: #9a7020; }
.jlpt-badge-n2 { background: #5d3d88; }
.jlpt-badge-n1 { background: #882d2d; }
.jlpt-deck-info { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 0.1rem; }
.jlpt-deck-name { font-size: 0.9rem; font-weight: 600; }
.jlpt-deck-meta { font-size: 0.78rem; opacity: 0.62; }
.deck-btn-added { border-color: #4caf50 !important; color: #4caf50 !important; cursor: default !important; }
.deck-btn-added:hover { background: transparent !important; color: #4caf50 !important; }
#show-jlpt-btn { margin-bottom: 0; }

/* ── Furigana setting in config ───────────────────────── */
.radio-group { display: flex; gap: 0.75rem; flex-wrap: wrap; }
.radio-option {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.88rem;
  color: #444;
  cursor: pointer;
}
.radio-option input[type="radio"] { accent-color: var(--brand); }

/* ── About section in config ──────────────────────────── */
#config-about { margin-bottom: 1.5rem; padding-bottom: 1.5rem; border-bottom: 1px solid #eee; }
#config-about h1 { font-size: 1.1rem; margin: 0 0 0.1rem; color: #222; }
#config-about .about-subtitle { font-size: 0.82rem; color: #999; margin: 0 0 1rem; }
#config-about h2 { font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.07em; color: #aaa; margin: 1rem 0 0.5rem; font-weight: 600; }
#config-page-about .about-body { font-size: 0.84rem; color: #444; margin: 0 0 0.6rem; line-height: 1.5; }
#config-page-about .about-list { font-size: 0.84rem; color: #444; margin: 0 0 0.6rem 1.2rem; padding: 0; line-height: 1.6; }
#config-page-about .about-sign { font-size: 0.82rem; color: #999; margin: 0.8rem 0 0; font-style: italic; }

/* ── Landscape lock (mobile only) ────────────────────── */
#rotate-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 99999;
  background: #1a1a1a;
  color: #fff;
  align-items: center;
  justify-content: center;
}
#rotate-overlay-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  padding: 2rem;
  text-align: center;
}
#rotate-overlay-inner svg { opacity: 0.6; }
#rotate-overlay-inner p { margin: 0; font-size: 1rem; opacity: 0.8; }

@media (pointer: coarse) and (orientation: landscape) {
  #rotate-overlay { display: flex; }
}

/* ── Story Settings Panel ───────────────────────────────── */
.story-slot-bar {
  display: flex; align-items: center; gap: 0.5rem;
  margin-bottom: 1rem; font-size: 0.78rem; color: #888;
}
.story-slot-dots { display: flex; gap: 0.35rem; align-items: center; }
.story-slot-dot {
  width: 9px; height: 9px; border-radius: 50%;
  background: var(--brand);
}
.story-slot-dot.empty { background: #ddd; }
.story-new-btn { margin-left: auto; border-color: var(--brand) !important; color: var(--brand) !important; }
.story-new-btn:hover { background: var(--brand-tint) !important; }

.story-card {
  border: 1px solid #e8e8e8; border-radius: 8px;
  padding: 0.65rem 0.75rem; margin-bottom: 0.5rem;
  background: #fff;
}
.story-card.is-active {
  border-color: var(--brand); background: var(--brand-tint);
}
.story-card-header {
  display: flex; align-items: center; gap: 0.45rem; margin-bottom: 0.35rem;
}
.story-card-label { font-size: 0.82rem; font-weight: 600; color: #333; flex: 1; }
.story-card-para { font-size: 0.74rem; color: #bbb; }
.story-active-badge {
  font-size: 0.68rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em;
  background: #e8f4e8; color: #2a7a2a; padding: 0.1rem 0.45rem; border-radius: 10px;
}
.story-card-preview {
  font-size: 0.78rem; color: #777; margin-bottom: 0.5rem; line-height: 1.45;
}
.story-card-actions { display: flex; gap: 0.4rem; flex-wrap: wrap; }
.story-card-btn {
  font-size: 0.74rem; padding: 0.22rem 0.6rem;
  border-radius: 5px; cursor: pointer;
  border: 1px solid #d0d0d0; background: #fff; color: #555;
  transition: background 0.12s, border-color 0.12s;
}
.story-card-btn:hover { background: #f4f4f4; border-color: #bbb; }
.story-card-btn.active-btn { border-color: var(--brand); color: var(--brand); }
.story-card-btn.active-btn:hover { background: var(--brand-tint); }
.story-card-btn.delete-btn { border-color: #d9534f; color: #c0392b; }
.story-card-btn.delete-btn:hover { background: #fff5f5; border-color: #c0392b; }
.story-card-summary {
  display: none; margin-top: 0.55rem;
  padding: 0.55rem 0.65rem;
  background: #f8f8f8; border: 1px solid #ebebeb; border-radius: 5px;
  font-size: 0.76rem; line-height: 1.6; color: #444;
  white-space: pre-wrap; max-height: 180px; overflow-y: auto;
}

    #offline-banner {
      position: fixed; top: 0; left: 0; right: 0;
      height: 28px;
      background: #92400e; color: #fef3c7;
      display: flex; align-items: center; justify-content: center;
      font-size: 0.72rem; font-weight: 500; letter-spacing: 0.01em;
      z-index: 600;
    }
    #offline-banner[hidden] { display: none; }
