/* ------------------------------------------------------------------ tokens */

:root {
  /* the sign system */
  --yellow: #FFCC00;
  --yellow-lift: #FFD84A;
  --yellow-press: #EDBC00;
  --black: #0B0B0B;
  --frame: #1A1A1A;
  --white: #FFFFFF;
  --sign-ink-2: #4A3B00;         /* secondary text on yellow, tinted from it */

  /* shell (day: the yellow panel) */
  --shell: var(--yellow);
  --shell-ink: var(--black);
  --shell-ink-2: var(--sign-ink-2);
  --shell-rule: var(--black);
  --shell-hover: rgba(11, 11, 11, 0.08);
  --shell-press: rgba(11, 11, 11, 0.14);
  --solid: var(--black);         /* filled controls on the shell */
  --solid-ink: var(--yellow);
  --mark-bg: var(--black);
  --mark-ink: var(--yellow);
  --guide-bg: var(--black);

  /* code panels (inset backplates) */
  --panel: #0B0B0B;
  --gutter: #141414;
  --panel-rule: #262626;
  --panel-edge: transparent;
  --panel-border: 1px solid var(--black);
  --panel-shadow: none;
  --solid-hover: #262626;
  --c-text: #E8E8E8;
  --c-dim: #8C8C8C;
  --c-num-line: #6E6E6E;
  --c-key: #FFCC00;
  --c-kw: #8FC8FF;
  --c-str: #FFFFFF;
  --c-num: #7FE0A4;
  --c-lit: #FF9E7A;
  --c-sym: #BFC6CE;
  --c-tag: #D6B8FF;
  --c-cmt: #8F8F8F;
  --c-dis: #767676;
  --c-brk: #8A8A8A;
  --c-bad: #FF6A5C;
  --route: #FFCC00;              /* the active route: yellow, as on the signs */
  --route-tint: rgba(255, 204, 0, 0.16);

  /* type */
  --sans: "Signika", "Segoe UI", system-ui, -apple-system, sans-serif;
  --mono: "Atkinson Mono", ui-monospace, "Cascadia Mono", Consolas, Menlo, monospace;
  --code-size: 14px;
  --lh: 22px;

  /* rhythm */
  --r: 4px;
  --r-panel: 6px;
  --gap: 12px;

  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --shell: #111111;
    --shell-ink: #F2F2F2;
    --shell-ink-2: #A9A9A9;
    --shell-rule: #2C2C2C;
    --shell-hover: rgba(255, 255, 255, 0.07);
    --shell-press: rgba(255, 255, 255, 0.12);
    --solid: var(--yellow);
    --solid-ink: var(--black);
    --mark-bg: var(--yellow);
    --mark-ink: var(--black);
    --panel: #070707;
    --gutter: #0F0F0F;
    --panel-rule: #222222;
    --panel-edge: #262626;
    --panel-border: 1px solid #262626;
    --panel-shadow: none;
    --solid-hover: var(--yellow-lift);
    --guide-bg: #070707;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --shell: #111111;
  --shell-ink: #F2F2F2;
  --shell-ink-2: #A9A9A9;
  --shell-rule: #2C2C2C;
  --shell-hover: rgba(255, 255, 255, 0.07);
  --shell-press: rgba(255, 255, 255, 0.12);
  --solid: var(--yellow);
  --solid-ink: var(--black);
  --mark-bg: var(--yellow);
  --mark-ink: var(--black);
  --panel: #070707;
  --gutter: #0F0F0F;
  --panel-rule: #222222;
  --panel-edge: #262626;
  --panel-border: 1px solid #262626;
  --panel-shadow: none;
  --solid-hover: var(--yellow-lift);
  --guide-bg: #070707;
  color-scheme: dark;
}

/* ------------------------------------------------------------------ base */

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

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--shell);
  color: var(--shell-ink);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.45;
  font-feature-settings: "tnum" 1;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

svg { width: 1em; height: 1em; flex: none; }

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

button { cursor: pointer; }

::selection { background: var(--black); color: var(--yellow); }

:focus-visible { outline: 3px solid var(--shell-ink); outline-offset: 2px; }

code, kbd { font-family: var(--mono); }

.sr-only {
  position: absolute !important;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0);
  white-space: nowrap; border: 0;
}

[hidden] { display: none !important; }

/* ------------------------------------------------------------------ app grid */

.app {
  height: 100vh;
  height: 100dvh;
  min-height: 600px;
  display: grid;
  grid-template-columns: 264px minmax(0, 1fr);
  grid-template-rows: auto minmax(0, 1fr) auto;
  grid-template-areas:
    "top top"
    "rail work"
    "status status";
}

