/* Chapter 07 — tools page (calculators). Uses tokens from style.css only. */

.tools-main { min-width: 0; }

/* Tool switcher */
.tool-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 12px; margin: 28px 0 8px; }
.tool-card { padding: 16px 18px; display: flex !important; flex-direction: column; gap: 2px; }
.tool-card strong { font-size: 1rem; line-height: 1.35; }
.tool-card small { color: var(--muted); font-size: .8rem; line-height: 1.4; }
.tool-card .card-num { color: var(--accent); font-weight: 600; }
@media (max-width: 420px) { .tool-grid { grid-template-columns: 1fr 1fr; } .tool-card { padding: 14px; } }

/* Calculator layout */
.calc-grid { display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); gap: 24px; align-items: start; }
@media (max-width: 760px) { .calc-grid { grid-template-columns: 1fr; } }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 400px) { .field-row { grid-template-columns: 1fr; } }
.field output { font-family: var(--mono); color: var(--accent-ink); }
.mini-chips { gap: 6px; margin-top: 4px; }
.mini-chips .chip { padding: 4px 10px; font-size: .78rem; }
.field[hidden] { display: none; }
.hint { font-size: .78rem; color: var(--muted); line-height: 1.5; }
p.hint { margin: -6px 0 14px; }

/* Segmented radio chips */
fieldset.seg { border: 0; padding: 0; margin: 0 0 16px; min-width: 0; }
fieldset.seg legend { font-size: .86rem; font-weight: 700; color: var(--ink-2); margin-bottom: 8px; padding: 0; }
.seg label.chip { cursor: pointer; position: relative; user-select: none; }
.seg label.chip input { position: absolute; opacity: 0; width: 1px; height: 1px; pointer-events: none; }
.seg label.chip:hover { border-color: var(--ink); }
.seg label.chip:has(input:focus-visible) { outline: 3px solid var(--accent); outline-offset: 2px; }

.switch { display: inline-flex; align-items: center; gap: 10px; font-size: .9rem; font-weight: 600; color: var(--ink-2); cursor: pointer; }
.switch input { width: 18px; height: 18px; accent-color: var(--accent); }

/* Result box internals */
.result-box { min-width: 0; }
.result-box .small-cap { font-size: .78rem; font-family: var(--mono); letter-spacing: .06em; text-transform: uppercase; }
.result-box .big .u { font-family: var(--font); font-size: .4em; font-weight: 700; opacity: .7; }
.result-box .big.sm { font-size: clamp(1.6rem, 3vw, 2.2rem); }
.rb-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 16px; margin-top: 18px; padding-top: 16px; border-top: 1px solid color-mix(in srgb, var(--bg) 18%, transparent); }
.rb-grid small { display: block; font-size: .74rem; color: color-mix(in srgb, var(--bg) 65%, transparent); line-height: 1.35; margin-bottom: 2px; }
.rb-grid b { font-family: var(--mono); font-size: .98rem; font-weight: 600; }
.rb-note { font-size: .84rem; line-height: 1.6; margin: 14px 0 0; color: color-mix(in srgb, var(--bg) 82%, transparent); }
.rb-note:empty { display: none; }
.rb-note strong { color: var(--bg); }
.rb-sep { height: 1px; background: color-mix(in srgb, var(--bg) 18%, transparent); margin: 16px 0; }
.result-box .warn { color: var(--gold); font-weight: 700; }

/* Formula line */
.prose .formula { font-family: var(--mono); font-size: .92rem; background: var(--surface); border: 1px solid var(--line); border-left: 4px solid var(--accent); border-radius: var(--radius-sm); padding: 14px 16px; color: var(--ink); overflow-x: auto; white-space: nowrap; }

