@font-face { font-family: "Metropolis"; src: url("fonts/Metropolis-Regular.schematic.woff2") format("woff2"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Metropolis"; src: url("fonts/Metropolis-Bold.schematic.woff2") format("woff2"); font-weight: 600 700; font-display: swap; }

:root {
  color-scheme: light dark;
  --page: light-dark(#fbfbfd, #161617);
  --ink: light-dark(#1d1d1f, #f5f5f7);
  --secondary: light-dark(#6e6e73, #98989d);
  --tertiary: light-dark(#a1a1a6, #636366);
  --hairline: light-dark(rgba(0, 0, 0, 0.08), rgba(255, 255, 255, 0.1));
  --fill: light-dark(rgba(120, 120, 128, 0.1), rgba(120, 120, 128, 0.24));
  --fill-strong: light-dark(rgba(120, 120, 128, 0.16), rgba(120, 120, 128, 0.34));
  --thumb: light-dark(#fff, #636366);
  --glass: light-dark(rgba(255, 255, 255, 0.76), rgba(40, 40, 42, 0.72));
  --field: light-dark(rgba(255, 255, 255, 0.9), rgba(255, 255, 255, 0.07));
  --blue: light-dark(#0071e3, #2997ff);
  --blue-fill: light-dark(rgba(0, 113, 227, 0.09), rgba(41, 151, 255, 0.16));
  --red: light-dark(#d70015, #ff6961);
  --orange: light-dark(#b25000, #ffb340);
  --green: light-dark(#248a3d, #30db5b);
  --grid-dot: light-dark(rgba(0, 0, 0, 0.16), rgba(255, 255, 255, 0.14));
  --panel-shadow: light-dark(0 0 0 0.5px rgba(0, 0, 0, 0.06), 0 0 0 0.5px rgba(255, 255, 255, 0.08)), light-dark(0 12px 40px rgba(0, 0, 0, 0.1), 0 12px 40px rgba(0, 0, 0, 0.5));
  --spring: cubic-bezier(0.32, 0.72, 0, 1);
  --sans: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Helvetica Neue", "Metropolis", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, monospace;
  --s1: light-dark(#2a78d6, #3987e5);
  --s2: light-dark(#eb6834, #d95926);
  --s3: light-dark(#1baf7a, #199e70);
  --s4: light-dark(#eda100, #c98500);
  --s5: light-dark(#e87ba4, #d55181);
  --s6: #008300;
  --s7: light-dark(#6250d6, #9085e9);
  --s8: light-dark(#e34948, #e66767);
}
:root[data-theme="light"] { color-scheme: light; }
:root[data-theme="dark"] { color-scheme: dark; }

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--page);
  color: var(--ink);
  font: 400 13px/1.4 var(--sans);
  letter-spacing: -0.006em;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow: hidden;
}
button, input, select, textarea { font: inherit; letter-spacing: inherit; color: inherit; }
button { cursor: default; }
a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }
kbd { font: 500 11px/1 var(--sans); color: inherit; opacity: 0.72; }
[hidden] { display: none !important; }
:focus-visible { outline: 3px solid color-mix(in srgb, var(--blue) 45%, transparent); outline-offset: 1px; }

#stage { position: fixed; inset: 0; }

/* ---- Sheet ---- */
#sheet { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; user-select: none; -webkit-user-select: none; cursor: default; }
#sheet[data-tool="wire"], #sheet[data-tool="rail"], #sheet[data-tool="note"], #sheet[data-tool="place"], #sheet[data-tool="label"] { cursor: crosshair; }
#sheet[data-tool="text"] { cursor: text; }
#sheet[data-hover="pin"] { cursor: crosshair; }
#sheet[data-space] { cursor: grab; }
#sheet[data-panning] { cursor: grabbing; }
.grid-dot { fill: var(--grid-dot); }
.schematic { color: var(--ink); }
.schematic text { font-family: "Metropolis", -apple-system, "Helvetica Neue", Arial, sans-serif; fill: currentColor; stroke: none; }
.ref { font-size: 15px; font-weight: 700; font-style: italic; }
.value { font-size: 10.5px; font-weight: 400; fill: var(--secondary) !important; font-style: normal; }
.net-name { font-size: 12px; fill: var(--blue) !important; }
.is-hidden .net-name { opacity: 0.55; font-weight: 400; }
.block-pin { font-size: 8px; font-weight: 400; fill: var(--secondary) !important; }
.note-text { font-size: 14px; }
.part .hit { fill: transparent; stroke: none; }
.wire-hit { fill: none; stroke: transparent; stroke-width: 12; }
.wire-line { transition: color 120ms; }
.wire:hover .wire-line { stroke: var(--blue); }
.part:hover > g:first-child { color: color-mix(in srgb, var(--ink) 82%, var(--blue)); }
.part-label { cursor: move; }
.drawing-only { opacity: 0.55; }
.select-box { fill: var(--blue-fill); stroke: var(--blue); stroke-width: 1; vector-effect: non-scaling-stroke; }
.select-wire { fill: none; stroke: var(--blue); stroke-width: 2.4; }
.select-point { fill: var(--blue-fill); stroke: var(--blue); stroke-width: 1; vector-effect: non-scaling-stroke; }
.pin-ring { fill: var(--blue-fill); stroke: var(--blue); stroke-width: 1.2; vector-effect: non-scaling-stroke; pointer-events: none; }
.marquee { fill: var(--blue-fill); stroke: var(--blue); stroke-width: 1; vector-effect: non-scaling-stroke; }
.wire-preview { fill: none; stroke: var(--blue); stroke-width: 1.6; stroke-dasharray: 4 3; pointer-events: none; }
.rail-preview { stroke-width: 3.2; }
.ghost { opacity: 0.45; pointer-events: none; color: var(--blue); }
#overlay { pointer-events: none; }
.probe rect { fill: var(--blue); }
.probe text { fill: #fff; font: 600 9px var(--sans); letter-spacing: 0; }
#probes { pointer-events: none; }

/* ---- Glass ---- */
.glass {
  background: var(--glass);
  backdrop-filter: saturate(180%) blur(24px);
  -webkit-backdrop-filter: saturate(180%) blur(24px);
  box-shadow: var(--panel-shadow);
}

/* ---- Top bar ---- */
#bar {
  position: absolute;
  top: 10px;
  left: 10px;
  right: 10px;
  height: 44px;
  border-radius: 14px;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  padding: 0 6px;
  z-index: 4;
}
.bar-group { display: flex; align-items: center; gap: 2px; }
.bar-group:last-child { justify-content: flex-end; }
.wordmark { font-weight: 600; font-size: 13px; letter-spacing: -0.012em; padding: 0 6px 0 2px; }
.divider { width: 1px; height: 18px; background: var(--hairline); margin: 0 6px; }
.icon-button, .text-button, .zoom-readout, .tool {
  border: 0;
  background: transparent;
  border-radius: 8px;
  height: 30px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background-color 160ms var(--spring), opacity 160ms, transform 160ms var(--spring);
}
.icon-button, .tool { width: 32px; }
.icon-button svg, .tool svg { width: 18px; height: 18px; }
.icon-button:hover:not(:disabled), .text-button:hover, .zoom-readout:hover { background: var(--fill); }
.icon-button:active:not(:disabled), .tool:active { transform: scale(0.94); }
.icon-button:disabled { opacity: 0.28; }
.text-button { padding: 0 10px; font-weight: 500; }
.zoom-readout { min-width: 48px; font-variant-numeric: tabular-nums; color: var(--secondary); font-size: 12px; }
.tools { background: var(--fill); border-radius: 10px; padding: 2px; }
.tool { width: 36px; height: 28px; border-radius: 8px; color: var(--secondary); }
.tool:hover { color: var(--ink); }
.tool[aria-pressed="true"] { background: var(--thumb); color: var(--ink); box-shadow: 0 1px 3px rgba(0, 0, 0, 0.14), 0 0 0 0.5px rgba(0, 0, 0, 0.04); }
.badge {
  border: 0;
  border-radius: 999px;
  padding: 3px 10px;
  font-size: 12px;
  font-weight: 500;
  margin-right: 6px;
  background: var(--fill);
  transition: background-color 160ms;
}
.badge[data-level="error"] { color: var(--red); background: color-mix(in srgb, var(--red) 12%, transparent); }
.badge[data-level="warning"] { color: var(--orange); background: color-mix(in srgb, var(--orange) 12%, transparent); }

/* ---- Menu ---- */
.menu {
  position: absolute;
  top: 60px;
  left: 10px;
  width: 240px;
  border-radius: 12px;
  padding: 5px;
  z-index: 6;
  max-height: calc(100dvh - 76px);
  overflow: auto;
  transform-origin: top left;
  animation: pop 220ms var(--spring);
}
@keyframes pop { from { opacity: 0; transform: scale(0.96) translateY(-4px); } }
.menu hr { border: 0; height: 1px; background: var(--hairline); margin: 5px 8px; }
.menu-title { font-size: 11px; font-weight: 600; color: var(--secondary); padding: 6px 10px 3px; }
.menu-item {
  width: 100%;
  border: 0;
  background: transparent;
  border-radius: 7px;
  padding: 5px 10px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  text-align: left;
}
.menu-item:hover, .menu-item:focus-visible { background: var(--blue); color: #fff; outline: none; }

/* ---- Library ---- */
#library {
  position: absolute;
  top: 62px;
  left: 10px;
  bottom: 10px;
  width: 212px;
  border-radius: 14px;
  display: flex;
  flex-direction: column;
  z-index: 3;
  overflow: hidden;
}
.library-head { padding: 8px 8px 6px; }
input[type="search"] {
  width: 100%;
  height: 28px;
  border: 0;
  border-radius: 8px;
  padding: 0 10px;
  background: var(--fill);
  outline-offset: 0;
}
input[type="search"]::placeholder { color: var(--secondary); }
#library-list { overflow-y: auto; padding: 0 8px 10px; flex: 1; scrollbar-width: thin; scrollbar-color: var(--fill-strong) transparent; }
.group summary {
  list-style: none;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 11px;
  font-weight: 600;
  color: var(--secondary);
  padding: 8px 4px 5px;
  border-radius: 6px;
}
.group summary::-webkit-details-marker { display: none; }
.group summary span:first-child::before {
  content: "";
  display: inline-block;
  width: 5px;
  height: 5px;
  margin: 0 7px 2px 2px;
  border-right: 1.4px solid currentColor;
  border-bottom: 1.4px solid currentColor;
  transform: rotate(-45deg);
  transition: transform 220ms var(--spring);
}
.group[open] summary span:first-child::before { transform: rotate(45deg); }
.count { font-weight: 400; color: var(--tertiary); font-variant-numeric: tabular-nums; }
.tiles { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; padding-bottom: 4px; }
.tile {
  border: 0;
  background: transparent;
  border-radius: 9px;
  padding: 5px 1px 4px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
  min-width: 0;
  touch-action: none;
  transition: background-color 160ms, transform 200ms var(--spring);
}
.tile:hover { background: var(--fill); }
.tile:active { transform: scale(0.95); }
.tile.active { background: var(--blue-fill); color: var(--blue); }
.tile-icon { width: 36px; height: 36px; display: block; pointer-events: none; }
.tile-icon svg { width: 100%; height: 100%; display: block; }
.tile-label { font-size: 10.5px; color: var(--secondary); white-space: nowrap; line-height: 1.2; }
.tile.active .tile-label { color: inherit; }
.empty { color: var(--secondary); padding: 20px 8px; text-align: center; }

/* ---- Right panel ---- */
#panel {
  position: absolute;
  top: 62px;
  right: 10px;
  bottom: 10px;
  width: 320px;
  border-radius: 14px;
  display: flex;
  flex-direction: column;
  z-index: 3;
  overflow: hidden;
}
.segmented {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
  background: var(--fill);
  border-radius: 9px;
  padding: 2px;
  gap: 0;
  font-size: 12px;
}
.segmented button {
  border: 0;
  background: transparent;
  border-radius: 7px;
  height: 26px;
  padding: 0 10px;
  font-weight: 500;
  color: var(--secondary);
  white-space: nowrap;
  transition: color 160ms, background-color 200ms var(--spring), box-shadow 200ms;
}
.segmented button:hover { color: var(--ink); }
.segmented button[aria-selected="true"], .segmented button[aria-checked="true"], .segmented button[aria-pressed="true"] {
  background: var(--thumb);
  color: var(--ink);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.14), 0 0 0 0.5px rgba(0, 0, 0, 0.04);
}
.segmented.small { font-size: 11.5px; }
.segmented.small button { height: 22px; padding: 0 9px; }
.tabs { margin: 8px; flex: none; }
#panel-body { flex: 1; overflow-y: auto; padding: 0 12px 12px; display: flex; flex-direction: column; gap: 14px; scrollbar-width: thin; scrollbar-color: var(--fill-strong) transparent; }
#panel-body[data-tab="netlist"] { overflow-y: auto; padding-bottom: 10px; gap: 8px; }
.section { display: flex; flex-direction: column; gap: 8px; }
h2 { font-size: 15px; font-weight: 600; letter-spacing: -0.016em; margin: 2px 0 0; }
h3 { font-size: 11px; font-weight: 600; color: var(--secondary); margin: 0; }
p { margin: 0; }
.muted { color: var(--secondary); font-size: 12px; }
.lead { margin-top: 2px; }
.fine { font-size: 11px; text-align: center; }
code { font: 500 11px var(--mono); }
.form { display: flex; flex-direction: column; gap: 5px; }
.field { display: grid; grid-template-columns: 84px 1fr; align-items: center; gap: 8px; min-height: 28px; }
.field-label { color: var(--secondary); font-size: 12px; }
.field-below { margin: 5px 0 0 92px; }
.field-below input { font-family: var(--mono); font-size: 11.5px; }
input[type="text"], select {
  width: 100%;
  height: 28px;
  border: 0;
  border-radius: 7px;
  padding: 0 9px;
  background: var(--field);
  box-shadow: inset 0 0 0 0.5px var(--hairline);
  font-size: 12.5px;
  min-width: 0;
  transition: box-shadow 160ms;
}
select { appearance: none; -webkit-appearance: none; padding-right: 22px; background-image: linear-gradient(45deg, transparent 50%, var(--secondary) 50%), linear-gradient(135deg, var(--secondary) 50%, transparent 50%); background-position: calc(100% - 13px) 12px, calc(100% - 9px) 12px; background-size: 4px 4px; background-repeat: no-repeat; }
input[type="text"]:focus, select:focus { outline: none; box-shadow: inset 0 0 0 0.5px var(--blue), 0 0 0 3px color-mix(in srgb, var(--blue) 25%, transparent); }
.with-unit { position: relative; display: flex; align-items: center; }
.with-unit input { padding-right: 34px; font-variant-numeric: tabular-nums; }
.unit { position: absolute; right: 9px; color: var(--tertiary); font-size: 11.5px; pointer-events: none; }
.readout { font-size: 12.5px; font-family: var(--mono); }
.actions { display: flex; gap: 6px; justify-content: flex-end; flex-wrap: wrap; }
.ghost-button, .primary {
  border: 0;
  border-radius: 8px;
  height: 28px;
  padding: 0 12px;
  font-weight: 500;
  font-size: 12.5px;
  transition: background-color 160ms, transform 200ms var(--spring), opacity 160ms;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
.ghost-button { background: var(--fill); }
.ghost-button:hover { background: var(--fill-strong); }
.ghost-button.small { height: 24px; padding: 0 9px; font-size: 11.5px; }
.ghost-button.danger { color: var(--red); }
.ghost-button[aria-pressed="true"] { background: var(--blue-fill); color: var(--blue); }
.ghost-button:active, .primary:active:not(:disabled) { transform: scale(0.97); }
.primary { background: var(--blue); color: #fff; }
.primary:hover:not(:disabled) { background: color-mix(in srgb, var(--blue) 90%, white); }
.primary:disabled { opacity: 0.4; }
.primary.wide { width: 100%; height: 34px; font-size: 13px; }
.run-row { gap: 6px; margin-top: auto; padding-top: 4px; }
.connections { display: grid; grid-template-columns: auto 1fr; gap: 3px 12px; margin: 0; font-size: 12px; }
.connections dt { color: var(--secondary); }
.connections dd { margin: 0; font-family: var(--mono); font-size: 11.5px; text-align: right; overflow-wrap: anywhere; }
.toggle { display: flex; justify-content: space-between; align-items: center; min-height: 26px; }
input[role="switch"] {
  appearance: none;
  -webkit-appearance: none;
  width: 32px;
  height: 20px;
  margin: 0;
  border-radius: 999px;
  background: var(--fill-strong);
  position: relative;
  transition: background-color 220ms var(--spring);
}
input[role="switch"]::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.26);
  transition: transform 260ms var(--spring);
}
input[role="switch"]:checked { background: #34c759; }
input[role="switch"]:checked::after { transform: translateX(12px); }

.issues { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }
.issues li { display: grid; grid-template-columns: 16px 1fr; gap: 8px; font-size: 12px; padding: 5px 6px; margin: 0 -6px; border-radius: 7px; }
.issues li[role="button"]:hover { background: var(--fill); }
.issue-mark { width: 16px; height: 16px; border-radius: 50%; display: grid; place-items: center; font-size: 10px; font-weight: 700; color: #fff; background: var(--secondary); margin-top: 1px; }
li[data-level="error"] .issue-mark { background: var(--red); }
li[data-level="warning"] .issue-mark { background: var(--orange); }
.issues.compact { max-height: 84px; overflow: auto; flex: none; }
.all-clear { color: var(--green); font-size: 12px; }

/* ---- Netlist ---- */
.netlist-head { display: flex; flex: none; }
.netlist-head .segmented { width: 100%; }
.code-wrap { position: relative; flex: 1; min-height: 120px; border-radius: 9px; background: var(--field); box-shadow: inset 0 0 0 0.5px var(--hairline); overflow: hidden; }
.code {
  font: 400 11.5px/1.6 var(--mono);
  letter-spacing: 0;
  tab-size: 4;
  white-space: pre;
  margin: 0;
  padding: 10px 11px;
  border: 0;
  width: 100%;
}
.code-wrap .code { position: absolute; inset: 0; height: 100%; overflow: auto; background: transparent; color: var(--ink); caret-color: var(--ink); resize: none; outline: none; }
.models-editor { flex: none; display: flex; flex-direction: column; gap: 6px; }
.models-editor p { margin: 0; }
.models-editor textarea { min-height: 90px; }
.code.small { width: 100%; border-radius: 8px; background: var(--field); box-shadow: inset 0 0 0 0.5px var(--hairline); resize: vertical; white-space: pre; outline: none; }
.code.small:focus { box-shadow: inset 0 0 0 0.5px var(--blue), 0 0 0 3px color-mix(in srgb, var(--blue) 25%, transparent); }
.code-wrap:focus-within { box-shadow: inset 0 0 0 0.5px var(--blue), 0 0 0 3px color-mix(in srgb, var(--blue) 25%, transparent); }

/* ---- Results ---- */
#results {
  position: absolute;
  left: 230px;
  right: 338px;
  bottom: 10px;
  height: min(44dvh, 380px);
  border-radius: 14px;
  z-index: 2;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: rise 420ms var(--spring);
}
@keyframes rise { from { transform: translateY(24px); opacity: 0; } }
#results-head { display: flex; align-items: center; gap: 8px; padding: 8px 8px 6px 10px; flex: none; }
#results-head .spacer { flex: 1; }
#results-body { flex: 1; min-height: 0; overflow: auto; padding: 0 12px 10px; }
.stale { font-size: 11.5px; color: var(--orange); }
.plot-actions { display: flex; gap: 4px; }
.run-warnings { position: relative; font-size: 11.5px; color: var(--orange); }
.run-warnings summary { cursor: default; list-style: none; }
.run-warnings summary::-webkit-details-marker { display: none; }
.run-warnings pre { position: absolute; right: 0; top: 22px; width: 420px; max-height: 200px; overflow: auto; background: var(--glass); backdrop-filter: blur(24px); -webkit-backdrop-filter: blur(24px); box-shadow: var(--panel-shadow); padding: 10px; border-radius: 10px; color: var(--ink); z-index: 2; font: 11px/1.5 var(--mono); white-space: pre-wrap; margin: 0; }
.plot-layout { display: grid; grid-template-columns: 124px 1fr; gap: 10px; height: 100%; min-height: 150px; }
.plot-side { overflow-y: auto; display: flex; flex-direction: column; gap: 10px; }
.legend { display: flex; flex-direction: column; gap: 1px; }
.trace-chip { border: 0; background: transparent; display: flex; align-items: center; gap: 7px; padding: 3px 6px; border-radius: 6px; font-size: 11.5px; text-align: left; overflow: hidden; white-space: nowrap; color: var(--ink); font-family: var(--mono); letter-spacing: -0.02em; }
.trace-chip:hover { background: var(--fill); }
.trace-chip[aria-pressed="false"] { color: var(--tertiary); }
.trace-chip:disabled { opacity: 0.5; }
.key { width: 12px; height: 2.5px; border-radius: 2px; background: var(--fill-strong); flex: none; }
.stat { display: flex; flex-direction: column; font-size: 11px; color: var(--secondary); padding: 0 6px; }
.stat strong { font-size: 17px; color: var(--ink); font-weight: 600; letter-spacing: -0.02em; }
.plot-area { position: relative; min-width: 0; outline-offset: 0; border-radius: 8px; }
.plot-area.table-view { overflow: auto; }
.chart { display: block; }
.chart .grid { stroke: var(--hairline); stroke-width: 1; }
.chart .grid.vertical { stroke-dasharray: 1 3; }
.chart .grid.zero { stroke: var(--tertiary); }
.axis-text { font: 10px var(--sans); fill: var(--secondary); font-variant-numeric: tabular-nums; }
.chart-title { font: 600 11px var(--sans); fill: var(--secondary); }
.end-label { font: 500 10px var(--mono); fill: var(--ink); letter-spacing: -0.02em; }
.cursor { stroke: var(--secondary); stroke-width: 1; }
.cursor-dot { stroke: var(--page); stroke-width: 2; }
.plot-tip { position: absolute; z-index: 3; pointer-events: none; padding: 7px 10px; border-radius: 10px; background: var(--glass); backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px); box-shadow: var(--panel-shadow); font-size: 11.5px; min-width: 120px; }
.tip-head { color: var(--secondary); font-size: 11px; margin-bottom: 3px; font-variant-numeric: tabular-nums; }
.tip-row { display: grid; grid-template-columns: 12px auto 1fr; gap: 6px; align-items: center; white-space: nowrap; }
.tip-row strong { font-weight: 600; font-variant-numeric: tabular-nums; }
.tip-row span:last-child { color: var(--secondary); font-family: var(--mono); font-size: 10.5px; }
.tip-key { width: 10px; height: 2.5px; border-radius: 2px; }
.op-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 16px 24px; align-items: start; }
.op-block.wide { grid-column: 1 / -1; }
.op-block h3 { margin-bottom: 6px; }
.op-block table, .data-table { width: 100%; border-collapse: collapse; font-size: 12px; font-variant-numeric: tabular-nums; }
.op-block th, .data-table th { text-align: left; font-weight: 400; color: var(--secondary); font-family: var(--mono); font-size: 11.5px; }
.op-block thead th, .data-table thead th { font-size: 11px; font-weight: 600; font-family: var(--sans); text-align: right; padding-bottom: 3px; }
.op-block td, .data-table td { text-align: right; padding: 2.5px 0 2.5px 12px; white-space: nowrap; }
.op-block tr + tr th, .op-block tr + tr td { border-top: 0.5px solid var(--hairline); }
.data-table thead th:first-child { text-align: left; }
.data-table thead { position: sticky; top: 0; background: var(--glass); }
.data-table th, .data-table td { padding-right: 6px; }
.run-error { max-width: 540px; padding: 12px 6px; display: flex; flex-direction: column; gap: 6px; }
.run-error h3 { color: var(--red); font-size: 13px; }
.run-error pre { font: 11px/1.5 var(--mono); white-space: pre-wrap; color: var(--secondary); margin: 6px 0 0; max-height: 120px; overflow: auto; }
.run-error summary { color: var(--secondary); font-size: 12px; }

/* ---- Hint & toast ---- */
#hint {
  position: absolute;
  left: 50%;
  top: 62px;
  transform: translate(-50%, -6px);
  padding: 5px 12px;
  border-radius: 999px;
  font-size: 12px;
  color: var(--secondary);
  opacity: 0;
  pointer-events: none;
  transition: opacity 220ms, transform 320ms var(--spring);
  z-index: 3;
  white-space: nowrap;
}
#hint[data-show="true"] { opacity: 1; transform: translate(-50%, 0); }
#toast {
  position: absolute;
  bottom: 24px;
  left: 50%;
  transform: translate(-50%, 12px);
  max-width: min(560px, 80vw);
  padding: 8px 16px;
  border-radius: 999px;
  background: light-dark(rgba(29, 29, 31, 0.92), rgba(245, 245, 247, 0.94));
  color: light-dark(#fff, #1d1d1f);
  font-size: 12.5px;
  font-weight: 500;
  opacity: 0;
  pointer-events: none;
  transition: opacity 220ms, transform 360ms var(--spring);
  z-index: 8;
  text-align: center;
}
#toast[data-show="true"] { opacity: 1; transform: translate(-50%, 0); }
#toast[data-level="error"] { background: var(--red); color: #fff; }

/* ---- Dialogs ---- */
.sheet-dialog {
  border: 0;
  border-radius: 16px;
  padding: 20px;
  width: min(420px, 92vw);
  background: var(--glass);
  backdrop-filter: saturate(180%) blur(30px);
  -webkit-backdrop-filter: saturate(180%) blur(30px);
  box-shadow: var(--panel-shadow);
  color: var(--ink);
  animation: pop 280ms var(--spring);
}
.sheet-dialog::backdrop { background: rgba(0, 0, 0, 0.2); }
.sheet-dialog h2 { margin-bottom: 12px; font-size: 17px; }
.sheet-dialog p { margin-bottom: 10px; font-size: 13px; line-height: 1.5; }
.keys { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; margin: 0 0 14px; }
.keys dt { color: var(--secondary); white-space: nowrap; }
.keys dd { margin: 0; }
.keys kbd { background: var(--fill); border-radius: 5px; padding: 2px 6px; opacity: 1; display: inline-block; }

@media (max-width: 860px) {
  .wordmark, #zoom-level { display: none; }
  #panel { width: 280px; }
  #results { left: 10px; right: 10px; z-index: 5; }
  #library { width: 168px; }
  .tiles { grid-template-columns: repeat(2, 1fr); }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 1ms !important; transition-duration: 1ms !important; }
}
@media (forced-colors: active) {
  .glass { border: 1px solid CanvasText; }
}
