:root {
  --bg: #f3f6f6;
  --surface: #ffffff;
  --surface-2: #eaf0f0;
  --text: #162425;
  --muted: #526668;
  --border: #cfdbdc;
  --accent: #0f766e;
  --accent-ink: #ffffff;
  --accent-soft: #e0f5f2;
  --sub-a2: #0f766e;
  --sub-a2-soft: #e0f5f2;
  --sub-b: #047857;
  --sub-b-soft: #dcfce7;
  --ok: #15803d;
  --ok-soft: #dcfce7;
  --ng: #c23b2a;
  --ng-soft: #fbe6e3;
  --flag: #b45309;
  --flag-soft: #fef3c7;
  --shadow: 0 1px 2px rgba(15, 40, 38, .06), 0 2px 8px rgba(15, 40, 38, .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: #0f1516;
    --surface: #172022;
    --surface-2: #202c2e;
    --text: #e4eded;
    --muted: #93a8aa;
    --border: #2f4042;
    --accent: #2dd4bf;
    --accent-ink: #072623;
    --accent-soft: #143533;
    --sub-a2: #2dd4bf;
    --sub-a2-soft: #143533;
    --sub-b: #4ade80;
    --sub-b-soft: #143322;
    --ok: #4ade80;
    --ok-soft: #143322;
    --ng: #ff7d6b;
    --ng-soft: #3a1d1a;
    --flag: #fbbf24;
    --flag-soft: #3a2c14;
    --shadow: none;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0f1516;
  --surface: #172022;
  --surface-2: #202c2e;
  --text: #e4eded;
  --muted: #93a8aa;
  --border: #2f4042;
  --accent: #2dd4bf;
  --accent-ink: #072623;
  --accent-soft: #143533;
  --sub-a2: #2dd4bf;
  --sub-a2-soft: #143533;
  --sub-b: #4ade80;
  --sub-b-soft: #143322;
  --ok: #4ade80;
  --ok-soft: #143322;
  --ng: #ff7d6b;
  --ng-soft: #3a1d1a;
  --flag: #fbbf24;
  --flag-soft: #3a2c14;
  --shadow: none;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; overflow-x: clip; }
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, textarea { 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-card: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; }
.theme-btn { min-height: 34px; padding: 0 10px; font-size: 13px; }

/* ---------- home ---------- */
.wrap { max-width: 1040px; margin: 0 auto; padding: 0 16px 48px; }
.site-head { display: flex; align-items: center; gap: 12px; padding: 18px 0 8px; }
.logo { width: 38px; height: 38px; border-radius: 9px; background: var(--accent); color: var(--accent-ink); display: grid; place-items: center; font-weight: 800; font-size: 13px; flex: none; letter-spacing: -.02em; }
.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; }
@media (max-width: 640px) { .site-head { flex-wrap: wrap; } }

.summary { display: grid; grid-template-columns: repeat(4, minmax(0, 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); min-width: 0; }
.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: 13px; 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(min(290px, 100%), 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; min-width: 0; }
.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; }

.badge { display: inline-block; font-size: 12px; padding: 1px 8px; border-radius: 99px; background: var(--surface-2); color: var(--muted); font-weight: 600; white-space: nowrap; }
.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.sub-a2 { background: var(--sub-a2-soft); color: var(--sub-a2); }
.badge.sub-b { background: var(--sub-b-soft); color: var(--sub-b); }

.dots { display: flex; gap: 4px; flex-wrap: wrap; align-items: center; }
.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); }
.dots-sep { width: 2px; height: 18px; background: var(--border); margin: 0 3px; border-radius: 2px; }

.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; }

.qtable-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
.qtable { width: 100%; border-collapse: collapse; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.qtable-wrap .qtable { border: 0; border-radius: 0; }
.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; display: flex; align-items: center; gap: 8px; }
.genre { display: flex; align-items: center; gap: 10px; background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; cursor: pointer; min-width: 0; }
.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; flex-wrap: wrap; }
.genre .cnt { font-size: 13px; color: var(--muted); white-space: nowrap; }
.genre-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(260px, 100%), 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; min-width: 0; }
.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); }

