/* ==========================================================================
   Notebook prototype — same paper, type and accent as baranbingol1.github.io
   ========================================================================== */

:root {
  --font-sans:  -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
  --font-mono:  ui-monospace, SFMono-Regular, "Cascadia Mono", Menlo, Consolas, "Liberation Mono", monospace;

  --gutter: 3.5rem;
  --measure: 42rem;
  --spring: cubic-bezier(.34, 1.56, .64, 1);
  --ease-out: cubic-bezier(.2, .8, .2, 1);
}

/* Registered colour tokens interpolate, so a theme switch glides instead of
   snapping, and a rapid second click reverses mid-way without a jump. */
@property --bg { syntax: '<color>'; inherits: true; initial-value: #fcfbf9; }
@property --bg-elevated { syntax: '<color>'; inherits: true; initial-value: #f3f1ec; }
@property --bg-code { syntax: '<color>'; inherits: true; initial-value: #f6f4ef; }
@property --text { syntax: '<color>'; inherits: true; initial-value: #17161a; }
@property --muted { syntax: '<color>'; inherits: true; initial-value: #635f57; }
@property --border { syntax: '<color>'; inherits: true; initial-value: #e4e0d6; }
@property --border-strong { syntax: '<color>'; inherits: true; initial-value: #cbc5b7; }
@property --accent { syntax: '<color>'; inherits: true; initial-value: #805b00; }
@property --accent-hover { syntax: '<color>'; inherits: true; initial-value: #634600; }
@property --accent-soft { syntax: '<color>'; inherits: true; initial-value: rgba(128, 91, 0, .09); }
@property --warn { syntax: '<color>'; inherits: true; initial-value: #a2401f; }
@property --warn-soft { syntax: '<color>'; inherits: true; initial-value: rgba(162, 64, 31, .09); }
@property --ok { syntax: '<color>'; inherits: true; initial-value: #116329; }
@property --ok-soft { syntax: '<color>'; inherits: true; initial-value: rgba(17, 99, 41, .1); }
@property --bar-bg { syntax: '<color>'; inherits: true; initial-value: rgba(252, 251, 249, .9); }
@property --t-fn { syntax: '<color>'; inherits: true; initial-value: #6d3ac0; }
@property --t-kw { syntax: '<color>'; inherits: true; initial-value: #b31a24; }
@property --t-num { syntax: '<color>'; inherits: true; initial-value: #0550ae; }
@property --t-var { syntax: '<color>'; inherits: true; initial-value: #953800; }
@property --t-arg { syntax: '<color>'; inherits: true; initial-value: #655e53; }
@property --del-bg { syntax: '<color>'; inherits: true; initial-value: #ffebe9; }
@property --add-bg { syntax: '<color>'; inherits: true; initial-value: #e6ffec; }

:root {
  transition-property: --bg, --bg-elevated, --bg-code, --text, --muted, --border, --border-strong,
    --accent, --accent-hover, --accent-soft, --warn, --warn-soft, --ok, --ok-soft, --bar-bg,
    --t-fn, --t-kw, --t-num, --t-var, --t-arg, --del-bg, --add-bg;
  transition-duration: .5s;
  transition-timing-function: cubic-bezier(.3, .7, .2, 1);
}

:root[data-theme="light"] {
  --bg: #fcfbf9;
  --bg-elevated: #f3f1ec;
  --bg-code: #f6f4ef;
  --text: #17161a;
  --muted: #635f57;
  --border: #e4e0d6;
  --border-strong: #cbc5b7;
  --accent: #805b00;
  --accent-hover: #634600;
  --accent-soft: rgba(128, 91, 0, .09);
  --warn: #a2401f;
  --warn-soft: rgba(162, 64, 31, .09);
  --ok: #116329;
  --ok-soft: rgba(17, 99, 41, .1);
  --bar-bg: rgba(252, 251, 249, .9);
  --shadow: 0 1px 2px rgba(23, 22, 26, .05), 0 6px 18px rgba(23, 22, 26, .07);
  --ambient-ink: #2a2620; --ambient-accent: #805b00; --ambient-alpha: .17;
  --t-fn: #6d3ac0; --t-kw: #b31a24; --t-num: #0550ae; --t-var: #953800; --t-arg: #655e53;
  --del-bg: #ffebe9; --add-bg: #e6ffec;
  --pop-1: #7c3aed; --pop-2: #2563eb; --pop-3: #0d9488; --pop-4: #b07d06; --pop-5: #c2512b;
}

:root[data-theme="dark"] {
  --bg: #141416;
  --bg-elevated: #1c1c1f;
  --bg-code: #1a1a1d;
  --text: #e6e3dd;
  --muted: #a49f96;
  --border: #2b2b2f;
  --border-strong: #3d3d43;
  --accent: #d8ab52;
  --accent-hover: #e8c079;
  --accent-soft: rgba(216, 171, 82, .12);
  --warn: #e0876f;
  --warn-soft: rgba(224, 135, 111, .12);
  --ok: #7ee787;
  --ok-soft: rgba(126, 231, 135, .1);
  --bar-bg: rgba(20, 20, 22, .88);
  --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 6px 18px rgba(0, 0, 0, .35);
  --ambient-ink: #e6e3dd; --ambient-accent: #d8ab52; --ambient-alpha: .2;
  --t-fn: #d2a8ff; --t-kw: #ff7b72; --t-num: #79c0ff; --t-var: #ffa657; --t-arg: #a2a9b1;
  --del-bg: #3d1113; --add-bg: #0f2f1a;
  --pop-1: #a78bfa; --pop-2: #60a5fa; --pop-3: #2dd4bf; --pop-4: #d8ab52; --pop-5: #e0876f;
}

/* ------------------------------- base ---------------------------------- */

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font-serif);
  font-size: 1.0625rem;
  line-height: 1.7;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  padding-bottom: calc(4.75rem + env(safe-area-inset-bottom));
  -webkit-tap-highlight-color: transparent;
}
h1, h2, p, ul, ol, pre { margin: 0; }
a { color: var(--accent); text-decoration: none; text-underline-offset: .18em; }
a:hover { color: var(--accent-hover); text-decoration: underline; }
button { font: inherit; color: inherit; }
kbd {
  font-family: var(--font-mono);
  font-size: .78em;
  padding: .05em .4em;
  border: 1px solid var(--border-strong);
  border-bottom-width: 2px;
  border-radius: 4px;
  background: var(--bg-elevated);
}
.muted { color: var(--muted); }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}
.skip-link {
  position: absolute; left: 1rem; top: -3rem; z-index: 100;
  padding: .5rem .8rem; background: var(--text); color: var(--bg); border-radius: 6px;
  font-family: var(--font-sans); font-size: .9rem;
}
.skip-link:focus { top: .75rem; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

::selection { background: rgba(128, 91, 0, .18); }
:root[data-theme="dark"] ::selection { background: rgba(216, 171, 82, .25); }

/* ------------------------------ header --------------------------------- */

/* The bars are paper only over the reading column; the dither runs
   through the margins on either side, edge to edge. */
.top { position: sticky; top: 0; z-index: 20; }
.top::before, .bar::before {
  content: ""; position: absolute; top: 0; bottom: 0; left: 50%; z-index: -1;
  width: min(100%, calc(var(--measure) + var(--gutter) + 5.5rem));
  transform: translateX(-50%);
  background: var(--bar-bg);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  -webkit-mask-image: linear-gradient(90deg, transparent, #000 3rem, #000 calc(100% - 3rem), transparent);
  mask-image: linear-gradient(90deg, transparent, #000 3rem, #000 calc(100% - 3rem), transparent);
}
.top::before { border-bottom: 1px solid var(--border); }
.bar::before { border-top: 1px solid var(--border); }
@media (max-width: 899px) {
  .top::before, .bar::before { width: 100%; -webkit-mask-image: none; mask-image: none; }
}
.top-inner, .page, .bar-inner {
  max-width: calc(var(--measure) + var(--gutter));
  margin: 0 auto;
  padding: 0 1.25rem;
}
.top-inner {
  display: flex; align-items: center; justify-content: space-between; gap: .75rem;
  min-height: 3.75rem;
}
.name {
  position: relative;
  font-family: "Newsreader", var(--font-serif);
  font-size: 1.28rem; font-weight: 600; letter-spacing: 0;
  white-space: nowrap;
}
.surname {
  /* Padding grows the tap target to 44px; the negative margin keeps layout. */
  border: 0; background: none; padding: .7rem .15rem; margin: -.7rem -.15rem; cursor: pointer;
  letter-spacing: inherit;
}
.bubble {
  position: absolute; left: 2.6rem; top: calc(100% + .6rem); z-index: 30;
  width: max-content; max-width: 15rem; white-space: normal;
  padding: .45rem .7rem;
  font-family: var(--font-serif); font-size: .82rem; font-weight: 500; line-height: 1.4; letter-spacing: 0;
  color: var(--bg); background: var(--text);
  border-radius: 8px; box-shadow: var(--shadow);
  transform-origin: 1.2rem 0;
  animation: pop-in .32s var(--spring) both;
}
.bubble::before {
  content: ""; position: absolute; left: 1rem; top: -5px;
  width: 10px; height: 10px; background: var(--text); transform: rotate(45deg);
}
.bubble:empty { display: none; }
.bubble.out { animation: bubble-out .16s ease-in both; pointer-events: none; }
@keyframes bubble-out { to { opacity: 0; transform: translateY(-3px) scale(.96); } }

.top-actions { display: flex; align-items: center; gap: .45rem; }

.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 2.25rem; height: 2.25rem; padding: 0;
  border: 1px solid var(--border); border-radius: 50%;
  background: var(--bg-elevated); color: var(--muted);
  cursor: pointer;
  transition: color .15s, border-color .15s, background-color .15s, transform .12s;
}
.icon-btn:hover { color: var(--accent); border-color: var(--accent); background: var(--accent-soft); }
.icon-btn:active { transform: scale(.9); }
.icon { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
/* Sound: the speaker draws its waves in, or crosses itself out */
.spk path { transition: stroke-dashoffset .35s var(--ease-out), opacity .2s; }
.spk .spk-body { transform-box: fill-box; transform-origin: right center; }
.spk-w1, .spk-w2, .spk-x { stroke-dasharray: 1; }
.spk-w2 { transition-delay: .07s; }
#sound-toggle[aria-pressed="true"] { color: var(--accent); border-color: var(--accent); }
#sound-toggle[aria-pressed="true"] .spk-w1, #sound-toggle[aria-pressed="true"] .spk-w2 { stroke-dashoffset: 0; }
#sound-toggle[aria-pressed="true"] .spk-x { stroke-dashoffset: 1; opacity: 0; }
#sound-toggle[aria-pressed="false"] .spk-w1, #sound-toggle[aria-pressed="false"] .spk-w2 { stroke-dashoffset: 1; opacity: 0; }
#sound-toggle[aria-pressed="false"] .spk-x { stroke-dashoffset: 0; }
#sound-toggle[aria-pressed="false"] .spk-w2 { transition-delay: 0s; }
#sound-toggle[aria-pressed="false"] .spk-w1 { transition-delay: .05s; }
#sound-toggle.turn-on { animation: squish .45s var(--spring); }
#sound-toggle.turn-on .spk-body { animation: speaker-thump .5s var(--spring); }
#sound-toggle.turn-off { animation: squish-soft .35s var(--ease-out); }
#sound-toggle.turn-off .spk { animation: hush .4s var(--ease-out); }
#sound-toggle.beat .spk-w1 { animation: wave-beat .22s ease-out; }
#sound-toggle.beat .spk-w2 { animation: wave-beat .26s .03s ease-out; }

/* Theme: one sun that becomes a moon. Spin accumulates in JS, so mashing it keeps rolling. */
.theme-btn { position: relative; }
/* The reveal overlay temporarily takes over hit-testing. Keep the switch
   the same color when hover returns as the overlay is removed. */
.theme-btn:hover { background: var(--bg-elevated); border-color: var(--border); color: var(--muted); }
.sunmoon {
  width: 20px; height: 20px; overflow: visible;
  transform: rotate(var(--spin, 0deg));
  transition: transform .75s cubic-bezier(.2, .9, .25, 1.12);
}
.sm-core { fill: currentColor; stroke: none; transform-box: fill-box; transform-origin: center; transition: transform .55s var(--spring); }
.sm-cut { transform-box: fill-box; transform-origin: center; transition: transform .55s var(--spring); }
.sm-rays { transform-box: view-box; transform-origin: 12px 12px; transition: transform .55s var(--spring), opacity .25s ease; }
:is(.theme-btn[data-preview-theme="light"], :root[data-theme="light"] .theme-btn:not([data-preview-theme])) .sm-core { transform: scale(1.75); }
:is(.theme-btn[data-preview-theme="light"], :root[data-theme="light"] .theme-btn:not([data-preview-theme])) .sm-cut { transform: none; }
:is(.theme-btn[data-preview-theme="light"], :root[data-theme="light"] .theme-btn:not([data-preview-theme])) .sm-rays { transform: rotate(-90deg) scale(.35); opacity: 0; }
:is(.theme-btn[data-preview-theme="dark"], :root[data-theme="dark"] .theme-btn:not([data-preview-theme])) .sm-core { transform: scale(1); }
:is(.theme-btn[data-preview-theme="dark"], :root[data-theme="dark"] .theme-btn:not([data-preview-theme])) .sm-cut { transform: translate(9px, -9px) scale(.5); }
:is(.theme-btn[data-preview-theme="dark"], :root[data-theme="dark"] .theme-btn:not([data-preview-theme])) .sm-rays { transform: none; opacity: 1; }
.theme-btn.flip { animation: squish .45s var(--spring); }
/* Kernel status pill */
.kernel {
  position: relative;
  display: inline-flex; align-items: center; gap: .45rem;
  height: 2.25rem; padding: 0 .8rem;
  border: 1px solid var(--border); border-radius: 999px;
  background: var(--bg-elevated);
  font-family: var(--font-sans); font-size: .8rem; color: var(--muted);
  cursor: pointer;
  transition: color .2s, border-color .2s, background-color .2s;
}
.kernel-text { max-width: 9.5rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.kernel-dot {
  width: 9px; height: 9px; border-radius: 50%;
  border: 2px solid var(--muted);
  transition: background-color .2s, border-color .2s, transform .2s;
}
.kernel.jiggle { animation: jiggle .25s ease; }
.kernel[data-state="busy"] { color: var(--accent); border-color: var(--accent); }
.kernel[data-state="busy"] .kernel-dot { background: var(--accent); border-color: var(--accent); animation: pulse 1s ease-in-out infinite; }
.kernel[data-state="doze"] { opacity: .75; }
.kernel[data-state="doze"] .kernel-dot { transform: scale(.7); }
.kernel[data-state="hot"] { color: var(--warn); border-color: var(--warn); background: var(--warn-soft); animation: shake .4s linear infinite; }
.kernel[data-state="hot"] .kernel-dot { background: var(--warn); border-color: var(--warn); }

.zzz, .steam { position: absolute; left: .55rem; bottom: 100%; pointer-events: none; display: none; }
.kernel[data-state="doze"] .zzz { display: block; }
.kernel[data-state="hot"] .steam { display: block; }
.zzz i {
  position: absolute; left: 0; bottom: 0;
  font-family: var(--font-sans); font-style: normal; font-size: .7rem; color: var(--muted);
  opacity: 0; animation: float-z 2.4s ease-in infinite;
}
.zzz i:nth-child(2) { animation-delay: .8s; font-size: .8rem; }
.zzz i:nth-child(3) { animation-delay: 1.6s; font-size: .9rem; }
.steam i {
  position: absolute; left: 0; bottom: 0;
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--warn); opacity: 0;
  animation: steam 1.1s ease-out infinite;
}
.steam i:nth-child(2) { left: 7px; animation-delay: .35s; }
.steam i:nth-child(3) { left: 14px; animation-delay: .7s; }

/* ------------------------------ toolbar -------------------------------- */

.toolbar {
  background: linear-gradient(var(--border), var(--border)) top center / min(100%, calc(var(--measure) + var(--gutter) + 2.5rem)) 1px no-repeat;
}
.no-js .toolbar { display: none; }
.tb-inner {
  max-width: calc(var(--measure) + var(--gutter));
  margin: 0 auto;
  padding: 0 1.25rem 0 .7rem;
  display: flex; align-items: center; gap: .1rem;
  min-height: 2.6rem;
  overflow-x: auto; overscroll-behavior-x: contain;
  scrollbar-width: none;
}
.tb-inner.fade-end { -webkit-mask-image: linear-gradient(to right, #000 calc(100% - 2.5rem), transparent); mask-image: linear-gradient(to right, #000 calc(100% - 2.5rem), transparent); }
.tb-inner.fade-start { -webkit-mask-image: linear-gradient(to left, #000 calc(100% - 2.5rem), transparent); mask-image: linear-gradient(to left, #000 calc(100% - 2.5rem), transparent); }
.tb-inner.fade-start.fade-end { -webkit-mask-image: linear-gradient(to right, transparent, #000 2.5rem, #000 calc(100% - 2.5rem), transparent); mask-image: linear-gradient(to right, transparent, #000 2.5rem, #000 calc(100% - 2.5rem), transparent); }
.tb-inner::-webkit-scrollbar { display: none; }
.tb-btn {
  position: relative; flex: none;
  display: inline-flex; align-items: center; justify-content: center;
  width: 2.1rem; height: 2.1rem; padding: 0;
  border: 0; border-radius: 7px;
  background: none; color: var(--muted);
  cursor: pointer;
  transition: color .15s, background-color .15s, transform .14s var(--ease-out), opacity .2s;
}
.tb-btn:hover { color: var(--text); background: var(--accent-soft); }
.tb-btn:active { transform: translateY(1px) scale(.88); }
.tb-btn[disabled] { opacity: .32; cursor: default; background: none; }
.tb-btn .icon { width: 17px; height: 17px; stroke-width: 1.8; }
.tb-btn .fill { fill: currentColor; stroke: none; }
.tb-btn[data-act="run"]:not([disabled]) { color: var(--accent); }
.tb-sep { flex: none; width: 1px; height: 1.1rem; margin: 0 .35rem; background: var(--border-strong); opacity: .7; }
.tb-type { position: relative; flex: none; display: inline-flex; align-items: center; }
.tb-type::after {
  content: ""; position: absolute; right: .6rem; top: 50%; margin-top: -4px;
  width: 5px; height: 5px; pointer-events: none;
  border-right: 1.5px solid var(--muted); border-bottom: 1.5px solid var(--muted);
  transform: rotate(45deg);
}
.tb-type select {
  -webkit-appearance: none; appearance: none;
  height: 1.95rem; padding: 0 1.7rem 0 .65rem;
  border: 1px solid var(--border); border-radius: 7px;
  background: transparent; color: var(--text);
  font: 600 .8rem var(--font-sans);
  cursor: pointer;
  transition: border-color .15s, background-color .15s;
}
.tb-type select:hover { border-color: var(--accent); background: var(--accent-soft); }
.tb-type select:disabled { opacity: .4; cursor: default; }
.tb-type select option { color: #17161a; background: #fcfbf9; }
.tb-saved {
  /* Shrinks and truncates instead of pushing the toolbar into a horizontal scroll. */
  flex: 0 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis;
  margin-left: auto; padding-left: .9rem;
  font-family: var(--font-sans); font-size: .76rem; color: var(--muted);
  white-space: nowrap; font-variant-numeric: tabular-nums;
}
.tb-saved.flash { animation: saved-flash .9s var(--ease-out); }

/* Each tool answers in its own small way */
.tb-btn.fire .icon { animation: tb-pop .4s var(--spring); }
.tb-btn[data-act="save"].fire .icon { animation: tb-stamp .5s var(--spring); }
.tb-btn[data-act="insert"].fire .icon { animation: tb-turn .45s var(--spring); }
.tb-btn[data-act="cut"].fire .icon { animation: tb-snip .38s ease; }
.tb-btn[data-act="paste"].fire .icon { animation: tb-drop .45s var(--spring); }
.tb-btn .lid { transform-box: fill-box; transform-origin: 85% 100%; }
.tb-btn[data-act="del"].fire .icon { animation: none; }
.tb-btn[data-act="del"].fire .lid { animation: tb-lid .5s var(--spring); }
.tb-btn[data-act="undo"].fire .icon { animation: tb-back .45s var(--spring); }
.tb-btn[data-act="up"].fire .icon { animation: tb-up .35s var(--ease-out); }
.tb-btn[data-act="down"].fire .icon { animation: tb-down .35s var(--ease-out); }
.tb-btn[data-act="run"].fire .icon { animation: tb-go .35s var(--ease-out); }
.tb-btn[data-act="interrupt"].fire .icon { animation: tb-squash .35s var(--spring); }
.tb-btn[data-act="restart"].fire .icon { animation: tb-rewind .6s var(--ease-out); }
.tb-btn[data-act="runall"].fire .icon { animation: tb-ff .5s var(--ease-out); }
.tb-btn.ready { color: var(--accent); }
.tb-btn.ready .icon { animation: tb-drop .45s var(--spring); }
.tb-btn.nope { animation: shake .3s linear 1; }
/* ------------------------------ page ----------------------------------- */

.page { padding-top: 1.75rem; }
.cells { display: flex; flex-direction: column; gap: .35rem; }

/* ------------------------------ cell ----------------------------------- */

.cell {
  position: relative;
  display: grid;
  grid-template-columns: var(--gutter) minmax(0, 1fr);
  padding: .4rem 0;
  border-radius: 8px;
  outline: none;
}
.cell:focus-visible .cell-input { outline: 2px solid var(--accent); outline-offset: 3px; }

.gutter {
  position: relative;
  padding-top: .62rem;
  font-family: var(--font-mono); font-size: .78rem; color: var(--muted);
  font-variant-numeric: tabular-nums;
  transition: color .2s;
}
.cell.is-selected .gutter { color: var(--accent); }
.exec { display: inline-flex; line-height: 1.25; vertical-align: top; }
.count {
  display: block; min-width: 1ch; height: 1.25em;
  overflow: hidden; text-align: center;
}
.roll { display: flex; flex-direction: column; animation: roll .3s var(--ease-out) forwards; }
.roll > span { display: block; height: 1.25em; }
.star, .nf-star {
  /* The font draws * above the middle of the line; spin around the glyph. */
  translate: 0 .15em;
  transform-origin: center calc(50% - .15em);
}
.star { display: inline-block; color: var(--accent); animation: spin .9s linear infinite; }
.roll > .star { animation: none; }

.cell-main { position: relative; min-width: 0; }
.cell-main::before {
  content: ""; position: absolute; left: -.8rem; top: .15rem; bottom: .15rem;
  width: 3px; border-radius: 2px; background: var(--accent);
  transform: scaleY(0); transform-origin: top;
  transition: transform .25s var(--ease-out);
}
.cell.is-selected .cell-main::before { transform: scaleY(1); }

.cell-input {
  position: relative;
  display: flex; align-items: flex-start; gap: .6rem;
  padding: .45rem .45rem .45rem .9rem;
  background: var(--bg-code);
  border: 1px solid var(--border);
  border-radius: 7px;
  overflow: hidden;
  transition: border-color .2s, box-shadow .2s;
}
.cell:hover .cell-input { border-color: var(--border-strong); }
.cell.is-selected .cell-input { border-color: var(--border-strong); box-shadow: var(--shadow); }
.code {
  flex: 1; min-width: 0;
  padding-top: .38rem;
  font-family: var(--font-mono); font-size: .9rem; line-height: 1.55;
  white-space: pre-wrap; word-break: break-word;
}
.code-block { display: flex; flex-direction: column; white-space: pre-wrap; }
.cl { display: block; padding: 0 .25rem; margin: 0 -.25rem; border-radius: 3px; transition: background-color .3s; }
.t-fn { color: var(--t-fn); } .t-kw { color: var(--t-kw); } .t-num { color: var(--t-num); }
.t-var { color: var(--t-var); } .t-arg { color: var(--t-arg); }
.t-num.hot { color: var(--warn); }

/* Busy shimmer along the top edge of a running cell */
.cell-input::after {
  content: ""; position: absolute; left: 0; top: 0; height: 2px; width: 35%;
  background: linear-gradient(90deg, transparent, var(--accent), transparent);
  opacity: 0; transform: translateX(-100%);
}
.cell.is-running .cell-input::after { opacity: 1; animation: shimmer .9s linear infinite; }

/* Run button */
.run {
  position: relative; flex: none;
  display: inline-flex; align-items: center; justify-content: center;
  width: 2.25rem; height: 2.25rem; padding: 0;
  border: 1px solid var(--border-strong); border-radius: 50%;
  background: var(--bg); color: var(--accent);
  cursor: pointer;
  transition: transform .12s var(--ease-out), background-color .15s, border-color .15s, box-shadow .15s;
  box-shadow: 0 2px 0 var(--border-strong);
}
.run svg { width: 15px; height: 15px; fill: currentColor; transition: transform .15s var(--ease-out); }
.run-cue { display: none; }
.first-run .run {
  width: auto; gap: .2rem; padding: 0 .65rem; border-radius: 999px;
  background: var(--accent-soft); border-color: var(--accent);
  animation: first-run-nudge .65s var(--spring) 2;
}
.first-run .run-cue { display: inline; font: 650 .8rem var(--font-sans); }
@keyframes first-run-nudge {
  0%, 100% { transform: scale(1); }
  45% { transform: scale(1.08); box-shadow: 0 0 0 5px var(--accent-soft); }
}
.run:hover { background: var(--accent-soft); border-color: var(--accent); }
.run:hover svg { transform: translateX(1.5px); }
.run:active, .run.pressed { transform: translateY(2px) scale(.94); box-shadow: 0 0 0 var(--border-strong); }
.run::before {
  content: ""; position: absolute; inset: -1px; border-radius: 50%;
  border: 2px solid transparent; border-top-color: var(--accent);
  opacity: 0;
}
.cell.is-running .run::before { opacity: 1; animation: spin .7s linear infinite; }
.ripple {
  position: absolute; inset: 0; border-radius: 50%;
  border: 2px solid var(--accent); pointer-events: none;
  animation: ripple .5s var(--ease-out) forwards;
}

/* Ghost preview of output that has not run yet */
.ghost { display: none; padding: .7rem 0 .2rem .9rem; }
.js .cell:not(.ran) .ghost { display: block; }
.ghost i {
  display: block; height: .5rem; margin-bottom: .45rem;
  border-radius: 4px; background: var(--border);
  opacity: .7;
}
.ghost i:nth-child(1) { width: 72%; }
.ghost i:nth-child(2) { width: 54%; }
.ghost i:nth-child(3) { width: 38%; }

/* Output: collapses to zero rows until run */
.cell-output { display: grid; grid-template-rows: 1fr; transition: grid-template-rows .4s var(--ease-out); }
.js .cell:not(.ran) .cell-output { grid-template-rows: 0fr; }
.out-inner { min-height: 0; overflow: hidden; padding: 0 0 0 .9rem; list-style: none; }
.out-inner > :first-child { margin-top: .8rem; }
.out-inner > :last-child { margin-bottom: .4rem; }

.ln { transition: opacity .28s ease, transform .4s var(--ease-out); }
.ln.pending { opacity: 0; transform: translateY(6px); }

/* whoami */
.meta { font-family: var(--font-sans); font-size: .85rem; color: var(--muted); margin-bottom: .6rem; }
.bio { margin-bottom: .9rem; min-height: 1.7em; }
.bio.typing::after, .bio.scrambling::after {
  content: ""; display: inline-block; width: 2px; height: 1.05em; margin-left: 2px;
  vertical-align: -.15em; background: var(--accent);
  animation: blink .9s steps(1) infinite;
}
.bio.wild { animation: wild .35s steps(3) 3; }
.temp { display: grid; gap: .2rem; max-width: 22rem; font-family: var(--font-sans); font-size: .82rem; color: var(--muted); }
.temp output { font-family: var(--font-mono); color: var(--text); }
.temp input { width: 100%; height: 44px; margin: 0; accent-color: var(--accent); cursor: pointer; }
.temp-scale { display: flex; justify-content: space-between; font-size: .75rem; margin-top: -.6rem; }

/* now */
.now-list li { position: relative; padding-left: 1.2rem; margin-bottom: .35rem; }
.now-list li::before {
  content: ""; position: absolute; left: .1rem; top: .72em;
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--ok); box-shadow: 0 0 0 0 var(--ok); animation: live 1.8s ease-out infinite;
}
.shipping-link { white-space: nowrap; }
.shipping-link .logo { width: 1em; height: 1em; margin-inline-end: .25em; vertical-align: -.12em; fill: currentColor; }

/* projects */
.projects { padding-left: .9rem; }
.proj { border-bottom: 1px solid var(--border); }
.proj:last-child { border-bottom: 0; }
.ln.proj.pending { transform: translateY(-10px); }
.proj-row {
  display: grid; grid-template-columns: minmax(0, 1fr) auto 1rem; align-items: center; gap: .75rem;
  width: 100%; min-height: 2.9rem; padding: .35rem .5rem; margin: 0 -.5rem; width: calc(100% + 1rem);
  border: 0; border-radius: 6px; background: none; text-align: left; cursor: pointer;
  font-family: var(--font-sans);
  transition: background-color .15s;
}
.proj-row:hover { background: var(--accent-soft); }
.proj-row:focus-visible { outline-offset: -2px; }
.proj-row:active { transform: scale(.99); }
.proj-name { font-weight: 650; font-size: .95rem; }
.proj-year { margin-inline-start: .3em; font-size: .82rem; font-weight: 400; color: var(--muted); font-variant-numeric: tabular-nums; }
.proj-what { font-size: .82rem; color: var(--muted); text-align: right; }
.chev {
  width: 8px; height: 8px; justify-self: center;
  border-right: 1.5px solid var(--muted); border-bottom: 1.5px solid var(--muted);
  transform: rotate(-45deg); transition: transform .25s var(--spring);
}
.proj.open .chev { transform: rotate(45deg); }
.proj-more { display: grid; grid-template-rows: 0fr; visibility: hidden; transition: grid-template-rows .3s var(--ease-out); }
.proj-more > div { min-height: 0; overflow: hidden; }
.proj-more p { padding: 0 0 .8rem; font-size: .95rem; }
.proj.open .proj-more { grid-template-rows: 1fr; visibility: visible; }

/* blog */
.posts { list-style: none; padding: 0; margin: .8rem 0 0; display: grid; gap: .5rem; }
.post a {
  display: flex; flex-direction: column; gap: .1rem;
  padding: .7rem .9rem;
  border: 1px solid var(--border); border-radius: 8px;
  background: var(--bg-elevated); color: var(--text);
  transition: transform .2s var(--spring), border-color .15s, box-shadow .2s;
}
.post a:hover { text-decoration: none; transform: translateY(-2px) rotate(-.4deg); border-color: var(--accent); box-shadow: var(--shadow); }
.post a:active { transform: translateY(0) scale(.98); }
.post-title { font-family: var(--font-sans); font-weight: 650; font-size: .95rem; line-height: 1.35; }
.post-meta { font-family: var(--font-sans); font-size: .78rem; color: var(--muted); }
.ln.post.pending { transform: translateY(-18px) rotate(var(--r, -3deg)) scale(.96); }
.ln.post { transition: opacity .3s ease, transform .55s var(--spring); }
.all-posts { margin-top: .7rem; font-family: var(--font-sans); font-size: .85rem; }

/* fix_me */
.traceback {
  padding: .65rem .85rem;
  font-family: var(--font-mono); font-size: .8rem; line-height: 1.55;
  white-space: pre-wrap; word-break: break-word;
  color: var(--warn); background: var(--warn-soft);
  border-left: 3px solid var(--warn); border-radius: 0 6px 6px 0;
}
.traceback.shake { animation: shake .35s linear 1; }
.fix-btn, .copy-btn {
  display: inline-flex; align-items: center; gap: .45rem;
  min-height: 2.75rem; margin-top: .6rem; padding: 0 1rem;
  border: 1px solid var(--accent); border-radius: 999px;
  background: var(--accent); color: var(--bg);
  font-family: var(--font-sans); font-size: .88rem; font-weight: 650;
  cursor: pointer;
  box-shadow: 0 2px 0 var(--accent-hover);
  transition: transform .12s var(--ease-out), box-shadow .12s, background-color .2s, border-color .2s, color .2s;
}
.fix-btn:hover, .copy-btn:hover { background: var(--accent-hover); }
.fix-btn:active, .copy-btn:active { transform: translateY(2px) scale(.97); box-shadow: 0 0 0 var(--accent-hover); }
.fix-btn[disabled] { opacity: .6; cursor: progress; }
.agent-log { font-family: var(--font-mono); font-size: .8rem; color: var(--muted); margin-top: .35rem; }
.agent-log::before { content: "› "; color: var(--accent); }
.ok-line { font-family: var(--font-mono); font-size: .85rem; color: var(--ok); margin-top: .2rem; }
.cl.del { background: var(--del-bg); text-decoration: line-through; text-decoration-color: var(--t-kw); }
.cl.add { background: var(--add-bg); animation: slide-in .4s var(--ease-out); }

/* contact */
.links { list-style: none; padding: 0; margin: .8rem 0 0; }
.links li { margin-bottom: .2rem; }
.links a { display: inline-block; padding: .25rem 0; font-family: var(--font-sans); font-weight: 600; }
.email-row { display: flex; flex-wrap: wrap; align-items: center; gap: .1rem .8rem; margin-top: .3rem; }
.email { font-family: var(--font-mono); font-size: .88rem; margin-top: .6rem; }
.copy-btn .check { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; stroke-dasharray: 22; stroke-dashoffset: 22; display: none; }
.copy-btn.copied { background: var(--ok-soft); border-color: var(--ok); color: var(--ok); box-shadow: 0 2px 0 var(--ok); }
.copy-btn.copied .check { display: block; animation: draw .35s .05s var(--ease-out) forwards; }
.copy-packet {
  position: fixed; z-index: 60; pointer-events: none; padding: .23rem .35rem; border-radius: 4px;
  color: var(--accent); background: var(--bg); box-shadow: 0 0 0 1px var(--accent);
  font: .8rem var(--font-mono); white-space: nowrap;
}

/* ------------------------- editing cells ------------------------------- */

.cell.entering, .cell.is-leaving { overflow: hidden; }
.cell.is-leaving { pointer-events: none; }
.cell-input.born { animation: born .45s var(--spring); }
.cell.copied-flash .cell-input { animation: copied-flash .6s var(--ease-out); }
.cell.nope .cell-input { animation: shake .3s linear 1; }
.cell.bump-up { animation: bump-up .3s var(--ease-out); }
.cell.bump-down { animation: bump-down .3s var(--ease-out); }
.cell-input.retype { animation: born .35s var(--spring); }
.cell-input.shake { animation: shake .35s linear 1; }

/* Scratch cells: visitors type here */
.cell-input:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.scratch-out { font-family: var(--font-mono); font-size: .86rem; line-height: 1.55; white-space: pre-wrap; word-break: break-word; margin-top: .15rem; }
.out-inner > .traceback + .traceback { margin-top: .4rem; }
.interrupt-note { margin-top: .5rem; }
.was-interrupted .ln.pending { display: none; }

/* Cell types */
.cell[data-type] .exec { visibility: hidden; }
.cell[data-type="markdown"] .code { font-family: var(--font-serif); font-size: 1rem; font-style: italic; }
.cell[data-type="raw"] .hl, .cell[data-type="raw"] .hl [class] { color: var(--muted); }
.cell[data-type="markdown"] .hl .md-hash { color: var(--accent); }
.cell[data-type="markdown"] .hl .md-h { font-weight: 650; }
.cell[data-type="raw"] .run { opacity: .45; }

.empty-note { margin: 1rem 0 0 var(--gutter); font-style: italic; color: var(--muted); }
.empty-note[hidden] { display: none; }

/* ------------------------- ambient background -------------------------- */

.ambient { position: fixed; inset: 0; width: 100%; height: 100%; z-index: 0; pointer-events: none; opacity: 0; }
.no-js .ambient { display: none; }
.page { position: relative; z-index: 1; }
/* The field fills the screen, top bar to bottom bar, but stays a whisper
   behind the reading column so text keeps full contrast. */
@media (min-width: 900px) {
  .ambient {
    -webkit-mask-image: linear-gradient(90deg, #000 0, #000 calc(50% - 30rem), rgba(0, 0, 0, .1) calc(50% - 23.5rem), rgba(0, 0, 0, .1) calc(50% + 23.5rem), #000 calc(50% + 30rem), #000 100%);
    mask-image: linear-gradient(90deg, #000 0, #000 calc(50% - 30rem), rgba(0, 0, 0, .1) calc(50% - 23.5rem), rgba(0, 0, 0, .1) calc(50% + 23.5rem), #000 calc(50% + 30rem), #000 100%);
  }
}
@media (max-width: 899px) {
  .ambient {
    -webkit-mask-image: linear-gradient(90deg, rgba(0, 0, 0, .55), rgba(0, 0, 0, .22) 1.5rem, rgba(0, 0, 0, .22) calc(100% - 1.5rem), rgba(0, 0, 0, .55));
    mask-image: linear-gradient(90deg, rgba(0, 0, 0, .55), rgba(0, 0, 0, .22) 1.5rem, rgba(0, 0, 0, .22) calc(100% - 1.5rem), rgba(0, 0, 0, .55));
  }
}
/* ------------------------------ bar ------------------------------------ */

.bar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
}
.no-js .bar { display: none; }
.bar-inner {
  display: flex; align-items: center; gap: .5rem;
  padding-top: .55rem; padding-bottom: calc(.55rem + env(safe-area-inset-bottom));
}
.progress { display: flex; align-items: center; gap: .45rem; margin-right: auto; font-family: var(--font-sans); font-size: .82rem; color: var(--muted); font-variant-numeric: tabular-nums; min-width: 0; border: 0; background: none; padding: .3rem .45rem; margin-left: -.45rem; border-radius: 8px; cursor: grab; touch-action: none; }
.progress:hover { background: var(--accent-soft); }
.progress.undocked { color: var(--accent); }
.progress.undocked .loss { opacity: .4; }
.progress.overfit { color: var(--warn); font-weight: 650; }
.progress.overfit .loss .mini-val { stroke: var(--warn); }
.loss { width: 64px; height: 22px; flex: none; overflow: visible; }
.loss polyline { fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.loss .mini-train { stroke: var(--lp-train); }
.loss .mini-val { stroke: var(--lp-val); }
.progress.converged { color: var(--ok); font-weight: 650; }
.progress.converged .loss polyline { stroke: var(--ok); }
.progress-text.bump { animation: bump .35s var(--spring); display: inline-block; }

.bar-btn, .disc-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .35rem;
  min-height: 2.6rem; padding: 0 .95rem;
  border: 1px solid var(--border-strong); border-radius: 999px;
  background: var(--bg-elevated);
  font-family: var(--font-sans); font-size: .85rem; font-weight: 650;
  cursor: pointer; white-space: nowrap;
  box-shadow: 0 2px 0 var(--border-strong);
  transition: transform .12s var(--ease-out), box-shadow .12s, border-color .15s, background-color .15s;
}
.bar-btn:hover, .disc-btn:hover { border-color: var(--accent); }
.bar-btn:active, .disc-btn:active { transform: translateY(2px) scale(.96); box-shadow: 0 0 0 var(--border-strong); }
.bar-btn.primary { background: var(--accent); border-color: var(--accent); color: var(--bg); box-shadow: 0 2px 0 var(--accent-hover); }
.bar-btn.primary:hover { background: var(--accent-hover); }
.bar-btn[disabled] { opacity: .55; cursor: progress; }
.disc-btn { padding: 0 .75rem; font-variant-numeric: tabular-nums; }
.disc-btn .icon { width: 16px; height: 16px; color: var(--accent); }
.disc-btn.bump { animation: bump .45s var(--spring); }
.disc-btn.bump .icon { animation: spin .6s var(--ease-out); fill: var(--accent); }

/* --------------------------- discoveries sheet ------------------------- */

.sheet {
  width: min(27rem, calc(100% - 2rem)); max-height: min(36rem, 85vh);
  padding: 1.1rem 1.2rem 1.2rem;
  border: 1px solid var(--border); border-radius: 14px;
  background: var(--bg); color: var(--text);
  box-shadow: var(--shadow);
}
.sheet[open] { animation: sheet-in .35s var(--spring); }
.sheet::backdrop { background: rgba(10, 10, 12, .35); }
.sheet-head { display: flex; align-items: center; justify-content: space-between; }
.sheet h2 { font-family: var(--font-sans); font-size: 1.05rem; font-weight: 650; }
.sheet-sub { font-size: .9rem; color: var(--muted); margin: .2rem 0 .8rem; }
.disc-list { list-style: none; padding: 0; display: grid; gap: .4rem; }
.disc-list li {
  display: grid; grid-template-columns: 1.4rem 1fr; gap: .1rem .5rem;
  padding: .5rem .65rem; border: 1px solid var(--border); border-radius: 8px;
  font-family: var(--font-sans); font-size: .85rem; line-height: 1.4;
}
.disc-list .mark { align-self: center; text-align: center; color: var(--muted); }
.disc-list .found { border-color: var(--accent); background: var(--accent-soft); }
.disc-list .found .mark { color: var(--accent); }
.disc-list .d-name { font-weight: 650; }
.disc-list .d-hint { grid-column: 2; color: var(--muted); font-size: .8rem; }
.disc-list .locked .d-name { color: var(--muted); }
.sheet-foot { display: flex; flex-wrap: wrap; align-items: center; gap: .6rem 1rem; margin-top: 1rem; font-family: var(--font-sans); font-size: .8rem; }

/* ------------------------- toasts, tokenizer, burst -------------------- */

.arrow-tracker {
  --arrow-bg: #121c20; --arrow-edge: #42655e; --arrow-ink: #9af3c0; --arrow-dim: #a0b6ae; --arrow-tile: #253437;
  position: fixed; z-index: 45; left: 50%;
  bottom: calc(5.25rem + env(safe-area-inset-bottom));
  translate: -50% 0; padding: .6rem .7rem .7rem; pointer-events: none;
  border: 1px solid var(--arrow-edge); border-radius: 8px;
  background: var(--arrow-bg); color: var(--arrow-ink);
  box-shadow: 0 8px 28px #0005;
  animation: arrow-arrive .38s var(--spring) both;
}
.arrow-tracker-head {
  display: flex; justify-content: space-between; gap: .75rem; margin-bottom: .45rem;
  font: 600 .7rem var(--font-mono); letter-spacing: .04em;
}
.arrow-tracker-count { color: var(--arrow-dim); font-variant-numeric: tabular-nums; }
.arrow-keys { display: flex; gap: .18rem; }
.arrow-key {
  display: grid; place-items: center; width: clamp(1.05rem, 7vw, 1.8rem); aspect-ratio: 1;
  border: 1px solid var(--arrow-edge); border-radius: 3px;
  background: var(--arrow-tile); color: var(--arrow-dim); font: 650 .95rem var(--font-sans);
}
.arrow-key:nth-child(2n):not(:last-child) { margin-inline-end: .22rem; }
.arrow-key.hit { background: var(--arrow-ink); border-color: var(--arrow-ink); color: var(--arrow-bg); }
.arrow-key.next { border-color: var(--arrow-ink); color: var(--arrow-ink); }
.arrow-tracker[data-style="signal"] .hit { box-shadow: 0 0 9px #7ff0b65c; }
.arrow-stamp { display: none; }
.arrow-tracker[data-style="tape"] {
  --arrow-bg: #f5ead3; --arrow-edge: #c9b89a; --arrow-ink: #942f31; --arrow-dim: #645c51;
  --tape-text: #372e28; --tape-rule: #b78c7d;
  border-radius: 2px; rotate: -1.6deg; padding: .65rem .8rem .58rem;
  box-shadow: 0 2px 4px #281c1410, 0 8px 18px #281c1426;
  animation: tape-arrive .4s cubic-bezier(.2,.7,.35,1) both;
}
:root[data-theme="dark"] .arrow-tracker[data-style="tape"] {
  --arrow-bg: #382d26; --arrow-edge: #736050; --arrow-ink: #ff9a91; --arrow-dim: #c1b2a4;
  --tape-text: #f6e7d1; --tape-rule: #956f64;
}
.arrow-tracker[data-style="tape"] .arrow-tracker-head {
  align-items: baseline; margin-bottom: .35rem;
}
.arrow-tracker[data-style="tape"] .arrow-tracker-name {
  color: var(--tape-text);
  font: 600 1.1rem/1 "Newsreader", var(--font-serif);
  letter-spacing: 0;
}
.arrow-tracker[data-style="tape"] .arrow-keys {
  gap: .15rem; padding-bottom: .45rem; border-bottom: 1px solid var(--tape-rule);
}
.arrow-tracker[data-style="tape"] .arrow-key {
  position: relative; width: clamp(1.15rem, 8vw, 2rem); aspect-ratio: 1.12;
  border: 1px solid transparent; border-radius: 2px; background: none;
  font-size: 1.05rem;
}
.arrow-tracker[data-style="tape"] .arrow-key:nth-child(2n):not(:last-child) {
  margin-inline-end: clamp(.25rem, 1.6vw, .6rem);
}
.arrow-tracker[data-style="tape"] .arrow-key.hit,
.arrow-tracker[data-style="tape"] .arrow-key.next { color: var(--arrow-ink); }
.arrow-tracker[data-style="tape"] .arrow-key.next { border-color: currentColor; }
.arrow-tracker[data-style="tape"] .arrow-key.hit::after {
  content: ""; position: absolute; inset: auto 18% 0;
  height: 2px; border-radius: 1px; background: currentColor; transform-origin: left;
}
.arrow-tracker[data-style="tape"] .arrow-key.tap { animation: tape-press .24s ease-out; }
.arrow-tracker[data-style="tape"] .arrow-key.tap::after { animation: tape-ink .22s var(--ease-out) both; }
.arrow-tracker[data-style="tape"].complete {
  animation: tape-arrive .4s cubic-bezier(.2,.7,.35,1) both, tape-leave .28s .74s var(--ease-out) forwards;
}
.arrow-tracker[data-style="tape"].complete .arrow-stamp {
  display: block; position: absolute; inset: .44rem 4rem auto auto;
  border: 1px solid currentColor; border-radius: 2px; padding: .16rem .34rem;
  font: 600 .7rem/1 "Newsreader", var(--font-serif); color: var(--arrow-ink);
  transform: rotate(-8deg); animation: tape-stamp .3s both;
}
@keyframes tape-arrive {
  from { opacity: 0; transform: translateY(26px) rotate(6deg); }
  72% { opacity: 1; transform: translateY(-3px) rotate(-.8deg); }
  to { opacity: 1; transform: none; }
}
@keyframes tape-press {
  28% { transform: translateY(1.5px) scale(.91,.84); }
  62% { transform: translateY(-1px) scale(1.02); }
}
@keyframes tape-ink { from { transform: scaleX(.08); opacity: .45; } }
@keyframes tape-stamp {
  from { opacity: 0; transform: translateY(-12px) rotate(-17deg) scale(1.55); }
  52% { opacity: 1; transform: rotate(-8deg) scale(.94); }
  75% { transform: rotate(-8deg) scale(1.04); }
}
@keyframes tape-leave { to { opacity: 0; } }
@media (prefers-reduced-motion: reduce) {
  .arrow-tracker[data-style="tape"],
  .arrow-tracker[data-style="tape"].complete,
  .arrow-tracker[data-style="tape"].complete .arrow-stamp,
  .arrow-tracker[data-style="tape"] .arrow-key.tap,
  .arrow-tracker[data-style="tape"] .arrow-key.tap::after { animation: none; }
}
.arrow-tracker[data-style="orbit"] {
  --arrow-bg: #231936; --arrow-edge: #685880; --arrow-ink: #d9baff; --arrow-dim: #bfaed1; --arrow-tile: #342746;
  bottom: max(1rem, calc(50% - 2.75rem)); border-radius: 40px; padding-inline: .9rem;
  box-shadow: 0 0 24px #8e6ae24d, 0 8px 28px #0005;
}
.arrow-tracker[data-style="orbit"] .arrow-tracker-head { margin-inline: .35rem; }
.arrow-tracker[data-style="orbit"] .arrow-keys { align-items: center; min-height: 2rem; }
.arrow-tracker[data-style="orbit"] .arrow-key { border-radius: 50%; }
.arrow-tracker[data-style="orbit"] .arrow-key:nth-child(even) { translate: 0 3px; }
.arrow-tracker[data-style="orbit"] .arrow-key:nth-child(odd) { translate: 0 -3px; }
.arrow-key.tap { animation: arrow-tap .3s var(--spring); }
.arrow-tracker.complete { animation: arrow-pop .42s var(--ease-out) forwards; }
@keyframes arrow-arrive { from { opacity: 0; transform: translateY(8px) scale(.88); } }
@keyframes arrow-tap { 40% { transform: translateY(-3px) scale(1.16); } }
@keyframes arrow-pop {
  25% { transform: scale(1.12); }
  100% { opacity: 0; transform: translateY(-10px) scale(1.2); }
}

.toast-stack {
  position: fixed; left: 50%; bottom: calc(4.6rem + env(safe-area-inset-bottom)); z-index: 40;
  transform: translateX(-50%);
  display: flex; flex-direction: column-reverse; align-items: center; gap: .4rem;
  width: max-content; max-width: calc(100vw - 2rem);
  pointer-events: none;
}
.toast {
  display: inline-flex; align-items: center; gap: .5rem;
  padding: .5rem .95rem; border-radius: 999px;
  font-family: var(--font-sans); font-size: .85rem; font-weight: 600;
  color: var(--bg); background: var(--text); box-shadow: var(--shadow);
  animation: toast-in .4s var(--spring) both;
}
.toast .icon { width: 15px; height: 15px; fill: var(--accent); stroke: var(--accent); }
.toast.out { animation: toast-out .25s ease forwards; }
.toast kbd { color: var(--text); border-color: transparent; background: var(--bg); font-size: .72rem; }
.toast-btn {
  pointer-events: auto;
  margin-left: .1rem; padding: .2rem .65rem; min-height: 1.9rem;
  border: 0; border-radius: 999px;
  background: var(--accent); color: var(--bg);
  font: 650 .8rem var(--font-sans); cursor: pointer;
  transition: transform .12s var(--ease-out);
}
.toast-btn:active { transform: scale(.92); }

.tok-pop {
  position: fixed; z-index: 45; display: none;
  max-width: min(22rem, calc(100vw - 1.5rem));
  padding: .5rem .6rem .55rem;
  border: 1px solid var(--border-strong); border-radius: 10px;
  background: var(--bg-elevated); box-shadow: var(--shadow);
  animation: pop-in .25s var(--spring);
}
.tok-pop.show { display: block; }
.tok-head { display: block; margin-bottom: .35rem; font-family: var(--font-sans); font-size: .74rem; color: var(--muted); }
.tok-head b { color: var(--text); }
.tok-body { display: flex; flex-wrap: wrap; gap: 2px; font-family: var(--font-mono); font-size: .78rem; line-height: 1.5; }
.tok { padding: 0 .2rem; border-radius: 3px; white-space: pre; }
.tok:nth-child(4n+1) { background: rgba(124, 58, 237, .16); }
.tok:nth-child(4n+2) { background: rgba(37, 99, 235, .16); }
.tok:nth-child(4n+3) { background: rgba(13, 148, 136, .18); }
.tok:nth-child(4n+4) { background: rgba(176, 125, 6, .18); }

.burst { position: fixed; inset: 0; z-index: 50; pointer-events: none; width: 100%; height: 100%; }

/* ------------------------------ mobile --------------------------------- */

@media (max-width: 640px) {
  body { font-size: 1rem; }
  .top-inner, .page, .bar-inner { padding-left: 1rem; padding-right: 1rem; }
  .icon-btn { width: 2.75rem; height: 2.75rem; }
  .kernel { height: 2.75rem; padding: 0 .75rem; }
  .kernel-text { max-width: 6.5rem; }
  .cell { grid-template-columns: minmax(0, 1fr); padding: .5rem 0; }
  .tb-inner { padding: 0 .6rem; min-height: 3rem; }
  .tb-btn { width: 2.75rem; height: 2.75rem; }
  .tb-type select { height: 2.75rem; }
  .tb-saved { display: none; }
  .empty-note { margin-left: 0; }
  .gutter { padding: 0 0 .25rem .1rem; }
  .cell-main::before { left: -.55rem; }
  .run { width: 2.75rem; height: 2.75rem; }
  .run svg { width: 17px; height: 17px; }
  .code { padding-top: .6rem; font-size: .86rem; }
  .out-inner, .projects { padding-left: .2rem; }
  .ghost { padding-left: .2rem; }
  .proj-row { grid-template-columns: minmax(0, 1fr) 1rem; grid-template-areas: "name chev" "what chev"; gap: 0 .75rem; padding: .5rem; }
  .proj-name { grid-area: name; }
  .proj-what { grid-area: what; text-align: left; }
  .chev { grid-area: chev; }
  .bar-inner { gap: .4rem; }
  .bar-btn, .disc-btn { min-height: 2.75rem; padding: 0 .8rem; }
  .sheet { margin: auto auto 0; width: 100%; max-width: none; border-radius: 16px 16px 0 0; padding-bottom: calc(1.2rem + env(safe-area-inset-bottom)); }
}
@media (max-width: 400px) {
  .loss { display: none; }
  .bar-btn { padding: 0 .7rem; }
  .kernel-text { max-width: 4.8rem; }
}
/* ----------------------------- keyframes ------------------------------- */

@keyframes spin { to { transform: rotate(360deg); } }
@keyframes pulse { 50% { transform: scale(1.35); } }
@keyframes blink { 50% { opacity: 0; } }
@keyframes roll { to { transform: translateY(-1.25em); } }
@keyframes shimmer { from { transform: translateX(-100%); } to { transform: translateX(300%); } }
@keyframes ripple { from { transform: scale(1); opacity: .8; } to { transform: scale(1.9); opacity: 0; } }
@keyframes pop-in { from { opacity: 0; transform: scale(.85); } to { opacity: 1; transform: scale(1); } }
@keyframes bump { 40% { transform: scale(1.18); } }
@keyframes jiggle { 25% { transform: rotate(-4deg); } 75% { transform: rotate(4deg); } }
@keyframes shake { 20% { transform: translateX(-3px); } 40% { transform: translateX(3px); } 60% { transform: translateX(-2px); } 80% { transform: translateX(2px); } }
@keyframes draw { to { stroke-dashoffset: 0; } }
@keyframes slide-in { from { opacity: 0; transform: translateX(-10px); } }
@keyframes wild { 0% { transform: translate(0); } 33% { transform: translate(-1px, 1px) skewX(-2deg); } 66% { transform: translate(1px, -1px) skewX(2deg); } }
@keyframes live { 0% { box-shadow: 0 0 0 0 var(--ok); } 70% { box-shadow: 0 0 0 6px transparent; } 100% { box-shadow: 0 0 0 0 transparent; } }
@keyframes float-z { 0% { opacity: 0; transform: translate(0, 0); } 30% { opacity: 1; } 100% { opacity: 0; transform: translate(14px, -22px); } }
@keyframes steam { 0% { opacity: .7; transform: translate(0, 0) scale(.6); } 100% { opacity: 0; transform: translate(4px, -20px) scale(1.6); } }
@keyframes squish { 0% { transform: scale(1); } 25% { transform: scale(.82, .9); } 60% { transform: scale(1.1); } 100% { transform: scale(1); } }
@keyframes squish-soft { 40% { transform: scale(.9); } }
@keyframes speaker-thump { 30% { transform: scale(1.25, .85); } 60% { transform: scale(.95, 1.08); } }
@keyframes hush { 40% { transform: translateX(-1.5px) scale(.92); } }
@keyframes wave-beat { 40% { transform: translateX(1.2px); opacity: .55; } }
@keyframes saved-flash { 0% { color: var(--ok); transform: translateY(-2px); } 100% { color: var(--muted); transform: none; } }
@keyframes tb-pop { 40% { transform: scale(1.28); } }
@keyframes tb-stamp { 30% { transform: translateY(-3px) scale(1.12); } 60% { transform: translateY(1px) scale(1.08, .9); } }
@keyframes tb-turn { from { transform: rotate(-90deg) scale(.6); } }
@keyframes tb-snip { 30% { transform: rotate(-14deg) scale(1.1); } 65% { transform: rotate(9deg); } }
@keyframes tb-drop { from { transform: translateY(-5px); opacity: .35; } }
@keyframes tb-lid { 40% { transform: rotate(-28deg) translate(-1px, -2px); } }
@keyframes tb-back { 40% { transform: rotate(-45deg) scale(1.1); } }
@keyframes tb-up { 40% { transform: translateY(-4px); } }
@keyframes tb-down { 40% { transform: translateY(4px); } }
@keyframes tb-go { 40% { transform: translateX(4px) scale(1.1); } }
@keyframes tb-squash { 40% { transform: scale(1.3, .7); } }
@keyframes tb-rewind { from { transform: rotate(0); } to { transform: rotate(-360deg); } }
@keyframes tb-ff { 35% { transform: translateX(6px); opacity: 0; } 36% { transform: translateX(-6px); opacity: 0; } }
@keyframes born { from { transform: scale(.96); } }
@keyframes copied-flash { 25% { border-color: var(--accent); box-shadow: 0 0 0 5px var(--accent-soft); } }
@keyframes bump-up { 40% { transform: translateY(-5px); } }
@keyframes bump-down { 40% { transform: translateY(5px); } }@keyframes sheet-in { from { opacity: 0; transform: translateY(24px) scale(.97); } }
@keyframes toast-in { from { opacity: 0; transform: translateY(14px) scale(.92); } }
@keyframes toast-out { to { opacity: 0; transform: translateY(8px) scale(.96); } }

/* --------------------------- reduced motion ---------------------------- */
/* Feedback stays (colour, state, text); movement goes. JS also skips
   typing, scatter, flying chips, particle bursts and background drift. */

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    animation-delay: 0s !important;
    transition-duration: .001ms !important;
    transition-delay: 0s !important;
    scroll-behavior: auto !important;
  }
  .ln.pending { transform: none; }
  .star { animation: none; }
}

/* ------------------------- loss chart tokens ------------------------- */

:root[data-theme="light"] { --lp-train: #0550ae; --lp-val: #c2512b; }
:root[data-theme="dark"] { --lp-train: #79c0ff; --lp-val: #e0876f; }

/* ------------------------- code editor overlay ----------------------- */
/* A transparent textarea sits on top of a highlighted copy of the same
   text. Both share the font, padding and wrapping, so they stay aligned. */
.code.editor { position: relative; padding-top: 0; min-height: 1.55em; }
.code.editor .hl {
  margin: 0; padding: .38rem 0 0;
  font: inherit; white-space: pre-wrap; word-break: break-word;
  pointer-events: none; user-select: none;
}
.code.editor .src {
  position: absolute; inset: 0; width: 100%; height: 100%;
  padding: .38rem 0 0; margin: 0; border: 0; resize: none; overflow: hidden;
  font: inherit; white-space: pre-wrap; word-break: break-word;
  color: transparent; background: transparent; caret-color: var(--accent);
  outline: none; border-radius: 0;
}
.code.editor .src::selection { background: rgba(128, 91, 0, .22); }
:root[data-theme="dark"] .code.editor .src::selection { background: rgba(216, 171, 82, .3); }
.code.editor .src::placeholder { color: var(--muted); opacity: .75; }
.code.editor .src[readonly] { caret-color: transparent; }
@media (max-width: 640px) {
  .code.editor .hl, .code.editor .src { padding-top: .6rem; }
}

/* Line numbers: both layers shift right together, numbers hang in the gap. */
.cell.lnum .code.editor { padding-left: 2.1rem; }
.cell.lnum .hl { counter-reset: lnum; }
.cell.lnum .hl .cl { position: relative; }
.cell.lnum .hl .cl::before {
  counter-increment: lnum; content: counter(lnum);
  position: absolute; left: -1.85rem; top: 0; width: 1.35rem;
  text-align: right; color: var(--muted); opacity: .55;
  font-size: .72em; line-height: 2.15; user-select: none;
}

/* Multi-select (Shift+J/K, Shift+click) */
.cell.is-multi { background: var(--accent-soft); }
.cell.is-multi .gutter { color: var(--accent); opacity: .85; }

/* Output hidden with O */
.cell.out-hidden .cell-output { grid-template-rows: 0fr !important; }
.cell.out-hidden .ghost { display: none !important; }

/* Drag to reorder */
/* Mid widths: the grip lies flat under the [n] prompt. Wide screens: it
   hangs in the margin left of the prompt. Touch: it sits in the gutter row. */
.grip {
  position: absolute; left: -.2rem; top: 1.95rem;
  width: 1.6rem; height: 1.25rem;
  display: flex; align-items: center; justify-content: center;
  color: var(--muted); opacity: 0; cursor: grab; touch-action: none;
  border-radius: 6px;
  transition: opacity .15s, color .15s;
}
.grip svg { width: 12px; height: 20px; fill: currentColor; transform: rotate(90deg); }
@media (min-width: 900px) {
  .grip { left: -1.85rem; top: .3rem; width: 1.5rem; height: 2.2rem; }
  .grip svg { transform: none; }
}
.cell:hover .grip, .cell.is-selected .grip, .cell:focus-within .grip { opacity: .5; }
.grip:hover { opacity: 1 !important; color: var(--accent); }
/* The lifted cell is a card of paper, so it never shows the cell it passes over. */
.cell.dragging { z-index: 6; background: var(--bg); border-radius: 10px; box-shadow: 0 0 0 .35rem var(--bg), 0 14px 34px rgba(0, 0, 0, .16); }
.cell.dragging .cell-input { border-color: var(--accent); box-shadow: 0 10px 28px rgba(0, 0, 0, .18); }
.cell.dragging .grip { opacity: 1; color: var(--accent); cursor: grabbing; }
.cells.sorting .cell:not(.dragging) { transition: transform .18s var(--ease-out); }
body.is-dragging { user-select: none; cursor: grabbing; }
body.is-dragging * { cursor: grabbing !important; }
@media (hover: none), (max-width: 640px) {
  .gutter { display: flex; align-items: center; justify-content: space-between; }
  .grip { position: static; width: 2.75rem; height: 2.2rem; }
  .grip svg { transform: rotate(90deg); }
}
@media (hover: none) { .grip { opacity: .45; } }

/* The void: fling a dragged cell off either side of the column to drop it in. */
.void {
  position: fixed; top: 0; bottom: 0; left: 0; z-index: 0; width: min(40vw, 440px);
  pointer-events: none; opacity: 0; transition: opacity .18s linear;
  background: radial-gradient(90% 62% at 0% 50%, rgba(6, 6, 8, .94) 0%, rgba(6, 6, 8, .62) 34%, rgba(6, 6, 8, .18) 58%, transparent 74%);
}
.void.right { left: auto; right: 0; background: radial-gradient(90% 62% at 100% 50%, rgba(6, 6, 8, .94) 0%, rgba(6, 6, 8, .62) 34%, rgba(6, 6, 8, .18) 58%, transparent 74%); }
/* The event horizon: a faint ochre rim that tightens when a release would drop the cell. */
.void::before {
  content: ""; position: absolute; top: 50%; left: 0; width: 15rem; height: 15rem; border-radius: 50%;
  transform: translate(-50%, -50%) scale(.85);
  box-shadow: 0 0 0 1px rgba(216, 171, 82, .28), 0 0 48px 6px rgba(216, 171, 82, .12), inset 0 0 40px 10px rgba(0, 0, 0, .6);
  transition: transform .35s var(--spring), box-shadow .25s;
}
.void.right::before { left: 100%; }
.void.armed::before { transform: translate(-50%, -50%) scale(1.08); box-shadow: 0 0 0 1.5px rgba(216, 171, 82, .65), 0 0 70px 14px rgba(216, 171, 82, .22), inset 0 0 50px 14px rgba(0, 0, 0, .75); }
.void-label {
  position: absolute; top: 50%; left: .9rem; max-width: 5.6rem; margin-top: -1.4rem; line-height: 1.35;
  font-family: var(--font-mono); font-size: .72rem; letter-spacing: .02em; color: #e8dcc2;
  opacity: 0; transform: translateY(4px); transition: opacity .2s, transform .2s;
}
.void.right .void-label { left: auto; right: .9rem; text-align: right; }
.void.armed .void-label { opacity: .85; transform: none; }
.void.gulp { opacity: 1 !important; animation: void-gulp .52s ease-in forwards; }
.void.gulp::before { animation: void-swallow .52s var(--ease-out); }
.void.gulp .void-label { opacity: 0; }
@keyframes void-gulp { 0%, 45% { opacity: 1; } 100% { opacity: 0; } }
@keyframes void-swallow { 0% { transform: translate(-50%, -50%) scale(1.08); } 35% { transform: translate(-50%, -50%) scale(.7); } 100% { transform: translate(-50%, -50%) scale(1.3); opacity: 0; } }
.cell.voiding { box-shadow: 0 0 0 .35rem var(--bg), 0 18px 44px rgba(0, 0, 0, .3); }
.cell.voiding .cell-input { border-color: var(--muted); }
@media (prefers-reduced-motion: reduce) { .void.gulp, .void.gulp::before { animation: none; } .void::before { transition: none; } }

/* Markdown output */
.md-out .md-h { font-family: var(--font-sans); font-weight: 650; line-height: 1.3; margin-top: .55rem; }
.md-out .md-h1 { font-size: 1.45rem; }
.md-out .md-h2 { font-size: 1.25rem; }
.md-out .md-h3 { font-size: 1.1rem; }
.md-out .md-h4, .md-out .md-h5, .md-out .md-h6 { font-size: 1rem; }
.md-out .md-p { margin: .25rem 0; }
.md-out .md-ul { padding-left: 1.3rem; margin: .25rem 0; list-style: disc; }
.md-out code {
  font-family: var(--font-mono); font-size: .85em;
  background: var(--bg-code); border: 1px solid var(--border);
  border-radius: 4px; padding: .05em .3em;
}
.blog-note { font-family: var(--font-sans); font-size: .8rem; color: var(--muted); font-style: italic; }
.post.off { display: none; }
.inline-out { border-left: 2px solid var(--border-strong); margin: .35rem 0; }

/* Contact logos */
.links li { display: flex; align-items: center; gap: .55rem; }
.links .logo { width: 17px; height: 17px; flex: none; fill: currentColor; color: var(--muted); transition: color .15s; }
.links li:hover .logo { color: var(--accent); }

/* --------------------------- loss panel ------------------------------ */
.loss-panel {
  position: fixed; z-index: 35; width: 300px; max-width: calc(100vw - 1rem);
  padding: .5rem .7rem .6rem;
  border: 1px solid var(--border-strong); border-radius: 12px;
  background: var(--bg); box-shadow: var(--shadow);
  transform-origin: bottom right;
}
.loss-panel[hidden] { display: none; }
.loss-panel.carrying { box-shadow: 0 12px 34px rgba(0, 0, 0, .28); }
.lp-head {
  display: flex; align-items: center; gap: .5rem;
  margin: -.1rem -.3rem .3rem; padding: .3rem .3rem;
  cursor: grab; border-radius: 8px; touch-action: none;
}
.loss-panel.carrying .lp-head { cursor: grabbing; }
.lp-title { font: 650 .8rem var(--font-mono); color: var(--muted); }
.lp-legend { display: inline-flex; align-items: center; gap: .3rem; margin-left: auto; font: 500 .72rem var(--font-sans); color: var(--muted); }
.lp-legend i { width: 12px; height: 3px; border-radius: 2px; display: inline-block; }
.lp-legend .lg-train { background: var(--lp-train); }
.lp-legend .lg-val { background: var(--lp-val); margin-left: .45rem; }
.lp-close {
  width: 1.9rem; height: 1.9rem; padding: 0; border: 0; border-radius: 6px;
  background: none; color: var(--muted); font-size: 1.1rem; line-height: 1; cursor: pointer;
}
.lp-close:hover { color: var(--text); background: var(--accent-soft); }
.lp-chart { width: 100%; height: auto; display: block; touch-action: none; outline: none; }
.lp-chart:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
.lp-grid { stroke: var(--border); stroke-width: 1; stroke-dasharray: 2 3; }
.lp-axis { stroke: var(--border-strong); stroke-width: 1; }
.lp-tick { font: 500 8px var(--font-mono); fill: var(--muted); }
.lp-train, .lp-val { fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.lp-train { stroke: var(--lp-train); }
.lp-val { stroke: var(--lp-val); }
#lp-best line { stroke: var(--ok); stroke-width: 1; stroke-dasharray: 3 3; opacity: .8; }
#lp-best text { font: 600 7.5px var(--font-sans); fill: var(--ok); }
#lp-cursor { stroke: var(--muted); stroke-width: 1; opacity: .55; }
#lp-dot-train { fill: var(--lp-train); stroke: var(--bg); stroke-width: 1.5; }
#lp-dot-val { fill: var(--lp-val); stroke: var(--bg); stroke-width: 1.5; }
.lp-read { margin-top: .3rem; font: 500 .78rem var(--font-sans); min-height: 1.2em; }
.lp-read .muted { color: var(--muted); }
.lp-read .lg-train { color: var(--lp-train); font-weight: 650; }
.lp-read .lg-val { color: var(--lp-val); font-weight: 650; }
.lp-read .lp-warn { color: var(--warn); font-weight: 650; }
body.is-carrying { user-select: none; cursor: grabbing; }
body.is-carrying * { cursor: grabbing !important; }

/* ------------------------- palette & help ---------------------------- */
.palette { padding: .65rem; width: min(26rem, calc(100% - 2rem)); }
.pal-input {
  width: 100%; height: 2.6rem; padding: 0 .8rem;
  border: 1px solid var(--border); border-radius: 9px;
  background: var(--bg-elevated); color: var(--text);
  font: 400 .95rem var(--font-sans); outline: none;
}
.pal-input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.pal-list { list-style: none; margin: .5rem 0 0; padding: 0; max-height: 16.5rem; overflow: auto; display: grid; gap: 2px; }
.pal-list li {
  display: flex; justify-content: space-between; align-items: center; gap: 1rem;
  padding: .45rem .6rem; border-radius: 7px;
  font: 500 .88rem var(--font-sans); cursor: pointer;
}
.pal-list li[aria-selected="true"] { background: var(--accent-soft); color: var(--accent); }
.pal-list .pal-empty { color: var(--muted); cursor: default; }
.help-list { list-style: none; padding: 0; margin: 0; display: grid; gap: .12rem; font-family: var(--font-sans); font-size: .85rem; }
.help-list li { display: flex; justify-content: space-between; align-items: baseline; gap: 1rem; padding: .14rem 0; }
.help-list .hk { color: var(--muted); white-space: nowrap; }

/* --------------------------- blown fuse ------------------------------ */
/* Blackout with a flashlight: the shade has a soft hole that follows the
   pointer (or wanders on its own), the lamp adds a warm cast over it. */
.fuse-shade, .fuse-lamp { position: fixed; pointer-events: none; visibility: hidden; opacity: 0; }
.fuse-shade {
  inset: 0; z-index: 90;
  background: radial-gradient(circle at var(--fx, 50vw) var(--fy, 40vh),
    rgba(4, 4, 6, .04) 0, rgba(4, 4, 6, .3) 85px, rgba(4, 4, 6, .86) 165px, #040406 250px);
}
.fuse-lamp {
  z-index: 91; left: 0; top: 0;
  width: 360px; height: 360px; margin: -180px 0 0 -180px; border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 214, 150, .2) 0, rgba(255, 200, 130, .07) 38%, transparent 66%);
  mix-blend-mode: screen;
  will-change: transform;
}
.fuse-shade.on, .fuse-lamp.on { visibility: visible; opacity: 1; }
.fuse-shade.on { animation: fuse-cut .5s linear; }
.fuse-lamp.on { animation: lamp-on .9s linear, lamp-flicker 3.2s 1s linear infinite; }
.fuse-shade.back, .fuse-lamp.back { animation: fuse-back .75s linear forwards; }
.theme-btn.dead { animation: shake .3s linear 1; }
@keyframes fuse-cut { 0% { opacity: 0; } 10% { opacity: 1; } 18% { opacity: .35; } 26% { opacity: 1; } 34% { opacity: .7; } 44% { opacity: 1; } }
@keyframes lamp-on { 0%, 35% { opacity: 0; } 45% { opacity: .8; } 52% { opacity: .1; } 64% { opacity: 1; } }
@keyframes lamp-flicker { 0%, 100% { opacity: 1; } 47% { opacity: 1; } 50% { opacity: .72; } 53% { opacity: 1; } 81% { opacity: .9; } }
@keyframes fuse-back { 0% { opacity: 1; } 18% { opacity: .1; } 28% { opacity: .85; } 46% { opacity: 0; } 56% { opacity: .55; } 100% { opacity: 0; } }

/* Theme switch: light spreads out of the switch, dark closes in over it. */
@property --vt-radius { syntax: '<length>'; inherits: false; initial-value: 0px; }
::view-transition-old(root), ::view-transition-new(root) { animation: none; mix-blend-mode: normal; }
:root.vt-theme { transition: none !important; }
:root.vt-close::view-transition-old(root) { z-index: 2; --vt-radius: 200vmax; }
:root.vt-close::view-transition-new(root) { z-index: 1; }
:root.vt-close::view-transition-old(root),
:root.vt-theme:not(.vt-close)::view-transition-new(root) {
  clip-path: circle(var(--vt-radius) at var(--vt-x) var(--vt-y));
}
/* The switch stays live above the reveal instead of freezing in the snapshot. */
:root.vt-theme .theme-btn { view-transition-name: theme-switch; }
::view-transition-group(theme-switch) { animation: none; z-index: 3; }
::view-transition-old(theme-switch) { display: none; }
::view-transition-new(theme-switch) { animation: none; }

/* Grabbable burst tokens */
body.can-grab { cursor: grab; }
body.is-grabbing { cursor: grabbing; user-select: none; }
body.is-grabbing * { cursor: grabbing !important; }