/* ------------------------------------------------------------------ top bar */

.top {
  grid-area: top;
  display: flex;
  align-items: center;
  gap: 20px;
  min-height: 64px;
  padding: 10px 16px;
  padding-top: calc(10px + env(safe-area-inset-top, 0px));
  border-bottom: 2px solid var(--shell-rule);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  color: inherit;
  text-decoration: none;
  min-width: 0;
  margin-right: 4px;
  border-radius: var(--r);
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: var(--r);
  background: var(--mark-bg);
  color: var(--mark-ink);
  font-size: 30px;
}

.brand-text { display: grid; line-height: 1.1; min-width: 0; }
.brand-name { font-size: 21px; font-weight: 700; letter-spacing: -0.01em; white-space: nowrap; }
.brand-sub { font-size: 14px; color: var(--shell-ink-2); white-space: nowrap; }

/* mode: a standard segmented control in sign livery */
.mode { display: inline-flex; }
.mode-opt { position: relative; display: block; }
.mode-opt input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; }
.mode-opt span {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 42px;
  padding: 0 18px 0 14px;
  border: 2px solid var(--shell-ink);
  font-size: 16px;
  font-weight: 600;
  transition: background-color 140ms cubic-bezier(.2, .8, .2, 1), color 140ms cubic-bezier(.2, .8, .2, 1);
}
.mode-opt span svg { font-size: 20px; }
.mode-opt + .mode-opt span { border-left-width: 0; }
.mode-opt:first-child span { border-radius: var(--r) 0 0 var(--r); }
.mode-opt:last-child span { border-radius: 0 var(--r) var(--r) 0; }
.mode-opt input:hover + span { background: var(--shell-hover); }
.mode-opt input:checked + span { background: var(--solid); color: var(--solid-ink); border-color: var(--solid); }
.mode-opt input:focus-visible + span { outline: 3px solid var(--shell-ink); outline-offset: 3px; }

.top-actions { margin-left: auto; display: flex; align-items: center; gap: 8px; }

/* ------------------------------------------------------------------ buttons */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 40px;
  padding: 0 14px;
  border: 2px solid var(--shell-ink);
  border-radius: var(--r);
  background: transparent;
  font-size: 15px;
  font-weight: 600;
  white-space: nowrap;
  transition: background-color 140ms cubic-bezier(.2, .8, .2, 1), transform 140ms cubic-bezier(.2, .8, .2, 1);
}
.btn svg { font-size: 18px; }
.btn:hover { background: var(--shell-hover); }
.btn:active { background: var(--shell-press); transform: translateY(1px); }
.btn:disabled { opacity: .45; cursor: not-allowed; transform: none; }

.btn-primary {
  background: var(--solid);
  color: var(--solid-ink);
  border-color: var(--solid);
  padding-left: 4px;
  gap: 10px;
}
.btn-primary:hover { background: var(--solid-hover); border-color: var(--solid-hover); }
.btn-primary:active { background: var(--solid); }
.btn-sq {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border: 2px solid currentColor;
  border-radius: 2px;
}
.btn-sq svg { font-size: 15px; }

.btn-icon { width: 40px; padding: 0; justify-content: center; }
.btn-icon svg { font-size: 19px; }
.when-night { display: none; }
:root[data-theme="dark"] .when-day { display: none; }
:root[data-theme="dark"] .when-night { display: block; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .when-day { display: none; }
  :root:not([data-theme="light"]) .when-night { display: block; }
}

.btn-small { height: 32px; padding: 0 10px; font-size: 14px; gap: 6px; border-width: 1.5px; }
.btn-small svg { font-size: 15px; }

/* ------------------------------------------------------------------ examples rail */

.rail {
  grid-area: rail;
  border-right: 1px solid var(--shell-rule);
  overflow-y: auto;
  padding: 16px 0 24px;
  scrollbar-width: thin;
}
.rail-title {
  margin: 0 16px 10px;
  font-size: 17px;
  font-weight: 700;
}
.examples { list-style: none; margin: 0; padding: 0; }
.examples li + li .ex { border-top: 1px solid var(--shell-rule); }

