/* ShellLab. One accent (cyan), used for data and focus only. Hairlines, not cards. */

@font-face { font-family: 'Geist'; src: url('../vendor/fonts/geist.woff2') format('woff2'); font-weight: 100 900; font-display: swap; }
@font-face { font-family: 'Geist Mono'; src: url('../vendor/fonts/geist-mono.woff2') format('woff2'); font-weight: 100 900; font-display: swap; }

:root, [data-theme='dark'] {
  --bg: #0d0d0e;
  --panel: #111113;
  --stage: #09090a;
  --ink: #ecebe8;
  --muted: #8d8c88;
  --faint: #6b6a66;
  --rule: #222225;
  --rule-strong: #34343a;
  --accent: #22d3ee;
  --accent-ink: #67e3f5;
  --sel: #1b1b1e;
  --scene-low: #3a3c41;
  --scene-surface: #9aa3ab;
  --scene-support: #ecebe8;
  color-scheme: dark;
}
[data-theme='light'] {
  --bg: #f4f3ef;
  --panel: #fafaf7;
  --stage: #eeede8;
  --ink: #161617;
  --muted: #5e5d59;
  --faint: #7c7a75;
  --rule: #e0ded7;
  --rule-strong: #cbc8bf;
  --accent: #0e7490;
  --accent-ink: #0e7490;
  --sel: #ffffff;
  --scene-low: #c3c1ba;
  --scene-surface: #7f8a93;
  --scene-support: #161617;
  color-scheme: light;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 400 14px/1.5 'Geist', system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: underline; text-decoration-color: var(--rule-strong); text-underline-offset: 3px; }
a:hover { text-decoration-color: currentColor; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 2px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: 1rem; top: -3rem; background: var(--ink); color: var(--bg); padding: .5rem .75rem; z-index: 10; }
.skip:focus { top: .5rem; }
output, dd, .legend, .block, .cursor { font-family: 'Geist Mono', ui-monospace, monospace; font-variant-numeric: tabular-nums; }

/* ---------- top bar ---------- */
.bar {
  height: 52px; display: flex; align-items: center; gap: 1.5rem;
  padding: 0 1.25rem; border-bottom: 1px solid var(--rule); background: var(--bg);
}
.mark { margin: 0; display: flex; align-items: baseline; gap: .9rem; font-size: 14px; font-weight: 600; letter-spacing: -.01em; }
.mark a { display: inline-flex; align-items: center; gap: .5rem; text-decoration: none; }
.mark svg { width: 18px; height: 18px; fill: none; stroke: var(--accent); stroke-width: 3; }
.mark .tag { font-weight: 400; color: var(--muted); }
.bar nav { margin-left: auto; display: flex; gap: 1.25rem; }
.bar nav a { color: var(--muted); text-decoration: none; font-size: 13px; }
.bar nav a:hover { color: var(--ink); }
.icon { width: 30px; height: 30px; display: grid; place-items: center; border: 1px solid var(--rule); border-radius: 6px; background: none; color: var(--muted); cursor: pointer; }
.icon:hover { color: var(--ink); border-color: var(--rule-strong); }
.icon svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 1.6; }
.icon .fill { fill: currentColor; stroke: none; }

/* ---------- workspace ---------- */
.work {
  display: grid; grid-template-columns: 17.5rem minmax(0, 1fr) 21rem;
  height: calc(100vh - 52px); min-height: 40rem; border-bottom: 1px solid var(--rule);
}
.side { background: var(--panel); overflow-y: auto; scrollbar-width: thin; scrollbar-color: var(--rule-strong) transparent; }
.controls { border-right: 1px solid var(--rule); padding: .25rem 1.25rem 1.25rem; }
.info { border-left: 1px solid var(--rule); }

fieldset { border: 0; margin: 0; padding: 1rem 0 .75rem; border-bottom: 1px solid var(--rule); min-width: 0; }
legend { float: left; width: 100%; padding: 0; margin-bottom: .75rem; font-size: 12px; font-weight: 500; color: var(--muted); }
legend + * { clear: both; }

.field { display: grid; grid-template-columns: 1fr auto; align-items: baseline; row-gap: .3rem; margin-bottom: .8rem; }
.field label { font-size: 13px; }
.field output { font-size: 12.5px; text-align: right; }
.field input { grid-column: 1 / -1; }
sub { font-size: .72em; }

