/* kaiba: 飾らず、読みやすく、速く。色は正誤にだけ使う。 */

:root {
  --bg: #ffffff;
  --bg-2: #f5f5f4;
  --bg-3: #ecebea;
  --text: #17181a;
  --text-2: #5f6368;
  --text-3: #80848a;
  --line: #e4e4e2;
  --line-2: #cfcfcc;
  --primary: #17181a;
  --on-primary: #ffffff;
  --link: #1a56c4;
  --ok: #0c7a4d;
  --ok-bg: #e8f5ee;
  --ng: #c8322b;
  --ng-bg: #fcecea;
  --sel: #eef1f6;
  --fig: #ffffff;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Yu Gothic UI", "Noto Sans JP", Meiryo, sans-serif;
  --read: var(--font);
  --stem: 16.5px;
  --r: 8px;
  color-scheme: light;
}
:root[data-font="mincho"] { --read: "Hiragino Mincho ProN", "Yu Mincho", "Noto Serif JP", serif; }
:root[data-size="s"] { --stem: 15px; }
:root[data-size="l"] { --stem: 18.5px; }
:root[data-size="xl"] { --stem: 21px; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #111214; --bg-2: #1b1c1f; --bg-3: #26282c;
    --text: #ececec; --text-2: #a4a7ac; --text-3: #85888e;
    --line: #2a2c30; --line-2: #3d3f44;
    --primary: #ececec; --on-primary: #111214;
    --link: #7fadf7;
    --ok: #4cc38a; --ok-bg: #12291f; --ng: #ff7b72; --ng-bg: #33191a;
    --sel: #23262c;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #111214; --bg-2: #1b1c1f; --bg-3: #26282c;
  --text: #ececec; --text-2: #a4a7ac; --text-3: #85888e;
  --line: #2a2c30; --line-2: #3d3f44;
  --primary: #ececec; --on-primary: #111214;
  --link: #7fadf7;
  --ok: #4cc38a; --ok-bg: #12291f; --ng: #ff7b72; --ng-bg: #33191a;
  --sel: #23262c;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-padding-top: 64px; }
body { margin: 0; min-height: 100dvh; background: var(--bg); color: var(--text); font-family: var(--font); font-size: 15px; line-height: 1.6; -webkit-font-smoothing: antialiased; }
a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; }
button { font: inherit; color: inherit; }
button, a, summary, label { -webkit-tap-highlight-color: transparent; touch-action: manipulation; }
main { display: block; max-width: 680px; margin: 0 auto; padding: 24px 20px 88px; }
main:focus, main:focus-visible { outline: none; }
:focus-visible { outline: 2px solid var(--link); outline-offset: 2px; }
h1, h2, h3 { font-weight: 650; letter-spacing: -.005em; font-feature-settings: "palt"; }
h1 { font-size: 1.45rem; line-height: 1.3; margin: 0 0 14px; }
h2 { font-size: .8rem; font-weight: 600; color: var(--text-2); margin: 32px 0 8px; letter-spacing: 0; }
p { margin: 0 0 10px; }
small, .muted { color: var(--text-2); font-size: .84rem; }
.num { font-variant-numeric: tabular-nums; }
.skip { position: absolute; left: -999px; }
.skip:focus { left: 8px; top: 8px; background: var(--bg); padding: 8px; z-index: 30; }
.section-note { color: var(--text-2); font-size: .82rem; margin: -2px 0 10px; }

/* ヘッダー */
html { overflow-x: clip; }
.site-header { display: flex; align-items: center; gap: 12px; padding: 14px max(20px, calc((100% - 1120px) / 2)); border-bottom: 1px solid var(--line); }
body.in-question .site-header { display: none; }
.brand { color: var(--text); margin-right: auto; }
.brand:hover { text-decoration: none; }
.brand-name { font-weight: 700; font-size: 1.12rem; letter-spacing: -.02em; }
.site-header nav { display: flex; gap: 20px; }
.site-header nav a { color: var(--text-2); font-size: .88rem; }
.site-header nav a:hover { color: var(--text); text-decoration: none; }
.site-header nav a[aria-current="page"] { color: var(--text); font-weight: 600; }
.site-footer { max-width: 680px; margin: 0 auto; padding: 16px 20px 28px; color: var(--text-3); font-size: .74rem; line-height: 1.7; border-top: 1px solid var(--line); }
.site-footer a { color: var(--text-2); }
.site-footer p { margin: 0 0 4px; }

