/* Chapter 05 — 고장과 수리 (page-specific) */
:root {
  --heat-1: #f3d36b; --heat-2: #f6ad3b; --heat-3: #ff7f2a; --heat-4: #f0492b; --heat-5: #c8102e;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) { --heat-1: #e6c75a; --heat-2: #f5a742; --heat-3: #ff8a3d; --heat-4: #ff5a3c; --heat-5: #ff3b55; }
}
:root[data-theme="dark"] { --heat-1: #e6c75a; --heat-2: #f5a742; --heat-3: #ff8a3d; --heat-4: #ff5a3c; --heat-5: #ff3b55; }

/* ---------- SVG primitives ---------- */
.sv-line { fill: none; stroke: var(--ink); stroke-width: 4; stroke-linecap: round; stroke-linejoin: round; }
.sv-thin { fill: none; stroke: var(--ink-2); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.sv-frame { fill: none; stroke: var(--ink); stroke-width: 9; stroke-linecap: round; stroke-linejoin: round; }
.sv-tire { fill: none; stroke: var(--ink); stroke-width: 12; stroke-linecap: round; }
.sv-spoke { fill: none; stroke: var(--line-2); stroke-width: 1.5; }
.sv-chain { fill: none; stroke: var(--muted); stroke-width: 4; stroke-dasharray: 5 3; stroke-linecap: round; stroke-linejoin: round; }
.sv-dash { fill: none; stroke: var(--muted); stroke-width: 2; stroke-dasharray: 6 5; }
.sv-acc { fill: none; stroke: var(--accent); stroke-width: 4; stroke-linecap: round; }
.sv-acc-thick { fill: none; stroke: var(--accent); stroke-width: 7; stroke-linecap: round; }
.sv-arrow { fill: none; stroke: var(--accent); stroke-width: 3; stroke-linecap: round; marker-end: none; }
.sv-hose { fill: none; stroke: var(--ink-2); stroke-width: 7; stroke-linecap: round; }
.sv-sealant { fill: var(--teal); stroke: var(--teal); stroke-width: 3; fill-opacity: .35; }
.sv-bubble { fill: var(--surface); stroke: var(--blue); stroke-width: 2; }
.sv-fill-ink { fill: var(--ink); }
.sv-fill-acc { fill: var(--accent); }
.sv-fill-red { fill: var(--red); }
.sv-fill-soft { fill: var(--surface-2); }
.sv-txt { fill: var(--ink-2); font-family: var(--font); font-size: 15px; font-weight: 600; }
.sv-thin.sv-fill-soft { fill: var(--surface-2); }

/* ---------- Guide blocks ---------- */
.guide-meta { display: flex; flex-wrap: wrap; gap: 8px 22px; padding: 14px 18px; margin: 1.4em 0; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface-2); font-size: .9rem; color: var(--ink-2); }
.guide-meta > div { display: flex; gap: 8px; align-items: baseline; }
.gm-k { font-family: var(--mono); font-size: .72rem; letter-spacing: .08em; text-transform: uppercase; color: var(--accent-ink); font-weight: 600; white-space: nowrap; }
.stars { color: var(--gold); letter-spacing: 1px; white-space: nowrap; }
.stars .off { color: var(--line-2); }
.fig { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; }
.fig svg { width: 100%; height: auto; }
.prose ol.steps { list-style: none; counter-reset: step; padding-left: 0; }
.prose ol.steps > li { counter-increment: step; position: relative; padding-left: 48px; margin-bottom: 1em; }
.prose ol.steps > li::before { content: counter(step); position: absolute; left: 0; top: 2px; width: 32px; height: 32px; border-radius: 50%; background: var(--ink); color: var(--bg); display: grid; place-items: center; font-family: var(--mono); font-weight: 600; font-size: .85rem; }
.toolkit-grid { margin: 1.6em 0 2.4em; }
.toolkit-grid .card h3 { margin-top: 14px; }

/* ---------- Heatmap ---------- */
.hm-grid { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr); gap: 24px; align-items: start; }
@media (max-width: 860px) { .hm-grid { grid-template-columns: 1fr; } }
.hm-bike { width: 100%; height: auto; overflow: visible; }
.hs { cursor: pointer; outline: none; }
.hs .glow { transform-box: fill-box; transform-origin: center; animation: hmPulse 2.6s ease-in-out infinite; }
.hs .core { stroke: var(--surface); stroke-width: 3; transition: r .2s; }
.hs:hover .core, .hs:focus-visible .core, .hs.active .core { stroke: var(--ink); stroke-width: 4; }
.hs:focus-visible .ring, .hs.active .ring { opacity: 1; }
.hs .ring { fill: none; stroke: var(--ink); stroke-width: 2; stroke-dasharray: 4 4; opacity: 0; }
@keyframes hmPulse { 0%, 100% { transform: scale(.85); opacity: .75; } 50% { transform: scale(1.1); opacity: 1; } }
.hm-legend { display: flex; align-items: center; gap: 10px; font-size: .8rem; color: var(--muted); margin: 8px 0 14px; }
.hm-scale { flex: 1; height: 10px; border-radius: 999px; background: linear-gradient(90deg, var(--heat-1), var(--heat-2), var(--heat-3), var(--heat-4), var(--heat-5)); }
.hm-list .chip { font-size: .82rem; padding: 6px 12px; }
.hm-list .dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.hm-panel { background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px; min-height: 260px; }
.hm-panel h4 { font-size: 1.25rem; margin: 6px 0 10px; }
.hm-panel dl { margin: 0; display: grid; gap: 10px; font-size: .92rem; }
.hm-panel dt { font-family: var(--mono); font-size: .72rem; letter-spacing: .08em; color: var(--muted); text-transform: uppercase; }
.hm-panel dd { margin: 2px 0 0; color: var(--ink-2); line-height: 1.6; }
.heat-meter { display: flex; gap: 4px; align-items: center; }
.heat-meter i { width: 22px; height: 8px; border-radius: 4px; background: var(--line); }
.heat-meter span { margin-left: 8px; font-size: .85rem; font-weight: 700; }
.hm-panel .btn { margin-top: 16px; }
.hm-note { font-size: .8rem; margin: 16px 0 0; }