.field { display: block; margin: 0 0 12px; }
.field span { display: block; font-size: 13px; font-weight: 700; margin-bottom: 4px; }
.field input, .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); }
.field input:focus, .field select:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.form-msg { margin: 0; font-size: 14px; }
.form-msg:empty { display: none; }
.form-msg.ng { color: var(--ng); }
.form-msg.ok { color: var(--ok); }
.form-note { color: var(--muted); font-size: 13px; }

/* ---------- 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: #134e4a; 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,.14); white-space: nowrap; }
.timer.warn { background: #c23b2a; }
.cbt-top .btn { min-height: 34px; background: rgba(255,255,255,.12); border-color: rgba(255,255,255,.28); color: #fff; }
.cbt-top .btn.finish { background: #fff; color: #134e4a; border-color: #fff; }

.cbt-body { display: grid; grid-template-columns: 182px 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: 6px; }
.qnav .legend { font-size: 11px; color: var(--muted); line-height: 1.5; margin-bottom: 4px; }
.qnav button { display: flex; align-items: center; gap: 6px; border: 1px solid var(--border); background: var(--surface); border-radius: 6px; padding: 6px 8px; cursor: pointer; font-size: 13px; text-align: left; }
.qnav button .n { font-weight: 700; }
.qnav button .subtag { font-size: 10px; font-weight: 700; padding: 0 5px; border-radius: 4px; background: var(--surface-2); color: var(--muted); }
.qnav button .subtag.b { background: var(--sub-b-soft); color: var(--sub-b); }
.qnav button .subtag.a2 { background: var(--sub-a2-soft); color: var(--sub-a2); }
.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; min-width: 0; }
.qview-inner { margin: 0 auto; max-width: var(--paper-w, 820px); min-width: 0; }
.paper { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px 22px; margin-bottom: 12px; color: var(--text); }
.paper.text { font-size: 15px; line-height: 1.75; overflow-wrap: break-word; }
.qhead { display: flex; align-items: center; flex-wrap: wrap; gap: 8px 10px; margin-bottom: 10px; }
.qhead h2 { margin: 0; font-size: 17px; }
.qhead .meta { color: var(--muted); font-size: 13px; }

.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: 44px; height: 44px; border-radius: 8px; border: 1.5px solid var(--border); background: var(--surface); font-size: 18px; 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; }

/* ---------- Markdown / ケーススタディ / 選択肢カード ---------- */
.q-sec-label { display: inline-block; font-size: 11.5px; font-weight: 700; letter-spacing: .04em; padding: 2px 9px; border-radius: 99px; background: var(--surface-2); color: var(--muted); margin-bottom: 8px; }
.q-sec-label.b { background: var(--sub-b-soft); color: var(--sub-b); }
.q-scenario { padding-bottom: 14px; margin-bottom: 14px; border-bottom: 1px dashed var(--border); }
.q-prompt { min-width: 0; }
.qtext, .explain { min-width: 0; overflow-wrap: break-word; }
.qtext p, .explain p { margin: 0 0 10px; }
.qtext p:last-child, .explain p:last-child { margin-bottom: 0; }
.qtext ul, .qtext ol, .explain ul, .explain ol { margin: 6px 0 10px; padding-left: 1.45em; }
.qtext li > ul, .qtext li > ol, .explain li > ul, .explain li > ol { margin: 4px 0 4px; }
.qtext blockquote, .explain blockquote { margin: 8px 0 12px; padding: 8px 14px; border-left: 3px solid var(--accent); background: var(--surface-2); border-radius: 0 6px 6px 0; color: var(--text); }
.qtext blockquote p:last-child, .explain blockquote p:last-child { margin-bottom: 0; }
.qtext pre, .explain pre { font-family: var(--mono); font-size: 13px; line-height: 1.55; background: var(--surface-2); color: var(--text); border: 1px solid var(--border); padding: 10px 14px; border-radius: 6px; overflow-x: auto; margin: 8px 0 12px; }
.qtext code, .explain code { font-family: var(--mono); background: var(--surface-2); padding: 1px 5px; border-radius: 4px; font-size: .91em; }
.qtext pre code, .explain pre code { background: none; padding: 0; font-size: 1em; }
.qtext h4, .explain h4 { margin: 14px 0 6px; font-size: 15px; line-height: 1.45; }
.qtext h4.case-h, .explain h4.case-h { padding: 4px 10px; border-left: 3px solid var(--accent); background: var(--accent-soft); border-radius: 0 6px 6px 0; font-size: 14.5px; }
.explain h4:first-child, .explain .ex-title + h4 { margin-top: 4px; }
.ex-tbl { overflow-x: auto; margin: 8px 0 12px; max-width: 100%; }
.ex-tbl table { border-collapse: collapse; font-size: 13.5px; min-width: 50%; }
.ex-tbl th, .ex-tbl td { border: 1px solid var(--border); padding: 5px 10px; text-align: left; vertical-align: top; }
.ex-tbl th { background: var(--surface-2); font-weight: 700; }
/* 狭い画面では列を潰さず、表だけを横スクロールさせる */
@media (max-width: 760px) {
  .ex-tbl table { width: max-content; min-width: 100%; }
  .ex-tbl th, .ex-tbl td { min-width: 4em; max-width: 15em; }
  .ex-tbl th { white-space: nowrap; }
  .svg-fig svg { min-width: 520px; } /* 図の文字が読める大きさを保ち、図だけを横スクロールさせる */
}