/* ボタン */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 46px; padding: 8px 18px;
  border: 1px solid var(--line-2); border-radius: var(--r); background: var(--bg); color: var(--text);
  font-weight: 600; cursor: pointer; transition: background-color .1s, opacity .1s;
}
.btn:hover { background: var(--bg-2); text-decoration: none; }
.btn:active { opacity: .7; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: var(--on-primary); }
.btn.primary:hover { opacity: .88; background: var(--primary); }
.btn[disabled] { color: var(--text-3); background: transparent; border-color: var(--line); cursor: not-allowed; }
.btn.primary[disabled] { background: var(--bg-3); border-color: var(--bg-3); color: var(--text-3); opacity: 1; }
.btn.small { min-height: 36px; padding: 4px 12px; font-size: .84rem; font-weight: 500; }
.btn.wide { width: 100%; }
.text-btn { background: none; border: 0; padding: 4px 0; color: var(--link); cursor: pointer; font-size: .84rem; }

/* 今日 */
.today-head { display: flex; justify-content: space-between; gap: 12px; color: var(--text-2); font-size: .82rem; margin-bottom: 2px; }
.today-head b { color: var(--text); font-weight: 600; }
.today-lead { font-size: 1.75rem; font-weight: 650; letter-spacing: -.01em; line-height: 1.25; margin: 0; font-feature-settings: "palt"; }
.today-sub { color: var(--text-2); font-size: .88rem; margin: 2px 0 14px; }
.today-sub small { font-size: .8rem; }
.today-actions { display: grid; grid-template-columns: 1fr auto; gap: 8px; }
.today-actions.single { grid-template-columns: 1fr; }
.today-bar { height: 3px; background: var(--bg-3); margin-top: 16px; border-radius: 2px; overflow: hidden; }
.today-bar i { display: block; height: 100%; background: var(--primary); transition: width .3s ease; }
.today-count { display: flex; justify-content: space-between; color: var(--text-2); font-size: .76rem; margin-top: 4px; font-variant-numeric: tabular-nums; }
.hello { font-size: .86rem; color: var(--text-2); margin: 16px 0 0; }
.scope-line { font-size: .8rem; color: var(--text-2); margin: 14px 0 0; }
.scope-line a { white-space: nowrap; }

/* 学習記録 */
.activity-head { display: flex; justify-content: space-between; align-items: baseline; margin: 32px 0 8px; }
.activity-head h2 { margin: 0; }
.activity-head span { font-size: .8rem; color: var(--text-2); font-variant-numeric: tabular-nums; }
.activity { display: grid; grid-template-rows: repeat(7, auto); grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); gap: 2px; max-width: 400px; }
.activity i { display: block; aspect-ratio: 1; border-radius: 1.5px; background: var(--bg-3); }
.activity i.l1 { background: color-mix(in srgb, var(--primary) 28%, var(--bg-3)); }
.activity i.l2 { background: color-mix(in srgb, var(--primary) 52%, var(--bg-3)); }
.activity i.l3 { background: color-mix(in srgb, var(--primary) 76%, var(--bg-3)); }
.activity i.l4 { background: var(--primary); }
.activity i.future { background: transparent; }
.activity i.now { outline: 1px solid var(--text-2); outline-offset: 0; }