/* ---------- ABC ---------- */
.abc-progress { font-family: var(--mono); font-size: .9rem; padding: 6px 14px; border-radius: 999px; background: var(--bg-2); }
.abc-grid { gap: 16px; }
.abc-card { background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; position: relative; overflow: hidden; }
.abc-letter { position: absolute; right: 12px; top: -8px; font-family: var(--serif); font-size: 4.6rem; font-weight: 800; color: var(--accent); opacity: .18; line-height: 1; }
.abc-ico { width: 48px; height: 48px; margin-bottom: 10px; }
.abc-ico .sv-line, .abc-ico .sv-acc { stroke-width: 3; }
.abc-card h4 { margin-bottom: 10px; }
.abc-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; font-size: .88rem; line-height: 1.45; color: var(--ink-2); }
.abc-list label { display: flex; gap: 8px; align-items: flex-start; cursor: pointer; }
.abc-list input { accent-color: var(--accent); width: 18px; height: 18px; margin-top: 1px; flex: none; }
.abc-list input:checked + * , .abc-list label:has(input:checked) { color: var(--muted); text-decoration: line-through; }
.abc-done { margin-top: 18px; padding: 14px 18px; border-radius: var(--radius-sm); background: var(--green-soft); color: var(--green); font-weight: 700; text-align: center; }