/* Charts */
.chart-wrap { margin-top: 22px; background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 6px 0; overflow: hidden; }
.chart-wrap svg, .gauge-wrap svg { width: 100%; height: auto; }
.chart-wrap svg text, .gauge-wrap svg text { font-family: var(--mono); font-size: 11px; fill: var(--muted); }
.chart-cap { font-size: .84rem; color: var(--muted); margin: 10px 0 0; line-height: 1.6; }
.legend-cross { color: var(--red); font-weight: 700; }
.ch-grid { stroke: var(--line); stroke-width: 1; }
.ch-axis { stroke: var(--line-2); stroke-width: 1; }
.ch-title { font-weight: 600; }
svg text.ch-ring { fill: var(--ink); font-weight: 600; font-size: 12px; }
.g-line { stroke-width: 3; stroke-linecap: round; opacity: .35; fill: none; }
.r0 { --rc: var(--accent); } .r1 { --rc: var(--teal); } .r2 { --rc: var(--blue); } .r3 { --rc: var(--violet); }
.g-line { stroke: var(--rc); }
.g-dot { fill: var(--rc); stroke: var(--surface-2); stroke-width: 2; }
.g-dot.cross { fill: var(--surface-2); stroke: var(--red); stroke-width: 2; stroke-dasharray: 2.5 2; }
svg text.g-lbl { font-size: 10px; fill: var(--ink-2); }
svg text.g-lbl.cross { fill: var(--red); }

/* Gear table */
.table-scroll { max-height: 420px; overflow: auto; }
.table-scroll thead th { position: sticky; top: 0; z-index: 1; }
#g-table td, #g-table th { padding: 8px 12px; }
#g-table tr.ring-start td { border-top: 2px solid var(--line-2); }
#g-table tr.cross td { color: var(--muted); background: color-mix(in srgb, var(--red-soft) 45%, transparent); }
#g-table .ring-sw { display: inline-block; width: 10px; height: 10px; border-radius: 50%; background: var(--rc); margin-right: 6px; vertical-align: middle; }
#g-table .tag { margin-left: 6px; }

/* Pressure */
.pr-pair { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 6px; vertical-align: middle; }
.dot-front { background: var(--teal); }
.dot-rear { background: var(--accent); }
.gauge-wrap { max-width: 460px; margin: 22px auto 0; }
.gauge-track { stroke: var(--line); fill: none; }
.gauge-tick { stroke: var(--line-2); }
.gauge-band-f { stroke: var(--teal); opacity: .35; fill: none; }
.gauge-band-r { stroke: var(--accent); opacity: .35; fill: none; }
.needle-f { stroke: var(--teal); stroke-width: 4; stroke-linecap: round; }
.needle-r { stroke: var(--accent); stroke-width: 5; stroke-linecap: round; }
.gauge-hub { fill: var(--ink); }
svg text.gauge-unit { font-size: 12px; fill: var(--ink-2); font-weight: 600; }
.gauge-max-zone { stroke: var(--red); opacity: .5; fill: none; }

/* Calorie / food */
.food-title { margin: 26px 0 8px; }
.food-list { display: grid; gap: 0; }
.food-row { display: grid; grid-template-columns: 130px minmax(0, 1fr) 72px; gap: 12px; align-items: center; padding: 10px 0; border-bottom: 1px dashed var(--line); }
.food-row:last-child { border-bottom: 0; }
.food-name { font-size: .9rem; font-weight: 700; line-height: 1.35; }
.food-name small { display: block; font-weight: 400; color: var(--muted); font-size: .76rem; }
.food-icons { display: flex; flex-wrap: wrap; gap: 3px; align-items: center; min-width: 0; }
.food-icons svg { width: 24px; height: 24px; flex: none; }
.food-icons .part { opacity: .3; }
.food-icons .more { font-family: var(--mono); font-size: .8rem; color: var(--muted); margin-left: 4px; }
.food-count { font-family: var(--mono); font-weight: 600; text-align: right; }
.f-rice { color: var(--ink-2); } .f-banana { color: var(--gold); } .f-kimbap { color: var(--green); }
.f-gel { color: var(--accent); } .f-ramen { color: var(--red); } .f-pie { color: var(--violet); }
@media (max-width: 520px) { .food-row { grid-template-columns: 1fr 64px; } .food-icons { grid-column: 1 / -1; order: 3; } .food-icons svg { width: 20px; height: 20px; } }

