/* Palette follows notes/numkim2026/slides.tex: red = our method, blue = bases and structure,
   gold = coefficients, ink = text, gray = secondary. */
:root {
  --paper: #ffffff;
  --ink: #202020;
  --gray: #6a6a6a;
  --rule: #dcdcdc;
  --control: #b9b9b9;
  --red: #b8514b;
  --blue: #4a689e;
  --blue-soft: #edf1f7;
  --gold: #8a6114;
  --rose: #b77986;
  --serif: "Latin Modern Roman", "CMU Serif", "STIX Two Text", Cambria, Georgia, serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --code: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }
html, body { background: var(--paper); }
body {
  margin: 0;
  color: var(--ink);
  font: 15px/1.5 var(--sans);
  -webkit-font-smoothing: antialiased;
}

button, select, input, textarea { font: inherit; color: inherit; }
var { font-family: var(--serif); font-style: italic; font-size: 1.08em; }
code { font-family: var(--code); font-size: .9em; }

.masthead, main, footer {
  width: min(1180px, calc(100% - 32px));
  margin-inline: auto;
}

.masthead {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 28px 0 20px;
}
.masthead-qr { flex: none; margin: 0; text-align: center; }
.masthead-qr svg { display: block; width: 132px; height: 132px; }
.masthead-qr figcaption { color: var(--gray); font-size: 12px; }
@media (max-width: 640px) { .masthead-qr { display: none; } }
h1, h2, h3 { font-family: var(--serif); font-weight: 400; margin: 0; }
h1 { font-size: 32px; line-height: 1.15; }
.masthead p { margin: 6px 0 0; color: var(--gray); }

.example-picker {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 0;
  border-block: 1px solid var(--rule);
}
.example-picker label { font-weight: 500; }
.example-picker select { flex: 0 1 340px; min-width: 0; }

