@import url('https://fonts.googleapis.com/css2?family=Fraunces:opsz,wght@9..144,400;9..144,600;9..144,700&family=Inter:wght@400;500;600;700&family=JetBrains+Mono:wght@400;500&display=swap');

  :root {
    --paper: #FFF5F9;
    --card: #FFFFFF;
    --card-alt: #FDE6F1;
    --ink: #4A1942;
    --muted: #AD7CA3;
    --line: #F7D3E6;
    --line2: #F3B9DA;
    --forest: #DB2777;
    --sage: #F472B6;
    --leafc: #C026D3;
    --gold: #FBBF24;
    --seedc: #F3A8C7;
    --danger-bg: #FDECEC;
    --danger-fg: #DC2626;
    --danger-line: #F6C6C6;
    --success-bg: #E8F8EE;
    --success-fg: #16A34A;
    --success-line: #BEE8CC;
  }

  * { box-sizing: border-box; }
  html, body { height: 100%; }
  body {
    margin: 0;
    font-family: 'Inter', sans-serif;
    background: var(--paper);
    color: var(--ink);
  }
  code {
    background: #FBE0EE;
    padding: 1px 5px;
    border-radius: 4px;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.9em;
  }
  button { font-family: inherit; }
  button:focus-visible, input:focus-visible, textarea:focus-visible, .flashcard:focus-visible {
    outline: 2px solid var(--forest);
    outline-offset: 2px;
  }
  @media (prefers-reduced-motion: reduce) {
    * { transition: none !important; animation: none !important; }
  }

  .wrap { max-width: 880px; margin: 0 auto; padding: 28px 20px 60px; }

  .vg-header-row { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
  .vg-logo { font-size: 26px; }
  .vg-title {
    font-family: 'Fraunces', serif;
    font-weight: 700;
    font-size: 32px;
    letter-spacing: -0.01em;
    margin: 0;
    color: var(--forest);
  }
  .vg-subtitle { margin: 6px 0 0 36px; color: var(--muted); font-size: 14.5px; }

  .save-badge {
    display: inline-flex; align-items: center; gap: 5px; font-size: 12px; color: var(--muted);
    margin-left: auto; padding: 4px 10px; border-radius: 20px; background: transparent;
    transition: background 0.2s, color 0.2s;
  }
  .save-badge.saving { color: var(--sage); }
  .save-badge.saved { color: var(--success-fg); background: var(--success-bg); }
  .save-badge.error { color: var(--danger-fg); background: var(--danger-bg); }

  .streak-badge {
    display: inline-flex; align-items: center; gap: 5px; font-size: 12px; font-weight: 600; color: #A9740A;
    padding: 4px 10px; border-radius: 20px; background: rgba(251,191,36,0.16);
  }

  .quick-review-btn {
    display: inline-flex; align-items: center; gap: 5px; font-size: 12px; font-weight: 600; color: var(--forest);
    padding: 4px 10px; border-radius: 20px; background: color-mix(in srgb, var(--forest) 14%, transparent);
    border: none; cursor: pointer; transition: background 0.2s, color 0.2s;
  }
  .quick-review-btn:hover { background: var(--forest); color: var(--paper); }

  .vg-warning-banner {
    background: var(--danger-bg);
    border: 1px solid var(--danger-line);
    color: #7A4A1F;
    font-size: 13px;
    padding: 8px 12px;
    border-radius: 8px;
    margin: 16px 0;
  }

  nav.vg-tabs {
    display: flex;
    gap: 6px;
    border-bottom: 1px solid var(--line);
    margin-bottom: 22px;
    flex-wrap: wrap;
  }
  .vg-tab-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 10px 14px;
    font-size: 14.5px;
    font-weight: 600;
    background: transparent;
    border: none;
    border-bottom: 2px solid transparent;
    color: var(--muted);
    cursor: pointer;
    margin-bottom: -1px;
  }
  .vg-tab-btn.active { color: var(--forest); border-bottom-color: var(--forest); }

  .unit-toolbar { display: flex; align-items: center; gap: 8px; margin: -10px 0 20px; flex-wrap: wrap; }
  .unit-toolbar-label { font-size: 13px; color: var(--muted); font-weight: 600; display: flex; align-items: center; gap: 5px; }
  .unit-select {
    font-family: inherit; font-size: 13px; padding: 6px 10px; border-radius: 8px; border: 1px solid var(--line2);
    background: var(--card); color: var(--ink); cursor: pointer;
  }

  .section-heading {
    font-family: 'Fraunces', serif;
    font-size: 18px;
    font-weight: 600;
    color: var(--forest);
    margin: 0 0 12px;
  }

  .btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    border-radius: 8px;
    padding: 10px 16px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    border: none;
  }
  .btn:disabled { opacity: 0.45; cursor: not-allowed; }
  .btn-primary { background: var(--forest); color: var(--paper); }
  .btn-ghost { background: transparent; color: var(--forest); border: 1px solid var(--line2); padding: 7px 12px; font-size: 13.5px; }
  .btn-ghost-icon { background: transparent; color: var(--forest); border: 1px solid var(--line2); padding: 8px; border-radius: 8px; cursor: pointer; display: inline-flex; }
  .btn-danger { background: var(--danger-bg); color: var(--danger-fg); border: 1px solid var(--danger-line); }
  .btn-success { background: var(--success-bg); color: var(--success-fg); border: 1px solid var(--success-line); }

  .empty-state {
    border: 1px dashed var(--line2);
    border-radius: 14px;
    padding: 36px 20px;
    text-align: center;
    color: var(--muted);
    font-size: 14.5px;
  }

  /* ---- Add tab ---- */
  .add-box { background: var(--card-alt); border-radius: 14px; padding: 18px; margin-bottom: 24px; }
  .add-label { font-size: 13.5px; font-weight: 600; color: var(--forest); display: block; margin-bottom: 8px; }
  .add-unit-row { display: flex; gap: 8px; margin-bottom: 10px; flex-wrap: wrap; }
  .add-unit-input {
    flex: 1; min-width: 200px; font-size: 13.5px; padding: 9px 12px; border-radius: 8px; border: 1px solid var(--line2);
    background: #FDFBF4; color: var(--ink);
  }
  .add-unit-select {
    font-size: 13px; padding: 9px 10px; border-radius: 8px; border: 1px solid var(--line2);
    background: #FDFBF4; color: var(--ink); max-width: 220px;
  }
  .add-textarea {
    width: 100%; resize: vertical; font-family: 'JetBrains Mono', monospace; font-size: 13.5px;
    padding: 10px 12px; border-radius: 8px; border: 1px solid var(--line2); background: #FDFBF4;
    color: var(--ink); min-height: 150px;
  }
  .add-hint { font-size: 12.5px; color: var(--muted); margin: 8px 0 12px; line-height: 1.7; }
  .add-error { color: var(--danger-fg); font-size: 13px; margin-bottom: 10px; }

  .word-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
  .unit-group { margin-bottom: 20px; }
  .unit-group-header { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
  .unit-group-title { font-size: 13.5px; font-weight: 700; color: var(--forest); display: flex; align-items: center; gap: 5px; }
  .unit-group-count { color: var(--muted); font-weight: 400; }
  .unit-group-delete {
    margin-left: auto; display: inline-flex; align-items: center; gap: 4px; background: none; border: none;
    color: var(--danger-fg); font-size: 11.5px; cursor: pointer; padding: 3px 6px;
  }
  .word-item { display: flex; align-items: center; gap: 12px; background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 10px 14px; }
  .word-item .stage-icon { flex-shrink: 0; }
  .word-main { flex: 1; min-width: 0; }
  .word-title { font-weight: 600; font-size: 15px; }
  .word-type { color: var(--muted); font-weight: 400; font-style: italic; }
  .word-meaning { color: var(--muted); font-weight: 400; }
  .word-example { font-size: 12.5px; color: var(--muted); font-style: italic; margin-top: 2px; }
  .word-extra { font-size: 11.5px; color: #A98C55; margin-top: 3px; display: flex; flex-wrap: wrap; gap: 10px; }
  .word-delete { background: none; border: none; cursor: pointer; color: var(--danger-fg); padding: 6px; display: inline-flex; }

  /* ---- Flashcard ---- */
  .fc-wrap { display: flex; flex-direction: column; align-items: center; }
  .fc-counter { font-size: 13px; color: var(--muted); margin-bottom: 10px; }
  .flashcard {
    width: 100%; max-width: 520px; min-height: 320px; border-radius: 18px; border: 1px solid var(--line);
    background: var(--card); box-shadow: 0 4px 18px rgba(47,74,60,0.08);
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px;
    padding: 32px; cursor: pointer; position: relative;
  }
  .flashcard.flipped { background: var(--card-alt); }
  .fc-stage-badge { position: absolute; top: 14px; right: 14px; display: flex; align-items: center; gap: 4px; font-size: 11.5px; font-weight: 600; }
  .fc-word { font-family: 'Fraunces', serif; font-size: 40px; font-weight: 700; color: var(--forest); text-align: center; }
  .fc-word small { font-size: 16px; font-weight: 400; color: var(--muted); font-style: italic; }
  .fc-hint { font-size: 12.5px; color: var(--muted); }
  .fc-meaning { font-size: 26px; font-weight: 600; color: var(--forest); text-align: center; }
  .fc-example { font-size: 13.5px; color: var(--muted); font-style: italic; text-align: center; max-width: 380px; }
  .fc-extra { font-size: 12px; color: #A98C55; text-align: center; max-width: 380px; line-height: 1.6; margin-top: 4px; }
  .fc-controls { display: flex; gap: 10px; margin-top: 18px; flex-wrap: wrap; justify-content: center; }
  .fc-attempt-row { width: 100%; max-width: 360px; display: flex; flex-direction: column; align-items: center; gap: 10px; cursor: default; }
  .fc-attempt-input { width: 100%; text-align: center; cursor: text; }
  .fc-attempt-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; justify-content: center; }
  .fc-attempt-recap { font-size: 13px; color: var(--forest); text-align: center; max-width: 380px; margin-bottom: 2px; }
  .fc-attempt-recap-empty { color: var(--muted); font-style: italic; }

  /* ---- Fill blank ---- */
  .fill-card { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 22px; }
  .fill-sentence { font-size: 17px; line-height: 1.6; margin-bottom: 4px; }
  .fill-hint { font-size: 13px; color: var(--muted); margin-bottom: 16px; }
  .fill-row { display: flex; gap: 8px; }
  .fill-input {
    flex: 1; padding: 10px 12px; border-radius: 8px; border: 1px solid var(--line2); font-size: 15px;
    font-family: 'JetBrains Mono', monospace;
  }
  .fill-input.correct { border-color: var(--success-fg); }
  .fill-input.wrong { border-color: var(--danger-fg); }
  .fill-feedback { font-weight: 600; margin-top: 12px; display: flex; align-items: center; gap: 4px; }
  .fill-feedback.correct { color: var(--success-fg); }
  .fill-feedback.wrong { color: var(--danger-fg); }

  .result-banner {
    background: var(--card-alt); border: 1px solid var(--line); border-radius: 12px; padding: 14px 18px;
    margin-bottom: 16px; display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  }
  .result-banner .grow { margin-left: auto; }

  /* Match game */
  .match-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 10px; }
  .match-tile {
    min-height: 84px; border-radius: 10px; border: 1px solid var(--line); background: var(--card); color: var(--ink);
    font-weight: 400; font-size: 13px; cursor: pointer; padding: 10px; display: flex; align-items: center;
    justify-content: center; text-align: center; transition: background 0.15s;
  }
  .match-tile.word { font-size: 15px; }
  .match-tile.flipped { background: var(--card-alt); font-weight: 600; }
  .match-tile.matched { background: var(--success-bg); border-color: var(--success-line); color: var(--success-fg); cursor: default; }

  /* Quiz game */
  .quiz-card { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 22px; max-width: 480px; }
  .quiz-word { font-family: 'Fraunces', serif; font-size: 26px; font-weight: 700; color: var(--forest); margin-bottom: 4px; }
  .quiz-prompt { font-size: 13px; color: var(--muted); margin-bottom: 16px; }
  .quiz-options { display: flex; flex-direction: column; gap: 8px; }
  .quiz-option {
    text-align: left; padding: 10px 14px; border-radius: 8px; border: 1px solid var(--line); background: var(--card);
    color: var(--ink); font-size: 14.5px; font-weight: 500; cursor: pointer;
  }
  .quiz-option.correct { background: var(--success-bg); border-color: var(--success-line); color: var(--success-fg); font-weight: 600; }
  .quiz-option.wrong { background: var(--danger-bg); border-color: var(--danger-line); color: var(--danger-fg); }
  .quiz-option:disabled { cursor: default; }

  /* Nghe & Chọn (Babadum-style) */
  .bbd-word-card { display: flex; flex-direction: column; align-items: center; gap: 6px; margin-bottom: 20px; }
  .bbd-speak {
    width: 56px; height: 56px; border-radius: 50%; border: none; cursor: pointer;
    background: linear-gradient(135deg, #14B8A6, #22D3EE); color: #fff; display: flex; align-items: center; justify-content: center;
    box-shadow: 0 6px 16px rgba(20,184,166,0.35); transition: transform 0.15s ease;
  }
  .bbd-speak:hover { transform: scale(1.06); }
  .bbd-speak:active { transform: scale(0.94); }
  .bbd-word { font-family: 'Fraunces', serif; font-size: 30px; font-weight: 700; color: var(--forest); margin-top: 6px; }
  .bbd-hint { font-size: 12.5px; color: var(--muted); }
  .bbd-tile-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; max-width: 480px; margin: 0 auto; }
  .bbd-tile {
    background: color-mix(in srgb, var(--tile-color, #FDE68A) 55%, white); border: none; border-radius: 16px;
    padding: 24px 14px; min-height: 88px; font-size: 15px; font-weight: 700; color: #4A1942; cursor: pointer;
    display: flex; align-items: center; justify-content: center; text-align: center; line-height: 1.4;
    box-shadow: 0 4px 0 color-mix(in srgb, var(--tile-color, #FDE68A) 85%, #000 15%);
    transition: transform 0.1s ease, box-shadow 0.1s ease;
  }
  .bbd-tile:hover:not(:disabled) { transform: translateY(-2px); }
  .bbd-tile:active:not(:disabled) { transform: translateY(2px); box-shadow: 0 1px 0 color-mix(in srgb, var(--tile-color, #FDE68A) 85%, #000 15%); }
  .bbd-tile.correct { background: var(--success-bg); color: var(--success-fg); box-shadow: 0 4px 0 var(--success-line); }
  .bbd-tile.wrong { background: var(--danger-bg); color: var(--danger-fg); box-shadow: 0 4px 0 var(--danger-line); }
  .bbd-tile:disabled { cursor: default; }
  @media (max-width: 420px) {
    .bbd-tile-grid { grid-template-columns: 1fr; }
  }

  /* Scramble game */
  .scramble-card { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 22px; max-width: 480px; }
  .scramble-meaning { font-size: 15px; margin-bottom: 4px; }
  .scramble-type { font-size: 12.5px; color: var(--muted); margin-bottom: 16px; }
  .tile-row { display: flex; flex-wrap: wrap; gap: 6px; }
  .answer-slots {
    min-height: 46px; padding: 8px; border-radius: 8px; border: 1px dashed var(--line2); background: var(--paper);
    margin-bottom: 14px;
  }
  .answer-hint { font-size: 12.5px; color: #B4AA8C; }
  .letter-tile {
    width: 34px; height: 34px; min-width: 40px; min-height: 44px; border-radius: 7px; font-weight: 700; font-size: 16px; cursor: pointer;
    text-transform: lowercase; border: 1px solid var(--line);
  }
  .letter-tile.pool { background: var(--card-alt); color: var(--ink); }
  .letter-tile.built { background: var(--success-bg); border-color: var(--success-line); color: var(--forest); }
  .scramble-actions { display: flex; gap: 8px; align-items: center; margin-top: 16px; flex-wrap: wrap; }
  .scramble-fb { font-weight: 600; display: flex; align-items: center; gap: 4px; }
  .scramble-fb.correct { color: var(--success-fg); }
  .scramble-fb.wrong { color: var(--danger-fg); }

  /* True/false game */
  .tf-card { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 22px; text-align: center; max-width: 480px; }
  .tf-word { font-family: 'Fraunces', serif; font-size: 26px; font-weight: 700; color: var(--forest); }
  .tf-lead { font-size: 12.5px; color: var(--muted); margin: 6px 0 14px; }
  .tf-meaning { font-size: 18px; font-weight: 600; margin-bottom: 18px; }
  .tf-actions { display: flex; gap: 10px; justify-content: center; }
  .tf-feedback { font-weight: 600; }
  .tf-feedback.correct { color: var(--success-fg); }
  .tf-feedback.wrong { color: var(--danger-fg); }

  /* Footer */
  footer.vg-footer {
    margin-top: 36px; padding-top: 18px; border-top: 1px solid var(--line); display: flex; flex-wrap: wrap;
    gap: 18px; align-items: center; font-size: 13.5px; color: var(--muted);
  }
  footer.vg-footer strong { color: var(--forest); }
  .footer-stage { display: flex; align-items: center; gap: 4px; }
  .footer-bloom { margin-left: auto; display: flex; align-items: center; gap: 4px; }

  .spin { animation: vgspin 1s linear infinite; }
  @keyframes vgspin { to { transform: rotate(360deg); } }

  /* Falling words game */
  .falling-container {
    position: relative; height: 170px; overflow: hidden; border-radius: 10px 10px 0 0;
    background: linear-gradient(180deg, #FFFFFF 0%, var(--card-alt) 100%);
    border: 1px solid var(--line); border-bottom: 2px dashed var(--line2); margin-bottom: 14px;
  }
  .falling-word {
    position: absolute; left: 50%; top: 0; transform: translateX(-50%);
    font-size: 17px; font-weight: 600; color: var(--forest); background: var(--card);
    padding: 7px 16px; border-radius: 20px; white-space: nowrap; box-shadow: 0 2px 8px rgba(47,74,60,0.08);
    animation-name: vgFall; animation-timing-function: linear; animation-fill-mode: forwards;
  }
  @keyframes vgFall { from { top: 4px; } to { top: 92%; } }
  .falling-row { display: flex; gap: 8px; }
  .falling-input {
    flex: 1; padding: 12px 14px; border-radius: 8px; border: 1px solid var(--line2); font-size: 16px;
    font-family: 'JetBrains Mono', monospace;
  }
  .falling-input.shake { animation: vgshake 0.3s; border-color: var(--danger-fg); }
  @keyframes vgshake { 0%, 100% { transform: translateX(0); } 25% { transform: translateX(-6px); } 75% { transform: translateX(6px); } }

  /* Flash recall game */
  .flash-stage { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 30px 22px; text-align: center; max-width: 480px; }
  .flash-word { font-family: 'Fraunces', serif; font-size: 30px; font-weight: 700; color: var(--forest); }
  .flash-caption { font-size: 12.5px; color: var(--muted); margin-top: 8px; }
  .flash-timerbar-track { height: 4px; background: var(--line); border-radius: 2px; margin-top: 16px; overflow: hidden; }
  .flash-timerbar { height: 100%; background: var(--forest); width: 100%; animation-name: flashShrink; animation-timing-function: linear; animation-fill-mode: forwards; }
  @keyframes flashShrink { from { width: 100%; } to { width: 0%; } }

  /* Speed tap game */
  .tap-card { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 22px; max-width: 480px; }
  .tap-word { font-family: 'Fraunces', serif; font-size: 26px; font-weight: 700; color: var(--forest); margin-bottom: 16px; }
  .tap-options { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
  .tap-option {
    text-align: left; padding: 12px 14px; border-radius: 8px; border: 1px solid var(--line); background: var(--paper);
    color: var(--ink); font-size: 14px; font-weight: 600; cursor: pointer;
  }
  .tap-option:active { background: var(--card-alt); }

  /* ---- Phonetic + speaker ---- */
  .phonetic { font-family: 'JetBrains Mono', monospace; font-size: 0.9em; color: var(--seedc); }
  .speak-btn {
    display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0;
    width: 30px; height: 30px; border-radius: 50%; border: 1px solid var(--line2);
    background: var(--card); color: var(--forest); cursor: pointer; padding: 0; vertical-align: middle;
    transition: background 0.15s, transform 0.1s;
  }
  .speak-btn:hover { background: var(--card-alt); }
  .speak-btn:active { transform: scale(0.92); }
  .speak-btn.speaking { background: var(--forest); color: var(--paper); border-color: var(--forest); }
  .speak-btn.sm { width: 24px; height: 24px; }
  .word-phonetic-row { display: flex; align-items: center; gap: 7px; margin-top: 3px; }

  /* ---- Dashboard ---- */
  .dash-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 22px; }
  .stat-card { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 16px 18px; }
  .stat-card.accent { background: var(--forest); border-color: var(--forest); }
  .stat-card.accent .stat-value, .stat-card.accent .stat-label { color: var(--paper); }
  .stat-card.accent .stat-sub { color: #FBD3EA; }
  .stat-value { font-family: 'Fraunces', serif; font-size: 30px; font-weight: 700; color: var(--forest); line-height: 1; }
  .stat-label { font-size: 12.5px; color: var(--muted); font-weight: 600; margin-top: 6px; }
  .stat-sub { font-size: 11.5px; color: var(--seedc); margin-top: 3px; }
  .dash-panel { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 18px 20px; margin-bottom: 18px; }
  .dash-panel-title { font-family: 'Fraunces', serif; font-size: 16px; font-weight: 600; color: var(--forest); margin: 0 0 14px; display: flex; align-items: center; gap: 7px; }
  .stage-bar-row { display: flex; align-items: center; gap: 10px; margin-bottom: 9px; font-size: 13px; }
  .stage-bar-name { width: 44px; display: flex; align-items: center; gap: 4px; flex-shrink: 0; color: var(--muted); }
  .stage-bar-track { flex: 1; height: 12px; background: var(--paper); border-radius: 6px; overflow: hidden; border: 1px solid var(--line); }
  .stage-bar-fill { height: 100%; border-radius: 6px; transition: width 0.5s ease; }
  .stage-bar-num { width: 30px; text-align: right; font-weight: 600; color: var(--ink); flex-shrink: 0; }
  .growth-track { display: flex; height: 16px; border-radius: 9px; overflow: hidden; background: var(--paper); border: 1px solid var(--line); margin-bottom: 16px; }
  .growth-seg { transition: width .6s ease; }
  .growth-ring-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(84px, 1fr)); gap: 10px; text-align: center; }
  .growth-ring-card { background: var(--paper); border: 1px solid var(--line); border-radius: 14px; padding: 12px 6px 10px; display: flex; flex-direction: column; align-items: center; gap: 2px; }
  .growth-ring-ico { width: 26px; height: 26px; border-radius: 50%; background: var(--card); border: 1px solid var(--line); display: flex; align-items: center; justify-content: center; margin-bottom: 4px; }
  .growth-ring-label { font-size: 12px; font-weight: 700; color: var(--forest); margin-top: 2px; }
  .growth-ring-num { font-size: 11px; color: var(--muted); }
  .unit-progress-row { margin-bottom: 12px; }
  .unit-progress-head { display: flex; align-items: center; gap: 8px; font-size: 13px; margin-bottom: 5px; }
  .unit-progress-head strong { color: var(--forest); }
  .unit-progress-pct { margin-left: auto; color: var(--muted); font-size: 12px; }
  .unit-progress-track { height: 8px; background: var(--paper); border-radius: 5px; overflow: hidden; border: 1px solid var(--line); }
  .unit-progress-fill { height: 100%; background: linear-gradient(90deg, var(--sage), var(--gold)); border-radius: 5px; transition: width 0.5s; }
  .weak-chip { display: inline-flex; align-items: center; gap: 6px; background: var(--paper); border: 1px solid var(--line); border-radius: 20px; padding: 5px 12px 5px 10px; font-size: 13px; margin: 0 6px 6px 0; }
  .weak-chip .stg { display: inline-flex; }
  .tips-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 12px; }
  .tip-item { display: flex; gap: 11px; }
  .tip-ico { flex-shrink: 0; width: 30px; height: 30px; border-radius: 8px; background: var(--card-alt); display: flex; align-items: center; justify-content: center; }
  .tip-body-title { font-weight: 600; font-size: 13.5px; color: var(--forest); }
  .tip-body-desc { font-size: 12.5px; color: var(--muted); line-height: 1.55; margin-top: 2px; }
  .streak-flame { font-size: 30px; }
  .ai-plan-box { background: var(--card-alt); border-radius: 10px; padding: 14px 16px; font-size: 13.5px; line-height: 1.65; color: var(--ink); white-space: pre-wrap; margin-top: 12px; }
  .study-plan-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 10px; margin-top: 14px; }
  .study-plan-day { background: var(--paper); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; }
  .study-plan-day-title { font-weight: 700; font-size: 12.5px; color: var(--forest); margin-bottom: 7px; }
  .study-plan-task { display: flex; align-items: flex-start; gap: 6px; font-size: 12px; margin-bottom: 7px; cursor: pointer; line-height: 1.45; }
  .study-plan-task.done { color: var(--muted); text-decoration: line-through; }

  /* ---- Grammar (AI) tab ---- */
  .ai-config { background: var(--card-alt); border-radius: 14px; padding: 18px; margin-bottom: 20px; }
  .ai-config-label { font-size: 13.5px; font-weight: 600; color: var(--forest); display: block; margin-bottom: 10px; }
  .chip-row { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
  .choice-chip {
    padding: 8px 14px; border-radius: 20px; border: 1px solid var(--line2); background: var(--card);
    color: var(--ink); font-size: 13px; font-weight: 600; cursor: pointer;
  }
  .choice-chip.active { background: var(--forest); color: var(--paper); border-color: var(--forest); }
  .ai-unavailable { background: var(--danger-bg); border: 1px solid var(--danger-line); color: #7A4A1F; font-size: 13px; padding: 12px 14px; border-radius: 10px; line-height: 1.6; }
  .gq-card { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 20px; margin-bottom: 14px; }
  .gq-num { font-size: 12px; color: var(--muted); font-weight: 600; margin-bottom: 6px; }
  .gq-prompt { font-size: 15.5px; line-height: 1.6; margin-bottom: 14px; }
  .gq-prompt .blank { color: var(--forest); font-weight: 700; font-family: 'JetBrains Mono', monospace; }
  .gq-focus-tag { display: inline-block; font-size: 11px; font-weight: 600; color: var(--sage); background: var(--success-bg); border-radius: 12px; padding: 2px 9px; margin-bottom: 10px; }
  .gq-options { display: flex; flex-direction: column; gap: 8px; }
  .gq-option {
    text-align: left; padding: 10px 14px; border-radius: 8px; border: 1px solid var(--line); background: var(--card);
    color: var(--ink); font-size: 14px; font-weight: 500; cursor: pointer;
  }
  .gq-option.correct { background: var(--success-bg); border-color: var(--success-line); color: var(--success-fg); font-weight: 600; }
  .gq-option.wrong { background: var(--danger-bg); border-color: var(--danger-line); color: var(--danger-fg); }
  .gq-option:disabled { cursor: default; }
  .gq-explain { margin-top: 12px; font-size: 13px; line-height: 1.6; color: var(--muted); background: var(--paper); border-left: 3px solid var(--sage); border-radius: 0 8px 8px 0; padding: 10px 14px; }
  .gq-explain strong { color: var(--forest); }
  .ai-loading { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 14px; padding: 30px 0; justify-content: center; }
  /* D3: gợi ý "vừa sai ở Writing" - tông cảnh báo nhẹ dùng --gold (đã dùng cho trophy/thành
     tích), không dùng đỏ error vì đây là gợi ý tích cực chứ không phải lỗi. */
  .grammar-weak-banner {
    display: flex; flex-wrap: wrap; align-items: center; gap: 8px 10px;
    background: var(--card-alt); border: 1px solid var(--gold); border-radius: 12px;
    padding: 12px 14px; margin-bottom: 16px; font-size: 13px; color: var(--ink); line-height: 1.5;
  }
  .grammar-weak-banner .chip-row { margin: 4px 0 0; }
  .grammar-weak-chip { border-color: var(--gold); color: #8A6A0F; }
  .grammar-weak-chip:hover { background: var(--gold); color: var(--ink); }

  /* D4: bản đồ tiến độ - liệt kê tier hiện tại của 16 chủ điểm GRAMMAR_FOCUS thật, mỗi dòng là
     1 <button> (data-gfocus-suggest) để nhảy thẳng tới luyện chủ điểm đó. */
  .grammar-map-list { display: flex; flex-direction: column; gap: 8px; }
  .grammar-map-row {
    display: flex; align-items: center; gap: 12px; width: 100%; text-align: left;
    background: var(--card-alt); border: 1px solid var(--line2); border-radius: 10px;
    padding: 10px 12px; cursor: pointer; font: inherit; color: inherit;
  }
  .grammar-map-row:hover { border-color: var(--forest); }
  .grammar-map-row.weak { border-color: var(--gold); }
  .grammar-map-label { flex: 0 0 150px; font-size: 13px; color: var(--ink); display: flex; align-items: center; gap: 5px; }
  .grammar-map-track { flex: 1; height: 8px; background: var(--line); border-radius: 5px; overflow: hidden; }
  .grammar-map-fill { height: 100%; background: var(--forest); border-radius: 5px; }
  .grammar-map-tier { flex: 0 0 72px; text-align: right; font-size: 12px; font-weight: 600; color: var(--muted); }
  .grammar-map-legend { font-size: 12px; color: var(--muted); margin-top: 10px; display: flex; align-items: center; gap: 6px; }

  /* ---- Decode phonetic game ---- */
  .decode-card { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 26px 22px; text-align: center; max-width: 480px; }
  .decode-ipa { font-family: 'JetBrains Mono', monospace; font-size: 30px; font-weight: 500; color: var(--forest); letter-spacing: 1px; }
  .decode-hint { font-size: 12.5px; color: var(--muted); margin: 10px 0 4px; }
  .decode-meaning { font-size: 14px; color: var(--seedc); font-style: italic; margin-bottom: 16px; }
  .decode-row { display: flex; gap: 8px; margin-top: 6px; }
  .decode-input { flex: 1; padding: 12px 14px; border-radius: 8px; border: 1px solid var(--line2); font-size: 16px; font-family: 'JetBrains Mono', monospace; text-align: center; }
  .decode-input.shake { animation: vgshake 0.3s; border-color: var(--danger-fg); }
  .decode-input.correct { border-color: var(--success-fg); }
  .decode-input.wrong { border-color: var(--danger-fg); }
  .decode-fb { font-weight: 600; margin-top: 12px; display: flex; align-items: center; gap: 5px; justify-content: center; }
  .decode-fb.correct { color: var(--success-fg); }
  .decode-fb.wrong { color: var(--danger-fg); }
  .big-speak {
    display: inline-flex; align-items: center; gap: 8px; margin: 10px auto 0; padding: 10px 20px;
    border-radius: 22px; border: 1px solid var(--line2); background: var(--card-alt); color: var(--forest);
    font-size: 14px; font-weight: 600; cursor: pointer;
  }
  .big-speak:hover { background: var(--card); }

  /* ---- review-mode flashcard banner ---- */
  .review-banner {
    display: flex; align-items: center; gap: 8px; background: var(--success-bg); border: 1px solid var(--success-line);
    color: var(--success-fg); font-size: 13px; font-weight: 600; padding: 8px 14px; border-radius: 20px; margin-bottom: 14px;
  }

  /* ---- weekly test & level ---- */
  .level-panel { background: linear-gradient(180deg, var(--card) 0%, var(--card-alt) 160%); }
  .level-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 8px; }
  .level-badge {
    display: inline-flex; align-items: center; gap: 6px; font-weight: 700; font-size: 14px;
    border: 1.5px solid var(--forest); border-radius: 20px; padding: 5px 13px; background: var(--paper);
  }
  .level-badge.big { font-size: 15.5px; padding: 7px 16px; margin-top: 12px; }
  .level-sub { font-size: 12px; color: var(--muted); }
  .level-desc { font-size: 13px; color: var(--ink); line-height: 1.55; margin-bottom: 10px; }
  .level-status {
    display: flex; align-items: center; gap: 7px; font-size: 13px; color: var(--forest);
    background: var(--success-bg); border: 1px solid var(--success-line); border-radius: 10px; padding: 8px 12px;
  }
  .level-status.due { background: #FBF3DD; border-color: #E7D49A; color: #8a6d12; }
  .level-lastscore { font-size: 13px; color: var(--ink); margin-top: 10px; }
  .test-trend { margin-top: 12px; display: flex; flex-direction: column; align-items: center; }

  .test-progress-row { display: flex; align-items: center; justify-content: space-between; font-size: 13px; color: var(--muted); font-weight: 600; }
  .test-type-tag { font-size: 11px; font-weight: 600; color: var(--forest); background: var(--card-alt); border-radius: 12px; padding: 3px 10px; }
  .test-track { height: 7px; background: var(--paper); border: 1px solid var(--line); border-radius: 5px; overflow: hidden; margin-top: 8px; }
  .test-track-fill { height: 100%; background: var(--forest); transition: width .25s ease; }
  .test-sub { font-size: 13px; color: var(--muted); margin-bottom: 10px; }
  .test-prompt { margin-bottom: 16px; min-height: 34px; }
  .test-ipa { font-family: 'JetBrains Mono', monospace; font-size: 24px; color: var(--forest); letter-spacing: .5px; }

  .test-result { text-align: center; background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 26px 18px; margin-bottom: 16px; }
  .test-score-ring {
    width: 108px; height: 108px; margin: 0 auto 14px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center; font-family: 'Fraunces', serif; font-size: 32px; font-weight: 700;
    color: var(--forest); background: var(--card-alt); border: 4px solid var(--sage);
  }
  .test-score-line { font-size: 15px; color: var(--ink); }
  .test-delta { font-size: 13px; color: var(--muted); margin-top: 6px; }
  .test-intro-desc { font-size: 13.5px; color: var(--ink); line-height: 1.6; margin: 4px 0 6px; }
  .test-hist-row { display: flex; align-items: center; gap: 10px; font-size: 13px; }
  .test-hist-row > span:first-child { min-width: 78px; color: var(--muted); }
  .test-hist-bar { flex: 1; height: 8px; background: var(--paper); border: 1px solid var(--line); border-radius: 5px; overflow: hidden; }
  .test-hist-bar > span { display: block; height: 100%; background: var(--leafc); }
  .longtest-tag { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; color: var(--forest); background: var(--card-alt); border-radius: 999px; padding: 4px 12px; margin-bottom: 12px; }

  /* ---- small button variant ---- */
  .btn-sm { padding: 7px 13px; font-size: 13px; }

  /* ---- hero (today progress + streak + encouragement) ---- */
  .hero-panel { background: linear-gradient(135deg, var(--card) 0%, var(--card-alt) 130%); }
  .longtest-banner { background: linear-gradient(135deg, var(--card) 0%, var(--card-alt) 130%); border-color: var(--gold); }
  .hero-row { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; }
  .hero-ring { flex-shrink: 0; }
  .hero-main { flex: 1; min-width: 220px; }
  .hero-streak { font-size: 15px; font-weight: 700; color: var(--forest); margin-bottom: 4px; }
  .hero-enc { font-size: 13.5px; color: var(--ink); line-height: 1.5; margin-bottom: 12px; }
  .hero-actions { display: flex; gap: 10px; flex-wrap: wrap; }
  .hero-next {
    display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--muted);
    margin-top: 14px; padding-top: 12px; border-top: 1px dashed var(--line2); flex-wrap: wrap;
  }
  .hero-next-track { flex: 1; min-width: 80px; height: 6px; background: var(--paper); border: 1px solid var(--line); border-radius: 4px; overflow: hidden; }
  .hero-next-track > span { display: block; height: 100%; background: var(--gold); }

  /* ---- focus / pomodoro panel ---- */
  .focus-panel.active { display: flex; align-items: center; gap: 20px; flex-wrap: wrap; background: var(--card-alt); border-color: var(--sage); }
  .focus-clock { flex-shrink: 0; }
  .focus-side { flex: 1; min-width: 200px; }

  /* ---- badges ---- */
  .badge-wrap { display: flex; flex-wrap: wrap; gap: 10px; }
  .badge-chip {
    display: flex; flex-direction: column; align-items: center; gap: 4px; width: 88px;
    padding: 10px 6px; border-radius: 12px; border: 1px solid var(--line); background: var(--paper); text-align: center;
  }
  .badge-chip.locked { opacity: .45; }
  .badge-ico {
    width: 30px; height: 30px; border-radius: 50%; display: flex; align-items: center; justify-content: center;
    background: var(--line2);
  }
  .badge-name { font-size: 11px; font-weight: 600; color: var(--forest); line-height: 1.25; }
  .badge-days { font-size: 10px; color: var(--muted); }

  /* ---- forest (rừng tập trung) ---- */
  .forest-points-row { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
  .forest-points-card {
    display: flex; align-items: center; gap: 12px; background: var(--forest); color: var(--paper);
    border-radius: 14px; padding: 14px 20px; flex: 1; min-width: 220px;
  }
  .forest-points-num { font-family: 'Fraunces', serif; font-size: 28px; font-weight: 700; }
  .forest-points-label { font-size: 12px; color: #FBD3EA; }
  .forest-rule-box { font-size: 12.5px; color: var(--muted); line-height: 1.6; background: var(--card-alt); border-radius: 10px; padding: 12px 14px; margin: 14px 0; }
  .forest-stage {
    background: linear-gradient(180deg, #DFF3D2 0%, #C9E9B4 100%); border-radius: 16px; padding: 14px;
    border: 1px solid var(--line); margin: 16px 0;
  }
  .forest-scene { width: 100%; height: auto; display: block; }
  .forest-chart-head { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 10px; }
  .forest-range-chips { display: flex; gap: 8px; }
  .forest-period-nav { display: flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 600; color: var(--forest); }
  .forest-weekday-row { display: flex; align-items: flex-end; justify-content: space-between; gap: 6px; height: 76px; }
  .forest-weekday-col { display: flex; flex-direction: column; align-items: center; justify-content: flex-end; gap: 6px; flex: 1; height: 100%; }
  .forest-weekday-bar { width: 60%; max-width: 26px; border-radius: 4px 4px 0 0; }
  .forest-weekday-label { font-size: 10.5px; color: var(--muted); }
  .plant-shop-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
  .plant-card {
    background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 14px; text-align: center;
    display: flex; flex-direction: column; align-items: center; gap: 6px; transition: transform .15s ease, box-shadow .15s ease;
  }
  .plant-card:hover { transform: translateY(-3px); box-shadow: 0 8px 18px rgba(0,0,0,.08); }
  .plant-card.locked { opacity: .55; }
  .plant-card.locked:hover { transform: none; box-shadow: none; }
  .plant-emoji { width: 56px; height: 56px; display: block; }
  .plant-name { font-weight: 700; font-size: 13.5px; color: var(--forest); }
  .plant-cost { font-size: 12px; color: var(--seedc); font-weight: 600; }
  @keyframes plantPop { from { transform: translateY(6px) scale(.4); opacity: 0; } to { transform: none; opacity: 1; } }
  .plant-pop { animation: plantPop .5s cubic-bezier(.34,1.56,.64,1); transform-origin: center bottom; transform-box: fill-box; }

  /* ---- API key panel ---- */
  .api-key-row { display: flex; gap: 8px; flex-wrap: wrap; }
  .api-key-input {
    flex: 1; min-width: 220px; font-family: 'JetBrains Mono', monospace; font-size: 13px;
    padding: 9px 12px; border-radius: 8px; border: 1px solid var(--line2); background: var(--paper); color: var(--ink);
  }
  .api-key-input:focus { outline: none; border-color: var(--forest); }

  /* ---- toast (celebration message) ---- */
  #vg-toast {
    position: fixed; left: 50%; bottom: 26px; transform: translateX(-50%) translateY(20px);
    background: var(--forest); color: var(--paper); font-size: 13.5px; font-weight: 600;
    padding: 12px 20px; border-radius: 30px; box-shadow: 0 8px 24px rgba(0,0,0,.18);
    opacity: 0; pointer-events: none; transition: opacity .3s ease, transform .3s ease; z-index: 9999; max-width: 90vw; text-align: center;
  }
  #vg-toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

  /* ---- Vocab tô đen (chủ động: người dùng bấm vào từ muốn tra, web không tự tô đen) ---- */
  .vocab-word { cursor: pointer; border-radius: 4px; padding: 0 2px; border-bottom: 1.5px dotted var(--line2); transition: background .15s ease, border-color .15s ease; }
  .vocab-word:hover { background: var(--card-alt); border-color: var(--forest); }
  .vocab-word.revealed { background: var(--success-bg); color: var(--success-fg); font-weight: 600; cursor: default; border-bottom: none; }
  .vocab-popover { display: inline-flex; align-items: center; gap: 5px; background: var(--card); border: 1px solid var(--line2); border-radius: 20px; padding: 2px 10px 2px 12px; font-size: 12px; margin: 0 3px; vertical-align: middle; color: var(--ink); }
  .vocab-popover.added { color: var(--success-fg); }
  .vp-add { background: none; border: none; color: var(--forest); cursor: pointer; display: inline-flex; align-items: center; padding: 2px; }

  /* ---- Roadmap tab ---- */
  .rm-subnav { display: flex; gap: 6px; margin-bottom: 18px; flex-wrap: wrap; }
  .rm-goal-panel { background: linear-gradient(135deg, var(--forest) 0%, #9333EA 100%); color: var(--paper); border: none; }
  .rm-goal-panel .dash-panel-title { color: var(--paper); }
  .rm-goal-row { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 14px; }
  .rm-goal-chip { display: flex; align-items: center; gap: 10px; background: rgba(255,255,255,0.14); border: 1px solid rgba(255,255,255,0.25); border-radius: 14px; padding: 10px 16px; flex: 1; min-width: 200px; }
  .rm-goal-chip .num { font-family: 'Fraunces', serif; font-size: 22px; font-weight: 700; }
  .rm-goal-chip .lbl { font-size: 11px; opacity: .85; text-transform: uppercase; letter-spacing: .04em; }
  .rm-status-box { background: rgba(255,255,255,0.94); color: var(--ink); border-radius: 14px; padding: 14px 16px; margin-top: 14px; max-width: 340px; }
  .rm-status-box .t { font-weight: 700; color: var(--forest); margin-bottom: 8px; display: flex; align-items: center; gap: 6px; }
  .rm-status-box li { display: flex; align-items: center; gap: 7px; font-size: 13px; margin-bottom: 5px; }
  .rm-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
  .rm-principle-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 12px; }
  .rm-principle-card { background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 16px; cursor: pointer; text-align: center; }
  .rm-principle-card .ic { width: 46px; height: 46px; border-radius: 14px; background: var(--card-alt); display: flex; align-items: center; justify-content: center; margin: 0 auto 10px; }
  .rm-principle-card .ti { font-weight: 700; font-size: 13.5px; color: var(--forest); margin-bottom: 6px; }
  .rm-principle-card .de { font-size: 12px; color: var(--muted); line-height: 1.55; }
  .rm-principle-tip { margin-top: 12px; text-align: left; background: var(--paper); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; font-size: 12px; color: var(--ink); line-height: 1.6; }
  .rm-principle-arrow { margin-top: 8px; color: var(--muted); }
  .rm-tips-panel { background: var(--card-alt); border: 1px solid var(--line2); }
  .rm-stage-list { display: flex; flex-direction: column; gap: 12px; }
  .rm-stage-card { background: var(--card); border: 1px solid var(--line); border-radius: 16px; overflow: hidden; }
  .rm-stage-head { width: 100%; display: flex; align-items: center; justify-content: space-between; padding: 16px 18px; background: transparent; border: none; cursor: pointer; text-align: left; }
  .rm-stage-head.open { background: var(--card-alt); }
  .rm-stage-num { width: 32px; height: 32px; border-radius: 50%; background: var(--forest); color: var(--paper); display: flex; align-items: center; justify-content: center; font-weight: 700; flex-shrink: 0; margin-right: 12px; }
  .rm-stage-name { font-weight: 700; font-size: 15px; color: var(--forest); }
  .rm-stage-dur { display: inline-block; font-size: 11px; font-weight: 600; color: var(--forest); background: var(--card-alt); border-radius: 12px; padding: 2px 10px; margin-top: 5px; }
  .rm-stage-body { padding: 0 18px 18px; }
  .rm-week-chip-row { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0 4px; }
  .rm-week-chip { padding: 6px 12px; border-radius: 10px; font-size: 12.5px; font-weight: 700; border: 1px solid var(--line2); background: var(--paper); color: var(--ink); cursor: pointer; display: inline-flex; align-items: center; gap: 4px; }
  .rm-week-chip.active { background: var(--forest); color: var(--paper); border-color: var(--forest); }
  .rm-week-chip.locked { color: var(--muted); cursor: not-allowed; opacity: .6; }
  .rm-day-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 12px; margin-top: 14px; }
  .rm-day-card { background: var(--paper); border: 1px solid var(--line); border-radius: 14px; padding: 14px 16px; }
  .rm-day-head { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 8px; padding-bottom: 8px; border-bottom: 1px solid var(--line); }
  .rm-day-head-right { display: flex; align-items: center; gap: 6px; }
  .rm-day-edit-btn { background: none; border: none; cursor: pointer; color: var(--muted); padding: 2px; display: inline-flex; border-radius: 5px; }
  .rm-day-edit-btn:hover { color: var(--forest); background: var(--card-alt); }
  .rm-day-custom-tag { font-size: 10px; font-weight: 600; color: var(--forest); background: var(--card-alt); border-radius: 999px; padding: 1px 7px; margin-left: 4px; }
  .rm-day-card-editing { border-color: var(--forest); }
  .rm-day-edit-textarea { width: 100%; border: 1px solid var(--line2); border-radius: 8px; padding: 8px 10px; font-size: 12.5px; font-family: inherit; line-height: 1.6; resize: vertical; }
  .rm-day-edit-hint { font-size: 11px; color: var(--muted); margin: 4px 0 8px; }
  .rm-day-edit-actions { display: flex; gap: 8px; flex-wrap: wrap; }
  .rm-day-name { font-weight: 700; color: var(--forest); font-size: 14px; }
  .rm-day-date { font-size: 12px; color: var(--muted); }
  .rm-task { display: flex; align-items: flex-start; gap: 8px; cursor: pointer; margin-bottom: 8px; font-size: 13px; line-height: 1.5; }
  .rm-task.done { color: var(--muted); text-decoration: line-through; }
  .rm-unlock-box { margin-top: 16px; background: var(--card-alt); border: 1px dashed var(--line2); border-radius: 14px; padding: 16px; text-align: center; }
  .rm-progress-form { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; }
  .rm-progress-form .fld { flex: 1; min-width: 110px; }
  .rm-progress-form label { display: block; font-size: 11.5px; font-weight: 600; color: var(--muted); margin-bottom: 5px; }
  .rm-progress-form input { width: 100%; padding: 9px 11px; border-radius: 8px; border: 1px solid var(--line2); font-size: 13.5px; background: var(--paper); color: var(--ink); }
  .rm-chart-wrap { overflow-x: auto; }
  .rm-legend { display: flex; gap: 14px; justify-content: center; margin-top: 10px; font-size: 12.5px; color: var(--muted); }
  .rm-legend span { display: inline-flex; align-items: center; gap: 6px; }
  .rm-legend i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
  .rm-journal { width: 100%; min-height: 100px; padding: 12px 14px; border-radius: 10px; border: 1px solid var(--line2); background: var(--paper); color: var(--ink); font-family: inherit; font-size: 13.5px; resize: vertical; }

  /* ---- confetti burst ---- */
  .vg-confetti { position: fixed; inset: 0; pointer-events: none; z-index: 9998; overflow: hidden; }
  .vg-confetti i {
    position: absolute; top: -10px; width: 8px; height: 14px; border-radius: 2px;
    animation: vg-fall 1.9s ease-in forwards;
  }
  @keyframes vg-fall {
    0% { transform: translateY(0) rotate(0deg); opacity: 1; }
    100% { transform: translateY(100vh) rotate(360deg); opacity: 0; }
  }

  /* ---- Shared FX layer (confetti burst / shake / pulse) ---- */
  #fx-layer { position: fixed; inset: 0; pointer-events: none; z-index: 9999; overflow: hidden; }
  .fx-bit { position: fixed; font-size: 20px; transform: translate(-50%, -50%); animation: fxBitFly 0.85s ease-out forwards; }
  @keyframes fxBitFly {
    0% { opacity: 1; transform: translate(-50%, -50%) scale(0.6) rotate(0deg); }
    100% { opacity: 0; transform: translate(calc(-50% + var(--dx)), calc(-50% + var(--dy))) scale(1.25) rotate(50deg); }
  }
  .fx-shake { animation: fxShake 0.46s; }
  @keyframes fxShake {
    10%, 90% { transform: translateX(-1px); }
    20%, 80% { transform: translateX(2px); }
    30%, 50%, 70% { transform: translateX(-6px); }
    40%, 60% { transform: translateX(6px); }
  }
  .fx-pulse-good { animation: fxPulseGood 0.52s ease; }
  @keyframes fxPulseGood {
    0% { box-shadow: 0 0 0 0 rgba(219,39,119,0.35); }
    70% { box-shadow: 0 0 0 18px rgba(219,39,119,0); }
    100% { box-shadow: 0 0 0 0 rgba(219,39,119,0); }
  }

  /* ---- Game hub (arcade feel) ---- */
  .game-root { position: relative; }

  .ghub-hero {
    display: flex; align-items: center; justify-content: space-between; gap: 18px; flex-wrap: wrap;
    background: linear-gradient(120deg, #4C1D5C 0%, #9D174D 55%, #C026D3 100%);
    border-radius: 20px; padding: 22px 24px; margin-bottom: 22px; position: relative; overflow: hidden;
    box-shadow: 0 12px 28px rgba(157,23,77,0.25);
  }
  .ghub-hero::after {
    content: ''; position: absolute; inset: 0; pointer-events: none;
    background: radial-gradient(circle at 80% 20%, rgba(255,255,255,0.22), transparent 60%);
  }
  .ghub-hero-text { position: relative; z-index: 1; }
  .ghub-hero-title { font-family: 'Fraunces', serif; font-size: 25px; font-weight: 700; color: #fff; margin: 0; }
  .ghub-hero-sub { font-size: 13px; color: rgba(255,255,255,0.78); margin: 6px 0 0; }

  .ghub-hero-actions { display: flex; align-items: center; gap: 10px; position: relative; z-index: 1; }
  .ghub-sound {
    width: 44px; height: 44px; border-radius: 12px; cursor: pointer; font-size: 19px; line-height: 1;
    display: flex; align-items: center; justify-content: center;
    background: rgba(255,255,255,0.16); border: 1px solid rgba(255,255,255,0.35); color: #fff;
    transition: background 0.18s ease;
  }
  .ghub-sound:hover { background: rgba(255,255,255,0.26); }
  .ghub-quick:focus-visible, .ghub-sound:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }

  .ghub-quick {
    display: flex; align-items: center; gap: 10px; padding: 12px 18px; border-radius: 14px; cursor: pointer; position: relative; z-index: 1;
    background: rgba(255,255,255,0.16); border: 1px solid rgba(255,255,255,0.35); color: #fff;
    backdrop-filter: blur(6px);
    transition: background 0.18s ease, transform 0.18s ease;
  }
  .ghub-quick-icon { font-size: 22px; }
  .ghub-quick-text { display: flex; flex-direction: column; align-items: flex-start; line-height: 1.3; }
  .ghub-quick-text strong { font-size: 14.5px; }
  .ghub-quick-text small { font-size: 11.5px; color: rgba(255,255,255,0.75); }
  .ghub-quick:hover:not(:disabled) { background: rgba(255,255,255,0.26); transform: translateY(-2px); }
  .ghub-quick:disabled { opacity: 0.5; cursor: not-allowed; }

  .ghub-group { margin-bottom: 26px; }
  .ghub-group-title {
    display: flex; align-items: center; gap: 8px; font-size: 12.5px; font-weight: 700; letter-spacing: 0.04em;
    text-transform: uppercase; color: var(--muted); margin: 0 0 12px;
  }
  .ghub-rule { flex: 1; height: 1px; background: var(--line); display: block; }

  .game-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 14px; }
  .game-card {
    text-align: left; background: #fff; background: linear-gradient(165deg, color-mix(in srgb, var(--accent) 11%, #fff) 0%, #fff 62%);
    border: 1px solid var(--line); border-color: color-mix(in srgb, var(--accent) 26%, var(--line)); border-radius: 18px; padding: 16px;
    cursor: pointer; display: flex; flex-direction: column; gap: 9px; position: relative; overflow: hidden;
    transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
  }
  @keyframes gameCardIn { from { opacity: 0; transform: translateY(10px) scale(0.97); } to { opacity: 1; transform: translateY(0) scale(1); } }
  .game-grid.ghub-animate .game-card { animation: gameCardIn 0.4s ease backwards; animation-delay: calc(var(--i, 0) * 0.05s); }
  .game-card::before {
    content: ''; position: absolute; inset: 0; background: var(--accent, var(--forest)); opacity: 0;
    transition: opacity 0.18s ease;
  }
  .game-card::after {
    content: ''; position: absolute; top: 0; left: 0; right: 0; height: 3px;
    background: linear-gradient(90deg, var(--accent), transparent);
  }
  .game-card:hover:not(:disabled) {
    transform: translateY(-5px); border-color: var(--accent);
    box-shadow: 0 8px 20px rgba(219,39,119,0.18); box-shadow: 0 14px 30px color-mix(in srgb, var(--accent) 30%, transparent);
  }
  .game-card:hover:not(:disabled)::before { opacity: 0.06; }
  .game-card:active:not(:disabled) { transform: translateY(-1px) scale(0.99); }
  .game-card:disabled { opacity: 0.5; filter: grayscale(0.55); cursor: not-allowed; }
  .game-card > * { position: relative; z-index: 1; }

  .game-card-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; }
  .game-card-icon {
    width: 44px; height: 44px; border-radius: 14px; display: flex; align-items: center; justify-content: center; font-size: 22px;
    background: var(--accent); background: linear-gradient(135deg, var(--accent), color-mix(in srgb, var(--accent) 45%, #fff));
    box-shadow: 0 6px 14px rgba(0,0,0,0.12); box-shadow: 0 6px 14px color-mix(in srgb, var(--accent) 32%, transparent);
  }
  .game-card:hover:not(:disabled) .game-card-icon { animation: gameIconBounce 0.5s ease; }
  @keyframes gameIconBounce { 0%, 100% { transform: translateY(0) rotate(0); } 30% { transform: translateY(-4px) rotate(-8deg); } 60% { transform: translateY(0) rotate(6deg); } }
  .game-card-tags { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; }
  .game-tag {
    font-size: 10px; font-weight: 600; padding: 2px 7px; border-radius: 999px; white-space: nowrap;
    background: var(--card-alt); color: var(--forest);
    background: color-mix(in srgb, var(--accent) 14%, #fff); color: color-mix(in srgb, var(--accent) 75%, #000);
  }
  .game-card-title { font-size: 15.5px; font-weight: 700; color: var(--ink); }
  .game-card-desc { font-size: 12.5px; color: var(--muted); line-height: 1.5; min-height: 3em; }
  .game-card-foot { margin-top: auto; padding-top: 10px; border-top: 1px dashed var(--line); font-size: 11.5px; display: flex; align-items: center; gap: 5px; }
  .game-card-record { color: var(--gold); display: flex; align-items: center; gap: 5px; }
  .game-card-locked { color: var(--danger-fg); display: flex; align-items: center; gap: 5px; }
  .game-card-fresh { color: var(--muted); }

  .game-active-header { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; flex-wrap: wrap; }
  .game-active-badge {
    width: 36px; height: 36px; border-radius: 12px; display: flex; align-items: center; justify-content: center; font-size: 19px;
    background: var(--accent); background: linear-gradient(135deg, var(--accent), color-mix(in srgb, var(--accent) 45%, #fff));
  }
  .game-active-title { font-family: 'Fraunces', serif; font-weight: 700; font-size: 19px; color: var(--accent, var(--forest)); }
  .game-back-btn { margin-left: auto; }
  .game-stage { animation: gameStageIn 0.25s ease; }
  @keyframes gameStageIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }

  @media (max-width: 460px) {
    .ghub-hero { flex-direction: column; align-items: stretch; padding: 18px; }
    .ghub-quick { justify-content: center; }
    .ghub-hero-actions { justify-content: center; }
    .game-grid { grid-template-columns: 1fr; }
  }

  /* ---- Khung chung màn chơi (HUD + kết ván) ---- */
  .g-hud { display:flex; align-items:center; gap:16px; flex-wrap:wrap; margin-bottom:10px; }
  .g-stat { display:flex; flex-direction:column; line-height:1.15; }
  .g-stat b { font-size:18px; font-weight:700; color:var(--ink); font-variant-numeric:tabular-nums; }
  .g-stat small { font-size:10.5px; font-weight:600; letter-spacing:0.04em; text-transform:uppercase; color:var(--muted); }
  .g-stat.is-hot b { color:var(--forest); animation: gStatPop .4s ease; }
  .g-stat.is-hot small { color:var(--forest); }
  @keyframes gStatPop { 0%{transform:scale(1);} 45%{transform:scale(1.28);} 100%{transform:scale(1);} }
  .g-lives { margin-left:auto; font-size:15px; letter-spacing:2px; color:var(--danger-fg); }
  .g-timer { margin-left:auto; display:flex; align-items:center; gap:5px; font-weight:700; font-size:15px; color:var(--ink); font-variant-numeric:tabular-nums; }
  .g-timer.low { color:var(--danger-fg); animation: gTimerPulse .9s ease infinite; }
  @keyframes gTimerPulse { 0%,100%{opacity:1;} 50%{opacity:.55;} }
  .g-hud-action { margin-left:auto; }
  .g-progress-track { height:6px; background:var(--line); border-radius:999px; overflow:hidden; margin-bottom:18px; }
  .g-progress-bar { height:100%; border-radius:999px; background:linear-gradient(90deg, var(--forest), var(--leafc)); transition: width .3s ease; }
  .g-progress-bar.smooth { transition: width 1s linear; }
  .g-progress-bar.low { background:var(--danger-fg); }

  .g-result { display:flex; flex-direction:column; align-items:center; text-align:center; gap:6px; padding:30px 22px; max-width:420px; margin:0 auto; background:var(--card); border:1px solid var(--line); border-radius:22px; box-shadow:0 10px 30px rgba(219,39,119,0.12); animation: gResultIn .45s cubic-bezier(.2,.8,.3,1.1); }
  @keyframes gResultIn { from { opacity:0; transform:translateY(14px) scale(.94);} to { opacity:1; transform:none; } }
  .g-result-ring { width:110px; height:110px; border-radius:50%; display:flex; align-items:baseline; justify-content:center; gap:1px; padding-top:34px; margin-bottom:4px; background:linear-gradient(135deg, var(--forest), var(--leafc)); color:#fff; box-shadow:0 8px 22px rgba(219,39,119,0.32); }
  .g-result-score { font-family:'Fraunces', serif; font-size:38px; font-weight:700; line-height:1; }
  .g-result-total { font-size:17px; font-weight:600; opacity:.8; }
  .g-result-unit { font-size:12px; font-weight:600; letter-spacing:.04em; text-transform:uppercase; color:var(--muted); }
  .g-result-badge { display:inline-flex; align-items:center; gap:6px; padding:5px 14px; border-radius:999px; background:linear-gradient(135deg,#FBBF24,#F59E0B); color:#7A4A00; font-size:11.5px; font-weight:800; letter-spacing:.06em; box-shadow:0 4px 12px rgba(251,191,36,.4); animation: gBadgePop .5s .15s ease backwards; }
  @keyframes gBadgePop { from { opacity:0; transform:scale(.5) rotate(-8deg);} to { opacity:1; transform:none; } }
  .g-result-title { font-family:'Fraunces', serif; font-size:21px; font-weight:700; color:var(--forest); margin-top:2px; }
  .g-result-sub { font-size:13px; color:var(--muted); }
  .g-result-record { font-size:12px; color:var(--gold); font-weight:600; }
  .g-result-again { margin-top:12px; }

  .quiz-card, .tf-card, .tap-card, .flash-stage, .decode-card, .scramble-card {
    max-width: 520px; margin-left: auto; margin-right: auto;
    border-radius: 18px; box-shadow: 0 6px 18px rgba(219,39,119,0.07);
  }

  .quiz-option, .tap-option { min-height: 46px; border-radius: 12px; transition: transform .12s ease, background .15s ease, border-color .15s ease; }
  .quiz-option:hover:not(:disabled), .tap-option:hover:not(:disabled) { background: var(--card-alt); border-color: var(--line2); transform: translateY(-1px); }

  @media (max-width: 520px) {
    .g-hud { gap: 12px; }
    .g-stat b { font-size: 16px; }
    .g-result { padding: 24px 18px; }
    .g-result-ring { width: 92px; height: 92px; padding-top: 28px; }
    .g-result-score { font-size: 32px; }
    .tap-options { grid-template-columns: 1fr; }
    .match-grid { grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); }
  }

  /* ---- Flashcard sidebar ---- */
  .fc-layout { display: flex; gap: 22px; align-items: flex-start; width: 100%; max-width: 800px; margin: 0 auto; }
  .fc-main { flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: center; }
  .fc-due-tag { display: inline-block; background: var(--card-alt); color: var(--forest); border-radius: 999px; padding: 1px 8px; font-size: 11px; font-weight: 600; margin-left: 6px; }
  /* E2: badge tier (tái dùng đúng kiểu dáng .fc-due-tag) — .fc-tier-1 "Đã nhớ" dùng màu success,
     .fc-tier-2 "Đã vận dụng" dùng --gold (đồng bộ với .game-card-record/.mistake-due-chip, nơi
     --gold đã là màu quy ước cho thành tích/mức cao nhất). tier 0 không render tag nào (xem JS). */
  .fc-tier-tag { display: inline-block; border-radius: 999px; padding: 1px 8px; font-size: 11px; font-weight: 600; margin-left: 6px; }
  .fc-tier-tag.fc-tier-1 { background: var(--success-bg); color: var(--success-fg); }
  .fc-tier-tag.fc-tier-2 { background: var(--card-alt); color: var(--gold); }
  .fc-sidebar { width: 220px; flex-shrink: 0; background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 16px; display: flex; flex-direction: column; gap: 14px; position: sticky; top: 20px; max-height: calc(100vh - 40px); overflow-y: auto; }
  .fc-sidebar-block + .fc-sidebar-block { border-top: 1px dashed var(--line); padding-top: 12px; }
  .fc-sidebar-title { font-size: 12px; font-weight: 700; color: var(--ink); display: flex; align-items: center; gap: 6px; margin-bottom: 8px; }
  .fc-sidebar-title.good { color: var(--success-fg); }
  .fc-sidebar-title.weak { color: var(--danger-fg); }
  .fc-bloom-bars { display: flex; flex-direction: column; gap: 7px; }
  .fc-bloom-row { display: flex; align-items: center; gap: 6px; }
  .fc-bloom-icon { display: flex; animation: bloomPop 0.6s ease backwards; }
  @keyframes bloomPop { 0% { transform: scale(0.4); opacity: 0.3; } 60% { transform: scale(1.15); } 100% { transform: scale(1); opacity: 1; } }
  .fc-bloom-track { flex: 1; height: 6px; border-radius: 999px; background: var(--card-alt); overflow: hidden; }
  .fc-bloom-fill { height: 100%; border-radius: 999px; transition: width 0.5s ease; }
  .fc-bloom-count { font-size: 11px; color: var(--muted); min-width: 16px; text-align: right; }
  .fc-log-list { display: flex; flex-direction: column; gap: 4px; max-height: 130px; overflow-y: auto; }
  .fc-log-item { font-size: 12.5px; padding: 4px 8px; border-radius: 7px; animation: logIn 0.3s ease; }
  @keyframes logIn { from { opacity: 0; transform: translateX(-6px); } to { opacity: 1; transform: translateX(0); } }
  .fc-log-item.good { background: var(--success-bg); color: var(--success-fg); }
  .fc-log-item.weak { background: var(--danger-bg); color: var(--danger-fg); }
  .fc-log-empty { font-size: 12px; color: var(--muted); font-style: italic; }
  .fc-complete-banner { flex-wrap: nowrap; }
  .fc-complete-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 14px; justify-content: center; }
  .fc-production-card { margin-top: 16px; background: var(--card-alt); border-radius: 14px; padding: 16px 18px; }
  .fc-production-title { display: flex; align-items: center; gap: 6px; font-size: 13.5px; font-weight: 600; color: var(--ink); margin-bottom: 10px; }
  .fc-production-sentence { font-size: 14.5px; line-height: 2.2; color: var(--ink); margin-bottom: 12px; }
  .fc-production-blank { display: inline-block; width: 110px; margin: 0 3px; padding: 3px 6px; border-radius: 6px; border: 1px solid var(--line2); font: inherit; font-size: 14px; text-align: center; }
  .fc-production-blank.correct { border-color: var(--success-fg); background: var(--success-bg); }
  .fc-production-blank.wrong { border-color: var(--danger-fg); background: var(--danger-bg); }
  .fc-production-result { font-size: 13.5px; font-weight: 600; color: var(--forest); margin-bottom: 8px; }
  @media (max-width: 720px) {
    .fc-layout { flex-direction: column; }
    .fc-sidebar { width: 100%; position: static; max-height: none; }
  }

  /* ---- TOEIC Writing tab ---- */
  .writing-intro { font-size: 13.5px; color: var(--muted); max-width: 600px; margin: 0 0 18px; }
  .writing-part-select { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 10px; margin-bottom: 16px; }
  .writing-part-card { text-align: left; background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 14px; cursor: pointer; transition: border-color 0.15s, background 0.15s; }
  .writing-part-card.active { border-color: var(--forest); background: var(--card-alt); }
  .writing-part-num { font-family: 'Fraunces', serif; font-weight: 700; color: var(--forest); font-size: 16px; }
  .writing-part-label { font-size: 13px; font-weight: 600; margin-top: 2px; }
  .writing-part-time { font-size: 11.5px; color: var(--muted); margin-top: 4px; }
  .writing-mode-select { display: flex; gap: 10px; margin-bottom: 18px; flex-wrap: wrap; }
  .writing-mode-btn { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 10px 16px; cursor: pointer; font-size: 13.5px; font-weight: 600; color: var(--ink); }
  .writing-mode-btn small { font-weight: 400; color: var(--muted); font-size: 11px; }
  .writing-mode-btn.active { border-color: var(--forest); background: var(--card-alt); color: var(--forest); }
  .writing-error { color: var(--danger-fg); font-size: 12.5px; margin: 6px 0 12px; display: flex; align-items: center; gap: 5px; }
  .writing-hint { font-size: 12px; color: var(--muted); margin-top: 8px; max-width: 480px; }
  .writing-generate-row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
  .writing-session-head { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; flex-wrap: wrap; }
  .writing-session-title { font-family: 'Fraunces', serif; font-weight: 700; color: var(--forest); font-size: 16px; }
  .writing-timer-row { display: flex; justify-content: flex-end; font-size: 13px; color: var(--muted); margin-bottom: 4px; }
  .writing-timer-track { height: 6px; border-radius: 999px; background: var(--card-alt); overflow: hidden; margin-bottom: 16px; }
  .writing-timer-bar { height: 100%; background: var(--forest); transition: width 1s linear; }
  .writing-timer-bar.low { background: var(--danger-fg); }
  .writing-practice-tag { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; color: var(--muted); background: var(--card-alt); border-radius: 999px; padding: 3px 10px; margin-bottom: 16px; }
  .writing-item { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 16px; margin-bottom: 14px; }
  .writing-item-head { font-size: 12.5px; font-weight: 700; color: var(--forest); margin-bottom: 8px; }
  .writing-scene { font-size: 14.5px; line-height: 1.5; margin-bottom: 10px; font-style: italic; color: var(--ink); }
  .writing-picture { display: block; width: 100%; max-width: 520px; height: auto; object-fit: contain; border-radius: 12px; border: 1px solid var(--line); background: var(--card-alt); margin-bottom: 10px; }
  .writing-picture-sm { max-width: 260px; margin-bottom: 8px; }
  .writing-pic-fallback { font-size: 11.5px; color: var(--muted); display: flex; align-items: center; gap: 5px; margin: -4px 0 10px; }
  .writing-input { width: 100%; padding: 10px 12px; border-radius: 8px; border: 1px solid var(--line2); font-size: 14px; font-family: inherit; }
  .writing-textarea { width: 100%; padding: 10px 12px; border-radius: 8px; border: 1px solid var(--line2); font-size: 13.5px; font-family: inherit; line-height: 1.6; resize: vertical; }
  .writing-essay { min-height: 260px; }
  .writing-wordcount { font-size: 12px; color: var(--muted); margin-top: 6px; text-align: right; }
  .writing-email { background: var(--card-alt); border-radius: 10px; padding: 12px 14px; margin-bottom: 10px; font-size: 13px; }
  .writing-email-meta { color: var(--muted); font-size: 11.5px; margin-bottom: 8px; line-height: 1.5; }
  .writing-email-body { line-height: 1.6; }
  .writing-instructions { font-size: 12.5px; color: #A98C55; background: #FFF8E8; border-radius: 8px; padding: 8px 10px; margin-bottom: 10px; display: flex; gap: 6px; align-items: flex-start; }
  .writing-question { font-size: 15px; line-height: 1.6; margin-bottom: 12px; }
  .writing-submit-btn { margin-top: 4px; }
  .writing-result-item { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 16px; margin-bottom: 14px; }
  .writing-result-head { display: flex; justify-content: space-between; align-items: center; font-weight: 700; color: var(--forest); margin-bottom: 8px; }
  .writing-score-badge { background: var(--card-alt); border-radius: 999px; padding: 2px 12px; font-size: 13px; color: var(--forest); }
  .writing-your-answer { font-size: 13.5px; line-height: 1.6; margin-bottom: 10px; }
  .writing-comment { font-size: 12.5px; line-height: 1.6; color: var(--ink); margin-bottom: 6px; }
  .writing-corrected { font-size: 13px; line-height: 1.6; background: var(--success-bg); color: var(--success-fg); border-radius: 8px; padding: 8px 10px; margin-top: 8px; }
  .writing-result-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 6px; }

  /* ---- Grammar AI: mode toggle + tense trainer ---- */
  .grammar-mode-toggle { display: flex; gap: 8px; margin-bottom: 16px; flex-wrap: wrap; }
  .grammar-mode-btn { display: flex; align-items: center; gap: 6px; background: var(--card); border: 1px solid var(--line); border-radius: 999px; padding: 7px 14px; font-size: 13px; font-weight: 600; color: var(--muted); cursor: pointer; }
  .grammar-mode-btn.active { background: var(--forest); border-color: var(--forest); color: #fff; }
  .tense-ref-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; margin-bottom: 14px; }
  .tense-ref-card { text-align: left; background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; cursor: pointer; }
  .tense-ref-card.active { border-color: var(--forest); background: var(--card-alt); }
  .tense-ref-name { font-size: 12.5px; font-weight: 700; color: var(--forest); }
  .tense-ref-formula { font-size: 11px; color: var(--ink); margin-top: 2px; font-family: 'JetBrains Mono', monospace; }
  .tense-ref-signal { font-size: 10.5px; color: var(--muted); margin-top: 3px; }
  .tense-blank-slot { display: inline-block; min-width: 44px; border-bottom: 2px solid var(--forest); text-align: center; font-weight: 700; color: var(--forest); }
  .tense-answer-row { display: flex; align-items: center; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
  .tense-base-hint { font-size: 12.5px; color: var(--muted); font-style: italic; }
  .tense-input { flex: 1; min-width: 160px; }
  .tense-input.correct { border-color: var(--success-fg); background: var(--success-bg); }
  .tense-input.wrong { border-color: var(--danger-fg); background: var(--danger-bg); }

  /* ===== Sổ lỗi sai ===== */
  .tab-count { display: inline-flex; align-items: center; justify-content: center; min-width: 18px; height: 18px; padding: 0 5px; margin-left: 4px; border-radius: 999px; background: var(--gold); color: var(--paper); font-size: 10.5px; font-weight: 700; }
  .mistake-row { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px; padding: 12px 0; border-bottom: 1px solid var(--line); }
  .mistake-row:last-child { border-bottom: none; }
  .mistake-src-chip { flex: 0 0 100%; font-size: 11.5px; font-weight: 600; color: var(--forest); text-transform: uppercase; letter-spacing: .3px; }
  .mistake-prompt { flex: 1 1 100%; font-size: 14px; color: var(--ink); line-height: 1.5; }
  .mistake-meta { flex: 1 1 auto; font-size: 12px; color: var(--muted); display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
  .mistake-due-chip { display: inline-flex; align-items: center; padding: 2px 8px; border-radius: 999px; background: var(--card-alt); border: 1px solid var(--gold); color: var(--gold); font-size: 10.5px; font-weight: 700; }
  .mistake-actions { display: flex; gap: 4px; margin-left: auto; }

  /* D2 - mức luyện & tier ngữ pháp */
  .grammar-tier-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: -4px 0 14px; }
  .grammar-tier-badge { font-size: 12.5px; color: var(--muted); }
  .grammar-tier-badge b { color: var(--forest); }

  /* A2 - ô thêm từ nhanh (nổi, mọi tab trừ "add") */
  .quick-add-fab {
    position: fixed; right: 20px; bottom: 90px; width: 52px; height: 52px; border-radius: 50%;
    background: var(--forest); color: var(--paper); border: none; box-shadow: 0 8px 22px rgba(0,0,0,.2);
    display: flex; align-items: center; justify-content: center; cursor: pointer; z-index: 500;
    transition: transform .15s ease, background .15s ease;
  }
  .quick-add-fab:hover { background: var(--leafc); transform: scale(1.06); }
  .quick-add-panel {
    position: fixed; right: 20px; bottom: 90px; width: 320px; max-width: calc(100vw - 40px);
    background: var(--paper); border: 1px solid var(--line); border-radius: 14px; padding: 16px;
    box-shadow: 0 10px 30px rgba(0,0,0,.18); z-index: 500;
  }
  .quick-add-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
  .quick-add-title { display: flex; align-items: center; gap: 6px; font-weight: 600; font-size: 13.5px; color: var(--forest); }
  .quick-add-close {
    width: 24px; height: 24px; border-radius: 50%; border: none; background: var(--card-alt); color: var(--muted);
    display: flex; align-items: center; justify-content: center; cursor: pointer; flex-shrink: 0;
  }
  .quick-add-textarea { min-height: 90px; margin-top: 8px; }
  .quick-add-hint { font-size: 12px; color: var(--muted); margin: 8px 0 10px; line-height: 1.5; }
  .quick-add-submit { width: 100%; margin-top: 4px; }
  @media (max-width: 480px) {
    .quick-add-panel { right: 20px; left: 20px; width: auto; max-width: none; }
  }
