/* Same palette as the Python course (python/tutorial/web/app.css), plus colours for what the solver does. */
:root {
  --bg: #ffffff; --fg: #1f2328; --muted: #656d76; --line: #d0d7de; --soft: #f6f8fa;
  --accent: #3776ab; --accent-fg: #fff;
  --region: rgba(55, 118, 171, .10); --node: rgba(55, 118, 171, .28);
  --path: #3776ab; --point: #0b5cad; --inc: #1a7f37; --cut: #cf222e; --branch: #bc4c00;
  --pruned: #8c959f; --infeasible: #cf222e; --int: #1a7f37; --frac: #bc4c00;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0d1117; --fg: #e6edf3; --muted: #8d96a0; --line: #30363d; --soft: #161b22;
    --accent: #4d8fd1; --region: rgba(77, 143, 209, .12); --node: rgba(77, 143, 209, .32);
    --path: #6cb0f0; --point: #9cc9ff; --inc: #3fb950; --cut: #f85149; --branch: #f0883e;
    --pruned: #6e7681; --infeasible: #f85149; --int: #3fb950; --frac: #f0883e;
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--fg); font: 15px/1.6 -apple-system, BlinkMacSystemFont, "Segoe UI",
  "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans CJK SC", sans-serif; }
a { color: var(--accent); }
[hidden] { display: none !important; }

.top { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 10px; padding: 8px 16px;
  background: var(--bg); border-bottom: 1px solid var(--line); }
.brand { font-weight: 700; text-decoration: none; color: var(--fg); }
.crumb { color: var(--muted); }
.crumb::before { content: "/"; margin-right: 10px; color: var(--line); }
.links { margin-left: auto; display: flex; align-items: center; gap: 14px; font-size: 14px; }

.btn { font: inherit; font-size: 14px; padding: 5px 12px; border-radius: 8px; border: 1px solid var(--line);
  background: var(--soft); color: var(--fg); cursor: pointer; white-space: nowrap; }
