/* ==========================================================================
   VOCAB QUIZ — theme tokens, layout, components.
   Themes are data-theme on <html>; font scale is data-font.
   ========================================================================== */

:root {
  --bg: #0b1220;
  --bg-elev: #111a2e;
  --card: #131d33;
  --border: #22304f;
  --text: #e8eefc;
  --text-sub: #a9b8d8;
  --text-muted: #7c8bad;
  --accent: #818cf8;
  --accent-strong: #6366f1;
  --accent-ink: #fff;
  --success: #34d399;
  --danger: #f87171;
  --warn: #fbbf24;
  --chip-bg: #e8edf7;
  --chip-ink: #1e293b;
  --correct-bg: #0e2a1f;
  --correct-border: #1f7a52;
  --correct-ink: #86efac;
  --wrong-bg: #2c1418;
  --wrong-border: #8a2b35;
  --wrong-ink: #fca5a5;
  --shadow: 0 10px 30px rgba(0, 0, 0, .35);
  --radius: 16px;
  --font-scale: 1;
}

:root[data-theme="bright"] {
  --bg: #f4f6fb; --bg-elev: #fff; --card: #fff; --border: #dde3ee;
  --text: #0f172a; --text-sub: #475569; --text-muted: #7b899f;
  --accent: #4f46e5; --accent-strong: #4338ca; --accent-ink: #fff;
  --chip-bg: #eef2f9; --chip-ink: #1e293b;
  --correct-bg: #ecfdf5; --correct-border: #6ee7b7; --correct-ink: #065f46;
  --wrong-bg: #fef2f2; --wrong-border: #fca5a5; --wrong-ink: #991b1b;
  --shadow: 0 8px 24px rgba(15, 23, 42, .08);
}

:root[data-theme="navy"] {
  --bg: #071a2f; --bg-elev: #0b2342; --card: #0d2a4e; --border: #1b4067;
  --text: #e6f1ff; --text-sub: #a8c4e4; --text-muted: #7396bd;
  --accent: #38bdf8; --accent-strong: #0ea5e9; --accent-ink: #052034;
  --chip-bg: #dbeafe; --chip-ink: #0c2d48;
  --correct-bg: #06291f; --correct-border: #1c7a5a; --correct-ink: #7ce0b8;
  --wrong-bg: #2a1220; --wrong-border: #8f2f4a; --wrong-ink: #ffa8bf;
}

:root[data-theme="forest"] {
  --bg: #0c1a12; --bg-elev: #12261a; --card: #163020; --border: #244c31;
  --text: #e8f6ea; --text-sub: #aacfb3; --text-muted: #7fae8c;
  --accent: #6ee7a0; --accent-strong: #34d399; --accent-ink: #06281a;
  --chip-bg: #e3f4e7; --chip-ink: #14371f;
  --correct-bg: #0d3320; --correct-border: #2f8f5b; --correct-ink: #9df0be;
  --wrong-bg: #2e1616; --wrong-border: #8f3a34; --wrong-ink: #ffb0a6;
}

:root[data-theme="sepia"] {
  --bg: #f3ead9; --bg-elev: #fbf5e9; --card: #fffaf0; --border: #e0d2b8;
  --text: #3a2f21; --text-sub: #6b5946; --text-muted: #8d7a63;
  --accent: #b45309; --accent-strong: #92400e; --accent-ink: #fff;
  --chip-bg: #efe3cc; --chip-ink: #4a3a26;
  --correct-bg: #e8f3e2; --correct-border: #94b87f; --correct-ink: #35521f;
  --wrong-bg: #f8e4e0; --wrong-border: #cf9b90; --wrong-ink: #7c2d20;
  --shadow: 0 8px 24px rgba(90, 70, 40, .12);
}

