/* 1. 原色（パレット）— 差し替えはここだけ */
:root {
  --bd: #1F3A32;
  --bd-2: #243F37;
  --bd-3: #2A483F;
  --ck: #F4F1E8;
  --ck-2: rgba(244, 241, 232, 0.64);
  --ck-3: rgba(244, 241, 232, 0.62);
  --rule: rgba(244, 241, 232, 0.18);
  --rule-2: rgba(244, 241, 232, 0.08);
  --seal: #D9442B;
  --seal-ink: #9F2E1C;
  --hi: #F2C94C;
  --paper: #F7F3EA;
  --paper-ink: #1C1C1A;
  --paper-ink-2: #4A4A44;
  --paper-rule: rgba(28, 28, 26, 0.14);
  --paper-wash: rgba(28, 28, 26, 0.05);
  --hi-mark: rgba(242, 201, 76, 0.55);

  /* 2. 役割（コンポーネントはこちらだけを参照する） */
  --c-bg: var(--bd);
  --c-surface: var(--bd-2);
  --c-surface-2: var(--bd-3);
  --c-text: var(--ck);
  --c-text-2: var(--ck-2);
  --c-text-3: var(--ck-3);
  --c-rule: var(--rule);
  --c-hi: var(--hi);
  --c-on-hi: var(--bd);
  --c-seal: var(--seal);
  --c-plus: var(--ck);
  --c-minus: var(--ck-2);

  /* 3. 書体と文字サイズ（Web フォントなし） */
  --font: "Hiragino Kaku Gothic ProN", "Yu Gothic UI", "Noto Sans JP", system-ui, sans-serif;
  --mono: ui-monospace, "SF Mono", "Consolas", monospace;
  --fs-note: 0.8125rem;
  --fs-sm: 0.875rem;
  --fs-body: 1.0625rem;
  --fs-lg: 1.1875rem;
  --fs-h2: 1.375rem;
  --fs-h1: clamp(1.6rem, 5vw, 2.4rem);
  --fs-lead: clamp(1.15rem, 4.2vw, 1.6rem);
  --fs-num: clamp(2.6rem, 9vw, 4.4rem);
  --lh-body: 1.8;
  --lh-head: 1.4;

  /* 4. 余白（8pt グリッド）・寸法・角 */
  --s1: 8px;
  --s2: 16px;
  --s3: 24px;
  --s4: 40px;
  --s5: 64px;
  --gutter: 16px;
  --measure: 44rem;
  --r: 12px;
  --r-sm: 8px;
  --r-pill: 999px;
  --tap: 44px;
  --thumb: 28px;
  --graph-h: min(52vw, 320px);
  --eq-h: 132px;
  --chev: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath d='M1 1l5 5 5-5' fill='none' stroke='%23F4F1E8' stroke-width='1.6'/%3E%3C/svg%3E");

  /* 5. 動き */
  --dur: 120ms;
  --dur-2: 180ms;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --ease-press: cubic-bezier(0.2, 0.9, 0.3, 1.2);
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }

html {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  -webkit-text-size-adjust: 100%;
}

body {
  position: relative;
  margin: 0;
  font-family: var(--font);
  font-size: var(--fs-body);
  line-height: var(--lh-body);
  color: var(--c-text);
  background: var(--c-bg);
  min-height: 100vh;
}
/* チョークの粉（ノイズ1枚） */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  opacity: 0.06;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='220' height='220'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 1.4 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

h1, h2, h3 { font-weight: 800; line-height: var(--lh-head); text-wrap: balance; word-break: auto-phrase; margin: 0; letter-spacing: 0.01em; }
p, li { text-wrap: pretty; }
a { color: var(--c-hi); text-underline-offset: 3px; }
a:hover { color: var(--c-text); }
:focus-visible { outline: 2px solid var(--c-hi); outline-offset: 2px; box-shadow: 0 0 0 2px var(--c-bg); border-radius: 4px; }
.num { font-family: var(--mono); font-variant-numeric: tabular-nums; }

.skip { position: absolute; left: -9999px; top: 0; }
.skip:focus { left: var(--s1); top: var(--s1); z-index: 10; background: var(--c-hi); color: var(--c-on-hi); padding: var(--s1) var(--s2); border-radius: var(--r-sm); }

.wrap { width: 100%; max-width: var(--measure); margin: 0 auto; padding: 0 var(--gutter); }

