:root {
  --bg: #f4f5f7;
  --surface: #ffffff;
  --surface-2: #eceff4;
  --text: #1e293b;
  --muted: #5c6778;
  --border: #d4dbe4;
  --accent: #b45309;
  --accent-ink: #ffffff;
  --accent-soft: #fef3c7;
  --ok: #15803d;
  --ok-soft: #dcfce7;
  --ng: #b91c1c;
  --ng-soft: #fee2e2;
  --flag: #d97706;
  --flag-soft: #fef3c7;
  --paper: #ffffff;
  --header-bg: #1e293b;
  --header-prac: #1e3a3a;
  --shadow: 0 1px 2px rgba(15, 23, 42, .06), 0 2px 8px rgba(15, 23, 42, .05);
  --radius: 10px;
  --font: "Hiragino Kaku Gothic ProN", "Hiragino Sans", "Noto Sans JP", "Yu Gothic UI", "Meiryo", system-ui, sans-serif;
  --mono: ui-monospace, "SFMono-Regular", "Menlo", "Consolas", "Noto Sans Mono CJK JP", monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f141c; --surface: #18202c; --surface-2: #222c3c; --text: #e6ebf2; --muted: #9aa7ba;
    --border: #334155; --accent: #f59e0b; --accent-ink: #111827; --accent-soft: #3a2a0d;
    --ok: #4ade80; --ok-soft: #133522; --ng: #f87171; --ng-soft: #3d1818; --flag: #fbbf24; --flag-soft: #3a2a0d;
    --paper: #18202c; --header-bg: #0b111a; --header-prac: #0f2928; --shadow: none; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0f141c; --surface: #18202c; --surface-2: #222c3c; --text: #e6ebf2; --muted: #9aa7ba;
  --border: #334155; --accent: #f59e0b; --accent-ink: #111827; --accent-soft: #3a2a0d;
  --ok: #4ade80; --ok-soft: #133522; --ng: #f87171; --ng-soft: #3d1818; --flag: #fbbf24; --flag-soft: #3a2a0d;
  --paper: #18202c; --header-bg: #0b111a; --header-prac: #0f2928; --shadow: none; color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--text); font-family: var(--font); font-size: 15px; line-height: 1.7; -webkit-text-size-adjust: 100%; }
button, input, select { font: inherit; color: inherit; }
a { color: var(--accent); }
.loading { padding: 40px 16px; text-align: center; color: var(--muted); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- buttons ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 40px; padding: 0 16px; border-radius: 8px;
  border: 1px solid var(--border); background: var(--surface); cursor: pointer; font-weight: 600; text-decoration: none; color: var(--text); white-space: nowrap; }
.btn:hover { border-color: var(--accent); }
.btn:focus-visible, .opt:focus-visible, .qnav button:focus-visible, .tab:focus-visible, .chip:focus-visible, .choice-item:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.07); }
.btn.danger { color: var(--ng); }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.small { min-height: 32px; padding: 0 10px; font-size: 13px; }
.btn[disabled] { opacity: .45; cursor: not-allowed; }

/* ---------- home ---------- */
.wrap { max-width: 1060px; margin: 0 auto; padding: 0 16px 48px; }
.site-head { display: flex; align-items: center; gap: 12px; padding: 18px 0 8px; flex-wrap: wrap; }
.logo { min-width: 44px; height: 38px; padding: 0 8px; border-radius: 9px; background: var(--header-bg); border: 1.5px solid var(--accent); color: var(--accent); display: grid; place-items: center; font-weight: 800; font-size: 13px; flex: none; letter-spacing: .03em; }
.site-head h1 { font-size: 20px; margin: 0; line-height: 1.3; }
.site-head p { margin: 0; color: var(--muted); font-size: 13px; }
.site-head .spacer { flex: 1; }
.theme-btn { font-size: 12.5px; }

.summary { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin: 14px 0 18px; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 10px 14px; box-shadow: var(--shadow); }
.stat .k { font-size: 12px; color: var(--muted); }
.stat .v { font-size: 22px; font-weight: 700; font-variant-numeric: tabular-nums; }
.stat .v small { font-size: 12.5px; color: var(--muted); font-weight: 500; }

.tabs { position: relative; display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 18px; overflow-x: auto; scrollbar-width: none; }
.tab { border: 0; background: none; padding: 10px 14px; cursor: pointer; font-weight: 600; color: var(--muted); border-bottom: 3px solid transparent; white-space: nowrap; transition: color .2s ease; }
.tab[aria-selected="true"] { color: var(--accent); }
.tab:hover { color: var(--text); }
.tab-ink { position: absolute; left: 0; bottom: 0; height: 3px; width: 0; border-radius: 3px 3px 0 0; background: var(--accent); pointer-events: none; }
.tab-ink.smooth { transition: transform .32s cubic-bezier(.2,.8,.2,1), width .32s cubic-bezier(.2,.8,.2,1); }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(310px, 1fr)); gap: 12px; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 8px; }
.card h3 { margin: 0; font-size: 16px; }
.card .meta { color: var(--muted); font-size: 13px; }
.card .row { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: auto; flex-wrap: wrap; }
.set-btns { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }

.badge { display: inline-block; font-size: 12px; padding: 1px 8px; border-radius: 99px; background: var(--surface-2); color: var(--muted); font-weight: 600; }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.ng { background: var(--ng-soft); color: var(--ng); }
.badge.flag { background: var(--flag-soft); color: var(--flag); }
.badge.subj-a2 { background: #e2e8f0; color: #334155; }
.badge.subj-b { background: var(--accent-soft); color: var(--accent); }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .badge.subj-a2 { background: #263244; color: #cbd5e1; }
}
:root[data-theme="dark"] .badge.subj-a2 { background: #263244; color: #cbd5e1; }

.dots-wrap { display: grid; grid-template-columns: auto 1fr; gap: 6px 8px; align-items: start; }
.dots-lbl { font-size: 11px; font-weight: 700; color: var(--muted); padding-top: 3px; }
.dots { display: flex; gap: 4px; flex-wrap: wrap; }
.dot { width: 22px; height: 22px; border-radius: 5px; font-size: 11px; display: grid; place-items: center; background: var(--surface-2); color: var(--muted); font-weight: 700; }
.dot.ok { background: var(--ok-soft); color: var(--ok); }
.dot.ng { background: var(--ng-soft); color: var(--ng); }

.toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 12px; }
.chip { border: 1px solid var(--border); background: var(--surface); border-radius: 99px; padding: 3px 12px; font-size: 13px; cursor: pointer; }
.chip[aria-pressed="true"] { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); font-weight: 600; }
.toolbar .label { font-size: 12px; color: var(--muted); margin-right: 2px; }