.q-choices { display: grid; gap: 8px; margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--border); }
.choice-card { display: flex; align-items: flex-start; gap: 10px; border: 1.5px solid var(--border); border-radius: 8px; padding: 10px 12px; background: var(--surface); text-align: left; min-width: 0; transition: border-color .15s ease, background-color .15s ease; }
.choice-card.clickable { cursor: pointer; }
.choice-card.clickable:hover { border-color: var(--accent); }
.choice-card.selected { border-color: var(--accent); background: var(--accent-soft); }
.choice-card.correct { border-color: var(--ok); background: var(--ok-soft); }
.choice-card.wrong { border-color: var(--ng); background: var(--ng-soft); }
.choice-key { flex: none; width: 30px; height: 30px; border-radius: 7px; border: 1px solid var(--border); background: var(--surface-2); display: grid; place-items: center; font-weight: 800; font-size: 15px; }
.choice-card.selected .choice-key { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.choice-card.correct .choice-key { background: var(--ok); color: #fff; border-color: var(--ok); }
.choice-card.wrong .choice-key { background: var(--ng); color: #fff; border-color: var(--ng); }
.choice-body { flex: 1; min-width: 0; overflow-wrap: break-word; }
.choice-body p { margin: 0 0 6px; }
.choice-body p:last-child { margin-bottom: 0; }
.choice-body pre { font-family: var(--mono); font-size: 12.5px; line-height: 1.5; background: var(--surface-2); border: 1px solid var(--border); padding: 8px 10px; border-radius: 6px; overflow-x: auto; margin: 6px 0; }
.choice-body code { font-family: var(--mono); background: var(--surface-2); padding: 1px 4px; border-radius: 4px; font-size: .9em; }
.choice-body pre code { background: none; padding: 0; }
.choice-body .ex-tbl { margin: 6px 0; }

/* ---------- SVG 図（ダークモード対応） ---------- */
.svg-fig { margin: 12px 0; overflow-x: auto; text-align: center; }
.svg-fig svg { display: block; max-width: 100%; height: auto; margin: 0 auto; color: var(--text); fill: currentColor; }
.svg-fig .svg-accent { fill: var(--accent); }
.svg-fig .svg-soft { fill: var(--accent-soft); }
.svg-fig .svg-accent-line { stroke: var(--accent); }
.svg-placeholder { margin: 10px 0; padding: 12px 14px; border: 1px dashed var(--border); border-radius: 8px; background: var(--surface-2); color: var(--muted); font-size: 13px; text-align: center; }

/* ---------- 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: 3px; font-size: 14px; min-width: 0; }
.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); }

.subj-split { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin: 10px 0 14px; }
.subj-box { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px; box-shadow: var(--shadow); }
.subj-box .sk { font-size: 12px; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.subj-box .sv { font-size: 20px; font-weight: 700; font-variant-numeric: tabular-nums; margin-top: 4px; }
.subj-box .sv small { font-size: 13px; color: var(--muted); font-weight: 500; }
@media (max-width: 640px) { .subj-split { grid-template-columns: 1fr; } }

.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 .ex-title { margin: 0 0 8px; font-size: 16px; }
.verdict { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; 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: 180px; }

/* ---------- 未保存の警告 ---------- */
#unsaved-bar { position: sticky; top: 0; z-index: 40; display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 8px 16px; background: var(--ng-soft); border-bottom: 2px solid var(--ng); color: var(--text); font-size: 13px; max-height: 40dvh; overflow: auto; }
#unsaved-bar[hidden], .unsaved-tag[hidden] { display: none; }
#unsaved-bar p { margin: 0; flex: 1; min-width: 220px; }
body.exam-mode .cbt { height: calc(100dvh - var(--unsaved-h, 0px)); }

/* ---------- 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(92px, 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: 13px; }
.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; flex-wrap: wrap; }
.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 (360px 含む) ---------- */
@media (max-width: 760px) {
  body { font-size: 14px; }
  .wrap { padding: 0 12px 40px; }
  .summary { grid-template-columns: repeat(2, minmax(0, 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; }
  .qview { padding: 10px; }
  .paper { padding: 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: 40px; height: 40px; }
  .qtable .hide-sm { display: none; }
  .qtext pre, .explain pre { font-size: 12px; padding: 8px 10px; }
}

/* ---------- 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: #14532d; }
.cbt.practice .cbt-top .btn.finish { color: #14532d; }
.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; }

/* ---------- 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; white-space: normal; }
.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; max-width: 100%; }
.cal-days { display: grid; grid-template-rows: 14px repeat(7, 13px); gap: 3px; font-size: 10px; color: var(--muted); flex: none; }
.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(min(170px, 100%), 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); min-width: 0; }
.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: 14px; }
.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: 2px; }

.badges { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(150px, 100%), 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, 820px); 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: #fff; font-weight: 700; }
.g-chip:disabled { cursor: default; opacity: .7; }
.g-body { font-size: 15px; line-height: 1.75; }
.g-body p { margin: 0 0 8px; }
.g-way { margin: 0 0 8px; padding-left: 1.5em; }
.g-way li { margin-bottom: 5px; }
.g-checks { list-style: none; padding: 0; margin: 0 0 8px; display: grid; gap: 6px; }
.g-checks li { background: var(--surface-2); border-left: 3px solid var(--flag); border-radius: 4px; padding: 6px 10px; font-size: 14px; }
.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, 820px) + 460px); display: grid; grid-template-columns: minmax(0, 1fr) clamp(360px, 34vw, 460px); 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: #134e4a; 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 .qbody { 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: 182px 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, #fff); 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, 820px); }
.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% - 520px - 184px); }
  .ad-rail.right { right: calc(50% - 520px - 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; }

/* ---------- アニメーション ---------- */
@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; }
.grid > .card:nth-child(5) { animation-delay: .12s; }
.grid > .card:nth-child(6) { animation-delay: .15s; }
.grid > .card:nth-child(n+7) { animation-delay: .18s; }
.bar > i, .gbar > i { transform-origin: left center; animation: grow .7s cubic-bezier(.2,.8,.2,1) both; }
.btn, .opt, .chip, .g-chip, .tab { 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); }
.qview { scroll-behavior: smooth; }
@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: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: #f76707; } .tier.t3 { background: #e8590c; } .tier.t4 { background: linear-gradient(90deg, #f76707, #d6336c); }
.tier.t5 { background: linear-gradient(90deg, #0f766e, #0ea5e9); } .tier.t6 { background: linear-gradient(90deg, #f59f00, #e8590c, #d6336c, #0f766e); }
.t-stat.streak.tier-1 { --flame: 30px; --glow: rgba(255, 146, 43, .5); }
.t-stat.streak.tier-2 { --flame: 36px; --glow: rgba(255, 120, 30, .7); background: linear-gradient(135deg, var(--surface-2), rgba(255, 146, 43, .12)); }
.t-stat.streak.tier-3 { --flame: 42px; --glow: rgba(255, 90, 30, .85); background: linear-gradient(135deg, var(--surface-2), rgba(255, 107, 53, .2)); }
.t-stat.streak.tier-4 { --flame: 46px; --glow: rgba(240, 62, 120, .85); background: linear-gradient(135deg, rgba(255, 107, 53, .16), rgba(214, 51, 108, .2)); }
.t-stat.streak.tier-5 { --flame: 50px; --glow: rgba(45, 212, 191, .75); background: linear-gradient(135deg, rgba(15, 118, 110, .18), rgba(14, 165, 233, .2)); }
.t-stat.streak.tier-6 { --flame: 54px; --glow: rgba(245, 159, 0, 1); background: linear-gradient(135deg, rgba(245, 159, 0, .22), rgba(214, 51, 108, .18), rgba(15, 118, 110, .22)); }
.t-stat.streak.tier-5.done::after, .t-stat.streak.tier-6.done::after { content: ""; position: absolute; inset: 0; background: linear-gradient(110deg, transparent 40%, rgba(255,255,255,.18) 50%, transparent 60%); background-size: 250% 100%; animation: shimmer 3.2s ease-in-out infinite; pointer-events: none; }
.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, #ffa94d, #f76707); transform-origin: left center; animation: grow .8s cubic-bezier(.2,.8,.2,1) both; }
.tier-4 .st-goal > i { background: linear-gradient(90deg, #f76707, #d6336c); }
.tier-5 .st-goal > i, .tier-6 .st-goal > i { background: linear-gradient(90deg, #0f766e, #0ea5e9); }
.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, #ffa94d, #f76707); box-shadow: 0 0 0 1px rgba(247,103,7,.3); }
.tier-5 .st-week .sd.on, .tier-6 .st-week .sd.on { background: linear-gradient(135deg, #2dd4bf, #0ea5e9); }
.st-week .sd.sd-today:not(.on) { background: transparent; box-shadow: inset 0 0 0 2px #f76707; animation: pulse 1.6s ease-in-out infinite; }
.t-stat.streak.pending:not(.tier-0) .st-sub { color: #d9480f; 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(247,103,7,.35); } }
@keyframes shimmer { 0% { background-position: 150% 0; } 100% { background-position: -100% 0; } }
@media (prefers-reduced-motion: reduce) { .t-stat.streak .fl, .st-week .sd.sd-today { animation: none !important; } }

/* 幅の狭いスマホでメモ帳・マーカーの操作列がはみ出さないようにする */
.mk-c { flex: none; }
@media (max-width: 760px) {
  .with-pad .mk-bar { flex-wrap: wrap; }
  .pad-head { flex-wrap: wrap; gap: 6px; padding: 6px 8px; }
  .pad-tabs button { padding: 5px 8px; }
}

/* 狭い画面では警告を小さくし、メモ帳を開いていても問題文が見えるようにする */
@media (max-width: 760px) {
  #unsaved-bar { padding: 4px 10px; gap: 4px; font-size: 11.5px; line-height: 1.4; }
  #unsaved-bar p { max-height: 4.2em; overflow: auto; }
  #unsaved-bar .u-more { display: none; }
  #unsaved-bar:not([hidden]) ~ #app .cbt-body.with-pad { grid-template-rows: auto minmax(0, 1fr) 30dvh; }
}