/* ヘッダー */
.top { border-bottom: 1px solid var(--c-rule); }
.top .wrap { display: flex; align-items: center; justify-content: space-between; gap: var(--s2); padding-top: var(--s1); padding-bottom: var(--s1); min-height: 64px; }
.logo { display: inline-flex; flex-direction: column; text-decoration: none; color: var(--c-text); line-height: 1.25; }
.logo-name { font-size: 1.375rem; font-weight: 800; letter-spacing: 0.04em; }
.logo-name b { color: var(--c-hi); font-weight: 800; }
.logo-catch { font-size: var(--fs-note); color: var(--c-text-2); }
.top-nav { display: flex; gap: var(--s1); align-items: center; }
.top-link { font-size: var(--fs-sm); color: var(--c-text-2); white-space: nowrap; min-height: var(--tap); display: inline-flex; align-items: center; padding: 0 4px; }
.top-link.is-make { padding: 0 var(--s2); border: 1px solid var(--c-rule); border-radius: var(--r-pill); color: var(--c-text); text-decoration: none; }
.top-link.is-make:hover { border-color: var(--c-text-2); }

main { display: block; padding: var(--s3) 0 var(--s5); }
.crumb { font-size: var(--fs-note); color: var(--c-text-3); margin: 0 0 var(--s1); }
.crumb a { color: var(--c-text-2); }

