
    :root {
      --red:     #b71c1c;
      --red-dark:#7f0000;
      --bg:      #faf7f2;
      --card:    #ffffff;
      --border:  #ede3d8;
      --text:    #1a1a1a;
      --ink:     #1a1a1a;
      --sub:     #555;
      --muted:   #999;
      --n5:      #00695c;  --n5-bg: #e0f2f1;
      --n4:      #1b5e20;  --n4-bg: #e8f5e9;
      --n3:      #0d47a1;  --n3-bg: #e3f2fd;
      --n2:      #4a148c;  --n2-bg: #f3e5f5;
      --n1:      #b71c1c;  --n1-bg: #fce4e4;
      --skel:    #e8e0d5;
    }

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

    body {
      font-family: 'Noto Sans JP', 'Hiragino Kaku Gothic ProN', 'Yu Gothic', sans-serif;
      background: var(--bg);
      color: var(--text);
      min-height: 100vh;
    }

    /* ���� Header ���������������������������������������������������������������������� */
    header {
      background: linear-gradient(135deg, var(--red) 0%, var(--red-dark) 100%);
      color: #fff;
      padding: 16px 32px;
      display: grid;
      grid-template-columns: 1fr auto 1fr;
      align-items: center;
      gap: 16px;
      box-shadow: 0 2px 20px rgba(0,0,0,.35);
      position: sticky;
      top: 0;
      z-index: 10;
    }
    .h-left   { text-align: left; }
    .h-center { text-align: center; }
    .h-right  { display: flex; align-items: center; justify-content: flex-end; gap: 10px; }
    .h-title { font-size: 26px; font-weight: 900; letter-spacing: 3px; font-family: 'Noto Sans JP', 'Yu Gothic', sans-serif; }
    .h-sub   { font-size: 12px; opacity: .55; margin-top: 3px; letter-spacing: 1px; }
    .h-date  { font-size: 13px; opacity: .75; }
    .h-greet { font-size: 12px; opacity: .45; margin-top: 3px; }
    .h-settings-btn {
      background: rgba(255,255,255,.1); border: 1px solid rgba(255,255,255,.2);
      color: rgba(255,255,255,.8); border-radius: 8px; padding: 6px 10px;
      font-size: 15px; cursor: pointer; line-height: 1;
      transition: background .15s;
      flex-shrink: 0;
      touch-action: manipulation;
      -webkit-tap-highlight-color: rgba(0,0,0,0);
      position: relative;
      z-index: 5;
    }
    .h-settings-btn:hover { background: rgba(255,255,255,.2); }
    /* hamburger wrap hidden on desktop */
    .h-hamburger-wrap { display: none; }

    /* ── Settings drawer (slide-in from right) ────────────────────────── */
    #settingsPage {
      position: fixed; top: 0; right: 0; bottom: 0;
      width: 360px; z-index: 1000;
      background: #fff;
      box-shadow: -4px 0 30px rgba(0,0,0,.18);
      transform: translateX(100%);
      transition: transform .28s cubic-bezier(.4,0,.2,1);
      display: flex; flex-direction: column;
      overflow: hidden;
    }
    #settingsPage.open { transform: translateX(0); }
    .settings-page-header {
      background: var(--red); color: #fff;
      display: flex; align-items: center; gap: 14px;
      padding: 16px 20px; flex-shrink: 0;
    }
    .settings-back-btn {
      background: rgba(255,255,255,.15); border: none; color: #fff;
      font-size: 15px; padding: 8px 14px; border-radius: 8px; cursor: pointer;
      touch-action: manipulation; -webkit-tap-highlight-color: rgba(0,0,0,0);
      flex-shrink: 0;
    }
    .settings-page-title { font-size: 17px; font-weight: 700; }
    .settings-page-body  { padding: 20px 24px 28px; overflow-y: auto; flex: 1; }
    .settings-section-title {
      font-size: 12px; font-weight: 700; text-transform: uppercase;
      letter-spacing: .08em; color: var(--muted);
      margin-bottom: 14px;
    }
    .settings-row {
      display: flex; align-items: center; justify-content: space-between;
      gap: 12px; padding: 10px 0; border-top: 1px solid var(--border);
    }
    .settings-label  { font-size: 14px; color: var(--sub); font-weight: 500; }
    .settings-toggle {
      width: 40px; height: 22px; cursor: pointer; accent-color: var(--red);
    }
    .settings-save-row {
      display: flex; align-items: center; gap: 14px;
      margin-top: 22px; padding-top: 18px; border-top: 1px solid var(--border);
    }
    .settings-save-msg { font-size: 13px; color: #388e3c; font-weight: 600; }
    /* Mobile: full width */
    @media (max-width: 640px) {
      #settingsPage { width: 100%; }
    }

    /* ���� Toolbar ���������������������������������������������������������������������� */
    .toolbar {
      max-width: 1120px;
      margin: 22px auto 0;
      padding: 0 24px;
      display: flex;
      align-items: center;
      gap: 10px;
      flex-wrap: wrap;
    }
    .btn {
      padding: 9px 20px;
      border: none;
      border-radius: 8px;
      font-size: 13px;
      font-weight: 700;
      cursor: pointer;
      transition: background .18s, transform .12s;
    }
    .btn:active { transform: scale(.97); }
    .btn-primary { background: var(--red); color: #fff; }
    .btn-primary:hover { background: #c62828; }
    .btn-ghost { background: #fff; color: var(--sub); border: 1.5px solid var(--border); }
    .btn-ghost:hover { background: #f5f0ea; }

    .toolbar-info { font-size: 13px; color: var(--muted); margin-left: 4px; }
    .toolbar-info strong { color: var(--sub); }

    /* ���� Status bar ���������������������������������������������������������������� */
    #statusMsg {
      font-size: 12px;
      padding: 3px 10px;
      border-radius: 20px;
      margin-left: auto;
    }
    .status-loading { background: #fff8e1; color: #f57f17; }
    .status-ok      { background: #e8f5e9; color: #2e7d32; }
    .status-error   { background: #fce4e4; color: #b71c1c; }

    /* ���� Legend ���������������������������������������������������������������������� */
    .legend {
      max-width: 1120px;
      margin: 14px auto 0;
      padding: 0 24px;
      display: flex;
      gap: 10px;
      flex-wrap: wrap;
      align-items: center;
    }
    .legend-item { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--sub); }
    .legend-dot  { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }

    /* ���� Grid ���������������������������������������������������������������������� */
    .grid {
      max-width: 1120px;
      margin: 20px auto 48px;
      padding: 0 24px;
      display: grid;
      grid-template-columns: repeat(auto-fill, minmax(330px, 1fr));
      gap: 20px;
    }

    /* ���� Card ���������������������������������������������������������������������� */
    .card {
      background: var(--card);
      border: 1px solid var(--border);
      border-radius: 12px;
      padding: 26px 24px 22px;
      box-shadow: 0 2px 14px rgba(0,0,0,.05);
      transition: transform .18s, box-shadow .18s;
      opacity: 0;
      animation: rise .38s ease forwards;
      position: relative;
      display: flex;
      flex-direction: column;
    }
    .card-body { flex: 1; display: flex; flex-direction: column; }
    .card:hover { transform: translateY(-4px); box-shadow: 0 10px 30px rgba(0,0,0,.1); }
    @keyframes rise {
      from { opacity: 0; transform: translateY(12px); }
      to   { opacity: 1; transform: translateY(0);    }
    }

    /* ���� Skeleton card ���������������������������������������������������������� */
    .skeleton {
      display: flex;
      gap: 16px;
      align-items: flex-start;
      opacity: 0;
      animation: rise .38s ease forwards;
    }
    .skel-big  { width: 82px; height: 82px; border-radius: 10px; background: var(--skel); flex-shrink: 0; animation: pulse 1.4s ease-in-out infinite; }
    .skel-line { height: 14px; border-radius: 6px; background: var(--skel); animation: pulse 1.4s ease-in-out infinite; margin-bottom: 8px; }
    @keyframes pulse { 0%,100%{opacity:1} 50%{opacity:.45} }

    .card-top  { display: flex; gap: 16px; align-items: flex-start; margin-bottom: 18px; overflow: hidden; }
    .kanji-char {
      font-size: 72px; line-height: 1; font-weight: 900; color: #111;
      width: 82px; min-width: 82px; text-align: center; user-select: none; flex-shrink: 0;
    }
    .card-info { flex: 1; padding-top: 4px; min-width: 0; overflow: hidden; display: flex; flex-direction: column; }
    .card-info .badge { order: 1; align-self: flex-start; margin-bottom: 0; margin-top: 8px; }

    .badge {
      display: inline-block; padding: 2px 10px; border-radius: 20px;
      font-size: 11px; font-weight: 800; letter-spacing: 1px; margin-bottom: 8px;
    }
    .badge-N5 { background: var(--n5-bg); color: var(--n5); }
    .badge-N4 { background: var(--n4-bg); color: var(--n4); }
    .badge-N3 { background: var(--n3-bg); color: var(--n3); }
    .badge-N2 { background: var(--n2-bg); color: var(--n2); }
    .badge-N1 { background: var(--n1-bg); color: var(--n1); }

    .card-meaning {
      font-size: 16px; font-weight: 700; line-height: 1.4; color: #1a1a1a;
      word-break: break-word; overflow-wrap: break-word;
    }

    /* ���� Readings �������������������������������������������������������������� */
    .readings { display: flex; gap: 16px; flex-wrap: wrap; border-top: 1px solid var(--border); padding-top: 14px; margin-bottom: 16px; }
    .reading-label { font-size: 10px; font-weight: 800; text-transform: uppercase; letter-spacing: 1px; color: var(--muted); display: block; margin-bottom: 4px; }
    .reading-kana  { font-size: 14px; font-weight: 700; color: #6d4c41; letter-spacing: 1px; word-break: break-all; }

    /* ���� Examples �������������������������������������������������������������� */
    .examples-label { font-size: 10px; font-weight: 800; text-transform: uppercase; letter-spacing: 1px; color: var(--muted); margin-bottom: 8px; }
    .example {
      display: flex;
      flex-direction: column;
      gap: 3px;
      padding: 8px 10px;
      background: var(--bg);
      border-radius: 8px;
      border-left: 3px solid var(--border);
      margin-bottom: 6px;
      overflow: hidden;
    }
    .example:last-child { margin-bottom: 0; }
    .ex-top     { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
    .ex-word    { font-size: 15px; font-weight: 800; color: #111; }
    .ex-reading { font-size: 11px; color: var(--muted); }
    .ex-meaning { font-size: 12px; color: var(--sub); word-break: break-word; overflow-wrap: break-word; }

    /* ���� Quiz mode ������������������������������������������������������������ */
    .btn-quiz         { background: #fff3e0; color: #e65100; border: 1.5px solid #ffcc80; }
    .btn-quiz:hover   { background: #ffe0b2; }
    .btn-quiz.active  { background: #e65100; color: #fff; border-color: #e65100; }

    .btn-save          { background: #e8f5e9; color: #2e7d32; border: 1.5px solid #a5d6a7; }
    .btn-save:hover    { background: #c8e6c9; }
    .btn-save.saved    { background: #2e7d32; color: #fff; border-color: #2e7d32; cursor: default; }

    /* Level filter pills */
    .level-filter       { display:flex; gap:6px; align-items:center; flex-wrap:wrap; padding:0 24px 10px; max-width:1120px; margin:12px auto 0; }
    .level-filter-label { font-size:12px; color:var(--muted); font-weight:600; margin-right:2px; }
    .pill               { font-size:12px; font-weight:700; padding:4px 12px; border-radius:20px; border:1.5px solid var(--border); background:#fff; color:var(--sub); cursor:pointer; transition:all .15s; }
    .pill:hover         { background:#f5f0ea; }
    .pill.active        { color:#fff; border-color:transparent; }
    .pill[data-level="all"].active { background:#666; }
    .pill[data-level="5"].active  { background:var(--n5); }
    .pill[data-level="4"].active  { background:var(--n4); }
    .pill[data-level="3"].active  { background:var(--n3); }
    .pill[data-level="2"].active  { background:var(--n2); }
    .pill[data-level="1"].active  { background:var(--n1); }

    /* Search bar */
    .search-wrap  { display:flex; padding:10px 24px; max-width:1120px; margin:0 auto; }
    .search-input { width:100%; padding:8px 16px; border:1.5px solid var(--border); border-radius:20px; font-size:14px; background:var(--card); color:var(--text); outline:none; transition:border-color .15s; }
    .search-input:focus { border-color:var(--red); }
    .search-input::-webkit-search-cancel-button { cursor:pointer; }
    .search-no-results { grid-column:1/-1; text-align:center; color:var(--muted); padding:48px 24px; font-size:15px; }

    /* ���� Vocab interactive quiz ���������������������������������������� */
    .quiz-screen {
      grid-column: 1 / -1;
      display: flex;
      flex-direction: column;
      align-items: center;
      padding: 8px 16px 48px;
      max-width: 640px;
      margin: 0 auto;
      width: 100%;
    }
    .quiz-progress-wrap {
      width: 100%; height: 7px;
      background: var(--border); border-radius: 4px;
      margin-bottom: 12px; overflow: hidden;
    }
    .quiz-progress-bar {
      height: 100%; background: var(--red); border-radius: 4px;
      transition: width .45s ease;
    }
    .quiz-meta {
      font-size: 13px; color: var(--muted);
      margin-bottom: 18px; letter-spacing: 1px;
    }
    .quiz-question-card {
      background: var(--card); border: 1px solid var(--border);
      border-radius: 12px; padding: 30px 28px 22px;
      width: 100%; text-align: center;
      box-shadow: 0 2px 14px rgba(0,0,0,.06);
      margin-bottom: 18px;
    }
    .quiz-direction-label {
      font-size: 11px; font-weight: 800;
      text-transform: uppercase; letter-spacing: 1.5px;
      color: var(--muted); margin-bottom: 16px;
    }
    .quiz-prompt-word {
      font-size: 72px; font-weight: 900; line-height: 1;
      color: #111; margin-bottom: 8px;
    }
    .quiz-prompt-meaning {
      font-size: 20px; font-weight: 700; color: #1a1a1a;
      line-height: 1.4; margin-bottom: 8px;
    }
    .quiz-prompt-reading {
      font-size: 14px; color: var(--red); font-weight: 700;
      margin-bottom: 8px;
    }
    .quiz-options {
      display: grid;
      grid-template-columns: 1fr 1fr;
      gap: 12px; width: 100%;
    }
    .quiz-option {
      background: #fff; border: 2px solid var(--border);
      border-radius: 12px; padding: 16px 12px;
      font-size: 14px; font-weight: 600; cursor: pointer;
      text-align: center; line-height: 1.4; color: var(--text);
      font-family: inherit;
      transition: background .14s, border-color .14s, transform .1s;
    }
    .quiz-option:hover:not(:disabled) {
      background: var(--bg); border-color: var(--red);
      transform: translateY(-2px);
    }
    .quiz-option.correct { background: #e8f5e9; border-color: #2e7d32; color: #1b5e20; }
    .quiz-option.wrong   { background: #fce4e4; border-color: #b71c1c; color: #b71c1c; }
    .quiz-option:disabled { cursor: default; transform: none; }
    /* Reveal card */
    .quiz-reveal {
      background: var(--card); border: 1.5px solid var(--border);
      border-radius: 12px; padding: 16px 20px; margin-top: 16px; text-align: center;
      animation: fadeIn .2s ease;
    }
    .quiz-reveal-word    { font-size: 28px; font-weight: 700; color: var(--text); }
    .quiz-reveal-reading { font-size: 14px; font-weight: 400; color: var(--muted); margin-left: 8px; }
    .quiz-reveal-meaning { font-size: 15px; color: var(--sub); margin-top: 6px; }
    .quiz-reveal-extras  { font-size: 12px; color: var(--muted); margin-top: 4px; }
    .quiz-reveal-pos     { font-size: 11px; color: var(--muted); margin-top: 4px; font-style: italic; }
    .quiz-next-btn {
      margin-top: 14px; background: var(--red); color: #fff;
      border: none; border-radius: 8px; padding: 10px 28px;
      font-size: 14px; font-weight: 700; cursor: pointer; font-family: inherit;
      transition: background .15s;
    }
    .quiz-next-btn:hover { background: #c62828; }
    /* Streak dots */
    .streak-dots { display: flex; gap: 6px; margin-top: 8px; justify-content: center; align-items: center; }
    .streak-dot  { width: 9px; height: 9px; border-radius: 50%; border: 2px solid var(--border); background: transparent; }
    .streak-dot-done  { background: var(--red); border-color: var(--red); }
    .streak-dot-today { border-color: var(--red); }
    .streak-dot-flame { width: auto; height: auto; border: none; background: none; font-size: 16px; line-height: 1; }
    /* Results screen */
    .quiz-results     { text-align: center; padding-top: 40px; }
    .quiz-result-emoji { font-size: 56px; margin-bottom: 12px; }
    .quiz-result-score { font-size: 52px; font-weight: 900; color: var(--red); line-height: 1; }
    .quiz-result-pct   { font-size: 20px; color: var(--muted); margin: 4px 0 10px; }
    .quiz-result-msg   { font-size: 18px; font-weight: 700; color: var(--sub); }
    .quiz-result-time  { font-size: 13px; color: var(--muted); margin-top: 6px; }
    .quiz-elapsed-wrap { opacity: 0.35; font-size: 12px; }
    .quiz-elapsed      { font-variant-numeric: tabular-nums; }

    .quiz-tomorrow {
      margin: 32px auto 0; max-width: 380px;
      background: #fff8f2; border: 1.5px solid #f5d9c4;
      border-radius: 14px; padding: 20px 24px;
      text-align: center;
    }
    .quiz-tomorrow-icon  { font-size: 32px; margin-bottom: 6px; }
    .quiz-tomorrow-title { font-size: 17px; font-weight: 800; color: var(--red); margin-bottom: 6px; }
    .quiz-tomorrow-body  { font-size: 14px; color: var(--sub); line-height: 1.6; }
    .btn-notif-opt {
      margin-top: 16px; padding: 9px 18px; border-radius: 20px;
      border: 1.5px solid var(--red); background: transparent;
      color: var(--red); font-size: 13px; font-weight: 700;
      cursor: pointer; font-family: inherit; transition: background .15s, color .15s;
    }
    .btn-notif-opt:hover:not(:disabled) { background: var(--red); color: #fff; }
    .btn-notif-opt.notif-opted, .btn-notif-opt:disabled { opacity: .65; cursor: default; }
    .notif-time-row {
      display: flex; align-items: center; justify-content: center;
      gap: 8px; margin-top: 16px; flex-wrap: wrap;
    }
    .notif-time-input {
      padding: 7px 10px; border-radius: 8px;
      border: 1.5px solid var(--border); background: #fff;
      font-size: 14px; font-family: inherit; color: var(--sub);
      cursor: pointer;
    }
    .notif-time-input:disabled { opacity: .65; cursor: default; }

    /* ── My List full empty state ──────────────────────────────────────── */
    .mylist-full-empty {
      text-align: center; padding: 72px 24px 48px;
    }
    .mylist-full-empty-icon  { font-size: 56px; margin-bottom: 16px; }
    .mylist-full-empty-title { font-size: 22px; font-weight: 800; color: var(--sub); margin-bottom: 10px; }
    .mylist-full-empty-body  { font-size: 15px; color: var(--muted); line-height: 1.6; margin-bottom: 28px; }
    .mylist-full-empty-actions { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }

    /* ���� Tabs �������������������������������������������������������������������������� */
    .tabbar {
      max-width: 1120px;
      margin: 0 auto;
      padding: 10px 24px 0;
      display: flex;
      gap: 6px;
      position: sticky;
      top: 0;
      z-index: 9;
      background: var(--bg);
      box-shadow: 0 2px 8px rgba(0,0,0,.06);
    }
    .tab {
      padding: 7px 16px;
      border: none;
      border-radius: 8px 8px 0 0;
      font-size: 18px;
      font-weight: 900;
      font-family: 'Noto Sans JP', 'Yu Gothic', sans-serif;
      cursor: pointer;
      background: #ede3d8;
      color: var(--sub);
      transition: background .18s, color .18s;
      letter-spacing: 0;
      text-align: center;
      line-height: 1.3;
      display: inline-flex;
      flex-direction: column;
      align-items: center;
      justify-content: center;
      gap: 2px;
    }
    .tab br { display: none; }
    .tab:hover  { background: #e0d5c8; }
    .tab.active { background: var(--red); color: #fff; }

    /* ── Vocab card extras ───────────────────────────────────────────────── */
    .vocab-header { margin-bottom: 10px; display: flex; align-items: center; flex-wrap: wrap; gap: 4px; }
    .vocab-word {
      font-size: 48px; line-height: 1.15; font-weight: 900; color: #111;
      user-select: none; word-break: break-word;
    }
    .vocab-reading {
      font-size: 14px; font-weight: 700; color: #6d4c41;
      letter-spacing: 1px; margin-top: 3px;
    }
    .vocab-meta {
      display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
      margin-bottom: 12px;
    }
    .vocab-meta .badge { margin-bottom: 0; }
    .source-kanji-tag {
      font-size: 18px; font-weight: 900; color: var(--red);
      background: var(--n3-bg); padding: 0 7px; border-radius: 7px;
      line-height: 1.6; letter-spacing: 0;
    }
    .vocab-pos {
      display: inline-block; font-size: 10px; font-weight: 700;
      color: var(--muted); background: var(--bg);
      border: 1px solid var(--border);
      padding: 1px 7px; border-radius: 10px;
    }

    /* ���� Footer ���������������������������������������������������������������������� */
    /* ── Kanji save button ────────────────────────────────────────────────── */
    .kanji-save-btn {
      position: absolute; top: 12px; right: 14px; z-index: 3;
      background: none; border: none; cursor: pointer;
      font-size: 20px; color: var(--muted); line-height: 1;
      padding: 4px; transition: color .15s, transform .1s;
    }
    .kanji-save-btn:hover { color: var(--red); transform: scale(1.2); }
    .kanji-save-btn.saved { color: var(--red); }

    /* ── Speak (TTS) button ───────────────────────────────────────────────── */
    .speak-btn {
      background: none; border: none; cursor: pointer;
      font-size: 18px; line-height: 1; padding: 4px 6px;
      border-radius: 6px; opacity: 0.7;
      transition: opacity .15s, background .15s, transform .1s;
      vertical-align: middle;
    }
    .speak-btn:hover { opacity: 1; background: var(--border); transform: scale(1.15); }
    .speak-btn:active { transform: scale(0.95); opacity: 1; }

    /* Positioned variant for kanji cards (top-left of save btn) */
    .kanji-speak-btn {
      position: absolute; top: 12px; right: 46px; z-index: 3;
      font-size: 16px; padding: 4px;
    }

    /* Vocab card — inline dans le header */
    .vocab-speak-btn { margin-left: auto; flex-shrink: 0; }

    /* Quiz speak button */
    .quiz-speak-btn { display: block; margin: 10px auto 0; font-size: 22px; opacity: 0.7; }
    .quiz-speak-btn:hover { opacity: 1; background: none; }

    footer { text-align: center; padding: 32px 20px; font-size: 13px; color: var(--muted); }

    /* ── Stats / Progression ─────────────────────────────────────────────── */
    .stats-section {
      max-width: 1120px;
      margin: 20px auto 48px;
      padding: 0 24px;
    }
    .stats-container { display: flex; flex-direction: column; gap: 24px; }
    .kpi-grid {
      display: grid;
      grid-template-columns: 1fr 1fr 1fr;
      grid-template-rows: auto auto;
      gap: 16px;
    }
    .kpi-wotd { grid-column: 3; grid-row: 1 / span 2; display: flex; flex-direction: column; justify-content: center; }
    .kpi-card {
      background: var(--card);
      border: 1px solid var(--border);
      border-radius: 12px;
      padding: 24px 20px 18px;
      text-align: center;
      box-shadow: 0 2px 10px rgba(0,0,0,.05);
      display: flex; flex-direction: column; align-items: center; justify-content: center;
    }
    .kpi-jlpt { justify-content: flex-start !important; }
    .kpi-num { font-size: 48px; font-weight: 900; color: var(--red); line-height: 1; margin-bottom: 8px; }
    .kpi-lbl { font-size: 13px; font-weight: 700; color: var(--sub); letter-spacing: .3px; }
    .chart-block {
      background: var(--card);
      border: 1px solid var(--border);
      border-radius: 12px;
      padding: 20px 20px 14px;
      box-shadow: 0 2px 10px rgba(0,0,0,.05);
    }
    .chart-title { font-size: 14px; font-weight: 800; color: var(--sub); letter-spacing: .3px; margin-bottom: 14px; }
    .chart-canvas { display: block; }
    .qh-list { display: flex; flex-direction: column; }
    .qh-row { display: flex; align-items: center; gap: 12px; padding: 9px 0; border-bottom: 1px solid var(--border); }
    .qh-row:last-child { border-bottom: none; }
    .qh-date  { font-size: 12px; color: var(--muted); min-width: 84px; font-weight: 600; }
    .qh-bar-wrap { flex: 1; height: 10px; background: var(--bg); border-radius: 5px; overflow: hidden; }
    .qh-bar  { height: 100%; background: var(--red); border-radius: 5px; }
    .qh-score { font-size: 13px; font-weight: 700; color: var(--sub); min-width: 90px; text-align: right; }
    .qh-pct  { color: var(--muted); font-weight: 400; }
    .qh-type { font-size: 10px; font-weight: 800; padding: 2px 7px; border-radius: 10px; margin-left: 4px; }
    .qh-type-daily    { background: #e3f2fd; color: #0d47a1; }
    .qh-type-biweekly { background: #fce4e4; color: #b71c1c; }
    .qh-type-srs      { background: #f3e5f5; color: #4a148c; }
    .qh-type-exam     { background: #1a237e; color: #fff; }

    /* ── Exam mode ──────────────────────────────────────────────────────── */
    .exam-countdown          { font-size: 15px; font-weight: 700; color: var(--text); font-variant-numeric: tabular-nums; }
    .exam-countdown.warning  { color: #e65100; }
    .exam-countdown.urgent   { color: var(--red); animation: pulse .8s infinite; }
    @keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: .45; } }
    .exam-result-banner {
      padding: 14px 24px; border-radius: 12px;
      font-size: 20px; font-weight: 900; letter-spacing: 2px;
      margin: 12px 0; text-align: center;
    }
    .exam-pass { background: #e8f5e9; color: #1b5e20; }
    .exam-fail { background: #ffebee; color: #b71c1c; }
    .btn-exam  { background: #1a237e !important; color: #fff !important; border: none !important; }
    .btn-exam:hover { background: #283593 !important; }
    /* Locked button */
    .btn-locked {
      background: #f0f0f0 !important; color: #bbb !important;
      border: 1.5px solid #ddd !important; cursor: not-allowed !important;
    }
    .btn-locked:hover { opacity: 1; transform: none !important; }
    /* Stats notification */
    .stat-notif {
      background: #fff3e0; border: 1.5px solid #ffcc80;
      border-radius: 12px; padding: 18px 20px;
      display: flex; align-items: flex-start; gap: 14px;
    }
    .stat-notif-icon { font-size: 28px; flex-shrink: 0; line-height: 1; }
    .stat-notif-body { flex: 1; }
    .stat-notif-title { font-size: 15px; font-weight: 800; color: #e65100; margin-bottom: 6px; }
    .stat-notif-sub   { font-size: 13px; color: #bf360c; line-height: 1.5; margin-bottom: 12px; }

    /* ── Home dashboard ─────────────────────────────────────────────────── */
    .home-section {
      max-width: 900px;
      margin: 24px auto 48px;
      padding: 0 24px;
      display: flex;
      flex-direction: column;
      gap: 24px;
    }
    .home-greeting {
      font-size: 22px;
      font-weight: 700;
      color: var(--ink);
    }
    .home-greeting span { color: var(--red); }
    .home-sub {
      font-size: 14px;
      color: var(--muted);
      margin-top: 2px;
    }
    .home-actions {
      display: grid;
      grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
      gap: 14px;
    }
    .home-action-card {
      background: var(--card);
      border: 1px solid var(--border);
      border-radius: 12px;
      padding: 20px 16px;
      cursor: pointer;
      transition: box-shadow .15s, transform .15s;
      text-align: center;
    }
    .home-action-card:hover {
      box-shadow: 0 4px 18px rgba(0,0,0,.1);
      transform: translateY(-2px);
    }
    .home-action-icon { font-size: 32px; margin-bottom: 8px; }
    .home-action-title { font-size: 15px; font-weight: 700; color: var(--ink); }
    .home-action-sub { font-size: 12px; color: var(--muted); margin-top: 3px; }
    .home-action-card.disabled { opacity: .45; cursor: default; pointer-events: none; }
    .home-today {
      background: var(--card);
      border: 1px solid var(--border);
      border-radius: 12px;
      padding: 18px 20px;
    }
    .home-today-title {
      font-size: 13px;
      font-weight: 700;
      color: var(--muted);
      text-transform: uppercase;
      letter-spacing: .06em;
      margin-bottom: 12px;
    }

    /* ── JLPT kpi card ────────────────────────────────────────────────────── */
    .kpi-jlpt { cursor: pointer; user-select: none; }
    .kpi-jlpt:hover { border-color: var(--red); }
    .kpi-jlpt-level { color: var(--red) !important; line-height: 1; }
    .kpi-jlpt-pct { font-size: 13px; font-weight: 700; color: var(--sub); margin-bottom: 4px; }
    .kpi-jlpt-hint { font-size: 11px; color: var(--muted); margin-top: 6px; letter-spacing: .3px; }
    .kpi-jlpt-sub { font-size: 10px; color: var(--muted); margin-top: 4px; line-height: 1.5; }
    .kpi-jlpt .kpi-jlpt-pct { font-size: 12px; }
    .kpi-streak-nudge { font-size: 11px; color: var(--sub); margin-top: 6px; line-height: 1.4; }
    .kpi-streak-nudge span { cursor: pointer; text-decoration: underline; }
    .kpi-grid-2col { grid-template-columns: 1fr 1fr !important; }
    .kpi-grid-2col .kpi-jlpt { grid-column: unset; }
    /* word of the day */
    .kpi-wotd { padding: 0 !important; overflow: hidden; display: flex !important; flex-direction: column !important; align-items: stretch !important; justify-content: flex-start !important; }
    .kpi-wotd-banner {
      background: linear-gradient(135deg, var(--red) 0%, var(--red-dark) 100%);
      color: #fff; text-align: center;
      padding: 20px 14px 18px;
      border-radius: 12px 12px 0 0;
    }
    .kpi-wotd-banner-emoji { font-size: 22px; margin-bottom: 4px; }
    .kpi-wotd-banner-title { font-size: 15px; font-weight: 900; letter-spacing: 2px; text-transform: uppercase; opacity: .95; }
    .kpi-wotd-body { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 20px 14px; }
    .kpi-wotd-kanji { font-size: clamp(1.6rem, 4.5vw, 3.2rem); font-weight: 900; color: var(--red); line-height: 1.1; margin-bottom: 8px; word-break: break-word; text-align: center; }
    .kpi-wotd-reading { font-size: 14px; font-weight: 700; color: var(--sub); margin-bottom: 5px; }
    .kpi-wotd-meaning { font-size: 12px; color: var(--muted); font-style: italic; }
    .kpi-wotd-save-btn {
      margin-top: 12px; padding: 6px 18px; font-size: 12px; font-weight: 700;
      background: var(--red); color: #fff; border: none; border-radius: 20px;
      cursor: pointer; transition: opacity .15s;
    }
    .kpi-wotd-save-btn:hover { opacity: .85; }
    .kpi-wotd-saved {
      margin-top: 12px; font-size: 12px; font-weight: 700; color: var(--red);
    }
    .home-today-row {
      display: flex;
      justify-content: space-between;
      align-items: center;
      padding: 6px 0;
      border-bottom: 1px solid var(--border);
      font-size: 14px;
    }
    .home-today-row:last-child { border-bottom: none; }
    .home-today-val { font-weight: 700; color: var(--red); }
    .home-today-val.good { color: #2e7d32; }

    /* ── My List tab ─────────────────────────────────────────────────── */
    .mylist-section {
      max-width: 1120px;
      margin: 20px auto 48px;
      padding: 0 24px;
    }
    .mylist-toolbar {
      display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
      margin-bottom: 18px;
    }
    .mylist-search {
      flex: 1; min-width: 180px; max-width: 320px;
      padding: 8px 14px; border: 1.5px solid var(--border);
      border-radius: 8px; font-size: 13px; font-family: inherit;
      background: #fff; color: var(--text);
    }
    .mylist-search:focus { outline: none; border-color: var(--red); }
    .mylist-count { font-size: 13px; color: var(--muted); margin-left: auto; }
    .mylist-table {
      width: 100%; border-collapse: collapse;
      background: var(--card); border-radius: 12px; overflow: hidden;
      box-shadow: 0 2px 14px rgba(0,0,0,.05);
    }
    .mylist-table th {
      text-align: left; padding: 12px 16px;
      font-size: 11px; font-weight: 800; text-transform: uppercase;
      letter-spacing: 1px; color: var(--muted);
      background: var(--bg); border-bottom: 1px solid var(--border);
    }
    .mylist-table td {
      padding: 11px 16px; border-bottom: 1px solid var(--border);
      font-size: 14px; color: var(--text); vertical-align: middle;
    }
    .mylist-table tr:last-child td { border-bottom: none; }
    .mylist-table tr:hover td { background: #faf5ef; }
    .mylist-word  { font-size: 20px; font-weight: 900; }
    .mylist-kana  { font-size: 12px; color: var(--red); font-weight: 700; display: block; }
    .mylist-date  { font-size: 11px; color: var(--muted); white-space: nowrap; }
    .ml-col-word    { width: 160px; min-width: 100px; }
    .ml-col-meaning { max-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--sub); font-size: 13px; }
    .mylist-empty {
      text-align: center; padding: 64px 20px; color: var(--muted);
      font-size: 15px;
    }
    .mylist-empty-icon { font-size: 48px; margin-bottom: 12px; }
    .btn-danger { background: #fce4e4; color: #b71c1c; border: 1.5px solid #ef9a9a; }
    .btn-danger:hover { background: #ffcdd2; }

    /* ── My List sections ─────────────────────────────────────────────────── */
    .mylist-section-title {
      font-size: 13px; font-weight: 800; text-transform: uppercase;
      letter-spacing: .08em; color: var(--muted);
      padding-bottom: 12px; border-bottom: 2px solid var(--border);
      margin-bottom: 16px; display: flex; align-items: center; justify-content: space-between;
    }
    .mylist-section-count {
      font-size: 12px; font-weight: 700; color: var(--sub);
      background: var(--bg); border: 1px solid var(--border);
      padding: 2px 9px; border-radius: 10px; text-transform: none;
    }
    .mylist-empty-small {
      padding: 18px 16px; color: var(--muted); font-size: 14px;
      background: var(--bg); border-radius: 12px; margin-bottom: 8px;
    }
    .kanji-saved-grid {
      display: grid;
      grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
      gap: 12px; margin-bottom: 8px;
    }
    .kanji-saved-chip {
      background: var(--card); border: 1px solid var(--border);
      border-radius: 12px; padding: 14px 12px 12px;
      display: flex; flex-direction: column; align-items: center;
      gap: 6px; text-align: center; position: relative;
      cursor: pointer; user-select: none;
      transition: border-color .15s, box-shadow .15s;
    }
    .kanji-saved-chip:hover  { border-color: var(--red); }
    .kanji-saved-chip.selected {
      border-color: var(--red); box-shadow: 0 0 0 2px rgba(220,53,69,.25);
      background: #fff5f5;
    }
    .kanji-chip-check {
      position: absolute; top: 7px; right: 9px;
      width: 22px; height: 22px; border-radius: 50%;
      border: 1.5px solid var(--border); background: #fff;
      display: flex; align-items: center; justify-content: center;
      font-size: 11px; color: transparent;
      transition: background .15s, border-color .15s, color .15s;
      cursor: pointer; z-index: 2;
      padding: 4px;
    }
    .kanji-saved-chip:hover .kanji-chip-check { border-color: var(--red); }
    .kanji-saved-chip.selected .kanji-chip-check {
      background: var(--red); border-color: var(--red); color: #fff;
    }
    /* In select mode: check icons always visible and pulsing slightly */
    .mylist-section.select-mode .kanji-chip-check,
    .mylist-section.select-mode .ml-check-icon {
      border-color: var(--red); color: rgba(220,53,69,.25);
      cursor: grab;
    }
    .kanji-saved-char    { font-size: 52px; font-weight: 900; line-height: 1; color: #111; }
    .kanji-saved-meaning { font-size: 11px; color: var(--sub); line-height: 1.4; }
    .kanji-saved-remove {
      position: absolute; top: 6px; right: 8px;
      background: none; border: none; font-size: 12px;
      color: var(--muted); cursor: pointer; padding: 2px; line-height: 1;
    }
    .kanji-saved-remove:hover { color: var(--red); }

    /* ── My List word row selection ────────────────────────────────────── */
    #mylistBody tr { cursor: pointer; transition: background .12s; }
    #mylistBody tr:hover { background: var(--bg); }
    #mylistBody tr.selected td,
    #mylistBody tr.selected:hover td { background: rgba(220,53,69,.08) !important; }
    #mylistBody tr.selected td:first-child { border-left: 3px solid var(--red); }
    .ml-check-icon {
      display: inline-flex; align-items: center; justify-content: center;
      width: 18px; height: 18px; border-radius: 50%;
      border: 1.5px solid var(--border); background: #fff;
      font-size: 11px; font-weight: 700; color: transparent;
      transition: background .15s, border-color .15s, color .15s;
    }
    #mylistBody tr:hover .ml-check-icon { border-color: var(--red); }
    #mylistBody tr.selected .ml-check-icon {
      background: var(--red); border-color: var(--red); color: #fff;
    }

    /* ── Select-all toolbar ───────────────────────────────────────────────── */
    .ml-select-toolbar {
      display: flex; gap: 8px; margin-bottom: 16px; align-items: center;
    }
    /* Long-press hint: only shown on touch devices */
    .ml-longpress-hint {
      display: none;
      font-size: 11px; color: var(--muted); font-weight: 500; margin-left: 4px;
    }
    @media (pointer: coarse) {
      .ml-longpress-hint { display: inline; }
    }

    /* ── Paywall soft warning ────────────────────────────────────────────── */
    .paywall-hint {
      background: #fff8e1; border: 1.5px solid #ffe082;
      border-radius: 12px; padding: 14px 18px; margin-bottom: 18px;
      font-size: 14px; color: #5d4037; line-height: 1.5;
      display: flex; flex-direction: column; align-items: flex-start;
    }
    .paywall-hint--full {
      background: #fce4e4; border-color: #ef9a9a; color: #b71c1c;
    }
    @media (prefers-color-scheme: dark) {
      .paywall-hint      { background: #2a220a; border-color: #7a6020; color: #ffd54f; }
      .paywall-hint--full{ background: #2a0808; border-color: #7a1c1c; color: #ff8a80; }
    }

    /* ── Delete bar ─────────────────────────────────────────────────────── */
    .ml-delete-bar {
      position: sticky; bottom: 16px;
      display: flex; align-items: center; gap: 12px;
      background: #fff; border: 1.5px solid var(--red);
      border-radius: 12px; padding: 10px 18px;
      box-shadow: 0 4px 20px rgba(0,0,0,.15);
      margin-top: 24px;
      opacity: 0; pointer-events: none;
      transform: translateY(8px);
      transition: opacity .2s, transform .2s;
    }
    .ml-delete-bar.visible {
      opacity: 1; pointer-events: auto; transform: translateY(0);
    }
    .ml-delete-bar span { font-size: 14px; font-weight: 600; color: var(--text); flex: 1; }
    /* Long-press hint: faint label on kanji chips and word rows in select mode */
    @media (pointer: coarse) {
      .kanji-saved-chip::after {
        content: 'hold'; position: absolute; bottom: 5px; left: 50%; transform: translateX(-50%);
        font-size: 9px; color: var(--muted); opacity: 0;
        transition: opacity .2s; pointer-events: none;
      }
      .mylist-section:not(:has(.kanji-saved-chip.selected, #mylistBody tr.selected)) .kanji-saved-chip:hover::after { opacity: 1; }
    }

    /* ── SRS rating buttons ─────────────────────────────────────────────── */
    .srs-rating-wrap {
      display: flex; gap: 10px; justify-content: center;
      flex-wrap: wrap; margin-top: 14px;
    }
    .srs-btn {
      padding: 10px 18px; border: none; border-radius: 8px;
      font-size: 13px; font-weight: 700; cursor: pointer;
      font-family: inherit; transition: transform .1s, opacity .15s;
      display: flex; flex-direction: column; align-items: center; gap: 2px;
    }
    .srs-btn:active { transform: scale(.96); }
    .srs-btn-again { background: #fce4e4; color: #b71c1c; }
    .srs-btn-hard  { background: #fff3e0; color: #e65100; }
    .srs-btn-good  { background: #e8f5e9; color: #2e7d32; }
    .srs-btn-easy  { background: #e3f2fd; color: #0d47a1; }
    .srs-interval  { font-size: 10px; font-weight: 400; opacity: .75; }
    .btn-review { background: #f3e5f5; color: #4a148c; border: 1.5px solid #ce93d8; }
    .btn-review:hover { background: #e1bee7; }
    .btn-review .review-count {
      display: inline-block; background: #4a148c; color: #fff;
      font-size: 10px; font-weight: 800; border-radius: 10px;
      padding: 1px 6px; margin-left: 6px; vertical-align: middle;
    }

    /* ── Cloud sync / Auth ──────────────────────────────────────────────── */
    .auth-wrap   { display: flex; align-items: center; }
    .auth-btn    {
      padding: 7px 16px; border: none; border-radius: 8px;
      font-size: 12px; font-weight: 700; cursor: pointer;
      font-family: inherit; transition: background .18s;
      white-space: nowrap;
    }
    .auth-btn-in  { background: rgba(255,255,255,.18); color: #fff; }
    .auth-btn-in:hover { background: rgba(255,255,255,.3); }
    .auth-btn-out { background: rgba(255,255,255,.1); color: rgba(255,255,255,.7); font-size: 11px; padding: 4px 10px; }
    .auth-btn-out:hover { background: rgba(255,255,255,.2); }
    .auth-user   { display: flex; align-items: center; gap: 8px; }
    .auth-avatar {
      width: 28px; height: 28px; border-radius: 50%;
      border: 2px solid rgba(255,255,255,.5); object-fit: cover;
      flex-shrink: 0;
    }
    .auth-avatar-fallback {
      display: inline-flex; align-items: center; justify-content: center;
      background: rgba(255,255,255,.25); font-size: 13px; font-weight: 800; color: #fff;
    }
    .auth-name   { font-size: 13px; font-weight: 700; color: rgba(255,255,255,.9); }
    .auth-syncing { font-size: 11px; color: rgba(255,255,255,.6); margin-left: 4px; }

    /* ════════════════════════════════════════════════════════════════
       📱 MOBILE — max-width: 640px
       ════════════════════════════════════════════════════════════════ */
    @media (max-width: 640px) {

      /* ── Header ── */
      header {
        padding: 12px 14px;
        gap: 8px;
        grid-template-columns: 1fr auto 1fr;
      }
      /* Hide gear on mobile, show hamburger */
      #settingsBtn { display: none; }
      .h-hamburger-wrap { display: block; position: relative; }
      .mobile-menu {
        position: absolute; top: calc(100% + 6px); right: 0;
        background: #fff; color: #333;
        border: 1px solid var(--border); border-radius: 10px;
        box-shadow: 0 4px 20px rgba(0,0,0,.18);
        z-index: 600; min-width: 160px; padding: 6px;
      }
      .mobile-menu-item {
        display: block; width: 100%; padding: 13px 16px;
        text-align: left; background: none; border: none;
        font-size: 15px; cursor: pointer; border-radius: 7px;
        color: #333; touch-action: manipulation;
        -webkit-tap-highlight-color: rgba(0,0,0,0);
      }
      .mobile-menu-item:active { background: var(--bg); }
      .h-title { font-size: 17px; letter-spacing: 2px; }
      .h-sub   { display: none; }
      .h-greet { display: none; }
      .h-date  { font-size: 10px; }
      .auth-name { display: none; }
      .auth-btn-in { padding: 6px 12px; font-size: 11px; }
      .auth-wrap { margin-left: 0; }

      /* ── Bottom tab bar (fixed) ── */
      .tabbar {
        position: fixed;
        bottom: 0; left: 0; right: 0;
        top: unset;
        margin: 0;
        padding: 0;        padding-bottom: env(safe-area-inset-bottom);        gap: 0;
        display: grid;
        grid-template-columns: repeat(5, 1fr);
        background: #fff;
        border-top: 1px solid var(--border);
        box-shadow: 0 -2px 12px rgba(0,0,0,.1);
        z-index: 200;
      }
      .tab {
        border-radius: 0;
        padding: 10px 2px 8px;
        font-size: 20px;
        letter-spacing: 0;
        line-height: 1.3;
      }
      .tab.active {
        border-top: 3px solid var(--red);
        background: #fff;
        color: var(--red);
      }

      /* Push content above bottom nav */
      .grid, .stats-section, .mylist-section, .home-section { margin-bottom: calc(72px + env(safe-area-inset-bottom)); }

      /* Push Crisp bubble above bottom nav — targets the container in our own DOM */
      #crisp-chatbox { bottom: 72px !important; }
      .home-actions { grid-template-columns: 1fr 1fr; }
      .home-action-card { padding: 16px 10px; }
      footer { padding-bottom: calc(80px + env(safe-area-inset-bottom) + 16px); }

      /* ── Toolbar ── */
      .toolbar {
        margin-top: 12px;
        padding: 0 12px;
        gap: 8px;
      }
      .btn {
        padding: 11px 14px;
        font-size: 12px;
        min-height: 44px;
      }
      #statusMsg { margin-left: 0; width: 100%; text-align: center; }

      /* ── Level filter ── */
      .level-filter { padding: 4px 12px 8px; gap: 6px; }
      .toolbar-info { display: none; }
      .search-wrap  { padding: 0 12px 8px; }
      .legend { padding: 0 12px; gap: 8px; }

      /* ── Grid ── */
      .grid {
        padding: 0 12px;
        grid-template-columns: 1fr;
        gap: 12px;
        margin-top: 12px;
      }

      /* ── Cards ── */
      .card {
        padding: 16px 14px 14px;
        border-radius: 12px;
      }
      .vocab-word { font-size: 38px; }
      .card-meaning { font-size: 15px; }
      .kanji-char { font-size: 58px; width: 66px; min-width: 66px; }

      /* ── Quiz interactive ── */
      .quiz-options {
        grid-template-columns: 1fr;
        gap: 10px;
      }
      .quiz-option {
        padding: 16px 14px;
        font-size: 14px;
        min-height: 52px;
      }
      .quiz-prompt-word { font-size: 54px; }
      .quiz-question-card { padding: 20px 14px 16px; border-radius: 12px; }
      .quiz-screen { padding: 6px 0 48px; }

      /* ── My List ── */
      .mylist-section { padding: 0 12px; }
      .mylist-toolbar {
        position: sticky;
        top: 52px; /* below fixed tabbar (bottom nav doesn’t apply here, but header does) */
        z-index: 8;
        background: var(--bg);
        padding: 8px 0 10px;
        margin-bottom: 8px;
        border-bottom: 1px solid var(--border);
      }
      .mylist-table { font-size: 13px; }
      .mylist-table th,
      .mylist-table td { padding: 9px 10px; }
      .mylist-word  { font-size: 17px; }
      .mylist-kana  { font-size: 11px; }
      .btn-danger   { padding: 5px 8px !important; font-size: 10px !important; }
      .mylist-search { max-width: 100%; min-width: 0; flex: 1; }
      /* Larger tap target for kanji chip select ✓ on touch screens */
      .kanji-chip-check {
        width: 36px; height: 36px;
        top: 0; right: 0;
        border-radius: 0 12px 0 12px;
        padding: 10px;
        font-size: 13px;
      }
      /* Delete bar: clear the fixed bottom tabbar */
      .ml-delete-bar { bottom: calc(72px + env(safe-area-inset-bottom)); }

      /* ── Stats ── */
      .stats-section { padding: 0 12px; }
      .kpi-grid { grid-template-columns: 1fr 1fr 1fr; gap: 10px; }
      .kpi-wotd { grid-column: 3; grid-row: 1 / span 2; }
      .kpi-num  { font-size: 38px; }
      .kpi-card { padding: 16px 10px 12px; border-radius: 12px; }
      .kpi-lbl  { font-size: 12px; }
      .chart-block { padding: 14px 12px 10px; }
      .qh-date { min-width: 70px; font-size: 11px; }
      .qh-score { min-width: 70px; font-size: 12px; }

      /* ── Home hero mobile ── */
      .home-hero { padding: 24px 18px 20px; }
      .home-hero-kana { font-size: 38px; }
      .home-hero-title { font-size: 20px; }
      .home-hero-actions { flex-direction: column; }
      .home-hero-actions .btn { width: 100%; text-align: center; }
    }

    /* ════════════════════════════════════════════════════════════════
       🏠 HOME HERO — concept banner + CTA
       ════════════════════════════════════════════════════════════════ */
    .home-hero {
      background: linear-gradient(135deg, var(--red) 0%, var(--red-dark) 100%);
      border-radius: 16px;
      padding: 32px 28px 28px;
      color: #fff;
      position: relative;
      overflow: hidden;
    }
    .home-hero::before {
      content: '漢字';
      position: absolute; right: -10px; top: -14px;
      font-size: 120px; font-weight: 900; opacity: .07;
      line-height: 1; pointer-events: none; user-select: none;
    }
    .home-hero-kana {
      font-size: 48px; font-weight: 900; letter-spacing: 3px;
      line-height: 1; margin-bottom: 8px;
    }
    .home-hero-title {
      font-size: 22px; font-weight: 700; line-height: 1.3;
      margin-bottom: 6px;
    }
    .home-hero-sub {
      font-size: 13px; opacity: .75; line-height: 1.6;
      margin-bottom: 20px; max-width: 440px;
    }
    .home-hero-actions {
      display: flex; gap: 10px; flex-wrap: wrap;
    }
    .home-hero-actions .btn-white {
      background: #fff; color: var(--red);
      border: none; font-weight: 800;
      padding: 10px 22px; border-radius: 8px;
      font-size: 14px; cursor: pointer; font-family: inherit;
      transition: opacity .15s, transform .12s;
    }
    .home-hero-actions .btn-white:hover  { opacity: .9; transform: translateY(-1px); }
    .home-hero-actions .btn-outline {
      background: rgba(255,255,255,.15); color: #fff;
      border: 1.5px solid rgba(255,255,255,.4); font-weight: 700;
      padding: 10px 22px; border-radius: 8px;
      font-size: 14px; cursor: pointer; font-family: inherit;
      transition: background .15s;
    }
    .home-hero-actions .btn-outline:hover { background: rgba(255,255,255,.25); }

    /* ════════════════════════════════════════════════════════════════
       🎓 TUTORIAL OVERLAY
       ════════════════════════════════════════════════════════════════ */
    .tutorial-overlay {
      position: fixed; inset: 0;
      background: rgba(0,0,0,.6);
      backdrop-filter: blur(3px);
      z-index: 1000;
      display: flex; align-items: center; justify-content: center;
      padding: 24px;
    }
    .tutorial-card {
      background: #fff;
      border-radius: 20px;
      padding: 36px 32px 28px;
      max-width: 440px; width: 100%;
      box-shadow: 0 16px 60px rgba(0,0,0,.3);
      position: relative;
      text-align: center;
      animation: rise .3s ease;
    }
    .tutorial-close {
      position: absolute; top: 14px; right: 16px;
      background: none; border: none; cursor: pointer;
      font-size: 18px; color: var(--muted); line-height: 1;
      padding: 4px 6px;
      transition: color .15s;
    }
    .tutorial-close:hover { color: var(--text); }
    .tutorial-icon {
      font-size: 52px; line-height: 1; margin-bottom: 14px;
      display:flex; align-items:center; justify-content:center;
    }
    .tutorial-title {
      font-size: 22px; font-weight: 900; color: var(--text);
      line-height: 1.3; margin-bottom: 12px;
    }
    .tutorial-body {
      font-size: 14px; color: var(--sub); line-height: 1.7;
      margin-bottom: 24px;
    }
    .tutorial-dots {
      display: flex; justify-content: center; gap: 7px;
      margin-bottom: 20px;
    }
    .tutorial-dot {
      width: 8px; height: 8px; border-radius: 50%;
      background: var(--border); transition: background .2s, transform .2s;
    }
    .tutorial-dot.active {
      background: var(--red); transform: scale(1.25);
    }
    .tutorial-nav {
      display: flex; gap: 10px; justify-content: center;
    }
    .tutorial-nav .btn { min-width: 110px; }

    /* ════════════════════════════════════════════════════════════════
       🔍 KANJI DETAIL POPUP
       ════════════════════════════════════════════════════════════════ */
    .kanji-detail-backdrop {
      position: fixed; inset: 0;
      background: rgba(0,0,0,.55);
      backdrop-filter: blur(4px);
      z-index: 800;
      display: flex; align-items: center; justify-content: center;
      padding: 20px;
      animation: fadeIn .2s ease;
    }
    @keyframes fadeIn { from { opacity: 0 } to { opacity: 1 } }
    .kanji-detail-modal {
      background: var(--card);
      border-radius: 16px;
      padding: 28px 26px 22px;
      max-width: 480px; width: 100%;
      max-height: 85vh; overflow-y: auto;
      box-shadow: 0 16px 60px rgba(0,0,0,.35);
      position: relative;
      animation: rise .25s ease;
    }
    .kanji-detail-close {
      position: absolute; top: 12px; right: 14px;
      background: none; border: none; cursor: pointer;
      font-size: 20px; color: var(--muted); padding: 4px 6px;
      transition: color .15s;
    }
    .kanji-detail-close:hover { color: var(--text); }
    .kanji-detail-loading {
      text-align: center; padding: 40px 20px;
      color: var(--muted); font-size: 14px;
    }
    @media (max-width: 640px) {
      .tutorial-card { padding: 28px 20px 22px; }
      .tutorial-icon { font-size: 42px; }
      .tutorial-title { font-size: 19px; }
      .kanji-detail-modal { padding: 22px 16px 18px; max-height: 90vh; }
    }

    /* ════════════════════════════════════════════════════════════════
       ✨ UPGRADE MODAL + CARD
       ════════════════════════════════════════════════════════════════ */
    .upgrade-modal-backdrop {
      position: fixed; inset: 0;
      background: rgba(0,0,0,.55);
      backdrop-filter: blur(4px);
      z-index: 900;
      display: flex; align-items: center; justify-content: center;
      padding: 20px;
      animation: fadeIn .2s ease;
    }
    .upgrade-modal {
      background: var(--card);
      border-radius: 20px;
      padding: 32px 28px 28px;
      max-width: 400px; width: 100%;
      box-shadow: 0 16px 60px rgba(0,0,0,.35);
      position: relative;
      animation: rise .25s ease;
    }
    .upgrade-modal-context {
      background: rgba(220,53,69,.08); border-left: 3px solid var(--red);
      padding: 10px 14px; border-radius: 0 8px 8px 0;
      font-size: 14px; margin-bottom: 18px;
    }
    .upgrade-modal-title {
      font-size: 22px; font-weight: 900; margin-bottom: 16px; color: var(--text);
    }
    .upgrade-modal-features {
      list-style: none; padding: 0; margin: 0 0 18px;
      display: flex; flex-direction: column; gap: 8px;
    }
    .upgrade-modal-features li { font-size: 15px; color: var(--sub); }
    .upgrade-modal-price {
      font-size: 28px; font-weight: 900; color: var(--red); margin-bottom: 20px;
    }
    .upgrade-modal-price span { font-size: 13px; font-weight: 400; color: var(--muted); }
    .upgrade-modal-cta {
      display: block; text-align: center; text-decoration: none;
      padding: 14px 24px; font-size: 16px; font-weight: 700;
      border-radius: 12px;
    }
    .upgrade-modal-note {
      font-size: 11px; color: var(--muted); text-align: center; margin-top: 10px;
    }
    .upgrade-modal-signin { font-size: 14px; color: var(--sub); text-align: center; }

    /* Upgrade card on Home */
    .upgrade-card {
      background: linear-gradient(135deg, #fff5f5, #fff);
      border: 1.5px solid rgba(220,53,69,.25);
      border-radius: 16px; padding: 20px 22px;
      display: flex; align-items: center; gap: 16px;
      margin-top: 28px;
    }
    .upgrade-card-left { flex: 1; }
    .upgrade-card-title { font-size: 16px; font-weight: 800; margin-bottom: 4px; }
    .upgrade-card-desc  { font-size: 13px; color: var(--sub); margin-bottom: 6px; }
    .upgrade-card-price { font-size: 18px; font-weight: 900; color: var(--red); }
    .upgrade-card-price span { font-size: 12px; font-weight: 400; color: var(--muted); }
    .upgrade-card-btn {
      background: var(--red); color: #fff; border: none;
      padding: 10px 18px; border-radius: 12px; font-size: 14px; font-weight: 700;
      cursor: pointer; white-space: nowrap; transition: opacity .15s;
    }
    .upgrade-card-btn:hover { opacity: .85; }
    @media (prefers-color-scheme: dark) {
      .upgrade-card { background: linear-gradient(135deg, #1a0808, #1a1a1a); }
    }
    @media (max-width: 640px) {
      .upgrade-card { flex-direction: column; align-items: flex-start; }
      .upgrade-modal { padding: 24px 18px 22px; }
    }

    /* ── Theme pill toggle ────────────────────────────────────────────────── */
    .theme-toggle-group {
      display: flex; gap: 0; border: 1.5px solid var(--border);
      border-radius: 10px; overflow: hidden;
    }
    .theme-btn {
      background: var(--card); color: var(--sub);
      border: none; border-right: 1px solid var(--border);
      padding: 6px 14px; font-size: 14px; cursor: pointer;
      font-family: inherit; transition: background .15s, color .15s;
      line-height: 1.4;
    }
    .theme-btn:last-child { border-right: none; }
    .theme-btn:hover { background: var(--border); }
    .theme-btn.active { background: var(--red); color: #fff; }

    /* ── Dark theme override (manual toggle) ────────────────────────────── */
    html[data-theme="dark"] {
      color-scheme: dark;
      --bg:      #0f0e0c;
      --card:    #1c1a17;
      --border:  #2e2a24;
      --text:    #e8e0d5;
      --ink:     #e8e0d5;
      --sub:     #a09080;
      --muted:   #6a5a50;
      --skel:    #2a2520;
    }
    html[data-theme="dark"] .kanji-char,
    html[data-theme="dark"] .kanji-saved-char,
    html[data-theme="dark"] .quiz-prompt-word,
    html[data-theme="dark"] .ex-word,
    html[data-theme="dark"] .card-meaning,
    html[data-theme="dark"] .vocab-word,
    html[data-theme="dark"] .quiz-prompt-meaning { color: var(--text); }
    html[data-theme="dark"] .vocab-reading { color: #c4956a; }
    html[data-theme="dark"] #settingsPage { background: var(--card); }
    html[data-theme="dark"] .settings-page-body { background: var(--card); }
    html[data-theme="dark"] .settings-section-title { color: var(--muted); }
    html[data-theme="dark"] .settings-label { color: var(--text); }
    html[data-theme="dark"] .settings-row { border-color: var(--border); }
    html[data-theme="dark"] .settings-save-row { border-color: var(--border); }
    html[data-theme="dark"] .theme-btn { background: var(--card); color: var(--text); border-color: var(--border); }
    html[data-theme="dark"] .theme-btn:hover { background: #252220; }
    html[data-theme="dark"] .theme-btn.active { background: var(--red); color: #fff; border-color: var(--red); }
    html[data-theme="dark"] #langSelect { background: var(--card); color: var(--text); border-color: var(--border); }
    html[data-theme="dark"] .mobile-menu { background: var(--card); color: var(--text); border-color: var(--border); }
    html[data-theme="dark"] .mobile-menu-item { color: var(--text); }
    html[data-theme="dark"] .mobile-menu-item:active { background: #252220; }
    html[data-theme="dark"] .mylist-table tr:hover td { background: #252220; }
    html[data-theme="dark"] .mylist-search { background: var(--card); color: var(--text); border-color: var(--border); }
    html[data-theme="dark"] .quiz-option { background: var(--card); color: var(--text); border-color: var(--border); }
    html[data-theme="dark"] .quiz-option:hover:not(:disabled) { background: #252220; }
    html[data-theme="dark"] .ml-delete-bar { background: var(--card); }
    html[data-theme="dark"] .pill { background: var(--card); }
    html[data-theme="dark"] .pill:hover { background: #252220; }
    html[data-theme="dark"] .btn-ghost { background: var(--card); border-color: var(--border); }
    html[data-theme="dark"] .btn-ghost:hover { background: #252220; }
    html[data-theme="dark"] .search-input { background: var(--card); color: var(--text); }
    html[data-theme="dark"] .upgrade-card { background: linear-gradient(135deg, #1a0808, #1c1a17); }
    html[data-theme="dark"] .paywall-hint { background: #2a220a; border-color: #7a6020; color: #ffd54f; }
    html[data-theme="dark"] .paywall-hint--full { background: #2a0808; border-color: #7a1c1c; color: #ff8a80; }
    html[data-theme="dark"] .reading-kana { color: #c4956a; }
    html[data-theme="dark"] .kanji-detail-modal { background: var(--card); }
    html[data-theme="dark"] .quiz-tomorrow { background: #1a1410; border-color: #3e2a1a; }