:root[data-font="xs"]     { --font-scale: .78; }
:root[data-font="small"]  { --font-scale: .9; }
:root[data-font="medium"] { --font-scale: 1; }
:root[data-font="large"]  { --font-scale: 1.18; }
:root[data-font="xl"]     { --font-scale: 1.36; }

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Pretendard", "Apple SD Gothic Neo", "Malgun Gothic",
               system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: calc(16px * var(--font-scale));
  line-height: 1.55;
  -webkit-text-size-adjust: 100%;
}

body { min-height: 100dvh; }

.boot {
  display: grid;
  place-items: center;
  min-height: 60dvh;
  color: var(--text-muted);
}

/* ── Layout ─────────────────────────────────────────────────────────── */

.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  padding-top: max(10px, env(safe-area-inset-top));
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}

.topbar-title {
  font-weight: 800;
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#view {
  max-width: 820px;
  margin: 0 auto;
  padding: 16px 14px 64px;
}

#sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: min(300px, 84vw);
  z-index: 50;
  transform: translateX(-102%);
  transition: transform .22s ease;
  background: var(--bg-elev);
  border-right: 1px solid var(--border);
  padding: 14px;
  padding-top: max(14px, env(safe-area-inset-top));
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

#sidebar.open { transform: none; }

.scrim {
  position: fixed;
  inset: 0;
  z-index: 40;
  background: rgba(0, 0, 0, .45);
}

.side-head { display: flex; align-items: center; justify-content: space-between; }
.side-label { display: grid; gap: 4px; font-size: .78em; color: var(--text-muted); font-weight: 700; }
.side-foot { margin-top: auto; }

.nav { display: grid; gap: 4px; }

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 10px 12px;
  border: 0;
  border-radius: 12px;
  background: transparent;
  color: var(--text-sub);
  font: inherit;
  font-weight: 700;
  text-align: left;
  cursor: pointer;
}

.nav-item:hover { background: color-mix(in srgb, var(--accent) 12%, transparent); color: var(--text); }
.nav-item.active { background: var(--accent-strong); color: var(--accent-ink); }
.nav-icon { font-size: 1.05em; }

.side-stats { display: grid; gap: 6px; padding-top: 8px; border-top: 1px solid var(--border); }
.side-stat { font-size: .85em; color: var(--text-sub); }

/* ── Cards & type ───────────────────────────────────────────────────── */

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  margin-bottom: 16px;
}

.sub-card { box-shadow: none; background: var(--bg-elev); margin: 12px 0; }

.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--accent) 22%, transparent);
  color: var(--accent);
  font-size: .72em;
  font-weight: 800;
  letter-spacing: .06em;
}

.title { font-size: 1.7em; font-weight: 900; margin: 10px 0 4px; line-height: 1.2; }
.sub { color: var(--text-sub); font-size: .9em; margin: 0 0 12px; }
.muted { color: var(--text-muted); }
.small { font-size: .84em; }
.center { text-align: center; }
.accent { color: var(--accent); }
.warn { color: var(--warn); font-size: .9em; }

.field-label {
  font-size: .82em;
  font-weight: 800;
  letter-spacing: .04em;
  color: var(--text-sub);
  margin: 18px 0 8px;
}

.info {
  padding: 12px 14px;
  border-radius: 12px;
  background: color-mix(in srgb, var(--accent) 12%, transparent);
  border: 1px solid color-mix(in srgb, var(--accent) 30%, transparent);
  color: var(--text-sub);
  font-size: .9em;
}

.err { white-space: pre-wrap; font-size: .8em; color: var(--danger); overflow-x: auto; }

/* ── Buttons & controls ─────────────────────────────────────────────── */

.btn {
  padding: 10px 14px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--bg-elev);
  color: var(--text);
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  transition: transform .08s ease, background .15s ease, border-color .15s ease;
}

.btn:hover:not(:disabled) { border-color: var(--accent); }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-primary { background: var(--accent-strong); border-color: var(--accent-strong); color: var(--accent-ink); }
.btn-danger { background: transparent; border-color: var(--danger); color: var(--danger); }
.btn-wide { flex: 1; width: 100%; }