/* Power */
.pw-block { margin-top: 24px; }
.pw-title { font-weight: 700; font-size: .92rem; margin: 22px 0 10px; color: var(--ink-2); }
.pw-block .pw-title { margin-top: 0; }
.pw-stack { display: flex; height: 24px; border-radius: 999px; overflow: hidden; background: var(--bg-2); }
.pw-stack span { height: 100%; width: 0; transition: width .35s ease; }
.pw-roll { background: var(--gold); } .pw-grav { background: var(--violet); } .pw-aero { background: var(--blue); } .pw-loss { background: var(--muted); }
.pw-legend { list-style: none; padding: 0; margin: 10px 0 0; display: flex; flex-wrap: wrap; gap: 6px 18px; font-size: .85rem; color: var(--ink-2); }
.pw-legend b { font-family: var(--mono); font-weight: 600; }
.sw { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: middle; }
.pos-bars .bar-fill { transition: width .35s ease; background: var(--line-2); }
.pos-bars .bar-row.on .bar-fill { background: var(--accent); }
.pos-bars .bar-row.on { font-weight: 700; }
.p-line { fill: none; stroke: var(--line-2); stroke-width: 1.5; stroke-dasharray: 4 3; }
.p-line.on { stroke: var(--accent); stroke-width: 3; stroke-dasharray: none; }
svg text.p-lbl { font-size: 10px; fill: var(--muted); }
svg text.p-lbl.on { fill: var(--accent-ink); font-weight: 600; }
.p-guide { stroke: var(--accent); stroke-dasharray: 3 3; opacity: .6; }
.p-mark { fill: var(--accent); stroke: var(--surface-2); stroke-width: 3; }

/* Chain wear */
.wear-track { position: relative; height: 14px; border-radius: 999px; margin-top: 12px; background: var(--green); }
.wear-mark { position: absolute; top: -5px; width: 6px; height: 24px; margin-left: -3px; border-radius: 3px; background: var(--bg); box-shadow: 0 0 0 2px var(--ink); transition: left .3s ease; left: 0; }
.wear-scale { display: flex; justify-content: space-between; font-family: var(--mono); font-size: .72rem; margin-top: 6px; color: color-mix(in srgb, var(--bg) 65%, transparent); }
hr.divider.slim { margin: 8px 0 20px; }

/* Quiz */
.quiz-q { padding: 16px 0 4px; border-top: 1px solid var(--line) !important; }
.quiz-q:first-child { border-top: 0 !important; padding-top: 0; }
.quiz-q legend { font-size: 1rem !important; color: var(--ink) !important; float: left; width: 100%; margin-bottom: 10px; }
.quiz-q legend + .chip-row { clear: both; }
.q-num { font-family: var(--mono); color: var(--accent); margin-right: 8px; }
.quiz-result { margin-top: 20px; border: 1px dashed var(--line-2); border-radius: var(--radius); padding: 20px; background: var(--surface-2); }
.quiz-result p:last-child { margin-bottom: 0; }
.quiz-result.done { border-style: solid; border-color: var(--accent); }
.qr-head { display: flex; gap: 16px; align-items: center; flex-wrap: wrap; margin-bottom: 10px; }
.qr-icon { width: 64px; height: 64px; border-radius: 16px; background: var(--accent-soft); color: var(--accent-ink); display: grid; place-items: center; flex: none; }
.qr-icon svg { width: 44px; height: 44px; }
.qr-name { font-size: 1.5rem; font-weight: 800; letter-spacing: -0.03em; line-height: 1.2; }
.quiz-result .small { font-size: .82rem; }
.qr-tag { color: var(--muted); font-size: .9rem; }
.quiz-result .bars { margin: 16px 0; }
.quiz-result .bar-fill { transition: width .5s ease; }

/* Converter */
.conv-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 14px; }
.conv-pair { display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); gap: 8px; align-items: end; background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 12px; }
.conv-pair label { display: grid; gap: 4px; font-size: .78rem; font-weight: 700; color: var(--muted); font-family: var(--mono); text-transform: uppercase; letter-spacing: .06em; min-width: 0; }
.conv-pair .input { padding: 9px 10px; min-width: 0; }
.conv-arrow { padding-bottom: 10px; color: var(--accent); font-weight: 700; }

/* FAQ */
.faq { max-width: var(--prose); }
