:root {
  color-scheme: dark;
  --background: #080a0d;
  --panel: #0e1116;
  --panel-raised: #14181f;
  --ink: #f1eee5;
  --muted: #939aa4;
  --line: #2a3039;
  --line-bright: #48525e;
  --red: #ff4e42;
  --cyan: #68d7e8;
  --amber: #f5bd62;
  --green: #7dd49d;
  --purple: #d5a9ff;
  --mono: "SFMono-Regular", "Cascadia Code", "Liberation Mono", monospace;
  --sans: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; overflow: hidden; color: var(--ink); background: var(--background); font-family: var(--mono); }
button, input { font: inherit; }
button { color: inherit; }
a { color: inherit; }
[hidden] { display: none !important; }

.skip-link {
  position: fixed;
  top: 8px;
  left: 8px;
  z-index: 30;
  padding: 10px;
  color: var(--background);
  background: var(--ink);
  transform: translateY(-150%);
}
.skip-link:focus { transform: none; }

.topbar {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  height: 48px;
  padding: 0 18px;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  background: #0a0c10;
  font-size: 9px;
  letter-spacing: .09em;
}
.wordmark { color: var(--red); font-weight: 800; text-decoration: none; }
.topbar > span { padding-left: 15px; }
.live-link { color: var(--ink); text-decoration: none; }
.live-link::before { display: inline-block; width: 6px; height: 6px; margin-right: 7px; border-radius: 50%; background: var(--green); box-shadow: 0 0 8px var(--green); content: ""; }

.workspace { display: grid; grid-template-columns: minmax(330px, 385px) minmax(0, 1fr); height: calc(100vh - 48px); }
.guide-pane { overflow-y: auto; border-right: 1px solid var(--line); background: var(--panel); scrollbar-width: thin; }
.guide-toolbar { position: sticky; top: 0; z-index: 3; display: grid; grid-template-columns: 1fr 1fr; gap: 1px; border-bottom: 1px solid var(--line); background: var(--line); }
.guide-toolbar button, .route-status button {
  min-height: 43px;
  border: 0;
  color: var(--muted);
  background: #0d1015;
  cursor: pointer;
  font-size: 8px;
  letter-spacing: .06em;
}
.guide-toolbar button:hover, .guide-toolbar button:focus-visible { color: var(--cyan); background: var(--panel-raised); }

.route-status { padding: 12px 18px; border-bottom: 1px solid var(--line); background: rgba(104,215,232,.05); }
.route-status > div:first-child { display: flex; justify-content: space-between; gap: 14px; color: var(--cyan); font-size: 8px; }
.route-status b { color: var(--muted); font-weight: 400; }
.route-track { height: 2px; margin-top: 10px; background: var(--line); }
.route-track i { display: block; width: 0; height: 100%; background: var(--cyan); }
.route-status button { min-height: 0; margin-top: 9px; padding: 0; background: transparent; font-size: 7px; }

