:root { color-scheme: light dark; font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Yu Gothic", sans-serif; color: #172033; background: #f7f9fd; font-synthesis: none; }
* { box-sizing: border-box; }
body { margin: 0; min-width: 320px; }
button, input, select { font: inherit; }
.lab { max-width: 1120px; margin: 0 auto; padding: 20px; }
header { margin-bottom: 14px; }
.eyebrow { margin: 0 0 5px; color: #3157b7; font-size: 12px; font-weight: 750; letter-spacing: .12em; }
h1 { margin: 0; font-size: clamp(25px, 5vw, 38px); }
h2 { margin: 4px 0 0; font-size: clamp(21px, 4vw, 29px); }
header > p:last-child, .context, .rule { margin: 7px 0 0; color: #56627a; line-height: 1.6; }
.filters { display: grid; grid-template-columns: minmax(200px, 1.5fr) repeat(2, minmax(140px, .8fr)) auto; gap: 9px; align-items: end; margin-bottom: 14px; }
.filters label { display: grid; gap: 4px; color: #56627a; font-size: 12px; font-weight: 700; }
.filters input, .filters select { min-height: 44px; padding: 8px 10px; border: 1px solid #abb6c9; border-radius: 9px; color: inherit; background: #fff; }
#reaction-count { align-self: center; color: #3157b7; font-weight: 750; }
.layout { display: grid; grid-template-columns: minmax(230px, .7fr) minmax(0, 2fr); gap: 15px; }
.reaction-list { display: flex; max-height: 690px; flex-direction: column; gap: 7px; overflow: auto; padding-right: 4px; }
button { min-height: 44px; padding: 8px 12px; border: 1px solid #abb6c9; border-radius: 9px; color: inherit; background: #fff; cursor: pointer; }
button.primary, button.active { border-color: #3157b7; color: #fff; background: #3157b7; }
.reaction-card { display: grid; flex: 0 0 auto; min-height: 72px; gap: 4px; align-content: center; text-align: left; }
.reaction-card span { color: #3157b7; font-size: 10px; font-weight: 750; }
.reaction-card.active span { color: #e6edff; }
.reaction-card b, .reaction-card small { display: block; overflow-wrap: anywhere; }
.reaction-card b { line-height: 1.35; }
.reaction-card small { line-height: 1.45; }
.stage { min-height: 690px; padding: 18px; border: 1px solid #d3dbe7; border-radius: 14px; background: #fff; }
.stage-heading { display: flex; align-items: start; justify-content: space-between; gap: 12px; }
.badge { display: inline-block; padding: 4px 8px; border-radius: 999px; color: #3157b7; background: #eaf0ff; font-size: 11px; font-weight: 750; }
.equation-builder { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 11px; margin: 25px 0 18px; }
.equation-side { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 9px; }
.compound { display: grid; width: 135px; gap: 8px; text-align: center; }
.compound span { min-height: 42px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 27px; font-weight: 800; }
.compound output { color: #3157b7; }
.compound input { width: 100%; min-height: 28px; accent-color: #3157b7; }
sub { font-size: .58em; }
.operator, .arrow { font-size: 26px; font-weight: 800; }
.stage-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin-bottom: 14px; }
.result { padding: 13px; border-left: 5px solid #c64141; border-radius: 8px; background: #fff0f0; }
.result.correct { border-color: #138a62; background: #e6f7ef; }
.result.almost { border-color: #ce8918; background: #fff7df; }
table { width: 100%; margin-top: 14px; border-collapse: collapse; text-align: center; }
th, td { padding: 8px; border-bottom: 1px solid #d3dbe7; }
tr.match { color: #087052; }
tr.mismatch { color: #b12d2d; background: #fff5f5; }
.empty { color: #56627a; text-align: center; }
/* 粒子モデル：係数を動かすと粒の数が変わり、左右の過不足が目で分かる */
.particle-wrap { margin: 4px 0 14px; }
.particle-model { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 10px; padding: 14px 10px; border: 1px solid #d3dbe7; border-radius: 12px; background: #fbfcfe; }
.particle-side { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 10px; }
.particle-group { display: grid; justify-items: center; gap: 5px; flex: 0 1 auto; min-width: 74px; max-width: 200px; }
.particle-box { display: grid; place-items: center; width: 100%; min-height: 58px; padding: 7px 9px; border-radius: 10px; background: #fff; border: 1px solid #e0e6ef; }
.particle-formula { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 15px; }
.particle-formula output { color: #3157b7; font-weight: 800; }
.particle-group input[type="range"] { width: 100%; max-width: 132px; min-height: 26px; accent-color: #3157b7; touch-action: manipulation; }

.particle-operator, .particle-arrow { font-size: 20px; font-weight: 800; color: #56627a; }
.particle-svg { display: block; width: 100%; height: auto; max-width: 100%; }
/* 分子は実線の枠で「1個の粒」を、イオン結晶は破線の枠で「この比で並ぶ」ことを示す。
   同じ見た目にすると NaCl が分子だという誤解につながるため、必ず描き分ける。 */
.unit-frame { fill: none; }
.unit-frame--molecule { stroke: #3157b7; stroke-width: 1.2; opacity: 0.5; }
.unit-frame--ionic { stroke: #8a6d3b; stroke-width: 1.2; stroke-dasharray: 4 3; opacity: 0.75; }
.kind-note { display: block; max-width: 148px; color: #6b7a92; font-size: 9.5px; line-height: 1.35; text-align: center; }
.particle-legend { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px 14px; margin-top: 8px; color: #56627a; font-size: 10.5px; }
.particle-legend span { display: inline-flex; align-items: center; gap: 5px; }
.swatch { display: inline-block; width: 15px; height: 13px; border-radius: 5px; }
.swatch--molecule { border: 1.2px solid #3157b7; opacity: .75; }
.swatch--ionic { border: 1.2px dashed #8a6d3b; border-radius: 3px; }
.swatch--atomic { border: 1.2px solid transparent; background: radial-gradient(circle at 50% 50%, #8fbf5f 42%, transparent 44%); }
@media (max-width: 760px) {
  .particle-model { gap: 7px; padding: 10px 6px; }
  .particle-group { min-width: 62px; max-width: 148px; }
  .particle-formula { font-size: 13px; }
  .particle-operator, .particle-arrow { font-size: 16px; }
}
.model-link { margin-top: 10px; padding: 9px 11px; border-radius: 9px; background: #eef3ff; font-size: 12px; }
.model-link a { color: #3157b7; font-weight: 750; }

@media (max-width: 760px) { .lab { padding: 15px 11px; } .filters { grid-template-columns: 1fr 1fr; } .filters label:first-child { grid-column: 1 / -1; } .layout { grid-template-columns: 1fr; } .stage { order: 1; min-height: 0; } .reaction-list { order: 2; max-height: 360px; } .equation-builder { align-items: flex-start; gap: 7px; margin: 14px 0 12px; } .equation-side { width: auto; gap: 7px; } .arrow { width: auto; text-align: center; align-self: center; } .operator, .arrow { font-size: 19px; } .compound { width: min(96px, 26vw); gap: 5px; } .compound span { min-height: 30px; font-size: 19px; } .compound input { min-height: 24px; } }
@media (prefers-color-scheme: dark) { :root { color: #edf2ff; background: #101522; } header > p:last-child, .context, .rule, .filters label, .empty { color: #b4bfd4; } button, .filters input, .filters select, .stage { color: #edf2ff; background: #1a2232; border-color: #46536b; } .badge { background: #172d55; } th, td { border-color: #46536b; } .result { background: #431f25; } .result.correct { background: #12392f; } .result.almost { background: #493817; } tr.mismatch { background: #351b21; } }

/* スライダーは指で操作するため、つまみを大きくして掴みやすくする。
   input の高さを44pxにすると余白が目立つので、つまみ側で当たり判定を確保する。 */
input[type="range"] { min-height: 44px; background: transparent; -webkit-appearance: none; appearance: none; }
input[type="range"]::-webkit-slider-runnable-track { height: 6px; border-radius: 99px; background: #dbe5f2; }
input[type="range"]::-moz-range-track { height: 6px; border-radius: 99px; background: #dbe5f2; }
input[type="range"]::-webkit-slider-thumb { -webkit-appearance: none; appearance: none; width: 28px; height: 28px; margin-top: -11px; border: 3px solid #fff; border-radius: 50%; background: #3157b7; box-shadow: 0 1px 4px #17384b55; cursor: pointer; }
input[type="range"]::-moz-range-thumb { width: 22px; height: 22px; border: 3px solid #fff; border-radius: 50%; background: #3157b7; box-shadow: 0 1px 4px #17384b55; cursor: pointer; }