/* ファーストビュー（公式ページ） */
.q { font-size: var(--fs-h1); }
/* 称号は直下の結果欄に大きく出るため、見出し内の称号は読み上げと検索用に残して画面からは隠す */
.q-sub { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.fv { margin: var(--s2) 0 0; }
.result { position: relative; padding: var(--s2) 88px var(--s2) 0; border-bottom: 1px solid var(--c-rule); }
.result-title { margin: 0; font-size: var(--fs-body); font-weight: 800; color: var(--c-hi); letter-spacing: 0.02em; line-height: 1.4; }
.kind { margin: 0 0 4px; font-size: var(--fs-note); color: var(--c-text-2); }
.kind b { color: var(--c-text); font-weight: 700; }
.rarity { display: inline-block; margin-left: var(--s1); padding: 0 8px; border: 1px solid var(--c-rule); border-radius: var(--r-pill); font-size: var(--fs-note); line-height: 1.6; color: var(--c-text-2); }
.rarity::before { content: "レア度 "; }
.rarity:empty { display: none; }
.rarity[data-level="2"] { color: var(--c-hi); border-color: var(--c-hi); }
.rarity[data-level="3"], .rarity[data-level="4"] { color: var(--c-on-hi); background: var(--c-hi); border-color: var(--c-hi); font-weight: 700; }
.answer { display: block; font-size: var(--fs-lead); font-weight: 800; line-height: 1.25; min-height: 2.6em; transition: opacity var(--dur) var(--ease); }
.answer .c-num { display: inline-block; margin: 0 0.08em; font-family: var(--mono); font-size: var(--fs-num); font-weight: 800; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; color: var(--c-hi); line-height: 1.05; vertical-align: -0.06em; }
.answer .c-part { white-space: nowrap; }
.answer.swap { opacity: 0.2; }
.answer-delta { display: block; min-height: 1.6em; margin: 4px 0 0; font-size: var(--fs-note); color: var(--c-text-2); font-variant-numeric: tabular-nums; }
.answer-delta b { color: var(--c-text); font-family: var(--mono); }

/* 判子 */
.seal {
  position: absolute;
  right: 0;
  top: var(--s2);
  width: 72px;
  height: 72px;
  display: grid;
  place-content: center;
  justify-items: center;
  border: 3px solid var(--c-seal);
  border-radius: var(--r-pill);
  box-shadow: inset 0 0 0 3px var(--c-bg), inset 0 0 0 5px var(--c-seal);
  color: var(--c-seal);
  font-weight: 800;
  font-size: 0.9375rem;
  line-height: 1.1;
  /* 横書き2段「ほぼ／公式」＝カード・OGP と同じ並び（縦書きは SNS で「公ほ式ぼ」と誤読される） */
  letter-spacing: 0.04em;
  transform: rotate(-8deg);
  opacity: 0.95;
  text-shadow: 0 0 0.5px var(--seal-ink);
  transition: opacity var(--dur-2) var(--ease);
}
.seal.is-pressed { animation: press var(--dur-2) var(--ease-press) both; }
.seal.is-floating { opacity: 0.28; transform: rotate(-8deg) translateY(-3px); }
@keyframes press { from { opacity: 0; transform: rotate(-8deg) scale(1.6); } to { opacity: 0.95; transform: rotate(-8deg) scale(1); } }

.eq { margin: var(--s2) 0 0; height: var(--eq-h); display: flex; justify-content: center; align-items: center; overflow: hidden; }
/* 式は JS が描き替える＝枠の高さを固定して中で縮める（読み込み直後に下が跳ねない＝CLS 0） */
.eq svg { width: 100%; height: 100%; display: block; }
.eq-plain { font-family: var(--mono); font-size: var(--fs-sm); margin: 0; overflow-wrap: anywhere; }
.eq-key { margin: var(--s1) 0 0; font-size: var(--fs-note); color: var(--c-text-3); }

.graph-box { margin: var(--s2) 0 0; }
.graph-head { display: flex; align-items: center; justify-content: space-between; gap: var(--s1); }
.graph-head .eq-key { margin: 0; }
.seg { display: inline-flex; padding: 2px; border: 1px solid var(--c-rule); border-radius: var(--r-pill); flex: none; }
.seg button { appearance: none; min-height: 36px; padding: 0 var(--s2); border: 0; border-radius: var(--r-pill); background: transparent; color: var(--c-text-2); font: inherit; font-size: var(--fs-note); cursor: pointer; white-space: nowrap; transition: background-color var(--dur) var(--ease), color var(--dur) var(--ease); }
.seg button[aria-pressed="true"] { background: var(--c-surface-2); color: var(--c-text); font-weight: 700; }
.graph-box[data-mode="peak"] .l-plus, .graph-box[data-mode="peak"] .l-minus { display: none; }
.graph { width: 100%; height: var(--graph-h); display: block; touch-action: pan-y; }
.legend { display: flex; flex-wrap: wrap; gap: 4px var(--s2); margin: var(--s1) 0 0; padding: 0; list-style: none; font-size: var(--fs-note); color: var(--c-text-2); }
.legend li::before { content: ""; display: inline-block; width: 18px; height: 0; border-top: 2px dashed currentColor; vertical-align: middle; margin-right: 6px; }
.legend .l-plus { color: var(--c-plus); }
.legend .l-minus { color: var(--c-minus); }
.legend .l-minus::before { border-top-style: dotted; border-top-width: 3px; }
.legend .l-total { color: var(--c-text); }
.legend .l-total::before { border-top: 3px solid currentColor; }
.legend .l-best { color: var(--c-hi); }
.legend .l-best::before { width: 8px; height: 8px; border: 0; border-radius: 50%; background: currentColor; }
.legend .l-ghost { color: var(--c-text-3); }
.legend .l-ghost[hidden] { display: none; }

/* スライダー */
.knobs { margin: var(--s3) 0 0; display: grid; gap: var(--s1) var(--s3); grid-template-columns: repeat(auto-fit, minmax(min(100%, 280px), 1fr)); }
.knob { margin: 0; padding: 0; border: 0; min-width: 0; }
.knob legend { padding: 0; font-size: var(--fs-sm); font-weight: 700; color: var(--c-text); }
.knob legend .sg { font-family: var(--mono); margin-right: 4px; color: var(--c-hi); }
.knob.is-minus legend { color: var(--c-text-2); }
.knob-row { position: relative; display: grid; grid-template-columns: 6.5em minmax(0, 1fr); align-items: end; column-gap: var(--s1); padding-top: 22px; font-size: var(--fs-note); }
.knob-name { color: var(--c-text-2); padding-bottom: 12px; line-height: 1.3; }
.knob-track { position: relative; min-width: 0; }
.knob-val {
  position: absolute; top: -22px; left: var(--pos, 50%); transform: translateX(-50%);
  padding: 0 6px; border-radius: var(--r-pill); font-family: var(--mono); font-size: var(--fs-note); font-weight: 700;
  font-variant-numeric: tabular-nums; white-space: nowrap; color: var(--c-text); pointer-events: none;
  transition: color var(--dur) var(--ease), background-color var(--dur) var(--ease);
}
.knob-row.live .knob-val { background: var(--c-hi); color: var(--c-on-hi); }
input[type="range"] {
  -webkit-appearance: none; appearance: none; display: block; width: 100%; height: var(--tap); margin: 0;
  background: transparent; cursor: pointer; touch-action: pan-y;
}
input[type="range"]::-webkit-slider-runnable-track {
  height: 4px; border-radius: var(--r-pill);
  background:
    repeating-linear-gradient(to right, var(--c-text-3) 0 1px, transparent 1px calc(100% / 19)) 0 0 / 100% 100%,
    linear-gradient(to right, var(--c-text) var(--pct, 50%), var(--c-rule) var(--pct, 50%));
}
input[type="range"]::-moz-range-track { height: 4px; border-radius: var(--r-pill); background: var(--c-rule); }
input[type="range"]::-moz-range-progress { height: 4px; border-radius: var(--r-pill); background: var(--c-text); }
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none; width: var(--thumb); height: var(--thumb); margin-top: -12px; border-radius: 50%;
  background: var(--c-text); border: 3px solid var(--c-bg); box-shadow: 0 0 0 2px var(--c-text);
  transition: transform var(--dur) var(--ease);
}
input[type="range"]::-moz-range-thumb { width: 22px; height: 22px; border-radius: 50%; background: var(--c-text); border: 3px solid var(--c-bg); box-shadow: 0 0 0 2px var(--c-text); }
input[type="range"]:active::-webkit-slider-thumb { transform: scale(1.12); }
input[type="range"]:focus-visible { outline: 2px solid var(--c-hi); outline-offset: 2px; }
.knob-foot { display: flex; justify-content: flex-end; margin: var(--s1) 0 0; }
.btn {
  appearance: none; min-height: var(--tap); padding: 0 var(--s2); border: 1px solid var(--c-rule); border-radius: var(--r-pill);
  background: transparent; color: var(--c-text-2); font: inherit; font-size: var(--fs-sm); cursor: pointer;
  transition: transform var(--dur) var(--ease), color var(--dur) var(--ease), border-color var(--dur) var(--ease);
}
.btn:hover { color: var(--c-text); border-color: var(--c-text-2); }
.btn:active { transform: scale(0.97); }