.ex {
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr);
  align-items: center;
  column-gap: 12px;
  width: 100%;
  padding: 11px 16px;
  border: 0;
  background: transparent;
  text-align: left;
  transition: background-color 140ms cubic-bezier(.2, .8, .2, 1);
}
.ex:hover { background: var(--shell-hover); }
.ex:focus-visible { outline-offset: -3px; }
.ex-code svg { font-size: 24px; }
.ex-code {
  grid-row: span 2;
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  border-radius: var(--r);
  background: var(--black);
  color: var(--white);
  font-family: var(--mono);
  font-weight: 700;
  font-size: 13px;
  letter-spacing: -0.02em;
}
.ex-title { font-size: 16px; font-weight: 600; line-height: 1.2; }
.ex-note { font-size: 13.5px; line-height: 1.3; color: var(--shell-ink-2); }

.ex[aria-pressed="true"] { background: var(--solid); color: var(--solid-ink); }
.ex[aria-pressed="true"] .ex-note { color: inherit; opacity: .82; }
.ex[aria-pressed="true"] .ex-code { background: var(--solid-ink); color: var(--solid); }

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

.work {
  grid-area: work;
  display: grid;
  grid-template-columns: minmax(0, 0.74fr) minmax(0, 1.26fr);
  grid-template-rows: auto minmax(0, 1fr);
  column-gap: var(--gap);
  padding: var(--gap) 16px var(--gap) var(--gap);
  min-height: 0;
}

/* Both panes share one header row, so their panels always line up even
   when the output options wrap. */
.pane {
  display: grid;
  grid-row: span 2;
  grid-template-rows: subgrid;
  min-height: 0;
  min-width: 0;
}

.pane-head {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  align-content: flex-start;
  gap: 8px 14px;
  min-height: 52px;
  padding: 0 2px 8px;
}
.pane-title {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0;
  font-size: 19px;
  font-weight: 700;
}
.sq {
  display: inline-grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 3px;
  background: var(--mark-bg);
  color: var(--mark-ink);
  font-size: 18px;
}
.pane-actions { margin-left: auto; display: flex; gap: 6px; }

/* ------------------------------------------------------------------ options */

.opts {
  margin: 0 0 0 auto;
  padding: 0;
  border: 0;
  min-width: 0;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px 12px;
}
.opts:disabled .opt-beautify { opacity: .42; }
.opt { display: inline-flex; align-items: center; gap: 8px; font-size: 14px; font-weight: 600; }
.opt-label { font-weight: 600; }

.switch { position: relative; cursor: pointer; }
.switch input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.sw {
  position: relative;
  width: 36px;
  height: 22px;
  border: 2px solid var(--shell-ink);
  border-radius: 11px;
  transition: background-color 160ms cubic-bezier(.2, .8, .2, 1);
}
.sw::after {
  content: "";
  position: absolute;
  top: 2px; left: 2px;
  width: 14px; height: 14px;
  border-radius: 50%;
  background: var(--shell-ink);
  transition: transform 160ms cubic-bezier(.2, .8, .2, 1), background-color 160ms;
}
.switch input:checked + .sw { background: var(--solid); border-color: var(--solid); }
.switch input:checked + .sw::after { transform: translateX(14px); background: var(--solid-ink); }
.switch input:focus-visible + .sw { outline: 3px solid var(--shell-ink); outline-offset: 2px; }
.switch input:disabled { cursor: not-allowed; }

.seg { gap: 0; }
.seg .opt-label { margin-right: 8px; }
.seg label { position: relative; }
.seg input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; }
.seg span:not(.opt-label) {
  display: grid;
  place-items: center;
  min-width: 30px;
  height: 28px;
  border: 1.5px solid var(--shell-ink);
  font-family: var(--mono);
  font-weight: 700;
  font-size: 13px;
}
.seg label + label span { border-left-width: 0; }
.seg label:first-of-type span { border-radius: 3px 0 0 3px; }
.seg label:last-of-type span { border-radius: 0 3px 3px 0; }
.seg input:hover + span { background: var(--shell-hover); }
.seg input:checked + span { background: var(--solid); color: var(--solid-ink); border-color: var(--solid); }
.seg input:focus-visible + span { outline: 3px solid var(--shell-ink); outline-offset: 2px; position: relative; z-index: 1; }
.seg input:disabled { cursor: not-allowed; }