.case-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 10px; }
.case-card { border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; background: var(--surface-2); display: flex; flex-direction: column; gap: 6px; }
.case-card-top { display: flex; gap: 6px; flex-wrap: wrap; }
.case-card-title { font-weight: 700; font-size: 14px; line-height: 1.4; }
.case-card-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: auto; font-size: 12.5px; }

.qtable { width: 100%; border-collapse: collapse; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.qtable th, .qtable td { padding: 8px 10px; border-bottom: 1px solid var(--border); text-align: left; font-size: 14px; vertical-align: middle; }
.qtable th { background: var(--surface-2); font-size: 12px; color: var(--muted); font-weight: 600; }
.qtable tr:last-child td { border-bottom: 0; }
.qtable td.num { white-space: nowrap; font-variant-numeric: tabular-nums; }
.qtable tbody tr:hover { background: var(--surface-2); }
.qtable input[type=checkbox] { width: 18px; height: 18px; accent-color: var(--accent); }
.sticky-actions { position: sticky; bottom: 0; background: var(--bg); border-top: 1px solid var(--border); margin-top: 14px; padding: 10px 0; display: flex; gap: 8px; justify-content: flex-end; align-items: center; flex-wrap: wrap; }

.genre-group { margin-bottom: 18px; }
.genre-group h3 { font-size: 13px; color: var(--muted); margin: 0 0 8px; font-weight: 600; }
.genre { display: flex; align-items: center; gap: 10px; background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; cursor: pointer; }
.genre:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.genre input { width: 18px; height: 18px; accent-color: var(--accent); flex: none; }
.genre .gbody { display: flex; flex-direction: column; flex: 1; min-width: 0; line-height: 1.4; }
.genre .name { font-weight: 600; }
.genre .gmeta { display: flex; align-items: center; gap: 8px; margin-top: 4px; }
.genre .cnt { font-size: 13px; color: var(--muted); white-space: nowrap; }
.genre-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 8px; }
.bar { height: 6px; border-radius: 3px; background: var(--surface-2); overflow: hidden; width: 70px; flex: none; }
.bar i { display: block; height: 100%; background: var(--ok); }

.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); margin-bottom: 14px; }
.panel h2 { font-size: 16px; margin: 0 0 10px; }
.form-row { display: flex; flex-wrap: wrap; gap: 10px 18px; align-items: center; }
.form-row label { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; }
.form-row select, .form-row input[type=number] { min-height: 36px; border: 1px solid var(--border); border-radius: 6px; background: var(--surface); padding: 0 8px; }
.footnote { color: var(--muted); font-size: 12px; margin-top: 28px; line-height: 1.6; }
.empty { color: var(--muted); padding: 24px; text-align: center; background: var(--surface); border: 1px dashed var(--border); border-radius: var(--radius); }