/* 行 */
.rows { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--line); }
.rows > li { border-bottom: 1px solid var(--line); }
.row { display: flex; align-items: center; gap: 12px; width: 100%; min-height: 50px; padding: 7px 0; background: none; border: 0; text-align: left; color: var(--text); cursor: pointer; }
.row:hover { text-decoration: none; }
.row:hover .row-main { color: var(--link); }
.row-main { flex: 1; min-width: 0; font-weight: 500; }
.row-main small { display: block; font-weight: 400; font-size: .78rem; line-height: 1.4; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row-count { color: var(--text-2); font-variant-numeric: tabular-nums; font-size: .88rem; }
.row-go { color: var(--text-3); }

/* 回とブロック */
.ledger { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--line); }
.ledger > li { display: grid; grid-template-columns: 62px 1fr; gap: 8px; align-items: center; padding: 6px 0; border-bottom: 1px solid var(--line); }
.ledger-exam { line-height: 1.2; }
.ledger-exam b { display: block; font-size: 1rem; font-weight: 600; font-variant-numeric: tabular-nums; }
.ledger-exam small { font-size: .7rem; color: var(--text-3); }
.ledger-blocks { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 3px; }
.block {
  position: relative; overflow: hidden; display: flex; flex-direction: column; align-items: center; justify-content: center;
  min-height: 42px; padding: 2px; background: var(--bg-2); border: 0; border-radius: 5px; cursor: pointer; line-height: 1.15;
}
.block:hover { background: var(--bg-3); }
.block b { position: relative; font-size: .88rem; font-weight: 600; }
.block small { position: relative; font-size: .62rem; color: var(--text-2); font-variant-numeric: tabular-nums; }
.block .fill { position: absolute; left: 0; bottom: 0; height: 3px; background: var(--primary); }
.block.off b, .block.off small { color: var(--text-3); }
.block .hissu { color: var(--text-2); font-size: .58rem; font-weight: 500; }

