/* Temper's case study: the run console. A dark instrument in both themes, so the 400 trials read like a live run.
   Every column is one question, from its trials down to its change. Colours keep the site's meaning: emerald passed,
   ember failed or worse beyond noise; shape and position say the same, so colour is never the only signal. */
.t-run {
  --t-bg: #0b0e12; --t-panel: #11161c; --t-line: rgba(255, 255, 255, 0.08); --t-line-2: rgba(255, 255, 255, 0.14);
  --t-ink: #ece9e3; --t-mute: #a09c94; --t-faint: #74716b;
  --t-pass: #34d399; --t-fail: #f97343; --t-none: #6b6863; --t-run: #e8f3ff; --t-flaky: #fbbf24;
  padding-block: clamp(48px, 7vw, 88px) clamp(32px, 5vw, 56px);
  scroll-margin-top: 80px;
}
.t-run-head { display: flex; flex-wrap: wrap; align-items: end; justify-content: space-between; gap: 18px 32px; }
.t-kicker { color: var(--accent); }
.t-run h2 { margin-top: 6px; font: 650 clamp(1.7rem, 3.6vw, 2.6rem)/1.08 var(--font-display); letter-spacing: -0.03em; text-wrap: balance; }
.t-sub { margin-top: 12px; max-width: 64ch; color: var(--mute); }
.t-controls { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.t-btn, .t-speed button, .t-copy { font: 500 0.85rem var(--font-mono); cursor: pointer; border-radius: 999px; border: 1px solid var(--line-strong); background: var(--card); color: var(--ink); padding: 8px 14px; }
.t-btn:not(.ghost) { background: var(--ink); color: var(--paper); border-color: var(--ink); min-width: 92px; }
.t-btn:hover, .t-speed button:hover { border-color: var(--accent); }
.t-speed { display: inline-flex; padding: 3px; border: 1px solid var(--line-strong); border-radius: 999px; background: var(--card); }
.t-speed button { border: 0; padding: 5px 10px; background: none; color: var(--mute); }
.t-speed button[aria-checked="true"] { background: var(--ink); color: var(--paper); }

/* The instrument */
.t-console { position: relative; margin-top: 22px; border-radius: 26px; background: radial-gradient(120% 80% at 15% 0%, #131a22, var(--t-bg) 60%); border: 1px solid var(--t-line-2); color: var(--t-ink); overflow: hidden; box-shadow: 0 30px 70px -40px rgba(4, 12, 20, 0.7); }
.t-bar { display: flex; align-items: center; gap: 14px; padding: 12px 18px; border-bottom: 1px solid var(--t-line); font-size: 0.8rem; color: var(--t-mute); }
.t-dots { display: inline-flex; gap: 6px; } .t-dots i { width: 10px; height: 10px; border-radius: 50%; background: rgba(255, 255, 255, 0.14); }
.t-cmd { color: var(--t-ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.t-cmd::before { content: '$ '; color: var(--t-pass); }
.t-clock { margin-left: auto; white-space: nowrap; font-variant-numeric: tabular-nums; }
.t-clock span { color: var(--t-ink); }

.t-grid { display: grid; gap: 14px; padding: 20px 18px 14px; }
.t-bands, .t-cells, .t-change { display: flex; gap: 10px; min-width: 0; }
.t-bands { margin-left: 168px; margin-right: 298px; }
.t-band { flex: 1 1 0; min-width: 0; border-top: 1px solid var(--t-line-2); padding-top: 6px; font: 500 0.66rem var(--font-mono); letter-spacing: 0.06em; text-transform: uppercase; color: var(--t-faint); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.t-row { display: grid; grid-template-columns: 150px minmax(0, 1fr) 280px; gap: 18px; align-items: center; }
.t-label { display: grid; gap: 3px; }
.t-label b { font: 600 0.98rem/1.2 var(--font-display); letter-spacing: -0.01em; }
.t-label span { font-size: 0.7rem; color: var(--t-faint); }
.t-group { flex: 1 1 0; display: grid; gap: 3px; min-width: 0; }
.t-cells { outline: none; border-radius: 8px; }
.t-cells:focus-visible { box-shadow: 0 0 0 2px var(--t-pass); }

.t-cell { display: block; height: 15px; border-radius: 3px; background: rgba(255, 255, 255, 0.05); box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.05); transition: background-color 0.35s, box-shadow 0.35s, transform 0.35s; cursor: crosshair; }
.t-cell.run { background: rgba(232, 243, 255, 0.22); box-shadow: inset 0 0 0 1px rgba(232, 243, 255, 0.55), 0 0 10px rgba(232, 243, 255, 0.25); animation: t-pulse 0.9s ease-in-out infinite alternate; }
.t-cell.pass { background: var(--t-pass); box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.12); }
.t-cell.fail { background: var(--t-fail); box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.18), 0 0 12px rgba(249, 115, 67, 0.35); }
.t-cell.none { background: repeating-linear-gradient(135deg, var(--t-none) 0 2px, transparent 2px 4px); }
.t-cell.sel { outline: 2px solid #fff; outline-offset: 1px; position: relative; z-index: 1; }
@keyframes t-pulse { to { background: rgba(232, 243, 255, 0.4); } }

/* Each question's change: zero across the middle, the likely range as a bar, the measured change as a dot */
.t-change { height: 92px; }
.t-cols { align-items: stretch; }
.t-col { position: relative; display: block; height: 100%; }
.t-col::before { content: ''; position: absolute; left: 0; right: 0; top: 50%; border-top: 1px dashed var(--t-line-2); }
.t-col-range, .t-col-dot { position: absolute; left: 50%; translate: -50% 0; opacity: 0; transition: opacity 0.4s, top 0.6s var(--ease), bottom 0.6s var(--ease); }
.t-col-range { width: 4px; border-radius: 2px; top: 50%; bottom: 50%; background: var(--t-none); }
.t-col-dot { width: 8px; height: 8px; border-radius: 50%; top: calc(50% - 4px); background: var(--t-ink); }
.t-col.on .t-col-range { opacity: 1; top: calc((1 - var(--hi)) / 2 * 100%); bottom: calc((1 + var(--lo)) / 2 * 100%); }
.t-col.on .t-col-dot { opacity: 1; top: calc((1 - var(--v)) / 2 * 100% - 4px); }
.t-col.worse .t-col-range { background: var(--t-fail); box-shadow: 0 0 10px rgba(249, 115, 67, 0.45); }
.t-col.worse .t-col-dot { background: #ffd4c2; }
.t-col.better .t-col-range { background: var(--t-pass); }

/* Live tiles beside each strip */
.t-tilegrid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; }
.t-tile { display: grid; align-content: start; gap: 2px; padding: 7px 9px; border-radius: 10px; background: rgba(255, 255, 255, 0.035); border: 1px solid var(--t-line); min-width: 0; }
.t-v { font: 600 0.98rem/1.15 var(--font-mono); font-variant-numeric: tabular-nums; color: var(--t-ink); white-space: nowrap; }
.t-l { font: 400 0.64rem/1.35 var(--font-mono); color: var(--t-mute); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.t-ci { position: relative; height: 4px; margin-top: 4px; border-radius: 2px; background: rgba(255, 255, 255, 0.08); }
.t-ci-range { position: absolute; top: 0; bottom: 0; left: calc(var(--lo, 0) * 100%); right: calc((1 - var(--hi, 1)) * 100%); border-radius: 2px; background: var(--t-pass); opacity: 0.55; transition: left 0.4s var(--ease), right 0.4s var(--ease); }
.t-ci-dot { position: absolute; top: -2px; width: 3px; height: 8px; border-radius: 1px; left: calc(var(--v, 0) * 100% - 1.5px); background: #fff; transition: left 0.4s var(--ease); }
.t-split { position: relative; height: 4px; margin-top: 4px; border-radius: 2px; overflow: hidden; display: flex; background: rgba(255, 255, 255, 0.08); }
.t-split .a { width: calc(var(--a, 0) * 100%); background: #93c5fd; transition: width 0.4s; }
.t-split .j { flex: 1; background: #c4b5fd; opacity: 0.75; }
.t-tile.overall { grid-column: 1 / -1; }
.t-ci.wide { height: 6px; }
.t-ci.wide .t-ci-zero { position: absolute; left: 50%; top: -4px; bottom: -4px; border-left: 1px dashed rgba(255, 255, 255, 0.35); }
.t-tile.overall .t-ci-range { left: calc((1 + var(--lo, 0)) / 2 * 100%); right: calc((1 - var(--hi, 0)) / 2 * 100%); opacity: 0; }
.t-tile.overall .t-ci-dot { left: calc((1 + var(--v, 0)) / 2 * 100% - 1.5px); opacity: 0; }
.t-tile.overall.on .t-ci-range, .t-tile.overall.on .t-ci-dot { opacity: 1; }
.t-tile.overall.worse .t-ci-range { background: var(--t-fail); opacity: 0.85; }
.t-tile.overall.worse .t-v { color: #ffb495; }

.t-legend { display: flex; flex-wrap: wrap; gap: 6px 16px; margin-left: 168px; font-size: 0.68rem; color: var(--t-mute); }
.t-legend span { display: inline-flex; align-items: center; gap: 6px; }
.t-legend i { width: 10px; height: 10px; border-radius: 2px; }
.k-pass i { background: var(--t-pass); } .k-fail i { background: var(--t-fail); } .k-run i { background: rgba(232, 243, 255, 0.4); box-shadow: inset 0 0 0 1px rgba(232, 243, 255, 0.7); }
.k-worse i { width: 4px; height: 12px; background: var(--t-fail); } .k-same i { width: 4px; height: 12px; background: var(--t-none); }

/* The log and the inspector */
.t-lower { display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); border-top: 1px solid var(--t-line); }
.t-log { padding: 14px 18px; min-height: 222px; font-size: 0.72rem; line-height: 1.75; color: var(--t-mute); border-right: 1px solid var(--t-line); overflow: hidden; }
.t-line { display: flex; gap: 10px; white-space: nowrap; animation: t-in 0.35s var(--ease) both; }
.t-line > span { flex: none; } .t-line .t-why, .t-line .t-tk { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; } .t-line .t-why { color: #ffb495; }
.t-ts { color: var(--t-faint); font-variant-numeric: tabular-nums; }
.t-line.ok .t-mark { color: var(--t-pass); } .t-line.bad .t-mark { color: var(--t-fail); }
.t-who { color: var(--t-ink); width: 7ch; } .t-id { color: var(--t-ink); width: 23ch; overflow: hidden; text-overflow: ellipsis; }
.t-ms, .t-tk, .t-usd { font-variant-numeric: tabular-nums; } .t-tk { color: var(--t-faint); }
@keyframes t-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.t-inspect { padding: 14px 18px 18px; display: grid; align-content: start; gap: 8px; font-size: 0.86rem; max-height: 380px; overflow: auto; }
.t-ins-k { font-size: 0.68rem; letter-spacing: 0.06em; text-transform: uppercase; color: var(--t-faint); }
.t-ins-empty { color: var(--t-mute); }
.t-ins-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px 10px; }
.t-ins-head b { font: 600 1rem var(--font-mono); }
.t-ins-head .mono { font-size: 0.72rem; color: var(--t-mute); }
.t-badge { padding: 2px 8px; border-radius: 999px; font: 600 0.66rem var(--font-mono); text-transform: uppercase; letter-spacing: 0.05em; }
.t-badge.pass { background: rgba(52, 211, 153, 0.16); color: var(--t-pass); } .t-badge.fail { background: rgba(249, 115, 67, 0.16); color: #ffb495; } .t-badge.none { background: rgba(255, 255, 255, 0.08); color: var(--t-mute); }
.t-ins-q, .t-ins-a { display: grid; gap: 3px; line-height: 1.5; }
.t-ins-q .mono, .t-ins-a .mono { font-size: 0.64rem; letter-spacing: 0.06em; text-transform: uppercase; color: var(--t-faint); }
.t-ins-q { color: var(--t-mute); }
.t-ins-g { list-style: none; padding: 0; display: grid; gap: 6px; }
.t-ins-g li { display: grid; grid-template-columns: 16px minmax(0, 1fr); gap: 1px 8px; padding: 7px 9px; border-radius: 8px; background: rgba(255, 255, 255, 0.035); }
.t-ins-g .t-gm { grid-row: span 2; font-weight: 700; } .t-ins-g li.pass .t-gm { color: var(--t-pass); } .t-ins-g li.fail .t-gm { color: var(--t-fail); }
.t-ins-g b { font-weight: 500; font-size: 0.8rem; } .t-gr { color: var(--t-mute); font-size: 0.78rem; line-height: 1.45; }
.t-ins-m { font-size: 0.7rem; color: var(--t-faint); }

/* The call */
.t-call { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 18px 24px; align-items: center; padding: 20px 22px; border-top: 1px solid rgba(249, 115, 67, 0.35); background: linear-gradient(90deg, rgba(249, 115, 67, 0.14), transparent 70%); animation: t-in 0.6s var(--ease) both; }
.t-call-mark { font: 700 clamp(2rem, 5vw, 3.2rem)/1 var(--font-display); letter-spacing: -0.03em; padding: 6px 18px 10px; border-radius: 14px; border: 2px solid currentColor; }
.t-call-mark.hold { color: var(--t-fail); } .t-call-mark.ship { color: var(--t-pass); }
.t-call-verdict { font-weight: 600; line-height: 1.45; } .t-call-more { margin-top: 4px; color: var(--t-mute); font-size: 0.9rem; }
.t-call-link { margin-top: 12px; color: var(--t-ink); border-color: var(--t-line-2); }
.t-fail { padding: 22px; color: var(--t-mute); }

.t-note { margin-top: 14px; color: var(--faint); font-size: 0.74rem; line-height: 1.6; }
.t-note code { color: var(--ink); background: var(--accent-soft); padding: 2px 6px; border-radius: 6px; }
.t-copy { padding: 3px 10px; margin-left: 4px; font-size: 0.72rem; }

/* The story's two prompts */
.t-diff { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin-block: 6px 16px; }
.t-diff-col { display: grid; align-content: start; gap: 10px; padding: 16px 18px; border-radius: 14px; background: var(--card); border: 1px solid var(--line); }
.t-diff-k { font-size: 0.72rem; color: var(--faint); }
.t-diff mark { color: inherit; padding: 1px 3px; border-radius: 4px; -webkit-box-decoration-break: clone; box-decoration-break: clone; }
.t-diff mark.keep { background: var(--go-soft); } .t-diff mark.cut { background: color-mix(in srgb, var(--accent) 16%, transparent); }
.t-files a { color: inherit; text-decoration: none; } .t-files a:hover b { color: var(--accent); }
.prose code, .cs-feats code { font: 0.88em var(--font-mono); padding: 1px 5px; border-radius: 5px; background: var(--accent-soft); }

@media (max-width: 1060px) {
  .t-row { grid-template-columns: minmax(0, 1fr); gap: 8px; }
  .t-label { grid-template-columns: auto auto; justify-content: start; align-items: baseline; gap: 10px; }
  .t-bands, .t-legend { margin-left: 0; margin-right: 0; }
  .t-tilegrid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .t-tile.overall { grid-column: auto; }
  .t-change-row .t-tilegrid { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 760px) {
  .t-lower { grid-template-columns: minmax(0, 1fr); }
  .t-log { border-right: 0; border-bottom: 1px solid var(--t-line); min-height: 0; max-height: 200px; }
  .t-log .t-tk, .t-log .t-why { display: none; }
  .t-diff { grid-template-columns: minmax(0, 1fr); }
  .t-call { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 560px) {
  .t-grid { padding: 14px 10px 12px; }
  .t-bands, .t-cells, .t-change { gap: 4px; }
  .t-group { gap: 2px; }
  .t-cell { height: 11px; border-radius: 2px; }
  .t-band { font-size: 0.5rem; letter-spacing: 0; }
  .t-tilegrid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .t-change { height: 74px; }
  .t-log .t-ms, .t-log .t-usd { display: none; }
  .t-clock { font-size: 0.7rem; } .t-cmd { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  .t-cell, .t-col-range, .t-col-dot, .t-ci-range, .t-ci-dot, .t-split .a { transition: none; }
  .t-cell.run { animation: none; } .t-line, .t-call { animation: none; }
}
.t-read { margin-top: 18px; display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px 14px; font-size: 0.8rem; color: var(--faint); }
.t-read a { color: var(--ink); text-decoration: none; border-bottom: 1px solid var(--line-strong); }
.t-read a:hover { color: var(--accent); border-color: var(--accent); }
.chapter .cs-feats { margin-top: 16px; }
