:root {
  --bg: #F3F4F7;
  --surface: #FFFFFF;
  --surface-hover: #F7F8FA;
  --surface-active: #EEF0F4;
  --text-primary: #0E1B2E;
  --text-secondary: #5B6A7E;
  --text-muted: #9AA5B4;
  --border: #E1E5EC;
  --border-hover: #CBD2DE;
  --accent: #1B3A66;
  --accent-hover: #14294B;
  --accent-soft: #E8EDF6;
  --accent-2: #4C6C94;
  --review-bar: #12A6E8;
  --review-bar-bg: #BFE7FA;
  --review-new: #3949AB;
  --review-learn: #D32F2F;
  --review-review: #2E7D32;
  --review-again: #D32F2F;
  --review-hard: #37474F;
  --review-good: #43A047;
  --review-easy: #1E88E5;
  --success: #06795E;
  --success-bg: #E7F6F1;
  --success-border: #A8DFCC;
  --danger: #B32424;
  --danger-bg: #FBECEC;
  --danger-border: #F0BDBD;
  --r-sm: 8px;
  --r-md: 12px;
  --r-lg: 16px;
  --r-full: 999px;
  --shadow-sm: 0 1px 2px rgba(14,27,46,.05);
  --shadow-md: 0 6px 16px rgba(14,27,46,.08);
  --ease: cubic-bezier(.4,0,.2,1);
  --ease-out: cubic-bezier(0,0,.2,1);
  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  --fast: 120ms var(--ease);
  --base: 200ms var(--ease);
}
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; -webkit-tap-highlight-color: transparent; }
body {
  font-family: var(--font); background: var(--bg); color: var(--text-primary);
  min-height: 100dvh; line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overscroll-behavior-y: contain;
}
::-webkit-scrollbar { width: 0; height: 0; }

/* Layout */
.app {
  max-width: 430px; margin: 0 auto;
  padding: 0 16px calc(24px + env(safe-area-inset-bottom, 0px));
}

/* Brand header */
.app-header {
  display: flex; align-items: center; justify-content: space-between;
  background: var(--accent);
  margin: 0 -16px; padding: 18px 16px 16px;
  border-radius: 0 0 20px 20px;
}
.app-logo {
  font-size: 1.0625rem; font-weight: 700; color: #fff;
  letter-spacing: -.03em; display: flex; align-items: center; gap: 9px;
  user-select: none;
}
.app-logo-mark {
  width: 30px; height: 30px; border-radius: 9px;
  background: rgba(255,255,255,.14); color: #fff;
  border: 1px solid rgba(255,255,255,.2);
  display: flex; align-items: center; justify-content: center;
  font-size: .875rem; font-weight: 700; letter-spacing: -.02em;
  flex-shrink: 0;
}

/* Plan chip */
.plan-chip {
  font: inherit; font-size: .6875rem; font-weight: 600;
  padding: 6px 13px; border-radius: var(--r-full);
  border: 1px solid rgba(255,255,255,.28); cursor: pointer;
  background: rgba(255,255,255,.1); color: #fff;
  letter-spacing: .04em; text-transform: uppercase;
  transition: all var(--fast);
}
.plan-chip:hover { background: rgba(255,255,255,.18); }
.plan-chip.pro { background: #fff; color: var(--accent); border-color: #fff; }

/* Tabs */
nav.tabs {
  display: flex; gap: 0; margin: 18px 0 24px;
  border-bottom: 1px solid var(--border);
}
nav.tabs button {
  flex: 1; font: inherit; font-size: .8125rem; font-weight: 500;
  padding: 12px 4px; border: none; background: transparent;
  color: var(--text-muted); cursor: pointer;
  border-bottom: 2px solid transparent; margin-bottom: -1px;
  transition: color var(--fast), border-color var(--fast);
  letter-spacing: -.01em;
  position: relative;
}
nav.tabs button:hover { color: var(--text-secondary); }
nav.tabs button.active {
  color: var(--accent); font-weight: 600;
  border-bottom-color: var(--accent);
}
nav.tabs button:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; border-radius: 4px 4px 0 0; }