.explanation { padding: 28px 25px 24px; }
.eyebrow { margin: 0 0 13px; color: var(--red); font-size: 8px; font-weight: 700; letter-spacing: .15em; }
.explanation h1 { margin: 0; font-family: var(--sans); font-size: clamp(27px, 2.35vw, 35px); letter-spacing: -.045em; line-height: 1.04; }
.explanation-body { margin-top: 22px; }
.explanation-body p { margin: 0 0 14px; color: #b6bdc6; font-family: var(--sans); font-size: 14px; line-height: 1.68; }
.example-values { margin: 23px 0 0; border-top: 1px solid var(--line); }
.example-values div { display: grid; grid-template-columns: 1fr auto; gap: 12px; padding: 9px 0; border-bottom: 1px solid var(--line); font-size: 9px; }
.example-values dt { color: var(--muted); }
.example-values dd { margin: 0; color: var(--amber); text-align: right; }

.hints { padding: 0 25px 25px; }
.hints-heading { display: flex; align-items: end; justify-content: space-between; gap: 12px; margin-bottom: 10px; }
.hints-heading h2 { margin: 0; font-size: 10px; font-weight: 500; }
.hints-heading span { color: var(--red); font-size: 7px; letter-spacing: .09em; }
#hint-list { display: grid; gap: 7px; }
.hint-button { position: relative; display: block; width: 100%; padding: 13px 36px 13px 13px; border: 1px solid var(--line); color: var(--ink); background: #0a0d11; cursor: pointer; text-align: left; }
.hint-button:hover, .hint-button:focus-visible { border-color: var(--cyan); background: rgba(104,215,232,.055); }
.hint-button strong { display: block; margin-bottom: 5px; color: var(--cyan); font-size: 9px; font-weight: 500; }
.hint-button small { display: block; color: var(--muted); font-family: var(--sans); font-size: 11px; line-height: 1.4; }
.hint-button::after { position: absolute; top: 50%; right: 13px; color: var(--line-bright); content: "→"; transform: translateY(-50%); }
.hint-button.route-next { border-color: rgba(104,215,232,.4); }
.hint-button.route-next::before { display: block; margin-bottom: 7px; color: var(--red); content: "CONTINUE ROUTE"; font-size: 7px; letter-spacing: .08em; }

.navigation-help { margin: 0 25px 35px; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.navigation-help summary { padding: 13px 0; color: var(--muted); cursor: pointer; font-size: 8px; letter-spacing: .05em; }
.navigation-help p { margin: 0 0 16px; color: var(--muted); font-family: var(--sans); font-size: 12px; line-height: 1.55; }
kbd { padding: 2px 5px; border: 1px solid var(--line-bright); color: var(--ink); font-family: var(--mono); font-size: 9px; }

.editor { position: relative; min-width: 0; overflow: hidden; background: #090c10; }
.editor-toolbar { display: grid; grid-template-columns: auto auto 1fr auto; align-items: center; height: 48px; border-bottom: 1px solid var(--line); background: #0c0f13; }
.history-controls { display: flex; height: 100%; border-right: 1px solid var(--line); }
.history-controls button, .file-button, .definition-picker button, .route-picker button { border: 0; background: transparent; cursor: pointer; }
.history-controls button { width: 42px; color: var(--muted); font-size: 13px; }
.history-controls button:hover:not(:disabled) { color: var(--cyan); background: var(--panel-raised); }
.history-controls button:disabled { opacity: .25; cursor: default; }
.file-button { align-self: stretch; padding: 0 14px; border-right: 1px solid var(--line); color: var(--muted); font-size: 8px; }
.file-button:hover { color: var(--cyan); }
.breadcrumbs { display: flex; min-width: 0; overflow: hidden; padding: 0 16px; color: #aab2bc; font-size: 9px; white-space: nowrap; }
.breadcrumbs button { padding: 0; border: 0; color: inherit; background: transparent; cursor: pointer; }
.breadcrumbs button:hover { color: var(--cyan); }
.breadcrumbs i { padding: 0 7px; color: #3f4751; font-style: normal; }
.line-badge { margin-right: 16px; color: var(--red); font-size: 8px; }

.editor-notice { display: flex; justify-content: space-between; gap: 20px; min-height: 34px; padding: 9px 17px; border-bottom: 1px solid var(--line); color: #65707b; background: #090b0e; font-size: 8px; }
.editor-notice b { color: var(--cyan); font-weight: 500; }
#navigation-message { color: var(--amber); text-align: right; }
.source-code { height: calc(100vh - 130px); margin: 0; overflow: auto; padding: 26px 0 100px; color: #c4cad2; font: clamp(11px, .9vw, 13px)/1.82 var(--mono); tab-size: 4; scrollbar-width: thin; }
.code-line { display: block; min-width: max-content; padding: 0 28px 0 0; border-left: 2px solid transparent; white-space: pre; }
.code-line::before { display: inline-block; width: 48px; margin-right: 20px; color: #3e4650; content: attr(data-line); text-align: right; user-select: none; }
.code-line.focused { border-left-color: var(--red); color: #fff; background: rgba(255,78,66,.11); }
.source-symbol { border-radius: 2px; cursor: default; }
.modifier-active .source-symbol.has-definition { cursor: pointer; text-decoration: underline; text-decoration-color: rgba(104,215,232,.55); text-underline-offset: 3px; }
.source-symbol.has-definition:hover { color: var(--cyan); }
.source-symbol.definition { color: var(--purple); font-weight: 600; }
.source-symbol.linked { color: #031014; background: var(--cyan); }

.file-tree { position: absolute; top: 53px; left: 7px; z-index: 8; width: min(390px, calc(100% - 14px)); max-height: calc(100vh - 115px); overflow: auto; padding: 15px; border: 1px solid var(--line-bright); background: #0c1015; box-shadow: 14px 14px 0 rgba(0,0,0,.45); }
.file-tree label span { display: block; margin-bottom: 8px; color: var(--muted); font-size: 8px; }
.file-tree input { width: 100%; padding: 10px; border: 1px solid var(--line); outline: 0; color: var(--ink); background: var(--background); font-size: 10px; }
.file-tree input:focus { border-color: var(--cyan); }
#file-list, #symbol-results { display: grid; margin-top: 11px; }
.tree-heading { padding: 7px 5px; color: var(--red); font-size: 7px; letter-spacing: .1em; }
.tree-button { padding: 8px 6px; border: 0; border-bottom: 1px solid var(--line); color: #aeb5be; background: transparent; cursor: pointer; font-size: 9px; text-align: left; }
.tree-button:hover { color: var(--cyan); background: rgba(104,215,232,.05); }
.tree-button small { display: block; margin-top: 4px; color: #606a75; font-size: 7px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.definition-picker { position: absolute; right: 20px; bottom: 22px; z-index: 9; width: min(520px, calc(100% - 40px)); max-height: 340px; overflow: auto; border: 1px solid var(--cyan); background: #0c1015; box-shadow: 13px 13px 0 rgba(0,0,0,.5); }
.definition-picker header { display: flex; justify-content: space-between; align-items: center; padding: 12px 14px; border-bottom: 1px solid var(--line); color: var(--cyan); font-size: 9px; }
.definition-picker header button, .route-picker header button { color: var(--muted); font-size: 18px; }
#definition-options { display: grid; }
.definition-option { padding: 12px 14px; border: 0; border-bottom: 1px solid var(--line); background: transparent; cursor: pointer; text-align: left; }
.definition-option:hover { background: rgba(104,215,232,.06); }
.definition-option strong { color: var(--ink); font-size: 9px; font-weight: 500; }
.definition-option span { display: block; margin-top: 5px; color: var(--muted); font-size: 8px; }

.route-picker { position: fixed; inset: 48px 0 0 auto; z-index: 20; width: min(560px, 100%); overflow-y: auto; padding: 35px; border-left: 1px solid var(--line-bright); background: #0c0f14; box-shadow: -25px 0 70px rgba(0,0,0,.55); }
.route-picker header { display: flex; justify-content: space-between; gap: 20px; }
.route-picker h2 { margin: 0; font-family: var(--sans); font-size: 31px; letter-spacing: -.04em; }
.route-picker > p { color: var(--muted); font-family: var(--sans); font-size: 13px; line-height: 1.6; }
#route-list { display: grid; gap: 9px; margin-top: 28px; }
.route-card { padding: 18px; border: 1px solid var(--line); background: var(--panel); cursor: pointer; text-align: left; }
.route-card:hover { border-color: var(--cyan); }
.route-card span { color: var(--red); font-size: 7px; }
.route-card strong { display: block; margin: 9px 0; font-family: var(--sans); font-size: 17px; }
.route-card small { display: block; color: var(--muted); font-family: var(--sans); font-size: 12px; line-height: 1.5; }

@media (max-width: 820px) {
  body { overflow: auto; }
  .topbar { grid-template-columns: 1fr auto; }
  .topbar > span { display: none; }
  .workspace { display: flex; height: auto; min-height: calc(100vh - 48px); flex-direction: column; }
  .guide-pane { max-height: none; overflow: visible; border-right: 0; border-bottom: 1px solid var(--line); }
  .editor { min-height: 650px; }
  .source-code { height: 570px; min-height: 0; font-size: 10px; }
  .editor-toolbar { grid-template-columns: auto auto 1fr; }
  .line-badge { display: none; }
  .breadcrumbs { padding-inline: 10px; }
  .editor-notice { align-items: flex-start; flex-direction: column; }
  .file-tree { top: 50px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: .001ms !important; }
}