.sel select {
  appearance: none;
  height: 28px;
  padding: 0 26px 0 9px;
  border: 1.5px solid var(--shell-ink);
  border-radius: 3px;
  background: transparent url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5 6 6.5 11 1.5' fill='none' stroke='%230B0B0B' stroke-width='2'/%3E%3C/svg%3E") no-repeat right 8px center / 11px 8px;
  font-family: var(--mono);
  font-weight: 700;
  font-size: 13px;
  cursor: pointer;
}
:root[data-theme="dark"] .sel select { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5 6 6.5 11 1.5' fill='none' stroke='%23F2F2F2' stroke-width='2'/%3E%3C/svg%3E"); }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .sel select { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5 6 6.5 11 1.5' fill='none' stroke='%23F2F2F2' stroke-width='2'/%3E%3C/svg%3E"); }
}
.sel select:hover { background-color: var(--shell-hover); }
.sel select:disabled { cursor: not-allowed; }
.sel option { background: var(--black); color: var(--white); }

/* ------------------------------------------------------------------ panels */

.panel {
  position: relative;
  min-height: 0;
  border-radius: var(--r-panel);
  background: var(--panel);
  color: var(--c-text);
  overflow: hidden;
  border: var(--panel-border);
  box-shadow: var(--panel-shadow);
}
.directory { border: var(--panel-border); }
.panel :focus-visible { outline-color: var(--yellow); }
.panel ::selection { background: rgba(255, 204, 0, .34); color: inherit; }

.panel-out {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
}
.panel-out > .out-scroll { grid-row: 2; grid-column: 1; }

/* more output to the right: an arrow locked to that edge */
.edge-cue {
  grid-row: 2;
  grid-column: 1;
  justify-self: end;
  align-self: stretch;
  z-index: 2;
  display: grid;
  align-items: center;
  justify-items: end;
  width: 56px;
  padding: 0 8px 0 0;
  border: 0;
  background: linear-gradient(to right, transparent, var(--panel) 70%);
}
.edge-sq {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 3px;
  background: var(--yellow);
  color: var(--black);
  font-size: 20px;
}

/* code text shared by the input highlight, the textarea and the output */
.hl, #input, .out {
  margin: 0;
  font-family: var(--mono);
  font-size: var(--code-size);
  line-height: var(--lh);
  font-variant-ligatures: none;
  font-feature-settings: "tnum" 0, "calt" 0;
  tab-size: 2;
  letter-spacing: 0;
}

/* gutter + line numbers */
.l {
  position: relative;
  min-height: var(--lh);
}
.hl .l { counter-increment: ln; }
.hl .l::before {
  content: counter(ln);
  position: absolute;
  left: -60px;
  top: 0;
  width: 48px;
  padding-right: 12px;
  text-align: right;
  color: var(--c-num-line);
  font-size: 12.5px;
  font-feature-settings: "tnum" 1;
  user-select: none;
  -webkit-user-select: none;
}

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

.editor {
  position: absolute;
  inset: 0;
}
.editor::before {
  content: "";
  position: absolute;
  top: 0; bottom: 0; left: 0;
  width: 48px;
  background: var(--gutter);
  border-right: 1px solid var(--panel-rule);
  pointer-events: none;
}

.hl, #input {
  position: absolute;
  inset: 0;
  padding: 14px 16px 40px 60px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  word-break: normal;
  scrollbar-gutter: stable;
}
.hl { overflow: hidden; pointer-events: none; color: var(--c-text); }
.hl code { display: block; counter-reset: ln; font: inherit; }

#input {
  width: 100%;
  height: 100%;
  border: 0;
  resize: none;
  background: transparent;
  color: transparent;
  caret-color: var(--yellow);
  overflow: auto;
  outline: none;
  scrollbar-width: thin;
  scrollbar-color: #3A3A3A transparent;
}
#input::placeholder { color: var(--c-dim); }
#input::selection { background: rgba(255, 204, 0, .34); color: transparent; }
.editor:focus-within::after {
  content: "";
  position: absolute;
  inset: 0;
  border: 2px solid var(--yellow);
  border-radius: var(--r-panel);
  pointer-events: none;
  opacity: .9;
}

/* error line in input: the number turns into an alert badge */
.l.el::before { color: var(--black); background: var(--c-bad); font-weight: 700; }
.err { text-decoration: underline wavy var(--c-bad); text-decoration-thickness: 1.5px; text-underline-offset: 4px; }
.hl .on { background: var(--route-tint); box-shadow: 0 0 0 1px var(--route-tint); }

/* ------------------------------------------------------------------ the sign */

.sign {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 14px;
  margin: 8px 8px 0;
  padding: 10px 16px 10px 10px;
  min-height: 78px;
  border-radius: 3px;
  background: var(--yellow);
  color: var(--black);
}