.icon-btn {
  border: 1px solid var(--border);
  background: var(--bg-elev);
  color: var(--text);
  border-radius: 10px;
  width: 38px;
  height: 38px;
  font-size: 1em;
  cursor: pointer;
  flex: none;
}

.row { display: flex; align-items: center; }
.row.gap { gap: 8px; }
.row.wrap { flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.toolbar { margin: 12px 0; }

.radios { display: flex; flex-wrap: wrap; gap: 8px; }

.radio {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 8px 13px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--bg-elev);
  font-size: .88em;
  font-weight: 700;
  cursor: pointer;
}

.radio input { accent-color: var(--accent); margin: 0; }
.radio:has(input:checked) { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 16%, transparent); }

.toggle {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  cursor: pointer;
  font-size: .88em;
  font-weight: 600;
  user-select: none;
}

.toggle input { position: absolute; opacity: 0; width: 0; height: 0; }

.toggle-track {
  position: relative;
  width: 38px;
  height: 22px;
  border-radius: 999px;
  background: var(--border);
  flex: none;
  transition: background .15s ease;
}

.toggle-track::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #fff;
  transition: transform .15s ease;
}

.toggle input:checked + .toggle-track { background: var(--accent-strong); }
.toggle input:checked + .toggle-track::after { transform: translateX(16px); }
.toggle input:focus-visible + .toggle-track { outline: 2px solid var(--accent); outline-offset: 2px; }

.help {
  display: inline-grid;
  place-items: center;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 1px solid var(--border);
  font-size: 10px;
  color: var(--text-muted);
  cursor: help;
}

.opts-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 10px; margin: 10px 0; }

input[type="text"], input[type="number"], input[type="search"], select, textarea {
  width: 100%;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--bg-elev);
  color: var(--text);
  font: inherit;
  font-weight: 600;
}

input:focus, select:focus, textarea:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
  border-color: var(--accent);
}

.form-field { display: grid; gap: 4px; font-size: .8em; color: var(--text-muted); font-weight: 700; flex: 1; min-width: 140px; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 10px; margin-bottom: 10px; }
.filters { display: flex; gap: 10px; flex-wrap: wrap; margin: 12px 0; }
.search { flex: 1; }

details.opts, details.qopts, details { margin: 12px 0; }
details > summary { cursor: pointer; font-weight: 800; font-size: .88em; padding: 6px 0; }
.qopts > summary { display: inline-block; }

.slider-row { display: grid; grid-template-columns: 1fr 2fr auto; gap: 10px; align-items: center; font-size: .85em; margin: 6px 0; }
.slider-value { color: var(--text-muted); font-size: .85em; min-width: 42px; text-align: right; }
input[type="range"] { accent-color: var(--accent); width: 100%; }

.file-drop {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  border: 1.5px dashed var(--border);
  border-radius: 12px;
  cursor: pointer;
  font-weight: 700;
  font-size: .9em;
}
.file-drop:hover { border-color: var(--accent); }
.file-drop input { display: none; }
.small-drop { padding: 10px 14px; }
.paste { font-family: ui-monospace, "SFMono-Regular", Menlo, monospace; font-size: .85em; }

/* ── Progress / metrics ─────────────────────────────────────────────── */

.bar { height: 8px; border-radius: 999px; background: var(--border); overflow: hidden; }
.bar.thin { height: 5px; }
.bar-fill { height: 100%; background: var(--accent-strong); border-radius: 999px; transition: width .25s ease; }
.goal { margin: 12px 0; display: grid; gap: 6px; }
.goal-row { display: flex; justify-content: space-between; font-size: .85em; font-weight: 700; }

.metric-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; margin: 12px 0; }
.metric-card { padding: 14px; border: 1px solid var(--border); border-radius: 14px; background: var(--bg-elev); }
.metric-value { font-size: 1.6em; font-weight: 900; color: var(--accent); line-height: 1.1; }
.metric-label { font-size: .8em; color: var(--text-sub); font-weight: 700; }
.metric-sub { font-size: .74em; color: var(--text-muted); }
.metric { display: grid; gap: 2px; align-content: end; }

