/* FRACTAL · The Shell — hangar prototype. Working tool, not canon.
   Skin: the FRACTAL identity (Site/site.css is the source of the language —
   black & white, luxury-minimal, sans, both modes, hairlines, content floating in space).
   Tokens mirrored from the site's design system; shell-specific extensions kept in its spirit. */

:root {
  --bg: #ffffff;
  --ink: #0a0a0a;
  --muted: #6e6e73;
  --faint: #a1a1a6;
  --hairline: rgba(10, 10, 10, 0.12);
  --hairline-soft: rgba(10, 10, 10, 0.06);
  --code-bg: rgba(10, 10, 10, 0.035);
  --nav-bg: rgba(255, 255, 255, 0.72);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #000000;
    --ink: #f5f5f7;
    --muted: #86868b;
    --faint: #58585c;
    --hairline: rgba(245, 245, 247, 0.16);
    --hairline-soft: rgba(245, 245, 247, 0.08);
    --code-bg: rgba(245, 245, 247, 0.055);
    --nav-bg: rgba(0, 0, 0, 0.65);
  }
}
:root[data-theme="dark"] {
  --bg: #000000;
  --ink: #f5f5f7;
  --muted: #86868b;
  --faint: #58585c;
  --hairline: rgba(245, 245, 247, 0.16);
  --hairline-soft: rgba(245, 245, 247, 0.08);
  --code-bg: rgba(245, 245, 247, 0.055);
  --nav-bg: rgba(0, 0, 0, 0.65);
}

* { box-sizing: border-box; }
:root { --nav-w: 300px; }       /* adjustable 180–300 via the drag handle; text stays at design width */
:root { --cockpit-w: 380px; }   /* the summoned pane's width; adjustable 300–560 */
html, body { height: 100%; }
body {
  margin: 0;
  display: grid;
  grid-template: "top top" 46px "nav main" 1fr / var(--nav-w) 1fr;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text", "Segoe UI", Inter, Helvetica, Arial, sans-serif;
  font-size: 1rem;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
::selection { background: rgba(128, 128, 132, 0.25); }
button { font: inherit; }

/* ── top bar (the site's nav.top language) ─────────────── */
#topbar {
  grid-area: top;
  display: flex; align-items: center; gap: 1.6rem;
  padding: 0 1.1rem;
  background: var(--nav-bg);
  -webkit-backdrop-filter: saturate(1.6) blur(18px);
  backdrop-filter: saturate(1.6) blur(18px);
  border-bottom: 1px solid var(--hairline-soft);
}
#brand { font-size: 0.78rem; white-space: nowrap; color: var(--muted); }
#brand .mark { color: var(--ink); font-weight: 600; letter-spacing: 0.08em; }
#brand em { font-style: normal; color: var(--faint); }
/* the tier pills live at the top of the rail (Max's call, 2026-08-26) */
#tiers { display: flex; gap: 0.5rem; padding: 0.95rem 1rem 0.1rem; }
.tier {
  font-size: 0.78rem; padding: 0.3rem 0.85rem;
  border-radius: 999px; border: 1px solid var(--hairline);
  background: transparent; color: var(--muted); cursor: pointer;
  transition: color 120ms ease, background 120ms ease, border-color 120ms ease;
  white-space: nowrap;
}
.tier:hover { color: var(--ink); border-color: var(--ink); }
.tier.active { background: var(--ink); color: var(--bg); border-color: var(--ink); }
/* the layout menu — the split icon opens it; a window arrangement is a choice, not a mode */
#layout-btn {
  background: none; border: none; cursor: pointer;
  color: var(--muted);
  font-size: 0.95rem; line-height: 1;
  padding: 0.25rem 0.1rem;
  transition: color 120ms ease;
}
#layout-btn:hover, #layout-btn[aria-expanded="true"] { color: var(--ink); }
#layout-menu {
  position: fixed; top: 46px; right: 0.6rem; z-index: 20;
  display: flex; flex-direction: column;
  min-width: 15rem;
  background: var(--nav-bg);
  -webkit-backdrop-filter: saturate(1.6) blur(18px);
  backdrop-filter: saturate(1.6) blur(18px);
  border: 1px solid var(--hairline-soft);
  border-radius: 0 0 12px 12px;
  padding: 0.35rem;
}
#layout-menu[hidden] { display: none; }
#layout-menu button {
  text-align: left;
  font-size: 0.8rem;
  color: var(--muted);
  background: none; border: none; border-radius: 8px;
  padding: 0.45rem 0.7rem; cursor: pointer;
  transition: color 120ms ease;
  white-space: nowrap;
}
#layout-menu button:hover { color: var(--ink); }
#status {
  margin-left: auto;
  font-size: 0.72rem; letter-spacing: 0.01em;
  color: var(--faint);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  max-width: 42vw;
}
#status.err { color: var(--ink); font-weight: 550; }
#theme {
  background: none; border: none; cursor: pointer;
  color: var(--muted);
  font-size: 0.95rem; line-height: 1;
  padding: 0.25rem 0.1rem;
  transition: color 120ms ease;
}
#theme:hover { color: var(--ink); }