/* ---------- Diagnoser ---------- */
.dx-step-label { font-family: var(--mono); font-size: .8rem; color: var(--muted); margin-bottom: 10px; }
.dx-crumbs { list-style: none; padding: 0; margin: 18px 0 0; display: flex; flex-wrap: wrap; gap: 6px; font-size: .8rem; }
.dx-crumbs:empty { display: none; }
.dx-crumbs li { padding: 4px 10px; border-radius: 6px; background: var(--bg-2); color: var(--ink-2); }
.dx-crumbs li b { color: var(--accent-ink); }
.dx-q { margin-top: 18px; padding: 22px; border-radius: var(--radius); border: 1px dashed var(--line-2); background: var(--surface-2); }
.dx-q p { font-size: 1.1rem; font-weight: 700; margin-bottom: 16px; }
.dx-q .flex .btn { min-width: 96px; justify-content: center; }
.dx-result { margin-top: 18px; padding: 24px; border-radius: var(--radius); border: 1px solid var(--line); background: var(--surface-2); border-left: 6px solid var(--green); }
.dx-result.shop { border-left-color: var(--red); }
.dx-result h4 { font-size: 1.2rem; margin-bottom: 8px; }
.dx-result p { color: var(--ink-2); margin-bottom: .8em; }
.dx-badge { display: inline-flex; align-items: center; gap: 6px; padding: 5px 12px; border-radius: 999px; font-size: .8rem; font-weight: 800; background: var(--red-soft); color: var(--red); margin-bottom: 10px; }
.dx-badge.ok { background: var(--green-soft); color: var(--green); }

/* ---------- Flat game ---------- */
.pf-grid { display: grid; grid-template-columns: minmax(0, 320px) minmax(0, 1fr); gap: 28px; align-items: center; }
@media (max-width: 700px) { .pf-grid { grid-template-columns: 1fr; } .pf-svg { max-width: 300px; margin: 0 auto; } }
.pf-svg { width: 100%; height: auto; }
.pf-water { fill: var(--blue-soft); }
.pf-seg { fill: var(--ink-2); stroke: var(--surface); stroke-width: 2; cursor: pointer; transition: fill .2s; outline: none; }
.pf-seg:hover, .pf-seg:focus-visible { fill: var(--accent); }
.pf-seg.dunked { fill: var(--muted); }
.pf-seg.found { fill: var(--red); }
.pf-center { font-size: 14px; }
.pf-score { font-family: var(--mono); font-size: .9rem; padding: 6px 14px; border-radius: 999px; background: var(--bg-2); }
.pf-msg { font-size: 1rem; color: var(--ink-2); min-height: 4.5em; }
.pf-bub { fill: var(--surface); stroke: var(--blue); stroke-width: 2; animation: bubUp 1.4s ease-out infinite; }
@keyframes bubUp { 0% { transform: translateY(0); opacity: 1; } 100% { transform: translateY(-34px); opacity: 0; } }