/* 問題 */
/* 本文の幅に関係なく画面幅いっぱいに線を引く */
.q-bar { position: sticky; top: 0; z-index: 10; margin: -24px calc(50% - 50vw) 0; padding: 0 calc(50vw - 50%); background: var(--bg); border-bottom: 1px solid var(--line); }
.q-bar-row { margin-left: -8px; margin-right: -8px; }
.q-bar-row { display: flex; align-items: center; gap: 2px; min-height: 50px; }
.q-title { margin: 0 auto 0 4px; font-weight: 600; font-size: .95rem; line-height: 1.25; min-width: 0; font-variant-numeric: tabular-nums; }
.q-title small { display: block; font-weight: 400; color: var(--text-2); font-size: .72rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.icon-btn { width: 40px; height: 40px; flex: none; display: inline-grid; place-items: center; border: 0; border-radius: var(--r); background: transparent; color: var(--text-2); cursor: pointer; }
.icon-btn:hover { background: var(--bg-2); color: var(--text); }
.icon-btn svg { width: 21px; height: 21px; }
.icon-btn[aria-pressed="true"] { color: var(--text); }
.icon-btn[aria-pressed="true"] svg { fill: currentColor; }
.q-progress { position: absolute; left: 0; right: 0; bottom: -1px; height: 2px; z-index: 1; }
.q-progress i { display: block; height: 100%; background: var(--primary); transition: width .2s ease; }
.q-meta { display: flex; flex-wrap: wrap; gap: 2px 8px; font-size: .76rem; color: var(--text-2); margin: 16px 0 8px; }
.q-meta .hissu { color: var(--text); font-weight: 600; }
.q-past { margin-left: auto; }
.sheet { margin-bottom: 8px; }
.stem { font-family: var(--read); font-size: var(--stem); line-height: 1.85; line-break: strict; }
.stem p { margin: 0 0 .75em; overflow-wrap: anywhere; }
.stem p:last-child { margin-bottom: 0; }
.stem b { font-weight: 650; }
.stem u { text-decoration-thickness: 1px; text-underline-offset: 3px; }
.stem sub, .stem sup { font-size: .68em; line-height: 0; }
.qno { font-weight: 650; margin-right: .6em; font-variant-numeric: tabular-nums; }
.lab-k { display: block; margin-top: .6em; font-size: .76em; font-weight: 650; color: var(--text-2); line-height: 1.7; font-family: var(--font); }
.ref { color: var(--text-3); font-size: .88em; }
.shared { background: var(--bg-2); border-radius: var(--r); padding: 10px 14px; margin-bottom: 14px; }
.shared summary { font-size: .78rem; color: var(--text-2); font-weight: 600; cursor: pointer; min-height: 26px; }
.shared .stem { font-size: calc(var(--stem) - 1px); margin-top: 4px; }
.fig-btn { display: block; padding: 0; border: 0; background: none; cursor: zoom-in; max-width: 100%; }
.inline-fig { display: block; max-width: 100%; height: auto; margin: .3em 0 .9em; background: var(--fig); }
.figures { display: flex; flex-wrap: wrap; gap: 12px; margin: 10px 0; }
.figure { margin: 0; max-width: 100%; }
.figure img { display: block; max-width: 100%; max-height: 420px; width: auto; height: auto; background: var(--fig); border-radius: 4px; }
.figure figcaption { font-size: .74rem; color: var(--text-2); margin-top: 4px; }
.notice { padding: 10px 14px; background: var(--bg-2); border-radius: var(--r); margin: 12px 0; font-size: .86rem; color: var(--text-2); }

/* 選択肢 */
.pick-row { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; margin: 16px 0 6px; }
.pick-hint { font-size: .76rem; color: var(--text-2); margin: 0; }
.fig-again { font-size: .78rem; cursor: pointer; }
.options { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.options > li { display: flex; align-items: stretch; border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; transition: border-color .1s, background-color .1s; }
.options > li:hover { border-color: var(--line-2); }
.option { flex: 1; min-width: 0; display: flex; align-items: flex-start; gap: 10px; min-height: 48px; padding: 11px 12px; text-align: left; border: 0; background: transparent; cursor: pointer; font-family: var(--read); font-size: var(--stem); line-height: 1.55; }
.option[disabled] { cursor: default; color: var(--text); }
.option:not([disabled]):active { opacity: .6; }
.opt-key { flex: none; width: 1.3em; color: var(--text-2); font-family: var(--font); font-weight: 600; }
.opt-text { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.options > li:has(.option[aria-pressed="true"]) { border-color: var(--primary); box-shadow: inset 0 0 0 1px var(--primary); background: var(--sel); }
.option[aria-pressed="true"] .opt-key { color: var(--text); }
.options > li.struck .opt-text { text-decoration: line-through; color: var(--text-3); }
.options > li.struck .opt-key { color: var(--text-3); }
.strike { flex: none; width: 42px; border: 0; background: transparent; color: var(--line-2); cursor: pointer; display: grid; place-items: center; }
.strike:hover { color: var(--text); }
.struck .strike { color: var(--text-2); }
.strike svg { width: 15px; height: 15px; }
.options.compact { display: flex; flex-wrap: wrap; }
.options.compact .option { justify-content: center; min-width: 52px; }
.options.compact .opt-key { width: auto; }
.options.answered > li { border-color: var(--line); }
.options.answered > li:hover { border-color: var(--line); }
.options.answered .option { color: var(--text-2); }
.options.answered > li.is-correct { border-color: var(--ok); background: var(--ok-bg); }
.options.answered > li.is-correct .option, .options.answered > li.is-correct .opt-key { color: var(--ok); font-weight: 600; }
.options.answered > li.is-wrong { border-color: var(--ng); background: var(--ng-bg); }
.options.answered > li.is-wrong .option, .options.answered > li.is-wrong .opt-key { color: var(--ng); }
.opt-note { flex: none; align-self: center; display: inline-grid; color: currentColor; }
.opt-note svg { width: 18px; height: 18px; }

/* 計算問題 */
.numeric { margin-top: 14px; }
.numeric label { display: block; font-size: .78rem; color: var(--text-2); margin-bottom: 6px; }
.numeric input { width: 180px; height: 50px; padding: 0 12px; font-size: 1.3rem; letter-spacing: .14em; border: 1px solid var(--line-2); border-radius: var(--r); background: var(--bg); color: var(--text); font-variant-numeric: tabular-nums; }
.numeric input:focus { outline: 2px solid var(--primary); outline-offset: -1px; border-color: transparent; }

/* 結果 */
.verdict { margin-top: 14px; }
.verdict-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 10px; }
.verdict-mark { font-weight: 650; font-size: 1.08rem; }
.verdict-mark.ok { color: var(--ok); }
.verdict-mark.ng { color: var(--ng); }
.verdict-answer { color: var(--text-2); font-size: .9rem; }
.verdict-answer b { color: var(--text); font-weight: 600; }
.memory { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 16px; margin-top: 10px; padding: 8px 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); font-size: .84rem; color: var(--text-2); }
.memory b { color: var(--text); font-weight: 600; }
.rating { display: flex; background: var(--bg-2); border-radius: var(--r); padding: 2px; }
.rating button { min-height: 32px; padding: 0 12px; border: 0; background: transparent; border-radius: 6px; cursor: pointer; font-size: .8rem; color: var(--text-2); }
.rating button[aria-pressed="true"] { background: var(--bg); color: var(--text); font-weight: 600; box-shadow: 0 0 0 1px var(--line-2); }
.note-box { margin-top: 12px; }
.note-box label { display: block; font-size: .76rem; color: var(--text-2); margin-bottom: 4px; }
.note-box textarea { display: block; width: 100%; min-height: 64px; resize: vertical; padding: 8px 10px; font: inherit; font-size: 16px; line-height: 1.5; color: var(--text); background: var(--bg); border: 1px solid var(--line); border-radius: var(--r); }
.note-box textarea:focus { outline: 2px solid var(--primary); outline-offset: -1px; border-color: transparent; }
.source { margin: 12px 0 0; font-size: .74rem; color: var(--text-3); }
.source a { color: var(--text-2); }
.action-bar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 10; background: var(--bg); border-top: 1px solid var(--line); padding: 8px 20px calc(8px + env(safe-area-inset-bottom)); }
.action-inner { max-width: 640px; margin: 0 auto; display: flex; gap: 8px; }
.action-inner .grow { flex: 1; }
.action-inner .btn:not(.grow):not(.exam-grade) { width: 50px; padding: 0; }
.action-inner .btn.exam-grade { padding: 0 14px; font-weight: 500; font-size: .86rem; }
.keys { font-size: .72rem; color: var(--text-3); margin: 12px 0 0; }
@media (hover: none) { .keys { display: none; } }
kbd { font: inherit; padding: 0 4px; border: 1px solid var(--line-2); border-radius: 3px; }
body:has(.action-bar) .site-footer { display: none; }
body:has(.action-bar) main { padding-bottom: 104px; }
.q-body.enter { animation: rise .12s ease-out; }
@keyframes rise { from { opacity: 0; } }
.exam-clock { font-size: .92rem; font-weight: 600; padding: 0 4px; font-variant-numeric: tabular-nums; }
.exam-clock.low { color: var(--ng); }
.nav-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(40px, 1fr)); gap: 3px; margin: 10px 0; }
.nav-grid a { display: grid; place-items: center; height: 36px; font-size: .78rem; border-radius: 5px; color: var(--text); background: var(--bg-2); font-variant-numeric: tabular-nums; }
.nav-grid a:hover { background: var(--bg-3); text-decoration: none; }
.nav-grid a.ok { background: var(--ok-bg); color: var(--ok); }
.nav-grid a.ng { background: var(--ng-bg); color: var(--ng); }
.nav-grid a.filled { background: var(--bg-3); }
.nav-grid a[aria-current="true"] { box-shadow: inset 0 0 0 2px var(--primary); }