/* ── the left rail — the quest map ─────────────────────── */
#nav {
  grid-area: nav;
  display: flex; flex-direction: column;
  border-right: 1px solid var(--hairline-soft);
  overflow-y: auto;
  overflow-x: hidden;          /* narrowing clips the fixed-width text — no reflow */
  background: var(--bg);
}
#tiers, #quest, #explorer-wrap, #nav-foot { width: 300px; min-width: 300px; }

/* the drag handle — a hairline seam that follows the rail's edge */
#nav-resize {
  position: fixed;
  top: 46px; bottom: 0;
  left: calc(var(--nav-w) - 3px);
  width: 7px;
  cursor: col-resize;
  z-index: 5;
}
#nav-resize:hover { background: linear-gradient(to right, transparent 2px, var(--hairline) 3px, var(--hairline) 4px, transparent 5px); }
body.resizing { cursor: col-resize; user-select: none; }
body.resizing iframe { pointer-events: none; }   /* keep the drag alive over framed docs */
#quest { padding: 1.1rem 1rem 0.4rem; }
#quest .chapter summary, #explorer-wrap h3 {
  margin: 1.6rem 0.35rem 0.5rem;
  font-size: 0.72rem; font-weight: 600;
  letter-spacing: 0.14em; text-transform: uppercase;
  color: var(--faint);
}
#quest .chapter summary {
  cursor: pointer; list-style: none; user-select: none;
  transition: color 120ms ease;
}
#quest .chapter summary::-webkit-details-marker { display: none; }
#quest .chapter summary::before { content: "▸  "; font-size: 0.85em; }
#quest .chapter[open] > summary::before { content: "▾  "; }
#quest .chapter summary:hover { color: var(--ink); }
#quest .chapter:first-child summary { margin-top: 0.2rem; }
#quest .chapter .chapter { margin-left: 0.85rem; }
#quest .chapter .chapter summary { margin: 0.7rem 0.35rem 0.3rem; }
.station {
  display: block; width: 100%; text-align: left;
  color: var(--muted);
  background: none; border: none; border-radius: 8px;
  padding: 0.42rem 0.55rem; cursor: pointer;
  transition: color 120ms ease;
  line-height: 1.35;
}
.station:hover { color: var(--ink); }
.station.active { color: var(--ink); }
.station .blurb {
  display: block; font-size: 0.75rem; color: var(--faint);
  letter-spacing: 0.01em;
}
.station.active .blurb { color: var(--muted); }

/* ── explorer (local tier) ─────────────────────────────── */
#explorer-wrap { border-top: 1px solid var(--hairline-soft); padding: 0.3rem 1rem 1rem; }
#root-name { color: var(--muted); text-transform: none; letter-spacing: 0; font-weight: 500; }
#explorer { font-size: 0.85rem; }
#explorer details { margin-left: 0.7rem; }
#explorer summary {
  cursor: pointer; color: var(--muted);
  padding: 0.12rem 0.3rem; border-radius: 6px;
  list-style: none; user-select: none;
  transition: color 120ms ease;
}
#explorer summary::before { content: "▸ "; font-size: 0.72em; color: var(--faint); }
#explorer details[open] > summary::before { content: "▾ "; }
#explorer summary:hover { color: var(--ink); }
.file-btn {
  display: block; width: 100%; text-align: left;
  font-size: 0.85rem;
  color: var(--muted);
  background: none; border: none; border-radius: 6px;
  padding: 0.12rem 0.3rem; margin-left: 0.7rem; cursor: pointer;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  transition: color 120ms ease;
}
.file-btn:hover { color: var(--ink); }
#nav-foot {
  margin-top: auto;
  padding: 0.9rem 1.35rem;
  font-size: 0.7rem; letter-spacing: 0.02em;
  color: var(--faint);
  border-top: 1px solid var(--hairline-soft);
}

/* ── content ───────────────────────────────────────────── */
#content { grid-area: main; overflow: hidden; display: flex; background: var(--bg); }
#content iframe { flex: 1; border: none; background: #fff; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) #content iframe { background: #000; } }
:root[data-theme="dark"] #content iframe { background: #000; }
#content .reader { flex: 1; overflow-y: auto; }
#content .reader article {
  max-width: 44rem; margin: 0 auto;
  padding: 3.4rem 1.5rem 7rem;
}

