/* ==========================================================================
   Home: a drive through the work.
   body.is-3d   → the canvas fills the screen, only the active .stop is shown
   body.list-mode (or no WebGL) → stops read top to bottom as a normal page
   ========================================================================== */

:root {
  --ink: #17181c;
  --ink-2: #4a4d55;
  --ink-3: #8a8d95;
  --paper: rgba(255, 255, 255, 0.86);
  --line: rgba(23, 24, 28, 0.1);
  --accent: #ff5a36;
  --sky: #cfe9f3;
  --serif: "Instrument Serif", Georgia, serif;
  --sans: "Geist", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "Geist Mono", ui-monospace, Menlo, monospace;
  --spring: cubic-bezier(0.2, 0.9, 0.25, 1.12);
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: linear-gradient(#cfe9f3, #eef7ee 70%);
  background-attachment: fixed;
  color: var(--ink); font: 400 16px/1.55 var(--sans);
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; }
button { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 6px; }

body.is-3d { height: 100vh; height: 100dvh; overflow: hidden; overscroll-behavior: none; touch-action: none; }
#world { position: fixed; inset: 0; width: 100%; height: 100%; display: none; }
body.is-3d #world { display: block; }
.only-3d { display: none !important; }
body.is-3d .only-3d { display: revert !important; }
body.is-3d .stepper.only-3d, body.is-3d .track.only-3d { display: flex !important; }

/* ---------- loader ---------- */
.loader { position: fixed; inset: 0; z-index: 60; display: none; place-content: center; justify-items: center; gap: 16px; background: linear-gradient(#cfe9f3, #eef7ee); font: 500 13px/1 var(--mono); letter-spacing: .06em; color: var(--ink-2); transition: opacity .6s ease, visibility .6s; }
body.booting .loader { display: grid; }
body.ready .loader { opacity: 0; visibility: hidden; }
.loader__road { width: 160px; height: 6px; border-radius: 6px; background: rgba(23,24,28,.12); overflow: hidden; }
.loader__road i { display: block; width: 40%; height: 100%; border-radius: 6px; background: var(--accent); animation: load 1.1s ease-in-out infinite; }
@keyframes load { from { transform: translateX(-100%); } to { transform: translateX(260%); } }

/* ---------- top bar ---------- */
.hud { position: fixed; z-index: 30; top: 14px; left: 14px; right: 14px; display: flex; align-items: center; justify-content: space-between; gap: 12px; pointer-events: none; }
.hud > * { pointer-events: auto; }
.hud__brand { display: inline-flex; align-items: center; gap: 10px; padding: 10px 16px; border-radius: 999px; background: var(--paper); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); box-shadow: 0 6px 24px -14px rgba(0,0,0,.4); text-decoration: none; font-weight: 600; letter-spacing: -0.01em; }
.hud__brand svg { width: 24px; height: 15px; color: var(--accent); }
.hud__links { display: flex; align-items: center; gap: 4px; padding: 5px; border-radius: 999px; background: var(--paper); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); box-shadow: 0 6px 24px -14px rgba(0,0,0,.4); }
.hud__links a, .hud__links button { border: 0; background: none; padding: 8px 13px; border-radius: 999px; font-size: 14px; text-decoration: none; color: var(--ink-2); cursor: pointer; }
.hud__links a:hover, .hud__links button:hover { color: var(--ink); background: rgba(23,24,28,.06); }
.hud__links .hud__cta { background: var(--ink); color: #fff; }
.hud__links .hud__cta:hover { background: #000; color: #fff; }
body:not(.is-3d) .hud { position: sticky; top: 14px; margin: 14px; }

/* ---------- stops: shared ---------- */
.stops { position: relative; z-index: 20; }
.stop { --c: var(--accent); }
.stop h1 { font: 400 clamp(46px, 6.6vw, 104px)/0.94 var(--serif); letter-spacing: -0.03em; margin: 18px 0 0; max-width: 12ch; }
.stop h1 em { color: var(--accent); }
.stop h2 { font: 400 clamp(32px, 3vw, 42px)/1.02 var(--serif); letter-spacing: -0.02em; margin: 10px 0 10px; }
.stop p { margin: 0; color: var(--ink-2); font-size: 15.5px; }
.stop .lede { font-size: clamp(16px, 1.3vw, 19px); max-width: 46ch; margin-top: 18px; }
.stop__kicker { display: flex; align-items: center; gap: 10px; font: 500 11.5px/1 var(--mono); letter-spacing: .07em; text-transform: uppercase; color: var(--ink-3); }
.stop__kicker b { display: grid; place-items: center; width: 26px; height: 26px; border-radius: 50%; background: var(--c); color: #fff; font-weight: 500; letter-spacing: 0; }
.chip { display: inline-flex; align-items: center; gap: 8px; padding: 7px 13px; border-radius: 999px; background: rgba(255,255,255,.75); font: 500 12px/1 var(--mono); letter-spacing: .05em; color: var(--ink-2); }
.chip i { width: 8px; height: 8px; border-radius: 50%; background: #23c98d; box-shadow: 0 0 0 4px rgba(35,201,141,.2); }
.facts { list-style: none; margin: 16px 0 0; padding: 0; display: grid; gap: 8px; }
.facts li { position: relative; padding-left: 16px; font-size: 14.5px; color: var(--ink-2); line-height: 1.45; }
.facts li::before { content: ""; position: absolute; left: 0; top: 7px; width: 7px; height: 7px; border-radius: 50%; background: var(--c); }
.facts b { color: var(--ink); font-weight: 600; }
.actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 20px; }
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 11px 17px; border-radius: 999px; border: 1px solid var(--line); background: rgba(255,255,255,.7); font-size: 14.5px; font-weight: 500; text-decoration: none; cursor: pointer; transition: transform .25s var(--spring), background .2s; }
.btn:hover { transform: translateY(-2px); background: #fff; }
.btn--solid { background: var(--c); border-color: var(--c); color: #fff; }
.btn--solid:hover { background: var(--c); filter: brightness(1.06); }
.btn--icon { justify-content: center; width: 44px; height: 44px; padding: 0; }
.btn--icon svg { width: 19px; height: 19px; }
.btn--github { color: #17181c; }
.btn--linkedin { color: #0a66c2; }
.keys { font-size: 13px; color: var(--ink-3); margin-left: 6px; }
kbd { font: 500 11.5px/1 var(--mono); padding: 4px 7px; border-radius: 6px; background: rgba(255,255,255,.8); border: 1px solid var(--line); color: var(--ink-2); }
.mail { display: inline-block; margin-top: 14px; font: 400 clamp(24px, 2.4vw, 32px)/1.1 var(--serif); color: var(--ink); text-decoration-color: var(--c); text-underline-offset: 5px; word-break: break-word; }

/* ---------- stops in 3D: one floating card at a time ---------- */
body.is-3d .stop {
  position: fixed; left: 22px; bottom: 92px; width: min(420px, calc(100vw - 44px)); max-height: calc(100dvh - 190px); overflow: auto;
  padding: 22px 24px 22px; border-radius: 24px; background: var(--paper);
  backdrop-filter: blur(16px) saturate(1.3); -webkit-backdrop-filter: blur(16px) saturate(1.3);
  box-shadow: 0 30px 60px -30px rgba(20, 30, 40, .45), 0 0 0 1px rgba(255,255,255,.6) inset;
  opacity: 0; transform: translateY(18px) scale(.98); pointer-events: none; visibility: hidden;
  transition: opacity .45s ease, transform .55s var(--spring), visibility 0s .45s;
}
body.is-3d .stop::before { content: ""; position: absolute; left: 24px; right: 24px; top: 0; height: 4px; border-radius: 0 0 4px 4px; background: var(--c); }
body.is-3d .stop.active { opacity: 1; transform: none; pointer-events: auto; visibility: visible; transition-delay: 0s; }
body.is-3d .stop--intro { left: max(22px, 5vw); top: 50%; bottom: auto; width: min(640px, calc(100vw - 44px)); transform: translateY(-46%) scale(.98); background: none; box-shadow: none; backdrop-filter: none; -webkit-backdrop-filter: none; padding: 0; max-height: none; overflow: visible; }
body.is-3d .stop--intro::before { display: none; }
body.is-3d .stop--intro.active { transform: translateY(-50%); }
body.is-3d .stop--intro h1 { text-shadow: 0 2px 30px rgba(255,255,255,.7); }
body.is-3d .stop--intro .lede { color: var(--ink); text-shadow: 0 1px 14px rgba(255,255,255,.9); }

/* ---------- stepper, track, hint ---------- */
.stepper { position: fixed; z-index: 25; right: 22px; bottom: 26px; gap: 8px; }
.stepper button { width: 46px; height: 46px; border-radius: 50%; border: 0; background: var(--paper); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); box-shadow: 0 8px 24px -12px rgba(0,0,0,.45); font-size: 18px; cursor: pointer; transition: transform .25s var(--spring); }
.stepper button:hover { transform: translateY(-2px); }
.stepper button[data-next] { background: var(--ink); color: #fff; }

.track { position: fixed; z-index: 25; left: 50%; bottom: 34px; transform: translateX(-50%); width: min(460px, calc(100vw - 210px)); height: 30px; align-items: center; }
.track::before { content: ""; position: absolute; left: 0; right: 0; height: 4px; border-radius: 4px; background: rgba(255,255,255,.7); box-shadow: 0 2px 10px -4px rgba(0,0,0,.3); }
.track .fill { position: absolute; left: 0; height: 4px; border-radius: 4px; background: var(--ink); width: 0; }
.track button { position: absolute; width: 14px; height: 14px; margin-left: -7px; border-radius: 50%; border: 2.5px solid #fff; background: var(--c); padding: 0; cursor: pointer; box-shadow: 0 2px 8px -2px rgba(0,0,0,.35); transition: transform .25s var(--spring); }
.track button:hover, .track button.on { transform: scale(1.35); }
.track button span { position: absolute; bottom: 20px; left: 50%; transform: translateX(-50%); white-space: nowrap; font: 500 11px/1 var(--mono); padding: 5px 8px; border-radius: 6px; background: var(--ink); color: #fff; opacity: 0; pointer-events: none; transition: opacity .2s; }
.track button:hover span { opacity: 1; }
.track .car { position: absolute; width: 22px; height: 22px; margin-left: -11px; border-radius: 50%; background: var(--accent); border: 3px solid #fff; box-shadow: 0 3px 10px -2px rgba(0,0,0,.4); pointer-events: none; }

.hint { position: fixed; z-index: 24; left: 50%; bottom: 80px; transform: translateX(-50%); font-size: 13px; color: var(--ink-2); padding: 8px 14px; border-radius: 999px; background: rgba(255,255,255,.7); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); transition: opacity .4s; white-space: nowrap; }
.hint.hide { opacity: 0; visibility: hidden; transition: opacity .4s, visibility 0s .4s; }

/* ---------- list view / no-WebGL fallback ---------- */
body:not(.is-3d) .stops { max-width: 760px; margin: 0 auto; padding: 30px 20px 80px; display: grid; gap: 18px; }
body:not(.is-3d) .stop { position: relative; padding: 26px 28px; border-radius: 24px; background: rgba(255,255,255,.82); box-shadow: 0 20px 50px -34px rgba(20,30,40,.5); overflow: hidden; }
body:not(.is-3d) .stop::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 5px; background: var(--c); }
body:not(.is-3d) .stop--intro { background: none; box-shadow: none; padding: 40px 0 30px; }
body:not(.is-3d) .stop--intro::before { display: none; }

/* ---------- phones ---------- */
@media (max-width: 700px) {
  .hud { top: 10px; left: 10px; right: 10px; }
  .hud__brand { padding: 9px 13px; font-size: 14.5px; }
  .hud__links a[href$=".pdf"] { display: none; }
  body.is-3d .stop { left: 10px; right: 10px; width: auto; bottom: 84px; padding: 18px 18px; border-radius: 20px; max-height: 45dvh; }
  body.is-3d .stop h2 { font-size: 28px; }
  body.is-3d .stop p { font-size: 14.5px; }
  body.is-3d .stop--intro { left: 16px; right: 16px; top: 108px; bottom: auto; transform: translateY(10px); max-height: none; }
  body.is-3d .stop--intro.active { transform: none; }
  body.is-3d .stop--intro .keys { display: none !important; }
  .track { left: 14px; right: 120px; width: auto; transform: none; bottom: 30px; }
  .stepper { right: 12px; bottom: 18px; }
  .stepper button { width: 44px; height: 44px; }
  .hint { display: none !important; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition-duration: .01ms !important; animation-duration: .01ms !important; }
}

/* no card transitions while the world boots, so the list layout never flashes */
body.booting .stop { transition: none !important; }

@media (max-width: 700px) {
  body.is-3d .hint.only-3d { display: none !important; }
  body.is-3d .stop--intro { padding: 20px 20px 22px; border-radius: 22px; }
  /* below the HUD and the chat button */
  body.is-3d .stop--intro { top: 116px; padding: 16px 18px 18px; }
  body.is-3d .stop--intro h1 { font-size: 38px; text-shadow: none; margin-top: 12px; }
  body.is-3d .stop--intro .lede { font-size: 14.5px; margin-top: 10px; text-shadow: none; color: var(--ink-2); }
  body.is-3d .stop--intro .actions { margin-top: 14px; }
  body.is-3d .stop--intro .chip { font-size: 11px; }
  .track { left: 24px; }
}
.hud__brand, .hud__links a, .hud__links button { white-space: nowrap; }

/* tablets and desktops: the intro sits on a frosted card so it never fights the scene */
@media (min-width: 701px) {
  body.is-3d .stop--intro { width: min(580px, calc(100vw - 44px)); padding: 24px 26px 26px; border-radius: 24px; }
  body.is-3d .stop--intro h1 { font-size: clamp(40px, 5vw, 68px); text-shadow: none; }
  body.is-3d .stop--intro .lede { font-size: 16px; text-shadow: none; color: var(--ink-2); }
}

/* sound toggle */
.hud__links .sound { display: inline-flex; align-items: center; gap: 6px; position: relative; }
.sound svg { width: 17px; height: 17px; }
.sound .waves { display: none; }
.sound[aria-pressed="true"] { color: var(--accent); }
.sound[aria-pressed="true"] .waves { display: inline; }
.sound[aria-pressed="true"] .mute { display: none; }
.sound.nudge::after { content: ""; position: absolute; top: 6px; right: 6px; width: 7px; height: 7px; border-radius: 50%; background: var(--accent); animation: nudge 1.8s ease-out infinite; }
@keyframes nudge { 0% { box-shadow: 0 0 0 0 rgba(255, 90, 54, .55); } 80%, 100% { box-shadow: 0 0 0 9px rgba(255, 90, 54, 0); } }
@media (max-width: 700px) { .sound span { display: none; } }

/* ==========================================================================
   Liquid glass
   Clear surfaces with a lit rim and a sheen that follows the pointer
   (--gx/--gy, set in drive.js). Chromium browsers also bend the scene at
   each surface's edge through the #lg-refract lens filter (html.refract).
   ========================================================================== */
.hud__brand, .hud__links, .stepper button, .hint, .stop, .btn, .chip, kbd, .track {
  --gx: 22%; --gy: 0%;
  --sheen: radial-gradient(130% 90% at var(--gx) var(--gy), rgba(255,255,255,.62), rgba(255,255,255,0) 52%);
  --glass: var(--sheen), linear-gradient(165deg, rgba(255,255,255,.36), rgba(255,255,255,.1) 58%, rgba(255,255,255,.24));
  --glass-strong: var(--sheen), linear-gradient(165deg, rgba(255,255,255,.58), rgba(255,255,255,.3) 55%, rgba(255,255,255,.44));
  --glass-dark: radial-gradient(130% 90% at var(--gx) var(--gy), rgba(255,255,255,.3), rgba(255,255,255,0) 50%), linear-gradient(165deg, rgba(34,36,42,.86), rgba(12,13,16,.74));
  --glass-edge: inset 1.5px 1.5px 0 -.5px rgba(255,255,255,.95), inset -1px -1px 0 -.5px rgba(255,255,255,.55), inset 0 0 0 1px rgba(255,255,255,.35), inset 0 0 18px rgba(255,255,255,.22), inset 0 -10px 24px -14px rgba(255,255,255,.5);
  --glass-drop: 0 12px 34px -14px rgba(18,38,58,.42), 0 2px 8px -3px rgba(18,38,58,.18);
  --glass-blur: blur(14px) saturate(1.8) brightness(1.05);
}

.hud__brand, .hud__links, .stepper button, .hint {
  background: var(--glass);
  backdrop-filter: var(--glass-blur); -webkit-backdrop-filter: var(--glass-blur);
  box-shadow: var(--glass-edge), var(--glass-drop);
}
.hud__links a:hover, .hud__links button:hover { background: rgba(255,255,255,.4); box-shadow: inset 0 1px 0 rgba(255,255,255,.8); }
.hud__links .hud__cta, .hud__links .hud__cta:hover, .stepper button[data-next] {
  background: var(--glass-dark); color: #fff;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.38), inset 0 0 0 1px rgba(255,255,255,.12), 0 8px 20px -10px rgba(0,0,0,.5);
}
.hint { color: var(--ink); }

/* the cards keep a little more frost than the controls so text reads cleanly over the scene */
body.is-3d .stop, body.is-3d .stop--intro {
  background: var(--glass-strong);
  backdrop-filter: blur(10px) saturate(1.9) brightness(1.05); -webkit-backdrop-filter: blur(10px) saturate(1.9) brightness(1.05);
  box-shadow: var(--glass-edge), 0 30px 60px -30px rgba(18, 38, 58, .5);
}

.btn:not(.btn--solid) {
  background: var(--glass); border-color: transparent;
  backdrop-filter: blur(10px) saturate(1.6); -webkit-backdrop-filter: blur(10px) saturate(1.6);
  box-shadow: var(--glass-edge), 0 6px 16px -10px rgba(18,38,58,.35);
}
.btn:not(.btn--solid):hover { background: var(--glass); filter: brightness(1.05); }
.btn--solid {
  background: radial-gradient(120% 90% at var(--gx) var(--gy), rgba(255,255,255,.38), rgba(255,255,255,0) 55%), var(--c);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.5), inset 0 -3px 8px rgba(0,0,0,.14), 0 10px 22px -12px var(--c);
}
.chip, kbd { background: var(--glass); border-color: transparent; box-shadow: var(--glass-edge); backdrop-filter: blur(8px) saturate(1.6); -webkit-backdrop-filter: blur(8px) saturate(1.6); }

/* the stop track becomes a glass capsule */
.track { isolation: isolate; }
.track::before {
  left: -18px; right: -18px; height: 34px; border-radius: 999px; z-index: -1;
  background: var(--glass); backdrop-filter: var(--glass-blur); -webkit-backdrop-filter: var(--glass-blur);
  box-shadow: var(--glass-edge), var(--glass-drop);
}
.track::after { content: ""; position: absolute; left: 0; right: 0; height: 3px; border-radius: 3px; background: rgba(23,24,28,.16); z-index: 0; }
.track .fill { z-index: 1; }
.track button { z-index: 2; }
.track .car { z-index: 3; }

/* real refraction where the browser supports SVG filters in backdrop-filter */
html.refract .hud__brand, html.refract .hud__links, html.refract .stepper button:not([data-next]), html.refract .hint, html.refract .track::before {
  backdrop-filter: url(#lg-refract) blur(3px) saturate(1.9) brightness(1.06);
}
html.refract body.is-3d .stop, html.refract .chat {
  backdrop-filter: url(#lg-refract) blur(9px) saturate(1.9) brightness(1.05);
}

/* "Try it" controls in the stop cards */
.lab { margin-top: 16px; padding-top: 14px; border-top: 1px solid rgba(23,24,28,.08); }
.lab__head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin-bottom: 9px; }
.lab__head b { font-size: 13.5px; font-weight: 600; }
.lab__head small { font: 500 10.5px/1.2 var(--mono); letter-spacing: .04em; text-transform: uppercase; color: var(--ink-3); text-align: right; }
.seg { display: flex; flex-wrap: wrap; gap: 5px; }
.seg button { flex: 1 1 auto; border: 0; border-radius: 999px; padding: 7px 11px; font: 500 12.5px/1.2 var(--sans); color: var(--ink-2); background: rgba(23,24,28,.06); cursor: pointer; transition: background .2s, color .2s, box-shadow .2s; }
.seg button:hover { background: rgba(23,24,28,.1); color: var(--ink); }
.seg button[aria-pressed="true"] { color: #fff; background: var(--c); box-shadow: inset 0 1px 0 rgba(255,255,255,.35), 0 4px 12px -6px var(--c); }
.seg button:focus-visible { outline: 2px solid var(--c); outline-offset: 2px; }
.seg .seg__flag { flex: 0 0 auto; background: transparent; box-shadow: inset 0 0 0 1.5px rgba(23,24,28,.14); }
.seg .seg__flag::before { content: "○ "; }
.seg .seg__flag[aria-pressed="true"] { color: var(--ink); background: color-mix(in srgb, var(--c) 16%, transparent); box-shadow: inset 0 0 0 1.5px var(--c); }
.seg .seg__flag[aria-pressed="true"]::before { content: "● "; color: var(--c); }
.lab__plot { display: block; width: 100%; height: 96px; margin-top: 12px; }
.lab__read { margin-top: 10px; font-size: 13.5px; line-height: 1.5; color: var(--ink-2); min-height: 3em; }
.lab__read b { color: var(--ink); }
.lab__read code { font: 500 11.5px var(--mono); padding: 1px 5px; border-radius: 5px; background: rgba(23,24,28,.06); word-break: break-all; }
.facts code { font: 500 .92em var(--mono); padding: 1px 5px; border-radius: 5px; background: rgba(23,24,28,.06); }
.lab__bubble { display: inline-block; margin-bottom: 8px; padding: 7px 12px; border-radius: 14px 14px 14px 4px; background: #fff; color: var(--ink); box-shadow: 0 2px 8px -4px rgba(0,0,0,.25); font-size: 13px; }
.receipt { margin-bottom: 8px; padding: 9px 12px; border-radius: 12px; background: rgba(255,255,255,.7); font: 400 13px/1.6 var(--sans); }
.receipt div { display: flex; justify-content: space-between; gap: 12px; }
.receipt__total { margin-top: 4px; padding-top: 4px; border-top: 1px dashed rgba(23,24,28,.15); font-weight: 600; color: var(--ink); }

/* ---------- Ask about Aman ---------- */
.chat-fab, .chat {
  --gx: 22%; --gy: 0%;
  --sheen: radial-gradient(130% 90% at var(--gx) var(--gy), rgba(255,255,255,.62), rgba(255,255,255,0) 52%);
  --glass-edge: inset 1.5px 1.5px 0 -.5px rgba(255,255,255,.95), inset -1px -1px 0 -.5px rgba(255,255,255,.55), inset 0 0 0 1px rgba(255,255,255,.35), inset 0 0 18px rgba(255,255,255,.22), inset 0 -10px 24px -14px rgba(255,255,255,.5);
}
.chat-fab {
  position: fixed; z-index: 35; right: 22px; bottom: 84px;
  display: inline-flex; align-items: center; gap: 8px; padding: 11px 16px; border: 0; border-radius: 999px; cursor: pointer;
  font-size: 14px; font-weight: 600; color: #fff;
  background: var(--sheen), linear-gradient(165deg, rgba(255, 110, 72, .95), rgba(232, 72, 40, .9));
  backdrop-filter: blur(12px) saturate(1.6); -webkit-backdrop-filter: blur(12px) saturate(1.6);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.55), inset 0 0 0 1px rgba(255,255,255,.18), 0 12px 28px -12px rgba(232, 72, 40, .7);
  transition: transform .25s var(--spring);
}
.chat-fab:hover { transform: translateY(-2px); }
.chat-fab svg { width: 18px; height: 18px; }
/* a soft ring that keeps inviting a click until the chat has been opened once */
.chat-fab::after { content: ''; position: absolute; inset: 0; border-radius: inherit; box-shadow: 0 0 0 0 rgba(255, 90, 54, .55); animation: fab-ring 2.6s ease-out infinite; pointer-events: none; }
.chat-fab.seen::after { animation: none; }
@keyframes fab-ring { 0% { box-shadow: 0 0 0 0 rgba(255, 90, 54, .5); } 70%, 100% { box-shadow: 0 0 0 14px rgba(255, 90, 54, 0); } }
.chat-fab__live { position: absolute; top: -2px; right: -2px; width: 11px; height: 11px; border-radius: 50%; background: #23c98d; box-shadow: 0 0 0 2px #fff; }

/* the speech bubble that pops out of the button */
.chat-peek {
  position: fixed; z-index: 36; right: 22px; bottom: 140px; width: min(290px, calc(100vw - 20px));
  padding: 13px 14px 14px; border-radius: 20px 20px 6px 20px;
  background: linear-gradient(165deg, rgba(255,255,255,.86), rgba(255,255,255,.66));
  backdrop-filter: blur(14px) saturate(1.8); -webkit-backdrop-filter: blur(14px) saturate(1.8);
  box-shadow: inset 1.5px 1.5px 0 -.5px rgba(255,255,255,.95), inset 0 0 0 1px rgba(255,255,255,.4), 0 22px 50px -22px rgba(18, 38, 58, .55);
  transform-origin: 100% 100%; transform: translateY(10px) scale(.6); opacity: 0;
  transition: transform .45s var(--spring), opacity .2s;
}
.chat-peek.in { transform: none; opacity: 1; }
.chat-peek[hidden] { display: none; }
.chat-peek::after { content: ''; position: absolute; right: 26px; bottom: -7px; width: 14px; height: 14px; transform: rotate(45deg); border-radius: 0 0 4px 0; background: rgba(255,255,255,.7); }
body.chat-open .chat-peek { display: none; }
.chat-peek__close { position: absolute; top: 8px; right: 8px; width: 26px; height: 26px; border: 0; border-radius: 50%; background: transparent; color: var(--ink-3); font-size: 17px; line-height: 1; cursor: pointer; }
.chat-peek__close:hover { background: rgba(23,24,28,.06); color: var(--ink); }
.chat-peek__who { display: flex; align-items: center; gap: 8px; font-size: 12px; font-weight: 600; color: var(--ink-3); }
.chat-peek__who i { display: grid; place-items: center; width: 24px; height: 24px; border-radius: 50%; font: 600 12px var(--sans); font-style: normal; color: #fff; background: linear-gradient(165deg, #ff6e48, #e84828); }
.chat-peek__text { margin: 8px 30px 10px 0; font-size: 14.5px; line-height: 1.45; color: var(--ink); min-height: 20px; }
.chat-peek__typing { display: inline-flex; gap: 4px; padding-top: 6px; }
.chat-peek__typing i { width: 6px; height: 6px; border-radius: 50%; background: var(--ink-3); animation: typing 1s infinite ease-in-out; }
.chat-peek__typing i:nth-child(2) { animation-delay: .15s; } .chat-peek__typing i:nth-child(3) { animation-delay: .3s; }
.chat-peek__qs { display: flex; flex-direction: column; align-items: flex-start; gap: 6px; }
.chat-peek__qs:empty { display: none; }
.chat-peek__qs button { border: 0; border-radius: 14px; padding: 8px 12px; font: 600 13px/1.3 var(--sans); text-align: left; cursor: pointer; color: #c23d1d; background: rgba(255, 90, 54, .1); box-shadow: inset 0 0 0 1px rgba(255, 90, 54, .22); animation: peek-q .4s var(--spring) both; transition: background .2s; }
.chat-peek__qs button:nth-child(2) { animation-delay: .08s; }
.chat-peek__qs button:hover { background: rgba(255, 90, 54, .18); }
@keyframes peek-q { from { opacity: 0; transform: translateY(6px); } }
body:not(.is-3d) .chat-peek { bottom: 78px; }
body.chat-open .chat-fab { opacity: 0; pointer-events: none; }
.chat-fab[hidden] { display: none; }
body:not(.is-3d) .chat-fab { bottom: 22px; }

.chat {
  position: fixed; z-index: 40; right: 22px; bottom: 84px; width: min(390px, calc(100vw - 44px)); height: min(560px, calc(100dvh - 170px));
  display: flex; flex-direction: column; border-radius: 24px; overflow: hidden;
  background: var(--sheen), linear-gradient(165deg, rgba(255,255,255,.6), rgba(255,255,255,.34) 55%, rgba(255,255,255,.48));
  backdrop-filter: blur(11px) saturate(1.9) brightness(1.05); -webkit-backdrop-filter: blur(11px) saturate(1.9) brightness(1.05);
  box-shadow: var(--glass-edge), 0 30px 70px -30px rgba(18, 38, 58, .55);
  animation: chat-in .45s var(--spring);
}
.chat[hidden] { display: none; }
@keyframes chat-in { from { opacity: 0; transform: translateY(16px) scale(.97); } to { opacity: 1; transform: none; } }
.chat__head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 16px 16px 12px 18px; border-bottom: 1px solid rgba(23,24,28,.07); }
.chat__head b { display: block; font: 400 24px/1.1 var(--serif); }
.chat__head small { font-size: 12px; color: var(--ink-3); }
.chat__close { width: 34px; height: 34px; border: 0; border-radius: 50%; background: rgba(255,255,255,.6); box-shadow: inset 0 0 0 1px rgba(23,24,28,.08); font-size: 20px; line-height: 1; cursor: pointer; color: var(--ink-2); }
.chat__log { flex: 1; overflow-y: auto; padding: 14px 16px; display: flex; flex-direction: column; gap: 10px; overscroll-behavior: contain; }
.msg { max-width: 88%; padding: 10px 13px; border-radius: 16px; font-size: 14.5px; line-height: 1.5; white-space: normal; }
.msg--assistant { align-self: flex-start; background: rgba(255,255,255,.82); box-shadow: inset 0 0 0 1px rgba(23,24,28,.06); border-bottom-left-radius: 6px; }
.msg--user { align-self: flex-end; background: var(--ink); color: #fff; border-bottom-right-radius: 6px; }
.msg--error { background: #fff3ee; color: #8a2f17; }
.msg a { color: inherit; font-weight: 600; }
.msg code { font-size: .92em; padding: 1px 5px; border-radius: 5px; background: rgba(20,20,30,.07); }
.msg__stops { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.msg__stop { border: 0; border-radius: 999px; padding: 7px 11px; font-size: 12.5px; font-weight: 600; cursor: pointer; color: #fff; background: linear-gradient(165deg, #ff6e48, #e84828); box-shadow: inset 0 1px 0 rgba(255,255,255,.45); }
.msg--typing { display: inline-flex; gap: 5px; padding: 13px 14px; }
.msg--typing i { width: 7px; height: 7px; border-radius: 50%; background: var(--ink-3); animation: typing 1s infinite ease-in-out; }
.msg--typing i:nth-child(2) { animation-delay: .15s; } .msg--typing i:nth-child(3) { animation-delay: .3s; }
@keyframes typing { 0%, 80%, 100% { opacity: .3; transform: translateY(0); } 40% { opacity: 1; transform: translateY(-3px); } }
.chat__chips { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 16px 10px; }
.chat__chips[hidden] { display: none; }
.chat__chips button { border: 0; border-radius: 999px; padding: 7px 11px; font-size: 12.5px; cursor: pointer; color: var(--ink-2); background: rgba(255,255,255,.7); box-shadow: inset 0 0 0 1px rgba(23,24,28,.08); }
.chat__chips button:hover { color: var(--ink); background: #fff; }
.chat__form { display: flex; gap: 8px; padding: 10px 12px 12px; border-top: 1px solid rgba(23,24,28,.07); }
.chat__form input { flex: 1; min-width: 0; border: 0; border-radius: 999px; padding: 11px 15px; font: inherit; font-size: 14.5px; background: rgba(255,255,255,.85); box-shadow: inset 0 0 0 1px rgba(23,24,28,.1); color: var(--ink); }
.chat__form input:focus { outline: 2px solid var(--accent); outline-offset: 0; }
.chat__form button { width: 42px; height: 42px; border: 0; border-radius: 50%; cursor: pointer; font-size: 18px; color: #fff; background: var(--ink); }
.chat__form.busy button { opacity: .4; pointer-events: none; }

@media (max-width: 700px) {
  .chat-fab { top: 66px; bottom: auto; right: 10px; padding: 10px; }
  .chat-fab span { display: none; }
  /* on phones the button sits at the top, so the bubble hangs below it */
  .chat-peek { top: 118px; bottom: auto; right: 10px; width: min(260px, calc(100vw - 20px)); border-radius: 20px 6px 20px 20px; transform-origin: 100% 0; transform: translateY(-10px) scale(.6); }
  .chat-peek.in { transform: none; }
  .chat-peek::after { top: -7px; bottom: auto; right: 14px; border-radius: 4px 0 0 0; background: rgba(255,255,255,.86); }
  .chat-peek__text { font-size: 14px; margin-bottom: 8px; }
  .chat-peek__qs button { font-size: 12.5px; padding: 7px 11px; }
  body:not(.is-3d) .chat-peek { top: auto; bottom: 70px; border-radius: 20px 20px 6px 20px; }
  body:not(.is-3d) .chat-peek::after { top: auto; bottom: -7px; border-radius: 0 0 4px 0; }
  body:not(.is-3d) .chat-fab { top: auto; bottom: 18px; }
  .chat { left: 10px; right: 10px; bottom: 10px; width: auto; height: min(72dvh, 600px); }
}
@media (max-width: 420px) {
  .hud { gap: 6px; }
  .hud__brand { padding: 9px 11px; font-size: 13.5px; gap: 7px; }
  .hud__brand svg { width: 20px; }
  .hud__links { gap: 0; padding: 4px; }
  .hud__links a, .hud__links button { padding: 8px 9px; font-size: 13px; }
}