/* 結果の次の一手（3ボタン） */
.next { margin: var(--s3) 0 0; display: grid; gap: var(--s1); grid-template-columns: repeat(3, minmax(0, 1fr)); padding: 0; list-style: none; }
.next a, .next button {
  display: flex; align-items: center; justify-content: center; gap: 6px; width: 100%; min-height: 52px; padding: 6px var(--s1);
  border-radius: var(--r); border: 1px solid var(--c-rule); background: var(--c-surface); color: var(--c-text);
  font: inherit; font-size: var(--fs-sm); font-weight: 700; text-align: center; text-decoration: none; line-height: 1.3; cursor: pointer;
  transition: transform var(--dur) var(--ease), border-color var(--dur) var(--ease), background-color var(--dur) var(--ease);
}
.next a:hover, .next button:hover { border-color: var(--c-text-2); color: var(--c-text); }
.next a:active, .next button:active { transform: scale(0.97); }
.next .is-primary { background: var(--seal-ink); border-color: var(--c-seal); color: var(--ck); }
.next .is-primary:hover { border-color: var(--ck); color: var(--ck); }
.next-msg { min-height: 1.5em; margin: 6px 0 0; font-size: var(--fs-note); color: var(--c-text-2); text-align: center; }
.next-box { margin: var(--s2) 0 0; }
.next-box .next { margin: 0; }
.today-line { margin: 0; font-size: var(--fs-sm); text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.today-line a { display: inline-block; min-height: 32px; line-height: 32px; }

/* 共有パネル（Web Share が使えない端末で開く） */
.share-panel { margin: var(--s2) 0 0; padding: var(--s2); border: 1px solid var(--c-rule); border-radius: var(--r); background: var(--c-surface); display: grid; gap: var(--s2); justify-items: center; }
.share-panel[hidden], .share-panel [hidden] { display: none; }
.share-panel img { width: min(100%, 300px); height: auto; aspect-ratio: 4 / 5; border-radius: var(--r-sm); border: 1px solid var(--c-rule); background: var(--c-bg); }
.share-acts { display: flex; flex-wrap: wrap; gap: var(--s1); justify-content: center; }
.share-acts .btn { display: inline-flex; align-items: center; text-decoration: none; color: var(--c-text); }
.share-acts a:not([href]) { opacity: 0.5; pointer-events: none; }
.share-msg { margin: 0; min-height: 1.5em; font-size: var(--fs-note); color: var(--c-text-2); text-align: center; }

/* 粉受けのつまみ（いちばん効く係数1本・画面の下に貼りつく） */
.tray { position: sticky; bottom: 0; z-index: 3; margin: var(--s2) calc(var(--gutter) * -1) 0; padding: 0 var(--gutter) calc(4px + env(safe-area-inset-bottom)); background: var(--c-surface); border-top: 1px solid var(--c-rule); transition: opacity var(--dur-2) var(--ease), transform var(--dur-2) var(--ease); }
.tray.is-away { opacity: 0; transform: translateY(12px); pointer-events: none; }
.tray .knob-row { padding-top: 20px; }
.slot[hidden] { display: none; }

/* 紙面（やさしい解説・法務） */
.paper { margin: var(--s4) calc(var(--gutter) * -1) 0; padding: var(--s3) var(--gutter) var(--s4); background: var(--paper); color: var(--paper-ink); border-radius: var(--r); }
.paper a { color: var(--paper-ink); }
.paper h2 { font-size: var(--fs-h2); margin: var(--s4) 0 var(--s1); padding-bottom: 6px; border-bottom: 1px solid var(--paper-rule); }
.paper h2:first-child { margin-top: var(--s1); }
.paper h2 .no { font-family: var(--mono); color: var(--paper-ink-2); margin-right: var(--s1); }
.paper p { margin: 0 0 var(--s2); }
.paper strong { background: linear-gradient(transparent 62%, var(--hi-mark) 62%); }
.readings { list-style: none; padding: 0; margin: var(--s1) 0 var(--s2); display: grid; gap: var(--s1); }
.readings li { padding: 10px var(--s2); border-left: 3px solid var(--paper-ink); background: var(--paper-wash); border-radius: 0 var(--r-sm) var(--r-sm) 0; }
.readings li.is-minus { border-left-style: dotted; }
.readings li { transition: opacity var(--dur-2) var(--ease), transform var(--dur-2) var(--ease); }
.readings li.pending { opacity: 0; transform: translateY(8px); }
.sens { width: 100%; border-collapse: collapse; font-size: var(--fs-sm); margin: var(--s1) 0 var(--s2); }
.sens th, .sens td { text-align: left; padding: var(--s1) 6px; border-bottom: 1px solid var(--paper-rule); vertical-align: top; }
.sens th { color: var(--paper-ink-2); font-weight: 400; }
.sens td:not(:first-child) { font-family: var(--mono); font-variant-numeric: tabular-nums; }

.note { margin: var(--s3) 0 0; padding: var(--s2); border-left: 3px solid var(--c-hi); background: var(--c-surface); border-radius: 0 var(--r-sm) var(--r-sm) 0; font-size: var(--fs-note); color: var(--c-text-2); }
.paper .note { background: var(--paper-wash); color: var(--paper-ink-2); border-left-color: var(--paper-ink); }

/* 一覧カード */
.sec-h { font-size: var(--fs-h2); margin: var(--s4) 0 0; }
.cards { list-style: none; padding: 0; margin: var(--s2) 0 0; display: grid; gap: var(--s2); grid-template-columns: repeat(auto-fill, minmax(min(100%, 200px), 1fr)); }
.card { min-width: 0; }
.card a {
  display: flex; flex-direction: column; height: 100%; padding: var(--s2); border-radius: var(--r);
  border: 1px solid var(--c-rule); background: var(--c-surface); color: var(--c-text); text-decoration: none;
  transition: transform var(--dur) var(--ease), border-color var(--dur) var(--ease);
}
.card a:hover { border-color: var(--c-text-2); color: var(--c-text); transform: translateY(-2px); }
.card a:active { transform: scale(0.985); }
.card-cat { font-size: var(--fs-note); color: var(--c-text-3); letter-spacing: 0.08em; }
.card-q { font-size: var(--fs-body); margin: 2px 0 4px; }
.card-a { font-family: var(--mono); font-size: 1.75rem; color: var(--c-hi); font-weight: 800; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; line-height: 1.2; }
.card-name { font-size: var(--fs-note); color: var(--c-text-2); margin-top: auto; padding-top: 6px; }
.spark { width: 100%; height: 48px; display: block; margin: 6px 0 2px; overflow: visible; }
.s-total { stroke: var(--c-text); }
.s-plus { stroke: var(--c-plus); }
.s-minus { stroke: var(--c-minus); }
.s-best { fill: var(--c-hi); }

/* トップ */
.hero { padding: 0 0 var(--s1); }
.hero-sub { color: var(--c-hi); font-size: var(--fs-sm); font-weight: 700; letter-spacing: 0.24em; margin: 0 0 var(--s1); }
.hero h1 { font-size: var(--fs-h1); }
.hero h1 .dash { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
.hero h1 .h1-sub { display: block; margin-top: 4px; font-size: var(--fs-h2); color: var(--c-text-2); }
.hero-lead { color: var(--c-text-2); margin: var(--s2) 0 0; max-width: 36em; }
.hero-art { position: relative; margin: var(--s3) 0 0; padding: var(--s2); border-radius: var(--r); border: 1px solid var(--c-rule); background: var(--c-surface); }
.hero-art svg { width: 100%; height: auto; display: block; overflow: visible; }
.hero-art .chalk-line { stroke-dasharray: 1400; stroke-dashoffset: 1400; animation: draw 1.2s var(--ease) 150ms forwards; }
.hero-art .s-best { animation: pop var(--dur-2) var(--ease-press) 1.25s both; transform-box: fill-box; transform-origin: center; }
.hero-art .seal { top: var(--s2); right: var(--s2); left: auto; animation: press var(--dur-2) var(--ease-press) 1.4s both; }
@keyframes draw { to { stroke-dashoffset: 0; } }
@keyframes pop { from { opacity: 0; transform: scale(0.2); } to { opacity: 1; transform: scale(1); } }
.hero-cap { font-size: var(--fs-note); color: var(--c-text-3); margin: var(--s1) 0 0; }

.steps { list-style: none; counter-reset: s; padding: 0; margin: var(--s1) 0 0; display: grid; gap: var(--s1); }
.steps li { counter-increment: s; position: relative; padding: 10px var(--s2) 10px 52px; border-radius: var(--r-sm); background: var(--paper-wash); }
.steps li::before { content: counter(s); position: absolute; left: var(--s2); top: 10px; width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; font-family: var(--mono); color: var(--paper); background: var(--paper-ink); font-weight: 700; }
.shapes { list-style: none; padding: 0; margin: var(--s1) 0 0; display: grid; gap: var(--s1); grid-template-columns: repeat(auto-fill, minmax(min(100%, 190px), 1fr)); }
.shapes li { padding: 10px var(--s2); border-radius: var(--r-sm); background: var(--paper-wash); min-width: 0; }
.shapes .tex { font-family: var(--mono); color: var(--paper-ink-2); margin-left: 6px; }
.paper .spark { height: 40px; }
.paper .s-total { stroke: var(--paper-ink); }

.reveal { animation: rise-in var(--dur-2) var(--ease) both; animation-delay: calc(var(--i, 0) * 40ms); }
@keyframes rise-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* 今日の定理（トップ最上部） */
.today { position: relative; margin: 0 0 var(--s3); padding: var(--s2); border: 1px dashed var(--c-text-3); border-radius: var(--r); background: var(--c-surface); }
.today-head { display: flex; align-items: baseline; gap: var(--s1); }
.today-tag { font-size: var(--fs-sm); color: var(--c-hi); letter-spacing: 0.12em; }
.today-n { font-size: var(--fs-sm); font-weight: 700; }
.today-date { margin-left: auto; font-size: var(--fs-note); color: var(--c-text-3); }
.today-q { margin: 4px 0 0; font-size: var(--fs-lg); font-weight: 800; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.today-a { margin: 2px 0 0; }
.today-name { display: block; font-size: var(--fs-sm); color: var(--c-text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.today-ans { display: block; font-size: var(--fs-sm); white-space: nowrap; }
.today-ans b { font-size: 2rem; color: var(--c-hi); letter-spacing: -0.02em; vertical-align: -0.1em; margin: 0 4px; }
.today-emoji { font-size: var(--fs-lg); }
.today-acts { display: flex; flex-wrap: wrap; gap: var(--s1); margin: var(--s1) 0 0; }
.today-go { display: inline-flex; align-items: center; min-height: var(--tap); padding: 0 var(--s3); border-radius: var(--r-pill); background: var(--seal-ink); border: 1px solid var(--c-seal); color: var(--ck); font-weight: 700; text-decoration: none; }
.today-go:hover { color: var(--ck); border-color: var(--ck); }
.today .share-msg { text-align: left; margin-top: 6px; }

/* 操作できるヒーロー */
.hero-ans { margin: 0 88px 0 0; font-size: var(--fs-lg); font-weight: 800; line-height: 1.3; min-height: 2.6em; }
.hero-ans .c-num { font-family: var(--mono); font-size: 2.6rem; color: var(--c-hi); letter-spacing: -0.02em; margin: 0 4px; font-variant-numeric: tabular-nums; }
.hero-plot { position: relative; aspect-ratio: 720 / 300; margin: var(--s1) 0 0; }
.hero-plot svg, .hero-plot canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
.hero-cv { pointer-events: none; }
.hero-art.is-live .hero-svg { visibility: hidden; }
.hero-knob { margin: 4px 0 0; }

/* ビルダー（/make/） */
.wrap.is-wide { max-width: 72rem; }
.make-grid { display: grid; gap: var(--s3); grid-template-columns: minmax(0, 1fr); }
.status { margin: 0 0 4px; font-size: var(--fs-note); color: var(--c-text-3); line-height: 1.6; height: 1.6em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.warn { margin: var(--s1) 0 0; min-height: 1.6em; font-size: var(--fs-note); color: var(--c-hi); }
.ctrl { min-width: 0; }
/* 部品は JS が組み立てる＝組み上がるまで見せない（伸び縮みを見せない・CLS 0） */
.ctrl:not(.is-ready) > :not(.ctrl-h) { visibility: hidden; }
.ctrl-h { font-size: var(--fs-h2); margin: 0 0 var(--s1); }
.mini { position: sticky; top: 0; z-index: 3; display: grid; grid-template-columns: minmax(0, 1fr) auto 96px; align-items: center; gap: var(--s1); margin: 0 calc(var(--gutter) * -1) var(--s2); padding: 6px var(--gutter); background: var(--c-surface); border-bottom: 1px solid var(--c-rule); font-size: var(--fs-note); }
.mini-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--c-text-2); }
.mini-ans { font-size: var(--fs-lg); color: var(--c-hi); white-space: nowrap; }
.mini-cv { width: 96px; height: 36px; display: block; }
.field { margin: 0 0 var(--s3); padding: 0; border: 0; min-width: 0; }
.field-l { display: block; padding: 0; margin: 0 0 6px; font-size: var(--fs-sm); font-weight: 800; color: var(--c-text); }
.field select, .term select { appearance: none; width: 100%; min-height: var(--tap); padding: 0 40px 0 var(--s2); border: 1px solid var(--c-rule); border-radius: var(--r-sm); background: var(--c-surface) var(--chev) no-repeat right 14px center; color: var(--c-text); font: inherit; font-size: var(--fs-body); cursor: pointer; }
.field-note { margin: 4px 0 0; font-size: var(--fs-note); color: var(--c-text-3); }
.pills { display: flex; flex-wrap: wrap; gap: var(--s1); min-height: var(--tap); }
.pill { position: relative; display: inline-flex; }
.pill input, .sp input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.pill span { display: inline-flex; align-items: center; min-height: var(--tap); padding: 0 var(--s2); border: 1px solid var(--c-rule); border-radius: var(--r-pill); font-size: var(--fs-sm); color: var(--c-text-2); cursor: pointer; white-space: nowrap; }
.pill input:checked + span { border-color: var(--c-text); color: var(--c-text); background: var(--c-surface-2); font-weight: 700; }
.pill input:focus-visible + span, .sp:has(input:focus-visible) { outline: 2px solid var(--c-hi); outline-offset: 2px; }
.terms-col { margin: 0 0 var(--s3); }
.terms { display: grid; gap: var(--s2); min-height: 280px; }
.term { margin: 0; padding: var(--s2); border: 1px solid var(--c-rule); border-radius: var(--r); background: var(--c-surface); min-width: 0; }
.term.is-minus { border-style: dashed; }
.term legend { padding: 0 6px; font-size: var(--fs-sm); font-weight: 700; }
.term legend .sg { font-family: var(--mono); color: var(--c-hi); margin-right: 4px; }
.term-head { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: var(--s1); align-items: end; }
.term-label span { display: block; font-size: var(--fs-note); color: var(--c-text-2); margin-bottom: 2px; }
.btn-x { font-size: var(--fs-note); }
.shape-pick { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 4px; margin: var(--s2) 0 0; }
.sp { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; min-height: 56px; padding: 4px 2px; border: 1px solid var(--c-rule); border-radius: var(--r-sm); color: var(--c-text-2); font-size: 0.75rem; cursor: pointer; text-align: center; line-height: 1.2; }
.sp:has(input:checked) { border-color: var(--c-text); color: var(--c-text); background: var(--c-surface-2); font-weight: 700; }
.sp.is-off { opacity: 0.55; }
.term-say { margin: var(--s1) 0 0; font-size: var(--fs-sm); color: var(--c-text-2); }
.term-warn { margin: 2px 0 0; font-size: var(--fs-note); color: var(--c-hi); }
.add { margin: var(--s1) 0 0; display: flex; align-items: center; gap: var(--s1); }
.btn-add { color: var(--c-text); border-style: dashed; }
.btn-add.is-off { opacity: 0.5; cursor: not-allowed; }
.add-note { font-size: var(--fs-note); color: var(--c-text-3); }
.copy-row { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s1); margin: 0 0 var(--s3); }
.copy-row .share-msg { text-align: left; }
.starts ul { list-style: none; padding: 0; margin: 0; display: grid; gap: var(--s1); grid-template-columns: repeat(auto-fill, minmax(min(100%, 200px), 1fr)); }
.start { appearance: none; width: 100%; min-height: var(--tap); display: flex; justify-content: space-between; align-items: center; gap: var(--s1); padding: 6px var(--s2); border: 1px solid var(--c-rule); border-radius: var(--r-sm); background: transparent; color: var(--c-text); font: inherit; font-size: var(--fs-note); text-align: left; cursor: pointer; }
.start:hover { border-color: var(--c-text-2); }
.start-a { color: var(--c-hi); font-weight: 700; white-space: nowrap; }
.more { margin: var(--s2) 0 0; }
@media (min-width: 960px) {
  .make-grid { grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); align-items: start; gap: var(--s4); }
  .pv { position: sticky; top: var(--s2); }
  .mini { display: none; }
  .terms { min-height: 0; }
}

/* フッター */
.foot { margin-top: var(--s4); border-top: 1px solid var(--c-rule); padding: var(--s3) 0 var(--s4); font-size: var(--fs-sm); color: var(--c-text-3); }
.foot ul { list-style: none; padding: 0; margin: 0 0 var(--s1); display: flex; flex-wrap: wrap; gap: 0 var(--s2); }
.foot a { color: var(--c-text-2); display: inline-flex; min-height: 32px; align-items: center; }
.foot-motto { letter-spacing: 0.24em; color: var(--c-hi); font-weight: 700; margin: var(--s2) 0 2px; }
.foot-copy { margin: 0; font-size: var(--fs-note); }

/* 法務・説明ページ（紙面） */
.doc { margin-top: 0; }
.doc h1 { font-size: var(--fs-h1); margin-bottom: var(--s2); }
.doc .types { list-style: none; padding: 0; display: grid; gap: var(--s1); }
.doc .types b { font-family: var(--mono); margin-right: var(--s1); }

/* PC・タブレット：結論は1行に収まる＝空けておく高さを1行分にし、式を詰めて山の全体をファーストビューへ */
@media (min-width: 561px) {
  :root { --graph-h: min(44vw, 300px); }
  .answer { min-height: 1.3em; }
  .next-box { margin-top: var(--s1); }
}

@media (max-width: 560px) {
  :root { --graph-h: 46vw; }
  main { padding-top: var(--s2); }
  .q { font-size: 1.375rem; }
  .fv { margin-top: var(--s1); }
  .result { padding: var(--s1) 72px var(--s1) 0; }
  .seal { width: 60px; height: 60px; font-size: 0.8125rem; top: var(--s1); }
  .answer { min-height: 0; }
  .next { gap: 6px; }
  .next a, .next button { min-height: 48px; white-space: nowrap; padding: 4px; }
  .sp-hide { display: none; }
  :root { --eq-h: 104px; }
  .eq { margin-top: var(--s1); }
  .graph-box { margin-top: var(--s1); }
  .legend { margin-top: 4px; }
  .top-link:not(.is-make) { display: none; }
  .hero-ans { margin-right: 72px; }
  .today-q { font-size: var(--fs-body); }
  .shape-pick { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; scroll-behavior: auto !important; }
  .hero-art .chalk-line { stroke-dashoffset: 0; }
  .readings li.pending { opacity: 1; transform: none; }
}