.btn:hover:not(:disabled) { border-color: var(--muted); }
.btn:disabled { opacity: .45; cursor: default; }
.btn.primary { background: var(--accent); color: var(--accent-fg); border-color: var(--accent); font-weight: 600; }
.btn.ghost { background: transparent; }
.btn.icon { min-width: 38px; padding: 5px 8px; }
.btn.wide { width: 100%; padding: 9px; font-size: 15px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.layout { display: grid; grid-template-columns: 340px minmax(0, 1fr); gap: 0; min-height: calc(100vh - 100px); }
.side { padding: 16px; border-right: 1px solid var(--line); }
.side h1 { font-size: 22px; margin: 4px 0 6px; line-height: 1.3; }
.lede { color: var(--muted); margin: 0 0 14px; }
.field { display: flex; flex-direction: column; gap: 4px; font-weight: 600; font-size: 14px; }
select, textarea { font: inherit; color: var(--fg); background: var(--bg); border: 1px solid var(--line); border-radius: 8px; }
select { padding: 6px 8px; font-weight: normal; }
.blurb { color: var(--muted); font-size: 14px; margin: 8px 0 12px; min-height: 3em; }
.editor { margin-bottom: 12px; }
.editor summary { cursor: pointer; font-size: 14px; font-weight: 600; }
.editor textarea { width: 100%; margin-top: 8px; padding: 8px; font-family: var(--mono); font-size: 13px; line-height: 1.45; resize: vertical; }
.hint { color: var(--muted); font-size: 13px; margin: 4px 0 0; }
.opts { border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px 12px; margin: 0 0 14px; display: flex; flex-direction: column; gap: 6px; font-size: 14px; }
.opts legend { font-weight: 600; padding: 0 4px; }
.opts .field { margin-top: 4px; }
.status { font-size: 14px; color: var(--muted); min-height: 1.5em; margin: 8px 0; }
.status.err { color: var(--cut); white-space: pre-wrap; }
.summary { border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; font-size: 14px; background: var(--soft); }
.summary h2 { font-size: 15px; margin: 0 0 6px; }
.summary dl { display: grid; grid-template-columns: auto 1fr; gap: 2px 12px; margin: 0; }
.summary dt { color: var(--muted); }
.summary dd { margin: 0; font-family: var(--mono); font-size: 13px; overflow-wrap: anywhere; }

.stage { padding: 12px 16px 24px; min-width: 0; display: flex; flex-direction: column; gap: 12px; }
.controls { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
#scrub { flex: 1; min-width: 120px; accent-color: var(--accent); }
.counter { font-family: var(--mono); font-size: 13px; color: var(--muted); min-width: 6em; text-align: right; }

.narration { border: 1px solid var(--line); border-left: 4px solid var(--accent); border-radius: 10px; padding: 10px 14px; min-height: 92px; }
.now { font-weight: 600; font-family: var(--mono); font-size: 14px; overflow-wrap: anywhere; }
.why { color: var(--muted); margin-top: 4px; font-size: 14px; }
.tag { display: inline-block; font: 600 12px/1.6 -apple-system, sans-serif; padding: 0 8px; border-radius: 99px;
  background: var(--soft); border: 1px solid var(--line); margin-right: 6px; vertical-align: 1px; }

.panels { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 12px; }
.panel { margin: 0; border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px 10px; min-width: 0; display: flex; flex-direction: column; }
.panel figcaption { font-weight: 600; font-size: 14px; margin-bottom: 4px; }
.canvas { position: relative; width: 100%; aspect-ratio: 1 / 1; }
.canvas.tree { overflow: auto; }
.canvas svg { display: block; width: 100%; height: 100%; }
.canvas text { font-family: -apple-system, "Segoe UI", sans-serif; fill: var(--fg); }
.legend { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 12px; color: var(--muted); margin-top: 6px; }
.legend i { display: inline-block; width: 12px; height: 12px; border-radius: 3px; vertical-align: -1px; margin-right: 4px; }
.empty { position: absolute; inset: 0; display: grid; place-items: center; color: var(--muted); font-size: 14px; text-align: center; padding: 20px; }

.canvas.tree svg { width: auto; height: auto; margin: 0 auto; }
.tree .node { cursor: pointer; }
.tree .node:hover circle { stroke-width: 3; }

.log-box summary { cursor: pointer; font-weight: 600; font-size: 14px; }
.log { list-style: none; margin: 8px 0 0; padding: 0; max-height: 280px; overflow-y: auto; border: 1px solid var(--line);
  border-radius: 10px; font-family: var(--mono); font-size: 12.5px; line-height: 1.5; }
.log li { padding: 1px 10px; white-space: pre-wrap; cursor: pointer; border-left: 3px solid transparent; }
.log li:hover { background: var(--soft); }
.log li.past { color: var(--fg); }
.log li.future { color: var(--muted); opacity: .55; }
.log li.cur { background: var(--node); border-left-color: var(--accent); }
.log li.node-line { font-weight: 700; margin-top: 4px; }

.foot { border-top: 1px solid var(--line); padding: 10px 16px; font-size: 13px; color: var(--muted); display: flex; gap: 12px; flex-wrap: wrap; justify-content: space-between; }

@media (max-width: 1100px) {
  .panels { grid-template-columns: minmax(0, 1fr); }
  .canvas { aspect-ratio: 4 / 3; }
}
@media (max-width: 820px) {
  /* one column: pick a model, watch it, then the settings and the result */
  .layout { grid-template-columns: minmax(0, 1fr); }
  .side { display: contents; }
  .side > * { margin-left: 16px; margin-right: 16px; }
  .side > h1 { margin-top: 16px; }
  .stage { order: 1; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
  .side > .editor, .side > .opts, .side > #solve, .side > #status, .side > #summary { order: 2; }
  .side > #summary { margin-bottom: 16px; }
  .btn.wide { width: auto; }
  .crumb { display: none; }
  .canvas { aspect-ratio: 1 / 1; }
  .counter { min-width: 0; }
}
