/* ── Nuclear Reactor Simulator ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:        #0d1117;
  --surface:   #161b27;
  --surface2:  #1f2535;
  --border:    #2a3050;
  /* Accent — Cherenkov blue */
  --accent:    #4aa8ff;
  --accent-lo: rgba(74,168,255,.22);
  --green:     #3ddc84;
  --red:       #ff5555;
  --gold:      #f5c842;
  --text:      #dde3f0;
  --text-dim:  #6b7a99;
  --font:      'Segoe UI', system-ui, sans-serif;
  --mono:      'Courier New', monospace;
  --radius:    12px;
}

body { background: var(--bg); color: var(--text); font-family: var(--font); min-height: 100vh; padding: 0 16px; }
#app { max-width: 1180px; margin: 0 auto; display: flex; flex-direction: column; gap: 14px; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

header { text-align: center; padding: 4px 0; }
header h1 {
  font-size: 1.8rem; font-weight: 700;
  background: linear-gradient(120deg, #9fe3ff 0%, #4aa8ff 50%, #3b5bdb 100%);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text;
}
.subtitle { color: var(--text-dim); font-size: 0.85rem; margin-top: 3px; }

.controls-bar {
  display: flex; flex-wrap: wrap; align-items: center; gap: 14px; padding: 12px 16px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
}
.ctrl-group { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.ctrl-label { font-size: 0.72rem; text-transform: uppercase; letter-spacing: .06em; color: var(--text-dim); white-space: nowrap; }

.pill-tabs { display: flex; background: var(--bg); border-radius: 8px; padding: 3px; gap: 2px; flex-wrap: wrap; }
.pill { padding: 5px 13px; min-height: 30px; border: none; background: transparent; color: var(--text-dim); border-radius: 6px; cursor: pointer; font-size: 0.81rem; font-family: var(--font); transition: background .18s, color .18s, box-shadow .18s; }
.pill.active { background: var(--accent); color: #fff; box-shadow: 0 0 12px var(--accent-lo); }
.pill:hover:not(.active) { background: var(--surface2); color: var(--text); }
.pill:focus-visible, .btn:focus-visible, .rx-btn:focus-visible, .pl-btn:focus-visible, .cb-btn:focus-visible, .vt-pill:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }

.btn { padding: 8px 18px; min-height: 36px; border: none; border-radius: 8px; cursor: pointer; font-size: 0.84rem; font-weight: 600; font-family: var(--font); transition: filter .18s, box-shadow .18s, opacity .18s; }
.btn:disabled { opacity: 0.38; cursor: not-allowed; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:not(:disabled):hover { filter: brightness(1.12); box-shadow: 0 0 12px var(--accent-lo); }
.btn-ghost { background: var(--surface2); color: var(--text); border: 1px solid var(--border); }
.btn-ghost:hover { background: var(--border); }
.btn-warn { background: var(--gold); color: #1a1a2e; }
.btn-danger { background: rgba(255,85,85,.15); color: #ffb3b3; border: 1px solid rgba(255,85,85,.55); }
.btn-danger:not(:disabled):hover { background: rgba(255,85,85,.28); }
.btn-tour { background: linear-gradient(120deg, #f5c842, #f2a33c); color: #1a1a2e; font-weight: 700; }
.btn-tour.active { box-shadow: 0 0 0 2px #fff3c4 inset, 0 0 14px rgba(245,200,66,.5); }

/* ── Canvas card ── */
.canvas-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 10px; overflow-x: clip; }
.view-strip { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 8px; flex-wrap: wrap; }
.vt-tabs { display: flex; gap: 2px; padding: 3px; background: var(--bg); border-radius: 8px; }
.vt-pill { display: inline-flex; align-items: center; gap: 6px; padding: 6px 14px; min-height: 32px; border: none; border-radius: 6px; background: transparent; color: var(--text-dim); font-family: var(--font); font-size: .8rem; font-weight: 700; cursor: pointer; }
.vt-pill.active { background: var(--accent); color: #fff; box-shadow: 0 0 10px var(--accent-lo); }
.vt-pill:hover:not(.active) { background: var(--surface2); color: var(--text); }
.vt-pill:disabled { opacity: .4; cursor: not-allowed; }
.stage-wrap { position: relative; }
.stage-wrap canvas { display: block; width: 100%; border-radius: 8px; touch-action: pan-y; }
.b3d-stage { position: relative; width: 100%; border-radius: 8px; overflow: hidden; background: #10141a; }
.b3d-stage canvas { display: block; width: 100%; height: 100%; touch-action: none; }
.b3d-msg { position: absolute; inset: 0; display: grid; place-items: center; color: var(--text-dim); font-size: .9rem; text-align: center; padding: 20px; }
.b3d-note { position: absolute; left: 50%; top: 12px; transform: translateX(-50%); z-index: 6; background: rgba(13,17,23,.92); border: 1px solid var(--gold); color: var(--gold); padding: 6px 10px; border-radius: 8px; font-size: .78rem; display: flex; gap: 8px; align-items: center; }
.b3d-note button { background: none; border: none; color: var(--text); cursor: pointer; font-size: .9rem; }

.b3d-bar { position: absolute; right: 10px; bottom: 10px; z-index: 5; display: flex; gap: 4px; padding: 3px; background: rgba(13,17,23,.85); border: 1px solid var(--border); border-radius: 9px; }
.b3d-btn { padding: 6px 11px; min-height: 30px; border: none; border-radius: 6px; background: transparent; color: var(--text-dim); font-family: var(--font); font-size: .76rem; font-weight: 700; cursor: pointer; }
.b3d-btn.active { background: var(--accent); color: #fff; }
.b3d-btn:hover:not(.active) { background: var(--surface2); color: var(--text); }
.tour-card ~ .b3d-stage .b3d-bar { bottom: auto; top: 10px; }

/* Display Controls — collapsible overlay pinned to the canvas */
.canvas-toggles {
  position: absolute; top: 8px; left: 8px; z-index: 5;
  background: rgba(13,17,23,0.88); -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px);
  border: 1px solid var(--border); border-radius: 9px; box-shadow: 0 4px 14px rgba(0,0,0,0.35); max-width: calc(100% - 16px);
}
.canvas-toggles > summary {
  list-style: none; cursor: pointer; user-select: none; display: flex; align-items: center; justify-content: center;
  width: 34px; height: 34px; font-size: 0.66rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em;
  color: var(--text); border-radius: 9px; transition: background .12s, color .12s;
}
.canvas-toggles > summary .cvt-title, .canvas-toggles > summary .cvt-caret { display: none; }
.canvas-toggles[open] > summary { width: auto; height: auto; min-height: 30px; padding: 6px 10px; gap: 7px; justify-content: flex-start; border-bottom: 1px solid var(--border); border-radius: 9px 9px 0 0; }
.canvas-toggles[open] > summary .cvt-title, .canvas-toggles[open] > summary .cvt-caret { display: inline; }
.canvas-toggles > summary::-webkit-details-marker { display: none; }
.canvas-toggles > summary::marker { content: ''; }
.canvas-toggles > summary:hover { background: var(--accent-lo); color: var(--accent); }
.canvas-toggles > summary:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
.canvas-toggles .cvt-ico { flex-shrink: 0; color: var(--accent); width: 17px; height: 17px; }
.canvas-toggles .cvt-caret { margin-left: auto; padding-left: 4px; color: var(--text-dim); font-size: 0.7rem; }
.canvas-toggles .cvt-body { display: flex; flex-direction: column; gap: 5px; padding: 8px 11px 10px; max-height: 60vh; overflow-y: auto; }
.canvas-toggles .cvt-group { font-size: 0.58rem; font-weight: 800; letter-spacing: .09em; text-transform: uppercase; color: var(--accent); margin-top: 4px; padding-bottom: 2px; border-bottom: 1px solid var(--border); }
.canvas-toggles .cvt-group:first-child { margin-top: 0; }
.canvas-toggles .cvt-item { display: flex; align-items: center; gap: 6px; font-size: 0.72rem; color: var(--text-dim); cursor: pointer; white-space: nowrap; }
.canvas-toggles .cvt-item:hover { color: var(--text); }
.canvas-toggles .cvt-item input[type="checkbox"] { accent-color: var(--accent); width: 14px; height: 14px; cursor: pointer; }
.canvas-toggles .cvt-reset { margin-top: 7px; padding: 5px 9px; min-height: 28px; background: var(--surface2); border: 1px solid var(--border); border-radius: 6px; color: var(--text-dim); font-size: 0.66rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; cursor: pointer; }
.canvas-toggles .cvt-reset:hover { border-color: var(--accent); color: var(--accent); }

/* Guided tour card — sits on the bottom of the drawing */
.tour-card {
  position: absolute; left: 50%; bottom: 10px; transform: translateX(-50%); z-index: 6;
  width: min(640px, calc(100% - 20px)); padding: 10px 14px 12px;
  background: rgba(14,18,26,.94); border: 1px solid rgba(245,200,66,.55); border-radius: 12px;
  box-shadow: 0 10px 30px rgba(0,0,0,.45); -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px);
}
.tour-head { display: flex; align-items: center; gap: 6px; }
.tour-step { font-family: var(--mono); font-size: .78rem; color: var(--gold); font-weight: 700; min-width: 44px; }
.tour-dots { display: flex; gap: 4px; flex: 1; }
.tour-dots span { width: 8px; height: 8px; border-radius: 50%; background: var(--border); }
.tour-dots span.done { background: rgba(245,200,66,.5); }
.tour-dots span.cur { background: var(--gold); box-shadow: 0 0 6px var(--gold); }
.tour-btn { width: 32px; height: 32px; border-radius: 8px; border: 1px solid var(--border); background: var(--surface2); color: var(--text); cursor: pointer; font-size: .85rem; }
.tour-btn:hover:not(:disabled) { border-color: var(--gold); color: var(--gold); }
.tour-btn:disabled { opacity: .35; cursor: default; }
.tour-prog { height: 3px; border-radius: 2px; background: var(--border); margin: 8px 0 6px; overflow: hidden; }
.tour-prog span { display: block; height: 100%; width: 0; background: var(--gold); }
.tour-title { font-size: 1rem; color: #fff3c4; margin-bottom: 4px; }
.tour-text { font-size: .86rem; line-height: 1.5; color: var(--text); }

/* Part info card */
.info-card {
  position: absolute; right: 10px; top: 10px; z-index: 6; width: min(320px, calc(100% - 20px));
  padding: 12px 14px; background: rgba(14,18,26,.95); border: 1px solid var(--accent); border-radius: 12px; box-shadow: 0 10px 30px rgba(0,0,0,.45);
}
.info-card h3 { font-size: 1rem; color: #fff; margin: 2px 0 6px; padding-right: 22px; }
.info-card p { font-size: .84rem; line-height: 1.5; color: var(--text); }
.info-cls { font-size: .66rem; text-transform: uppercase; letter-spacing: .08em; color: var(--accent); font-weight: 800; }
.info-x { position: absolute; right: 8px; top: 8px; width: 26px; height: 26px; border-radius: 6px; border: 1px solid var(--border); background: var(--surface2); color: var(--text); cursor: pointer; }

.ctx-menu { position: absolute; z-index: 20; min-width: 170px; background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 4px 0; box-shadow: 0 8px 24px rgba(0,0,0,.4); }
.ctx-item { display: block; width: 100%; padding: 8px 16px; border: none; background: transparent; color: var(--text); font-size: 0.82rem; text-align: left; cursor: pointer; font-family: var(--font); }
.ctx-item:hover { background: var(--accent-lo); color: var(--accent); }

select { padding: 6px 10px; min-height: 32px; border-radius: 8px; border: 1px solid var(--border); background: var(--surface2); color: var(--text); font-family: var(--font); font-size: .82rem; }
.scen-desc { font-size: .82rem; color: var(--text-dim); margin-top: -6px; padding: 0 4px; }


/* ── Reactor choice ── */
.rx-strip { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.rx-btn { display: flex; flex-direction: column; gap: 3px; text-align: left; padding: 10px 14px; min-height: 56px; cursor: pointer; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); color: var(--text); font-family: var(--font); transition: border-color .18s, background .18s, box-shadow .18s; }
.rx-btn:hover { border-color: var(--accent); }
.rx-btn.active { border-color: var(--accent); background: linear-gradient(135deg, rgba(74,168,255,.2), rgba(74,168,255,.04)); box-shadow: 0 0 16px var(--accent-lo); }
.rx-t { font-weight: 700; font-size: .92rem; }
.rx-s { font-size: .74rem; color: var(--text-dim); }

.vs-right { display: flex; align-items: center; gap: 8px; }
.parts-wrap { position: relative; }
.btn-parts { min-height: 34px; padding: 6px 14px; }
.parts-pop { position: absolute; right: 0; top: calc(100% + 6px); z-index: 30; width: min(560px, 86vw); max-height: 60vh; overflow-y: auto; padding: 12px; background: var(--surface); border: 1px solid var(--accent); border-radius: 12px; box-shadow: 0 12px 30px rgba(0,0,0,.5); }
.pp-h { font-size: .78rem; color: var(--text-dim); margin-bottom: 8px; }
.pl-group { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-bottom: 10px; }
.pl-h { width: 100%; font-size: .64rem; font-weight: 800; text-transform: uppercase; letter-spacing: .08em; color: var(--accent); }
.pl-btn { padding: 6px 11px; min-height: 32px; border-radius: 999px; border: 1px solid var(--border); background: var(--bg); color: var(--text); font-family: var(--font); font-size: .78rem; cursor: pointer; }
.pl-btn:hover { border-color: var(--accent); color: #fff; }

.half-bar { position: absolute; right: 8px; bottom: 8px; z-index: 5; }
.half-bar .btn { min-height: 36px; padding: 6px 12px; background: rgba(13,17,23,.9); }
.chain-bar { position: absolute; left: 50%; bottom: 8px; transform: translateX(-50%); z-index: 5; display: flex; flex-wrap: wrap; justify-content: center; gap: 4px; align-items: center; padding: 4px; background: rgba(13,17,23,.9); border: 1px solid var(--border); border-radius: 10px; max-width: calc(100% - 16px); }
.cb-l { font-size: .7rem; color: var(--text-dim); padding: 0 4px; text-transform: uppercase; letter-spacing: .06em; }
.cb-btn { padding: 6px 11px; min-height: 32px; border: none; border-radius: 6px; background: var(--surface2); color: var(--text-dim); font-family: var(--font); font-size: .78rem; font-weight: 700; cursor: pointer; }
.cb-btn.active { background: var(--accent); color: #fff; }
.cb-btn.cb-act { background: var(--gold); color: #1a1a2e; }
.cb-btn:hover:not(.active):not(.cb-act) { color: var(--text); }

.info-card { width: min(360px, calc(100% - 20px)); max-height: calc(100% - 20px); overflow-y: auto; }
.info-what { margin-bottom: 6px; }
.info-fn { margin-bottom: 6px; }
.info-fn b { color: var(--gold); }
.info-facts { padding-left: 18px; margin: 4px 0 8px; }
.info-facts li { font-size: .78rem; color: var(--text-dim); line-height: 1.45; margin-bottom: 2px; }
.info-live { display: flex; gap: 8px; align-items: flex-start; font-size: .8rem !important; font-family: var(--mono); background: rgba(74,168,255,.1); border: 1px solid rgba(74,168,255,.35); border-radius: 8px; padding: 6px 8px; color: #cfe6ff !important; }
.il-dot { width: 8px; height: 8px; border-radius: 50%; background: #57d38c; box-shadow: 0 0 6px #57d38c; margin-top: 5px; flex-shrink: 0; }
.info-actions { display: flex; gap: 8px; margin-top: 10px; }
.info-actions .btn { flex: 1; min-height: 34px; padding: 6px 10px; font-size: .78rem; }

.btn-scram { background: #c62828; color: #fff; font-weight: 800; letter-spacing: .08em; box-shadow: 0 0 0 2px rgba(255,255,255,.12) inset; }
.btn-scram:hover { filter: brightness(1.15); box-shadow: 0 0 14px rgba(255,80,80,.55); }
.trip-banner { background: rgba(198,40,40,.18); border: 1px solid #ff5555; color: #ffd0d0; border-radius: var(--radius); padding: 10px 14px; font-size: .86rem; animation: tripPulse 1.2s ease-in-out infinite; }
@keyframes tripPulse { 50% { background: rgba(198,40,40,.32); } }
@media (prefers-reduced-motion: reduce) { .trip-banner { animation: none; } }

.rho-bars { display: flex; flex-direction: column; gap: 5px; }
.rb-row { display: grid; grid-template-columns: 170px 1fr 70px; gap: 8px; align-items: center; font-size: .78rem; }
.rb-l { color: var(--text); }
.rb-track { position: relative; height: 12px; background: rgba(255,255,255,.04); border-radius: 3px; }
.rb-track::after { content: ''; position: absolute; left: 50%; top: -2px; bottom: -2px; width: 1px; background: rgba(255,255,255,.25); }
.rb-bar { position: absolute; top: 0; bottom: 0; border-radius: 3px; }
.rb-bar.pos { background: linear-gradient(90deg, rgba(255,176,87,.6), #ffb057); }
.rb-bar.neg { background: linear-gradient(270deg, rgba(110,198,255,.6), #6ec6ff); }
.rb-v { font-family: var(--mono); text-align: right; color: var(--text); }
.rb-total { border-top: 1px solid var(--border); padding-top: 5px; font-weight: 700; }
.rb-total .rb-track { background: none; }
.rb-total .rb-track::after { display: none; }

/* ── Parameters ── */
.param-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.param { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 10px 14px; display: flex; flex-direction: column; gap: 8px; }
.param label { font-size: .8rem; font-weight: 600; color: var(--text); }
.p-unit { color: var(--accent); font-weight: 700; font-size: .74rem; }
.p-hint { color: var(--text-dim); font-weight: 400; font-size: .72rem; margin-left: 4px; }
.p-row { display: flex; align-items: center; gap: 10px; }
.sim-slider {
  flex: 1; min-width: 80px; -webkit-appearance: none; appearance: none; height: 24px; background: transparent; outline: none; cursor: pointer;
}
.sim-slider::-webkit-slider-runnable-track { height: 6px; border-radius: 3px; border: 1px solid rgba(255,255,255,.1); background: linear-gradient(to right, var(--accent) 0, var(--accent) var(--pct, 50%), rgba(255,255,255,.12) var(--pct, 50%)); }
.sim-slider::-moz-range-track { height: 6px; border-radius: 3px; border: none; background: linear-gradient(to right, var(--accent) 0, var(--accent) var(--pct, 50%), rgba(255,255,255,.12) var(--pct, 50%)); }
.sim-slider::-webkit-slider-thumb { -webkit-appearance: none; width: 18px; height: 18px; margin-top: -7px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 8px var(--accent-lo); border: 2px solid rgba(255,255,255,.25); }
.sim-slider::-moz-range-thumb { width: 16px; height: 16px; border-radius: 50%; background: var(--accent); border: 2px solid rgba(255,255,255,.25); }
.stepper-wrap { display: flex; align-items: center; height: 36px; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; background: var(--bg); flex-shrink: 0; }
.stepper-btn { width: 36px; height: 36px; border: none; background: var(--surface2); color: var(--text-dim); font-size: 1.1rem; font-weight: 700; cursor: pointer; }
.stepper-btn:hover { background: var(--accent-lo); color: var(--text); }
.stepper-btn:active { background: var(--accent); color: #fff; }
.stepper-input { width: 60px; height: 100%; border: none; background: transparent; color: var(--accent); font-family: var(--mono); font-size: .85rem; font-weight: 700; text-align: center; outline: none; -moz-appearance: textfield; }
.stepper-input::-webkit-outer-spin-button, .stepper-input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }

/* ── Readouts ── */
.readout-panel { display: grid; grid-template-columns: repeat(6, 1fr); gap: 8px; }
.readout-cell { min-width: 0; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 9px 12px; display: flex; flex-direction: column; gap: 3px; }
.readout-label { font-size: .66rem; text-transform: uppercase; letter-spacing: .06em; color: var(--text-dim); }
.readout-value { font-family: var(--mono); color: var(--text); }
.readout-value b { font-size: 1.1rem; color: var(--accent); }
.readout-value small { font-size: .72rem; color: var(--text-dim); font-family: var(--font); }

.log-spec { display: grid; grid-template-columns: 1fr 1.2fr; gap: 10px; }
.event-card, .spec-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 16px; }
.event-card h3, .spec-card h3 { font-size: .95rem; color: var(--accent); margin-bottom: 6px; }
.event-log { list-style: none; display: flex; flex-direction: column; gap: 6px; }
.event-log li { font-size: .8rem; line-height: 1.4; color: var(--text); padding-left: 8px; border-left: 3px solid var(--border); }
.event-log li span { font-family: var(--mono); color: var(--text-dim); font-size: .72rem; margin-right: 4px; }
.event-log .ev-alarm, .event-log .ev-bad { border-color: var(--red); color: #ffd0d0; }
.event-log .ev-ok { border-color: var(--green); }
.event-log .ev-warn { border-color: var(--gold); }
.spec-uses { font-size: .84rem; color: var(--text-dim); margin-bottom: 8px; }
.spec-table { width: 100%; border-collapse: collapse; font-size: .8rem; margin-bottom: 8px; }
.spec-table th { text-align: left; color: var(--text-dim); font-weight: 600; padding: 3px 8px 3px 0; width: 38%; }
.spec-table td { color: var(--text); padding: 3px 0; }
.spec-table tr + tr { border-top: 1px solid rgba(255,255,255,.05); }
.spec-pc { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.spec-pc h4 { font-size: .72rem; text-transform: uppercase; letter-spacing: .06em; color: var(--green); margin-bottom: 4px; }
.spec-pc div + div h4 { color: var(--gold); }
.spec-pc ul { padding-left: 16px; font-size: .8rem; color: var(--text); line-height: 1.45; }
.spec-note { font-size: .7rem; color: var(--text-dim); margin-top: 8px; }

/* ── Explore ── */
.explore-panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; }
.explore-tabs { display: flex; flex-wrap: wrap; gap: 4px; background: var(--bg); padding: 4px; border-radius: 9px; margin-bottom: 14px; }
.explore-tab { padding: 7px 13px; min-height: 34px; border: none; background: transparent; color: var(--text-dim); border-radius: 6px; cursor: pointer; font-size: .82rem; font-weight: 600; font-family: var(--font); }
.explore-tab.active { background: var(--accent); color: #fff; }
.explore-tab:hover:not(.active) { background: var(--surface2); color: var(--text); }
.explore-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 12px; }
.ex-card { background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; }
.ex-card:hover { border-color: var(--accent); }
.ex-card h3 { font-size: .98rem; color: var(--accent); margin-bottom: 6px; }
.ex-card p { font-size: .84rem; color: var(--text); line-height: 1.55; margin-bottom: 6px; }
.ex-formula { font-family: var(--mono); font-size: .85rem; background: var(--surface2); color: var(--gold); padding: 7px 10px; border-radius: 6px; margin: 6px 0; }
.ex-example { border-left: 3px solid var(--accent); padding-left: 10px; color: var(--text-dim) !important; }
.ex-note { color: var(--text-dim) !important; font-size: .8rem !important; }
.ex-tw { overflow-x: auto; }
.ex-table { width: 100%; border-collapse: collapse; font-size: .78rem; margin: 6px 0; }
.ex-table th { text-align: left; color: var(--accent); padding: 4px 6px; border-bottom: 1px solid var(--border); }
.ex-table td { padding: 4px 6px; color: var(--text); border-bottom: 1px solid rgba(255,255,255,.05); }

/* ── Practice & quiz ── */
.practice-panel, .quiz-panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; display: flex; flex-direction: column; gap: 12px; }
.practice-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.practice-top h2 { font-size: 1.05rem; color: var(--accent); }
.pbar-score { font-size: .84rem; color: var(--text-dim); }
.pbar-score span { color: var(--text); font-weight: 700; }
.practice-prompt { font-size: .95rem; line-height: 1.6; }
.practice-input-group { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.practice-input-group input { width: 150px; padding: 8px 10px; min-height: 36px; border-radius: 8px; border: 1px solid var(--border); background: var(--surface2); color: var(--text); font-family: var(--mono); font-size: .95rem; }
.practice-unit { color: var(--text-dim); font-size: .85rem; min-width: 40px; }
.practice-note { font-size: .74rem; color: var(--text-dim); }
.fb-ok { color: var(--green); font-weight: 700; }
.fb-bad { color: var(--red); font-weight: 700; }
.fb-warn { color: var(--gold); }
.fb-sol { font-size: .85rem; color: var(--text-dim); margin-top: 4px; font-family: var(--mono); }
.quiz-counter { font-size: .78rem; color: var(--text-dim); text-transform: uppercase; letter-spacing: .08em; }
.quiz-prompt { font-size: 1rem; line-height: 1.5; }
.quiz-options { display: flex; flex-direction: column; gap: 8px; }
.quiz-opt { display: flex; gap: 10px; align-items: center; padding: 11px 14px; min-height: 44px; border-radius: 8px; cursor: pointer; background: var(--surface2); border: 1px solid var(--border); color: var(--text); font-size: .9rem; text-align: left; font-family: var(--font); }
.quiz-opt:hover:not(:disabled) { border-color: var(--accent); }
.quiz-opt:disabled { cursor: default; }
.quiz-opt.right { border-color: var(--green); background: rgba(61,220,132,.15); }
.quiz-opt.wrong { border-color: var(--red); background: rgba(255,85,85,.15); }
.qo-k { width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; background: var(--bg); color: var(--accent); font-weight: 800; font-size: .78rem; flex-shrink: 0; }
.quiz-result { text-align: center; display: flex; flex-direction: column; gap: 10px; align-items: center; }
.quiz-stars { font-size: 2.2rem; color: var(--gold); letter-spacing: 4px; }

/* ── SEO article ── */
.seo-article { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 28px 24px; line-height: 1.7; }
.seo-article h2 { font-size: 1.3rem; color: var(--accent); margin: 8px 0 12px; }
.seo-article h3 { font-size: 1.05rem; color: var(--text); margin: 18px 0 8px; }
.seo-article p { font-size: 0.92rem; color: var(--text-dim); margin-bottom: 10px; }
.seo-article a { color: var(--accent); text-decoration: none; }
.seo-article a:hover { text-decoration: underline; }
.table-wrap { overflow-x: auto; margin: 8px 0 14px; }
.art-table { width: 100%; border-collapse: collapse; font-size: .84rem; }
.art-table th { text-align: left; color: var(--accent); padding: 6px 8px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.art-table td { padding: 6px 8px; color: var(--text); border-bottom: 1px solid rgba(255,255,255,.05); vertical-align: top; }

/* INTERLINK-START header quick-links */
.head-actions{display:flex;align-items:center;gap:8px;margin-left:auto;flex-wrap:wrap;justify-content:flex-end;}
.btn-link{display:inline-flex;align-items:center;gap:7px;padding:5px 12px;border-radius:8px;font-size:.82rem;font-weight:700;text-decoration:none;cursor:pointer;background:var(--surface2,#1f2535);color:var(--text,#dde3f0);border:1.5px solid var(--border,#2a3050);white-space:nowrap;transition:border-color .18s,background .18s,color .18s;}
.btn-link:hover{border-color:var(--accent,#4fc3f7);background:var(--accent-lo,rgba(79,195,247,.18));color:#fff;}
.btn-link img{width:20px;height:20px;border-radius:4px;flex:none;}
.btn-link .lbl{line-height:1;}
@media(max-width:1000px){.btn-link .lbl{display:none;}.btn-link{padding:5px 9px;}}
/* INTERLINK-END */

/* ── Responsive ── */
@media (max-width: 900px) {
  .readout-panel { grid-template-columns: repeat(4, 1fr); }
  .log-spec { grid-template-columns: 1fr; }
}
@media (max-width: 768px) {
  .rx-s { display: none; }
  .param-grid { grid-template-columns: 1fr; }
  .controls-bar { gap: 10px; }
  .explore-cards { grid-template-columns: 1fr; }
}
@media (max-width: 500px) {
  body { padding: 0 10px; }
  header h1 { font-size: 1.4rem; }
  .subtitle { font-size: .76rem; }
  .controls-bar { padding: 10px 12px; gap: 8px; }
  .pill { padding: 5px 10px; font-size: .76rem; }
  .rx-btn { padding: 8px 10px; min-height: 46px; }
  .rx-t { font-size: .8rem; }
  .rb-row { grid-template-columns: 110px 1fr 58px; font-size: .72rem; }
  .readout-panel { grid-template-columns: repeat(2, 1fr); }
  .spec-pc { grid-template-columns: 1fr; }
  .tour-text { font-size: .8rem; }
  .info-card { top: auto; bottom: 10px; }
  .seo-article { padding: 20px 14px; }
}

.b3d-sep { width: 1px; align-self: stretch; background: var(--border); margin: 2px 2px; }

/* ═══ Phone layout (mobile-ui.js) ══════════════════════════════
   Scoped to body.nr-m, which mobile-ui.js sets only while the screen is ≤ 720 px — none of this can
   reach desktop. The dock is sticky inside #sec-simulate, never position:fixed on the page (a fixed
   bottom bar stopped the Auto Ads anchor ad on utm-testing). */
.m-dock, .m-setchip { display: none; }
@media (max-width: 720px) {
  body.nr-m header { padding: 0; }
  body.nr-m header h1 { font-size: 1.15rem; line-height: 1.2; }
  body.nr-m .subtitle { font-size: 0.7rem; margin-top: 1px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  body.nr-m .m-banner { padding: 6px; gap: 6px; flex-direction: column; align-items: stretch; }
  body.nr-m .m-banner .ctrl-label { display: none; }
  body.nr-m .m-banner .ctrl-group { display: block; }
  body.nr-m #mode-tabs { display: grid; grid-template-columns: repeat(4, 1fr); }
  body.nr-m #mode-tabs .pill { min-height: 36px; padding: 0 4px; font-size: 0.8rem; font-weight: 700; }
  body.nr-m .m-banner .head-actions { display: flex; flex-wrap: nowrap; justify-content: space-between; gap: 6px; margin: 0; width: 100%; }
  body.nr-m .m-banner .head-actions > a, body.nr-m .m-banner .head-actions > button { flex: 1 1 0; min-width: 0; height: 38px; padding: 0 !important; justify-content: center; border-radius: 9px; }
  body.nr-m .m-banner .btn-link .lbl, body.nr-m .m-banner .btn-share-ext { display: none; }
  body.nr-m .m-banner .btn-link img { width: 22px; height: 22px; }
  body.nr-m .m-banner .head-actions > button.btn-link, body.nr-m .m-banner .btn-guide { font-size: 0 !important; display: inline-flex; align-items: center; }
  body.nr-m .m-banner .head-actions > button.btn-link::before { content: '\1F517'; font-size: 17px; }
  body.nr-m .m-banner .btn-guide::before { content: '\1F4D6'; font-size: 17px; }
  body.nr-m .m-setchip { display: flex; align-items: center; gap: 6px; width: 100%; min-height: 38px; padding: 6px 10px; border-radius: 10px; border: 1px solid var(--border); background: var(--surface); color: var(--text); font-family: inherit; font-size: .78rem; cursor: pointer; text-align: left; }
  body.nr-m .m-chip-t { font-weight: 700; }
  body.nr-m .m-chip-v { flex: 1; min-width: 0; color: var(--text-dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

  /* Stage */
  body.nr-m .rx-strip { gap: 6px; }
  body.nr-m .canvas-card { padding: 4px; }
  body.nr-m .view-strip { margin-bottom: 4px; gap: 6px; }
  body.nr-m .vt-tabs { width: 100%; display: grid; grid-template-columns: repeat(4, 1fr); }
  body.nr-m .vt-pill { justify-content: center; padding: 6px 4px; min-height: 36px; font-size: .74rem; }
  body.nr-m .vs-right { width: 100%; }
  body.nr-m .vs-right .parts-wrap, body.nr-m .vs-right .btn-parts { flex: 1; }
  body.nr-m .btn-parts { width: 100%; min-height: 36px; }
  body.nr-m .info-card { top: auto; bottom: 8px; left: 8px; right: 8px; width: auto; max-height: 70%; }
  body.nr-m .chain-bar .cb-btn { padding: 6px 8px; min-height: 36px; }
  body.nr-m .readout-panel { grid-template-columns: repeat(4, 1fr); gap: 3px; }
  body.nr-m .readout-cell { padding: 4px 5px; border-radius: 8px; gap: 1px; }
  body.nr-m .readout-label { font-size: .5rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  body.nr-m .readout-value b { font-size: .75rem; }
  body.nr-m .readout-value small { font-size: .55rem; }

  /* Dock */
  body.nr-m .m-dock { display: block; position: sticky; bottom: var(--m-anchor, 0px); z-index: 60; margin-top: 8px; padding: 0 0 env(safe-area-inset-bottom); pointer-events: none; }
  body.nr-m .m-dock > * { pointer-events: auto; }
  body.nr-m .m-bar { display: flex; gap: 6px; align-items: stretch; margin: 0 0 8px; padding: 6px; background: rgba(18,22,32,0.94); backdrop-filter: blur(8px); border: 1px solid var(--border); border-radius: 14px; box-shadow: 0 -6px 24px rgba(0,0,0,.45); }
  body.nr-m .m-run { flex: 1; display: flex; gap: 6px; min-width: 0; }
  body.nr-m .m-run .btn { flex: 1 1 0; min-width: 0; min-height: 46px; padding: 2px 4px; font-size: .7rem; line-height: 1.1; border-radius: 10px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  body.nr-m .m-run .btn-ghost { background: var(--surface2); color: var(--text); border: 1.5px solid var(--border); }
  body.nr-m .m-setup { flex: none; width: 58px; min-height: 46px; border-radius: 10px; border: 2px solid var(--border); background: var(--surface2); color: var(--text); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px; font-family: inherit; cursor: pointer; }
  body.nr-m .m-setup-ic { font-size: 1.05rem; line-height: 1; }
  body.nr-m .m-setup-lbl { font-size: 0.6rem; font-weight: 700; }
  body.nr-m .m-setup[aria-expanded="true"] { background: var(--accent); border-color: var(--accent); color: #0d1117; }
  body.nr-m .m-sheet { display: flex; flex-direction: column; margin: 0 0 6px; overflow: hidden; background: rgba(22,27,38,0.97); backdrop-filter: blur(10px); border: 1px solid var(--border); border-radius: 14px; box-shadow: 0 -8px 30px rgba(0,0,0,.5); }
  body.nr-m .m-sheet[hidden] { display: none; }
  body.nr-m .m-sheet-tabs { flex: none; display: grid; grid-template-columns: repeat(3, 1fr); gap: 2px; padding: 4px; border-bottom: 1px solid var(--border); }
  body.nr-m .m-sheet-tabs button { min-height: 36px; border: 0; border-radius: 8px; background: transparent; color: var(--text-dim); font-family: inherit; font-size: 0.74rem; font-weight: 700; cursor: pointer; }
  body.nr-m .m-sheet-tabs button[aria-selected="true"] { background: var(--surface2); color: var(--text); box-shadow: inset 0 -2px 0 var(--accent); }
  body.nr-m .m-pane { flex: 1 1 auto; overflow-y: auto; overscroll-behavior: contain; padding: 10px; display: flex; flex-direction: column; gap: 10px; }
  body.nr-m .m-pane[hidden] { display: none; }
  body.nr-m .m-pane .param-grid { grid-template-columns: 1fr; gap: 8px; }
  body.nr-m .m-pane .param { padding: 8px 10px; }
  body.nr-m .m-pane .stepper-wrap, body.nr-m .m-pane .stepper-btn { height: 40px; }
  body.nr-m .m-pane .stepper-btn { width: 40px; }
  body.nr-m .m-pane #desk-actions { padding: 8px; flex-direction: column; align-items: stretch; }
  body.nr-m .m-pane #desk-actions .ctrl-group { flex-wrap: wrap; }
  body.nr-m .m-pane #desk-actions .btn { min-height: 40px; }
  body.nr-m .m-pane #desk-actions select { flex: 1; min-height: 40px; }
  body.nr-m .m-pane .scen-desc { margin: 0; }
  body.nr-m .m-pane .log-spec { grid-template-columns: 1fr; }
}
@media (max-width: 720px) { body.nr-m .m-pane .pill { min-height: 36px; } }
@media (max-width: 720px) { body.nr-m .m-pane .sim-slider { height: 36px; } }
.seo-article h4 { font-size: .95rem; color: var(--text); margin: 12px 0 4px; }