/* the reading surface — the site's floating-section typography */
.reader h1, .reader h2, .reader h3, .reader h4 { line-height: 1.2; letter-spacing: -0.02em; color: var(--ink); }
.reader h1 { font-size: clamp(1.9rem, 4.5vw, 2.6rem); font-weight: 700; margin: 2.2em 0 0.7em; }
.reader h2 { font-size: clamp(1.4rem, 3vw, 1.8rem); font-weight: 650; margin: 2em 0 0.7em; }
.reader h3 { font-size: 1.12rem; font-weight: 600; letter-spacing: -0.01em; margin: 1.8em 0 0.5em; }
.reader h4 { font-size: 1rem; font-weight: 600; margin: 1.6em 0 0.4em; }
.reader h1:first-child { margin-top: 0; }
.reader p { margin: 0 0 1.1rem; color: var(--muted); }
.reader p strong, .reader li strong, .reader p b, .reader li b { color: var(--ink); font-weight: 550; }
.reader li { color: var(--muted); margin: 0.25rem 0; }
.reader a { color: var(--ink); text-decoration: none; border-bottom: 1px solid var(--hairline); transition: border-color 0.2s ease; }
.reader a:hover { border-color: var(--ink); }
.reader blockquote {
  margin: 1.4rem 0; padding: 0.15rem 1.2rem;
  border-left: 1px solid var(--hairline);
  color: var(--muted);
}
.reader blockquote p { color: var(--muted); margin: 0.6rem 0; }
.reader code {
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 0.84em;
  background: var(--code-bg);
  border: 1px solid var(--hairline-soft);
  border-radius: 6px;
  padding: 0.08em 0.4em;
  color: var(--ink);
}
.reader pre {
  background: var(--code-bg);
  border: 1px solid var(--hairline-soft);
  border-radius: 12px;
  padding: 0.85rem 1.1rem;
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 0.84rem;
  line-height: 1.55;
  overflow-x: auto;
}
.reader pre code { background: none; border: none; padding: 0; }
.reader table {
  border-collapse: collapse; margin: 1.4rem 0;
  display: block; overflow-x: auto;
  font-size: 0.92rem;
}
.reader th, .reader td {
  border: none; border-top: 1px solid var(--hairline-soft);
  padding: 0.6rem 1.1rem 0.6rem 0;
  text-align: left; vertical-align: top;
  color: var(--muted);
}
.reader th {
  font-size: 0.75rem; font-weight: 600;
  letter-spacing: 0.14em; text-transform: uppercase;
  color: var(--faint);
  border-top: none;
}
.reader tbody tr:last-child td { border-bottom: 1px solid var(--hairline-soft); }
.reader hr { border: none; border-top: 1px solid var(--hairline-soft); margin: 2.6rem 0; }
.wikiref { color: var(--ink); border-bottom: 1px dotted var(--hairline); }

/* the welcome pane — same language, quieter */
.welcome h1 { font-weight: 700; letter-spacing: -0.02em; }
.welcome .hint { color: var(--faint); font-size: 0.85rem; }

/* the idle screen — no window selected: just the bare background.
   Future home of the subtle graphics (they mount here, nowhere else). */
#screen-idle { flex: 1; background: var(--bg); }

/* ── the cockpit — summonable-pane #1 (the pattern later panes repeat:
      a grid column, the hidden-attribute toggle, a topbar button).
      Two default layouts (Max's call): screen left · cockpit right, or the mirror.
      Direction of record: all windows behave as the same shell — open, close, arrange. ── */
body.cockpit-open { grid-template: "top top top" 46px "nav main cockpit" 1fr / var(--nav-w) 1fr var(--cockpit-w); }
body.cockpit-open.cockpit-left { grid-template: "top top top" 46px "nav cockpit main" 1fr / var(--nav-w) var(--cockpit-w) 1fr; }
body.cockpit-left #cockpit { border-left: none; border-right: 1px solid var(--hairline-soft); }
#reader-btn {
  background: none; border: none; cursor: pointer;
  color: var(--muted);
  font-size: 0.95rem; line-height: 1;
  padding: 0.25rem 0.1rem;
  transition: color 120ms ease;
}
#reader-btn:hover, #reader-btn.on { color: var(--ink); }
#cockpit {
  grid-area: cockpit;
  display: flex; flex-direction: column;
  min-width: 0; min-height: 0; overflow: hidden;   /* the log scrolls; the grid never grows */
  border-left: 1px solid var(--hairline-soft);
  background: var(--bg);
}
#cockpit[hidden] { display: none; }   /* display:flex must not defeat the hidden toggle */
#cockpit-resize {
  display: none;
  position: fixed;
  top: 46px; bottom: 0;
  right: calc(var(--cockpit-w) - 4px);
  width: 7px;
  cursor: col-resize;
  z-index: 5;
}
body.cockpit-left #cockpit-resize { right: auto; left: calc(var(--nav-w) + var(--cockpit-w) - 3px); }
body.cockpit-open #cockpit-resize { display: block; }
#cockpit-resize:hover { background: linear-gradient(to right, transparent 2px, var(--hairline) 3px, var(--hairline) 4px, transparent 5px); }
#cockpit-head {
  display: flex; align-items: baseline; gap: 0.7rem;
  padding: 0.75rem 1.1rem 0.55rem;
  border-bottom: 1px solid var(--hairline-soft);
}
#cockpit-head .label {
  font-size: 0.72rem; font-weight: 600;
  letter-spacing: 0.14em; text-transform: uppercase;
  color: var(--faint);
}
#cockpit-state { flex: 1; text-align: right; font-size: 0.72rem; color: var(--faint); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#cockpit-state.live { color: var(--muted); }
#cockpit-btns { display: flex; gap: 0.15rem; align-self: center; }
.cp-btn {
  background: none; border: none; cursor: pointer;
  color: var(--faint); font-size: 0.85rem; line-height: 1;
  padding: 0.1rem 0.2rem;
  transition: color 120ms ease;
}
.cp-btn:hover { color: var(--ink); }
#cockpit.as-pane .win-only { display: none; }
#cockpit.as-window .pane-only { display: none; }