.chart { display: flex; align-items: flex-end; gap: 4px; margin: 10px 0 4px; }
.chart-col { flex: 1; display: flex; flex-direction: column; align-items: center; height: 100%; gap: 4px; min-width: 0; }
.chart-bar-wrap { flex: 1; width: 100%; display: flex; align-items: flex-end; }
.chart-bar { width: 100%; background: var(--accent-strong); border-radius: 6px 6px 0 0; min-height: 2px; position: relative; }
.chart-value { position: absolute; top: -16px; left: 0; right: 0; text-align: center; font-size: 10px; color: var(--text-muted); }
.chart-label { font-size: 10px; color: var(--text-muted); white-space: nowrap; }

/* ── Quiz ───────────────────────────────────────────────────────────── */

.qtop { display: grid; gap: 8px; margin-bottom: 14px; }
.qtop-row { display: flex; align-items: center; gap: 10px; }
.score {
  padding: 4px 12px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--success) 15%, transparent);
  color: var(--success);
  font-size: .8em;
  font-weight: 800;
  white-space: nowrap;
}
.progress-text { margin-left: auto; font-size: .85em; color: var(--text-muted); font-weight: 700; }
.qctx { font-size: .78em; color: var(--text-muted); }

.retry-banner {
  padding: 7px 12px;
  border: 1px dashed var(--accent);
  border-radius: 10px;
  background: color-mix(in srgb, var(--accent) 10%, transparent);
  color: var(--accent);
  font-size: .84em;
  font-weight: 800;
  text-align: center;
}

.prompt {
  padding: 18px 20px;
  border-radius: 14px;
  background: color-mix(in srgb, var(--accent) 10%, transparent);
  border: 1px solid color-mix(in srgb, var(--accent) 26%, transparent);
  margin: 12px 0;
}

.prompt-main { font-size: 1.5em; font-weight: 800; line-height: 1.3; margin-top: 2px; }
.group-prompt { margin: 8px 0; }
.group-head { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; }
.group-tag { font-size: .7em; color: var(--text-muted); font-weight: 800; margin-right: 4px; }

.chip {
  display: inline-block;
  padding: 5px 12px;
  margin: 3px 5px 3px 0;
  border-radius: 9px;
  background: var(--chip-bg);
  color: var(--chip-ink);
  font-size: .82em;
  font-weight: 700;
}

