/* ══════════════════════════════════════
   Nugget — Nihongo · stylesheet (v10)
   Dark minimalist · Gradient accent
   Fonts: DM Sans (Latin) · BIZ UDGothic (JP)
   Self-hosted, subsetted woff2

   SECTION INDEX
   ─────────────────────────────────────
   §1  FONTS          @font-face
   §2  RESET          *, html
   §3  TOKENS         :root, --vars
   §4  THEME          light mode, dark overrides
   §5  BODY           base typography
   §6  HEADER         top bar, streak badge
   §7  INSTALL        strip + modal
   §8  NAVIGATION     tabs, pills
   §9  BROWSE         filter, search, cards
   §10 QUIZ-SETUP     mode select, level filter
   §11 QUIZ-CARD      flashcard, swipe, options
   §12 QUIZ-RESULT    score ring, stats
   §13 QUIZ-FILL      fill-in-the-blank mode
   §14 QUIZ-REARRANGE rearrange sentence mode
   §15 PROGRESS       SRS panel, legend
   §16 MODALS         confirm, generic overlay
   §17 ANIMATIONS     @keyframes
   §18 UTILITIES      misc helpers
   §19 VOCAB-UI       quiz feedback, detail modal, browse vocab, daily word, mixed quiz (v14)
   §20 BOOK-FILTER    book pill + chapter strip (v14.5)
   §21 BOOK-PROGRESS  SRS progress bar per buku (v14.5)
══════════════════════════════════════ */
/* ══════════════════════════════════════
   §1 FONTS — self-hosted, subsetted
══════════════════════════════════════ */
@font-face {
  font-family: 'DM Sans';
  src: url('../fonts/dm-sans.woff2') format('woff2');
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'BIZ UDGothic';
  src: url('../fonts/biz-udgothic.woff2') format('woff2');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

/* ══════════════════════════════════════
   §2 RESET
══════════════════════════════════════ */

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

/* ══════════════════════════════════════
   §3 TOKENS — design variables
══════════════════════════════════════ */

:root {
  /* Brand gradient */
  --grad: linear-gradient(135deg, #2D6A4F 25%, #3B82C4 100%);
  --grad-end: #3B82C4;

  /* Level colors — vivid on dark */
  --n5: #A78BFA; --n5-dim: rgba(167,139,250,0.12); --n5-border: rgba(167,139,250,0.28);
  --n4: #F87171; --n4-dim: rgba(248,113,113,0.12); --n4-border: rgba(248,113,113,0.28);
  --n3: #60A5FA; --n3-dim: rgba(96,165,250,0.12);  --n3-border: rgba(96,165,250,0.28);
  --n2: #34D399; --n2-dim: rgba(52,211,153,0.12);  --n2-border: rgba(52,211,153,0.28);
  --n1: #FBBF24; --n1-dim: rgba(251,191,36,0.12);  --n1-border: rgba(251,191,36,0.28);

  /* Dark base — slightly lighter */
  --bg:        #0F141B;
  --surface:   #171E2A;
  --surface-2: #1E2738;
  --surface-3: #273044;
  --border:    rgba(255,255,255,0.07);
  --border-2:  rgba(255,255,255,0.16);
  --text:      #EFF3F8;
  --muted:     rgba(239,243,248,0.45);
  --accent:    #3B82C4;
  --gold:      #FBBF24;

  /* Safe area */
  --safe-top:    env(safe-area-inset-top, 0px);

  --safe-bottom: env(safe-area-inset-bottom, 0px);

  /* Shadows */
  --shadow-sm:  0 1px 4px rgba(0,0,0,0.35);
  --shadow-md:  0 4px 16px rgba(0,0,0,0.4), 0 1px 4px rgba(0,0,0,0.25);
  --shadow-lg:  0 8px 32px rgba(0,0,0,0.5);
  --shadow-xl:  0 20px 60px rgba(0,0,0,0.6);
  --shadow-glow: 0 4px 20px rgba(59,130,196,0.25);

  /* Nav height */
  --nav-h: 60px;

  /* Typography scale */
  --text-xs:   0.68rem;
  --text-sm:   0.78rem;
  --text-base: 0.875rem;
  --text-md:   0.95rem;

  /* Accent colors */
  --accent-green : #34D399;
  --accent-red   : #F87171;
  /* Status feedback — dark mode defaults */
  --success-dim  : rgba(52,211,153,0.15);
  --success-text : #34D399;
  --error-dim    : rgba(248,113,113,0.15);
  --error-text   : #F87171;

  /* Component aliases — dark mode */
  --card-bg   : #1C2230;
  --input-bg  : #242C3A;
  --surface-1 : #141920;
  --text-sub  : rgba(239,243,248,0.52);
  --font-jp   : 'BIZ UDGothic', sans-serif;
  --danger-dim: #fee2e2;
  --warn-dim  : #fef3c7;
}

html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; font-size: 16px; }

/* ══════════════════════════════════════
   §4 THEME — light/dark overrides
══════════════════════════════════════ */

/* ── LIGHT MODE ── */
body.light {
  --bg:        #F4F6FA;
  --surface:   #FFFFFF;
  --surface-2: #EEF1F7;
  --surface-3: #E2E6EF;
  --border:    rgba(0,0,0,0.07);
  --border-2:  rgba(0,0,0,0.12);
  --text:      #1A2030;
  --muted:     rgba(26,32,48,0.48);
  /* level colors adjusted for light */
  --n5: #7C3AED; --n5-dim: rgba(124,58,237,0.08); --n5-border: rgba(124,58,237,0.22);
  --n4: #DC2626; --n4-dim: rgba(220,38,38,0.08);  --n4-border: rgba(220,38,38,0.22);
  --n3: #2563EB; --n3-dim: rgba(37,99,235,0.08);  --n3-border: rgba(37,99,235,0.22);
  --n2: #059669; --n2-dim: rgba(5,150,105,0.08);  --n2-border: rgba(5,150,105,0.22);
  --n1: #D97706; --n1-dim: rgba(217,119,6,0.08);  --n1-border: rgba(217,119,6,0.22);
  /* Component aliases — light mode overrides */
  --card-bg   : #FFFFFF;
  --input-bg  : #EEF1F7;
  --surface-1 : #F4F6FA;
  --text-sub  : rgba(26,32,48,0.48);
}

/* Night mode — boost text clarity */
body:not(.light) .card-grammar,
body:not(.light) .card-meaning,
body:not(.light) header h1 {
  text-shadow: 0 0 20px rgba(255,255,255,0.05);
}
body:not(.light) .face {
  background: var(--surface);
  box-shadow: 0 2px 12px rgba(0,0,0,0.35);
}

/* Day/Night toggle button */
.theme-toggle {
  display: flex; align-items: center; justify-content: center;
  width: 36px; height: 36px;
  border: 1px solid var(--border-2);
  border-radius: 50%;
  background: var(--surface-2);
  cursor: pointer; font-size: 1rem;
  transition: all 0.2s;
  -webkit-tap-highlight-color: transparent;
  flex-shrink: 0;
  margin-right: 0.5rem;
  align-self: center;
}
.theme-toggle:active { transform: scale(0.88); }

/* Header top row */
.header-top-row {
  display: flex; align-items: flex-start;
  justify-content: space-between; gap: 1rem;
}

/* ══════════════════════════════════════
   §6 HEADER — top bar, streak badge
══════════════════════════════════════ */

/* Streak badge */
.streak-badge {
  display: flex; flex-direction: column; align-items: center;
  background: rgba(255,255,255,0.12);
  border: 1px solid rgba(255,255,255,0.2);
  border-radius: 12px;
  padding: 0.45rem 0.75rem;
  backdrop-filter: blur(4px);
  min-width: 54px; flex-shrink: 0;
  gap: 0;
}
.streak-fire { font-size: 1.3rem; line-height: 1; }
.streak-num {
  font-family: 'DM Sans', sans-serif;
  font-size: 1.1rem; font-weight: 700;
  color: white; line-height: 1.2;
}
.streak-label {
  font-size: 0.58rem; color: rgba(255,255,255,0.65);
  font-family: 'DM Sans', sans-serif; letter-spacing: 0.05em;
}

/* Swipe visual feedback on quiz card */
.swipe-hint-overlay {
  position: absolute; inset: 0; border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 2.5rem; font-weight: 900;
  pointer-events: none; opacity: 0;
  transition: opacity 0.12s;
  z-index: 10; border: 3px solid transparent;
  border-radius: 12px;
}
.swipe-hint-overlay.show-know   { opacity: 1; background: rgba(52,211,153,0.18); border-color: rgba(52,211,153,0.5); color: #34D399; }
.swipe-hint-overlay.show-unsure { opacity: 1; background: rgba(251,191,36,0.18); border-color: rgba(251,191,36,0.5); color: #FBBF24; }
.swipe-hint-overlay.show-forgot { opacity: 1; background: rgba(248,113,113,0.18); border-color: rgba(248,113,113,0.5); color: #F87171; }

/* Light mode — no text-stroke on pills */
body.light .pill[class*="active"] {
  -webkit-text-stroke: 0 !important;
}

/* Streak hot (7+ days) */
.streak-badge.streak-hot {
  background: rgba(251,191,36,0.18);
  border-color: rgba(251,191,36,0.4);
  animation: streakPulse 2s ease-in-out infinite;
}
@keyframes streakPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(251,191,36,0.3); }
  50%       { box-shadow: 0 0 0 6px rgba(251,191,36,0); }
}

/* Streak broken modal */
.streak-broken-modal {
  text-align: center;
}
.streak-broken-fire {
  font-size: 3.5rem; line-height: 1; margin-bottom: 0.75rem;
  display: inline-block;
  animation: none;
}
.streak-broken-fire.crack {
  animation: fireCrack 0.6s cubic-bezier(0.36, 0.07, 0.19, 0.97);
}
@keyframes fireCrack {
  0%   { transform: scale(1) rotate(0deg); }
  15%  { transform: scale(1.3) rotate(-8deg); }
  30%  { transform: scale(0.85) rotate(6deg); filter: grayscale(0.8); }
  50%  { transform: scale(1.1) rotate(-4deg); filter: grayscale(0.4); }
  70%  { transform: scale(0.9) rotate(2deg); filter: grayscale(1); }
  100% { transform: scale(1) rotate(0deg); filter: grayscale(1) opacity(0.5); }
}
.streak-broken-sub {
  font-size: var(--text-sm); color: var(--muted);
  margin: 0.35rem 0 0.85rem; line-height: 1.6;
}
.streak-tip-box {
  background: var(--surface-2); border: 1px solid var(--border-2);
  border-radius: 10px; padding: 0.75rem 1rem;
  font-size: var(--text-sm); color: var(--text);
  line-height: 1.6; font-style: italic;
  border-left: 3px solid var(--accent);
}


/* ══════════════════════════════════════
   §5 BODY — base typography & layout
══════════════════════════════════════ */

body {
  font-family: 'DM Sans', 'BIZ UDGothic', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  min-height: -webkit-fill-available;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
  line-height: 1.5;
}

/* ══════════════════════════════════════
   §7 INSTALL — strip + install modal
══════════════════════════════════════ */
#installStrip {
  background: var(--surface);
  color: var(--text);
  padding: 0.6rem 1.25rem;
  display: flex; align-items: center;
  justify-content: space-between; gap: 0.75rem;
  font-size: var(--text-xs);
  border-bottom: 1px solid var(--border);
}
#installStrip span { opacity: 0.6; }
.install-strip-btn {
  background: var(--grad);
  color: white; border: none; border-radius: 6px;
  padding: 0.4rem 1rem; font-size: var(--text-xs); font-weight: 700;
  cursor: pointer; font-family: 'DM Sans', sans-serif;
  white-space: nowrap; flex-shrink: 0;
  -webkit-tap-highlight-color: transparent;
}

/* — INSTALL MODAL
══════════════════════════════════════ */
#installOverlay {
  display: none; position: fixed; inset: 0;
  background: rgba(0,0,0,0.7); z-index: 999;
  align-items: flex-end; justify-content: center;
  padding: 1rem;
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
}
#installOverlay.show { display: flex; }
#installModal {
  background: var(--surface); border: 1px solid var(--border-2);
  border-radius: 20px; width: 100%; max-width: 420px;
  padding: 1.5rem; overflow: hidden;
  box-shadow: 0 20px 60px rgba(0,0,0,0.6);
  animation: slideUp 0.35s cubic-bezier(0.34,1.56,0.64,1);
}
@keyframes slideUp {
  from { transform: translateY(40px); opacity: 0; }
  to   { transform: translateY(0);    opacity: 1; }
}
.modal-header {
  display: flex; justify-content: space-between;
  align-items: flex-start; margin-bottom: 1.25rem;
}
.modal-title {
  font-family: 'BIZ UDGothic', sans-serif;
  font-size: 1.05rem; font-weight: 700; line-height: 1.3;
  color: var(--text);
}
.modal-title span {
  display: block; font-size: var(--text-sm); color: var(--muted);
  font-family: 'DM Sans', sans-serif; font-weight: 400; margin-top: 0.2rem;
}
.modal-close {
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 50%; width: 30px; height: 30px; font-size: 1rem;
  cursor: pointer; color: var(--muted); flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  -webkit-tap-highlight-color: transparent;
}
.os-tabs { display: flex; gap: 0.4rem; margin-bottom: 1.25rem; }
.os-tab {
  flex: 1; padding: 0.55rem; border: 1px solid var(--border-2);
  border-radius: 8px; background: var(--surface-2); font-size: var(--text-sm);
  font-weight: 700; cursor: pointer; color: var(--muted);
  font-family: 'DM Sans', sans-serif;
  -webkit-tap-highlight-color: transparent; transition: all 0.12s;
}
.os-tab.active { background: var(--grad); color: white; border-color: transparent; }
.install-steps { display: none; }
.install-steps.active { display: flex; flex-direction: column; gap: 0.75rem; }
.step { display: flex; gap: 0.75rem; align-items: flex-start; }
.step-num {
  width: 28px; height: 28px; border-radius: 50%;
  background: var(--grad); color: white;
  font-family: 'DM Sans', sans-serif; font-size: var(--text-xs); font-weight: 700;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.step-text { font-size: var(--text-sm); line-height: 1.6; color: var(--text); padding-top: 0.2rem; }
.step-text b { color: var(--accent); }
.step-text code {
  background: var(--surface-2); border-radius: 4px;
  padding: 0.1rem 0.45rem; font-family: 'DM Sans', sans-serif; font-size: var(--text-xs);
  color: var(--text);
}
.install-divider {
  text-align: center; font-size: var(--text-xs); color: var(--muted);
  font-family: 'DM Sans', sans-serif; letter-spacing: 0.1em;
  position: relative; margin: 0.25rem 0;
}
.install-divider::before, .install-divider::after {
  content: ''; position: absolute; top: 50%;
  width: 42%; height: 1px; background: var(--border-2);
}
.install-divider::before { left: 0; }
.install-divider::after { right: 0; }
.direct-install-btn {
  width: 100%; padding: 0.85rem; background: var(--grad); color: white;
  border: none; border-radius: 8px; font-size: var(--text-base); font-weight: 700;
  cursor: pointer; font-family: 'DM Sans', sans-serif;
  -webkit-tap-highlight-color: transparent; transition: opacity 0.15s;
}
.direct-install-btn:active { opacity: 0.8; }
.direct-install-btn:disabled { background: var(--surface-3); color: var(--muted); cursor: not-allowed; }
.direct-install-note {
  font-size: var(--text-xs); color: var(--muted); text-align: center;
  line-height: 1.5; min-height: 1rem; margin-top: 0.4rem;
}

/* ══════════════════════════════════════
   OFFLINE BADGE
══════════════════════════════════════ */
#offlineBadge {
  display: none; background: var(--n4); color: white;
  text-align: center; font-size: var(--text-xs);
  padding: 0.45rem; font-family: 'DM Sans', sans-serif;
}
#offlineBadge.show { display: block; }