/* ── the rider — the cockpit folded, resting on a workspace border (2026-08-27).
      There is no bar object: the top/bottom/left/right borders themselves are the
      dock — all four magnetic, for the rider and for the window's edges. ── */
/* depth grammar (Max's 3D pass, restrained): what floats casts shadow and lifts
   in the hand; what docks flattens into the frame. Elevation, never perspective.
   The rider is a BUBBLE (Max's sketch): the ⎈ mark on the border; hover blooms
   the menu — the two doors emerge as satellite bubbles fanned into the workspace. */
#rider {
  position: fixed; z-index: 16;
  width: 69px; height: 69px;         /* 46 +50% (Max's call); the satellites stay 34 */
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg);
  border: 1px solid var(--hairline);
  cursor: grab; user-select: none;
  touch-action: none;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.10);
  transition: box-shadow 160ms ease, transform 160ms ease;
}
#rider:hover { box-shadow: 0 5px 20px rgba(0, 0, 0, 0.16); }
#rider.lift { transform: scale(1.06); box-shadow: 0 14px 36px rgba(0, 0, 0, 0.28); }
#rider[hidden] { display: none; }
#rider[data-edge="bottom"] { bottom: 6px; }
#rider[data-edge="top"]    { top: 52px; }                       /* 46 topbar + the standoff */
#rider[data-edge="left"]   { left: calc(var(--nav-w) + 6px); }
#rider[data-edge="right"]  { right: 6px; }
/* the orb — the bubble's living face (the 21st.dev voice orb's shader, ours to
   drive: idle breathing, the hover and the hand stir it; no microphone here) */
#rider-orb {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  border-radius: 50%;
  pointer-events: none;
}
#rider .r-mark {
  position: relative; z-index: 2;
  font-size: 1.2rem; line-height: 1;
  color: #fff;
  text-shadow: 0 1px 6px rgba(0, 0, 0, 0.55);
  transition: color 120ms ease;
}
#rider.no-orb .r-mark { color: var(--muted); text-shadow: none; }
#rider.no-orb:hover .r-mark { color: var(--ink); }

/* the bloom — hidden satellites scale out on hover/focus; a hide delay keeps them
   alive while the pointer crosses the small gap; the lift (dragging) closes them */
#rider .sat {
  position: absolute;
  width: 34px; height: 34px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg);
  border: 1px solid var(--hairline);
  color: var(--muted); font-size: 0.82rem; line-height: 1;
  cursor: pointer;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.12);
  opacity: 0; transform: scale(0.4); pointer-events: none;
  transition: opacity 140ms ease, transform 140ms ease, color 120ms ease, border-color 120ms ease;
  transition-delay: 180ms;
}
#rider:hover .sat, #rider:focus .sat, #rider:focus-within .sat {
  opacity: 1; transform: scale(1); pointer-events: auto;
  transition-delay: 0ms;
}
#rider.lift .sat { opacity: 0; pointer-events: none; transition-delay: 0ms; }
#rider .sat:hover { color: var(--ink); border-color: var(--ink); }
/* the satellites bloom fully CLEAR of the bubble (no overlap — Max's call):
   69px bubble + 8px void gap = 77px; the hide delay bridges the crossing */
#rider[data-edge="bottom"] #rider-pane { bottom: 77px; left: -12px; }
#rider[data-edge="bottom"] #rider-mini { bottom: 77px; right: -12px; }
#rider[data-edge="top"]    #rider-pane { top: 77px; left: -12px; }
#rider[data-edge="top"]    #rider-mini { top: 77px; right: -12px; }
#rider[data-edge="left"]   #rider-pane { left: 77px; top: -12px; }
#rider[data-edge="left"]   #rider-mini { left: 77px; bottom: -12px; }
#rider[data-edge="right"]  #rider-pane { right: 77px; top: -12px; }
#rider[data-edge="right"]  #rider-mini { right: 77px; bottom: -12px; }
/* corner care: near a border's ends the fan folds inward (t-start/t-end via JS) */
#rider.t-end[data-edge="left"] #rider-mini,
#rider.t-end[data-edge="right"] #rider-mini { bottom: auto; top: 34px; }
#rider.t-start[data-edge="left"] #rider-pane,
#rider.t-start[data-edge="right"] #rider-pane { top: auto; bottom: 34px; }
#rider.t-end[data-edge="top"] #rider-mini,
#rider.t-end[data-edge="bottom"] #rider-mini { right: 0; }
#rider.t-start[data-edge="top"] #rider-pane,
#rider.t-start[data-edge="bottom"] #rider-pane { left: 0; }
/* free = beyond every border's reach: the bubble rides the hand — only the edge
   anchors release (after the data-edge rules on purpose); inline left/top steer */