/* ---------- Chain checker ---------- */
.cc-svg { width: 100%; height: auto; margin: 6px 0 10px; }
.cc-zone0 { fill: var(--green-soft); }
.cc-zone1 { fill: var(--gold); opacity: .55; }
.cc-zone2 { fill: var(--accent); opacity: .6; }
.cc-zone3 { fill: var(--red); opacity: .65; }
.cc-link { fill: var(--surface-2); stroke: var(--ink-2); stroke-width: 2; }
.cc-pin { fill: var(--ink); }
.cc-tick { fill: var(--muted); font-family: var(--mono); font-size: 16px; }
.cc-out { display: grid; grid-template-columns: auto 1fr; gap: 6px 18px; align-items: start; }
.cc-status { padding: 8px 16px; border-radius: 999px; font-weight: 800; font-size: .95rem; white-space: nowrap; background: var(--green-soft); color: var(--green); }
.cc-status[data-state="soon"] { background: var(--gold-soft); color: var(--gold); }
.cc-status[data-state="now"] { background: var(--accent-soft); color: var(--accent-ink); }
.cc-status[data-state="late"] { background: var(--red-soft); color: var(--red); }
.cc-text { margin: 0; color: var(--ink-2); }
.cc-len { grid-column: 2; margin: 0; font-size: .82rem; }
@media (max-width: 560px) { .cc-out { grid-template-columns: 1fr; } .cc-len { grid-column: 1; } .cc-status { justify-self: start; } }
.cc-costs { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)) minmax(0, 1.2fr); gap: 10px; margin-top: 18px; }
@media (max-width: 640px) { .cc-costs { grid-template-columns: 1fr 1fr; } }
.cc-cost, .cc-total { padding: 14px; border-radius: var(--radius-sm); border: 1px solid var(--line); background: var(--surface-2); display: grid; gap: 4px; font-size: .85rem; color: var(--muted); transition: all .25s; }
.cc-cost strong { color: var(--muted); font-size: .95rem; }
.cc-cost.on { border-color: var(--accent); background: var(--accent-soft); color: var(--accent-ink); }
.cc-cost.on strong { color: var(--ink); }
.cc-total { background: var(--ink); color: color-mix(in srgb, var(--bg) 70%, transparent); border-color: var(--ink); }
.cc-total strong { color: var(--bg); font-family: var(--serif); font-size: 1.4rem; }
.cc-note { font-size: .8rem; margin: 12px 0 0; }