/* 結果画面 */
.returned { margin-bottom: 18px; }
.returned-title { font-size: .84rem; color: var(--text-2); margin: 0 0 2px; }
.score { font-size: 2.8rem; font-weight: 650; letter-spacing: -.02em; line-height: 1.1; font-variant-numeric: tabular-nums; }
.score small { font-size: .5em; font-weight: 500; color: var(--text-2); letter-spacing: 0; margin-left: .15em; }
.score-rate { color: var(--text-2); font-size: .88rem; margin: 4px 0 0; }
.answer-sheet { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--line); }
.answer-sheet li { border-bottom: 1px solid var(--line); }
.answer-sheet a { display: flex; gap: 10px; align-items: center; min-height: 44px; padding: 6px 0; color: var(--text); }
.answer-sheet a:hover { text-decoration: none; background: var(--bg-2); }
.answer-sheet .m { width: 18px; flex: none; display: inline-grid; place-items: center; }
.answer-sheet .m svg { width: 16px; height: 16px; }
.answer-sheet .m.ok { color: var(--ok); }
.answer-sheet .m.ng { color: var(--ng); }
.answer-sheet .m.blank { color: var(--text-3); }
.answer-sheet .t { flex: 1; min-width: 0; font-size: .84rem; color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.answer-sheet b { font-weight: 500; font-size: .84rem; white-space: nowrap; font-variant-numeric: tabular-nums; }
.row-actions { display: flex; flex-wrap: wrap; gap: 8px; margin: 14px 0; }

/* 成績 */
.figures-line { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin: 4px 0 12px; }
.figures-line b { display: block; font-size: 1.45rem; font-weight: 650; letter-spacing: -.01em; line-height: 1.2; font-variant-numeric: tabular-nums; }
.figures-line span { font-size: .72rem; color: var(--text-2); line-height: 1.3; display: block; }
@media (max-width: 480px) { .figures-line { grid-template-columns: repeat(2, 1fr); gap: 12px 8px; } }
.mastery { display: flex; gap: 2px; height: 8px; border-radius: 2px; overflow: hidden; margin: 2px 0 8px; }
.mastery i { display: block; min-width: 2px; }
.mastery .m1, .mastery-legend .m1 { background: var(--primary); }
.mastery .m2, .mastery-legend .m2 { background: color-mix(in srgb, var(--primary) 35%, var(--bg-3)); }
.mastery .m3, .mastery-legend .m3 { background: var(--bg-3); }
.mastery-legend { list-style: none; display: flex; flex-wrap: wrap; gap: 2px 14px; padding: 0; margin: 0 0 4px; font-size: .8rem; color: var(--text-2); }
.mastery-legend i { display: inline-block; width: 9px; height: 9px; border-radius: 2px; margin-right: 5px; }
.mastery-legend b { color: var(--text); font-weight: 600; }
.tide { display: grid; grid-template-columns: repeat(9, 1fr); gap: 4px; align-items: end; height: 96px; }
.tide > div { display: flex; flex-direction: column; justify-content: flex-end; align-items: center; height: 100%; gap: 3px; min-width: 0; }
.tide i { display: block; width: 100%; max-width: 26px; background: var(--primary); border-radius: 2px 2px 0 0; }
.tide i.zero { background: var(--line); height: 1px !important; }
.tide .v { font-size: .72rem; font-variant-numeric: tabular-nums; line-height: 1; }
.tide .d { font-size: .64rem; color: var(--text-2); line-height: 1.1; white-space: nowrap; }
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { border-collapse: collapse; width: 100%; font-variant-numeric: tabular-nums; }
th, td { padding: 6px 8px; text-align: right; border-bottom: 1px solid var(--line); white-space: nowrap; font-size: .86rem; }
thead th { color: var(--text-2); font-weight: 500; font-size: .74rem; }
.matrix { border-spacing: 2px; border-collapse: separate; }
.matrix td { padding: 0; border: 0; text-align: center; min-width: 38px; }
.matrix td:first-child { text-align: left; padding-right: 8px; font-weight: 600; }
.matrix thead th { text-align: center; border: 0; padding: 2px; }
.matrix thead th:first-child { text-align: left; }
.matrix-cell { display: grid; place-items: center; width: 100%; height: 32px; border: 0; border-radius: 3px; background: var(--bg-2); cursor: pointer; font-variant-numeric: tabular-nums; font-size: .76rem; }
.matrix-cell:hover { box-shadow: inset 0 0 0 1px var(--primary); }

/* フォーム */
.field { margin: 0 0 16px; border: 0; padding: 0; }
.field legend, .field > label { font-weight: 600; font-size: .82rem; padding: 0; margin-bottom: 6px; display: block; }
.field legend small { font-weight: 400; margin-left: 6px; font-size: .76rem; }
.field-pair { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.field-pair select { width: 100%; }
.chips { display: flex; flex-wrap: wrap; gap: 4px; }
.chip { position: relative; }
.chip input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; width: 100%; height: 100%; }
.chip span { display: inline-flex; align-items: center; min-height: 36px; padding: 2px 12px; border-radius: 6px; background: var(--bg-2); font-size: .85rem; color: var(--text-2); font-variant-numeric: tabular-nums; }
.chip input:checked + span { background: var(--primary); color: var(--on-primary); font-weight: 600; }
.chip input:focus-visible + span { outline: 2px solid var(--link); outline-offset: 2px; }
select, input, textarea { font-size: 16px; }
select, input[type="search"], input[type="text"], input[type="date"] { font-family: inherit; min-height: 44px; padding: 6px 10px; border: 1px solid var(--line-2); border-radius: var(--r); background: var(--bg); color: var(--text); max-width: 100%; }
input[type="search"] { width: 100%; }
.settings-row { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 6px 16px; min-height: 52px; padding: 7px 0; border-bottom: 1px solid var(--line); }
.settings-row:first-of-type { border-top: 1px solid var(--line); }
.settings-row > label, .settings-row > span:first-child { font-size: .92rem; }
.settings-row small { display: block; font-size: .76rem; }
.switch { position: relative; width: 44px; height: 26px; flex: none; }
.switch input { position: absolute; inset: 0; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; z-index: 1; }
.switch i { position: absolute; inset: 0; border-radius: 13px; background: var(--bg-3); transition: background-color .15s; }
.switch i::after { content: ""; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(0, 0, 0, .25); transition: transform .15s; }
.switch input:checked + i { background: var(--primary); }
.switch input:checked + i::after { transform: translateX(18px); }
:root[data-theme="dark"] .switch input:checked + i::after { background: #111214; }
.switch input:focus-visible + i { outline: 2px solid var(--link); outline-offset: 2px; }
.account { padding: 2px 0; }
.preview-stem { padding: 10px 0; font-family: var(--read); font-size: var(--stem); line-height: 1.8; color: var(--text-2); border-bottom: 1px solid var(--line); }
.more-filter { margin-top: 18px; }
.more-filter > summary { cursor: pointer; font-weight: 600; font-size: .88rem; min-height: 36px; }
.more-filter form { margin-top: 10px; }
.crumb { font-size: .82rem; margin-bottom: 4px; }
.empty-note { font-size: .95rem; color: var(--text-2); margin: 8px 0 18px; }
.empty { padding: 32px 8px; text-align: center; color: var(--text-2); }
.loading { padding: 60px 0; text-align: center; color: var(--text-3); font-size: .86rem; }
.notfound { padding-top: 48px; }

/* 検索 */
.result-list { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--line); }
.result-list li { border-bottom: 1px solid var(--line); }
.result-list a { display: block; padding: 10px 0; color: var(--text); }
.result-list a:hover { text-decoration: none; background: var(--bg-2); }
.result-list b { display: block; font-size: .78rem; font-weight: 600; font-variant-numeric: tabular-nums; }
.result-list span { font-size: .86rem; color: var(--text-2); display: block; line-height: 1.65; }
mark { background: color-mix(in srgb, #f5c400 45%, transparent); color: var(--text); border-radius: 2px; }
.suggest { display: flex; flex-wrap: wrap; gap: 4px 14px; margin-top: 12px; font-size: .86rem; }

/* 静的ページ */
main ul:not([class]) { padding-left: 1.2em; }
.static-options .option { cursor: default; }
.static-options .option:active { opacity: 1; }
.answer { margin: 12px 0; padding: 8px 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.answer summary { cursor: pointer; font-weight: 600; font-size: .88rem; }
.answer p { margin: 6px 0 0; font-weight: 600; }
.tags { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 8px; font-size: .76rem; color: var(--text-2); }
.tag.hissu { color: var(--text); font-weight: 600; }

/* 拡大表示 */
dialog#lightbox { width: 100vw; max-width: 100vw; height: 100dvh; max-height: 100dvh; margin: 0; padding: 52px 8px 12px; border: 0; background: rgba(10, 10, 11, .97); color: #fff; overflow: auto; }
dialog#lightbox::backdrop { background: rgba(10, 10, 11, .97); }
dialog#lightbox img { display: block; margin: 0 auto; max-width: 100%; max-height: calc(100dvh - 110px); height: auto; width: auto; background: #fff; cursor: zoom-in; }
dialog#lightbox img.zoomed { max-width: none; max-height: none; width: 220%; cursor: zoom-out; }
.lightbox-close { position: fixed; top: 8px; right: 8px; width: 44px; height: 44px; border: 0; border-radius: 50%; background: transparent; color: #fff; font-size: 1.4rem; cursor: pointer; }
.lightbox-caption { text-align: center; margin: 8px 0 0; font-size: .8rem; color: #aaa; }
.lightbox-nav { position: fixed; top: 50%; transform: translateY(-50%); width: 44px; height: 72px; border: 0; background: transparent; color: #fff; font-size: 1.8rem; cursor: pointer; z-index: 2; }
.lightbox-nav.prev { left: 0; }
.lightbox-nav.next { right: 0; }
.lightbox-nav[hidden] { display: none; }

/* 下部タブ */
.tabbar { display: none; }
@media (max-width: 640px) {
  .site-header { padding: 10px 16px; padding-top: calc(10px + env(safe-area-inset-top)); }
  .site-header nav { display: none; }
  main { padding: 18px 16px calc(80px + env(safe-area-inset-bottom)); }
  .tabbar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 9; display: grid; grid-template-columns: repeat(5, 1fr); background: var(--bg); border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); }
  .tabbar a { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px; min-height: 50px; color: var(--text-3); font-size: .62rem; }
  .tabbar a:hover { text-decoration: none; }
  .tabbar svg { width: 21px; height: 21px; }
  .tabbar a[aria-current="page"] { color: var(--text); font-weight: 600; }
  .site-footer { padding-bottom: calc(68px + env(safe-area-inset-bottom)); }
  body.in-question .site-header, body.in-question .tabbar { display: none; }
  body.in-question main { padding: 0 16px calc(84px + env(safe-area-inset-bottom)); }
  body.in-question .q-bar { margin-top: 0; padding-top: env(safe-area-inset-top); }
  .q-figs .figures, .figures { margin-left: -16px; margin-right: -16px; }
  .figure, .figure .fig-btn, .figure img { width: 100%; }
  .figure img { max-height: none; border-radius: 0; }
  .figure figcaption { padding: 0 16px; }
  .action-bar { padding-left: 12px; padding-right: 12px; }
}
@media (min-width: 1040px) {
  main:has(.q-body.two) { max-width: 1160px; }
  main:has(.q-body.two) .action-inner { max-width: 1120px; }
  .q-body.two { display: grid; grid-template-columns: minmax(0, 1fr) minmax(320px, 440px); column-gap: 28px; align-items: start; }
  .q-body.two > .sheet, .q-body.two > .q-answer { grid-column: 1; }
  .q-body.two > .q-figs { grid-column: 2; grid-row: 1 / span 2; position: sticky; top: 66px; margin-top: 2px; max-height: calc(100dvh - 140px); overflow: auto; }
  .q-body.two .figures { flex-direction: column; flex-wrap: nowrap; margin: 0; }
  .q-body.two .figure img { max-height: none; width: 100%; }
  .q-body.two .fig-again { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
@media print {
  .site-header, .tabbar, .action-bar, .keys, .q-bar { display: none !important; }
}
