/* Asymptote — a bench instrument for C++ complexity.
 *
 * Everything separates by 1px hairlines and small surface steps. No shadows,
 * no gradients, no border radius above 2px. Two channels carry two fixed hues
 * (time amber, space teal) and those hues are reused everywhere, including the
 * signal rail, so the palette never grows.
 */

:root {
  color-scheme: light dark;

  --bg:        light-dark(#fbfaf7, #0e1013);
  --sunk:      light-dark(#f4f2ec, #121417);
  --raised:    light-dark(#ffffff, #171a1e);
  --rule:      light-dark(#e4e0d6, #23272c);
  --rule-2:    light-dark(#cec9bb, #333940);

  --ink:       light-dark(#16181a, #e7e8e5);
  --ink-2:     light-dark(#4a4d52, #a3a8ad);
  --ink-3:     light-dark(#6b6f76, #868d95);
  --ink-4:     light-dark(#8e9299, #5f666d);

  --time:      light-dark(#9a6510, #e2a44f);
  --time-soft: light-dark(#9a651022, #e2a44f1f);
  --space:     light-dark(#1f6f66, #4fb3a5);
  --space-soft:light-dark(#1f6f6620, #4fb3a51c);
  --alarm:     light-dark(#a83a24, #e0705f);
  --accent:    light-dark(#2f6ab0, #6ea6e0);

  --mono: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  --sans: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;

  --code-size: 13px;
  --code-line: 20px;
  --head-h: 46px;
}

html[data-theme="light"] { color-scheme: only light; }
html[data-theme="dark"]  { color-scheme: only dark; }

*, *::before, *::after { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 400 13px/1.5 var(--sans);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow: hidden;
}

button, select, textarea { font: inherit; color: inherit; }

::selection { background: light-dark(#2f6ab033, #6ea6e033); }

:focus-visible { outline: 1px solid var(--accent); outline-offset: 1px; }

.tabular { font-variant-numeric: tabular-nums; }

/* ------------------------------------------------------------- masthead */

.masthead {
  height: var(--head-h);
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 14px;
  border-bottom: 1px solid var(--rule);
  background: var(--sunk);
}

.brand { display: flex; align-items: baseline; gap: 10px; flex: none; }

.wordmark {
  font: 600 12.5px/1 var(--mono);
  letter-spacing: 0.19em;
  color: var(--ink);
}

.unit-tag {
  font: 400 9.5px/1 var(--mono);
  letter-spacing: 0.14em;
  color: var(--ink-3);
  border: 1px solid var(--rule-2);
  padding: 4px 6px 3px;
}

.meta {
  font: 400 11px/1 var(--mono);
  color: var(--ink-3);
  display: flex;
  gap: 7px;
  align-items: center;
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
}
.meta-sep { color: var(--ink-4); }

.masthead-right { margin-left: auto; display: flex; align-items: center; gap: 12px; flex: none; }

.privacy {
  margin: 0;
  font: 400 10px/1 var(--mono);
  letter-spacing: 0.11em;
  text-transform: uppercase;
  color: var(--ink-2);
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: help;
}
.lamp {
  width: 6px; height: 6px;
  background: var(--space);
  border-radius: 50%;
  flex: none;
}

.seg { display: flex; border: 1px solid var(--rule-2); height: 26px; }
.seg-btn {
  background: none;
  border: 0;
  border-right: 1px solid var(--rule-2);
  padding: 0 10px;
  font: 500 9.5px/1 var(--mono);
  letter-spacing: 0.13em;
  color: var(--ink-3);
  cursor: pointer;
}
.seg-btn:last-child { border-right: 0; }
.seg-btn.is-on { background: var(--raised); color: var(--ink); box-shadow: inset 0 2px 0 var(--accent); }

.icon-btn, .ghost-btn {
  background: none;
  border: 1px solid var(--rule-2);
  height: 26px;
  padding: 0 9px;
  font: 500 9.5px/1 var(--mono);
  letter-spacing: 0.13em;
  color: var(--ink-3);
  cursor: pointer;
}
.icon-btn:hover, .ghost-btn:hover { color: var(--ink); border-color: var(--ink-4); }

/* ----------------------------------------------------------- work area */

.work {
  height: calc(100dvh - var(--head-h));
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) 1px minmax(0, 1fr);
}

.split { background: var(--rule); }

.pane { min-width: 0; min-height: 0; display: flex; flex-direction: column; }

.pane-head {
  height: 32px;
  flex: none;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 10px 0 12px;
  border-bottom: 1px solid var(--rule);
  background: var(--bg);
}
.pane-title {
  font: 500 9.5px/1 var(--mono);
  letter-spacing: 0.16em;
  color: var(--ink-3);
}
.spacer { flex: 1; }

.examples {
  appearance: none;
  background: transparent;
  border: 1px solid var(--rule-2);
  height: 22px;
  padding: 0 20px 0 7px;
  font: 400 10.5px/1 var(--mono);
  color: var(--ink-2);
  cursor: pointer;
  background-image: linear-gradient(45deg, transparent 50%, currentColor 50%),
                    linear-gradient(135deg, currentColor 50%, transparent 50%);
  background-position: calc(100% - 11px) 9px, calc(100% - 7px) 9px;
  background-size: 4px 4px, 4px 4px;
  background-repeat: no-repeat;
}
.ghost-btn { height: 22px; padding: 0 7px; font-size: 9px; }

/* -------------------------------------------------------------- editor */

.ed {
  position: relative;
  flex: 1;
  min-height: 0;
  background: var(--sunk);
  font: 400 var(--code-size)/var(--code-line) var(--mono);
  overflow: hidden;
}

.ed-gutter, .ed-rail, .ed-hl, .ed-input {
  font: inherit;
  tab-size: 4;
  letter-spacing: 0;
}

/* line numbers */
.ed-gutter {
  position: absolute;
  inset: 0 auto 0 0;
  width: 44px;
  padding: 12px 8px 40vh 0;
  text-align: right;
  color: var(--ink-4);
  background: var(--sunk);
  border-right: 1px solid var(--rule);
  overflow: hidden;
  z-index: 3;
  user-select: none;
}
.ed-gutter span { display: block; height: var(--code-line); }
.ed-gutter span.is-marked { color: var(--ink); }

/* two-track signal rail: cost registered against the line that produced it */
.ed-rail {
  position: absolute;
  inset: 0 auto 0 45px;
  width: 14px;
  padding: 12px 0 40vh 0;
  overflow: hidden;
  z-index: 3;
  border-right: 1px solid var(--rule);
  background: var(--sunk);
  pointer-events: none;
}
.ed-rail i {
  position: absolute;
  height: var(--code-line);
  width: 5px;
  display: block;
}
.ed-rail i.t { left: 2px; background: var(--time-soft); border-left: 2px solid var(--time); }
.ed-rail i.s { left: 8px; background: var(--space-soft); border-left: 2px solid var(--space); }
.ed-rail i.on { filter: none; }

.ed-hl, .ed-input {
  position: absolute;
  inset: 0 0 0 60px;
  margin: 0;
  padding: 12px 18px 40vh 10px;
  border: 0;
  white-space: pre;
  overflow: auto;
  word-wrap: normal;
}

.ed-hl { z-index: 1; pointer-events: none; color: var(--ink); }
.ed-input {
  z-index: 2;
  background: transparent;
  color: transparent;
  caret-color: var(--ink);
  resize: none;
  outline: none;
}
.ed-input::selection { background: light-dark(#2f6ab033, #6ea6e044); }

/* syntax colours — kept few, and sharing the channel hues */
.t-kw   { color: light-dark(#8a4f9e, #c191d6); }
.t-type { color: light-dark(#1f6f66, #4fb3a5); }
.t-str  { color: light-dark(#8a5a1d, #d8a35e); }
.t-num  { color: light-dark(#a83a24, #e0705f); }
.t-com  { color: var(--ink-4); font-style: italic; }
.t-pre  { color: var(--ink-3); }
.t-fn   { color: light-dark(#2f6ab0, #6ea6e0); }
.t-ns   { color: var(--ink-3); }
.t-op   { color: var(--ink-2); }

/* -------------------------------------------------------------- report */

.pane-report { position: relative; background: var(--bg); overflow: hidden; }

.boot {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 24px;
  background: var(--bg);
  z-index: 5;
}
.boot.is-gone { display: none; }
.boot-inner { max-width: 330px; }
.boot-bar { height: 1px; background: var(--rule-2); overflow: hidden; }
.boot-bar i { display: block; height: 100%; width: 0; background: var(--accent); transition: width .18s linear; }
.boot-label {
  margin: 12px 0 0;
  font: 400 10.5px/1 var(--mono);
  letter-spacing: 0.13em;
  text-transform: uppercase;
  color: var(--ink-2);
}
.boot-note { margin: 10px 0 0; font-size: 12px; line-height: 1.55; color: var(--ink-3); }

.report { overflow-y: auto; overflow-x: hidden; height: 100%; }

/* two channels, stacked so a long expression gets the full pane width */
.channels { border-bottom: 1px solid var(--rule); }
.chan { padding: 14px 16px 13px; min-width: 0; }
.chan-time { border-bottom: 1px solid var(--rule); }

.chan-label {
  margin: 0 0 10px;
  font: 500 9px/1 var(--mono);
  letter-spacing: 0.17em;
  color: var(--ink-3);
  display: flex;
  align-items: center;
  gap: 6px;
}
.chan-label::before {
  content: "";
  width: 3px; height: 9px;
  flex: none;
}
.chan-time .chan-label::before { background: var(--time); }
.chan-space .chan-label::before { background: var(--space); }

.chan-value {
  font-size: 26px;
  line-height: 1.22;
  min-height: 30px;
  /* app.js shrinks this until the expression fits on one line */
  white-space: nowrap;
  overflow: hidden;
}
.chan-sub {
  margin: 9px 0 0;
  font-size: 11.5px;
  color: var(--ink-2);
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: baseline;
}
.chan-dot { color: var(--ink-4); }
.chan-pattern { color: var(--ink-3); }

/* blocks */
.block { padding: 15px 16px; border-bottom: 1px solid var(--rule); }
.block-title {
  margin: 0 0 12px;
  font: 500 9px/1 var(--mono);
  letter-spacing: 0.17em;
  color: var(--ink-3);
  display: flex;
  align-items: baseline;
  gap: 8px;
  flex-wrap: wrap;
}
.block-hint {
  font-family: var(--sans);
  font-weight: 400;
  font-size: 10.5px;
  letter-spacing: 0;
  text-transform: none;
  color: var(--ink-4);
}

/* growth plate */
.block-plate { padding-bottom: 12px; }
.plate-wrap { margin: 0 -2px; }
.plate { display: block; width: 100%; height: auto; overflow: visible; }
.pl-grid       { stroke: var(--rule); stroke-width: 1; }
.pl-rail       { fill: none; stroke: var(--rule-2); stroke-width: 1; }
.pl-rail.is-self { stroke: var(--ink-4); }
.pl-curve      { fill: none; stroke: var(--accent); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.pl-budget     { stroke: var(--alarm); stroke-width: 1; stroke-dasharray: 3 3; }
.pl-drop       { stroke: var(--accent); stroke-width: 1; stroke-dasharray: 2 3; }
.pl-cross      { fill: var(--bg); stroke: var(--accent); stroke-width: 1.5; }
.pl-curve.is-projected,
.pl-cross.is-projected { stroke-dasharray: 4 3; }
.pl-crosslabel.is-projected { font-weight: 400; }
.pl-tick, .pl-raillabel, .pl-budgetlabel, .pl-crosslabel, .pl-axis {
  font-family: var(--mono);
  font-size: 8.5px;
}
.pl-raillabel { font-size: 8px; }
.pl-tick       { fill: var(--ink-4); }
.pl-raillabel  { fill: var(--ink-4); }
.pl-budgetlabel{ fill: var(--alarm); }
.pl-crosslabel { fill: var(--accent); font-weight: 600; }
.pl-axis       { fill: var(--ink-4); }
.plate-caption { margin: 8px 0 0; font-size: 11px; line-height: 1.5; color: var(--ink-3); }

/* constraints */
.constraints { margin: 0; display: grid; grid-template-columns: auto 1fr; gap: 0; }
.constraints dt,
.constraints dd { padding: 7px 0; border-top: 1px solid var(--rule); margin: 0; min-width: 0; }
.constraints dt:first-of-type, .constraints dt:first-of-type + dd { border-top: 0; }
.constraints dt {
  font: 500 12px/1.35 var(--mono);
  color: var(--ink);
  padding-right: 14px;
  white-space: nowrap;
}
.constraints .val { color: var(--accent); font-variant-numeric: tabular-nums; }
.constraints dd { font-size: 11.5px; line-height: 1.5; color: var(--ink-3); }

/* signals */
.signals { list-style: none; margin: 0; padding: 0; }
.sig {
  display: grid;
  grid-template-columns: 34px 1fr auto;
  gap: 10px;
  align-items: baseline;
  padding: 6px 4px 6px 0;
  border-top: 1px solid var(--rule);
  cursor: pointer;
}
.sig:first-child { border-top: 0; }
.sig:hover { background: var(--sunk); }
.sig-line {
  font: 400 10.5px/1.5 var(--mono);
  color: var(--ink-4);
  text-align: right;
  font-variant-numeric: tabular-nums;
  border-right: 2px solid transparent;
  padding-right: 6px;
}
.sig-time  .sig-line { border-right-color: var(--time); }
.sig-space .sig-line { border-right-color: var(--space); }
.sig-kind { font-size: 12px; line-height: 1.45; color: var(--ink-2); min-width: 0; }
.sig-cost { font-size: 12px; color: var(--ink); white-space: nowrap; }
.sig-none { padding: 6px 0; font-size: 12px; color: var(--ink-3); }

/* notes */
.notes { list-style: none; margin: 0; padding: 0; }
.notes li {
  position: relative;
  padding: 4px 0 4px 15px;
  font-size: 11.5px;
  line-height: 1.55;
  color: var(--ink-3);
}
.notes li::before {
  content: "";
  position: absolute;
  left: 0; top: 11px;
  width: 7px; height: 1px;
  background: var(--ink-4);
}

.colophon { padding: 14px 16px 26px; display: flex; gap: 14px; align-items: flex-start; }
.colophon p { margin: 0; font-size: 11px; line-height: 1.55; color: var(--ink-4); }
.colophon a { color: var(--ink-3); }

/* ------------------------------------------------------------ notation */

.m { font-family: var(--mono); font-variant-ligatures: none; white-space: nowrap; }
.chan-value .m-times { width: .3em; }
.m-O      { font-weight: 500; }
.m-paren  { color: var(--ink-3); }
.m-var    { font-style: italic; }
.m-name   { font-style: normal; }
.m-fn     { font-style: normal; color: var(--ink-2); }
.m-num    { font-style: normal; }
.m-op     { padding: 0 .34em; color: var(--ink-3); }
.m-op-tight { color: var(--ink-3); }
.m-times  { display: inline-block; width: .34em; }
.m-sup    { font-size: .62em; vertical-align: super; line-height: 0; font-style: normal; }
.m-degree { font-size: .55em; vertical-align: super; line-height: 0; margin-right: -.3em; }
.m-root   { white-space: nowrap; }
.m-radical{ color: var(--ink-2); }
.m-radicand { border-top: 1px solid currentColor; padding: 0 .12em 0 .06em; margin-left: -.04em; }

.chan-time  .m-O { color: var(--time); }
.chan-space .m-O { color: var(--space); }

/* --------------------------------------------------------------- toast */

.toast {
  position: fixed;
  left: 50%;
  bottom: 22px;
  transform: translateX(-50%) translateY(6px);
  background: var(--raised);
  border: 1px solid var(--rule-2);
  padding: 8px 14px;
  font: 400 11px/1 var(--mono);
  letter-spacing: 0.06em;
  color: var(--ink);
  opacity: 0;
  pointer-events: none;
  transition: opacity .16s, transform .16s;
  z-index: 20;
}
.toast.is-on { opacity: 1; transform: translateX(-50%) translateY(0); }

/* -------------------------------------------------------------- mobile */

@media (max-width: 820px) {
  body { overflow: auto; }
  .work { grid-template-columns: 1fr; grid-template-rows: minmax(230px, 46vh) 1px auto; height: auto; }
  .split { height: 1px; }
  .pane-report { overflow: visible; }
  .report { height: auto; overflow: visible; }
  .masthead { gap: 10px; padding: 0 10px; }
  .meta, .unit-tag { display: none; }
  .chan-value { font-size: 22px; }
}

@media (max-width: 620px) {
  .masthead { gap: 8px; padding: 0 8px; }
  .masthead-right { gap: 7px; }
  .privacy-text { display: none; }
  .wordmark { font-size: 11px; letter-spacing: 0.14em; }
  .seg-btn, .icon-btn { padding: 0 7px; font-size: 9px; }
  .pane-head { padding: 0 8px; gap: 7px; }
  .examples { max-width: 46vw; }
  .block, .chan { padding-left: 12px; padding-right: 12px; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition-duration: .01ms !important; animation-duration: .01ms !important; }
}