select, button, input {
  min-height: 34px;
  padding: 5px 10px;
  border: 1px solid var(--control);
  border-radius: 4px;
  background: var(--paper);
  font-size: 14px;
}
input { width: 100%; font-variant-numeric: tabular-nums; }
select:focus-visible, input:focus-visible, button:focus-visible, summary:focus-visible, a:focus-visible {
  outline: 2px solid var(--blue);
  outline-offset: 2px;
}
button { cursor: pointer; }
button:hover:not(:disabled) { border-color: var(--ink); }
button:disabled { opacity: .4; cursor: default; }
button.primary { color: #fff; background: var(--ink); border-color: var(--ink); }
button.primary:hover:not(:disabled) { background: #3a3a3a; }
button.full { width: 100%; }
input.rank-cap-warning { border-color: var(--red); outline: 2px solid var(--red); outline-offset: 1px; }

.experiment {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 280px;
  gap: 36px;
  padding: 24px 0 32px;
}

.figure-column h2 { font-size: 24px; line-height: 1.2; }
.note { margin: 6px 0 0; color: var(--gray); font-size: 13.5px; }

.figure-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin: 16px 0 8px;
}
.transport-controls { display: flex; gap: 6px; }
.icon-button {
  display: grid;
  place-items: center;
  width: 42px;
  height: 38px;
  padding: 0;
}
.icon-button svg { width: 16px; height: 16px; fill: currentColor; }
.icon-button.reset-icon svg { fill: none; stroke: currentColor; stroke-width: 1.8; }
.timeline-readout {
  display: flex;
  align-items: baseline;
  gap: 18px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.time-readout { font-family: var(--serif); font-size: 18px; }
.time-readout strong { font-weight: 400; }
.step-readout { color: var(--gray); font-size: 13px; }
.step-readout strong { font-weight: 400; color: var(--ink); }

.plot-shell { position: relative; aspect-ratio: 1.6 / 1; min-height: 320px; }
#plot { display: block; width: 100%; height: 100%; }
.plot-loading {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(255, 255, 255, .9);
  color: var(--gray);
  text-align: center;
}
.plot-loading[hidden] { display: none; }

.slice-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 18px;
  padding: 8px 0 14px;
  color: var(--gray);
  font-size: 13.5px;
}
.slice-row label { display: flex; align-items: center; gap: 6px; }
.slice-row select { min-width: 88px; }
#slice-note { margin-left: auto; }

.diagnostics { padding: 16px 0 18px; border-top: 1px solid var(--rule); }
.diagnostics[hidden] { display: none; }
.diagnostics-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.diagnostics-head h3 { font-size: 19px; }
.diagnostics-head button { min-height: 30px; padding: 3px 10px; font-size: 13px; }
.diagnostics-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-top: 10px; }
.diagnostics-grid figure { margin: 0; min-width: 0; }
.diagnostics-grid figure[hidden] { display: none; }
.diagnostics-grid canvas { display: block; width: 100%; aspect-ratio: 1.45 / 1; }
.figures figcaption { margin-bottom: 4px; font-size: 15px; }
.tree-panel { padding-top: 16px; border-top: 1px solid var(--rule); }
.tree-panel h3 { font-size: 19px; }
#tree-plot { display: block; max-width: 100%; height: auto; margin: 10px auto 0; overflow: visible; }
.tree-edge { stroke: var(--blue); stroke-width: 1.6; vector-effect: non-scaling-stroke; }
.tree-core { fill: #fff; stroke: var(--gold); stroke-width: 1.4; vector-effect: non-scaling-stroke; }
.tree-leaf { fill: var(--blue-soft); stroke: var(--blue); stroke-width: 1.4; vector-effect: non-scaling-stroke; }
.tree-symbol { fill: var(--ink); font: italic 17px var(--serif); text-anchor: middle; dominant-baseline: central; }
.tree-symbol .upright { font-style: normal; }
.tree-rank { fill: var(--blue); font: 14px var(--serif); text-anchor: middle; dominant-baseline: central; paint-order: stroke; stroke: #fff; stroke-width: 5px; stroke-linejoin: round; }
.tree-output { margin: 4px 0 0; color: var(--gray); font-size: 13px; overflow-wrap: anywhere; }
.tree-output code { color: var(--ink); }

.control-column { font-size: 14px; }
.control-column dl { margin: 0; }
.run-description div {
  display: grid;
  grid-template-columns: 96px minmax(0, 1fr);
  gap: 8px;
  padding: 7px 0;
  border-bottom: 1px solid var(--rule);
}
.run-description div:first-child { padding-top: 0; }
.run-description dt, .metrics dt { color: var(--gray); }
.run-description dd { margin: 0; overflow-wrap: anywhere; }
.metrics {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px 16px;
  padding: 16px 0;
}
.metrics dt { font-size: 12.5px; }
.metrics dd {
  margin: 2px 0 0;
  overflow: hidden;
  font-size: 17px;
  font-variant-numeric: tabular-nums;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.status {
  margin-bottom: 18px;
  padding: 8px 10px;
  border-radius: 4px;
  background: #f4f4f4;
  color: var(--gray);
  font-size: 13px;
  overflow-wrap: anywhere;
}
.status.ready { background: var(--blue-soft); color: #33496f; }
.status.error { background: #f8ecea; color: #8e3a35; }

.collision-controls { margin: 0 0 16px; padding: 10px 0 0; border: 0; border-top: 1px solid var(--rule); min-width: 0; }
.collision-controls legend { padding: 0; font-weight: 500; }
.collision-controls .parameter-grid { margin: 10px 0 0; }
.collision-controls:disabled { color: var(--gray); }

.control-column details { border-top: 1px solid var(--rule); padding: 10px 0; }
.control-column details:last-of-type { border-bottom: 1px solid var(--rule); margin-bottom: 16px; }
summary { cursor: pointer; font-weight: 500; }
details[open] > summary { margin-bottom: 12px; }

.parameter-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 12px; margin-bottom: 14px; }
.parameter-grid label { display: grid; gap: 3px; color: var(--gray); font-size: 12.5px; }
.grid-head { display: flex; justify-content: space-between; margin-bottom: 6px; color: var(--gray); font-size: 12.5px; }
#grid-total { font-variant-numeric: tabular-nums; }
#grid-total.error { color: var(--red); }
.axis-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 12px; margin-bottom: 14px; }
.axis-row { display: grid; grid-template-columns: 34px 1fr; align-items: center; gap: 6px; }
.axis-row var { text-align: right; }
.spec-link { margin: 0 0 14px; color: var(--gray); font-size: 13px; line-height: 1.5; }
.spec-link a { color: var(--blue); }
.map-guide dt { margin-top: 8px; font-family: var(--code); font-size: 13px; }
.map-guide dd { margin: 2px 0 0; color: var(--gray); }

.definition-panel { padding: 28px 0 36px; border-top: 1px solid var(--rule); }
.definition-panel[hidden] { display: none; }
.definition-header { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; }
.definition-header h2 { font-size: 24px; }
.definition-actions { display: flex; gap: 8px; }
.definition-panel > .note { margin-bottom: 12px; }

/* The textarea draws only the caret and selection; the highlighted copy sits underneath. */
.code-editor {
  position: relative;
  height: 560px;
  min-height: 240px;
  border: 1px solid var(--control);
  border-radius: 4px;
  overflow: hidden;
  resize: vertical;
}
.code-editor:focus-within { border-color: var(--blue); }
.code-highlight, #definition, .code-block {
  margin: 0;
  padding: 14px 16px;
  font: 13px/1.6 var(--code);
  tab-size: 2;
  white-space: pre;
}
.code-highlight, #definition {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: auto;
}
.code-highlight { pointer-events: none; color: var(--ink); overflow: hidden; }
#definition {
  border: 0;
  outline: none;
  resize: none;
  background: transparent;
  color: transparent;
  caret-color: var(--ink);
}
#definition::selection { background: rgba(74, 104, 158, .22); color: transparent; }
.json-key { color: var(--blue); }
.json-string { color: var(--gold); }
.json-number { color: var(--red); }
.json-literal { color: var(--rose); font-weight: 600; }
.json-punct { color: #8a8a8a; }
.js-keyword { color: var(--blue); }
.js-string { color: var(--gold); }
.js-number { color: var(--red); }
.js-comment { color: #8a8a8a; font-style: italic; }
#parameter-controls code { font-size: 13px; }

.reference-panel { margin-top: 16px; border: 1px solid var(--rule); border-radius: 4px; }
.reference-head { display: flex; justify-content: space-between; align-items: center; padding: 6px 8px 6px 16px; border-bottom: 1px solid var(--rule); font-weight: 500; }
.code-block { max-height: 32rem; overflow: auto; }

/* Notebook reading order: rendered problem, editable code, then simulation output. */
body { background: #f8f9fb; }
.masthead, main, footer { width: min(1260px, calc(100% - 32px)); }
.example-picker {
  margin-bottom: 20px;
  padding: 13px 18px;
  border: 1px solid var(--rule);
  border-radius: 8px;
  background: var(--paper);
}
.notebook-markdown {
  display: grid;
  grid-template-columns: 94px minmax(0, 1fr);
  overflow: hidden;
  border: 1px solid var(--rule);
  border-radius: 8px;
  background: var(--paper);
}
.notebook-gutter {
  padding: 29px 14px;
  border-right: 1px solid #e9ebf0;
  background: #fafbfd;
  color: var(--blue);
  font: 12px/1.6 var(--code);
  text-align: right;
}
.notebook-document { min-width: 0; padding: 26px 32px 32px; }
.notebook-document-header { display: flex; align-items: start; justify-content: space-between; gap: 18px; }
.notebook-document-header h2 { font-size: 27px; line-height: 1.25; }
.notebook-kicker {
  margin: 0 0 5px;
  color: var(--gray);
  font: 11px/1.4 var(--sans);
  letter-spacing: .09em;
  text-transform: uppercase;
}
.notebook-document-header button { flex: none; }
.notebook-prose { max-width: 980px; color: #343a45; font-size: 15px; line-height: 1.75; }
.notebook-text-cell { margin-top: 21px; }
.notebook-text-cell + .notebook-text-cell { margin-top: 24px; padding-top: 20px; border-top: 1px solid var(--rule); }
.notebook-text-cell h3 { margin: 19px 0 6px; color: var(--ink); font-size: 20px; }
.notebook-text-cell h4 { margin: 17px 0 6px; color: var(--ink); font-size: 17px; }
.notebook-text-cell h5 { margin: 14px 0 6px; color: var(--ink); font-size: 15px; }
.notebook-text-cell p { margin: 9px 0; }
.notebook-text-cell ul { margin: 8px 0 14px; padding-left: 24px; }
.notebook-text-cell li { margin: 4px 0; }
.notebook-text-cell code {
  padding: 2px 5px;
  border-radius: 4px;
  background: #f2f4f7;
  color: #445573;
}
.notebook-equation {
  max-width: 100%;
  margin: 17px 0 21px;
  padding: 15px 20px;
  border-left: 2px solid #bac9e0;
  background: #f8fafe;
  overflow-x: auto;
  font-family: var(--serif);
  line-height: 1.7;
}
.notebook-equation mjx-container[display="true"] { margin: .3em 0; overflow-x: auto; }
.definition-panel {
  margin: 16px 0 0;
  padding: 24px 32px 28px;
  border: 1px solid var(--rule);
  border-radius: 8px;
  background: var(--paper);
}
.notebook-input-heading { margin-bottom: 12px; color: var(--blue); font: 13px/1.5 var(--code); }
.experiment {
  margin: 16px 0 34px;
  padding: 18px 28px 30px;
  gap: 24px 30px;
  border: 1px solid var(--rule);
  border-radius: 8px;
  background: var(--paper);
}
.notebook-output-heading {
  grid-column: 1 / -1;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--rule);
  color: var(--blue);
  font: 13px/1.5 var(--code);
}
.notebook-output-heading span { margin-left: 10px; color: var(--gray); font: 13px/1.5 var(--sans); }
.figure-column, .control-column { min-width: 0; }
.control-column { padding-left: 20px; border-left: 1px solid var(--rule); }
footer { padding: 16px 0 32px; border-top: 1px solid var(--rule); color: var(--gray); font-size: 12.5px; }

@media (max-width: 960px) {
  .experiment { grid-template-columns: 1fr; gap: 24px; }
  .control-column { padding: 18px 0 0; border-left: 0; border-top: 1px solid var(--rule); }
}

@media (max-width: 620px) {
  .notebook-markdown { grid-template-columns: 1fr; }
  .notebook-gutter { display: none; }
  .notebook-document { padding: 20px; }
  .notebook-document-header { flex-wrap: wrap; }
  .notebook-document-header h2 { font-size: 23px; }
  .notebook-prose { font-size: 14px; }
  .notebook-equation { padding: 10px; }
  .example-picker { flex-wrap: wrap; padding: 12px; }
  .definition-panel { padding: 16px; }
  .experiment { padding: 16px; }
  h1 { font-size: 26px; }
  .example-picker select { flex: 1; }
  .figure-toolbar { flex-wrap: wrap; }
  .plot-shell { aspect-ratio: 1.1 / 1; min-height: 0; }
  #slice-note { width: 100%; margin-left: 0; }
  .definition-actions { flex-wrap: wrap; }
  .code-editor { height: 460px; }
  .diagnostics-grid { grid-template-columns: 1fr; }
}
