/* Annealing Chamber. Layout: title with presets; the energy landscape beside the decision-rule plot and telemetry; the annealing console (thermometer, timeline, schedule table); then the distribution histogram and success rate. Stacks on narrow screens. */
:root {
  color-scheme: dark;
  --bg: #070a12;
  --panel: #0c111d;
  --panel-2: #121a2a;
  --line: #1b2436;
  --line-2: #29364f;
  --fg: #e3e8f2;
  --muted: #8b97ad;
  --dim: #56627a;
  --cyan: #00f0ff;
  --crimson: #ff3366;
  --amber: #ffb800;
  --green: #34d399;
  --display: "Literata", "Iowan Old Style", Georgia, serif;
  --sans: "Instrument Sans", "Segoe UI", system-ui, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, "SFMono-Regular", Menlo, monospace;
  --r: 6px;
}
[hidden] { display: none !important; }
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--fg); font: 14px/1.45 var(--sans); }
button, select, input { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--cyan); outline-offset: 2px; }

.app { display: grid; gap: 12px; padding-block: 12px 20px;
  padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); }
.top { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 12px 24px; }
.eyebrow { font: 500 11px/1.2 var(--mono); letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
h1 { margin: 4px 0 0; font: 600 24px/1.15 var(--display); text-wrap: balance; }
h1 span { display: block; margin-top: 3px; font: 400 13px/1.3 var(--sans); color: var(--muted); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { font: 12.5px var(--sans); padding: 5px 11px; border-radius: 999px; border: 1px solid var(--line-2); background: var(--panel); cursor: pointer; transition: border-color .15s, color .15s; }
.chip:hover { border-color: var(--cyan); }
.chip.on { border-color: var(--cyan); color: var(--cyan); background: rgba(0,240,255,.07); }
.note { margin: 0; font-size: 13.5px; color: #c7cfdf; max-width: 130ch; }
.note b { color: var(--fg); }
.lbl { font: 500 11px var(--mono); letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }

select, .btn { background: var(--panel-2); border: 1px solid var(--line-2); border-radius: var(--r); padding: 5px 9px; min-height: 32px; max-width: 100%; }
.btn { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; transition: border-color .15s; white-space: nowrap; }
.btn:hover { border-color: var(--cyan); }
.btn svg { width: 14px; height: 14px; flex: none; }
.btn.icon { padding: 5px 8px; }
.btn.sm { min-height: 28px; padding: 3px 9px; font-size: 12px; }
.btn.primary { background: rgba(0,240,255,.1); border-color: rgba(0,240,255,.5); color: var(--cyan); }
.seg { display: inline-flex; border: 1px solid var(--line-2); border-radius: var(--r); overflow: hidden; }
.segb { background: var(--panel-2); border: 0; padding: 5px 10px; font-size: 12.5px; cursor: pointer; color: var(--muted); }
.segb + .segb { border-left: 1px solid var(--line-2); }
.segb.on { background: rgba(255,184,0,.14); color: var(--amber); }
#mDet.on { background: rgba(255,51,102,.14); color: #ff8fab; }

.main { display: grid; grid-template-columns: minmax(0, 1fr) 380px; gap: 12px; align-items: start; }
.card { border: 1px solid var(--line); border-radius: 8px; background: var(--panel); padding: 10px 12px 12px; display: grid; gap: 8px; min-width: 0; align-content: start; }
.card-h { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 6px 12px; }
.sec-h { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 10px; margin: 0; font: 500 11px var(--mono); letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.sec-h em { font-style: normal; text-transform: none; letter-spacing: 0; color: var(--dim); }
canvas { display: block; width: 100%; border-radius: 6px; border: 1px solid var(--line); background: radial-gradient(120% 100% at 50% 20%, #0c1424 0%, #05070d 75%); }
#cvStage { height: 470px; }
#cvSig { height: 230px; }
#cvHist { height: 190px; }
.stage-ctl { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 10px; }
.side { display: grid; gap: 12px; min-width: 0; }
.cap { margin: 0; font: 11.5px/1.45 var(--mono); color: var(--dim); }
#sigCap { display: grid; height: calc(3 * 1.45em); overflow: hidden; }
#sigCap span { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#sigCap span:first-child { color: var(--muted); }
.tele { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 4px 12px; font: 12px var(--mono); font-variant-numeric: tabular-nums; }
.tele span { color: var(--muted); }
.tele b { font-weight: 500; text-align: right; }
.tele .hot { color: var(--amber); }
.tele .hint { grid-column: 1 / -1; color: var(--dim); font-size: 11px; line-height: 1.4; }

.console-grid { display: grid; grid-template-columns: 72px minmax(0, 1fr) 300px; gap: 14px; align-items: start; }
.thermo-col { display: grid; justify-items: center; gap: 6px; }
.thermo { position: relative; width: 22px; height: 150px; border-radius: 11px; background: #0a0f1a; border: 1px solid var(--line-2); overflow: hidden; }
.thermo::before { content: ""; position: absolute; inset: 0; background: linear-gradient(0deg, #2563eb 0%, #00f0ff 30%, #a3e635 50%, #ffb800 72%, #ff3366 100%); opacity: .18; }
.mercury { position: absolute; left: 3px; right: 3px; bottom: 3px; border-radius: 8px; background: linear-gradient(0deg, #2563eb 0%, #00f0ff 30%, #a3e635 50%, #ffb800 72%, #ff3366 100%); background-size: 100% 144px; background-position: bottom; transition: height .15s; box-shadow: 0 0 12px rgba(255,184,0,.35); }
.thermo .tick { position: absolute; left: -2px; right: -2px; height: 2px; background: #fff; opacity: .7; }
.thermo.off .mercury { filter: grayscale(1); opacity: .35; }
.tread { display: grid; justify-items: center; font: 700 18px/1 var(--mono); font-variant-numeric: tabular-nums; }
.tread span { font-size: 10.5px; color: var(--muted); font-weight: 500; margin-top: 2px; }
.seq-col { display: grid; gap: 8px; min-width: 0; }
.tr-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 10px; }
.clock { font: 500 12.5px var(--mono); color: var(--muted); font-variant-numeric: tabular-nums; min-width: 25ch; white-space: nowrap; }
.clock b { color: var(--cyan); }
.spacer { flex: 1; }
.timeline { position: relative; height: 46px; border-radius: 6px; border: 1px solid var(--line-2); overflow: hidden; cursor: pointer; background: #05070d; }
.timeline .segs { position: absolute; inset: 0; display: flex; }
.timeline .sg { height: 100%; border-right: 1px solid rgba(7,10,18,.8); display: flex; align-items: flex-end; padding: 0 4px 3px; font: 600 10px var(--mono); color: rgba(7,10,18,.85); overflow: hidden; white-space: nowrap; min-width: 0; }
.timeline .sg.on { box-shadow: inset 0 0 0 2px #fff; }
.timeline .head { position: absolute; top: 0; bottom: 0; width: 2px; background: #fff; box-shadow: 0 0 8px #fff; pointer-events: none; }
.scale { display: flex; justify-content: space-between; font: 10.5px var(--mono); color: var(--dim); }
input[type=range] { -webkit-appearance: none; appearance: none; width: 100%; background: transparent; height: 18px; margin: 0; }
input[type=range]::-webkit-slider-runnable-track { height: 6px; border-radius: 3px; background: linear-gradient(90deg, #2563eb, #00f0ff 30%, #a3e635 50%, #ffb800 72%, #ff3366); }
input[type=range]::-moz-range-track { height: 6px; border-radius: 3px; background: linear-gradient(90deg, #2563eb, #00f0ff 30%, #a3e635 50%, #ffb800 72%, #ff3366); }
input[type=range]::-webkit-slider-thumb { -webkit-appearance: none; width: 16px; height: 16px; margin-top: -5px; border-radius: 50%; background: #fff; border: 2px solid var(--bg); box-shadow: 0 0 0 1px #fff; }
input[type=range]::-moz-range-thumb { width: 14px; height: 14px; border-radius: 50%; background: #fff; border: 2px solid var(--bg); }
.switch { display: inline-flex; align-items: center; gap: 9px; cursor: pointer; font-size: 13px; }
.switch input { position: absolute; opacity: 0; pointer-events: none; }
.switch i { width: 32px; height: 18px; border-radius: 9px; background: var(--line-2); position: relative; transition: background .15s; flex: none; }
.switch i::after { content: ""; position: absolute; left: 3px; top: 3px; width: 12px; height: 12px; border-radius: 50%; background: var(--fg); transition: transform .15s; }
.switch input:checked + i { background: var(--cyan); }
.switch input:checked + i::after { transform: translateX(14px); }
.switch:has(input:focus-visible) { outline: 2px solid var(--cyan); outline-offset: 2px; border-radius: 4px; }
.table-col { display: grid; gap: 6px; min-width: 0; }
table.steps { width: 100%; border-collapse: collapse; font: 12px var(--mono); }
.steps th { font-weight: 500; font-size: 10.5px; color: var(--muted); text-align: left; padding: 2px 4px; }
.steps td { padding: 2px 4px; border-top: 1px solid var(--line); }
.steps tr.on td { background: rgba(255,255,255,.05); }
.steps input { width: 64px; background: var(--bg); border: 1px solid var(--line-2); border-radius: 4px; padding: 2px 5px; font: 12px var(--mono); color: var(--fg); }
.steps .x { background: none; border: 0; color: var(--muted); cursor: pointer; padding: 2px; }
.steps .x svg { width: 12px; height: 12px; }
.steps .sw { display: inline-block; width: 10px; height: 10px; border-radius: 2px; vertical-align: -1px; }
.table-col .tbl-wrap { max-height: 170px; overflow-y: auto; border: 1px solid var(--line); border-radius: 6px; }
.row-btns { display: flex; gap: 6px; flex-wrap: wrap; }
.row-btns select { flex: 1; min-width: 0; font-size: 12px; min-height: 28px; padding: 3px 6px; }
.badge { white-space: nowrap; min-width: 222px; justify-content: center; display: inline-flex; align-items: center; gap: 8px; font: 700 11.5px/1 var(--mono); letter-spacing: .06em; padding: 6px 10px; border-radius: 4px; border: 1px solid var(--line-2); background: var(--panel-2); }
.badge i { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); }
.badge.hot { color: #ffd166; border-color: rgba(255,184,0,.55); } .badge.hot i { background: var(--amber); box-shadow: 0 0 8px var(--amber); }
.badge.cold { color: #67e8f9; border-color: rgba(0,240,255,.5); } .badge.cold i { background: var(--cyan); box-shadow: 0 0 8px var(--cyan); }
.badge.det { color: #ff8fab; border-color: rgba(255,51,102,.55); } .badge.det i { background: var(--crimson); box-shadow: 0 0 8px var(--crimson); }

.lower { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); gap: 12px; align-items: start; }
.success { display: grid; gap: 10px; }
.success .big { display: flex; align-items: baseline; gap: 10px; }
.success .big b { font: 700 40px/1 var(--mono); color: var(--cyan); text-shadow: 0 0 18px rgba(0,240,255,.4); font-variant-numeric: tabular-nums; }
.success .big span { color: var(--muted); font-size: 13px; }
.success .bars { display: grid; gap: 5px; }
.success .br { display: grid; grid-template-columns: 120px minmax(0, 1fr) 40px; gap: 8px; align-items: center; font: 12px var(--mono); }
.success .br .t { height: 10px; border-radius: 5px; background: var(--panel-2); overflow: hidden; position: relative; }
.success .br .t i { position: absolute; left: 0; top: 0; bottom: 0; border-radius: 5px; }
.success .br .t u { position: absolute; top: -2px; bottom: -2px; width: 2px; background: #fff; opacity: .7; text-decoration: none; }
.success .br span { color: var(--muted); }
.success .br b { text-align: right; font-weight: 500; }
.success .foot { font-size: 12px; color: var(--muted); margin: 0; }

@media (max-width: 1100px) {
  .main, .lower { grid-template-columns: minmax(0, 1fr); }
  .side { grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }
  .console-grid { grid-template-columns: 72px minmax(0, 1fr); }
  .table-col { grid-column: 1 / -1; }
}
@media (max-width: 600px) {
  h1 { font-size: 20px; }
  #cvStage { height: 360px; }
  .console-grid { grid-template-columns: minmax(0, 1fr); }
  .thermo-col { grid-template-columns: auto auto; justify-content: start; align-items: center; }
  .thermo { height: 100px; }
  .success .br { grid-template-columns: 96px minmax(0, 1fr) 36px; }
}
.pg-embedded .top > div:first-child { display: none; }
@media (prefers-reduced-motion: reduce) { .btn, .chip, .switch i, .switch i::after, .mercury { transition: none; } }