.sign-go {
  display: grid;
  place-items: center;
  width: 52px;
  height: 52px;
  border: 0;
  border-radius: 3px;
  background: var(--black);
  color: var(--white);
  font-size: 30px;
  transition: transform 160ms cubic-bezier(.2, .8, .2, 1);
}
.sign-go:hover { transform: scale(1.04); }
.sign-go:active { transform: scale(.97); }
.sign-go:focus-visible { outline: 3px solid var(--black); outline-offset: 3px; }
.sign-go svg { transition: transform 200ms cubic-bezier(.2, .8, .2, 1); }
.sign-go[data-dir="up"] svg { transform: rotate(-90deg); }
.sign-go[data-dir="down"] svg { transform: rotate(90deg); }
.sign-go[data-dir="left"] svg { transform: rotate(180deg); }

.sign-body { min-width: 0; display: grid; gap: 1px; }

.sign-path {
  font-family: var(--mono);
  font-size: 21px;
  font-weight: 700;
  line-height: 28px;
  letter-spacing: -0.02em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sign-path .plain { font-family: var(--sans); letter-spacing: -0.01em; }
.sign-path .br { font-weight: 400; }
.seg-btn {
  padding: 0 1px;
  border: 0;
  border-radius: 2px;
  background: none;
  font: inherit;
  letter-spacing: inherit;
  color: inherit;
  cursor: pointer;
}
.seg-btn:hover { background: rgba(11, 11, 11, .12); text-decoration: underline; text-decoration-thickness: 2px; text-underline-offset: 4px; }
.seg-btn:focus-visible { outline: 2px solid var(--black); outline-offset: 1px; }
.seg-btn[aria-current="location"] { cursor: default; }
.seg-btn[aria-current="location"]:hover { background: none; text-decoration: none; }
.sign-path .sp { white-space: pre; }

.sign-meta {
  font-size: 15px;
  font-weight: 500;
  color: var(--sign-ink-2);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.btn-sign {
  height: 34px;
  padding: 0 12px;
  border: 2px solid var(--black);
  font-size: 14px;
}
.btn-sign:hover { background: rgba(11, 11, 11, .1); }
.btn-sign:focus-visible { outline-color: var(--black); }

.sign-stat {
  display: grid;
  justify-items: end;
  padding-left: 16px;
  border-left: 2px solid var(--black);
  line-height: 1;
}
.stat-big {
  font-size: 50px;
  line-height: .9;
  font-weight: 700;
  letter-spacing: -0.03em;
  font-feature-settings: "tnum" 1, "lnum" 1;
}
.stat-small {
  margin-top: 4px;
  font-size: 13px;
  font-weight: 500;
  color: var(--sign-ink-2);
  white-space: nowrap;
  font-feature-settings: "tnum" 1;
}

.sign.is-error .sign-go { background: var(--black); color: var(--c-bad); }
.sign.is-error .sign-path { font-family: var(--sans); letter-spacing: -0.01em; white-space: normal; line-height: 1.2; font-size: 19px; }
.sign.is-empty .sign-copy, .sign.is-error .sign-copy { display: none; }

/* split-flap swap: the message rolls in from below */
.flap { animation: flap 200ms cubic-bezier(.16, 1, .3, 1); }
@keyframes flap {
  from { transform: translateY(45%); opacity: .1; clip-path: inset(0 0 45% 0); }
  to { transform: none; opacity: 1; clip-path: inset(0 0 0 0); }
}

/* ------------------------------------------------------------------ output */

.out-scroll {
  position: relative;
  min-height: 0;
  overflow: auto;
  scrollbar-width: thin;
  scrollbar-color: #3A3A3A transparent;
  outline: none;
}
.out-scroll:focus-visible { box-shadow: inset 0 0 0 2px var(--yellow); }

.out-scroll {
  background: linear-gradient(to right, var(--gutter) 48px, var(--panel-rule) 48px 49px, transparent 49px);
}
.out-grid {
  display: grid;
  grid-template-columns: 49px max-content;
  min-height: 100%;
}
.out-grid.wrap { grid-template-columns: 49px minmax(0, 1fr); }

.gut {
  position: sticky;
  left: 0;
  z-index: 1;
  padding: 14px 0 48px;
  background: var(--gutter);
  border-right: 1px solid var(--panel-rule);
  color: var(--c-num-line);
  font-family: var(--mono);
  font-size: 12.5px;
  line-height: var(--lh);
  text-align: right;
  user-select: none;
  -webkit-user-select: none;
}
.gut div { height: var(--lh); padding-right: 12px; }

.out {
  padding: 14px 32px 48px 14px;
  white-space: pre;
  color: var(--c-text);
}
.out code { display: block; font: inherit; }
.out-grid.wrap .out { white-space: pre-wrap; overflow-wrap: anywhere; }
.out-grid.stale .out { opacity: .32; filter: saturate(.3); transition: opacity 200ms; }

/* active route: line numbers become a yellow route bar */
.gut .rt { background: var(--route); color: var(--black); font-weight: 700; }
.out .on { background: var(--route-tint); border-radius: 2px; box-shadow: 0 0 0 1px rgba(255, 204, 0, .45); }
.out .brk.on { color: var(--route); font-weight: 800; background: rgba(255, 204, 0, .2); }
.out [data-i] { cursor: pointer; }
.out-scroll.flash .on { animation: flash 900ms cubic-bezier(.2, .8, .2, 1); }
@keyframes flash {
  0%, 30% { background: rgba(255, 204, 0, .55); }
  100% { background: var(--route-tint); }
}

/* syntax */
.kw { color: var(--c-kw); }
.kw.key, .str.key, .sym.key { color: var(--c-key); }
.ns { opacity: .68; }
.str { color: var(--c-str); }
.num { color: var(--c-num); }
.chr { color: var(--c-num); }
.lit { color: var(--c-lit); }
.rx { color: var(--c-lit); }
.sym { color: var(--c-sym); }
.tag { color: var(--c-tag); }
.meta { color: var(--c-tag); }
.cmt { color: var(--c-cmt); font-style: italic; }
.dis { color: var(--c-dis); text-decoration: line-through; text-decoration-color: rgba(118, 118, 118, .6); }
.brk { color: var(--c-brk); }
.bad { color: var(--black); background: var(--c-bad); border-radius: 2px; }

/* empty state, pointing at the input by edge rule */
.empty {
  position: absolute;
  inset: 0;
  display: grid;
  align-content: center;
  justify-items: start;
  gap: 6px;
  padding: 24px 40px;
  background: var(--panel);
}
.empty-sq {
  display: grid;
  place-items: center;
  width: 64px;
  height: 64px;
  margin-bottom: 12px;
  border-radius: 3px;
  background: var(--yellow);
  color: var(--black);
  font-size: 40px;
}
.empty-sq svg { transform: rotate(180deg); }
.empty-title { margin: 0; font-size: 30px; font-weight: 700; letter-spacing: -0.02em; color: var(--white); line-height: 1.1; }
.empty-sub { margin: 0; font-size: 17px; color: var(--c-dim); }

/* scrollbars inside panels */
.panel ::-webkit-scrollbar { width: 12px; height: 12px; }
.panel ::-webkit-scrollbar-track { background: transparent; }
.panel ::-webkit-scrollbar-thumb { background: #333; border: 3px solid var(--panel); border-radius: 6px; }
.panel ::-webkit-scrollbar-thumb:hover { background: #555; }
.panel ::-webkit-scrollbar-corner { background: transparent; }

/* ------------------------------------------------------------------ status bar */

.status {
  grid-area: status;
  display: flex;
  align-items: center;
  gap: 14px;
  min-height: 36px;
  padding: 6px 16px;
  padding-bottom: calc(6px + env(safe-area-inset-bottom, 0px));
  border-top: 1px solid var(--shell-rule);
  font-size: 14px;
  font-weight: 500;
}
.st-state { display: inline-flex; align-items: center; gap: 8px; min-width: 0; font-weight: 600; }
.st-state .st-sq {
  display: inline-grid;
  place-items: center;
  width: 20px;
  height: 20px;
  border-radius: 2px;
  background: var(--mark-bg);
  color: var(--mark-ink);
  font-size: 14px;
  flex: none;
}
.st-state.is-error .st-sq { background: var(--c-bad); color: var(--black); }
.st-state .st-msg { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.st-jump {
  border: 0;
  padding: 0;
  background: none;
  font-weight: 700;
  text-decoration: underline;
  text-decoration-thickness: 2px;
  text-underline-offset: 3px;
}
.st-sep { flex: 1; }
.st-pos, .st-bytes { white-space: nowrap; }
.st-bytes { color: var(--shell-ink-2); }
.st-local { color: var(--shell-ink-2); white-space: nowrap; }

/* ------------------------------------------------------------------ guide (directory sign) */

.guide {
  padding: 56px 16px 72px;
  padding-bottom: calc(72px + env(safe-area-inset-bottom, 0px));
  border-top: 2px solid var(--shell-rule);
}
.guide-inner { max-width: 1120px; margin: 0 auto; }
.guide-title {
  margin: 0 0 24px;
  font-size: clamp(28px, 3.4vw, 44px);
  font-weight: 700;
  letter-spacing: -0.025em;
  line-height: 1.05;
  text-wrap: balance;
}
.directory {
  margin: 0;
  border-radius: var(--r-panel);
  background: var(--guide-bg);
  color: #E6E6E6;
  overflow: hidden;
}
.dir-row {
  display: grid;
  grid-template-columns: 240px minmax(0, 1fr);
  gap: 24px;
  padding: 20px 24px;
}
.dir-row + .dir-row { border-top: 1px solid #262626; }
.dir-row dt {
  display: flex;
  align-items: center;
  gap: 12px;
  align-self: start;
  color: var(--yellow);
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.01em;
}
.dir-row dt .sq { background: var(--yellow); color: var(--black); width: 34px; height: 34px; font-size: 20px; }
.dir-row dd {
  margin: 0;
  max-width: 68ch;
  font-size: 16px;
  line-height: 1.55;
  padding-top: 4px;
}
.dir-row code {
  padding: 1px 5px;
  border-radius: 3px;
  background: #1C1C1C;
  color: var(--c-kw);
  font-size: .9em;
}
.keys { display: flex; flex-wrap: wrap; gap: 8px 22px; }
kbd {
  display: inline-block;
  min-width: 26px;
  padding: 1px 6px;
  border: 1.5px solid #555;
  border-bottom-width: 3px;
  border-radius: 4px;
  font-size: 13px;
  font-weight: 700;
  text-align: center;
  color: var(--white);
}

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

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(52px + env(safe-area-inset-bottom, 0px));
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 12px;
  max-width: min(560px, calc(100vw - 32px));
  padding: 8px 10px 8px 8px;
  border-radius: var(--r);
  background: var(--black);
  color: var(--white);
  box-shadow: 0 10px 30px -8px rgba(0, 0, 0, .5);
  transform: translateX(-50%);
  animation: toast-in 220ms cubic-bezier(.16, 1, .3, 1);
}
.toast-sq {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 2px;
  background: var(--yellow);
  color: var(--black);
  font-size: 18px;
  flex: none;
}
.toast-text { font-size: 15px; font-weight: 500; }
.toast-action {
  margin-left: 4px;
  height: 30px;
  padding: 0 10px;
  border: 1.5px solid var(--yellow);
  border-radius: 3px;
  background: none;
  color: var(--yellow);
  font-weight: 700;
}
.toast-action:hover { background: rgba(255, 204, 0, .14); }
.toast-action:focus-visible { outline-color: var(--yellow); }
@keyframes toast-in {
  from { transform: translate(-50%, 12px); opacity: 0; }
  to { transform: translate(-50%, 0); opacity: 1; }
}

/* ------------------------------------------------------------------ responsive */

@media (max-width: 1240px) {
  .brand-sub { display: none; }
  .sign-stat .stat-big { font-size: 42px; }
}

/* examples become a horizontal strip */
@media (max-width: 1100px) {
  .app {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto auto minmax(0, 1fr) auto;
    grid-template-areas: "top" "rail" "work" "status";
  }
  .rail {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 16px;
    border-right: 0;
    border-bottom: 1px solid var(--shell-rule);
    overflow-x: auto;
    overflow-y: hidden;
  }
  .rail-title { margin: 0; font-size: 15px; flex: none; }
  .examples { display: flex; gap: 8px; }
  .examples li + li .ex { border-top: 0; }
  .ex {
    grid-template-columns: 34px auto;
    column-gap: 9px;
    padding: 5px 12px 5px 5px;
    border: 1.5px solid var(--shell-rule);
    border-radius: var(--r);
    white-space: nowrap;
  }
  .ex-code { grid-row: auto; width: 34px; height: 34px; font-size: 11px; border-radius: 3px; }
  .ex-title { font-size: 15px; }
  .ex-note { display: none; }
  .work { padding: var(--gap) 16px; }
  .sign-copy { display: none; }
}

/* panes stack; the page scrolls instead of the panes */
@media (max-width: 820px) {
  .app { height: auto; min-height: 0; grid-template-rows: auto auto auto auto; }
  .top { flex-wrap: wrap; gap: 12px; }
  .top-actions { margin-left: auto; }
  .mode { order: 3; width: 100%; }
  .mode-opt { flex: 1; }
  .mode-opt span { justify-content: center; }
  .work { grid-template-columns: minmax(0, 1fr); }
  .pane-in .panel { height: 42vh; min-height: 260px; }
  .pane-out .panel { height: 70vh; min-height: 420px; }
  .opts { margin-left: 0; width: 100%; }
  .pane-out .pane-head { row-gap: 10px; }
  .status { flex-wrap: wrap; row-gap: 2px; }
  .st-local { display: none; }
  .dir-row { grid-template-columns: minmax(0, 1fr); gap: 10px; padding: 18px 18px; }
  .empty-sq svg { transform: rotate(-90deg); }
}

@media (max-width: 560px) {
  :root { --code-size: 13px; --lh: 21px; }
  .top { gap: 10px 8px; padding-left: 12px; padding-right: 12px; }
  .brand { gap: 10px; }
  .brand-name { font-size: 17px; }
  .brand-mark { width: 38px; height: 38px; font-size: 25px; }
  .top-actions { gap: 6px; }
  .btn-icon, #share, .btn-primary { width: 38px; height: 38px; }
  .out { padding-right: 16px; }
  #share span { display: none; }
  #share { width: 40px; padding: 0; justify-content: center; }
  .btn-primary span:last-child { display: none; }
  .btn-primary { width: 40px; padding: 0; justify-content: center; }
  .btn-primary .btn-sq { border: 0; }
  .sign { grid-template-columns: auto minmax(0, 1fr); gap: 12px; padding-right: 12px; }
  .sign-go { width: 46px; height: 46px; font-size: 26px; }
  .sign-path { font-size: 18px; }
  .sign-meta { font-size: 14px; }
  .sign-stat { grid-column: 1 / -1; grid-template-columns: auto 1fr; align-items: baseline; justify-items: start; gap: 10px; padding: 8px 0 0; border-left: 0; border-top: 2px solid var(--black); }
  .stat-big { font-size: 34px; }
  .hl, #input { padding-right: 10px; }
  .empty { padding: 24px; }
  .empty-title { font-size: 24px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 1ms !important; animation-iteration-count: 1 !important; transition-duration: 1ms !important; }
  .flap { animation: none; }
}

/* ------------------------------------------------------------------ late additions: states */

.opt.is-off { opacity: .42; }
.opt.is-off, .opt.is-off * { cursor: not-allowed; }

/* very large input: plain text, no overlay */
#input.plain { color: var(--c-text); }

/* error excerpt in the output */
.out .xl { background: rgba(255, 106, 92, .14); }
.out .xc { color: var(--c-bad); }
.out .xcaret { font-weight: 800; }
.out .xmsg { font-family: var(--sans); font-weight: 600; font-size: 15px; }
.gut .bad-ln { background: var(--c-bad); color: var(--black); font-weight: 700; }

/* numbers that change in place keep their width */
.stat-big, .stat-small, .sign-meta, .sign-path, .status, .st-pos, .st-bytes, .gut, .hl .l::before, .toast-text {
  font-variant-numeric: tabular-nums lining-nums;
}

/* ------------------------------------------------------------------ files, JSON, nesting */

.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }

#opt-nested span:not(.opt-label) {
  padding: 0 7px;
  font-family: var(--sans);
  font-size: 13.5px;
  font-weight: 600;
}

.sign.is-json .sign-copy { display: none; }

/* drop target over the input editor */
.drop {
  position: absolute;
  inset: 0;
  z-index: 3;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 4px;
  border: 3px dashed var(--yellow);
  border-radius: var(--r-panel);
  background: rgba(11, 11, 11, .94);
  color: var(--white);
  text-align: center;
  pointer-events: none;
}
.drop-sq {
  display: grid;
  place-items: center;
  width: 64px;
  height: 64px;
  margin-bottom: 10px;
  border-radius: 3px;
  background: var(--yellow);
  color: var(--black);
  font-size: 40px;
}
.drop-title { margin: 0; font-size: 26px; font-weight: 700; letter-spacing: -0.02em; }
.drop-sub { margin: 0; font-size: 15px; color: var(--c-dim); }

@media (max-width: 560px) {
  #download span { display: none; }
  #download { width: 38px; height: 38px; padding: 0; justify-content: center; }
}

@media (max-width: 820px) {
  .pane { grid-row: auto; grid-template-rows: auto minmax(0, 1fr); }
  .work { grid-template-rows: none; row-gap: var(--gap); }
}
@media (max-width: 420px) {
  .brand-name { white-space: normal; max-width: 7.2em; font-size: 16px; line-height: 1.05; }
  .top-actions { gap: 4px; }
  .top-actions .btn { width: 36px; height: 36px; }
}