/* ---------- Derailleur sim ---------- */
.rd-intro { font-size: .92rem; }
.rd-svg { width: 100%; height: auto; max-height: 320px; }
.rd-cog { fill: var(--ink-2); }
.rd-cog.sel { fill: var(--accent); }
#rd-cage, #rd-target { transition: transform .35s cubic-bezier(.2,.8,.2,1); }
#rd-barrel { transition: transform .35s ease; }
.rd-status { padding: 8px 16px; border-radius: 999px; font-weight: 800; background: var(--green-soft); color: var(--green); }
.rd-status[data-state="noise"] { background: var(--gold-soft); color: var(--gold); }
.rd-status[data-state="noisy"] { background: var(--accent-soft); color: var(--accent-ink); }
.rd-status[data-state="bad"] { background: var(--red-soft); color: var(--red); }
.rd-controls { display: flex; flex-wrap: wrap; gap: 14px 28px; margin-top: 12px; }
.rd-group { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.rd-label { font-size: .82rem; font-weight: 700; color: var(--muted); width: 100%; }
.rd-msg { margin: 16px 0 4px; color: var(--ink-2); min-height: 3.4em; }
.rd-turns { font-size: .8rem; margin: 0; }

/* ---------- Lifespan chart ---------- */
.ls-stats { margin-bottom: 24px; }
.ls-stats .stat { padding: 16px 0; }
.ls-stats .stat-value { font-size: clamp(2rem, 4vw, 2.8rem); }
.ls-chart { display: grid; gap: 12px; }
.ls-row { display: grid; grid-template-columns: 130px minmax(0, 1fr); gap: 14px; align-items: center; font-size: .9rem; }
.ls-name { font-weight: 700; color: var(--ink-2); line-height: 1.3; }
.ls-track { position: relative; height: 26px; background: var(--bg-2); border-radius: 6px; }
.ls-fill { position: absolute; top: 0; bottom: 0; border-radius: 6px; transform: scaleX(0); transform-origin: left; transition: transform 1.1s cubic-bezier(.2,.8,.2,1); display: flex; align-items: center; justify-content: center; }
.ls-chart.in .ls-fill { transform: scaleX(1); }
.ls-fill span { font-family: var(--mono); font-size: .72rem; color: #fff; white-space: nowrap; font-weight: 600; padding: 0 6px; }
.ls-fill.tight span { position: absolute; left: 100%; color: var(--ink-2); }
.ls-axis { display: grid; grid-template-columns: 130px minmax(0, 1fr); gap: 14px; font-family: var(--mono); font-size: .72rem; color: var(--muted); }
.ls-axis-t { position: relative; height: 16px; }
.ls-axis-t span { position: absolute; transform: translateX(-50%); white-space: nowrap; }
.ls-axis-t span:first-child { transform: none; }
.ls-axis-t span:last-child { transform: translateX(-100%); }
.ls-note { font-size: .8rem; margin: 16px 0 0; }
@media (max-width: 640px) { .ls-row, .ls-axis { grid-template-columns: 84px minmax(0, 1fr); gap: 8px; font-size: .8rem; } .ls-fill span { font-size: .64rem; } }

/* ---------- Planner ---------- */
.pl-inputs { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.2fr); gap: 20px 32px; }
@media (max-width: 760px) { .pl-inputs { grid-template-columns: 1fr; } }
.pl-env { border: 0; padding: 0; margin: 0 0 16px; }
.pl-env legend { font-size: .86rem; font-weight: 700; color: var(--ink-2); margin-bottom: 8px; padding: 0; }
.pl-env .chip { cursor: pointer; }
.pl-env .chip:has(input:checked) { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.pl-env .chip:has(input:focus-visible) { outline: 3px solid var(--accent); outline-offset: 2px; }
.pl-summary { gap: 12px; margin: 8px 0 4px; }
.pl-card { padding: 16px; border-radius: var(--radius-sm); background: var(--surface-2); border: 1px solid var(--line); }
.pl-card .v { font-family: var(--serif); font-size: 1.8rem; font-weight: 800; line-height: 1.1; }
.pl-card .v small { font-family: var(--font); font-size: .8rem; color: var(--muted); margin-left: 4px; }
.pl-card .l { font-size: .82rem; color: var(--muted); margin-top: 4px; }
#pl-tbody td:first-child { font-weight: 700; }
#pl-tbody td.num { white-space: nowrap; }
.pl-note-m { display: none; font-weight: 400; color: var(--muted); font-size: .78rem; line-height: 1.4; margin-top: 4px; }
@media (max-width: 560px) {
  #pl-widget th:nth-child(4), #pl-widget td.pl-note-c { display: none; }
  .pl-note-m { display: block; }
  #pl-widget th, #pl-widget td { padding: 10px 10px; font-size: .82rem; }
}
#pl-tbody .sw { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 8px; vertical-align: middle; }
.pl-tl-title { margin: 8px 0 12px; }
.pl-timeline { display: grid; gap: 8px; }
.pl-tl-row { display: grid; grid-template-columns: 120px minmax(0, 1fr); gap: 12px; align-items: center; font-size: .82rem; }
.pl-tl-row > span { color: var(--ink-2); font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pl-tl-track { position: relative; height: 18px; background: var(--bg-2); border-radius: 4px; }
.pl-tl-track i { position: absolute; top: 3px; width: 12px; height: 12px; margin-left: -6px; border-radius: 50%; border: 2px solid var(--surface); }
.pl-tl-track i.dense { width: auto; height: 6px; top: 6px; margin-left: 0; border-radius: 3px; border: 0; opacity: .75; }
.pl-tl-axis { display: grid; grid-template-columns: 120px minmax(0, 1fr); gap: 12px; font-family: var(--mono); font-size: .7rem; color: var(--muted); }
.pl-tl-axis div { display: flex; justify-content: space-between; }
@media (max-width: 560px) { .pl-tl-row, .pl-tl-axis { grid-template-columns: 82px minmax(0, 1fr); gap: 8px; font-size: .74rem; } }
.pl-note { font-size: .8rem; margin: 14px 0 0; }

/* ---------- Cost table ---------- */
.cost-table td:first-child a { font-weight: 700; text-decoration: none; }
.cost-table td:first-child a:hover { text-decoration: underline; }
.cost-table td { white-space: nowrap; }
.cost-table td:nth-child(2), .cost-table td:nth-child(3) { white-space: normal; min-width: 140px; }

.accordion.prose { max-width: var(--prose); }