#rider.free { inset: auto; }

/* the window's shadow — the deferred morph's ghost */
#win-shadow {
  position: fixed; z-index: 14;
  border: 1px dashed var(--hairline);
  border-radius: 14px;
  background: var(--code-bg);
  pointer-events: none;
}
#win-shadow[hidden] { display: none; }

/* ── the window — the same cockpit, floating. "Mini" is not a second thing:
      it is this window with one border held on a workspace border (a corner: two).
      Held sides flatten; data-att lists them space-separated. ── */
#cockpit.as-window {
  position: fixed; z-index: 15;
  border: 1px solid var(--hairline);
  border-radius: 14px;
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.22);
  overflow: hidden;
  transition: box-shadow 160ms ease, border-radius 160ms ease;   /* attach morphs, drags stay 1:1 */
}
#cockpit.as-window #cockpit-head { cursor: grab; }
#cockpit.as-window.in-hand { box-shadow: 0 34px 96px rgba(0, 0, 0, 0.30); }
#cockpit.as-window.attached { box-shadow: 0 10px 40px rgba(0, 0, 0, 0.14); }
#cockpit.as-window.attached[data-att~="bottom"] { border-bottom-left-radius: 0; border-bottom-right-radius: 0; }
#cockpit.as-window.attached[data-att~="top"]    { border-top-left-radius: 0; border-top-right-radius: 0; }
#cockpit.as-window.attached[data-att~="left"]   { border-top-left-radius: 0; border-bottom-left-radius: 0; }
#cockpit.as-window.attached[data-att~="right"]  { border-top-right-radius: 0; border-bottom-right-radius: 0; }

/* resize handles — live only in window state; the dock-side ones become
   pull-away grips when attached (moving that border IS the detach gesture) */
.win-h { display: none; position: absolute; z-index: 3; touch-action: none; }
#cockpit.as-window .win-h { display: block; }
.win-h.n  { top: 0; left: 12px; right: 12px; height: 6px; cursor: ns-resize; }
.win-h.s  { bottom: 0; left: 12px; right: 12px; height: 6px; cursor: ns-resize; }
.win-h.e  { right: 0; top: 12px; bottom: 12px; width: 6px; cursor: ew-resize; }
.win-h.w  { left: 0; top: 12px; bottom: 12px; width: 6px; cursor: ew-resize; }
.win-h.ne { top: 0; right: 0; width: 12px; height: 12px; cursor: nesw-resize; }
.win-h.nw { top: 0; left: 0; width: 12px; height: 12px; cursor: nwse-resize; }
.win-h.se { bottom: 0; right: 0; width: 12px; height: 12px; cursor: nwse-resize; }
.win-h.sw { bottom: 0; left: 0; width: 12px; height: 12px; cursor: nesw-resize; }

body.dragging { user-select: none; cursor: grabbing; }
body.dragging iframe { pointer-events: none; }   /* keep the drag alive over framed docs */
#cockpit-log { flex: 1; overflow-y: auto; padding: 0.9rem 1.1rem; font-size: 0.92rem; }
#cockpit-log .who {
  margin: 1.1rem 0 0.3rem;
  font-size: 0.68rem; font-weight: 600;
  letter-spacing: 0.14em; text-transform: uppercase;
  color: var(--faint);
}
#cockpit-log .who:first-child { margin-top: 0; }
#cockpit-log .you-text { color: var(--ink); white-space: pre-wrap; }
#cockpit-log .agent-text { color: var(--muted); white-space: pre-wrap; }
#cockpit-log .agent-text.md { white-space: normal; }
#cockpit-log .agent-text.md p { margin: 0 0 0.7rem; }
#cockpit-log .act {
  margin: 0.25rem 0;
  font-size: 0.8rem; color: var(--faint);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