/* ══════════════════════════════════════
   HEADER
══════════════════════════════════════ */
header {
  background: var(--grad);
  color: white;
  padding-top: var(--safe-top);
  overflow: hidden;
  position: relative;
}
header::before {
  content: '文法';
  position: absolute; right: -0.05em; top: -0.15em;
  font-family: 'BIZ UDGothic', sans-serif;
  font-size: min(12rem, 38vw);
  font-weight: 700;
  color: rgba(255,255,255,0.06);
  pointer-events: none;
  line-height: 1; z-index: 0;
}
.header-inner {
  padding: 1.5rem 1.25rem 1.25rem;
  position: relative; z-index: 1;
}
.header-badges {
  display: flex; gap: 0.4rem; margin-bottom: 0.75rem; flex-wrap: wrap;
}
.badge {
  font-size: 0.58rem; font-weight: 700;
  letter-spacing: 0.15em; padding: 0.22rem 0.6rem;
  border-radius: 4px; text-transform: uppercase;
  font-family: 'DM Sans', sans-serif;
  background: rgba(255,255,255,0.15);
  color: white;
  border: 1px solid rgba(255,255,255,0.2);
  backdrop-filter: blur(4px);
}
header h1 {
  font-family: 'BIZ UDGothic', sans-serif;
  font-size: clamp(1.3rem, 5vw, 2rem);
  font-weight: 700; line-height: 1.2; margin-bottom: 0.3rem;
  color: white;
}
header p { color: rgba(255,255,255,0.6); font-size: var(--text-sm); }

.header-rule {
  height: 1px;
  background: rgba(255,255,255,0.15);
}

/* ══════════════════════════════════════
   TAB NAV
══════════════════════════════════════ */
.tab-nav {
  display: flex;
  background: var(--surface);
  border-top: 1px solid rgba(255,255,255,0.08);
  position: fixed;
  bottom: 0; left: 0; right: 0;
  z-index: 100;
  padding-bottom: env(safe-area-inset-bottom, 0px);
  box-shadow: 0 -1px 0 rgba(255,255,255,0.05), 0 -8px 32px rgba(0,0,0,0.35);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
}
body.light .tab-nav {
  border-top-color: var(--border);
  box-shadow: 0 -1px 0 rgba(0,0,0,0.07), 0 -4px 20px rgba(0,0,0,0.07);
}
.tab-btn {
  flex: 1; padding: 0.6rem 0.5rem 0.45rem;
  border: none; background: none;
  font-family: 'DM Sans', sans-serif;
  font-size: 0.58rem; font-weight: 700; letter-spacing: 0.05em;
  color: var(--muted); cursor: pointer;
  transition: all 0.2s; -webkit-tap-highlight-color: transparent;
  text-transform: uppercase;
  display: flex; flex-direction: column; align-items: center; gap: 0.25rem;
  position: relative;
}
.tab-btn::after {
  content: '';
  position: absolute; top: 0; left: 25%; right: 25%;
  height: 2px; border-radius: 0 0 3px 3px;
  background: var(--grad);
  opacity: 0; transform: scaleX(0);
  transition: all 0.25s cubic-bezier(0.34,1.56,0.64,1);
}
.tab-btn.active { color: var(--text); }
.tab-btn.active::after { opacity: 1; transform: scaleX(1); }
.tab-icon { font-size: 1.2rem; line-height: 1; display: block; }
@media (min-width: 768px) {
  .tab-nav {
    position: sticky; top: 0; bottom: auto;
    border-top: none; border-bottom: 1px solid var(--border-2);
    box-shadow: 0 4px 20px rgba(0,0,0,0.25);
    padding-bottom: 0;
  }
  .tab-btn {
    flex-direction: row; gap: 0.4rem;
    padding: 0.85rem 0.75rem;
    font-size: var(--text-xs);
    justify-content: center;
  }
  .tab-btn::after { top: auto; bottom: 0; }
  .tab-icon { font-size: 1rem; }
}

/* ══════════════════════════════════════
   PAGES
══════════════════════════════════════ */
.page { display: none; padding-bottom: calc(60px + env(safe-area-inset-bottom, 0px) + 0.5rem); }
.page.active { display: block; }
@media (min-width: 768px) {
  .page { padding-bottom: 2rem; }
}

/* ══════════════════════════════════════
   FILTER BAR (Browse)
══════════════════════════════════════ */
.filter-bar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0.75rem 1rem 0;
  position: sticky; top: 0; z-index: 50;
}
@media (min-width: 768px) {
  .filter-bar { top: 49px; }
}

/* Row label */
.filter-row-label {
  font-family: 'DM Sans', sans-serif;
  font-size: 0.58rem; font-weight: 700; letter-spacing: 0.12em;
  text-transform: uppercase; color: var(--muted);
  margin-bottom: 0.4rem; display: block;
}

/* Level pills */
.level-pills {
  display: flex; gap: 0.35rem; flex-wrap: nowrap;
  overflow-x: auto; -webkit-overflow-scrolling: touch;
  scrollbar-width: none; padding-bottom: 0.65rem;
}
.level-pills::-webkit-scrollbar { display: none; }

