:root {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: #222725;
  background: #fff;
  font-synthesis: none;
  --muted: #69706c;
  --line: #e3e6e4;
  --accent: #276348;
  --mono: ui-monospace, "SFMono-Regular", Consolas, monospace;
}

* { box-sizing: border-box; }
body { margin: 0; }
main { max-width: 840px; margin: 0 auto; padding: 32px 24px 24px; }
h1, h2, p { margin: 0; }
h1 { font-size: 20px; font-weight: 650; letter-spacing: -.4px; }
h2 { font-size: 14px; font-weight: 600; }
.header { display: flex; align-items: baseline; gap: 12px; margin-bottom: 28px; }
.header p { color: var(--muted); font-size: 13px; }
button, select, input { font: inherit; }
button, select { color: inherit; background: #fff; border: 1px solid #d7dcd9; border-radius: 5px; font-size: 13px; }
select { width: 100%; min-height: 36px; padding: 6px 8px; }
button { min-height: 36px; padding: 6px 14px; cursor: pointer; }
button:hover { background: #f4f6f5; }
button:disabled { color: #9da39f; background: #fafbfa; cursor: default; }
button.primary { min-width: 70px; background: #2b3530; border-color: #2b3530; color: #fff; }
button.primary:hover { background: #414c45; }
:is(button, select, input, summary, .table-wrap):focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.input-bar { display: grid; grid-template-columns: 56px minmax(0, 1fr) 118px auto; gap: 14px; align-items: center; padding-bottom: 22px; border-bottom: 1px solid var(--line); }
#digit { width: 56px; height: 56px; image-rendering: pixelated; border-radius: 3px; }
.field { min-width: 0; }
.field label { display: block; color: var(--muted); font-size: 12px; margin-bottom: 6px; }
.prediction { display: flex; gap: 18px; padding-left: 8px; align-items: center; }
.prediction span { font-size: 12px; color: var(--muted); }
.prediction strong { display: block; font-size: 21px; font-weight: 600; color: #222725; margin-top: 4px; font-variant-numeric: tabular-nums; }
.batch-detail { grid-column: 2 / -1; color: var(--muted); font-size: 12px; line-height: 1.5; }
.batch-detail:empty { display: none; }
.trace { padding-top: 22px; }
.trace-heading { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; margin-bottom: 18px; }
.trace-meta { display: flex; gap: 14px; font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.array-direction { display: flex; justify-content: space-between; color: var(--muted); font-size: 11px; margin-bottom: 8px; }
.array { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; }
.pe { padding: 10px 12px; min-height: 83px; background: #fafbfa; border: 1px solid var(--line); border-radius: 4px; font-family: var(--mono); }
.pe.active { background: #edf5ef; border-color: #aac9b5; }
.pe.padded { background: #f3f3f3; border-color: #d2d6d3; border-style: dashed; }
.pe-id { display: flex; justify-content: space-between; gap: 2px; color: var(--muted); font-size: 10px; }
.pe.active .pe-id { color: var(--accent); }
.pe-acc { font-size: clamp(15px, 2.3vw, 22px); font-weight: 550; letter-spacing: -.6px; line-height: 1.6; font-variant-numeric: tabular-nums; }
.pe-operands { color: var(--muted); font-size: 11px; white-space: nowrap; }
.legend { display: flex; gap: 16px; color: var(--muted); font-size: 11px; margin: 12px 0 20px; }
.legend span { display: inline-flex; align-items: center; gap: 5px; }
.legend i { width: 8px; height: 8px; border: 1px solid var(--line); border-radius: 1px; }
.legend .useful { background: #edf5ef; border-color: #aac9b5; }
.legend .padding { background: #f3f3f3; border-color: #a8ada9; border-style: dashed; }
.legend .idle { background: #fafbfa; }
input[type="range"] { display: block; width: 100%; height: 24px; margin: 0 0 10px; accent-color: var(--accent); cursor: pointer; }
.playback, .playback-buttons, .speed-label { display: flex; align-items: center; gap: 8px; }
.playback { justify-content: space-between; }
.speed-label { font-size: 12px; color: var(--muted); }
.speed-label select { width: auto; }
.frame-line { display: flex; justify-content: space-between; gap: 12px; margin-top: 14px; font-family: var(--mono); font-size: 11px; color: var(--muted); }
.help { font-size: 12px; color: var(--muted); line-height: 1.6; margin-top: 16px; }
.measurements { margin-top: 24px; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
summary { cursor: pointer; padding: 16px 0; font-size: 13px; font-weight: 500; }
summary::marker { color: var(--muted); }
.metrics { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin: 6px 0 24px; }
.metrics span { display: block; color: var(--muted); font-size: 12px; margin-bottom: 6px; }
.metrics strong { font-size: 20px; font-weight: 550; font-variant-numeric: tabular-nums; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; text-align: right; font-size: 12px; }
caption { text-align: left; color: var(--muted); line-height: 1.6; margin-bottom: 12px; }
th, td { padding: 10px 8px; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { font-weight: 500; line-height: 1.5; }
th small { color: var(--muted); font-size: 11px; font-weight: 400; }
th:first-child, td:first-child { text-align: left; }
td { font-variant-numeric: tabular-nums; }
.notes { display: grid; gap: 10px; margin: 18px 0; font-size: 12px; color: var(--muted); line-height: 1.6; }
.source { font-family: var(--mono); font-size: 10px; overflow-wrap: anywhere; }
footer { padding-top: 16px; color: var(--muted); font-size: 11px; }
.status { padding: 20px 0; font-size: 13px; line-height: 1.6; color: var(--muted); }
.status.error { color: #8b3f31; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
[hidden] { display: none !important; }

@media (max-width: 600px) {
  main { padding: 22px 16px; }
  .header { margin-bottom: 22px; }
  .input-bar { grid-template-columns: 48px minmax(0, 1fr) 100px; gap: 12px; padding-bottom: 18px; }
  #digit { width: 48px; height: 48px; }
  .prediction { grid-column: 2 / -1; padding: 0; gap: 20px; }
  .prediction span { display: flex; align-items: baseline; gap: 7px; }
  .prediction strong { font-size: 16px; margin: 0; }
  .batch-detail { grid-column: 1 / -1; }
  .trace { padding-top: 18px; }
  .trace-meta { gap: 10px; font-size: 11px; }
  .pe { min-height: 75px; padding: 8px 6px; }
  .pe-id { font-size: 9px; }
  .pe-operands { font-size: 10px; }
  .pe-acc { font-size: clamp(13px, 3.7vw, 18px); }
  .playback { flex-wrap: wrap; }
  .playback-buttons { gap: 6px; }
  .playback-buttons button { padding-inline: 11px; }
  .speed-label { margin-left: auto; gap: 6px; }
  .metrics { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 370px) {
  main { padding-inline: 12px; }
  .header { gap: 8px; }
  .header p { font-size: 12px; }
  .input-bar { grid-template-columns: 40px minmax(0, 1fr) 90px; gap: 8px; }
  #digit { width: 40px; height: 40px; }
  .playback { flex-wrap: wrap; }
  .speed-label { margin-left: auto; }
  .pe-id { font-size: 8px; }
}