/* Page transition */
.page-enter { animation: pageIn .22s var(--ease-out); }
@keyframes pageIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Typography */
h2 { font-size: 1.375rem; font-weight: 700; margin-bottom: 4px; color: var(--text-primary); letter-spacing: -.03em; line-height: 1.25; }
.lib-title-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 4px; }
.lib-title-row h2 { margin-bottom: 0; }
.lib-sub-btn { flex-shrink: 0; }
.page-desc { color: var(--text-secondary); font-size: .875rem; margin-bottom: 22px; line-height: 1.5; }
.hint { font-size: .8125rem; color: var(--text-secondary); line-height: 1.45; }
.meta { font-size: .78rem; color: var(--text-secondary); margin-bottom: 6px; }

/* Buttons */
.btn {
  font: inherit; font-size: .8125rem; font-weight: 600; padding: 10px 16px;
  min-height: 40px; border-radius: var(--r-sm); border: none; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  transition: background var(--fast), box-shadow var(--fast), transform var(--fast);
 white-space: nowrap; text-decoration: none;
}
.btn:active:not(:disabled) { transform: scale(.98); }
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.btn svg { width: 16px; height: 16px; flex-shrink: 0; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--accent-hover); }
.btn-secondary { background: var(--surface); color: var(--text-primary); border: 1px solid var(--border); }
.btn-secondary:hover:not(:disabled) { background: var(--surface-hover); border-color: var(--border-hover); }
.btn-sm { padding: 7px 12px; min-height: 34px; font-size: .75rem; gap: 5px; }
.btn-sm svg { width: 14px; height: 14px; }
.btn-block { width: 100%; }
.btn:disabled { opacity: .4; cursor: not-allowed; }

/* Back link */
.back-link {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: .8125rem; font-weight: 500; color: var(--text-secondary);
  cursor: pointer; margin-bottom: 14px; background: none; border: none;
  font-family: inherit; padding: 4px 0; transition: color var(--fast);
}
.back-link:hover { color: var(--text-primary); }
.back-link svg { width: 16px; height: 16px; }

/* Explanation link + panel */
.explain-row { text-align: right; margin: -4px 0 12px; }
.explain-btn {
  display: inline-flex; align-items: center; gap: 4px;
  font: inherit; font-size: .8125rem; font-weight: 500;
  color: var(--text-secondary); background: transparent;
  border: none; cursor: pointer; padding: 4px 0;
  text-decoration: underline; text-underline-offset: 3px;
  text-decoration-color: var(--border-hover);
  transition: color var(--fast), text-decoration-color var(--fast);
}
.explain-btn:hover { color: var(--text-primary); text-decoration-color: var(--text-secondary); }
.explain-panel {
  background: var(--accent-soft); border: 1px solid var(--border);
  border-radius: var(--r-md); padding: 12px 14px; margin: -2px 0 12px;
  font-size: .8125rem; color: var(--text-primary); line-height: 1.5;
}