.chip-got { background: #dcfce7; color: #166534; }
.chip-hint { background: #eef2ff; color: #3730a3; font-family: ui-monospace, monospace; }
.chip-blank { background: var(--border); color: var(--text-muted); }
.chip-todo { background: #fee2e2; color: #991b1b; }

.hint { font-family: ui-monospace, monospace; letter-spacing: .12em; color: var(--accent); font-weight: 800; }

.answer-form { display: grid; gap: 10px; margin: 14px 0 6px; }
.answer-input { font-size: 1.1em; padding: 13px 14px; }
.kbd-hint { font-size: .76em; color: var(--text-muted); margin: 6px 0 0; }
kbd {
  display: inline-block;
  padding: 1px 6px;
  border: 1px solid var(--border);
  border-bottom-width: 2px;
  border-radius: 5px;
  background: var(--bg-elev);
  font-family: inherit;
  font-size: .95em;
  font-weight: 800;
}

.mc-options { display: grid; gap: 8px; margin: 14px 0; }
.mc-options .btn { text-align: left; padding: 14px 16px; font-size: 1em; }

.box { padding: 18px 20px; border-radius: 16px; border: 1.5px solid; margin: 14px 0; animation: fade .3s ease-out; }
.box-correct { background: var(--correct-bg); border-color: var(--correct-border); color: var(--correct-ink); }
.box-wrong { background: var(--wrong-bg); border-color: var(--wrong-border); color: var(--wrong-ink); }
.box-label { font-weight: 800; font-size: .86em; margin-bottom: 12px; }

@keyframes fade { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

.rewrite-target { font-size: 1.7em; font-weight: 900; text-align: center; letter-spacing: .08em; padding: 8px 0; }
.rewrite-meaning { text-align: center; font-size: .92em; opacity: .85; }

/* Word anatomy — shared by reveal, flashcard back and the result list */
.anatomy { display: grid; gap: 2px; }
.ana-label { font-size: .74em; font-weight: 800; letter-spacing: .04em; opacity: .75; }
.ana-head { font-size: 2.2em; font-weight: 900; line-height: 1.15; margin: 2px 0 6px; }
.compact .ana-head { font-size: 1.5em; }
.ana-block { margin-bottom: 8px; }
.ana-sense { border-left: 3px solid currentColor; padding-left: 12px; margin: 9px 0; }
.ana-meaning { font-size: 1.15em; font-weight: 700; line-height: 1.35; }
.compact .ana-meaning { font-size: 1em; }
.ana-syns { margin-top: 5px; }
.ana-none { margin-top: 5px; font-size: .82em; opacity: .6; }
.ana-det { margin-top: 10px; border-top: 1px solid currentColor; border-color: color-mix(in srgb, currentColor 25%, transparent); padding-top: 6px; }
.ana-det > summary { font-size: .82em; font-weight: 800; opacity: .85; }
.ana-root { font-size: 1.02em; font-weight: 700; margin-top: 5px; }
.ana-sub { font-size: .82em; opacity: .85; margin-top: 3px; }
.ana-rel { display: flex; gap: 10px; align-items: baseline; flex-wrap: wrap; margin-top: 4px; }
.ana-term { font-weight: 800; font-size: .96em; }
.ana-gloss { opacity: .85; font-size: .86em; }

.result-emoji { font-size: 3.2em; text-align: center; line-height: 1; }
.result-score { text-align: center; margin: 6px 0; }
.score-num { font-size: 2.8em; font-weight: 900; color: var(--accent); }
.score-den { font-size: 1.2em; color: var(--text-muted); font-weight: 700; }
.result-word { border: 1px solid var(--border); border-radius: 12px; padding: 12px 14px; margin: 8px 0; }

.range-row { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; }
.lesson-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 6px; margin: 8px 0; }
.lesson {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: .84em;
  cursor: pointer;
}
.lesson:has(input:checked) { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 12%, transparent); }
.lesson input { accent-color: var(--accent); }
.lesson span:last-child { margin-left: auto; }

.lesson-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 10px; }
.lesson-stat { border: 1px solid var(--border); border-radius: 12px; padding: 10px 12px; display: grid; gap: 5px; }

/* ── Word list ──────────────────────────────────────────────────────── */

.wl-list { display: grid; gap: 6px; margin-top: 10px; }
.wl-row {
  display: flex;
  gap: 10px;
  padding: 11px 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--bg-elev);
  align-items: flex-start;
}
.wl-row.selected { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 9%, transparent); }
.wl-row.editing { display: block; }
.wl-check { width: 17px; height: 17px; margin-top: 3px; accent-color: var(--accent); flex: none; }
.wl-body { flex: 1; min-width: 0; }
.wl-head { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.wl-num { color: var(--text-muted); font-size: .74em; font-variant-numeric: tabular-nums; }
.wl-word { font-weight: 800; }
.wl-meaning { color: var(--text-sub); }
.wl-syns { color: var(--text-muted); }
.wl-meta { color: var(--text-muted); }
.wl-root { color: var(--accent); }
.wl-actions { display: flex; gap: 4px; flex: none; }
.wl-actions .btn { padding: 6px 9px; }

.badge-stat { padding: 2px 8px; border-radius: 999px; font-size: .68em; font-weight: 800; white-space: nowrap; }
.badge-unseen { background: var(--border); color: var(--text-muted); }
.badge-new { background: #e0e7ff; color: #3730a3; }
.badge-good { background: #dcfce7; color: #166534; }
.badge-ok { background: #fef3c7; color: #92400e; }
.badge-bad { background: #fee2e2; color: #991b1b; }

.pager { display: flex; align-items: center; justify-content: center; gap: 14px; margin-top: 16px; font-size: .86em; font-weight: 700; }

.weak-list { display: grid; gap: 5px; }
.weak-row { display: flex; gap: 10px; align-items: baseline; padding: 8px 11px; border: 1px solid var(--border); border-radius: 10px; flex-wrap: wrap; }
.weak-word { font-weight: 800; }
.weak-meaning { color: var(--text-sub); font-size: .88em; flex: 1; min-width: 120px; }

.session-list { display: grid; gap: 4px; }
.session-row { display: grid; grid-template-columns: auto 1fr auto auto; gap: 10px; padding: 7px 11px; border: 1px solid var(--border); border-radius: 10px; font-size: .84em; align-items: baseline; }

/* ── Manage ─────────────────────────────────────────────────────────── */

.set-list { display: grid; gap: 10px; }
.set-card { border: 1px solid var(--border); border-radius: 14px; padding: 13px 15px; display: grid; gap: 8px; background: var(--bg-elev); }
.set-card.active { border-color: var(--accent); }
.set-head { display: flex; align-items: center; gap: 8px; }
.pill { padding: 2px 9px; border-radius: 999px; background: var(--accent-strong); color: var(--accent-ink); font-size: .68em; font-weight: 800; }
.set-picker { font-size: .88em; }

.preview-list { display: grid; gap: 4px; margin: 10px 0; }
.preview-row { display: flex; gap: 10px; flex-wrap: wrap; align-items: baseline; padding: 6px 10px; border: 1px solid var(--border); border-radius: 9px; font-size: .86em; }
.warn-box { border: 1px solid var(--warn); border-radius: 10px; padding: 8px 12px; margin: 10px 0; color: var(--warn); }
.storage-box { border: 1px solid var(--border); border-radius: 12px; padding: 12px 14px; display: grid; gap: 6px; font-size: .88em; }

.sync { font-size: .72em; font-weight: 800; padding: 3px 9px; border-radius: 999px; background: var(--border); color: var(--text-sub); white-space: nowrap; }
.sync-synced { background: color-mix(in srgb, var(--success) 18%, transparent); color: var(--success); }
.sync-offline, .sync-error, .sync-conflict { background: color-mix(in srgb, var(--warn) 18%, transparent); color: var(--warn); }

/* ── Toast & modal ──────────────────────────────────────────────────── */

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(24px + env(safe-area-inset-bottom));
  transform: translate(-50%, 16px);
  z-index: 100;
  padding: 11px 18px;
  border-radius: 12px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  font-size: .9em;
  font-weight: 700;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s ease, transform .2s ease;
  max-width: min(90vw, 420px);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast-ok { border-color: var(--success); color: var(--success); }
.toast-err { border-color: var(--danger); color: var(--danger); }

.modal-backdrop { position: fixed; inset: 0; z-index: 110; display: grid; place-items: center; background: rgba(0, 0, 0, .55); padding: 20px; }
.modal { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 22px; max-width: 460px; width: 100%; box-shadow: var(--shadow); }
.modal h3 { margin: 0 0 8px; }
.modal p { color: var(--text-sub); font-size: .9em; }
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 16px; }

/* ── Desktop ────────────────────────────────────────────────────────── */

@media (min-width: 900px) {
  .topbar { display: none; }
  #sidebar { transform: none; }
  .scrim { display: none; }
  .side-close { display: none; }
  #view { margin-left: 300px; padding-top: 28px; }
}

@media print {
  #sidebar, .topbar, .btn, .toast { display: none !important; }
  #view { margin: 0; max-width: none; }
  .card { box-shadow: none; border: 0; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