#cockpit-log .act b { color: var(--muted); font-weight: 550; }
#cockpit-log .note { margin: 0.4rem 0; font-size: 0.8rem; color: var(--faint); }
#cockpit-log .note.err { color: var(--ink); }
/* the C-008 moment — the one card in the pane */
.gate-card {
  margin: 0.7rem 0;
  padding: 0.7rem 0.9rem;
  border: 1px solid var(--hairline);
  border-radius: 12px;
}
.gate-card .gate-tool { font-weight: 600; color: var(--ink); font-size: 0.86rem; }
.gate-card .gate-detail {
  margin: 0.25rem 0 0.6rem;
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 0.74rem; color: var(--muted);
  word-break: break-all;
}
.gate-card .gate-verdict { font-size: 0.8rem; color: var(--muted); }
.gate-btn {
  font-size: 0.8rem; padding: 0.25rem 0.8rem; margin-right: 0.45rem;
  border-radius: 999px; border: 1px solid var(--hairline);
  background: transparent; color: var(--muted); cursor: pointer;
  transition: color 120ms ease, background 120ms ease, border-color 120ms ease;
}
.gate-btn:hover { color: var(--ink); border-color: var(--ink); }
.gate-btn.allow:hover { background: var(--ink); color: var(--bg); }
#cockpit-form {
  position: relative;                /* hosts the composer's top-edge drag seam */
  display: flex; align-items: flex-end; gap: 0.5rem;
  padding: 0.7rem 0.9rem 0.9rem;
  border-top: 1px solid var(--hairline-soft);
}
#input-seam {
  position: absolute; top: -4px; left: 0; right: 0; height: 8px;
  cursor: ns-resize; z-index: 2; touch-action: none;
}
#input-seam:hover { background: linear-gradient(to bottom, transparent 3px, var(--hairline) 4px, var(--hairline) 5px, transparent 6px); }
#cockpit-input {
  flex: 1; resize: none;
  font: inherit; font-size: 0.92rem; line-height: 1.5;
  color: var(--ink); background: var(--code-bg);
  border: 1px solid var(--hairline-soft); border-radius: 12px;
  padding: 0.55rem 0.8rem;
  outline: none;
}
#cockpit-input:focus { border-color: var(--hairline); }
#cockpit-input { scrollbar-width: none; }        /* two rows; overflow scrolls with the caret */
#cockpit-input::-webkit-scrollbar { display: none; }
#cockpit-controls { display: flex; flex-direction: column; gap: 0.35rem; align-items: stretch; }
#cockpit-send, #cockpit-stop {
  font-size: 0.85rem; padding: 0.3rem 0.7rem;
  border-radius: 999px; border: 1px solid var(--hairline);
  background: transparent; color: var(--muted); cursor: pointer;
  transition: color 120ms ease, background 120ms ease, border-color 120ms ease;
  white-space: nowrap;
}
#cockpit-send:hover:not(:disabled) { background: var(--ink); color: var(--bg); border-color: var(--ink); }
#cockpit-send:disabled { opacity: 0.35; cursor: default; }
#cockpit-stop:hover { color: var(--ink); border-color: var(--ink); }

/* ── small screens: the rail folds under, the cockpit docks below ── */
@media (max-width: 760px) {
  body { grid-template: "top" 46px "nav" auto "main" 1fr / 1fr; }
  body.cockpit-open, body.cockpit-open.cockpit-left { grid-template: "top" 46px "nav" auto "main" 1fr "cockpit" 46vh / 1fr; }
  #nav { grid-area: nav; max-height: 38vh; border-right: none; border-bottom: 1px solid var(--hairline-soft); }
  #tiers, #quest, #explorer-wrap, #nav-foot { width: auto; min-width: 0; }
  #nav-resize { display: none; }
  #content { grid-area: main; }
  #cockpit.as-pane { border-left: none; border-top: 1px solid var(--hairline-soft); }
  body.cockpit-open #cockpit-resize { display: none; }
  #status { display: none; }
  #rider[data-edge="left"] { left: 6px; }
}

/* ═══════════════════════════════════════════════════════════════════════════
   SKIN · station — the first experimental theme (hidden; Max's direction,
   2026-08-27). Black cards floating in dark empty space as one coherent
   structure: no stars, no scenery — the void, the cards, the light. The docks
   live in the void channels between the cards and the outer frame; the
   bubbles float there, gated by the frame. 'classic' (default, no data-skin)
   stays byte-identical — the permanent fallback.
   Absorbed from the 21st.dev examples as TECHNIQUES, never identity:
   the radial top glow · the hairline light seam · card elevation on dark ·
   the blur-in arrival · the pointer-tracked border spotlight (the lamp) —
   stripped white, no hue. The dot pattern was deliberately not absorbed
   ("no stars"). Toggle: Alt/Option-click the FRACTAL mark · ?skin=station.
   ═══════════════════════════════════════════════════════════════════════ */
:root[data-skin="station"],
:root[data-skin="station"][data-theme="light"] {
  /* the station is night-side by nature — its palette overrides both modes */
  --bg: #000000;
  --card: #0a0a0d;
  --ink: #f5f5f7;
  --muted: #9a9aa1;
  --faint: #5c5c63;
  --hairline: rgba(245, 245, 247, 0.15);
  --hairline-soft: rgba(245, 245, 247, 0.07);
  --code-bg: rgba(245, 245, 247, 0.05);
  --nav-bg: #0a0a0d;
}
[data-skin="station"] body { background: #000; }
[data-skin="station"] #content iframe { background: #000; }

/* the cards — one structure, four bodies; lit from above, a seam at the top
   edge, and the lamp's sheen drifting across (fixed-attachment radial) */
[data-skin="station"] #topbar,
[data-skin="station"] #nav,
[data-skin="station"] #content {
  position: relative;      /* NOT the cockpit — .as-window must keep its fixed */
}
[data-skin="station"] #cockpit.as-pane { position: relative; }
[data-skin="station"] #topbar,
[data-skin="station"] #nav,
[data-skin="station"] #content,
[data-skin="station"] #cockpit {
  background:
    radial-gradient(240px 240px at var(--mx, -9999px) var(--my, -9999px),
      rgba(255, 255, 255, 0.04), transparent 70%),
    linear-gradient(to bottom, rgba(255, 255, 255, 0.09) 0, transparent 2px),
    radial-gradient(45% 70px at 50% 0%, rgba(255, 255, 255, 0.05), transparent),
    var(--card);
  background-attachment: fixed, scroll, scroll, scroll;
  border: 1px solid var(--hairline-soft);
  border-radius: 16px;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.55);
}
[data-skin="station"] #cockpit.as-window { box-shadow: 0 40px 110px rgba(0, 0, 0, 0.7); }
[data-skin="station"] #cockpit.as-window.in-hand { box-shadow: 0 48px 130px rgba(0, 0, 0, 0.8); }