/* QCM top line: quit on the left, question count on the right */
.qcm-topline { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.qcm-topline .back-link { margin-bottom: 0; }
.qcm-count { font-size: .8125rem; font-weight: 600; color: var(--text-secondary); font-variant-numeric: tabular-nums; }

/* Icon-only button (e.g. previous question) */
.btn-icon { padding: 10px; min-width: 40px; flex-shrink: 0; }
.btn-icon svg { width: 17px; height: 17px; }

/* Secondary action */
.secondary-action {
  display: inline-flex; align-items: center; gap: 4px;
  font: inherit; font-size: .8125rem; font-weight: 500;
  color: var(--text-secondary); background: transparent;
  border: none; cursor: pointer; margin-top: 10px; padding: 8px 0;
  text-decoration: underline; text-underline-offset: 3px;
  text-decoration-color: var(--border-hover);
  transition: color var(--fast), text-decoration-color var(--fast);
}
.secondary-action:hover { color: var(--text-primary); text-decoration-color: var(--text-secondary); }
.secondary-action svg { width: 14px; height: 14px; }

/* Manage top line: back on the left, create action on the right */
.manage-topline { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.manage-topline .back-link { margin-bottom: 0; }
.text-action {
  font: inherit; font-size: .8125rem; font-weight: 600; color: var(--accent);
  background: transparent; border: none; cursor: pointer; padding: 4px 0;
  display: inline-flex; align-items: center; gap: 5px; transition: color var(--fast);
}
.text-action:hover { color: var(--accent-hover); text-decoration: underline; text-underline-offset: 3px; }
.text-action svg { width: 15px; height: 15px; }

/* Editable item row (card / QCM question) inside pack editor */
.item-row {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-md);
  padding: 14px 16px; margin-bottom: 10px; display: flex; align-items: center;
  justify-content: space-between; gap: 10px; box-shadow: var(--shadow-sm);
}
.item-row-main { min-width: 0; flex: 1; }
.item-row-title {
  font-size: .875rem; font-weight: 600; color: var(--text-primary); margin-bottom: 2px;
  overflow: hidden; text-overflow: ellipsis; display: -webkit-box;
  -webkit-line-clamp: 2; -webkit-box-orient: vertical;
}
.item-row-sub { font-size: .78rem; color: var(--text-secondary); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item-row-actions { display: flex; gap: 6px; flex-shrink: 0; }

/* QCM option editor row */
.opt-edit-row { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.opt-edit-row input[type="text"] { margin-bottom: 0; flex: 1; }
.opt-edit-row input[type="checkbox"] { width: 18px; height: 18px; flex-shrink: 0; accent-color: var(--accent); cursor: pointer; }

.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover:not(:disabled) { background: #8f1c1c; }

/* Card */
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-md); padding: 16px; margin-bottom: 12px;
  box-shadow: var(--shadow-sm);
}
.card h3 { font-size: .9375rem; font-weight: 600; color: var(--text-primary); margin-bottom: 4px; letter-spacing: -.01em; }
.desc { font-size: .8125rem; color: var(--text-secondary); line-height: 1.5; margin-bottom: 12px; }

/* Badge */
.badge {
  display: inline-flex; align-items: center; font-size: .6875rem; font-weight: 600;
  padding: 3px 10px; border-radius: var(--r-full);
  background: var(--accent-soft); color: var(--accent);
  letter-spacing: .01em;
}
.badge-success { background: var(--success-bg); color: var(--success); }

/* Search */
.search-box {
  display: flex; align-items: stretch; border: 1px solid var(--border); border-radius: var(--r-lg);
  overflow: hidden; margin-bottom: 16px; background: var(--surface);
}
.search-box-input-wrap { position: relative; flex: 1; display: flex; align-items: center; min-width: 0; }
.search-box-input-wrap svg {
  position: absolute; left: 17px; top: 50%; transform: translateY(-50%);
  width: 16px; height: 16px; color: var(--text-muted); pointer-events: none;
}
.search-box input {
  border: none; outline: none; flex: 1; width: 100%; margin: 0 !important; padding: 15px 10px 15px 46px !important; box-shadow: none !important;
  font: inherit; font-size: .9375rem; background: transparent; color: var(--text-primary);
  -webkit-appearance: none; appearance: none; border-radius: 0 !important; min-width: 0;
}
.search-box input::placeholder { color: var(--text-muted); }
.search-box button {
  background: var(--accent); color: #fff; border: none; outline: none; padding: 0 26px;
  font-weight: 700; cursor: pointer; font: inherit; font-size: .875rem;
  white-space: nowrap; transition: background var(--fast); flex-shrink: 0;
  -webkit-appearance: none; appearance: none; border-radius: 0;
  display: flex; align-items: center; justify-content: center;
}
.search-box button:hover { background: var(--accent-hover); }

/* Category links */
.cat-chips {
  display: flex; align-items: center; flex-wrap: nowrap;
  gap: 10px; margin-bottom: 18px;
  overflow-x: auto; -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.cat-chips::-webkit-scrollbar { display: none; }
.cat-chip {
  font: inherit; font-size: .8125rem; font-weight: 500;
  padding: 4px 1px; flex-shrink: 0;
  border: none; background: none;
  color: var(--text-secondary); cursor: pointer; transition: color var(--fast);
  border-bottom: 2px solid transparent;
}
.cat-chip:hover { color: var(--text-primary); }
.cat-chip.active {
  color: var(--accent); font-weight: 600; border-bottom-color: var(--accent);
}
.cat-chip-sep { color: var(--border-hover); flex-shrink: 0; font-size: .75rem; }

/* Mode card (action tile) */
.mode-list { display: flex; flex-direction: column; gap: 10px; margin-bottom: 16px; }
.mode-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-lg); padding: 16px 18px;
  cursor: pointer; text-align: left; font: inherit; color: inherit; width: 100%;
  transition: border-color var(--fast), box-shadow var(--fast), transform var(--fast);
 box-shadow: var(--shadow-sm);
}
.mode-card:hover { border-color: var(--border-hover); box-shadow: var(--shadow-md); }
.mode-card:active { transform: scale(.99); }
.mode-card .t { font-weight: 600; font-size: .9375rem; color: var(--text-primary); margin-bottom: 3px; letter-spacing: -.02em; }
.mode-card .d { font-size: .8125rem; color: var(--text-secondary); line-height: 1.45; }

/* Library card */
.lib-quota { font-size: .8125rem; color: var(--text-muted); margin-bottom: 16px; line-height: 1.5; }
.lib-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-lg); padding: 18px 18px 16px; margin-bottom: 12px;
  box-shadow: var(--shadow-sm); transition: border-color var(--fast), box-shadow var(--fast);
}
.lib-card:hover { border-color: var(--border-hover); box-shadow: var(--shadow-md); }
.lib-card h3 { font-size: 1rem; font-weight: 600; color: var(--text-primary); letter-spacing: -.02em; margin-bottom: 6px; }
.lib-card .meta { font-size: .8125rem; color: var(--text-secondary); margin-bottom: 4px; }
.lib-card .desc { font-size: .8125rem; color: var(--text-secondary); line-height: 1.45; margin-bottom: 0; }
.lib-card-actions { padding-top: 14px; border-top: 1px solid var(--border); margin-top: 14px; }

