/* Toolholder EMC presentation — forked from present.css: white theme, grey tones, large type for a bench/projector. */
:root {
  color-scheme: light;
  --bg: #f3f4f6;
  --panel: #ffffff;
  --panel-2: #eceef1;
  --line: #d3d8de;
  --line-strong: #9aa3ad;
  --text: #1b2129;
  --muted: #5d6874;
  --white: #ffffff;
  --green: #1fae5a;
  --green-glow: rgba(31,174,90,.45);
  --red: #e01f1f;
  --red-glow: rgba(224,31,31,.45);
  --blue: #2b7fe0;
  --amber: #d99a06;
  --graphite: #2a3340;
  --graphite-glow: rgba(42,51,64,.35);
  --focus: #2b7fe0;
  font: 18px/1.35 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; min-height: 100vh; padding: clamp(10px, 1.4vw, 24px); background: var(--bg); display: flex; flex-direction: column; }
#live { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; gap: 10px; }
h1, h2, h3, p { margin: 0; }
kbd {
  font: 600 .7em/1 ui-monospace, SFMono-Regular, Menlo, monospace;
  padding: 3px 7px; border: 1px solid var(--line-strong); border-bottom-width: 3px; border-radius: 6px;
  background: #fff; color: var(--text); vertical-align: middle; margin-left: 8px;
}
.eyebrow { font-size: .78rem; letter-spacing: .14em; color: var(--muted); text-transform: uppercase; }
.muted { color: var(--muted); font-size: .82rem; }