/* the lamp on the borders — the cursor lights the ring it passes (masked to
   the border band; sits just inside the clip so scrolling cards keep it) */
[data-skin="station"] #topbar::after,
[data-skin="station"] #content::after,
[data-skin="station"] #cockpit::after,
[data-skin="station"] #rider::after,
[data-skin="station"] #rider .sat::after {
  content: "";
  position: absolute; inset: 1px;
  border: 1px solid transparent;
  border-radius: inherit;
  pointer-events: none;
  background: radial-gradient(170px 170px at var(--mx, -9999px) var(--my, -9999px),
    rgba(255, 255, 255, 0.35), transparent 72%) border-box;
  background-attachment: fixed;
  mask: linear-gradient(#fff 0 0) padding-box, linear-gradient(#fff 0 0) border-box;
  mask-composite: exclude;
  -webkit-mask: linear-gradient(#fff 0 0) padding-box, linear-gradient(#fff 0 0) border-box;
  -webkit-mask-composite: xor;
  z-index: 4;
}

/* the bubbles are small cards — the same light language */
[data-skin="station"] #rider,
[data-skin="station"] #rider .sat {
  background:
    radial-gradient(60% 50% at 50% 14%, rgba(255, 255, 255, 0.07), transparent),
    var(--card);
}
[data-skin="station"] #win-shadow { background: rgba(245, 245, 247, 0.03); }

/* ── the structure — the frame that holds everything (Max's correction: real
      girders, not bars — two chords with diagonal lattice web between them,
      spans cut to length, butting into corner gusset NODES; clean square
      edges, nothing overshooting. The MAGNETIC DOCK LINE runs just inside —
      the snap law's own boundary made visible, a light looping it. ── */
#frame { display: none; }
#frame .beam, #frame .node { position: fixed; z-index: 3; pointer-events: none; }
#frame .beam.h {
  height: 14px;
  border-top: 2px solid #454b54;               /* the chords */
  border-bottom: 2px solid #454b54;
  background:                                   /* the lattice web */
    repeating-linear-gradient(45deg, rgba(69, 75, 84, 0.85) 0 2px, transparent 2px 9px),
    #17191d;
}
#frame .beam.v {
  width: 14px;
  border-left: 2px solid #454b54;
  border-right: 2px solid #454b54;
  background:
    repeating-linear-gradient(-45deg, rgba(69, 75, 84, 0.85) 0 2px, transparent 2px 9px),
    #17191d;
}
/* spans: girders butt into the nodes — computed, never eyeballed */
#frame .top  { top: 66px; left: calc(var(--nav-w) + 20px); right: 22px; }
#frame .bot  { bottom: 2px; left: calc(var(--nav-w) + 20px); right: 22px; }
#frame .left  { left: calc(var(--nav-w) + 2px); top: 84px; bottom: 22px; }
#frame .right { right: 2px; top: 84px; bottom: 22px; }
/* the gusset nodes — the four joints that resolve the frame */
#frame .node {
  width: 22px; height: 22px; z-index: 4;
  background: linear-gradient(180deg, #363b43, #24272d);
  border: 1px solid #454b54;
  border-radius: 3px;
}
#frame .node::after {                           /* the fastener */
  content: "";
  position: absolute; inset: 7px;
  border-radius: 50%;
  background: radial-gradient(circle at 40% 35%, #4d545e, #23262b 70%);
}
#frame .tl { left: calc(var(--nav-w) - 2px); top: 62px; }
#frame .tr { right: 0; top: 62px; }
#frame .bl { left: calc(var(--nav-w) - 2px); bottom: 0; }
#frame .br { right: 0; bottom: 0; }
/* the bridges — the top menu and the side menu attach to the structure through
   mounting clamps: each strut bites both the card's edge and the girder's chord */