/* QCM question card */
.qcm-card {
  background: var(--accent); color: #fff; border-radius: var(--r-lg);
  padding: 28px 24px; margin-bottom: 18px; box-shadow: var(--shadow-md);
  min-height: 148px; display: flex; align-items: center;
}
.qcm-question { font-size: 1.25rem; font-weight: 600; line-height: 1.5; letter-spacing: -.01em; }

/* QCM options */
.opt-list { display: flex; flex-direction: column; gap: 9px; margin-bottom: 16px; }
.opt-row {
  display: flex; align-items: center; gap: 12px; width: 100%;
  text-align: left; padding: 12px 14px; border: 1px solid var(--border);
  border-radius: var(--r-md); background: var(--surface);
  font: inherit; cursor: pointer; color: var(--text-primary);
  box-shadow: var(--shadow-sm);
  transition: border-color var(--fast), background var(--fast), transform var(--fast);
}
.opt-row:hover:not(:disabled) { border-color: var(--border-hover); background: var(--surface-hover); }
.opt-row:active:not(:disabled) { transform: scale(.99); }
.opt-row:disabled { cursor: default; }
.opt-flag {
  width: 4px; align-self: stretch; border-radius: var(--r-full);
  background: var(--border); flex-shrink: 0; transition: background var(--fast);
}
.opt-letter { font-size: .8125rem; font-weight: 700; color: var(--text-muted); flex-shrink: 0; transition: color var(--fast); }
.opt-label { flex: 1; font-size: .9375rem; line-height: 1.4; }
.opt-check {
  width: 22px; height: 22px; border-radius: 6px; flex-shrink: 0;
  border: 1.5px solid var(--border-hover); display: flex; align-items: center;
  justify-content: center; color: transparent; transition: all var(--fast);
}
.opt-check svg { width: 13px; height: 13px; stroke-width: 3; }

.opt-row.selected { border-color: var(--accent); background: var(--accent-soft); }
.opt-row.selected .opt-letter { color: var(--accent); }
.opt-row.selected .opt-check { background: var(--accent); border-color: var(--accent); color: #fff; }

.opt-row.correct { border-color: var(--success-border); background: var(--success-bg); }
.opt-row.correct .opt-flag { background: var(--success); }
.opt-row.correct .opt-letter, .opt-row.correct .opt-label { color: var(--success); font-weight: 600; }
.opt-row.correct .opt-check { background: var(--success); border-color: var(--success); color: #fff; }

.opt-row.wrong { border-color: var(--danger-border); background: var(--danger-bg); }
.opt-row.wrong .opt-flag { background: var(--danger); }
.opt-row.wrong .opt-letter, .opt-row.wrong .opt-label { color: var(--danger); font-weight: 600; }
.opt-row.wrong .opt-check { background: var(--danger); border-color: var(--danger); color: #fff; }


/* Form elements */
label {
  display: block; font-size: .75rem; font-weight: 600; color: var(--text-secondary);
  margin-bottom: 6px; letter-spacing: .01em;
}
input[type="text"], select {
  font: inherit; font-size: .875rem; padding: 11px 12px;
  border: 1px solid var(--border); border-radius: var(--r-sm);
  background: var(--surface); color: var(--text-primary); width: 100%;
  margin-bottom: 14px; transition: border-color var(--fast), box-shadow var(--fast);
}
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(11,17,32,.08);
}
select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%235F6B7A' d='M2.5 4.5L6 8l3.5-3.5'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center;
  padding-right: 36px; cursor: pointer;
}
textarea {
  font: inherit; font-size: .875rem; padding: 12px; border: 1px solid var(--border);
  border-radius: var(--r-sm); background: var(--surface); color: var(--text-primary);
  width: 100%; min-height: 140px; resize: vertical; margin-bottom: 14px; line-height: 1.5;
}

/* Auth box */
.auth-box {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-lg); padding: 20px; margin-bottom: 16px; box-shadow: var(--shadow-sm);
}