.pill {
  flex-shrink: 0; display: inline-flex; align-items: center; gap: 0.3rem;
  border: 1px solid var(--border-2); border-radius: 20px;
  padding: 0.38rem 0.85rem;
  font-size: var(--text-sm); font-weight: 600;
  font-family: 'DM Sans', sans-serif;
  background: transparent; color: var(--muted);
  cursor: pointer; transition: all 0.18s;
  -webkit-tap-highlight-color: transparent;
  white-space: nowrap; line-height: 1; min-height: 44px;
}
.pill:active { opacity: 0.7; }
.pill-dot { width: 6px; height: 6px; border-radius: 50%; flex-shrink: 0; }
.pill.active-all       { background: var(--grad); color: white; border-color: transparent; -webkit-text-stroke: 0.5px rgba(255,255,255,0.75); }
.pill.active-n1        { background: var(--n1); color: #0D1117; border-color: transparent; -webkit-text-stroke: 0.5px rgba(255,255,255,0.7); }
.pill.active-n2        { background: var(--n2); color: #0D1117; border-color: transparent; -webkit-text-stroke: 0.5px rgba(255,255,255,0.7); }
.pill.active-n3        { background: var(--n3); color: #0D1117; border-color: transparent; -webkit-text-stroke: 0.5px rgba(255,255,255,0.7); }
.pill.active-n4        { background: var(--n4); color: #0D1117; border-color: transparent; -webkit-text-stroke: 0.5px rgba(255,255,255,0.7); }
.pill.active-n5        { background: var(--n5); color: #0D1117; border-color: transparent; -webkit-text-stroke: 0.5px rgba(255,255,255,0.7); }
.pill.active-bookmark  { background: var(--gold); color: #0D1117; border-color: transparent; -webkit-text-stroke: 0.5px rgba(255,255,255,0.7); }

/* Hollow dot saat pill aktif */
.pill[class*="active"] .pill-dot {
  background: transparent !important;
  border: 2px solid currentColor;
  width: 7px; height: 7px;
  opacity: 0.85;
}

/* Week strip */
.week-strip {
  display: none; gap: 0.3rem; flex-wrap: nowrap;
  overflow-x: auto; -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  padding: 0.55rem 0 0.65rem;
  border-top: 1px solid var(--border);
  margin: 0 -1rem; padding-left: 1rem; padding-right: 1rem;
}
.week-strip::-webkit-scrollbar { display: none; }
.week-strip.show { display: flex; }

.week-pill {
  flex-shrink: 0; display: inline-flex; align-items: stretch; gap: 0;
  border: 1px solid var(--border-2); border-radius: 8px;
  overflow: hidden; background: var(--surface-2);
  cursor: pointer; transition: all 0.18s;
  -webkit-tap-highlight-color: transparent; min-height: 44px;
}
.week-pill.active { border-color: var(--accent); }
.week-pill.active .week-num-badge { background: var(--grad); color: white; border-right-color: transparent; }
.week-pill.active .week-theme { color: var(--text); font-weight: 700; }
.week-pill.coming { opacity: 0.35; cursor: not-allowed; }
.week-pill.coming .week-theme { font-style: italic; }
.week-num-badge {
  font-family: 'DM Sans', sans-serif;
  font-size: 0.6rem; font-weight: 700;
  background: var(--surface-3); color: var(--muted);
  padding: 0 0.5rem;
  border-right: 1px solid var(--border);
  display: flex; align-items: center; white-space: nowrap;
  transition: background 0.18s, color 0.18s;
}
.week-theme {
  font-family: 'DM Sans', sans-serif;
  font-size: 0.73rem; color: var(--muted);
  padding: 0 0.65rem;
  display: flex; align-items: center; white-space: nowrap;
}

/* Sort + filter row */
.sort-filter-row {
  display: flex; align-items: center; gap: 0.3rem;
  flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none;
  border-top: 1px solid var(--border);
  padding: 0.5rem 0;
  margin: 0 -1rem; padding-left: 1rem; padding-right: 1rem;
}
.sort-filter-row::-webkit-scrollbar { display: none; }

.sort-label-inline {
  font-family: 'DM Sans', sans-serif;
  font-size: 0.58rem; font-weight: 700; letter-spacing: 0.08em;
  text-transform: uppercase; color: var(--muted);
  white-space: nowrap; flex-shrink: 0; margin-right: 0.15rem;
}
.sort-chip {
  flex-shrink: 0; display: inline-flex; align-items: center; gap: 0.2rem;
  border: 1px solid var(--border-2); border-radius: 20px;
  padding: 0.28rem 0.7rem; font-size: 0.7rem; font-weight: 700;
  font-family: 'DM Sans', sans-serif;
  background: transparent; color: var(--muted);
  cursor: pointer; transition: all 0.18s;
  -webkit-tap-highlight-color: transparent; white-space: nowrap; min-height: 44px;
}
.sort-chip.active { background: var(--surface-3); color: var(--text); border-color: var(--border-2); }
.sort-chip-arrow { font-size: 0.58rem; transition: transform 0.2s; }
.sort-chip.active .sort-chip-arrow { transform: rotate(180deg); }

/* Kategori chips panel */
.cat-panel {
  display: none; flex-wrap: wrap; gap: 0.35rem;
  padding: 0.6rem 1rem 0.7rem;
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
  margin: 0 -1rem;
  animation: slideDown 0.15s ease;
}
.cat-panel.show { display: flex; }
@keyframes slideDown {
  from { opacity: 0; transform: translateY(-6px); }
  to   { opacity: 1; transform: translateY(0); }
}
.cat-chip {
  display: inline-flex; align-items: center;
  border: 1px solid var(--border-2); border-radius: 20px;
  padding: 0.32rem 0.8rem; font-size: var(--text-sm); font-weight: 600;
  font-family: 'DM Sans', sans-serif;
  background: transparent; color: var(--muted);
  cursor: pointer; transition: all 0.18s;
  -webkit-tap-highlight-color: transparent; min-height: 34px;
}
.cat-chip.active { background: var(--n3-dim); color: var(--n3); border-color: var(--n3-border); }
.cat-chip.active-all-cat { background: var(--grad); color: white; border-color: transparent; }

/* Search row */
.search-row {
  padding: 0.45rem 1rem 0.6rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: relative;
}
.search-row svg {
  position: absolute; left: 1.65rem; top: 50%;
  transform: translateY(-50%); width: 14px; height: 14px;
  color: var(--muted); pointer-events: none;
}
.search-row input {
  width: 100%; border: 1px solid var(--border-2); border-radius: 20px;
  padding: 0.5rem 1rem 0.5rem 2.25rem;
  font-size: var(--text-base); font-family: 'DM Sans', sans-serif;
  background: var(--surface-2); color: var(--text);
  outline: none; -webkit-appearance: none; transition: border-color 0.18s;
  box-sizing: border-box; min-height: 42px;
}
.search-row input::placeholder { color: var(--muted); }
.search-row input:focus { border-color: var(--accent); background: var(--surface-3); }

/* ══════════════════════════════════════
   PROGRESS PANEL
══════════════════════════════════════ */
.progress-panel {
  display: none;
  margin: 0.75rem 1rem;
  background: var(--surface);
  border: 1px solid var(--border-2);
  border-radius: 12px;
  overflow: hidden;
}
.progress-panel.show { display: block; }

.progress-panel-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0.6rem 0.9rem 0.5rem;
  border-bottom: 1px solid var(--border);
  background: var(--surface-2);
}
.progress-panel-title {
  font-family: 'DM Sans', sans-serif;
  font-size: 0.6rem; font-weight: 700; letter-spacing: 0.1em;
  text-transform: uppercase; color: var(--muted);
}
.progress-panel-total {
  font-family: 'DM Sans', sans-serif;
  font-size: 0.6rem; color: var(--muted);
}
.progress-level-row {
  display: flex; align-items: center; gap: 0.75rem;
  padding: 0.5rem 0.9rem;
  border-bottom: 1px solid var(--border);
}
.progress-level-row:last-child { border-bottom: none; }
.progress-lv-badge {
  font-family: 'DM Sans', sans-serif;
  font-size: 0.62rem; font-weight: 700;
  width: 26px; text-align: center; flex-shrink: 0;
}
.progress-lv-badge.n1 { color: var(--n1); }
.progress-lv-badge.n2 { color: var(--n2); }
.progress-lv-badge.n3 { color: var(--n3); }
.progress-lv-badge.n4 { color: var(--n4); }
.progress-lv-badge.n5 { color: var(--n5); }
.progress-lv-bar-wrap {
  flex: 1; height: 6px; background: var(--surface-3);
  border-radius: 99px; overflow: hidden; display: flex;
}
.plv-mature   { background: #34D399; height: 100%; transition: width 0.6s ease; }
.plv-young    { background: #60A5FA; height: 100%; transition: width 0.6s ease; }
.plv-learning { background: #FBBF24; height: 100%; transition: width 0.6s ease; }

/* Progress legend */
.progress-legend {
  display: flex; gap: 0.85rem; padding: 0.45rem 0.9rem;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}
.leg-item {
  display: flex; align-items: center; gap: 0.3rem;
  font-family: 'DM Sans', sans-serif;
  font-size: 0.58rem; color: var(--muted); letter-spacing: 0.04em;
}
.leg-dot {
  width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0;
}
.leg-dot.mature   { background: #34D399; }
.leg-dot.young    { background: #60A5FA; }
.leg-dot.learning { background: #FBBF24; }
.leg-dot.unseen   { background: var(--surface-3); border: 1px solid var(--border-2); }

/* Due today banner inside progress panel */
.progress-due-banner {
  display: none; align-items: center; gap: 0.6rem;
  padding: 0.55rem 0.9rem;
  background: rgba(96,165,250,0.08);
  border-bottom: 1px solid var(--border);
}
.due-fire { font-size: 1rem; flex-shrink: 0; }
.due-text { flex: 1; font-size: var(--text-sm); color: var(--text); }
.due-text strong { color: var(--n3); }
.due-review-btn {
  background: var(--n3-dim); color: var(--n3);
  border: 1px solid var(--n3-border); border-radius: 20px;
  padding: 0.3rem 0.75rem; font-size: var(--text-xs);
  font-weight: 700; font-family: 'DM Sans', sans-serif;
  cursor: pointer; white-space: nowrap;
  -webkit-tap-highlight-color: transparent;
  transition: all 0.15s;
}
.due-review-btn:active { background: var(--n3); color: #0D1117; }

/* Quick Review card in quiz setup */
.quick-review-card {
  display: flex; align-items: center; justify-content: space-between;
  gap: 0.75rem;
  background: var(--grad);
  border-radius: 14px; padding: 1rem 1.1rem;
  margin-bottom: 0.35rem;
  box-shadow: 0 4px 20px rgba(45,106,79,0.25);
  animation: qrPop 0.4s cubic-bezier(0.34,1.56,0.64,1);
}
@keyframes qrPop {
  from { opacity: 0; transform: scale(0.94) translateY(8px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}
.qr-left { display: flex; align-items: center; gap: 0.75rem; }
.qr-icon { font-size: 1.6rem; line-height: 1; }
.qr-title {
  font-family: 'BIZ UDGothic', sans-serif;
  font-size: 1rem; font-weight: 700; color: white; line-height: 1.2;
}
.qr-sub {
  font-size: var(--text-xs); color: rgba(255,255,255,0.75);
  font-family: 'DM Sans', sans-serif; margin-top: 0.1rem;
}
.qr-btn {
  background: rgba(255,255,255,0.18);
  border: 1.5px solid rgba(255,255,255,0.35);
  color: white; border-radius: 10px;
  padding: 0.6rem 1rem; font-size: var(--text-sm); font-weight: 700;
  font-family: 'DM Sans', sans-serif;
  cursor: pointer; white-space: nowrap;
  -webkit-tap-highlight-color: transparent;
  transition: background 0.15s;
  flex-shrink: 0;
}
.qr-btn:active { background: rgba(255,255,255,0.3); }

/* Section divider */
.quiz-section-divider {
  display: flex; align-items: center; gap: 0.6rem;
  margin: 0.75rem 0 1rem;
  color: var(--muted); font-size: var(--text-xs);
  font-family: 'DM Sans', sans-serif; letter-spacing: 0.08em;
}
.quiz-section-divider::before, .quiz-section-divider::after {
  content: ''; flex: 1; height: 1px; background: var(--border-2);
}

.progress-lv-count {
  font-family: 'DM Sans', sans-serif;
  font-size: 0.6rem; color: var(--muted);
  white-space: nowrap; flex-shrink: 0;
}

/* ══════════════════════════════════════
   STATS BAR
══════════════════════════════════════ */
.stats {
  padding: 0.5rem 1rem;
  font-size: var(--text-xs); color: var(--muted);
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  font-family: 'DM Sans', sans-serif;
}
.stats strong { color: var(--n3); }

/* ══════════════════════════════════════
   CARD GRID
══════════════════════════════════════ */
.cards-wrap { padding: 1rem 1rem 6rem; }
.section { margin-bottom: 2rem; }
.section-header {
  display: flex; align-items: center; gap: 0.6rem;
  margin-bottom: 0.85rem; padding-bottom: 0.5rem;
  border-bottom: 1px solid currentColor;
  opacity: 0.9;
}
.section-header.n1 { color: var(--n1); }
.section-header.n2 { color: var(--n2); }
.section-header.n3 { color: var(--n3); }
.section-header.n4 { color: var(--n4); }
.section-header.n5 { color: var(--n5); }
.section-title { font-family: 'BIZ UDGothic', sans-serif; font-size: var(--text-md); font-weight: 700; }
.section-count {
  font-family: 'DM Sans', sans-serif; font-size: 0.6rem; font-weight: 700;
  background: currentColor; color: var(--bg) !important;
  border-radius: 999px; padding: 0.1rem 0.55rem;
}
.cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(290px, 1fr));
  gap: 0.85rem;
}
@media (max-width: 520px) { .cards { grid-template-columns: 1fr; } }

/* ══════════════════════════════════════
   FLIP CARD
══════════════════════════════════════ */
.flip-wrap {
  height: 360px; perspective: 1000px;
  cursor: pointer; -webkit-tap-highlight-color: transparent;
}
.flip-inner {
  width: 100%; height: 100%;
  position: relative; transform-style: preserve-3d;
  transition: transform 0.45s cubic-bezier(0.4, 0.2, 0.2, 1);
}
.flip-wrap.flipped .flip-inner { transform: rotateY(180deg); }

.face {
  position: absolute; inset: 0;
  border-radius: 16px; border: 1px solid var(--border-2);
  padding: 1rem 1.1rem 0.9rem;
  background: var(--surface);
  backface-visibility: hidden; -webkit-backface-visibility: hidden;
  overflow: hidden; display: flex; flex-direction: column;
  box-shadow: var(--shadow-md);
}
.face::before {
  content: ''; position: absolute; left: 0; top: 0; bottom: 0;
  width: 3px; border-radius: 12px 0 0 12px;
}
.card-level-dot {
  position: absolute; top: 1rem; right: 1rem;
  width: 7px; height: 7px; border-radius: 50%; opacity: 0.7;
}

/* Front face */
.card-grammar {
  font-family: 'BIZ UDGothic', sans-serif;
  font-size: 1.35rem; font-weight: 700; line-height: 1.3;
  margin-bottom: 0.15rem; padding-right: 1.4rem;
  color: var(--text);
}
.card-reading {
  font-family: 'DM Sans', sans-serif; font-size: 0.68rem;
  color: var(--muted); font-style: italic; margin-bottom: 0.5rem;
}
.card-meaning {
  font-size: var(--text-base); font-weight: 700; line-height: 1.4;
  margin-bottom: 0.5rem; color: var(--text);
}
.card-connection {
  font-family: 'DM Sans', sans-serif; font-size: 0.65rem;
  font-weight: 700;
  border-radius: 5px; padding: 0.26rem 0.6rem;
  margin-bottom: 0.5rem; display: inline-block; line-height: 1.4;
  border: 1px solid; /* color set per level */
}
.card-desc {
  font-size: var(--text-sm); color: var(--muted); line-height: 1.7;
  padding: 0.5rem 0.65rem;
  background: var(--surface-2);
  border-radius: 6px; border-left: 2px solid var(--border-2);
  flex: 1;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 4;
  -webkit-box-orient: vertical;
}
.front-bottom {
  display: flex; justify-content: space-between;
  align-items: center; margin-top: 0.65rem; flex-shrink: 0;
}
.card-tags { display: flex; flex-wrap: wrap; gap: 0.3rem; align-items: center; }
.tag {
  font-size: 0.6rem; font-weight: 700; letter-spacing: 0.05em;
  text-transform: uppercase;
  border-radius: 4px; padding: 0.1rem 0.45rem;
  font-family: 'DM Sans', sans-serif;
  display: inline-flex; align-items: center;
  height: 1.6rem; line-height: 1; border: 1px solid;
}
.tag.n1 { background: var(--n1-dim); color: var(--n1); border-color: var(--n1-border); }
.tag.n2 { background: var(--n2-dim); color: var(--n2); border-color: var(--n2-border); }
.tag.n3 { background: var(--n3-dim); color: var(--n3); border-color: var(--n3-border); }
.tag.n4 { background: var(--n4-dim); color: var(--n4); border-color: var(--n4-border); }
.tag.n5 { background: var(--n5-dim); color: var(--n5); border-color: var(--n5-border); }
.flip-hint {
  font-size: 0.62rem; color: var(--muted);
  font-family: 'DM Sans', sans-serif; opacity: 0.45;
  white-space: nowrap;
}

/* Back face */
.back {
  transform: rotateY(180deg);
  gap: 0.4rem; overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
  scrollbar-color: var(--surface-3) transparent;
}
.back::-webkit-scrollbar { width: 3px; }
.back::-webkit-scrollbar-track { background: transparent; }
.back::-webkit-scrollbar-thumb { background: var(--surface-3); border-radius: 4px; }

.back-label {
  font-size: 0.6rem; font-weight: 700; letter-spacing: 0.1em;
  text-transform: uppercase; color: var(--muted);
  font-family: 'DM Sans', sans-serif; flex-shrink: 0;
  margin-bottom: 0.1rem;
}
.card-examples { display: flex; flex-direction: column; gap: 0.4rem; }
.card-example {
  background: var(--surface-2); border-radius: 6px;
  padding: 0.5rem 0.7rem; border-left: 2px solid var(--border-2); flex-shrink: 0;
}
.card-example .jp { font-size: var(--text-sm); line-height: 1.65; margin-bottom: 0.1rem; color: var(--text); }
.card-example .jp b { font-weight: 700; text-decoration: underline; text-underline-offset: 3px; }
.card-example .id { font-size: 0.73rem; color: var(--muted); font-style: italic; }

.card-nuance {
  background: rgba(251,191,36,0.08); border: 1px solid rgba(251,191,36,0.2);
  border-radius: 6px; padding: 0.45rem 0.65rem;
  font-size: 0.73rem; color: rgba(251,191,36,0.9); line-height: 1.6; flex-shrink: 0;
}
.nuance-label { margin-right: 0.3rem; }

/* ── Level color theming ── */
.n1 .face::before { background: var(--n1); }
.n2 .face::before { background: var(--n2); }
.n3 .face::before { background: var(--n3); }
.n4 .face::before { background: var(--n4); }
.n5 .face::before { background: var(--n5); }
.n1 .card-level-dot { background: var(--n1); }
.n2 .card-level-dot { background: var(--n2); }
.n3 .card-level-dot { background: var(--n3); }
.n4 .card-level-dot { background: var(--n4); }
.n5 .card-level-dot { background: var(--n5); }
.n1 .card-desc { border-left-color: var(--n1-border); }
.n2 .card-desc { border-left-color: var(--n2-border); }
.n3 .card-desc { border-left-color: var(--n3-border); }
.n4 .card-desc { border-left-color: var(--n4-border); }
.n5 .card-desc { border-left-color: var(--n5-border); }
.n1 .card-connection { color: var(--n1); background: var(--n1-dim); border-color: var(--n1-border); }
.n2 .card-connection { color: var(--n2); background: var(--n2-dim); border-color: var(--n2-border); }
.n3 .card-connection { color: var(--n3); background: var(--n3-dim); border-color: var(--n3-border); }
.n4 .card-connection { color: var(--n4); background: var(--n4-dim); border-color: var(--n4-border); }
.n5 .card-connection { color: var(--n5); background: var(--n5-dim); border-color: var(--n5-border); }
.n1 .card-example { border-left-color: var(--n1-border); }
.n1 .card-example .jp b { color: var(--n1); }
.n2 .card-example { border-left-color: var(--n2-border); }
.n2 .card-example .jp b { color: var(--n2); }
.n3 .card-example { border-left-color: var(--n3-border); }
.n3 .card-example .jp b { color: var(--n3); }
.n4 .card-example { border-left-color: var(--n4-border); }
.n4 .card-example .jp b { color: var(--n4); }
.n5 .card-example { border-left-color: var(--n5-border); }
.n5 .card-example .jp b { color: var(--n5); }
.flip-wrap.dummy .face { opacity: 0.4; }

/* Progress badge & bookmark */
.card-progress-badge {
  position: absolute; top: 0.7rem; right: 0.75rem;
  font-size: 0.9rem; line-height: 1; z-index: 2; pointer-events: none;
  filter: drop-shadow(0 1px 3px rgba(0,0,0,0.5));
}
.bookmark-btn {
  position: absolute; top: 0.55rem; right: 0.6rem;
  width: 30px; height: 30px; border: none; border-radius: 50%;
  background: rgba(22,27,34,0.85);
  display: flex; align-items: center; justify-content: center;
  font-size: 0.9rem; cursor: pointer; z-index: 20;
  -webkit-tap-highlight-color: transparent;
  transition: transform 0.15s, background 0.15s;
  backdrop-filter: blur(4px);
  box-shadow: 0 1px 6px rgba(0,0,0,0.4);
}
.bookmark-btn:active { transform: scale(0.82); }
.bookmark-btn.bookmarked { background: rgba(251,191,36,0.15); }

/* ══════════════════════════════════════
   EMPTY STATE
══════════════════════════════════════ */
.empty-state {
  text-align: center; padding: 3rem 1rem;
  color: var(--muted); font-size: var(--text-base);
}
.empty-state .icon { font-size: 2.5rem; margin-bottom: 0.75rem; }

/* ══════════════════════════════════════
   QUIZ — SETUP
══════════════════════════════════════ */
.quiz-setup { padding: 1.25rem 1rem; }
.quiz-setup h2 {
  font-family: 'BIZ UDGothic', sans-serif;
  font-size: 1.15rem; font-weight: 700; margin-bottom: 1.25rem;
  color: var(--text);
}
.quiz-option-group { margin-bottom: 1.1rem; }
.quiz-option-label {
  display: block; font-family: 'DM Sans', sans-serif;
  font-size: 0.58rem; font-weight: 700; letter-spacing: 0.1em;
  text-transform: uppercase; color: var(--muted); margin-bottom: 0.5rem;
}
.quiz-start-btn {
  display: block; width: 100%; margin-top: 1.5rem;
  padding: 1rem; border-radius: 12px; border: none;
  background: var(--grad); color: white;
  font-size: var(--text-md); font-weight: 700; cursor: pointer;
  -webkit-tap-highlight-color: transparent; transition: opacity 0.15s;
  font-family: 'BIZ UDGothic', sans-serif; letter-spacing: 0.02em;
  box-shadow: 0 4px 20px rgba(45,106,79,0.25), 0 0 0 0 rgba(59,130,196,0.15);
  border-radius: 14px;
}
.quiz-start-btn:active { opacity: 0.87; transform: scale(0.99); }

/* ══════════════════════════════════════
   QUIZ — ACTIVE SESSION
══════════════════════════════════════ */
#quizActive { display: none; padding: 0.9rem 1rem; }

.quiz-topbar {
  display: flex; align-items: center; gap: 0.75rem;
  margin-bottom: 0.75rem;
}
.quiz-progress { flex: 1; display: flex; align-items: center; gap: 0.6rem; }
.quiz-progress-bar {
  flex: 1; height: 4px; background: var(--surface-3);
  border-radius: 99px; overflow: hidden;
}
.quiz-progress-fill {
  height: 100%; background: var(--grad);
  border-radius: 99px; transition: width 0.3s;
}
.quiz-progress-txt {
  font-family: 'DM Sans', sans-serif;
  font-size: 0.62rem; color: var(--muted); white-space: nowrap;
}
.quiz-end-btn {
  flex-shrink: 0;
  border: 1px solid var(--border-2); border-radius: 20px;
  padding: 0.35rem 0.8rem; font-size: 0.68rem; font-weight: 700;
  font-family: 'DM Sans', sans-serif;
  background: transparent; color: var(--muted);
  cursor: pointer; transition: all 0.15s;
  -webkit-tap-highlight-color: transparent; min-height: 34px;
}
.quiz-end-btn:active { background: rgba(248,113,113,0.12); color: var(--n4); border-color: var(--n4-border); }

.quiz-score {
  text-align: center; font-size: var(--text-sm); color: var(--muted);
  font-family: 'DM Sans', sans-serif;
  margin-bottom: 0.75rem; letter-spacing: 0.05em;
}

/* Quiz card */
.quiz-card-wrap {
  position: relative;
  height: 340px; perspective: 1000px;
  cursor: pointer; -webkit-tap-highlight-color: transparent;
  margin-bottom: 0.9rem;
}
.quiz-flip-inner {
  width: 100%; height: 100%;
  position: relative; transform-style: preserve-3d;
  transition: transform 0.45s cubic-bezier(0.4,0.2,0.2,1);
}
.quiz-card-wrap.flipped .quiz-flip-inner { transform: rotateY(180deg); }

.quiz-face {
  position: absolute; inset: 0; border-radius: 12px;
  border: 1px solid var(--border-2); background: var(--surface);
  backface-visibility: hidden; -webkit-backface-visibility: hidden;
  display: flex; flex-direction: column;
  padding: 1.25rem; overflow: hidden;
}
.quiz-face::before {
  content: ''; position: absolute; left: 0; top: 0; bottom: 0;
  width: 3px; border-radius: 12px 0 0 12px;
}
.quiz-face-label {
  font-family: 'DM Sans', sans-serif;
  font-size: 0.6rem; font-weight: 700; letter-spacing: 0.1em;
  text-transform: uppercase; color: var(--muted);
  flex-shrink: 0; margin-bottom: 0.75rem;
}

.quiz-face.front {
  justify-content: center; align-items: center;
  text-align: center; gap: 0.4rem;
}
.quiz-face.front .quiz-face-label {
  position: absolute; top: 1rem; left: 1.25rem; margin-bottom: 0;
}
.qgrammar {
  font-family: 'BIZ UDGothic', sans-serif;
  font-size: clamp(1.7rem, 7vw, 2.3rem);
  font-weight: 700; line-height: 1.3; color: var(--text);
}
.qreading {
  font-family: 'DM Sans', sans-serif;
  font-size: 0.78rem; color: var(--muted); font-style: italic;
}
.qmeaning {
  font-size: var(--text-base); font-weight: 700;
  color: var(--text); margin-top: 0.25rem; line-height: 1.4;
  padding: 0 1rem;
}
.quiz-tap-hint {
  font-size: 0.62rem; color: var(--muted);
  font-family: 'DM Sans', sans-serif; opacity: 0.4;
  margin-top: 0.75rem;
}

.quiz-face.back {
  transform: rotateY(180deg);
  gap: 0.45rem; overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
  scrollbar-color: var(--surface-3) transparent;
}
.quiz-face.back::-webkit-scrollbar { width: 3px; }
.quiz-face.back::-webkit-scrollbar-thumb { background: var(--surface-3); border-radius: 4px; }

.qdesc {
  font-size: var(--text-sm); color: var(--muted); line-height: 1.7;
  padding: 0.5rem 0.65rem; background: var(--surface-2);
  border-radius: 6px; border-left: 2px solid var(--border-2); flex-shrink: 0;
}
.qexamples { display: flex; flex-direction: column; gap: 0.35rem; }
.quiz-ex {
  background: var(--surface-2); border-radius: 6px;
  padding: 0.45rem 0.65rem; border-left: 2px solid var(--border-2);
}
.quiz-ex .jp { font-size: var(--text-sm); line-height: 1.6; color: var(--text); }
.quiz-ex .jp b { font-weight: 700; text-decoration: underline; text-underline-offset: 2px; }
.quiz-ex .id { font-size: 0.7rem; color: var(--muted); font-style: italic; }

/* Quiz level colors */
.qn1 .quiz-face::before { background: var(--n1); }
.qn1 .qdesc { border-left-color: var(--n1-border); }
.qn1 .quiz-ex { border-left-color: var(--n1-border); }
.qn1 .quiz-ex .jp b { color: var(--n1); }
.qn2 .quiz-face::before { background: var(--n2); }
.qn2 .qdesc { border-left-color: var(--n2-border); }
.qn2 .quiz-ex { border-left-color: var(--n2-border); }
.qn2 .quiz-ex .jp b { color: var(--n2); }
.qn3 .quiz-face::before { background: var(--n3); }
.qn3 .qdesc { border-left-color: var(--n3-border); }
.qn3 .quiz-ex { border-left-color: var(--n3-border); }
.qn3 .quiz-ex .jp b { color: var(--n3); }
.qn4 .quiz-face::before { background: var(--n4); }
.qn4 .qdesc { border-left-color: var(--n4-border); }
.qn4 .quiz-ex { border-left-color: var(--n4-border); }
.qn4 .quiz-ex .jp b { color: var(--n4); }
.qn5 .quiz-face::before { background: var(--n5); }
.qn5 .qdesc { border-left-color: var(--n5-border); }
.qn5 .quiz-ex { border-left-color: var(--n5-border); }
.qn5 .quiz-ex .jp b { color: var(--n5); }

/* ══════════════════════════════════════
   ASSESS BUTTONS
══════════════════════════════════════ */
.assess-btns {
  display: none; grid-template-columns: 1fr 1fr 1fr;
  gap: 0.6rem; margin-bottom: 0.75rem;
}
.assess-btns.show { display: grid; }
.assess-btn {
  padding: 0.85rem 0.5rem; border: 1px solid;
  border-radius: 12px; font-size: var(--text-sm); font-weight: 700; cursor: pointer;
  font-family: 'DM Sans', sans-serif;
  -webkit-tap-highlight-color: transparent; transition: all 0.12s;
  display: flex; flex-direction: column; align-items: center; gap: 0.3rem;
  min-height: 70px; justify-content: center;
}
.assess-btn:active { transform: scale(0.94); }
.assess-btn .emoji { font-size: 1.5rem; line-height: 1; }
.assess-btn.know   { background: rgba(52,211,153,0.1); color: #34D399; border-color: rgba(52,211,153,0.3); }
.assess-btn.unsure { background: rgba(251,191,36,0.1); color: #FBBF24; border-color: rgba(251,191,36,0.3); }
.assess-btn.forgot { background: rgba(248,113,113,0.1); color: #F87171; border-color: rgba(248,113,113,0.3); }
.assess-btn.know:active   { background: rgba(52,211,153,0.2); }
.assess-btn.unsure:active { background: rgba(251,191,36,0.2); }
.assess-btn.forgot:active { background: rgba(248,113,113,0.2); }

/* ══════════════════════════════════════
   QUIZ MODE TOGGLE
══════════════════════════════════════ */
.quiz-mode-toggle {
  display: grid; grid-template-columns: 1fr 1fr;
  gap: 0.5rem; margin-bottom: 1rem;
}
.mode-btn {
  display: flex; flex-direction: column; align-items: flex-start;
  gap: 0.1rem; padding: 0.75rem 0.9rem;
  border-radius: 12px; border: 1.5px solid var(--border-2);
  background: var(--surface-2); cursor: pointer;
  text-align: left; transition: all 0.15s;
  -webkit-tap-highlight-color: transparent;
}
.mode-btn.active {
  border-color: var(--accent);
  background: rgba(59,130,196,0.12);
  box-shadow: 0 0 0 1px var(--accent);
}
.mode-icon { font-size: 1.2rem; line-height: 1; }
.mode-label {
  font-size: var(--text-sm); font-weight: 700; color: var(--text);
  font-family: 'DM Sans', sans-serif;
}
.mode-desc {
  font-size: 0.62rem; color: var(--muted);
  font-family: 'DM Sans', sans-serif; letter-spacing: 0.03em;
}
.mode-btn.active .mode-label { color: var(--accent); }

/* ══════════════════════════════════════
   FILL-IN QUIZ CARD
══════════════════════════════════════ */
.fill-card {
  background: var(--surface);
  border: 1px solid var(--border-2);
  border-radius: 18px;
  padding: 1.25rem 1.1rem 1rem;
  margin: 0.75rem 0;
  min-height: 300px;
  box-shadow: var(--shadow-md);
  animation: fillCardIn 0.3s cubic-bezier(0.34,1.2,0.64,1);
}
@keyframes fillCardIn {
  from { opacity: 0; transform: translateY(12px) scale(0.97); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}
.fill-level-badge {
  display: inline-block;
  font-family: 'DM Sans', sans-serif;
  font-size: 0.65rem; font-weight: 700;
  padding: 0.15rem 0.55rem; border-radius: 20px;
  margin-bottom: 0.85rem;
  background: var(--n3-dim); color: var(--n3);
  border: 1px solid var(--n3-border);
  letter-spacing: 0.08em;
}
.fill-sentence {
  font-family: 'BIZ UDGothic', sans-serif;
  font-size: 1.2rem; line-height: 1.9;
  color: var(--text); margin-bottom: 0.5rem;
  word-break: break-all;
}
.fill-blank {
  display: inline-block;
  min-width: 3rem; border-bottom: 2.5px solid var(--accent);
  text-align: center; padding: 0 0.3rem;
  color: var(--accent); font-weight: 700;
  vertical-align: middle; margin: 0 0.15rem;
  transition: all 0.2s;
}
.fill-blank.answered-correct { border-color: #34D399; color: #34D399; background: rgba(52,211,153,0.1); border-radius: 4px; }
.fill-blank.answered-wrong   { border-color: #F87171; color: #F87171; background: rgba(248,113,113,0.1); border-radius: 4px; }

.fill-grammar-hint {
  font-size: var(--text-xs); color: var(--muted);
  font-family: 'DM Sans', sans-serif;
  margin-bottom: 1rem; letter-spacing: 0.03em;
}

/* Choice buttons */
.fill-choices {
  display: grid; grid-template-columns: 1fr 1fr;
  gap: 0.5rem; margin-top: 0.25rem;
}
.fill-choice {
  padding: 0.75rem 0.6rem;
  border-radius: 10px; border: 1.5px solid var(--border-2);
  background: var(--surface-2); cursor: pointer;
  font-family: 'BIZ UDGothic', sans-serif;
  font-size: 1rem; color: var(--text);
  transition: all 0.12s; text-align: center;
  -webkit-tap-highlight-color: transparent;
  position: relative;
}
.fill-choice:active { transform: scale(0.95); }
.fill-choice.selected-correct {
  background: rgba(52,211,153,0.15);
  border-color: #34D399; color: #34D399; font-weight: 700;
}
.fill-choice.selected-wrong {
  background: rgba(248,113,113,0.12);
  border-color: #F87171; color: #F87171;
}
.fill-choice.reveal-correct {
  background: rgba(52,211,153,0.08);
  border-color: rgba(52,211,153,0.4); color: #34D399;
}
.fill-choice.disabled { pointer-events: none; opacity: 0.5; }
.fill-choice.disabled.reveal-correct { opacity: 1; }

/* Feedback area */
.fill-feedback {
  margin-top: 1rem; padding-top: 0.9rem;
  border-top: 1px solid var(--border);
  animation: fadeUp 0.25s ease both;
}
.fill-feedback-verdict {
  font-size: 1rem; font-weight: 700; margin-bottom: 0.4rem;
}
.fill-next-btn {
  width: 100%; padding: 0.8rem;
  border-radius: 10px; border: none;
  background: var(--grad); color: white;
  font-size: var(--text-sm); font-weight: 700;
  cursor: pointer; font-family: 'DM Sans', sans-serif;
  -webkit-tap-highlight-color: transparent;
  transition: opacity 0.15s;
}
.fill-next-btn:active { opacity: 0.8; }

/* Coming soon overlay on fill-in when no questions */
.fill-coming-soon {
  text-align: center; padding: 3rem 1rem;
  color: var(--muted);
}
.fill-coming-soon .cs-icon { font-size: 2.5rem; margin-bottom: 0.75rem; }
.fill-coming-soon h3 {
  font-size: 1rem; font-weight: 700; color: var(--text);
  margin-bottom: 0.4rem;
}
.fill-coming-soon p { font-size: var(--text-sm); line-height: 1.6; }

#quizResult {
  display: none; padding: 2rem 1rem 2rem;
  text-align: center;
}

/* Score ring */
.result-ring-wrap {
  position: relative; width: 140px; height: 140px;
  margin: 0 auto 1.25rem; display: flex;
  align-items: center; justify-content: center;
  animation: ringPop 0.5s cubic-bezier(0.34,1.56,0.64,1) both;
}
@keyframes ringPop {
  from { opacity: 0; transform: scale(0.6); }
  to   { opacity: 1; transform: scale(1); }
}
.result-ring {
  position: absolute; inset: 0; width: 100%; height: 100%;
  transform: rotate(-90deg);
}
.ring-bg {
  fill: none; stroke: var(--surface-3);
  stroke-width: 8;
}
.ring-fill {
  fill: none; stroke: var(--grad-end);
  stroke-width: 8; stroke-linecap: round;
  stroke-dasharray: 327;
  transition: stroke-dashoffset 1.2s cubic-bezier(0.4,0,0.2,1);
}
.ring-fill.perfect { stroke: url(#ringGrad); }
.result-ring-inner {
  position: relative; z-index: 1; text-align: center;
}
.result-pct {
  font-family: 'DM Sans', sans-serif;
  font-size: 1.8rem; font-weight: 700; color: var(--text);
  line-height: 1;
}
.result-pct-label {
  font-size: 0.62rem; color: var(--muted);
  font-family: 'DM Sans', sans-serif;
  letter-spacing: 0.08em; text-transform: uppercase;
}

.result-title {
  font-family: 'BIZ UDGothic', sans-serif;
  font-size: 1.4rem; font-weight: 700; color: var(--text);
  margin-bottom: 0.4rem;
  animation: fadeUp 0.4s 0.3s both;
}
.result-sub {
  font-size: var(--text-sm); color: var(--muted);
  margin-bottom: 1.25rem; line-height: 1.6;
  animation: fadeUp 0.4s 0.4s both;
}
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

.result-stats {
  display: flex; gap: 0.6rem; justify-content: center;
  margin-bottom: 1rem;
  animation: fadeUp 0.4s 0.5s both;
}
.rs-item {
  flex: 1; max-width: 100px;
  border-radius: 12px; padding: 0.85rem 0.5rem;
  text-align: center; border: 1px solid;
}
.rs-item.know   { background: rgba(52,211,153,0.08);  border-color: rgba(52,211,153,0.25); }
.rs-item.unsure { background: rgba(251,191,36,0.08);  border-color: rgba(251,191,36,0.25); }
.rs-item.forgot { background: rgba(248,113,113,0.08); border-color: rgba(248,113,113,0.25); }
.rs-num {
  font-family: 'DM Sans', sans-serif;
  font-size: 1.75rem; font-weight: 700; line-height: 1;
  transition: all 0.3s;
}
.rs-item.know   .rs-num { color: #34D399; }
.rs-item.unsure .rs-num { color: #FBBF24; }
.rs-item.forgot .rs-num { color: #F87171; }
.rs-label { font-size: 0.7rem; color: var(--muted); margin-top: 0.35rem; }

/* SRS next review hint */
.result-srs-hint {
  display: flex; align-items: center; gap: 0.5rem;
  background: var(--surface-2); border: 1px solid var(--border-2);
  border-radius: 10px; padding: 0.65rem 0.9rem;
  font-size: var(--text-sm); color: var(--muted);
  margin-bottom: 1rem; text-align: left;
  animation: fadeUp 0.4s 0.65s both;
  border-left: 3px solid var(--accent);
}
.srs-hint-icon { font-size: 1rem; flex-shrink: 0; }

.result-total {
  font-family: 'DM Sans', sans-serif;
  font-size: 0.68rem; color: var(--muted); margin-bottom: 1.5rem;
}
.retry-btn {
  display: block; width: 100%;
  padding: 0.9rem; border-radius: 10px; border: none;
  background: var(--grad); color: white;
  font-size: var(--text-base); font-weight: 700; cursor: pointer;
  margin-bottom: 0.6rem; font-family: 'BIZ UDGothic', sans-serif;
  -webkit-tap-highlight-color: transparent; transition: opacity 0.15s;
  box-shadow: 0 4px 16px rgba(45,106,79,0.25);
  animation: fadeUp 0.4s 0.7s both;
}
.retry-btn:active { opacity: 0.8; }
.back-to-menu-btn {
  display: block; width: 100%;
  padding: 0.8rem; border-radius: 10px; margin-top: 0.25rem;
  border: 1px solid var(--border-2); background: transparent;
  font-size: var(--text-sm); font-weight: 700; color: var(--muted);
  cursor: pointer; text-align: center;
  -webkit-tap-highlight-color: transparent; transition: all 0.12s;
  animation: fadeUp 0.4s 0.8s both;
}
.back-to-menu-btn:active { background: var(--surface-2); }

/* ══════════════════════════════════════
   MODAL — KONFIRMASI AKHIRI QUIZ
══════════════════════════════════════ */
.modal-overlay {
  display: none; position: fixed; inset: 0; z-index: 200;
  background: rgba(0,0,0,0.7); backdrop-filter: blur(8px);
  align-items: center; justify-content: center; padding: 1rem;
}
.modal-overlay.show { display: flex; }
.confirm-modal {
  background: var(--surface); border: 1px solid var(--border-2);
  border-radius: 20px; padding: 1.75rem 1.5rem 1.5rem;
  max-width: 320px; width: 100%;
  box-shadow: 0 24px 60px rgba(0,0,0,0.6);
  text-align: center;
  animation: slideUp 0.25s cubic-bezier(0.34,1.56,0.64,1);
}
.confirm-icon  { font-size: 2.25rem; margin-bottom: 0.65rem; line-height: 1; }
.confirm-title { font-size: 1.05rem; font-weight: 700; margin-bottom: 0.4rem; color: var(--text); }
.confirm-sub   { font-size: var(--text-sm); color: var(--muted); line-height: 1.6; margin-bottom: 1.25rem; }
.confirm-btns  { display: flex; gap: 0.6rem; }
.confirm-btn-cancel {
  flex: 1; padding: 0.75rem; border-radius: 8px;
  border: 1px solid var(--border-2); background: transparent;
  font-size: var(--text-sm); font-weight: 700; cursor: pointer;
  color: var(--muted); transition: all 0.12s;
  -webkit-tap-highlight-color: transparent;
}
.confirm-btn-cancel:active { background: var(--surface-2); }
.confirm-btn-ok {
  flex: 1; padding: 0.75rem; border-radius: 8px;
  border: none; background: rgba(248,113,113,0.15);
  border: 1px solid rgba(248,113,113,0.3);
  font-size: var(--text-sm); font-weight: 700; cursor: pointer;
  color: var(--n4); transition: all 0.12s;
  -webkit-tap-highlight-color: transparent;
}
.confirm-btn-ok:active { background: rgba(248,113,113,0.25); }


/* ══════════════════════════════════════
   DAY SUB-SECTION (Browse by day)
══════════════════════════════════════ */
.week-section { margin-bottom: 0.25rem; }
.week-section .section-header { margin-bottom: 0.6rem; }
.day-subsection { margin-bottom: 1.5rem; padding-left: 0.75rem; border-left: 2px solid var(--border-2); }
.section-header.day-header {
  color: var(--muted);
  font-size: var(--text-sm);
  border-bottom: 1px dashed var(--border-2);
  opacity: 0.85;
}

/* ══════════════════════════════════════
   REARRANGE QUIZ
══════════════════════════════════════ */
.rea-sentence {
  font-size: var(--text-md); font-family: 'BIZ UDGothic', sans-serif;
  line-height: 1.9; color: var(--text);
  margin-bottom: 1rem;
}
.rea-slot {
  display: inline-block;
  min-width: 2.8rem; padding: 0.15rem 0.5rem;
  background: rgba(59,130,196,0.12);
  border: 1.5px dashed var(--accent);
  border-radius: 6px;
  font-size: 0.75rem; font-weight: 700;
  color: var(--accent); text-align: center;
  margin: 0 0.15rem;
  vertical-align: middle;
}
.rea-hint {
  font-size: var(--text-sm); color: var(--muted);
  font-family: 'DM Sans', sans-serif;
  margin-bottom: 0.75rem;
}
.rea-parts {
  display: grid; grid-template-columns: 1fr 1fr;
  gap: 0.5rem; margin-top: 0.5rem;
}
.rea-part-btn {
  padding: 0.65rem 0.75rem;
  border-radius: 10px; border: 1.5px solid var(--border-2);
  background: var(--surface-2); cursor: pointer;
  font-size: var(--text-sm); font-family: 'BIZ UDGothic', sans-serif;
  color: var(--text); text-align: left;
  transition: all 0.15s;
  -webkit-tap-highlight-color: transparent;
}
.rea-part-btn:active { background: rgba(59,130,196,0.1); }
.rea-part-btn.correct { border-color: var(--n3); background: rgba(16,185,129,0.12); color: var(--n3); }
.rea-part-btn.wrong   { border-color: var(--n4); background: rgba(248,113,113,0.12); color: var(--n4); }
.rea-part-btn:disabled { cursor: default; }
.rea-order-label { font-size: 0.65rem; color: var(--muted); font-family: 'DM Sans', sans-serif; text-transform: uppercase; }
.rea-correct-order {
  font-size: var(--text-sm); color: var(--text);
  margin: 0.4rem 0 0.6rem;
  font-family: 'BIZ UDGothic', sans-serif;
  line-height: 1.6;
}
/* ══════════════════════════════════════════════════════════════
   APPEND INI KE PALING BAWAH css/style.css
   §19 — Quiz Feedback Breakdown
   Self-contained: termasuk semua dependency (accent vars, bd-particle, dll)
══════════════════════════════════════════════════════════════ */


/* ── CSS tambahan ── */

body.light {
  --success-dim  : #dcfce7;
  --success-text : #16a34a;
  --error-dim    : #fee2e2;
  --error-text   : #dc2626;
}


/* ══════════════════════════════════════
   §19a — Breakdown particle (dipakai
   di detail modal DAN quiz feedback)
══════════════════════════════════════ */
.bd-particle {
  color: var(--muted);
  opacity: 0.75;
  font-size: 0.9em;
}
.bd-gap {
  display: inline-block;
  width: 0.45em;
}


/* ══════════════════════════════════════
   §19b — Tombol Breakdown (quiz feedback)
   Standalone — tidak bergantung pada
   .detail-bd-btn dari patch detail modal
══════════════════════════════════════ */
.qfb-bd-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  border: 1px solid var(--border-2, var(--border));
  border-radius: 20px;
  padding: 0.22rem 0.7rem;
  background: transparent;
  font-family: 'DM Sans', sans-serif;
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--muted);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: all 0.12s;
}
.qfb-bd-btn:active { background: var(--surface-3, var(--surface-2)); }
.qfb-bd-btn.active {
  border-color: var(--accent);
  color: var(--accent);
  background: rgba(59, 130, 196, 0.08);
}
.qfb-bd-icon { font-size: 0.75rem; opacity: 0.7; }


/* ══════════════════════════════════════
   §19c — Verdict & Explanation
══════════════════════════════════════ */
.qfb-correct {
  font-size: 1rem;
  font-weight: 700;
  color: var(--accent-green);
}
.qfb-wrong {
  font-size: 1rem;
  font-weight: 700;
  color: var(--accent-red);
}
.qfb-correct-ans {
  display: inline-block;
  font-size: var(--text-sm);
  color: var(--text);
  margin-top: 0.2rem;
}
.qfb-correct-ans strong { color: var(--accent-green); }

/* Grammar pattern tag — label utama */
.qfb-grammar-tag {
  display: inline-block;
  font-family: 'BIZ UDGothic', sans-serif;
  font-size: 0.78rem;
  font-weight: 700;
  background: var(--surface-3, var(--surface-2));
  border: 1px solid var(--border-2, var(--border));
  border-radius: 6px;
  padding: 0.2rem 0.65rem;
  color: var(--accent);
  margin-bottom: 0.35rem;
  margin-right: 0.35rem;
}

/* Hasil konjugasi — label sekunder */
.qfb-result-tag {
  display: inline-block;
  font-family: 'BIZ UDGothic', sans-serif;
  font-size: 0.78rem;
  font-weight: 700;
  background: transparent;
  border: 1px solid var(--accent-green);
  border-radius: 6px;
  padding: 0.2rem 0.65rem;
  color: var(--accent-green);
  margin-bottom: 0.35rem;
}

.qfb-expl-text {
  font-size: var(--text-sm);
  color: var(--muted);
  line-height: 1.75;
  margin: 0 0 0.3rem;
}
.qfb-expl-text strong { color: var(--text); font-weight: 700; }

.qfb-translation {
  font-size: var(--text-sm);
  color: var(--muted);
  line-height: 1.6;
  padding: 0.4rem 0.65rem;
  background: var(--surface-3, var(--surface-2));
  border-radius: 6px;
  margin-top: 0.2rem;
}
.qfb-translation em { font-style: normal; color: var(--text); }

/* Reset existing .fill-explanation styling —
   sekarang formatExplanation yang handle semua */
.fill-explanation {
  font-size: var(--text-sm);
  color: var(--muted);
  line-height: 1.7;
  padding: 0;
  background: none;
  border: none;
  margin-bottom: 0;
}


/* ══════════════════════════════════════
   §19d — Sentence Breakdown Block
══════════════════════════════════════ */
.qfb-sentence-block {
  margin: 0.8rem 0 0.9rem;
  padding: 0.75rem 0.9rem;
  background: var(--surface-2);
  border-radius: 10px;
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
}
.qfb-sentence-label {
  font-family: 'DM Sans', sans-serif;
  font-size: 0.58rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 0.5rem;
}
.qfb-sentence-wrap {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}
.qfb-sentence-jp {
  font-family: 'BIZ UDGothic', sans-serif;
  font-size: 1.05rem;
  line-height: 1.9;
  color: var(--text);
}
/* Grammar highlight dalam kalimat */
.qfb-sentence-jp b {
  font-weight: 700;
  text-decoration: underline;
  text-underline-offset: 3px;
  color: var(--accent);
}


/* ══════════════════════════════════════
   §19e — pill-soon (dari patch-A audit)
   Defensive: pastikan tidak bisa diklik
   walau JS masih ada onclick-nya
══════════════════════════════════════ */
.pill-soon {
  opacity: 0.45;
  pointer-events: none;
  position: relative;
}
.pill-soon::after {
  content: 'segera';
  position: absolute;
  top: -0.6rem;
  right: -0.3rem;
  font-size: 0.48rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  background: var(--surface-3, var(--surface-2));
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0.05rem 0.25rem;
  color: var(--muted);
  white-space: nowrap;
}

/* ── TypeTr Quiz ──────────────────────────── */
.ttr-card       { padding: 1.25rem; display: flex; flex-direction: column; gap: .85rem; }
.ttr-label      { font-size: .8rem; color: var(--text-sub); text-transform: uppercase; letter-spacing: .05em; }
.ttr-prompt     { font-size: 1.5rem; font-family: var(--font-jp); line-height: 1.5;
                  color: var(--text); background: var(--card-bg);
                  border-radius: .75rem; padding: 1rem 1.25rem; }
.ttr-input      { width: 100%; padding: .85rem 1rem; font-size: 1rem;
                  border: 2px solid var(--border); border-radius: .75rem;
                  background: var(--input-bg, var(--card-bg)); color: var(--text);
                  resize: vertical; font-family: inherit; transition: border-color .2s; }
.ttr-input:focus{ outline: none; border-color: var(--accent); }
.ttr-hint       { font-size: .78rem; color: var(--accent); background: color-mix(in srgb, var(--accent) 12%, transparent);
                  padding: .3rem .75rem; border-radius: 2rem; align-self: flex-start; }
#typeTrActive .result-pct { font-size: 1.1rem; color: var(--text-sub); margin-top: -.5rem; margin-bottom: 1rem; }

/* ══════════════════════════════════════
   §19f — Vocab Quiz Mode (v14)
   Flashcard, multichoice, fill vocab
══════════════════════════════════════ */

/* ── Vocab Flashcard ───────────────── */
.vq-flash-card {
  background: var(--card-bg);
  border: 1.5px solid var(--border);
  border-radius: 1.25rem;
  padding: 2rem 1.5rem 1.75rem;
  text-align: center;
  cursor: pointer;
  min-height: 200px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  transition: transform 0.15s, box-shadow 0.15s;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}
.vq-flash-card:active { transform: scale(0.98); }

.vq-face { display: flex; flex-direction: column; align-items: center; gap: 0.5rem; width: 100%; }

.vq-word {
  font-family: var(--font-jp);
  font-size: 3rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1.1;
}
.vq-reading {
  font-family: var(--font-jp);
  font-size: 1.1rem;
  color: var(--text-sub);
}
.vq-pos-tag {
  font-size: 0.72rem;
  background: var(--surface-2);
  color: var(--muted);
  border-radius: 1rem;
  padding: 0.15rem 0.65rem;
  margin-top: 0.25rem;
}
.vq-flip-hint {
  font-size: 0.75rem;
  color: var(--accent);
  margin-top: 0.75rem;
  opacity: 0.75;
}
.vq-meaning-big {
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 0.5rem;
}
.vq-ex {
  font-family: var(--font-jp);
  font-size: 0.92rem;
  color: var(--text);
  line-height: 1.75;
}
.vq-ex-id {
  font-size: 0.82rem;
  color: var(--text-sub);
}

/* ── Assess buttons ────────────────── */
.vq-assess-row {
  display: flex;
  gap: 0.6rem;
  margin-top: 1rem;
}
.vq-assess-btn {
  flex: 1;
  padding: 0.8rem 0.5rem;
  border: none;
  border-radius: 0.85rem;
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.15s, transform 0.1s;
}
.vq-assess-btn:active { transform: scale(0.96); }
.vq-btn-forgot { background: var(--danger-dim, #fee2e2); color: #dc2626; }
.vq-btn-unsure { background: var(--warn-dim, #fef3c7);  color: #d97706; }
.vq-btn-know   { background: var(--success-dim); color: var(--success-text); }

/* ── Multichoice word prompt ────────── */
.vq-mc-word {
  font-family: var(--font-jp);
  font-size: 2.25rem;
  font-weight: 700;
  color: var(--text);
  text-align: center;
  margin-bottom: 0.5rem;
}

/* ── Fill-in blank ──────────────────── */
.vq-blank {
  display: inline-block;
  border-bottom: 2.5px solid var(--accent);
  color: var(--accent);
  min-width: 3rem;
  text-align: center;
  letter-spacing: 0.05em;
  font-weight: 700;
}
.vq-blank-filled {
  display: inline-block;
  font-family: var(--font-jp);
  font-weight: 700;
  padding: 0 0.3rem;
  border-radius: 0.3rem;
}
.vq-blank-filled.correct { color: var(--success-text); background: var(--success-dim); }
.vq-blank-filled.wrong   { color: var(--error-text);   background: var(--error-dim); }

/* ── Vocab quiz "segera" tab ─────────── */
.qcat-tab[disabled] {
  opacity: 0.45;
  pointer-events: none;
}

/* ══════════════════════════════════════
   §19g — Browse Vocab Tab (v14)
══════════════════════════════════════ */

/* ── Sub-tabs ──────────────────────── */
.browse-subtabs {
  display: flex;
  gap: 0.4rem;
  padding: 0 0 0.75rem;
  margin: 0 -0.1rem;
}
.browse-subtab {
  flex: 1;
  padding: 0.55rem 0.5rem;
  border: 1.5px solid var(--border);
  border-radius: 0.75rem;
  background: var(--surface-1, var(--bg));
  color: var(--text-sub);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.18s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.3rem;
}
.browse-subtab.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}
.bst-badge {
  background: rgba(255,255,255,0.25);
  color: inherit;
  border-radius: 1rem;
  padding: 0.05rem 0.4rem;
  font-size: 0.72rem;
  font-weight: 700;
}
.browse-subtab:not(.active) .bst-badge {
  background: var(--surface-2);
  color: var(--muted);
}

/* ── Vocab filter bar ──────────────── */
.vocab-filter-bar {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  padding-bottom: 0.5rem;
}
.vocab-pos-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}
.vocab-count-row {
  padding: 0.1rem 0 0.25rem;
}
.browse-count-label {
  font-size: 0.78rem;
  color: var(--muted);
  font-weight: 500;
}

/* ── Vocab cards grid ──────────────── */
.vocab-grid {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  padding-bottom: 5rem;
}
.vb-card {
  background: var(--card-bg);
  border: 1.5px solid var(--border);
  border-radius: 1rem;
  padding: 0.9rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  transition: box-shadow 0.15s;
  cursor: pointer;
}
.vb-card:active { box-shadow: 0 2px 12px rgba(0,0,0,0.08); }

.vb-card-head {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  margin-bottom: 0.2rem;
}
.vb-jlpt-badge {
  font-size: 0.65rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  padding: 0.12rem 0.5rem;
  border-radius: 0.4rem;
}
.vb-jlpt-n5 { background: var(--n5-dim); color: var(--n5); border: 1px solid var(--n5-border); }
.vb-jlpt-n4 { background: var(--n4-dim); color: var(--n4); border: 1px solid var(--n4-border); }
.vb-jlpt-n3 { background: var(--n3-dim); color: var(--n3); border: 1px solid var(--n3-border); }
.vb-jlpt-n2 { background: var(--n2-dim); color: var(--n2); border: 1px solid var(--n2-border); }
.vb-jlpt-n1 { background: var(--n1-dim); color: var(--n1); border: 1px solid var(--n1-border); }

.vb-pos-tag {
  font-size: 0.68rem;
  color: var(--muted);
  background: var(--surface-2);
  border-radius: 0.4rem;
  padding: 0.1rem 0.45rem;
}
.vb-word {
  font-family: var(--font-jp);
  font-size: 1.55rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1.2;
}
.vb-reading {
  font-family: var(--font-jp);
  font-size: 0.88rem;
  color: var(--text-sub);
}
.vb-romaji {
  font-family: inherit;
  font-size: 0.78rem;
  color: var(--muted);
  margin-left: 0.3rem;
}
.vb-meaning {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text);
  margin-top: 0.15rem;
}
.vb-nuance {
  font-size: 0.76rem;
  color: var(--muted);
  line-height: 1.5;
  margin-top: 0.1rem;
}
.vb-ex {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  margin-top: 0.35rem;
  padding-top: 0.35rem;
  border-top: 1px solid var(--border);
}
.vb-ex-jp {
  font-family: var(--font-jp);
  font-size: 0.85rem;
  color: var(--text);
  line-height: 1.7;
}
.vb-ex-id {
  font-size: 0.76rem;
  color: var(--text-sub);
}
.vb-empty {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--muted);
}
.vb-empty .cs-icon { font-size: 2.5rem; margin-bottom: 0.75rem; }
.active-cat { background: var(--accent); color: #fff; border-color: var(--accent); }

/* ══════════════════════════════════════
   §19h — Error Boundary (v14.2)
══════════════════════════════════════ */
#errorRecovery {
  position: fixed; inset: 0; z-index: 9999;
  background: var(--bg);
  display: flex; align-items: center; justify-content: center;
  padding: 1.5rem;
}
.eb-inner {
  max-width: 420px; width: 100%;
  text-align: center;
  display: flex; flex-direction: column; gap: 0.85rem;
}
.eb-icon  { font-size: 3rem; }
.eb-title { font-size: 1.3rem; font-weight: 700; color: var(--text); margin: 0; }
.eb-msg   { font-size: 0.9rem; color: var(--text-sub); line-height: 1.6; margin: 0; }
.eb-detail {
  background: var(--surface-2); border-radius: 0.65rem;
  padding: 0.65rem 0.85rem; text-align: left; font-size: 0.78rem;
}
.eb-detail summary { cursor: pointer; color: var(--muted); }
.eb-detail code    { display: block; margin-top: 0.4rem; word-break: break-all;
                     color: var(--text-sub); font-size: 0.73rem; }
.eb-src { color: var(--muted) !important; margin-top: 0.15rem; }
.eb-actions { display: flex; gap: 0.6rem; }
.eb-btn { flex:1; padding: 0.75rem; border: none; border-radius: 0.75rem;
          font-size: 0.9rem; font-weight: 600; cursor: pointer; }
.eb-btn-primary   { background: var(--accent); color: #fff; }
.eb-btn-secondary { background: var(--surface-2); color: var(--text-sub); }
.eb-warn { font-size: 0.72rem; color: var(--muted); margin: 0; }

/* ══════════════════════════════════════
   §19i — Global Search (v14.2)
══════════════════════════════════════ */
.gs-trigger-btn {
  display: flex; align-items: center; gap: 0.35rem;
  padding: 0.4rem 0.75rem;
  background: var(--surface-2); border: 1.5px solid var(--border);
  border-radius: 2rem; cursor: pointer;
  font-size: 0.8rem; color: var(--text-sub);
  transition: all 0.15s;
}
.gs-trigger-btn:hover { border-color: var(--accent); color: var(--accent); }
.gs-trigger-btn kbd {
  font-size: 0.65rem; background: var(--surface-1, var(--bg));
  border: 1px solid var(--border); border-radius: 0.25rem;
  padding: 0.05rem 0.3rem; color: var(--muted);
  display: none;
}
@media (min-width: 640px) { .gs-trigger-btn kbd { display: inline; } }

.gs-overlay {
  position: fixed; inset: 0; z-index: 800;
  background: rgba(0,0,0,0.75); backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  display: flex; align-items: flex-start; justify-content: center;
  padding: 3rem 1rem 1rem;
  opacity: 0; pointer-events: none;
  transition: opacity 0.18s;
}
.gs-overlay.open { opacity: 1; pointer-events: all; }

.gs-box {
  background: var(--surface); border: 1px solid var(--border-2);
  border-radius: 18px; width: 100%; max-width: 560px;
  overflow: hidden;
  box-shadow: 0 24px 64px rgba(0,0,0,0.6);
  transform: translateY(-10px);
  transition: transform 0.22s cubic-bezier(0.34,1.2,0.64,1);
}
.gs-overlay.open .gs-box { transform: translateY(0); }

.gs-input-row {
  display: flex; align-items: center; gap: 0.6rem;
  padding: 0.85rem 1rem;
  border-bottom: 1.5px solid var(--border);
}
.gs-input {
  flex: 1; border: none; background: transparent;
  font-size: 1rem; color: var(--text);
  outline: none; font-family: inherit;
}
.gs-input::placeholder { color: var(--muted); }
.gs-close-btn {
  background: none; border: none; cursor: pointer;
  color: var(--muted); font-size: 1rem; padding: 0.25rem;
}

.gs-results {
  max-height: 60vh; overflow-y: auto;
  padding: 0.5rem 0;
}
.gs-section-label {
  font-size: 0.72rem; font-weight: 700; letter-spacing: 0.06em;
  color: var(--muted); text-transform: uppercase;
  padding: 0.6rem 1rem 0.3rem;
}
.gs-item {
  display: block; width: 100%; text-align: left;
  padding: 0.6rem 1rem; background: none; border: none;
  cursor: pointer; transition: background 0.12s;
}
.gs-item:hover { background: var(--surface-2); }
.gs-item-main { display: flex; align-items: center; gap: 0.5rem; }
.gs-word { font-family: var(--font-jp); font-size: 1.05rem;
           font-weight: 700; color: var(--text); }
.gs-reading { font-family: var(--font-jp); font-size: 0.82rem; color: var(--text-sub); }
.gs-jlpt-dot {
  font-size: 0.62rem; font-weight: 800;
  padding: 0.08rem 0.4rem; border-radius: 0.3rem;
  margin-left: auto;
}
.gs-jlpt-n5 { background: var(--n5-dim); color: var(--n5); }
.gs-jlpt-n4 { background: var(--n4-dim); color: var(--n4); }
.gs-jlpt-n3 { background: var(--n3-dim); color: var(--n3); }
.gs-jlpt-n2 { background: var(--n2-dim); color: var(--n2); }
.gs-jlpt-n1 { background: var(--n1-dim); color: var(--n1); }
.gs-item-sub { font-size: 0.8rem; color: var(--text-sub); margin-top: 0.15rem; }
.gs-empty {
  padding: 2.5rem 1rem; text-align: center;
  color: var(--muted); font-size: 0.88rem;
}
.gs-empty-icon { font-size: 2rem; margin-bottom: 0.5rem; }

/* ══════════════════════════════════════
   §19j — Vocab Detail Modal (v14.2)
══════════════════════════════════════ */
.vd-modal {
  position: fixed; inset: 0; z-index: 700;
  background: rgba(0,0,0,0.78); backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  display: flex; align-items: flex-end; justify-content: center;
  opacity: 0; pointer-events: none;
  transition: opacity 0.2s;
}
.vd-modal.open { opacity: 1; pointer-events: all; }

.vd-modal-inner {
  background: var(--surface);
  border: 1px solid var(--border-2);
  border-radius: 24px 24px 0 0;
  width: 100%; max-width: 600px;
  max-height: 88dvh; overflow-y: auto;
  padding: 1.25rem 1.25rem 3rem;
  box-shadow: 0 -4px 40px rgba(0,0,0,0.4);
  transform: translateY(40px);
  transition: transform 0.22s cubic-bezier(0.34, 1.56, 0.64, 1);
  position: relative;
}
.vd-modal.open .vd-modal-inner { transform: translateY(0); }

.vd-close-btn {
  position: sticky; top: 0; float: right;
  background: var(--surface-2); border: none;
  width: 2rem; height: 2rem; border-radius: 50%;
  cursor: pointer; font-size: 0.9rem;
  color: var(--text-sub); display: flex;
  align-items: center; justify-content: center;
  margin-bottom: -2rem;
}

/* Header */
.vd-header { margin-bottom: 1rem; }
.vd-header-badges { display: flex; gap: 0.4rem; flex-wrap: wrap; margin-bottom: 0.65rem; }
.vd-common-badge {
  font-size: 0.62rem; font-weight: 700;
  background: var(--accent); color: #fff;
  padding: 0.1rem 0.5rem; border-radius: 1rem;
  letter-spacing: 0.04em;
}
.vd-word { font-family: var(--font-jp); font-size: 2.75rem;
           font-weight: 700; color: var(--text); line-height: 1.1; }
.vd-reading { font-family: var(--font-jp); font-size: 1rem;
              color: var(--text-sub); margin: 0.25rem 0; }
.vd-romaji { font-size: 0.82rem; color: var(--muted); margin-left: 0.4rem; }
.vd-meaning-main { font-size: 1.3rem; font-weight: 700; color: var(--text); margin-top: 0.35rem; }
.vd-meaning-en   { font-size: 0.85rem; color: var(--text-sub); margin-top: 0.1rem; }

/* Sections */
.vd-section { margin-top: 1.1rem; }
.vd-section-row { display: flex; gap: 0.5rem; flex-wrap: wrap; margin-top: 0.65rem; }
.vd-section-title {
  font-size: 0.75rem; font-weight: 700; letter-spacing: 0.05em;
  text-transform: uppercase; color: var(--muted); margin-bottom: 0.5rem;
}
.vd-nuance { font-size: 0.88rem; color: var(--text-sub); line-height: 1.65; }
.vd-meta-chip {
  background: var(--surface-2); border-radius: 1rem;
  padding: 0.3rem 0.75rem; font-size: 0.8rem; color: var(--text-sub);
}

/* Examples */
.vd-example {
  padding: 0.65rem 0;
  border-bottom: 1px solid var(--border);
}
.vd-example:last-child { border-bottom: none; }
.vd-ex-jp {
  font-family: var(--font-jp); font-size: 0.95rem;
  color: var(--text); line-height: 1.75;
}
.vd-ex-id { font-size: 0.82rem; color: var(--text-sub); margin-top: 0.15rem; }
.vd-ex-tags { display: flex; gap: 0.3rem; margin-top: 0.3rem; flex-wrap: wrap; }

/* Tags */
.vd-tag {
  font-size: 0.68rem; background: var(--surface-2);
  color: var(--muted); border-radius: 0.4rem;
  padding: 0.1rem 0.45rem;
}
.vd-tags-row { display: flex; flex-wrap: wrap; gap: 0.35rem; }

/* Relations */
.vd-relation-row {
  display: flex; align-items: center; gap: 0.4rem;
  flex-wrap: wrap; margin-top: 0.4rem;
}
.vd-rel-label { font-size: 0.72rem; color: var(--muted); min-width: 4.5rem; }
.vd-relation-btn {
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 0.5rem; padding: 0.25rem 0.6rem;
  font-family: var(--font-jp); font-size: 0.88rem;
  color: var(--text); cursor: pointer; transition: background 0.12s;
}
.vd-relation-btn:hover { background: color-mix(in srgb, var(--accent) 12%, transparent); }
.vd-rel-reading { font-size: 0.72rem; color: var(--text-sub); margin-left: 0.2rem; }

/* Conjugation */
.vd-conj-grid {
  display: grid; grid-template-columns: 1fr 1fr;
  gap: 0.4rem;
}
.vd-conj-row {
  background: var(--surface-2); border-radius: 0.5rem;
  padding: 0.4rem 0.65rem;
  display: flex; flex-direction: column; gap: 0.1rem;
}
.vd-conj-label { font-size: 0.65rem; color: var(--muted); }
.vd-conj-val   { font-family: var(--font-jp); font-size: 0.95rem;
                 font-weight: 600; color: var(--text); }

/* vb-card tap hint */
.vb-detail-hint {
  margin-left: auto; font-size: 0.75rem;
  color: var(--muted); opacity: 0.6;
}
.vb-card:hover { border-color: var(--accent); }

/* ══════════════════════════════════════════════════
   §19k — Daily Word (v14.3)
   ══════════════════════════════════════════════════ */
.dw-block {
  margin-top: 0.85rem;
  padding: 0.75rem 0.9rem;
  background: color-mix(in srgb, var(--accent) 8%, var(--surface-2));
  border: 1px solid color-mix(in srgb, var(--accent) 25%, transparent);
  border-radius: 0.75rem;
}
.dw-header {
  display: flex; align-items: center; gap: 0.4rem;
  margin-bottom: 0.35rem;
}
.dw-label {
  font-size: 0.7rem; font-weight: 600; letter-spacing: 0.04em;
  color: var(--accent); text-transform: uppercase;
}
.dw-jlpt {
  font-size: 0.62rem; font-weight: 700; padding: 0.05rem 0.35rem;
  border-radius: 0.3rem; border: 1px solid;
}
.dw-jlpt-n5 { background:var(--n5-dim); color:var(--n5); border-color:var(--n5-border); }
.dw-jlpt-n4 { background:var(--n4-dim); color:var(--n4); border-color:var(--n4-border); }
.dw-jlpt-n3 { background:var(--n3-dim); color:var(--n3); border-color:var(--n3-border); }
.dw-jlpt-n2 { background:var(--n2-dim); color:var(--n2); border-color:var(--n2-border); }
.dw-jlpt-n1 { background:var(--n1-dim); color:var(--n1); border-color:var(--n1-border); }
.dw-word {
  font-family: var(--font-jp); font-size: 1.55rem; font-weight: 700;
  color: var(--text); line-height: 1.2;
}
.dw-reading {
  font-family: var(--font-jp); font-size: 0.8rem;
  color: var(--text-sub); margin-top: 0.05rem;
}
.dw-meaning {
  font-size: 0.88rem; color: var(--text); margin-top: 0.3rem;
  font-weight: 500;
}
.dw-ex {
  margin-top: 0.45rem; padding-top: 0.4rem;
  border-top: 1px solid var(--border);
  display: flex; flex-direction: column; gap: 0.1rem;
}
.dw-ex-jp {
  font-family: var(--font-jp); font-size: 0.8rem; color: var(--text);
}
.dw-ex-id { font-size: 0.75rem; color: var(--text-sub); }

/* ══════════════════════════════════════════════════
   §19l — Mixed Quiz Mode (v14.3)
   ══════════════════════════════════════════════════ */
.mx-source-badge {
  font-size: 0.72rem; font-weight: 600; padding: 0.15rem 0.5rem;
  border-radius: 0.4rem; border: 1px solid var(--border);
  background: var(--surface-2); color: var(--text-sub);
}
.mx-src-vocab   { color: var(--n5); background: var(--n5-dim); border-color: var(--n5-border); }
.mx-src-grammar { color: var(--n3); background: var(--n3-dim); border-color: var(--n3-border); }

/* ══════════════════════════════════════
   §20 — Book Filter (TASK-UI-BOOK-FILTER, v14.5)
   ══════════════════════════════════════ */

#vbBookPanel {
  margin-bottom: 0.5rem;
}

/* ── Book pill row ─────────────────── */
.vb-book-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  padding-bottom: 0.5rem;
}
.vb-book-pill {
  padding: 0.45rem 0.75rem;
  border: 1.5px solid var(--border);
  border-radius: 2rem;
  background: var(--surface-1, var(--bg));
  color: var(--text-sub);
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.16s, border-color 0.16s, color 0.16s, opacity 0.16s;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  position: relative;
}
.vb-book-pill.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}
/* Soon pill — bisa diklik, tampilan beda (bukan disabled) */
.vb-book-soon-pill {
  opacity: 0.6;
  border-style: dashed;
}
.vb-book-soon-pill.active {
  opacity: 1;
  border-style: solid;
  background: var(--surface-2);
  color: var(--text-sub);
  border-color: var(--border);
}
.vb-book-soon {
  font-size: 0.62rem;
  font-weight: 700;
  background: var(--surface-2);
  color: var(--muted);
  border-radius: 0.3rem;
  padding: 0.05rem 0.3rem;
  margin-left: 0.1rem;
  letter-spacing: 0.02em;
}
.vb-book-soon-pill.active .vb-book-soon {
  background: var(--accent);
  color: rgba(255,255,255,0.7);
}

/* ── Chapter wrap + controls ───────── */
.vb-chapter-wrap {
  border-top: 1px solid var(--border);
  padding-top: 0.5rem;
  margin-top: 0.1rem;
}
.vb-chapter-controls {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  margin-bottom: 0.4rem;
}
.vb-chapter-label {
  font-size: 0.74rem;
  color: var(--muted);
  font-weight: 600;
}
.vb-ch-ctrl {
  font-size: 0.72rem;
  font-weight: 600;
  padding: 0.2rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: 1rem;
  background: var(--surface-1, var(--bg));
  color: var(--text-sub);
  cursor: pointer;
  transition: all 0.14s;
  min-height: 28px;
}
.vb-ch-ctrl.active-ch-ctrl {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

/* ── Chapter pill strip ────────────── */
.vb-chapter-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
  padding-bottom: 0.25rem;
}
.vb-ch-pill {
  min-width: 2.2rem;
  min-height: 2.2rem;
  padding: 0.2rem 0.4rem;
  border: 1.5px solid var(--border);
  border-radius: 0.5rem;
  background: var(--surface-1, var(--bg));
  color: var(--text-sub);
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.14s;
  text-align: center;
}
.vb-ch-pill.active-ch {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}
/* Chapter soon — buku belum ada data, tapi pill tetap interaktif */
.vb-ch-soon {
  opacity: 0.45;
  border-style: dashed;
}
.vb-ch-soon.active-ch {
  opacity: 0.7;
  background: var(--surface-2);
  color: var(--text-sub);
  border-color: var(--border);
  border-style: solid;
}

/* ── Empty state kontekstual buku ──── */
.vb-empty-book {
  padding: 2.5rem 1rem;
}
.vb-empty-book h3 {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
  margin: 0.4rem 0 0.5rem;
}
.vb-empty-book p {
  font-size: 0.85rem;
  color: var(--text-sub);
  line-height: 1.6;
  margin: 0;
}
.vb-empty-sub {
  font-size: 0.75rem !important;
  color: var(--muted) !important;
  margin-top: 0.5rem !important;
}

/* ══════════════════════════════════════
   §21 — Book Progress (TASK-UI-BOOK-PROGRESS, v14.5)
   ══════════════════════════════════════ */

#vbProgressPanel {
  background: var(--surface-2, var(--card-bg));
  border: 1.5px solid var(--border);
  border-radius: 1rem;
  padding: 0.85rem 1rem;
  margin-bottom: 0.75rem;
}
.vb-prog-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.5rem;
}
.vb-prog-title {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--text-sub);
}
.vb-prog-pct {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--accent);
  white-space: nowrap;
  margin-left: 0.5rem;
}
.vb-prog-bar-wrap { margin-bottom: 0.5rem; }
.vb-prog-bar {
  width: 100%;
  height: 8px;
  border-radius: 4px;
  background: var(--border);
  overflow: hidden;
  display: flex;
}
.vb-prog-fill {
  height: 100%;
  transition: width 0.45s ease;
}
.vb-prog-known    { background: var(--success-text, #22c55e); }
.vb-prog-learning { background: #f59e0b; }
.vb-prog-legend {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex-wrap: wrap;
  font-size: 0.74rem;
  color: var(--text-sub);
}
.vb-prog-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  display: inline-block;
  flex-shrink: 0;
}
.vb-dot-known    { background: var(--success-text, #22c55e); }
.vb-dot-learning { background: #f59e0b; }
.vb-dot-new      { background: var(--border); border: 1px solid var(--muted); }
.vb-prog-total {
  margin-left: auto;
  font-size: 0.72rem;
  color: var(--muted);
}


/* ══════════════════════════════════════════════════════════════════
   AI SENSEI TAB
   ══════════════════════════════════════════════════════════════════ */

.ai-tutor-wrap {
  display: flex;
  flex-direction: column;
  height: calc(100vh - 120px);
  max-width: 680px;
  margin: 0 auto;
  padding: 0 0.5rem;
}

.ai-tutor-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 1rem 0.5rem 0.5rem;
  border-bottom: 1px solid var(--border);
}
.ai-tutor-avatar {
  font-size: 2rem;
  line-height: 1;
}
.ai-tutor-name {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
}
.ai-tutor-tagline {
  font-size: 0.75rem;
  color: var(--muted);
}
.ai-tutor-status {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.72rem;
  color: var(--muted);
}
.ai-status-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: #22c55e;
}
.ai-status-dot--thinking {
  background: #f59e0b;
  animation: pulse 1s infinite;
}
@keyframes pulse {
  0%,100% { opacity: 1; } 50% { opacity: 0.3; }
}

.ai-mode-tabs {
  display: flex;
  gap: 0.4rem;
  padding: 0.5rem 0;
  overflow-x: auto;
}
.ai-mode-tab {
  flex-shrink: 0;
  padding: 0.35rem 0.85rem;
  border-radius: 20px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-sub);
  font-size: 0.8rem;
  cursor: pointer;
  transition: all 0.15s;
}
.ai-mode-tab.active,
.ai-mode-tab:hover {
  background: var(--accent, #3b82f6);
  color: #fff;
  border-color: transparent;
}

.ai-quota-bar {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.3rem 0;
  font-size: 0.72rem;
  color: var(--muted);
}
.ai-quota-track {
  flex: 1;
  height: 4px;
  border-radius: 2px;
  background: var(--border);
  overflow: hidden;
}
.ai-quota-fill {
  height: 100%;
  background: #22c55e;
  border-radius: 2px;
  transition: width 0.4s ease;
}

.ai-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 0.5rem 0;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  scroll-behavior: smooth;
}
.ai-msg {
  display: flex;
  max-width: 90%;
}
.ai-msg--bot  { align-self: flex-start; }
.ai-msg--user { align-self: flex-end; flex-direction: row-reverse; }
.ai-msg-bubble {
  padding: 0.6rem 0.9rem;
  border-radius: 16px;
  font-size: 0.875rem;
  line-height: 1.55;
  color: var(--text);
}
.ai-msg--bot  .ai-msg-bubble { background: var(--surface); border: 1px solid var(--border); border-bottom-left-radius: 4px; }
.ai-msg--user .ai-msg-bubble { background: var(--accent, #3b82f6); color: #fff; border-bottom-right-radius: 4px; }
.ai-msg-bubble--error { background: #fee2e2; color: #991b1b; border-color: #fca5a5; }

.ai-typing {
  display: flex;
  gap: 4px;
  align-items: center;
  padding: 0.75rem 1rem;
}
.ai-typing span {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--muted);
  animation: typing-dot 1.2s infinite;
}
.ai-typing span:nth-child(2) { animation-delay: 0.2s; }
.ai-typing span:nth-child(3) { animation-delay: 0.4s; }
@keyframes typing-dot {
  0%,60%,100% { transform: translateY(0); opacity: 0.4; }
  30%          { transform: translateY(-6px); opacity: 1; }
}

.ai-input-area {
  padding: 0.5rem 0 0.75rem;
  border-top: 1px solid var(--border);
}
.ai-context-chip {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.75rem;
  color: var(--muted);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.25rem 0.6rem;
  margin-bottom: 0.4rem;
  width: fit-content;
}
.ai-ctx-clear {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--muted);
  padding: 0;
  font-size: 0.75rem;
}
.ai-input-row {
  display: flex;
  gap: 0.5rem;
  align-items: flex-end;
}
.ai-input {
  flex: 1;
  padding: 0.6rem 0.8rem;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 0.875rem;
  resize: none;
  line-height: 1.4;
  min-height: 40px;
  max-height: 120px;
  overflow-y: auto;
  font-family: inherit;
}
.ai-input:focus { outline: none; border-color: var(--accent, #3b82f6); }
.ai-send-btn {
  width: 40px; height: 40px;
  border-radius: 50%;
  background: var(--accent, #3b82f6);
  color: #fff;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.15s;
}
.ai-send-btn:hover { background: #2563eb; }
.ai-send-btn:disabled { background: var(--border); cursor: not-allowed; }
.ai-setup-notice {
  font-size: 0.75rem;
  color: var(--muted);
  margin-top: 0.4rem;
  padding: 0.4rem 0.6rem;
  background: #fef9c3;
  border-radius: 8px;
  color: #92400e;
}
.ai-setup-notice a { color: #92400e; }

/* ══════════════════════════════════════════════════════════════════
   STATISTIK TAB
   ══════════════════════════════════════════════════════════════════ */

.stats-wrap {
  padding: 1rem 0.75rem;
  max-width: 680px;
  margin: 0 auto;
}
.stats-header { margin-bottom: 1.25rem; }
.stats-title {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--text);
  margin: 0 0 0.25rem;
}
.stats-subtitle { font-size: 0.8rem; color: var(--muted); }

.stats-row {
  display: grid;
  gap: 0.75rem;
  margin-bottom: 1.25rem;
}
.stats-row--2 { grid-template-columns: 1fr 1fr; }
.stats-row--5 { grid-template-columns: repeat(5, 1fr); }

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1rem 0.75rem;
  text-align: center;
}
.stat-card--highlight { border-color: var(--accent, #3b82f6); }
.stat-card-icon { font-size: 1.5rem; margin-bottom: 0.25rem; }
.stat-card-value { font-size: 1.75rem; font-weight: 800; color: var(--text); }
.stat-card-label { font-size: 0.72rem; color: var(--muted); margin-top: 0.2rem; }

.stat-section { margin-bottom: 1.5rem; }
.stat-section-title {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-sub);
  margin-bottom: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.jlpt-ring-card {
  text-align: center;
  padding: 0.5rem 0.25rem;
}
.jlpt-ring-wrap {
  position: relative;
  width: 52px;
  height: 52px;
  margin: 0 auto 0.35rem;
}
.jlpt-ring-svg {
  width: 52px; height: 52px;
  transform: rotate(-90deg);
}
.jlpt-ring-pct {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.65rem;
  font-weight: 700;
  color: var(--text);
}
.jlpt-ring-label {
  font-size: 0.75rem;
  font-weight: 700;
}
.jlpt-ring-sub {
  font-size: 0.65rem;
  color: var(--muted);
}

.srs-health-grid { display: flex; flex-direction: column; gap: 0.5rem; }
.srs-health-item { display: flex; flex-direction: column; gap: 0.2rem; }
.srs-health-bar-wrap {
  height: 8px;
  background: var(--border);
  border-radius: 4px;
  overflow: hidden;
}
.srs-health-bar {
  height: 100%;
  border-radius: 4px;
  transition: width 0.6s ease;
}
.srs-health-meta {
  display: flex;
  justify-content: space-between;
  font-size: 0.72rem;
}
.srs-health-label { color: var(--text-sub); }
.srs-health-count { color: var(--muted); }

.heatmap-container { overflow-x: auto; }
.heatmap-canvas { display: block; }
.heatmap-legend {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  margin-top: 0.4rem;
  font-size: 0.7rem;
  color: var(--muted);
}
.heatmap-legend-cells { display: flex; gap: 3px; }
.heatmap-legend-cell {
  width: 12px; height: 12px;
  border-radius: 2px;
}

.weak-points-list { display: flex; flex-direction: column; gap: 0.5rem; }
.weak-point-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.6rem 0.75rem;
}
.weak-point-pattern { font-size: 0.9rem; font-weight: 600; color: var(--text); margin-bottom: 0.2rem; }
.weak-point-meta { display: flex; align-items: center; gap: 0.4rem; flex-wrap: wrap; }
.weak-point-meaning { font-size: 0.75rem; color: var(--muted); }
.weak-point-r { font-size: 0.7rem; color: #ef4444; margin-left: auto; }
.pill-mini {
  font-size: 0.62rem;
  font-weight: 700;
  padding: 0.1rem 0.4rem;
  border-radius: 4px;
  color: #fff;
}
.pill-mini--n5 { background: #22c55e; }
.pill-mini--n4 { background: #3b82f6; }
.pill-mini--n3 { background: #f59e0b; }
.pill-mini--n2 { background: #8b5cf6; }
.pill-mini--n1 { background: #ef4444; }

.quiz-accuracy-canvas { display: block; width: 100%; max-width: 400px; }
.stats-empty { font-size: 0.85rem; color: var(--muted); padding: 1rem 0; text-align: center; }

/* ══════════════════════════════════════════════════════════════════
   AUTH MODAL
   ══════════════════════════════════════════════════════════════════ */

.auth-modal {
  background: var(--surface);
  border-radius: 16px;
  padding: 2rem 1.5rem 1.5rem;
  width: min(90vw, 380px);
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}
.auth-header { text-align: center; }
.auth-logo {
  font-size: 2.5rem;
  font-weight: 900;
  line-height: 1;
  margin-bottom: 0.5rem;
}
.auth-title { font-size: 1.1rem; font-weight: 700; color: var(--text); }
.auth-subtitle { font-size: 0.8rem; color: var(--muted); margin-top: 0.2rem; }

.auth-google-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  width: 100%;
  padding: 0.7rem;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s;
}
.auth-google-btn:hover { background: var(--surface); }

.auth-divider {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  color: var(--muted);
  font-size: 0.75rem;
}
.auth-divider::before, .auth-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

.auth-form { display: flex; flex-direction: column; gap: 0.6rem; }
.auth-input {
  width: 100%;
  padding: 0.65rem 0.8rem;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-size: 0.875rem;
  font-family: inherit;
  box-sizing: border-box;
}
.auth-input:focus { outline: none; border-color: var(--accent, #3b82f6); }
.auth-error {
  font-size: 0.8rem;
  color: #dc2626;
  background: #fee2e2;
  padding: 0.4rem 0.6rem;
  border-radius: 8px;
}
.auth-submit-btn {
  width: 100%;
  padding: 0.7rem;
  border-radius: 10px;
  border: none;
  background: var(--accent, #3b82f6);
  color: #fff;
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
}
.auth-submit-btn:hover { background: #2563eb; }
.auth-submit-btn:disabled { background: var(--border); cursor: not-allowed; }

.auth-toggle {
  text-align: center;
  font-size: 0.8rem;
  color: var(--muted);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
}
.auth-toggle-btn {
  background: none;
  border: none;
  color: var(--accent, #3b82f6);
  cursor: pointer;
  font-size: 0.8rem;
  font-weight: 600;
  padding: 0;
}
.auth-offline-note {
  font-size: 0.72rem;
  color: var(--muted);
  text-align: center;
  padding: 0.4rem;
  background: var(--bg);
  border-radius: 8px;
}

/* ══════════════════════════════════════════════════════════════════
   HEADER AUTH BUTTON + SYNC INDICATOR
   ══════════════════════════════════════════════════════════════════ */

.auth-header-btn {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.35rem 0.7rem;
  border-radius: 20px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-sub);
  font-size: 0.75rem;
  cursor: pointer;
  transition: all 0.15s;
}
.auth-header-btn:hover { border-color: var(--accent, #3b82f6); color: var(--accent, #3b82f6); }

.sync-indicator {
  font-size: 1rem;
  cursor: default;
  opacity: 0.7;
}

/* ── §21 Backup Panel ─────────────────────────────────────────── */
.backup-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  overflow: hidden;
}
.backup-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
}
.backup-row:last-of-type { border-bottom: none; }
.backup-info-title {
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--text);
  margin-bottom: 2px;
}
.backup-info-desc {
  font-size: var(--text-xs);
  color: var(--muted);
}
.backup-btn {
  flex-shrink: 0;
  padding: 0.45rem 1rem;
  border-radius: 8px;
  border: 1px solid var(--border-2);
  font-size: var(--text-sm);
  font-weight: 600;
  cursor: pointer;
  min-height: 44px;
  min-width: 90px;
  transition: opacity 0.15s;
}
.backup-btn:active { opacity: 0.7; }
.backup-btn--export {
  background: var(--surface-2);
  color: var(--text);
}
.backup-btn--import {
  background: rgba(59,130,196,0.15);
  color: var(--accent);
  border-color: rgba(59,130,196,0.3);
}
.backup-note {
  padding: 0.85rem 1.25rem;
  font-size: var(--text-xs);
  color: var(--muted);
  line-height: 1.6;
  background: var(--surface-2);
  border-top: 1px solid var(--border);
}

/* ── §22 Category Accordion ───────────────────────────────────── */
.cat-group { margin-top: 4px; }

.cat-group-hdr {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 7px 10px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--text);
  cursor: pointer;
  text-align: left;
  transition: background 0.15s;
  min-height: 44px;
}
.cat-group-hdr:active { background: var(--surface-3); }
.cat-group-hdr.open { border-radius: 8px 8px 0 0; border-bottom-color: transparent; }
.cg-arrow { font-size: 10px; color: var(--muted); transition: transform 0.2s; }
.cat-group-hdr.open .cg-arrow { transform: rotate(90deg); }

.cat-group-body {
  display: none;
  flex-wrap: wrap;
  gap: 6px;
  padding: 8px 10px 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-top: none;
  border-radius: 0 0 8px 8px;
}
.cat-group-body.open { display: flex; }