#frame .bridge {
  position: fixed; z-index: 4; pointer-events: none;
  border: 1px solid #454b54;
  border-radius: 2px;
}
#frame .bridge.tb {
  width: 12px; height: 16px; top: 55px;
  background: linear-gradient(180deg, #3a3f47, #262a30);
}
#frame .bridge.rl {
  width: 16px; height: 12px; left: calc(var(--nav-w) - 9px);
  background: linear-gradient(90deg, #3a3f47, #262a30);
}
#frame .b1 { left: calc(var(--nav-w) + 44px); }
#frame .b2 { left: calc(50% + var(--nav-w) / 2 - 6px); }
#frame .b3 { right: 64px; }
#frame .b4 { top: 110px; }
#frame .b5 { top: calc(50% + 26px); }
#frame .b6 { bottom: 110px; }
/* the void canvas — the workspace ground: an infinite plane, grab and drag to
   pan (the TouchDesigner mechanic); the frame and the menus hold still. With
   the Reader closed its card recedes and the whole framed workspace is open
   canvas — ▤ toggles the Reader back over the plane. */
#void-canvas { display: none; position: fixed; z-index: 0; cursor: grab; touch-action: none; }
#void-canvas.grabbing { cursor: grabbing; }
@media (min-width: 761px) {
  [data-skin="station"] #void-canvas { display: block; }
  [data-skin="station"] #screen-idle { background: transparent; pointer-events: none; }
  [data-skin="station"] body:has(#screen-idle) #content {
    background: none;
    border-color: transparent;
    box-shadow: none;
    pointer-events: none;
  }
  [data-skin="station"] body:has(#screen-idle) #content::after { display: none; }
}

/* the light runs THROUGH the girders (Max's call — no extra line): the comet's
   path is the girder centerline; it threads the lattice and slides under the
   gusset nodes and bridges, which sit a layer above */
#dockline {
  position: fixed; z-index: 3;
  pointer-events: none;
  overflow: visible;
}
#dockline rect { fill: none; }
#dockline rect.comet {
  stroke: rgba(150, 200, 255, 0.75);
  stroke-width: 7;
  stroke-linecap: round;
  filter: drop-shadow(0 0 6px rgba(150, 200, 255, 0.7));
  animation: dock-run 9s linear infinite;
}
@keyframes dock-run { to { stroke-dashoffset: var(--perim, 4000px); } }
@media (prefers-reduced-motion: reduce) {
  #dockline rect.comet { animation: none; visibility: hidden; }
}

/* the structure floats: the frame band (12px) gates the workspace; the cards
   inside sit clear of the dock line (desktop grammar only) */
@media (min-width: 761px) {
  [data-skin="station"] #frame { display: block; }
  [data-skin="station"] body { grid-template: "top top" 64px "nav main" 1fr / var(--nav-w) 1fr; }
  [data-skin="station"] body.cockpit-open { grid-template: "top top top" 64px "nav main cockpit" 1fr / var(--nav-w) 1fr var(--cockpit-w); }
  [data-skin="station"] body.cockpit-open.cockpit-left { grid-template: "top top top" 64px "nav cockpit main" 1fr / var(--nav-w) var(--cockpit-w) 1fr; }
  [data-skin="station"] #topbar { margin: 10px 10px 0 10px; }
  [data-skin="station"] #nav { margin: 10px 5px 10px 10px; }
  [data-skin="station"] #content { margin: 28px 28px 28px 23px; }
  [data-skin="station"] body.cockpit-open:not(.cockpit-left) #content { margin-right: 6px; }
  [data-skin="station"] #cockpit.as-pane { margin: 28px 28px 28px 6px; border-left: 1px solid var(--hairline-soft); border-right: 1px solid var(--hairline-soft); }
  [data-skin="station"] body.cockpit-left #cockpit.as-pane { margin: 28px 6px 28px 23px; }
  [data-skin="station"] body.cockpit-left #content { margin: 28px 28px 28px 6px; }
  [data-skin="station"] #nav-resize, [data-skin="station"] #cockpit-resize { top: 64px; }
  [data-skin="station"] #layout-menu {
    top: 70px; right: 14px;
    border-radius: 12px;
    border: 1px solid var(--hairline-soft);
    background: var(--card);
  }
  /* the bubbles dock on the line, inside the girders: border + 6px standoff */
  [data-skin="station"] #rider[data-edge="bottom"] { bottom: 24px; }
  [data-skin="station"] #rider[data-edge="top"]    { top: 88px; }
  [data-skin="station"] #rider[data-edge="left"]   { left: calc(var(--nav-w) + 24px); }
  [data-skin="station"] #rider[data-edge="right"]  { right: 24px; }
}

/* the arrival — out of the void, blur to sharp (releases after; drags stay 1:1) */
@media (prefers-reduced-motion: no-preference) {
  [data-skin="station"] #topbar,
  [data-skin="station"] #nav,
  [data-skin="station"] #content,
  [data-skin="station"] #cockpit,
  [data-skin="station"] #rider {
    animation: station-arrive 0.55s ease backwards;
  }
  [data-skin="station"] #nav { animation-delay: 0.06s; }
  [data-skin="station"] #content { animation-delay: 0.12s; }
  [data-skin="station"] #cockpit { animation-delay: 0.10s; }
  [data-skin="station"] #rider { animation-delay: 0.18s; }
}
@keyframes station-arrive {
  from { opacity: 0; transform: translateY(8px); filter: blur(5px); }
  to { opacity: 1; transform: none; filter: none; }
}