/* Subscription formula/duration selector */
.choice-row { display: flex; gap: 8px; margin-bottom: 14px; }
.choice-btn {
  flex: 1; font: inherit; font-size: .8125rem; font-weight: 600; padding: 10px 6px;
  border-radius: var(--r-sm); border: 1px solid var(--border); background: var(--surface);
  color: var(--text-secondary); cursor: pointer; transition: all var(--fast);
}
.choice-btn:hover { border-color: var(--border-hover); }
.choice-btn.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.price-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 6px 2px 14px; font-size: .875rem; color: var(--text-secondary);
}
.price-row strong { color: var(--text-primary); font-size: 1.0625rem; }

/* Support links */
.support-list { display: flex; flex-direction: column; gap: 10px; }
.support-link {
  display: flex; align-items: center; gap: 14px;
  padding: 14px 16px; border-radius: var(--r-md);
  border: 1px solid var(--border); background: var(--surface);
  text-decoration: none; color: var(--text-primary); transition: all var(--fast);
  font-weight: 500; font-size: .875rem; box-shadow: var(--shadow-sm);
}
.support-link:hover { border-color: var(--border-hover); background: var(--surface-hover); }
.support-ico {
  width: 40px; height: 40px; border-radius: var(--r-sm);
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.support-ico svg { width: 18px; height: 18px; }
.support-ico.phone { background: var(--accent-soft); color: var(--accent); }
.support-ico.wa { background: var(--success-bg); color: var(--success); }
.support-ico.web { background: var(--accent-soft); color: var(--accent-2); }
.support-meta { flex: 1; min-width: 0; }
.support-meta strong { display: block; font-size: .875rem; color: var(--text-primary); font-weight: 600; }
.support-meta span { font-size: .75rem; color: var(--text-secondary); font-weight: 400; }

/* Empty state */
.empty {
  text-align: center; padding: 40px 20px; color: var(--text-muted);
}
.empty svg { width: 48px; height: 48px; color: var(--border-hover); margin-bottom: 14px; }
.empty p { font-size: .875rem; line-height: 1.55; margin: 0; }
.empty p strong { color: var(--text-secondary); font-weight: 600; }

/* Pagination */
.pagination {
  display: flex; align-items: center; justify-content: center; gap: 12px; margin-top: 20px;
}

/* Progress bar */
.progress-track {
 height: 4px; background: var(--border); border-radius: 2px;
  margin-bottom: 18px; overflow: hidden;
}
.progress-fill {
 height: 100%; background: var(--accent); border-radius: 2px;
  transition: width .35s var(--ease-out);
}

/* Review screen (AnkiDroid-style) */
.review-screen {
  margin: 0 -16px; display: flex; flex-direction: column;
  min-height: 100dvh;
  transition: background var(--fast), color var(--fast);
}
.app--review { padding-top: 0; padding-bottom: 0; }

/* ===== Dark mode toggle button (used in both cards & QCM review) ===== */
.dark-toggle {
  display: inline-flex; align-items: center; justify-content: center;
  width: 34px; height: 34px; border-radius: var(--r-full);
  background: rgba(14,27,46,.06); color: var(--text-secondary);
  border: none; cursor: pointer; flex-shrink: 0;
  transition: background var(--fast), color var(--fast);
}
.dark-toggle:hover { background: rgba(14,27,46,.12); color: var(--text-primary); }
.dark-toggle svg { width: 17px; height: 17px; }
.dark-toggle:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ===== DARK MODE — scoped to review screens only ===== */
/* Cards review (AnkiDroid-style screen) */
.review-screen.dark {
  background: #0F1621;
}
.review-screen.dark .review-topline {
  background: #17202D;
}
.review-screen.dark .review-topline .back-link { color: #B8C2D0; }
.review-screen.dark .review-topline .back-link:hover { color: #FFFFFF; }
.review-screen.dark .rc { color: #5B6A7E; }
.review-screen.dark .rc-new.active { color: #7C8CF5; }
.review-screen.dark .rc-learn.active { color: #FF6B6B; }
.review-screen.dark .rc-review.active { color: #66BB6A; }
.review-screen.dark .rc-new:not(.active) { color: #7C8CF5; }
.review-screen.dark .rc-learn:not(.active) { color: #FF6B6B; }
.review-screen.dark .rc-review:not(.active) { color: #66BB6A; }
.review-screen.dark .review-question,
.review-screen.dark .review-answer { color: #ECEFF4; }
.review-screen.dark .review-divider { background: #2A3446; }
.review-screen.dark .dark-toggle {
  background: rgba(255,255,255,.08); color: #B8C2D0;
}
.review-screen.dark .dark-toggle:hover { background: rgba(255,255,255,.14); color: #FFFFFF; }

/* QCM review dark mode (scoped via .qcm-review-dark on the app root) */
.app.qcm-review-dark {
  background: #0F1621;
}
.app.qcm-review-dark .qcm-topline .back-link { color: #B8C2D0; }
.app.qcm-review-dark .qcm-topline .back-link:hover { color: #FFFFFF; }
.app.qcm-review-dark .qcm-count { color: #B8C2D0; }
.app.qcm-review-dark .progress-track { background: #2A3446; }
.app.qcm-review-dark .progress-fill { background: #4C6C94; }
.app.qcm-review-dark .qcm-card {
  background: #17202D; color: #ECEFF4;
  box-shadow: 0 6px 16px rgba(0,0,0,.4);
}
.app.qcm-review-dark .hint { color: #9AA5B4; }
.app.qcm-review-dark .opt-row {
  background: #17202D; color: #ECEFF4;
  border-color: #2A3446;
  box-shadow: 0 1px 2px rgba(0,0,0,.3);
}
.app.qcm-review-dark .opt-row:hover:not(:disabled) {
  background: #1D2837; border-color: #3A4658;
}
.app.qcm-review-dark .opt-flag { background: #2A3446; }
.app.qcm-review-dark .opt-letter { color: #9AA5B4; }
.app.qcm-review-dark .opt-check {
  border-color: #3A4658;
}
.app.qcm-review-dark .opt-row.selected {
  background: #1E2A47; border-color: #4C6C94;
}
.app.qcm-review-dark .opt-row.selected .opt-letter { color: #8BA9D4; }
.app.qcm-review-dark .opt-row.selected .opt-check {
  background: #4C6C94; border-color: #4C6C94; color: #fff;
}
.app.qcm-review-dark .opt-row.correct {
  background: #14352A; border-color: #2E7D32;
}
.app.qcm-review-dark .opt-row.correct .opt-flag { background: #66BB6A; }
.app.qcm-review-dark .opt-row.correct .opt-letter,
.app.qcm-review-dark .opt-row.correct .opt-label { color: #A5D6A7; }
.app.qcm-review-dark .opt-row.correct .opt-check {
  background: #2E7D32; border-color: #2E7D32; color: #fff;
}
.app.qcm-review-dark .opt-row.wrong {
  background: #3B1A1A; border-color: #B32424;
}
.app.qcm-review-dark .opt-row.wrong .opt-flag { background: #FF6B6B; }
.app.qcm-review-dark .opt-row.wrong .opt-letter,
.app.qcm-review-dark .opt-row.wrong .opt-label { color: #FFB4B4; }
.app.qcm-review-dark .opt-row.wrong .opt-check {
  background: #B32424; border-color: #B32424; color: #fff;
}
.app.qcm-review-dark .explain-panel {
  background: #1E2A47; border-color: #2A3446; color: #ECEFF4;
}
.app.qcm-review-dark .explain-btn { color: #B8C2D0; text-decoration-color: #3A4658; }
.app.qcm-review-dark .explain-btn:hover { color: #FFFFFF; text-decoration-color: #B8C2D0; }
.app.qcm-review-dark .btn-secondary {
  background: #17202D; color: #ECEFF4; border-color: #2A3446;
}
.app.qcm-review-dark .btn-secondary:hover:not(:disabled) {
  background: #1D2837; border-color: #3A4658;
}
.app.qcm-review-dark .btn-primary {
  background: #4C6C94;
}
.app.qcm-review-dark .btn-primary:hover:not(:disabled) {
  background: #5C7CA4;
}
.app.qcm-review-dark .dark-toggle {
  background: rgba(255,255,255,.08); color: #B8C2D0;
}
.app.qcm-review-dark .dark-toggle:hover { background: rgba(255,255,255,.14); color: #FFFFFF; }
@media (min-width: 431px) {
  .app.qcm-review-dark { background: #0F1621; }
}
.review-topbar {
  height: 4px; background: var(--review-bar);
  transition: width .3s var(--ease-out);
}
.review-topline {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  background: var(--review-bar-bg); padding: 11px 16px;
}
.review-topline .back-link { margin-bottom: 0; color: var(--text-secondary); }
.review-topline .back-link:hover { color: var(--text-primary); }

/* Review display controls: font size (A- / A+) and bold toggle */
.review-topline-actions { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }
.review-display-controls { display: inline-flex; align-items: center; gap: 4px; }
.rdc-btn {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 30px; height: 34px; padding: 0 7px; border-radius: var(--r-full);
  background: rgba(14,27,46,.06); color: var(--text-secondary);
  border: none; cursor: pointer; font: inherit;
  font-size: .75rem; font-weight: 700; letter-spacing: .01em;
  transition: background var(--fast), color var(--fast);
}
.rdc-btn:hover:not(:disabled) { background: rgba(14,27,46,.12); color: var(--text-primary); }
.rdc-btn:disabled { opacity: .35; cursor: default; }
.rdc-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.rdc-btn.rdc-bold.active { background: var(--accent); color: #fff; }
.review-screen.dark .rdc-btn,
.app.qcm-review-dark .rdc-btn { background: rgba(255,255,255,.08); color: #B8C2D0; }
.review-screen.dark .rdc-btn:hover:not(:disabled),
.app.qcm-review-dark .rdc-btn:hover:not(:disabled) { background: rgba(255,255,255,.14); color: #FFFFFF; }
.review-screen.dark .rdc-btn.rdc-bold.active,
.app.qcm-review-dark .rdc-btn.rdc-bold.active { background: #4C6C94; color: #fff; }
.review-counts {
  display: flex; align-items: center; gap: 20px;
  font-size: .9375rem; font-weight: 700; font-variant-numeric: tabular-nums;
}
.rc { color: var(--text-muted); transition: color var(--fast); }
.rc-new.active { color: var(--review-new); text-decoration: underline; text-decoration-thickness: 2px; text-underline-offset: 3px; }
.rc-learn.active { color: var(--review-learn); text-decoration: underline; text-decoration-thickness: 2px; text-underline-offset: 3px; }
.rc-review.active { color: var(--review-review); text-decoration: underline; text-decoration-thickness: 2px; text-underline-offset: 3px; }
.rc-new:not(.active) { color: var(--review-new); }
.rc-learn:not(.active) { color: var(--review-learn); }
.rc-review:not(.active) { color: var(--review-review); }
.review-content { flex: 1; padding: 0 16px; display: flex; flex-direction: column; }
.review-question {
  font-size: 1.5rem; font-weight: 500; line-height: 1.4; color: var(--text-primary);
  text-align: center; padding: 30px 4px 18px;
}
.review-divider { height: 1px; background: var(--border); margin: 2px 0 22px; }
.review-answer {
  font-size: 1.5rem; font-weight: 500; line-height: 1.4; color: var(--text-primary);
  text-align: center;
}
.review-footer { margin-top: auto; }
.review-showbtn {
  width: 100%; border: none; background: var(--review-hard); color: #fff;
  font: inherit; font-size: .875rem; font-weight: 600; letter-spacing: .01em;
  padding: 13px 16px calc(13px + env(safe-area-inset-bottom, 0px));
  cursor: pointer; transition: background var(--fast);
}
.review-showbtn:hover { background: #2C363D; }
.review-grade-bar { display: flex; }
.review-grade-btn {
  flex: 1; border: none; color: #fff; cursor: pointer; font: inherit;
  padding: 9px 4px calc(9px + env(safe-area-inset-bottom, 0px));
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  transition: filter var(--fast);
}
.review-grade-btn:active { filter: brightness(.92); }
.review-grade-btn .ivl { font-size: .8125rem; font-weight: 700; }
.review-grade-btn .lbl { font-size: .75rem; font-weight: 500; }
.grade-again { background: var(--review-again); }
.grade-hard { background: var(--review-hard); }
.grade-good { background: var(--review-good); }
.grade-easy { background: var(--review-easy); }
.review-empty { text-align: center; padding: 60px 20px; color: var(--text-muted); }
.review-empty svg { width: 48px; height: 48px; color: var(--border-hover); margin-bottom: 14px; }
.review-empty p { font-size: .875rem; line-height: 1.55; margin: 0; }

/* Toast */
.toast {
  position: fixed; left: 50%; bottom: 24px;
  transform: translateX(-50%) translateY(120%);
  background: var(--accent); color: #fff; padding: 12px 18px;
  border-radius: var(--r-full); font-size: .8125rem; font-weight: 500;
  z-index: 100; transition: transform .3s var(--ease);
  max-width: 90%; pointer-events: none;
  box-shadow: 0 10px 24px rgba(14,27,46,.28);
  display: flex; align-items: center; gap: 8px;
}
.toast.show { transform: translateX(-50%) translateY(0); }
.toast svg { width: 16px; height: 16px; flex-shrink: 0; }

/* Modal */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(11,17,32,.45); backdrop-filter: blur(4px);
  z-index: 100; display: flex; align-items: center; justify-content: center;
  opacity: 0; visibility: hidden; transition: opacity .2s var(--ease), visibility .2s;
}
.modal-overlay.open { opacity: 1; visibility: visible; }
.modal {
  background: var(--surface); border-radius: var(--r-lg); padding: 28px 24px;
  max-width: 360px; width: calc(100% - 32px); box-shadow: 0 12px 32px rgba(11,17,32,.18);
  transform: scale(.96) translateY(8px); transition: transform .25s var(--ease-out);
}
.modal-overlay.open .modal { transform: scale(1) translateY(0); }
.modal h3 { font-size: 1rem; font-weight: 700; margin-bottom: 8px; }
.modal p { font-size: .875rem; color: var(--text-secondary); line-height: 1.5; margin-bottom: 20px; }
.modal-actions { display: flex; flex-direction: column-reverse; gap: 8px; }
.modal-actions .btn { width: 100%; }

/* Star indicator */
.correct-indicator { color: var(--success); font-size: .75rem; font-weight: 700; margin-left: 4px; }

/* Responsive */
@media (min-width: 431px) {
  body { background: #E8E9EC; }
  .app { background: var(--bg); box-shadow: var(--shadow-md); border-radius: var(--r-lg); margin-top: 0; min-height: 100dvh; }
}

/* Landscape / short-viewport phones: use more of the available width,
   and tighten vertical spacing so the review screen fills the screen
   instead of leaving empty space above/below. */
@media (orientation: landscape) and (max-height: 520px) {
  .app { max-width: min(760px, 96vw); }
  .app-header { padding: 10px 16px 10px; border-radius: 0 0 14px 14px; }
  nav.tabs { margin: 10px 0 14px; }
  .review-question, .review-answer { padding: 14px 4px 10px; }
  .rdc-btn { min-width: 26px; height: 30px; padding: 0 5px; font-size: .7rem; }
  .review-divider { margin: 2px 0 12px; }
  .review-content { justify-content: center; }
  .review-topline { padding: 8px 16px; }
  .review-showbtn { padding: 10px 16px calc(10px + env(safe-area-inset-bottom, 0px)); }
  .review-grade-btn { padding: 7px 4px calc(7px + env(safe-area-inset-bottom, 0px)); }
}
@media (min-width: 600px) {
  .app { max-width: 480px; }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
  html { scroll-behavior: auto; }
}

/* QCM multi-answer: make selection visibly checkable and accessible. */
.qcm-checkbox{display:inline-flex;align-items:center;justify-content:center;width:18px;height:18px;border:2px solid currentColor;border-radius:4px;margin-right:6px;vertical-align:middle}
.qcm-checkbox svg{width:13px;height:13px}
.opt-row[aria-pressed="true"] .qcm-checkbox{background:currentColor}
.opt-row[aria-pressed="true"] .qcm-checkbox svg{color:var(--surface,#fff)}