/* header */
.top { display: flex; justify-content: space-between; align-items: center; gap: 24px; }
.top h1 { font-size: clamp(22px, 2.3vw, 36px); font-weight: 700; }
.top-tools { display: flex; gap: 16px; align-items: center; flex-wrap: wrap; }
.pill {
  display: inline-flex; align-items: center; gap: 10px; padding: 8px 16px; border-radius: 999px;
  font-weight: 600; font-size: .95rem; border: 1px solid var(--line); background: var(--panel);
}
.pill::before { content: ""; width: 14px; height: 14px; border-radius: 50%; background: var(--line-strong); }
.pill.online::before { background: var(--green); box-shadow: 0 0 12px var(--green-glow); }
.pill.offline { color: #a51616; border-color: #e9a3a3; }
.pill.offline::before { background: var(--red); box-shadow: 0 0 12px var(--red-glow); }

/* buttons */
button {
  font: inherit; font-size: 1.1rem; font-weight: 700; min-height: 60px; padding: 12px 28px;
  border: 2px solid var(--line-strong); border-radius: 12px; background: #e9ecf0; color: var(--text); cursor: pointer;
}
button:hover:not(:disabled) { background: #dde2e8; }
button:disabled { opacity: .4; cursor: not-allowed; }
button:focus-visible { outline: 4px solid var(--focus); outline-offset: 4px; }
button.ghost { background: transparent; min-height: 44px; font-size: .95rem; font-weight: 600; }
button.ghost.small { min-height: 30px; padding: 2px 10px; font-size: .8rem; }
button.primary { background: var(--green); border-color: #157a3e; color: #fff; }
button.primary:hover:not(:disabled) { background: #1a9a4f; }
button.danger { background: var(--red); border-color: #a51616; color: #fff; }
button.danger:hover:not(:disabled) { background: #c41b1b; }

/* hero */
.hero {
  display: grid; grid-template-columns: 200px 1fr 330px 200px; align-items: center;
  gap: 24px; padding: 12px 24px; background: var(--panel); border: 1px solid var(--line); border-radius: 18px;
  box-shadow: 0 2px 12px rgba(27,33,41,.06);
}
.led-area { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 8px; }
.led-area strong { font-size: 1.15rem; }
.led {
  width: min(170px, 22vh); height: min(170px, 22vh); border-radius: 50%; border: 9px solid #e6e9ed;
  background: #b3bac3; box-shadow: 0 0 0 2px var(--line), 0 8px 30px rgba(27,33,41,.15);
  transition: background-color .15s, box-shadow .15s, border-color .15s;
}
.led.white { background: var(--white); border-color: #f4f5f7; box-shadow: 0 0 0 2px var(--line-strong), 0 0 70px rgba(27,33,41,.28); }
.led.green { background: var(--green); border-color: #cdeedb; box-shadow: 0 0 0 2px #8fd6ac, 0 0 80px var(--green-glow); }
.led.unknown { background: #b3bac3; }

.mode-row { display: flex; align-items: center; gap: 24px; }
.mode-letter {
  font-size: clamp(72px, 9vw, 150px); line-height: .9; font-weight: 900; letter-spacing: -.02em; min-width: 1.1em; text-align: center;
  color: var(--graphite); font-variant-numeric: tabular-nums;
}
.mode-letter.b { color: var(--green); }
.hero-copy h2#mode-title { font-size: clamp(28px, 3.4vw, 54px); line-height: 1.05; font-weight: 800; letter-spacing: -.01em; }
.hero-copy .eyebrow { font-size: .95rem; margin-bottom: 4px; }
.expectation { font-size: clamp(18px, 1.8vw, 28px); margin-top: 6px; color: #2d3640; font-variant-numeric: tabular-nums; }
.badge {
  display: inline-block; margin-top: 10px; padding: 8px 26px; border-radius: 14px; font-size: clamp(26px, 3vw, 46px);
  font-weight: 900; letter-spacing: .06em; color: #fff; background: #8f99a4; min-width: 10em; text-align: center;
}
.badge.match { background: var(--green); box-shadow: 0 0 30px var(--green-glow); }
.badge.mismatch { background: var(--red); box-shadow: 0 0 40px var(--red-glow); animation: flash 1s steps(1, end) infinite; }
.badge.transition { background: var(--amber); }
.badge.unknown { background: #8f99a4; }
@keyframes flash { 50% { opacity: .55; } }

.run-clock { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 4px; padding: 8px; border-radius: 14px; }
.run-clock strong { font-size: clamp(44px, 5vw, 80px); line-height: 1; font-variant-numeric: tabular-nums; font-weight: 800; }
.run-clock .cycles { font-size: 1.25rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.run-clock.idle strong { color: var(--line-strong); }

/* readouts (inside the hero, stacked) */
.readouts { display: grid; grid-template-rows: 1fr 1fr; gap: 6px; }
.readout {
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 10px; padding: 4px 12px;
  display: grid; grid-template-columns: auto 1fr; grid-template-rows: auto auto; column-gap: 14px; align-items: center;
}
.readout .label { font-size: .85rem; font-weight: 700; letter-spacing: .08em; }
.readout .bit {
  grid-row: 1 / span 2; grid-column: 2; justify-self: end; font-size: clamp(24px, 2.2vw, 34px); line-height: 1;
  font-weight: 800; font-variant-numeric: tabular-nums; color: #8f99a4;
}
.readout .bit.small { font-size: clamp(16px, 1.5vw, 22px); }
.readout.high .bit { color: var(--graphite); }
.readout.high { border: 2px solid var(--graphite); box-shadow: 0 0 0 3px var(--graphite-glow); background: #fff; }
.readout small { color: var(--muted); font-size: .66rem; grid-column: 1; line-height: 1.1; }
.readout.strain.stale .bit { color: var(--line-strong); }

/* graph */
.graph-panel { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 8px 14px 10px; }
.graph-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; font-size: .9rem; }
.graph-title { font-weight: 700; }
.legend { font-weight: 400; color: var(--muted); margin-left: 12px; font-size: .8rem; }
.legend .sw { display: inline-block; width: 14px; height: 10px; margin: 0 3px 0 8px; vertical-align: -1px; border: 1px solid rgba(27,33,41,.25); }
.sw.a { background: #ffffff; } .sw.b { background: #bfe9cf; } .sw.mm { background: rgba(224,31,31,.45); }
.sw.unk { background: repeating-linear-gradient(135deg, #cfd4da 0 3px, #f3f4f6 3px 6px); } .sw.ev { background: var(--amber); width: 4px; }
.sw.gl { background: #8e44ad; width: 4px; }
.sw.late { background: #11806a; width: 4px; }
.capture-path { font-size: .78rem; font-weight: 400; margin-left: 8px; }
.graph-tools { display: flex; gap: 14px; align-items: center; }
.graph-tools label { color: var(--muted); font-size: .85rem; }
.graph-tools select { font: inherit; font-size: .9rem; padding: 4px 8px; border-radius: 8px; border: 1px solid var(--line-strong); background: #fff; }
.replay { background: #fff3d1; border: 1px solid #ecd28a; padding: 4px 10px; border-radius: 10px; font-size: .85rem; }
.graph-wrap { position: relative; margin-top: 6px; }
#graph { display: block; width: 100%; height: 240px; border-radius: 8px; background: #fbfbfc; cursor: crosshair; }
.tooltip {
  position: absolute; pointer-events: none; background: rgba(27,33,41,.92); color: #fff; font-size: .8rem; padding: 6px 10px;
  border-radius: 8px; white-space: nowrap; z-index: 2; font-variant-numeric: tabular-nums;
}

/* counters */
.counters { display: grid; grid-template-columns: repeat(8, 1fr); gap: 10px; }
.counters > div { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 8px 14px; display: flex; flex-direction: column; }
.counters .label { font-size: .78rem; font-weight: 700; letter-spacing: .08em; color: var(--muted); text-transform: uppercase; }
.counters strong { font-size: clamp(26px, 2.6vw, 40px); font-weight: 800; font-variant-numeric: tabular-nums; line-height: 1.1; }
.counters strong.good { color: var(--green); }
.counters strong.bad { color: #8f99a4; }
.counters .mismatch-card.hot { border-color: var(--red); box-shadow: 0 0 0 3px var(--red), 0 0 0 6px var(--red-glow); }
.counters .mismatch-card.hot strong { color: var(--red); }
.counters .glitch-card.hot { border-color: #8e44ad; box-shadow: 0 0 0 3px #8e44ad; }
.counters .glitch-card.hot strong { color: #8e44ad; }
.counters .late-card.hot { border-color: #11806a; box-shadow: 0 0 0 3px #11806a; }
.counters .late-card.hot strong { color: #11806a; }
.counters .verdict-card { grid-column: span 2; }
.verdict { font-size: clamp(18px, 1.7vw, 26px) !important; padding: 4px 12px; border-radius: 10px; color: #fff; background: #8f99a4; display: inline-block; align-self: flex-start; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.verdict.nominal { background: var(--green); }
.verdict.deviation { background: var(--red); }
.verdict.indeterminate { background: var(--amber); }
.verdict.indeterminate.flagged { background: var(--red); }
.verdict-card small { color: var(--muted); font-size: .72rem; margin-top: 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* lower row: controls / events / results */
.lower { display: grid; grid-template-columns: 1.1fr .8fr 1.8fr; gap: 12px; align-items: stretch; }
.lower > section { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 10px 16px; min-height: 0; }
.lower h3 { font-size: 1rem; font-weight: 700; margin-bottom: 6px; }
.fields { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.fields label { display: flex; flex-direction: column; font-size: .8rem; color: var(--muted); gap: 3px; }
.fields input { font: inherit; font-size: 1.1rem; padding: 6px 10px; border-radius: 8px; border: 1px solid var(--line-strong); background: #fff; width: 100%; }
.fields input:invalid, .fields input.bad { border-color: var(--red); box-shadow: 0 0 0 3px var(--red-glow); }
.plan { margin-top: 6px; min-height: 1.3em; }
.plan.warn { color: #b07d00; font-weight: 600; }
.declare { display: flex; align-items: center; gap: 10px; margin-top: 6px; font-size: .95rem; font-weight: 600; }
.declare input { width: 24px; height: 24px; }
.buttons { display: flex; gap: 12px; margin-top: 8px; }
.buttons button { flex: 1 1 auto; }
.progress { margin-top: 6px; font-size: 1rem; min-height: 1.3em; color: #2d3640; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.error { margin-top: 2px; font-size: .92rem; min-height: 1.2em; color: #b11a1a; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.events ol { list-style: none; margin: 0; padding: 0; max-height: 190px; overflow: auto; font-size: .82rem; font-variant-numeric: tabular-nums; }
.events li { padding: 3px 0; border-bottom: 1px solid var(--panel-2); display: grid; grid-template-columns: 64px 1fr; gap: 8px; }
.events li .t { color: var(--muted); }
.events li.deviation .kind { color: var(--red); font-weight: 700; }
.events li.glitch .kind { color: #8e44ad; font-weight: 700; }
.events li.late .kind { color: #11806a; font-weight: 700; }
.events li .detail { color: var(--muted); font-size: .76rem; overflow-wrap: anywhere; }
.results table { width: 100%; border-collapse: collapse; font-size: .78rem; table-layout: fixed; }
.results th:nth-child(1), .results td:nth-child(1) { width: 12%; } .results th:nth-child(2), .results td:nth-child(2) { width: 15%; } .results th:nth-child(3), .results td:nth-child(3) { width: 12%; } .results th:nth-child(4), .results td:nth-child(4) { width: 7%; } .results th:nth-child(5), .results td:nth-child(5) { width: 6%; } .results th:nth-child(6), .results td:nth-child(6) { width: 11%; } .results th:nth-child(7), .results td:nth-child(7) { width: 5%; } .results th:nth-child(8), .results td:nth-child(8) { width: 32%; }
.results th { overflow: hidden; text-overflow: ellipsis; }
.results td input.meta-label, .results td select.meta-kind { font: inherit; font-size: .75rem; width: 100%; min-width: 0; padding: 2px 4px; border-radius: 6px; border: 1px solid var(--line-strong); background: #fff; }
.results tr.dirty input.meta-label, .results tr.dirty select.meta-kind { border-color: var(--amber); }
.results button.meta-save { min-height: 26px; padding: 1px 8px; font-size: .75rem; margin-right: 6px; }
.results th { text-align: left; color: var(--muted); font-weight: 600; padding: 2px 4px; border-bottom: 1px solid var(--line); }
.results td { padding: 3px 4px; border-bottom: 1px solid var(--panel-2); vertical-align: middle; font-variant-numeric: tabular-nums; }
.results tbody { display: block; max-height: 170px; overflow-y: auto; overflow-x: hidden; }
.results thead, .results tbody tr { display: table; width: 100%; table-layout: fixed; }
.results td .v { display: inline-block; padding: 1px 8px; border-radius: 8px; color: #fff; background: #8f99a4; font-size: .75rem; font-weight: 700; }
.results td .v.nominal { background: var(--green); } .results td .v.deviation { background: var(--red); } .results td .v.indeterminate { background: var(--amber); }
.results td .v.indeterminate.flagged { background: var(--red); }
.results td.mm.hot { color: var(--red); font-weight: 800; }
.results a { color: var(--blue); margin-right: 6px; }
.results button.view { min-height: 26px; padding: 1px 8px; font-size: .75rem; margin-right: 6px; }
.results button.remove { min-height: 26px; padding: 1px 8px; font-size: .75rem; margin-left: 4px; color: var(--red); }
footer { display: flex; gap: 24px; justify-content: space-between; color: var(--muted); font-size: .76rem; }

/* states */
body.offline .hero { border-color: #e9a3a3; }
body.offline .led { filter: grayscale(.6) brightness(.95); }
body.offline .readout .bit { color: var(--line-strong); }
body[data-phase="running"] .hero { box-shadow: 0 0 0 3px var(--graphite), 0 2px 12px rgba(27,33,41,.06); }
body.replaying .graph-panel { border-color: #ecd28a; box-shadow: 0 0 0 3px #fff3d1; }

/* compact laptops (1366×768) — everything must fit without scrolling */
@media (max-height: 820px) {
  :root { font-size: 14px; }
  body { padding: 8px 14px; }
  #live { gap: 7px; }
  .top h1 { font-size: 22px; }
  .pill { padding: 5px 12px; font-size: .9rem; }
  button.ghost { min-height: 36px; }
  .hero { padding: 6px 18px; gap: 14px; grid-template-columns: 120px 1fr 300px 170px; }
  .led { width: 78px; height: 78px; border-width: 5px; }
  .led-area { gap: 3px; }
  .led-area strong { font-size: .95rem; }
  .led-area .muted { display: none; }
  .mode-letter { font-size: 64px; }
  .mode-row { gap: 16px; }
  .hero-copy h2#mode-title { font-size: 26px; }
  .hero-copy .eyebrow { font-size: .8rem; margin-bottom: 0; }
  .expectation { font-size: 16px; margin-top: 0; }
  .badge { margin-top: 4px; font-size: 22px; padding: 2px 16px; }
  .run-clock { padding: 2px; gap: 1px; }
  .run-clock strong { font-size: 40px; }
  .run-clock .cycles { font-size: 1rem; }
  .readouts { gap: 4px; }
  .readout { padding: 2px 10px; column-gap: 10px; }
  .readout .label { font-size: .8rem; }
  .readout .bit { font-size: 24px; }
  .readout .bit.small { font-size: 16px; }
  .readout small { font-size: .62rem; }
  .graph-panel { padding: 3px 10px 4px; }
  .graph-head { font-size: .85rem; }
  .graph-wrap { margin-top: 2px; }
  #graph { height: 220px; }
  .counters { gap: 8px; }
  .counters > div { padding: 4px 10px; }
  .counters strong { font-size: 24px; }
  .verdict { font-size: 16px !important; padding: 2px 10px; }
  .lower { gap: 8px; }
  .lower > section { padding: 6px 12px; }
  .fields input { font-size: .95rem; padding: 3px 8px; }
  .buttons { margin-top: 4px; }
  button { min-height: 40px; padding: 4px 16px; font-size: .95rem; }
  .plan { margin-top: 2px; }
  .declare { margin-top: 2px; font-size: .85rem; }
  .declare input { width: 18px; height: 18px; }
  .progress { margin-top: 2px; font-size: .9rem; }
  .error { font-size: .85rem; }
  .lower h3 { margin-bottom: 2px; font-size: .9rem; }
  .fields { gap: 6px; }
  .fields label { font-size: .72rem; gap: 1px; }
  .progress, .error { min-height: 0; }
  .events ol { max-height: 118px; }
  .results tbody { max-height: 100px; }
  footer { font-size: .7rem; }
  footer p:last-child { display: none; }
}
@media (max-width: 1000px) {
  .hero { grid-template-columns: 1fr; text-align: center; }
  .counters { grid-template-columns: repeat(3, 1fr); }
  .lower { grid-template-columns: 1fr; }
}