input[type='range'] { -webkit-appearance: none; appearance: none; width: 100%; height: 16px; margin: 0; background: transparent; cursor: pointer; }
input[type='range']::-webkit-slider-runnable-track { height: 2px; background: var(--rule-strong); border-radius: 1px; }
input[type='range']::-moz-range-track { height: 2px; background: var(--rule-strong); border-radius: 1px; }
input[type='range']::-webkit-slider-thumb { -webkit-appearance: none; width: 12px; height: 12px; margin-top: -5px; border-radius: 50%; background: var(--ink); border: 2px solid var(--panel); box-shadow: 0 0 0 1px var(--ink); }
input[type='range']::-moz-range-thumb { width: 10px; height: 10px; border-radius: 50%; background: var(--ink); border: 2px solid var(--panel); box-shadow: 0 0 0 1px var(--ink); }
input[type='range']:focus-visible { outline: none; }
input[type='range']:focus-visible::-webkit-slider-thumb { box-shadow: 0 0 0 1px var(--ink), 0 0 0 4px var(--accent); }
input[type='range']:focus-visible::-moz-range-thumb { box-shadow: 0 0 0 1px var(--ink), 0 0 0 4px var(--accent); }

.presets { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.presets button { white-space: nowrap;
  display: grid; justify-items: center; gap: .3rem; padding: .55rem .2rem .45rem;
  font: inherit; font-size: 11.5px; color: var(--muted); background: none;
  border: 1px solid var(--rule); border-radius: 6px; cursor: pointer;
}
.presets button:hover { color: var(--ink); border-color: var(--rule-strong); }
.presets button[aria-checked='true'] { color: var(--ink); background: var(--sel); border-color: var(--ink); font-weight: 500; }
.presets svg { width: 26px; height: 26px; fill: none; stroke: var(--faint); stroke-width: 1; color: var(--muted); }
.presets svg .s { fill: currentColor; stroke: none; }
.presets svg .e { stroke: currentColor; stroke-width: 2.5; }
.presets svg .d { stroke-dasharray: 2 2; }
.presets button[aria-checked='true'] svg { color: var(--accent); }

.hint { margin: .7rem 0 0; font-size: 12px; line-height: 1.45; color: var(--muted); }

.actions { display: grid; grid-template-columns: 1.4fr 1fr 1fr 1fr; gap: 6px; padding-top: 1rem; }
.btn {
  height: 30px; padding: 0 .5rem; font: inherit; font-size: 12.5px; font-weight: 500; color: var(--ink);
  background: none; border: 1px solid var(--rule-strong); border-radius: 6px; cursor: pointer; white-space: nowrap;
}
.btn:hover { background: var(--sel); border-color: var(--muted); }
.btn.quiet { color: var(--muted); border-color: var(--rule); }
.status { min-height: 1.2em; margin: .6rem 0 0; font-size: 12px; color: var(--muted); }
.status.err { color: #f87171; }
[data-theme='light'] .status.err { color: #b91c1c; }

/* ---------- stage ---------- */
.stage { position: relative; background: var(--stage); min-width: 0; overflow: hidden; }
.view { position: absolute; inset: 0; cursor: grab; }
.view:active { cursor: grabbing; }
.view canvas { display: block; width: 100%; height: 100%; }

.seg { position: absolute; z-index: 2; top: 14px; left: 14px; display: inline-flex; padding: 2px; border: 1px solid var(--rule); border-radius: 7px; background: color-mix(in srgb, var(--stage) 80%, transparent); backdrop-filter: blur(6px); }
.seg button { height: 26px; padding: 0 .7rem; font: inherit; font-size: 12px; color: var(--muted); background: none; border: 0; border-radius: 5px; cursor: pointer; }
.seg button:hover { color: var(--ink); }
.seg button[aria-checked='true'] { color: var(--ink); background: var(--sel); box-shadow: inset 0 0 0 1px var(--rule-strong); font-weight: 500; }

.legend { position: absolute; z-index: 2; top: 20px; right: 16px; display: flex; align-items: center; gap: .5rem; font-size: 11px; color: var(--muted); }
.legend i { width: 96px; height: 4px; border-radius: 2px; background: linear-gradient(90deg, var(--scene-low), var(--accent)); }

.block {
  position: absolute; z-index: 2; left: 14px; bottom: 14px; display: grid; grid-template-columns: auto auto; column-gap: 1.1rem;
  padding: .55rem .75rem; font-size: 11px; line-height: 1.6; color: var(--muted);
  border: 1px solid var(--rule); border-radius: 6px; background: color-mix(in srgb, var(--stage) 82%, transparent); backdrop-filter: blur(6px);
  pointer-events: none;
}
.block b { font-weight: 400; color: var(--ink); text-align: right; }
.block:empty { display: none; }
.orbit { position: absolute; z-index: 2; right: 16px; bottom: 16px; font-size: 11px; color: var(--faint); pointer-events: none; }

/* ---------- plan and results ---------- */
.info h2 { margin: 0 0 .75rem; font-size: 12px; font-weight: 500; color: var(--muted); }
.planbox, .readout { padding: 1rem 1.25rem; }
.planbox { border-bottom: 1px solid var(--rule); }
#plan { display: block; width: 100%; height: auto; max-height: 19rem; touch-action: none; cursor: crosshair; }
#plan:focus-visible { outline-offset: 4px; }
#plan .g { stroke: var(--rule); stroke-width: .6; }
#plan .o { fill: none; stroke: var(--muted); stroke-width: .8; stroke-dasharray: 3 2; }
#plan .n { fill: var(--faint); }
#plan .s { fill: var(--ink); }
#plan .th { fill: none; stroke: var(--accent); stroke-width: 1.4; stroke-linecap: round; stroke-linejoin: round; }
#plan .cur { fill: none; stroke: var(--accent); stroke-width: 1.2; opacity: 0; }
#plan:focus-visible .cur { opacity: 1; }

.key { list-style: none; margin: .6rem 0 0; padding: 0; display: flex; flex-wrap: wrap; gap: .3rem 1rem; font-size: 11.5px; color: var(--muted); }
.key li { display: inline-flex; align-items: center; gap: .4rem; }
.k-sup { width: 7px; height: 7px; background: var(--ink); }
.k-out { width: 14px; border-top: 1px dashed var(--muted); }
.k-arrow { width: 13px; height: 1.5px; background: var(--accent); position: relative; margin-right: 3px; }
.k-arrow::after { content: ''; position: absolute; right: -4px; top: -3.25px; border: 4px solid transparent; border-left: 5px solid var(--accent); border-right: 0; }
.cursor { margin: .5rem 0 0; font-size: 11px; color: var(--faint); min-height: 1.5em; }

.group { margin: 0 0 1rem; }
.group h3 { margin: 0 0 .25rem; font-size: 11px; font-weight: 500; letter-spacing: .02em; color: var(--faint); }
.group dl { margin: 0; display: grid; grid-template-columns: 1fr auto; }
.group dt, .group dd { padding: .34rem 0; border-top: 1px solid var(--rule); font-size: 13px; }
.group dt { color: var(--muted); }
.group dd { margin: 0; padding-left: 1rem; text-align: right; font-size: 12.5px; }
.group dd.hi { color: var(--accent-ink); }
.note { margin: .25rem 0 0; font-size: 11.5px; line-height: 1.5; color: var(--faint); }

/* ---------- notes ---------- */
.notes { display: grid; grid-template-columns: 17.5rem minmax(0, 1fr); padding: 4rem 1.25rem 4.5rem; border-bottom: 1px solid var(--rule); }
.notes > h2 { margin: 0; font-size: 12px; font-weight: 500; color: var(--muted); }
.notes ol { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(22rem, 1fr)); gap: 2.5rem 3rem; counter-reset: n; max-width: 72rem; }
.notes li { counter-increment: n; }
.notes h3 { margin: 0 0 .5rem; font-size: 14px; font-weight: 500; }
.notes h3::before { content: counter(n, decimal-leading-zero); margin-right: .7rem; font: 400 11px 'Geist Mono', monospace; color: var(--faint); }
.notes p { margin: 0; max-width: 62ch; color: var(--muted); font-size: 13.5px; line-height: 1.65; }
.notes a { color: var(--ink); }
.notes i { font-family: Georgia, 'Times New Roman', serif; }

.foot { display: flex; justify-content: space-between; gap: 1rem; padding: 1.25rem; font-size: 12px; color: var(--faint); }
.foot a { color: var(--muted); }
.noscript { padding: 1rem 1.25rem; color: var(--muted); }

/* ---------- smaller screens ---------- */
@media (max-width: 72rem) {
  .work { grid-template-columns: 17.5rem minmax(0, 1fr); height: auto; }
  .controls { grid-row: 1 / span 2; }
  .stage { height: 70vh; min-height: 30rem; }
  .info { border-left: 0; border-top: 1px solid var(--rule); display: grid; grid-template-columns: 1fr 1fr; overflow: visible; }
  .planbox { border-bottom: 0; border-right: 1px solid var(--rule); }
  .notes { grid-template-columns: 1fr; gap: 1.5rem; }
}
@media (max-width: 46rem) {
  .bar { gap: .75rem; padding: 0 1rem; }
  .bar nav, .mark .tag { display: none; }
  .icon { margin-left: auto; }
  .work { display: flex; flex-direction: column; min-height: 0; }
  .stage { order: -1; height: 88vw; min-height: 20rem; border-bottom: 1px solid var(--rule); }
  .controls { border-right: 0; padding: .25rem 1rem 1rem; }
  .info { grid-template-columns: 1fr; }
  .planbox { border-right: 0; border-bottom: 1px solid var(--rule); }
  .planbox, .readout { padding: 1rem; }
  .orbit { display: none; }
  .block { left: 10px; bottom: 10px; }
  .notes { padding: 2.5rem 1rem 3rem; }
  .notes ol { grid-template-columns: 1fr; gap: 2rem; }
  .foot { flex-direction: column; padding: 1rem; }
}

@media (prefers-reduced-motion: reduce) { * { scroll-behavior: auto !important; transition: none !important; } }
@media print {
  .bar nav, .icon, .actions, .seg, .orbit, .skip { display: none; }
  .work { height: auto; display: block; }
  .stage { height: 60vh; }
}