.subj-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
@media (max-width: 680px) { .subj-grid { grid-template-columns: 1fr; } }
.subj-card { border: 1px solid var(--border); border-radius: 8px; padding: 12px; background: var(--surface-2); }
.subj-head { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.subj-nums { display: flex; flex-wrap: wrap; gap: 10px 18px; font-size: 13.5px; }
.subj-nums b { font-size: 17px; font-variant-numeric: tabular-nums; }

/* ---------- exam (CBT) ---------- */
body.exam-mode { background: var(--surface-2); }
.cbt { display: grid; grid-template-rows: auto 1fr auto; height: 100dvh; }
.cbt-top { display: flex; align-items: center; gap: 10px; padding: 8px 16px; background: var(--header-bg); color: #fff; }
.cbt-top .title { font-weight: 700; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; min-width: 0; }
.cbt-top .pos { font-variant-numeric: tabular-nums; font-size: 14px; white-space: nowrap; }
.timer { font-variant-numeric: tabular-nums; font-weight: 700; font-size: 18px; padding: 2px 12px; border-radius: 6px; background: rgba(255,255,255,.12); white-space: nowrap; }
.timer.warn { background: #dc2626; }
.cbt-top .btn { min-height: 34px; background: rgba(255,255,255,.1); border-color: rgba(255,255,255,.25); color: #fff; }
.cbt-top .btn.finish { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }

.cbt-body { display: grid; grid-template-columns: 180px 1fr; min-height: 0; }
.qnav { overflow-y: auto; border-right: 1px solid var(--border); background: var(--surface); padding: 10px; display: flex; flex-direction: column; gap: 5px; }
.qnav .legend { font-size: 11px; color: var(--muted); line-height: 1.5; margin-bottom: 4px; }
.qnav button { display: flex; align-items: center; gap: 5px; border: 1px solid var(--border); background: var(--surface); border-radius: 6px; padding: 5px 8px; cursor: pointer; font-size: 13px; text-align: left; }
.qnav button .n { font-weight: 700; min-width: 2.8em; }
.qnav button .s-tag { font-size: 10px; padding: 0 5px; border-radius: 4px; font-weight: 700; background: var(--surface-2); color: var(--muted); }
.qnav button .s-tag.b { background: var(--accent-soft); color: var(--accent); }
.qnav button .a { margin-left: auto; font-weight: 700; color: var(--accent); }
.qnav button.answered { background: var(--accent-soft); }
.qnav button.current { outline: 2px solid var(--accent); outline-offset: -2px; }
.qnav button .f { color: var(--flag); font-size: 12px; }

.qview { overflow-y: auto; padding: 16px; scroll-behavior: smooth; }
.qview-inner { margin: 0 auto; max-width: var(--paper-w, 860px); }
.qview-inner.has-case { max-width: min(100%, calc(var(--paper-w, 860px) + 340px)); }
.paper { background: var(--paper); border: 1px solid var(--border); border-radius: 8px; box-shadow: var(--shadow); padding: 10px; margin-bottom: 12px; }
.qhead { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; margin-bottom: 10px; }
.qhead h2 { margin: 0; font-size: 17px; }
.qhead .meta { color: var(--muted); font-size: 13px; }

/* 科目B 大問リード文＋設問レイアウト */
.case-layout { display: grid; grid-template-columns: minmax(0, 1.08fr) minmax(0, 1fr); gap: 14px; align-items: start; }
.scenario-box { margin-bottom: 0; }
.scenario-head { cursor: pointer; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; list-style: none; padding: 4px 0; }
.scenario-head::-webkit-details-marker { display: none; }
.scenario-body { margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--border); }
.question-pane { min-width: 0; }
@media (max-width: 1020px) { .case-layout { grid-template-columns: minmax(0, 1fr); } }
.with-pad .case-layout, .with-guide .case-layout { grid-template-columns: minmax(0, 1fr); }

/* 問題文・リード文 Markdown 描画 */
.paper.text { padding: 18px 22px; color: var(--text); font-size: 15px; line-height: 1.75; }
.qtext p { margin: 0 0 10px; }
.qtext ul, .qtext ol { margin: 0 0 10px; padding-left: 1.5em; }
.qtext ul ul, .qtext ol ol, .qtext ul ol, .qtext ol ul { margin: 4px 0; }
.qtext pre { font-family: var(--mono); font-size: 13px; line-height: 1.6; background: var(--surface-2); color: var(--text); border: 1px solid var(--border); padding: 10px 14px; border-radius: 6px; overflow-x: auto; margin: 6px 0 12px; }
.qtext code { font-family: var(--mono); background: var(--surface-2); padding: 1px 4px; border-radius: 4px; font-size: .92em; }
.qtext pre code { background: none; padding: 0; }
.qtext blockquote, .explain blockquote { margin: 8px 0 12px; padding: 8px 12px; border-left: 3px solid var(--accent); background: var(--surface-2); border-radius: 0 6px 6px 0; }
.qtext blockquote p:last-child, .explain blockquote p:last-child { margin-bottom: 0; }
.qtext .ex-tbl, .explain .ex-tbl { overflow-x: auto; margin: 8px 0 12px; }
.qtext table { border-collapse: collapse; font-size: 13.5px; width: auto; min-width: 50%; }
.qtext th, .qtext td { border: 1px solid var(--border); padding: 5px 10px; text-align: left; vertical-align: top; color: var(--text); background: var(--surface); }
.qtext th { background: var(--surface-2); font-weight: 700; }
.qtext h4, .explain h4 { margin: 14px 0 6px; font-size: 14.5px; }
.case-heading { margin: 16px 0 8px; padding: 4px 10px; border-left: 4px solid var(--accent); background: var(--surface-2); border-radius: 0 6px 6px 0; font-size: 14.5px; }

/* SVG 図表（レスポンシブ＆ダークモード対応） */
.svg-fig { margin: 10px 0 14px; padding: 10px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); overflow-x: auto; text-align: center; }
.svg-fig svg { display: block; margin: 0 auto; max-width: 100%; height: auto; color: var(--text); }
.svg-error { margin: 8px 0; padding: 8px 12px; border-radius: 6px; background: var(--ng-soft); color: var(--ng); font-size: 13px; border: 1px solid var(--ng); }

/* 選択肢リスト（問題文内） */
.choices-list { list-style: none; padding: 0; margin: 14px 0 2px; display: grid; gap: 8px; }
.choice-item { width: 100%; display: flex; align-items: flex-start; gap: 10px; text-align: left; padding: 10px 12px; border: 1.5px solid var(--border); border-radius: 8px; background: var(--surface); color: var(--text); font-size: 14.5px; line-height: 1.6; }
button.choice-item { cursor: pointer; }
button.choice-item:hover { border-color: var(--accent); background: var(--surface-2); }
.choice-item.selected { border-color: var(--accent); background: var(--accent-soft); }
.choice-item.correct { border-color: var(--ok); background: var(--ok-soft); }
.choice-item.wrong { border-color: var(--ng); background: var(--ng-soft); }
.choice-key { flex: none; min-width: 26px; height: 26px; border-radius: 6px; background: var(--surface-2); border: 1px solid var(--border); display: grid; place-items: center; font-weight: 800; font-size: 13px; }
.choice-item.selected .choice-key { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.choice-item.correct .choice-key { background: var(--ok); color: #fff; border-color: var(--ok); }
.choice-item.wrong .choice-key { background: var(--ng); color: #fff; border-color: var(--ng); }
.choice-body { flex: 1; min-width: 0; }
.choice-mark { flex: none; font-size: 11px; font-weight: 700; padding: 2px 7px; border-radius: 99px; }
.choice-mark.ok { background: var(--ok); color: #fff; }
.choice-mark.ng { background: var(--ng); color: #fff; }

.answer-bar { background: var(--surface); border-top: 1px solid var(--border); padding: 10px 16px; display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; }
.answer-bar .lbl { font-weight: 700; font-size: 13px; color: var(--muted); }
.opts { display: flex; flex-wrap: wrap; gap: 6px; }
.opt { width: 42px; height: 42px; border-radius: 8px; border: 1.5px solid var(--border); background: var(--surface); font-size: 16px; font-weight: 700; cursor: pointer; }
.opt:hover { border-color: var(--accent); }
.opt[aria-checked="true"] { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.flagbox { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; font-size: 14px; user-select: none; }
.flagbox input { width: 18px; height: 18px; accent-color: var(--flag); }
.answer-bar .navbtns { margin-left: auto; display: flex; gap: 8px; }
.zoom { display: inline-flex; gap: 2px; }

/* ---------- result / review ---------- */
.score { display: flex; align-items: center; gap: 22px; flex-wrap: wrap; }
.ring { --p: 0; width: 120px; height: 120px; border-radius: 50%; display: grid; place-items: center; flex: none;
  background: conic-gradient(var(--ok) calc(var(--p) * 1%), var(--surface-2) 0); }
.ring > div { width: 92px; height: 92px; border-radius: 50%; background: var(--surface); display: grid; place-items: center; text-align: center; line-height: 1.2; }
.ring b { font-size: 26px; font-variant-numeric: tabular-nums; }
.ring span { font-size: 12px; color: var(--muted); display: block; }
.score .facts { display: grid; gap: 2px; font-size: 14px; }
.score .facts strong { font-variant-numeric: tabular-nums; }
.mark { font-weight: 800; font-size: 17px; }
.mark.ok { color: var(--ok); }
.mark.ng { color: var(--ng); }

.review-opts { display: flex; flex-wrap: wrap; gap: 6px; margin: 4px 0 6px; }
.review-opts span { width: 40px; height: 40px; border-radius: 8px; border: 1.5px solid var(--border); display: grid; place-items: center; font-weight: 700; position: relative; background: var(--surface); }
.review-opts span.correct { background: var(--ok-soft); border-color: var(--ok); color: var(--ok); }
.review-opts span.wrong { background: var(--ng-soft); border-color: var(--ng); color: var(--ng); }
.review-opts span .you { position: absolute; top: -9px; right: -9px; font-size: 10px; background: var(--text); color: var(--surface); border-radius: 99px; padding: 0 5px; line-height: 16px; }
.explain { background: var(--surface); border: 1px solid var(--border); border-left: 4px solid var(--accent); border-radius: var(--radius); padding: 14px 18px; margin: 14px 0; }
.explain h3 { margin: 0 0 6px; font-size: 15px; }
.explain p { margin: 8px 0; }
.explain ul, .explain ol { margin: 6px 0; padding-left: 1.4em; }
.explain pre { font-family: var(--mono); font-size: 13px; line-height: 1.55; background: var(--surface-2); padding: 10px 12px; border-radius: 6px; overflow-x: auto; margin: 8px 0; }
.explain code { font-family: var(--mono); background: var(--surface-2); padding: 0 4px; border-radius: 4px; font-size: .92em; }
.explain pre code { background: none; padding: 0; }
.explain h4 { margin: 14px 0 6px; font-size: 14.5px; padding-left: 8px; border-left: 3px solid var(--accent); line-height: 1.4; }
.explain .ex-tbl table { border-collapse: collapse; font-size: 13.5px; min-width: 60%; }
.explain .ex-tbl th, .explain .ex-tbl td { border: 1px solid var(--border); padding: 5px 10px; text-align: left; vertical-align: top; }
.explain .ex-tbl th { background: var(--surface-2); font-weight: 600; }

.verdict { display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-radius: var(--radius); font-weight: 700; margin: 10px 0; }
.verdict.ok { background: var(--ok-soft); color: var(--ok); }
.verdict.ng { background: var(--ng-soft); color: var(--ng); }
.review-nav { display: flex; gap: 8px; justify-content: space-between; flex-wrap: wrap; margin: 16px 0; }
.page-head { display: flex; align-items: center; gap: 10px; padding: 16px 0 10px; flex-wrap: wrap; }
.page-head h1 { font-size: 19px; margin: 0; flex: 1; min-width: 200px; }

/* ---------- 保存失敗の案内 ---------- */
.save-warn { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; padding: 10px 16px; background: var(--ng-soft); border-bottom: 2px solid var(--ng); color: var(--text); font-size: 13px; line-height: 1.6; }
.save-warn p { margin: 0; flex: 1; min-width: 240px; }
.save-warn strong { color: var(--ng); margin-right: 6px; }
.save-warn-actions { display: flex; flex-wrap: wrap; gap: 8px; }
body:not(.exam-mode) #save-warn { position: sticky; top: 0; z-index: 20; max-height: 40dvh; overflow: auto; }
body.exam-mode.save-warned { display: flex; flex-direction: column; height: 100dvh; }
body.exam-mode.save-warned #save-warn { flex: none; max-height: 40dvh; overflow: auto; }
body.exam-mode.save-warned #app { flex: 1; min-height: 0; }
body.exam-mode.save-warned .cbt { height: 100%; }
.backup-text { width: 100%; font: 13px/1.6 monospace; border: 1px solid var(--border); border-radius: 6px; padding: 8px; background: var(--surface-2); color: var(--text); }
.pad-note.ng { color: var(--ng); font-weight: 700; }

/* ---------- modal ---------- */
.modal-back { position: fixed; inset: 0; background: rgba(10, 15, 25, .55); display: grid; place-items: center; padding: 16px; z-index: 50; }
.modal { background: var(--surface); color: var(--text); border-radius: 12px; max-width: 560px; width: 100%; max-height: calc(100dvh - 32px); overflow: auto; padding: 20px; box-shadow: 0 10px 40px rgba(0,0,0,.3); }
.modal.wide { max-width: 900px; }
.modal h2 { margin: 0 0 10px; font-size: 18px; }
.modal .actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 16px; flex-wrap: wrap; }
.modal .grid-status { display: grid; grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); gap: 6px; margin: 10px 0; }
.modal .grid-status button { border: 1px solid var(--border); border-radius: 6px; padding: 6px; background: var(--surface); cursor: pointer; font-size: 12.5px; }
.modal .grid-status button.answered { background: var(--accent-soft); }
.modal .grid-status button.unanswered { border-color: var(--ng); color: var(--ng); }
.time-choice { display: grid; gap: 8px; margin: 8px 0; }
.time-choice label { display: flex; align-items: center; gap: 8px; border: 1px solid var(--border); border-radius: 8px; padding: 8px 12px; cursor: pointer; }
.time-choice label:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.time-choice input[type=radio] { accent-color: var(--accent); }
.time-choice small { color: var(--muted); margin-left: auto; }

/* ---------- responsive ---------- */
@media (max-width: 760px) {
  body { font-size: 14px; }
  .summary { grid-template-columns: repeat(2, 1fr); }
  .cbt-body { grid-template-columns: 1fr; grid-template-rows: auto 1fr; }
  .qnav { flex-direction: row; overflow-x: auto; overflow-y: hidden; border-right: 0; border-bottom: 1px solid var(--border); padding: 6px 10px; }
  .qnav .legend { display: none; }
  .qnav button { flex: none; padding: 4px 8px; }
  .qnav button .n { min-width: auto; }
  .qview { padding: 10px; }
  .paper.text { padding: 12px; font-size: 14px; }
  .qtext pre { font-size: 12px; }
  .cbt-top { padding: 6px 10px; gap: 6px; flex-wrap: wrap; }
  .cbt-top .title { flex-basis: 100%; order: -1; font-size: 13px; }
  .cbt-top .btn { padding: 0 10px; }
  .timer { font-size: 16px; }
  .answer-bar { padding: 8px 10px; gap: 8px; }
  .answer-bar .navbtns { margin-left: 0; width: 100%; }
  .answer-bar .navbtns .btn { flex: 1; }
  .qview-inner { min-width: var(--paper-min, 0); }
  .opt { width: 38px; height: 38px; }
  .qtable .hide-sm { display: none; }
  .qtable th, .qtable td { padding: 7px 3px; font-size: 12.5px; }
  .qtable th { white-space: nowrap; }
  .qtable td .badge { white-space: nowrap; }
  .qtable td .btn { padding: 0 8px; white-space: nowrap; }
}

/* ---------- modes ---------- */
.mode-choice { display: grid; gap: 8px; margin: 8px 0; }
.mode-choice label { display: flex; align-items: flex-start; gap: 10px; border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; cursor: pointer; }
.mode-choice label:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.mode-choice input { accent-color: var(--accent); margin-top: 5px; }
.mode-choice span { display: flex; flex-direction: column; line-height: 1.5; }
.mode-choice small { color: var(--muted); }
.mode-tag { display: inline-block; font-size: 11px; padding: 0 7px; border-radius: 4px; background: rgba(255,255,255,.18); margin-right: 8px; vertical-align: 1px; }
.cbt.practice .cbt-top { background: var(--header-prac); }
.opt.correct { background: var(--ok-soft); border-color: var(--ok); color: var(--ok); opacity: 1; }
.opt.wrong { background: var(--ng-soft); border-color: var(--ng); color: var(--ng); opacity: 1; }
.opt[disabled] { cursor: default; }
.opt[disabled]:not(.correct):not(.wrong) { opacity: .45; }
.btn.judged { opacity: 1 !important; cursor: default; }
.btn.judged.ok { background: var(--ok-soft); color: var(--ok); border-color: var(--ok); }
.btn.judged.ng { background: var(--ng-soft); color: var(--ng); border-color: var(--ng); }
.qnav button .a.ok { color: var(--ok); }
.qnav button .a.ng { color: var(--ng); }
.feedback { margin-top: 18px; padding-top: 6px; border-top: 2px dashed var(--border); scroll-margin-top: 10px; }

/* ---------- settings dialog fields (study.js) ---------- */
.auth-field { display: block; margin: 0 0 12px; }
.auth-field span { display: block; font-size: 13px; font-weight: 700; margin-bottom: 4px; }
.auth-field input, .auth-field select { width: 100%; min-height: 40px; border: 1px solid var(--border); border-radius: 6px; padding: 0 10px; font: inherit; background: var(--surface); color: var(--text); }
.auth-field input:focus, .auth-field select:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.auth-msg { margin: 0; font-size: 14px; }
.auth-msg:empty { display: none; }
.auth-msg.ng { color: var(--ng); }
.auth-note { color: var(--muted); font-size: 13px; }

/* ---------- study.js ---------- */
.muted { color: var(--muted); }
.linkbtn { border: 0; background: none; color: var(--accent); font: inherit; font-size: 12px; cursor: pointer; padding: 0 2px; text-decoration: underline; }
.today { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px; margin: 8px 0 14px; }
.today-stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.t-stat { background: var(--surface-2); border-radius: 8px; padding: 10px 12px; min-width: 0; }
.t-stat .k { font-size: 12px; color: var(--muted); font-weight: 700; }
.t-stat .v { font-size: 15px; margin-top: 2px; }
.t-stat .v b { font-size: 24px; font-variant-numeric: tabular-nums; }
.t-stat .v small, .t-stat .s { display: block; font-size: 12px; color: var(--muted); }
.t-stat.streak { display: flex; gap: 10px; align-items: center; }

.gbar { height: 8px; border-radius: 99px; background: var(--surface); margin-top: 6px; overflow: hidden; }
.gbar i { display: block; height: 100%; background: var(--accent); border-radius: 99px; }
.today-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 12px; }
.btn.big { min-height: 54px; flex: 1 1 200px; flex-direction: column; align-items: flex-start; justify-content: center; text-align: left; gap: 0; padding: 6px 14px; }
.btn.big span { font-weight: 700; }
.btn.big small { font-size: 12px; font-weight: 400; opacity: .85; }
.t-none { flex: 1 1 200px; border: 1px dashed var(--border); border-radius: 8px; padding: 8px 14px; font-size: 14px; color: var(--muted); display: flex; flex-direction: column; justify-content: center; }
.t-none small { font-size: 12px; }
@media (max-width: 760px) { .today-stats { grid-template-columns: 1fr; gap: 8px; } }

.setprog { display: flex; align-items: center; gap: 8px; margin: 4px 0 6px; }
.setprog .bar { flex: 1; }
.card.mastered { border-color: var(--ok); }
.star { color: var(--flag); }

.charts2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
@media (max-width: 900px) { .charts2 { grid-template-columns: 1fr; } }
.chart { width: 100%; height: auto; display: block; }
.chart .grid { stroke: var(--border); stroke-width: 1; }
.chart .ytick, .chart .xtick { fill: var(--muted); font-size: 11px; text-anchor: end; }
.chart .xtick { text-anchor: middle; }
.chart .bar { fill: var(--accent); }
.chart .line { fill: none; stroke: var(--accent); stroke-width: 2; stroke-linejoin: round; }
.chart .dot { fill: var(--accent); stroke: var(--surface); stroke-width: 2; }
.chart .ref { stroke: var(--muted); stroke-width: 1.5; stroke-dasharray: 5 4; }
.chart .reflab { fill: var(--muted); font-size: 11px; text-anchor: start; }
.chart .vlab { fill: var(--text); font-size: 11px; text-anchor: middle; font-weight: 600; }
.chart .hit:hover .bar, .chart .hit:hover .dot { opacity: .8; }
.chart-table summary { cursor: pointer; font-size: 13px; color: var(--muted); margin-top: 6px; }

.cal { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 4px; }
.cal-days { display: grid; grid-template-rows: 14px repeat(7, 13px); gap: 3px; font-size: 10px; color: var(--muted); }
.cal-days span:first-child { visibility: hidden; }
.cal-days::before { content: ""; }
.cal-months { display: grid; grid-template-columns: repeat(18, 13px); gap: 3px; font-size: 10px; color: var(--muted); height: 14px; white-space: nowrap; }
.cal-grid { display: grid; grid-template-columns: repeat(18, 13px); gap: 3px; margin-top: 3px; }
.cal-col { display: grid; grid-template-rows: repeat(7, 13px); gap: 3px; }
.cal-cell { display: inline-block; width: 13px; height: 13px; border-radius: 3px; background: var(--surface-2); }
.cal-cell.l1 { background: color-mix(in srgb, var(--accent) 30%, var(--surface-2)); }
.cal-cell.l2 { background: color-mix(in srgb, var(--accent) 55%, var(--surface-2)); }
.cal-cell.l3 { background: color-mix(in srgb, var(--accent) 78%, var(--surface-2)); }
.cal-cell.l4 { background: var(--accent); }
.cal-cell.future { background: transparent; }
.cal-legend { display: flex; align-items: center; gap: 3px; font-size: 11px; color: var(--muted); margin-top: 6px; justify-content: flex-end; }

.gmap { display: grid; grid-template-columns: repeat(auto-fill, minmax(185px, 1fr)); gap: 10px; }
.gtile { border: 1px solid var(--border); border-left: 5px solid var(--border); border-radius: 8px; padding: 8px 10px; display: flex; flex-direction: column; gap: 3px; background: var(--surface); }
.gtile.good { border-left-color: var(--ok); }
.gtile.mid { border-left-color: var(--accent); }
.gtile.weak { border-left-color: var(--ng); background: var(--ng-soft); }
.gtile .gname { font-weight: 700; font-size: 13.5px; display: flex; align-items: center; gap: 5px; flex-wrap: wrap; }
.gtile .gnum { font-size: 18px; font-weight: 700; font-variant-numeric: tabular-nums; }
.gtile .gnum small { font-size: 11px; font-weight: 400; color: var(--muted); }
.gtile .gtag { font-size: 12px; color: var(--muted); }
.gtile.weak .gtag { color: var(--ng); font-weight: 700; }
.gtile .btn { align-self: flex-start; margin-top: auto; }

.badges { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.bdg { display: grid; grid-template-columns: 34px 1fr; grid-template-rows: auto auto; column-gap: 6px; align-items: center; border: 1px solid var(--border); border-radius: 8px; padding: 8px; opacity: .55; }
.bdg.got { opacity: 1; background: var(--flag-soft); border-color: transparent; }
.bdg .bi { grid-row: span 2; font-size: 24px; text-align: center; }
.bdg .bn { font-weight: 700; font-size: 13px; }
.bdg .bd { font-size: 11px; color: var(--muted); }
.panel h2 small { font-weight: 400; font-size: 13px; }

.compare .cmp-line { font-size: 15px; margin: 0 0 6px; }
.compare .cmp-line b { font-size: 20px; }
.newbadge { border-color: var(--flag); }

.markbox { display: flex; flex-wrap: wrap; gap: 8px; align-items: flex-start; margin: 10px 0; }
.markbox .bm.on { color: var(--flag); border-color: var(--flag); }
.markbox details { flex: 1 1 260px; }
.markbox summary { cursor: pointer; font-size: 13px; min-height: 32px; display: flex; align-items: center; }
.markbox textarea { width: 100%; border: 1px solid var(--border); border-radius: 6px; padding: 6px 8px; font: inherit; font-size: 14px; background: var(--surface); color: var(--text); resize: vertical; }
.markbox .saved { font-size: 12px; }
.similar { margin: 12px 0; }
.similar .btn { white-space: normal; height: auto; min-height: 40px; padding: 6px 14px; text-align: left; }

/* ---------- guide.js ---------- */
.hintbtn { border-color: var(--flag); color: var(--flag); }
.hintbtn:disabled { opacity: .5; }
.guide { margin: 16px auto; max-width: var(--paper-w, 860px); background: var(--surface); border: 2px solid var(--flag); border-radius: var(--radius); padding: 14px; box-shadow: var(--shadow); scroll-margin-top: 70px; }
.g-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; margin-bottom: 8px; }
.g-head b { color: var(--flag); font-size: 16px; }
.g-steps { list-style: none; display: flex; flex-wrap: wrap; gap: 6px; padding: 0; margin: 0 0 12px; }
.g-chip { border: 1px solid var(--border); background: var(--surface-2); color: var(--muted); border-radius: 99px; padding: 3px 10px; font-size: 12px; cursor: pointer; font-family: inherit; }
.g-chip.open { color: var(--text); background: var(--flag-soft); border-color: transparent; }
.g-chip.cur { background: var(--flag); color: var(--accent-ink); font-weight: 700; }
.g-chip:disabled { cursor: default; opacity: .7; }
.g-body { font-size: 14.5px; line-height: 1.75; }
.g-body p { margin: 0 0 8px; }
.g-ex { background: var(--surface-2); border-radius: 6px; padding: 6px 10px; }
.g-patterns, .g-way, .g-check { margin: 0 0 8px; padding-left: 1.5em; }
.g-check { list-style: none; padding-left: 0; display: grid; gap: 6px; }
.g-check li { background: var(--surface-2); border-radius: 6px; padding: 6px 10px; }
.g-way li, .g-patterns li { margin-bottom: 4px; }
.g-ctl { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 10px; border-top: 1px solid var(--border); padding-top: 10px; }
.g-ctl #g-close { margin-left: auto; }

@media (min-width: 1100px) {
  .qview-inner.with-guide { max-width: calc(var(--paper-w, 860px) + 460px); display: grid; grid-template-columns: minmax(0, 1fr) clamp(340px, 34vw, 440px); column-gap: 18px; align-items: start; }
  .qview-inner.with-guide > * { grid-column: 1; min-width: 0; }
  .qview-inner.with-guide > #guidebox { grid-column: 2; grid-row: 1 / span 40; position: sticky; top: 0; max-height: calc(var(--qview-h, 80vh) - 32px); overflow-y: auto; overscroll-behavior: contain; border-radius: var(--radius); }
  .with-guide .guide { margin: 0; max-width: none; scroll-margin-top: 0; }
}

/* ---------- marker.js ---------- */
.cbt-top .btn.on { background: #fff; color: #1e293b; border-color: #fff; }
mark.hl { color: inherit; border-radius: 2px; padding: 0; }
mark.hl-y { background: rgba(255, 212, 59, .55); }
mark.hl-g { background: rgba(105, 219, 124, .5); }
mark.hl-p { background: rgba(247, 131, 172, .45); }
mark.hl-b { background: rgba(116, 192, 252, .5); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) mark.hl { color: #111; } }
:root[data-theme="dark"] mark.hl { color: #111; }
.paper { position: relative; }
.marking .paper.text .qtext { touch-action: none; user-select: none; -webkit-user-select: none; cursor: text; }
.marking .paper { outline: 2px dashed var(--flag); outline-offset: 2px; }
.mk-bar { position: sticky; top: -16px; z-index: 5; display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: -16px -16px 12px; padding: 8px 16px; background: var(--surface); border-bottom: 1px solid var(--border); box-shadow: 0 2px 6px rgba(0,0,0,.06); }
.mk-bar[hidden] { display: none; }
.mk-lbl { font-weight: 700; font-size: 14px; }
.mk-c { width: 30px; height: 30px; border-radius: 50%; border: 2px solid var(--border); cursor: pointer; padding: 0; }
.mk-c.cur { border-color: var(--text); box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--accent); }
.mk-y { background: #ffd43b; } .mk-g { background: #69db7c; } .mk-p { background: #f783ac; } .mk-b { background: #74c0fc; }
.mk-tip { font-size: 12px; flex: 1; min-width: 160px; }
.mk-off { margin-left: auto; }
.mk-short { display: none; }
.with-pad .mk-tip, .with-pad .mk-long { display: none; }
.with-pad .mk-short { display: inline; }
.with-pad .mk-bar { flex-wrap: nowrap; gap: 6px; }
.with-pad .mk-bar .btn { white-space: nowrap; padding: 0 10px; }
@media (max-width: 1099px) { .with-pad .mk-lbl { display: none; } .with-pad .mk-c { width: 26px; height: 26px; } }
@media (max-width: 760px) { .mk-bar { top: -10px; margin: -10px -10px 10px; padding: 6px 10px; } .mk-tip { display: none; } }

/* ---------- notepad.js ---------- */
.cbt-body.with-pad { grid-template-columns: 180px minmax(0, 1fr) clamp(320px, 40vw, 560px); }
.pad { display: flex; flex-direction: column; min-height: 0; border-left: 1px solid var(--border); background: var(--surface); }
.pad[hidden] { display: none; }
.pad-head { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border-bottom: 1px solid var(--border); }
.pad-head b { font-size: 14px; white-space: nowrap; }
.pad-q { font-size: 12px; }
.pad-tabs { display: inline-flex; margin-left: auto; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.pad-tabs button { font: inherit; font-size: 12.5px; border: 0; background: var(--surface); color: var(--text); padding: 5px 10px; min-height: 32px; cursor: pointer; }
.pad-tabs button[aria-selected="true"] { background: var(--accent); color: var(--accent-ink); font-weight: 700; }
.pad-tools { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; padding: 6px 10px; border-bottom: 1px solid var(--border); }
.pad-tools[hidden] { display: none; }
.pad-c { width: 30px; height: 30px; border-radius: 50%; border: 2px solid var(--border); padding: 0; cursor: pointer; }
.pad-c.cur { box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--accent); }
.pad-k { background: #1f2328; } .pad-r { background: #e03131; } .pad-b { background: #1c7ed6; }
.pad-tools .btn { min-height: 32px; padding: 0 10px; }
.pad-size { min-width: 40px; }
.pad-opt { font-size: 12.5px; display: inline-flex; align-items: center; gap: 4px; white-space: nowrap; }
.pad-area { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; background: #fff; -webkit-overflow-scrolling: touch; }
.pad-area[hidden] { display: none; }
.pad-area.grid { background-image: linear-gradient(#e3e8ef 1px, transparent 1px), linear-gradient(90deg, #e3e8ef 1px, transparent 1px); background-size: var(--grid, 20px) var(--grid, 20px); }
.pad-area canvas { display: block; touch-action: none; cursor: crosshair; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; -webkit-tap-highlight-color: transparent; }
body.exam-mode, html:has(body.exam-mode) { overscroll-behavior: none; }
.pad-area.pen-eraser canvas { cursor: cell; }
.pad-text { flex: 1; min-height: 0; margin: 0; border: 0; padding: 12px; font: inherit; font-size: 15px; line-height: 1.7; resize: none; background: var(--surface); color: var(--text); }
.pad-text[hidden] { display: none; }
.pad-text:focus { outline: none; box-shadow: inset 0 0 0 2px var(--accent); }
.pad-note { font-size: 11.5px; margin: 0; padding: 4px 10px; border-top: 1px solid var(--border); }
@media (min-width: 761px) and (max-width: 1099px) {
  .cbt-body.with-pad { grid-template-columns: minmax(0, 1fr) minmax(300px, 46%); }
  .cbt-body.with-pad .qnav { display: none; }
}
.cbt-body.with-pad .qview-inner.with-guide { display: block; max-width: var(--paper-w, 860px); }
.cbt-body.with-pad #guidebox { position: static; max-height: none; overflow: visible; }
@media (max-width: 760px) {
  .cbt-body.with-pad { grid-template-columns: 1fr; grid-template-rows: auto minmax(0, 1fr) 42dvh; }
  .pad { border-left: 0; border-top: 2px solid var(--accent); }
}

/* ---------- ads.js ---------- */
#ad-rails { display: none; }
@media (min-width: 1400px) {
  body.with-ads #ad-rails { display: block; }
  .ad-rail { position: fixed; top: 96px; width: 160px; z-index: 1; }
  .ad-rail.left { left: calc(50% - 530px - 184px); }
  .ad-rail.right { right: calc(50% - 530px - 184px); }
  .ad-rail img { display: block; width: 160px; height: 600px; object-fit: cover; border-radius: 6px; }
}
.ad-lbl { display: block; font-size: 10.5px; color: var(--muted); margin-bottom: 2px; }
.ad-preview { width: 160px; height: 600px; display: flex; align-items: center; justify-content: center; text-align: center; background: repeating-linear-gradient(45deg, var(--surface-2), var(--surface-2) 10px, var(--surface) 10px, var(--surface) 20px); border: 1px dashed var(--border); color: var(--muted); border-radius: 6px; font-size: 13px; }
.unans-note { font-size: 13px; background: var(--surface-2); border-left: 3px solid var(--flag); border-radius: 6px; padding: 8px 12px; margin: 10px 0; }

/* ---------- transitions & streak ---------- */
@keyframes in-fwd { from { opacity: 0; transform: translateX(22px); } to { opacity: 1; transform: none; } }
@keyframes in-back { from { opacity: 0; transform: translateX(-22px); } to { opacity: 1; transform: none; } }
@keyframes in-up { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes fade-out { to { opacity: 0; } }
@keyframes pop-in { from { opacity: 0; transform: translateY(10px) scale(.97); } to { opacity: 1; transform: none; } }
@keyframes pop-out { to { opacity: 0; transform: translateY(6px) scale(.98); } }
@keyframes grow { from { transform: scaleX(0); } }
.anim-fwd { animation: in-fwd .28s cubic-bezier(.2,.8,.2,1) both; }
.anim-back { animation: in-back .28s cubic-bezier(.2,.8,.2,1) both; }
::view-transition-old(root) { animation: fade-out .16s ease-in both; }
::view-transition-new(root) { animation: in-fwd .3s cubic-bezier(.2,.8,.2,1) both; }
html[data-nav="back"]::view-transition-new(root) { animation-name: in-back; }
.modal-back { animation: fade-in .18s ease-out both; }
.modal-back .modal { animation: pop-in .24s cubic-bezier(.2,.8,.2,1) both; }
.modal-back.closing { animation: fade-out .14s ease-in both; pointer-events: none; }
.modal-back.closing .modal { animation: pop-out .14s ease-in both; }
.feedback { animation: in-up .32s cubic-bezier(.2,.8,.2,1) both; }
.guide, .today, .unans-note { animation: in-up .26s cubic-bezier(.2,.8,.2,1) both; }
.g-body { animation: fade-in .22s ease-out both; }
.grid > .card, .summary > .stat { animation: in-up .32s cubic-bezier(.2,.8,.2,1) both; }
.grid > .card:nth-child(2), .summary > .stat:nth-child(2) { animation-delay: .03s; }
.grid > .card:nth-child(3), .summary > .stat:nth-child(3) { animation-delay: .06s; }
.grid > .card:nth-child(4), .summary > .stat:nth-child(4) { animation-delay: .09s; }
.bar > i, .gbar > i { transform-origin: left center; animation: grow .7s cubic-bezier(.2,.8,.2,1) both; }
.btn, .opt, .chip, .g-chip, .tab, .choice-item { transition: background-color .15s ease, border-color .15s ease, color .15s ease, box-shadow .15s ease, transform .1s ease; }
.btn:active:not(:disabled), .opt:active:not(:disabled), .chip:active { transform: scale(.97); }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after, ::view-transition-old(root), ::view-transition-new(root) { animation: none !important; transition: none !important; }
  .qview { scroll-behavior: auto; }
}

.t-stat.streak { align-items: flex-start; position: relative; overflow: hidden; --flame: 30px; --glow: transparent; }
.t-stat.streak .flame { position: relative; flex: none; width: 52px; text-align: center; line-height: 1; padding-top: 6px; }
.t-stat.streak .fl { display: inline-block; font-size: var(--flame); filter: grayscale(1); opacity: .45; transform-origin: 50% 90%; transition: font-size .3s ease; }
.t-stat.streak.done .fl, .t-stat.streak.pending.tier-1 .fl, .t-stat.streak.pending:not(.tier-0) .fl { filter: none; opacity: 1; }
.t-stat.streak.pending:not(.tier-0) .fl { opacity: .7; }
.t-stat.streak.done .fl { animation: flicker 1.6s ease-in-out infinite; filter: drop-shadow(0 0 6px var(--glow)); }
.t-stat.streak .crown { position: absolute; top: -4px; left: 50%; transform: translateX(-50%) rotate(-8deg); font-size: 18px; }
.st-body { flex: 1; min-width: 0; }
.t-stat.streak .sn { font-size: 30px; }
.st-sub b { font-size: inherit !important; }
.tier { display: inline-block; font-size: 11px; font-weight: 800; padding: 2px 8px; border-radius: 99px; vertical-align: 4px; margin-left: 4px; color: #fff; }
.tier.t2 { background: #d97706; } .tier.t3 { background: #c2410c; } .tier.t4 { background: linear-gradient(90deg, #f59e0b, #db2777); }
.tier.t5 { background: linear-gradient(90deg, #9333ea, #2563eb); } .tier.t6 { background: linear-gradient(90deg, #f59e0b, #dc2626, #db2777, #9333ea); }
.t-stat.streak.tier-1 { --flame: 30px; --glow: rgba(245, 158, 11, .5); }
.t-stat.streak.tier-2 { --flame: 36px; --glow: rgba(217, 119, 6, .7); background: linear-gradient(135deg, var(--surface-2), rgba(245, 158, 11, .12)); }
.t-stat.streak.tier-3 { --flame: 42px; --glow: rgba(234, 88, 12, .85); background: linear-gradient(135deg, var(--surface-2), rgba(234, 88, 12, .2)); }
.t-stat.streak.tier-4 { --flame: 46px; --glow: rgba(219, 39, 119, .85); background: linear-gradient(135deg, rgba(234, 88, 12, .16), rgba(219, 39, 119, .2)); }
.t-stat.streak.tier-5 { --flame: 50px; --glow: rgba(147, 51, 234, .9); background: linear-gradient(135deg, rgba(147, 51, 234, .18), rgba(37, 99, 235, .2)); }
.t-stat.streak.tier-6 { --flame: 54px; --glow: rgba(245, 158, 11, 1); background: linear-gradient(135deg, rgba(245, 158, 11, .22), rgba(219, 39, 119, .18), rgba(147, 51, 234, .22)); }
.st-goal { position: relative; height: 16px; margin: 6px 0 4px; border-radius: 99px; background: rgba(127,127,127,.18); overflow: hidden; }
.st-goal > i { display: block; height: 100%; border-radius: 99px; background: linear-gradient(90deg, #fbbf24, #d97706); transform-origin: left center; animation: grow .8s cubic-bezier(.2,.8,.2,1) both; }
.st-goal > span { position: absolute; right: 8px; top: 0; font-size: 10.5px; line-height: 16px; font-weight: 700; color: var(--muted); }
.st-week { display: flex; gap: 5px; margin: 4px 0 2px; }
.st-week .sd { width: 14px; height: 14px; border-radius: 50%; background: rgba(127,127,127,.22); display: inline-block; }
.st-week .sd.on { background: linear-gradient(135deg, #fbbf24, #d97706); box-shadow: 0 0 0 1px rgba(217,119,6,.3); }
.st-week .sd.sd-today:not(.on) { background: transparent; box-shadow: inset 0 0 0 2px var(--accent); animation: pulse 1.6s ease-in-out infinite; }
.t-stat.streak.pending:not(.tier-0) .st-sub { color: var(--flag); font-weight: 600; }
.t-stat.streak.milestone .st-sub { font-weight: 800; color: var(--text); }
.t-stat.streak.milestone .fl { animation: celebrate .9s cubic-bezier(.2,.8,.2,1) 1, flicker 1.6s ease-in-out .9s infinite; }
@keyframes flicker { 0%, 100% { transform: scale(1) rotate(-2deg); } 50% { transform: scale(1.08) rotate(2deg); } }
@keyframes celebrate { 0% { transform: scale(.4); } 60% { transform: scale(1.35); } 100% { transform: scale(1); } }
@keyframes pulse { 50% { box-shadow: inset 0 0 0 2px rgba(245,158,11,.35); } }
@media (prefers-reduced-motion: reduce) { .t-stat.streak .fl, .st-week .sd.sd-today { animation: none !important; } }
