/* ───────────── Fonts ───────────── */
@font-face {
  font-family: "Geist";
  src: url("https://fonts.gstatic.com/s/geist/v5/gyByhwUxId8gMEwcGFU.woff2") format("woff2");
  font-weight: 100 900; font-display: swap;
}
@font-face {
  font-family: "Geist Mono";
  src: url("https://fonts.gstatic.com/s/geistmono/v6/or3nQ6H-1_WfwkMZI_qYFrcdmg.woff2") format("woff2");
  font-weight: 100 900; font-display: swap;
}
@font-face {
  font-family: "Instrument Serif";
  src: url("https://fonts.gstatic.com/s/instrumentserif/v5/jizBRFtNs2ka5fXjeivQ4LroWlx-6zUTjg.woff2") format("woff2");
  font-weight: 400; font-display: swap;
}

/* ───────────── Tokens ───────────── */
:root {
  --color-night: #0f110d;
  --color-paper: #f0e5c8;
  --color-dots: #c9d4b8;
  --color-tech: #7fa8a3;
  --color-muted: #7f8a6a;
  --color-surface: #fff;
  --color-ink: #111;
  --color-line: #1111111a;
  --font-sans: "Geist", ui-sans-serif, system-ui, sans-serif;
  --font-mono: "Geist Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  --font-serif: "Instrument Serif", Georgia, "Times New Roman", serif;
  /* Apple's SF on Mac/iOS, Inter Tight elsewhere */
  --font-ui: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Inter Tight", "Inter", system-ui, sans-serif;
  /* Hardware cursor: drawn by the OS, so it never lags behind the WebGL frame */
  --cursor-hero: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='24' height='24'><circle cx='12' cy='12' r='7.5' fill='none' stroke='%23000' stroke-opacity='.35' stroke-width='2.6'/><circle cx='12' cy='12' r='7.5' fill='none' stroke='%23f0e5c8' stroke-width='1.2'/><circle cx='12' cy='12' r='1.7' fill='%23f0e5c8'/></svg>") 12 12, crosshair;

  /* Extra UI tokens (windows, dock) */
  --ui-fill: color-mix(in srgb, var(--color-paper) 6%, transparent);
  --ui-fill-hover: color-mix(in srgb, var(--color-paper) 11%, transparent);
  --ui-fill-active: color-mix(in srgb, var(--color-paper) 16%, transparent);
  --ui-line: color-mix(in srgb, var(--color-paper) 13%, transparent);
  --ui-sub: color-mix(in srgb, var(--color-paper) 55%, transparent);
  --win-bg: color-mix(in srgb, #0f110d 80%, transparent);
  --win-shadow: 0 40px 90px -30px #000c, 0 0 0 1px #0004;
  --ok: #9cc58a;
  --warn: #d8b36a;
  --off: #a46a5f;
  --grain-filter: invert(1);
  --grain-opacity: .05;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  color-scheme: dark;
}

/* Light mode: paper and ink trade places. */
/* Light mode — "Mist": a soft sage-grey morning, low glare, low contrast.
   The canvas is transparent here, so the gradient below shows through. */
[data-theme="light"] {
  --color-night: #d5dacf;
  --color-paper: #29332a;
  --color-dots: #3f4d3c;
  --color-tech: #4d7c75;
  --color-muted: #6a7564;
  --color-surface: #2b352c;
  --color-ink: #e9ece4;
  --color-line: #e9ece41a;
  --ui-fill: color-mix(in srgb, #f4f6f0 42%, transparent);
  --ui-fill-hover: color-mix(in srgb, #f4f6f0 62%, transparent);
  --ui-fill-active: color-mix(in srgb, #ffffff 70%, transparent);
  --ui-line: color-mix(in srgb, #29332a 10%, transparent);
  --ui-sub: color-mix(in srgb, #29332a 58%, transparent);
  --win-bg: color-mix(in srgb, #e8ebe3 82%, transparent);
  --win-shadow: 0 40px 80px -36px #2d3a2a55, 0 0 0 1px #29332a10;
  --mist-bg:
    radial-gradient(ellipse 55% 65% at 50% 38%, #e7eae1 0%, #e7eae100 70%),
    radial-gradient(ellipse 130% 100% at 50% 40%, #d7dcd1 40%, #c3cabb 100%);
  --ok: #4f8a3c;
  --warn: #9a7a35;
  --off: #9b4a3c;
  --grain-filter: none;
  --grain-opacity: .035;
  --cursor-hero: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='24' height='24'><circle cx='12' cy='12' r='7.5' fill='none' stroke='%23fff' stroke-opacity='.55' stroke-width='2.6'/><circle cx='12' cy='12' r='7.5' fill='none' stroke='%2329332a' stroke-width='1.2'/><circle cx='12' cy='12' r='1.7' fill='%2329332a'/></svg>") 12 12, crosshair;
  color-scheme: light;
}
[data-theme="light"] .page { background: var(--mist-bg), var(--color-night); }

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--color-night); }
body {
  font-family: var(--font-sans);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
button { font: inherit; color: inherit; }

/* ───────────── Page ───────────── */
.page {
  position: fixed; inset: 0; overflow: hidden; overflow: clip;
  background: var(--color-night);
  color: var(--color-paper);
  cursor: crosshair;
  touch-action: none;
  transition: background-color .5s ease, color .5s ease;
}
.page[data-phase="ready"] { cursor: var(--cursor-hero); }
.page::after {
  content: ""; position: absolute; inset: 0; pointer-events: none; z-index: 60;
  background: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='240' height='240'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='3' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 0  0 0 0 0 0  0 0 0 0 0  1.7 0 0 0 -0.6'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>");
  filter: var(--grain-filter);
  opacity: var(--grain-opacity);
}
.stage { position: absolute; inset: 0; }
.stage canvas { width: 100%; height: 100%; display: block; }

/* ───────────── Loader ───────────── */
.loader {
  position: absolute; inset: 0; display: grid; place-items: center;
  pointer-events: none;
  transition: opacity .5s .15s;
}
.page[data-phase="ready"] .loader { opacity: 0; }
.ring {
  position: absolute; width: 220px; height: 220px;
  top: 50%; left: 50%; translate: -50% -50%;
  overflow: visible;
}
.ring circle {
  fill: color-mix(in srgb, var(--color-paper) 18%, transparent);
  r: 1.6;
  transition: fill .25s, r .25s;
}
.ring circle[data-on] { fill: var(--color-paper); r: 2.2px; }
.counter {
  position: absolute; top: 50%; left: 50%; translate: -50% -60%;
  font-family: var(--font-mono); font-size: 34px;
  letter-spacing: .02em; font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.label {
  position: absolute; top: 50%; left: 50%; translate: -50% 26px;
  font-family: var(--font-mono); font-size: 11px;
  text-transform: uppercase; letter-spacing: .12em; opacity: .5;
  white-space: nowrap;
}

/* ───────────── Hero text ───────────── */
.logo, .name, .tagline {
  opacity: 0; margin: 0; position: absolute;
  transition: opacity .9s, translate .9s var(--ease);
}
.name, .tagline {
  font-family: var(--font-sans); font-weight: 400;
  font-size: clamp(17px, 1.6vw, 24px);
  letter-spacing: -.01em;
  top: 50%; translate: 0 calc(10px - 50%);
  pointer-events: none;
}
.name { left: clamp(20px, 4vw, 64px); }
.tagline { right: clamp(20px, 4vw, 64px); color: var(--color-muted); transition-delay: .12s; }
.page[data-phase="ready"] .name,
.page[data-phase="ready"] .tagline { opacity: 1; translate: 0 -50%; }

.logo {
  font-family: var(--font-serif); font-size: 26px; color: inherit; text-decoration: none;
  top: 20px; left: clamp(20px, 4vw, 64px);
  cursor: pointer; z-index: 5;
}
.page[data-phase="ready"] .logo { opacity: .9; }
.page[data-phase="ready"] .logo:hover,
.page[data-phase="ready"] .logo:focus-visible { opacity: 1; text-decoration: underline; text-underline-offset: 4px; outline: none; }


/* ───────────── Pill ───────────── */
/* "How this page was made": dissolved into the page until the cursor finds it */
.pill {
  position: fixed; bottom: 20px; left: 20px; z-index: 7;
  display: inline-flex; align-items: center; gap: 8px;
  font-family: var(--font-ui); font-size: 13px; font-weight: 500; letter-spacing: -.005em;
  padding: 9px 16px; border-radius: 999px; text-decoration: none;
  color: var(--color-paper);
  background: transparent;
  cursor: pointer; isolation: isolate;
  --mx: 50%; --my: 50%;
}
/* glass body, grows in on hover */
.pill::before {
  content: ""; position: absolute; inset: 0; z-index: -1; border-radius: inherit;
  background:
    radial-gradient(120px circle at var(--mx) var(--my), color-mix(in srgb, var(--color-tech) 30%, transparent), transparent 70%),
    var(--ui-fill-hover);
  backdrop-filter: blur(14px) saturate(1.2); -webkit-backdrop-filter: blur(14px) saturate(1.2);
  box-shadow: inset 0 0 0 1px var(--ui-line), 0 12px 32px -14px color-mix(in srgb, var(--color-tech) 55%, transparent);
  opacity: 0; transform: scale(.82, .6);
  transition: opacity .45s ease, transform .6s cubic-bezier(.34, 1.45, .5, 1);
}
/* a thin light that runs around the edge once */
.pill::after {
  content: ""; position: absolute; inset: 0; z-index: -1; border-radius: inherit; padding: 1px;
  background: conic-gradient(from var(--pill-a, 0deg), transparent 0 70%, color-mix(in srgb, var(--color-tech) 90%, #fff) 82%, transparent 94%);
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor; mask-composite: exclude;
  opacity: 0; transition: opacity .3s ease;
}
@property --pill-a { syntax: "<angle>"; inherits: false; initial-value: 0deg; }
@keyframes pill-orbit { to { --pill-a: 360deg; } }
.pill .pill-text { white-space: nowrap; }
.pill .pc {
  display: inline-block; white-space: pre;
  opacity: .32; filter: blur(.3px);
  transition: opacity .5s ease, transform .5s cubic-bezier(.34, 1.56, .64, 1), filter .5s ease;
  transition-delay: calc(var(--i) * 14ms);
}
.pill .arrow { display: inline-block; opacity: .32; transition: opacity .4s ease, transform .6s cubic-bezier(.34, 1.56, .64, 1); }
.pill:hover::before, .pill:focus-visible::before { opacity: 1; transform: none; }
.pill:hover::after, .pill:focus-visible::after { opacity: 1; animation: pill-orbit 2.4s linear infinite; }
.pill:hover .pc, .pill:focus-visible .pc { opacity: 1; filter: none; animation: pill-wave .55s ease both; animation-delay: calc(var(--i) * 18ms); }
.pill:hover .arrow, .pill:focus-visible .arrow { opacity: 1; transform: translateX(5px); }
.pill:focus-visible { outline: none; }
@keyframes pill-wave { 40% { transform: translateY(-3px); } }
.page:not([data-pill]) .pill { visibility: hidden; }
.page[data-pill] .pill { animation: pill-in .6s var(--ease) both; }
@keyframes pill-in { 0% { opacity: 0; transform: translateY(8px); } }

/* ───────────── Dock (tabs) + controls ───────────── */
.dock, .controls {
  position: absolute; top: 18px; z-index: 8;
  display: flex; align-items: center; gap: 2px;
  opacity: 0; pointer-events: none;
  transition: opacity .9s .35s, translate .9s .35s var(--ease);
  cursor: auto;
}
.dock {
  left: 50%; translate: -50% -8px;
  padding: 4px; border-radius: 999px;
  background: var(--ui-fill);
  box-shadow: inset 0 0 0 1px var(--ui-line);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
}
.controls { right: clamp(20px, 4vw, 64px); translate: 0 -8px; gap: 8px; }
.page[data-phase="ready"] .dock { opacity: 1; pointer-events: auto; translate: -50% 0; }
.page[data-phase="ready"] .controls { opacity: 1; pointer-events: auto; translate: 0 0; }

.tab {
  position: relative; z-index: 1;
  display: inline-flex; align-items: center; gap: 7px;
  border: 0; background: transparent; cursor: pointer;
  font-family: var(--font-ui); font-size: 13.5px; font-weight: 500;
  letter-spacing: -.012em; font-feature-settings: "ss01", "cv11";
  color: color-mix(in srgb, var(--color-paper) 66%, transparent);
  padding: 7px 15px; border-radius: 999px; white-space: nowrap;
  transition: color .3s ease, background-color .3s ease;
  -webkit-font-smoothing: antialiased;
}
.tab:hover, .tab:focus-visible { color: var(--color-paper); outline: none; }
.tab:focus-visible { box-shadow: 0 0 0 2px color-mix(in srgb, var(--color-tech) 60%, transparent); }
.tab[aria-pressed="true"] { color: var(--color-paper); background: var(--ui-fill-active); }
.tab-idx { display: none; }
.tab-pre { opacity: .55; font-weight: 400; }
.tab-pre::after { content: ""; }
.dock-glider {
  position: absolute; top: 4px; bottom: 4px; left: 0; width: 0; z-index: 0;
  border-radius: 999px; pointer-events: none;
  background: color-mix(in srgb, var(--color-paper) 10%, transparent);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--color-paper) 8%, transparent), 0 1px 2px #0002;
  opacity: 0;
  transition: left .42s cubic-bezier(.32, 1.25, .5, 1), width .42s cubic-bezier(.32, 1.25, .5, 1), opacity .25s ease;
}
.dock:hover .dock-glider { opacity: 1; }
.tab-dot, .status-dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: color-mix(in srgb, var(--color-paper) 30%, transparent);
  flex: none;
}
.tab-dot[data-status="online"], .status-dot[data-status="online"] { background: var(--ok); box-shadow: 0 0 8px var(--ok); }
.tab-dot[data-status="demo"], .status-dot[data-status="demo"] { background: var(--warn); }
.tab-dot[data-status="ready"], .status-dot[data-status="ready"] { background: var(--color-tech); box-shadow: 0 0 8px var(--color-tech); }
.tab-dot[data-status="offline"], .status-dot[data-status="offline"] { background: var(--off); }
.tab-dot[data-status="checking"], .status-dot[data-status="checking"] { animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .3; } }

.seg {
  display: flex; padding: 3px; border-radius: 999px;
  background: var(--ui-fill); box-shadow: inset 0 0 0 1px var(--ui-line);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
}
.seg button {
  border: 0; background: transparent; cursor: pointer;
  font-family: var(--font-ui); font-size: 12.5px; font-weight: 500; letter-spacing: .01em;
  padding: 6px 10px; border-radius: 999px;
  color: color-mix(in srgb, var(--color-paper) 60%, transparent);
  transition: background-color .25s, color .25s;
}
.seg button[aria-pressed="true"] { background: var(--ui-fill-active); color: var(--color-paper); }
.seg button:hover { color: var(--color-paper); }
.theme-btn {
  width: 34px; height: 34px; border-radius: 50%; border: 0; cursor: pointer;
  display: grid; place-items: center;
  background: var(--ui-fill); box-shadow: inset 0 0 0 1px var(--ui-line);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  color: var(--color-paper);
  transition: background-color .25s, rotate .6s var(--ease);
}
.theme-btn:hover { background: var(--ui-fill-hover); rotate: 20deg; }
.theme-btn .i-moon { display: none; }
[data-theme="light"] .theme-btn .i-sun { display: none; }
[data-theme="light"] .theme-btn .i-moon { display: block; }

/* ───────────── Windows ───────────── */
.windows { position: absolute; inset: 0; pointer-events: none; z-index: 20; overflow: clip; }
.win {
  position: absolute; pointer-events: auto;
  display: flex; flex-direction: column;
  min-width: 300px; min-height: 260px;
  background: var(--win-bg);
  backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
  border-radius: 14px;
  contain: layout paint;
  box-shadow: var(--win-shadow), inset 0 0 0 1px var(--ui-line);
  color: var(--color-paper);
  cursor: auto; touch-action: auto;
  opacity: 0; transform: translateY(10px) scale(.975);
  transform-origin: 50% 0;
  transition: opacity .35s ease, transform .5s var(--ease), box-shadow .3s;
  overflow: hidden;
  resize: both;
}
.win.open { opacity: 1; transform: none; }
.win.closing { opacity: 0; transform: translateY(6px) scale(.985); transition-duration: .22s; }
.win.focused { box-shadow: var(--win-shadow), inset 0 0 0 1px color-mix(in srgb, var(--color-paper) 22%, transparent); }
.win-bar {
  display: flex; align-items: center; gap: 10px;
  padding: 11px 12px 11px 16px;
  border-bottom: 1px solid var(--ui-line);
  cursor: grab; user-select: none; -webkit-user-select: none; touch-action: none;
}
.win-bar:active { cursor: grabbing; }
.win-titles { display: flex; flex-direction: column; gap: 2px; min-width: 0; flex: 1; }
.win-title {
  font-family: var(--font-mono); font-size: 11px; text-transform: uppercase; letter-spacing: .12em;
  display: flex; align-items: center; gap: 8px; white-space: nowrap;
}
.win-sub { font-size: 12px; color: var(--ui-sub); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.win-actions { display: flex; gap: 4px; }
.icon-btn {
  width: 30px; height: 30px; border-radius: 8px; border: 0; cursor: pointer;
  display: grid; place-items: center; background: transparent; color: var(--ui-sub);
  transition: background-color .2s, color .2s;
}
.icon-btn:hover, .icon-btn:focus-visible { background: var(--ui-fill-hover); color: var(--color-paper); outline: none; }
.icon-btn[aria-pressed="true"] { background: var(--ui-fill-active); color: var(--color-paper); }
.win-body { flex: 1; min-height: 0; position: relative; display: flex; flex-direction: column; }

/* ───────────── Chat ───────────── */
.chat-msgs {
  flex: 1; overflow-y: auto; padding: 18px 18px 8px;
  display: flex; flex-direction: column; gap: 16px;
  scrollbar-width: thin; scrollbar-color: var(--ui-line) transparent;
  overscroll-behavior: contain;
}
.msg { font-size: 14.5px; line-height: 1.6; max-width: 92%; overflow-wrap: anywhere; animation: msg-in .45s var(--ease) both; }
@keyframes msg-in { from { opacity: 0; transform: translateY(6px); } }
.msg.user {
  align-self: flex-end; max-width: 82%;
  background: var(--ui-fill-hover);
  padding: 9px 13px; border-radius: 14px 14px 4px 14px;
  white-space: pre-wrap;
}
.msg.ai { align-self: flex-start; display: grid; grid-template-columns: 18px 1fr; gap: 10px; }
.msg.ai .avatar { width: 8px; height: 8px; margin: 8px 5px 0; border-radius: 50%; background: var(--color-tech); box-shadow: 0 0 10px var(--color-tech); }
.msg.ai.streaming .avatar { animation: pulse 1s ease-in-out infinite; }
.msg.ai .body > :first-child { margin-top: 0; }
.msg.ai .body > :last-child { margin-bottom: 0; }
.msg.ai .body p { margin: 0 0 .7em; }
.msg.ai .body ul, .msg.ai .body ol { margin: 0 0 .7em; padding-left: 1.3em; }
.msg.ai .body h3, .msg.ai .body h4 { font-size: 1em; margin: .9em 0 .4em; font-weight: 600; }
.msg.ai .body code {
  font-family: var(--font-mono); font-size: .86em;
  background: var(--ui-fill-hover); padding: .1em .35em; border-radius: 4px;
}
.msg.ai .body pre {
  background: color-mix(in srgb, var(--color-night) 70%, #000 12%);
  box-shadow: inset 0 0 0 1px var(--ui-line);
  padding: 11px 13px; border-radius: 9px; overflow-x: auto; margin: 0 0 .7em;
}
[data-theme="light"] .msg.ai .body pre { background: #fffdf6; }
.msg.ai .body pre code { background: none; padding: 0; font-size: 12.5px; line-height: 1.55; }
.msg.ai.streaming .body::after {
  content: ""; display: inline-block; width: 7px; height: 1em; margin-left: 2px; vertical-align: -2px;
  background: var(--color-tech); animation: blink 1s steps(2) infinite;
}
@keyframes blink { 50% { opacity: 0; } }
.msg.error .body { color: var(--off); }
.msg-meta {
  grid-column: 2; margin-top: 6px;
  font-family: var(--font-mono); font-size: 10.5px; letter-spacing: .06em; color: var(--ui-sub);
  display: flex; gap: 12px; flex-wrap: wrap;
}
.chat-empty {
  margin: auto; text-align: center; padding: 24px 12px; max-width: 420px;
  display: flex; flex-direction: column; align-items: center; gap: 12px;
}
.chat-empty .big { font-family: var(--font-serif); font-size: 34px; line-height: 1.05; letter-spacing: -.01em; }
.chat-empty .small { font-family: var(--font-mono); font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: var(--ui-sub); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; margin-top: 6px; }
.chip {
  border: 0; cursor: pointer; font-size: 13px; padding: 7px 11px; border-radius: 999px;
  background: var(--ui-fill); box-shadow: inset 0 0 0 1px var(--ui-line);
  transition: background-color .2s;
}
.chip:hover { background: var(--ui-fill-hover); }

.chat-tools {
  display: flex; align-items: center; gap: 10px; padding: 8px 14px 0;
  font-family: var(--font-mono); font-size: 10.5px; letter-spacing: .06em; color: var(--ui-sub);
}
.chat-tools .spacer { flex: 1; }
.chat-tools label { display: flex; align-items: center; gap: 8px; }
.chat-tools output { min-width: 2.2em; color: var(--color-paper); }
.link-btn {
  border: 0; background: none; cursor: pointer; padding: 4px 6px; border-radius: 6px;
  font-family: var(--font-mono); font-size: 10.5px; letter-spacing: .06em; text-transform: uppercase; color: var(--ui-sub);
}
.link-btn:hover { color: var(--color-paper); background: var(--ui-fill); }
input[type="range"] { accent-color: var(--color-tech); width: 90px; }

.chat-settings {
  margin: 8px 14px 0; padding: 12px; border-radius: 10px;
  background: var(--ui-fill); box-shadow: inset 0 0 0 1px var(--ui-line);
  display: none; flex-direction: column; gap: 10px;
}
.chat-settings.show { display: flex; }
.chat-settings label { display: flex; flex-direction: column; gap: 6px; font-family: var(--font-mono); font-size: 10.5px; letter-spacing: .06em; text-transform: uppercase; color: var(--ui-sub); }
.chat-settings textarea, .chat-settings input[type="number"] {
  font-family: var(--font-sans); font-size: 13px; text-transform: none; letter-spacing: 0;
  background: transparent; color: var(--color-paper); border: 0;
  box-shadow: inset 0 0 0 1px var(--ui-line); border-radius: 8px; padding: 8px 10px; resize: vertical; outline: none;
}
.chat-settings textarea:focus, .chat-settings input:focus { box-shadow: inset 0 0 0 1px var(--color-tech); }

.composer { display: flex; align-items: flex-end; gap: 8px; padding: 10px 12px 12px; }
.composer textarea {
  flex: 1; resize: none; max-height: 170px; min-height: 42px;
  font: 14.5px/1.45 var(--font-sans); color: var(--color-paper);
  background: var(--ui-fill); border: 0; border-radius: 12px; padding: 11px 13px;
  box-shadow: inset 0 0 0 1px var(--ui-line); outline: none;
  transition: box-shadow .2s;
}
.composer textarea::placeholder { color: var(--ui-sub); }
.composer textarea:focus { box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--color-tech) 70%, transparent); }
.send-btn {
  width: 42px; height: 42px; border-radius: 12px; border: 0; cursor: pointer; flex: none;
  display: grid; place-items: center;
  background: var(--color-paper); color: var(--color-night);
  transition: transform .2s var(--ease), opacity .2s;
}
.send-btn:hover { transform: translateY(-1px); }
.send-btn:disabled { opacity: .35; cursor: default; transform: none; }
.send-btn .i-stop { display: none; }
.send-btn.stop .i-stop { display: block; }
.send-btn.stop .i-send { display: none; }

.login {
  margin: auto; width: min(320px, 90%); display: flex; flex-direction: column; gap: 10px; text-align: center; padding: 20px 0;
}
.login .big { font-family: var(--font-serif); font-size: 30px; }
.login p { margin: 0; color: var(--ui-sub); font-size: 13px; }
.login input {
  font: 14px var(--font-mono); color: var(--color-paper); background: var(--ui-fill);
  border: 0; border-radius: 10px; padding: 11px 13px; box-shadow: inset 0 0 0 1px var(--ui-line); outline: none; text-align: center;
}
.login button {
  border: 0; border-radius: 10px; padding: 11px; cursor: pointer;
  background: var(--color-paper); color: var(--color-night); font-family: var(--font-mono); font-size: 12px; letter-spacing: .08em; text-transform: uppercase;
}
.login .err { color: var(--off); font-size: 12px; min-height: 1em; }

/* ───────────── Garden ───────────── */
.garden { position: relative; flex: 1; min-height: 0; }
.garden canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; cursor: crosshair; touch-action: none; }
.garden-hud {
  position: absolute; left: 14px; right: 14px; bottom: 12px;
  display: flex; align-items: center; gap: 10px; pointer-events: none;
  font-family: var(--font-mono); font-size: 10.5px; letter-spacing: .08em; text-transform: uppercase; color: var(--ui-sub);
}
.garden-hud .spacer { flex: 1; }
.garden-hud button { pointer-events: auto; }
.garden-empty {
  position: absolute; inset: 0; display: grid; place-items: center; pointer-events: none;
  font-family: var(--font-serif); font-size: 30px; color: var(--ui-sub); transition: opacity .6s;
}

/* ───────────── Pairs ───────────── */
.pairs { flex: 1; min-height: 0; display: flex; flex-direction: column; padding: 14px 16px 16px; gap: 12px; }
.pairs-hud {
  display: flex; align-items: center; gap: 16px;
  font-family: var(--font-mono); font-size: 10.5px; letter-spacing: .08em; text-transform: uppercase; color: var(--ui-sub);
}
.pairs-hud b { color: var(--color-paper); font-weight: 400; font-variant-numeric: tabular-nums; }
.pairs-hud .spacer { flex: 1; }
.pairs-grid {
  flex: 1; min-height: 0;
  display: grid; grid-template-columns: repeat(4, 1fr); grid-auto-rows: 1fr; gap: 10px;
}
.card {
  position: relative; border: 0; padding: 0; cursor: pointer; background: transparent;
  perspective: 700px; min-height: 64px;
}
.card-inner {
  position: absolute; inset: 0; transform-style: preserve-3d;
  transition: transform .55s var(--ease);
}
.card.up .card-inner, .card.done .card-inner { transform: rotateY(180deg); }
.card-face {
  position: absolute; inset: 0; border-radius: 12px; backface-visibility: hidden; -webkit-backface-visibility: hidden;
  display: grid; place-items: center;
  box-shadow: inset 0 0 0 1px var(--ui-line);
}
.card-back {
  background:
    radial-gradient(circle at 50% 50%, color-mix(in srgb, var(--color-paper) 22%, transparent) 1.2px, transparent 1.6px) 0 0 / 12px 12px,
    var(--ui-fill);
}
.card:hover .card-back { background-color: var(--ui-fill-hover); }
.card-front { transform: rotateY(180deg); background: var(--ui-fill-hover); }
.card-front svg { width: 62%; height: 62%; color: var(--color-paper); }
.card.done .card-front { box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--color-tech) 70%, transparent); }
.card.done .card-front svg { color: var(--color-tech); }
.card.shake .card-inner { animation: shake .4s; }
@keyframes shake { 25% { translate: -4px 0; } 75% { translate: 4px 0; } }
.pairs-win {
  position: absolute; inset: 0; display: grid; place-items: center; text-align: center;
  background: color-mix(in srgb, var(--color-night) 55%, transparent);
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  opacity: 0; pointer-events: none; transition: opacity .5s;
}
.pairs-win.show { opacity: 1; pointer-events: auto; }
.pairs-win .big { font-family: var(--font-serif); font-size: 40px; }
.pairs-win p { margin: 6px 0 16px; font-family: var(--font-mono); font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: var(--ui-sub); }
.solid-btn {
  border: 0; border-radius: 10px; padding: 10px 16px; cursor: pointer;
  background: var(--color-paper); color: var(--color-night);
  font-family: var(--font-mono); font-size: 11px; letter-spacing: .1em; text-transform: uppercase;
}

/* ───────────── About ───────────── */
.about { overflow-y: auto; padding: 22px 24px 26px; font-size: 14.5px; line-height: 1.65; }
.about .big { font-family: var(--font-serif); font-size: 36px; line-height: 1.05; margin: 0 0 14px; font-weight: 400; }
.about p { margin: 0 0 .9em; color: color-mix(in srgb, var(--color-paper) 85%, transparent); }
.about ol { margin: 0 0 1em; padding: 0; list-style: none; counter-reset: s; display: grid; gap: 10px; }
.about li { counter-increment: s; display: grid; grid-template-columns: 34px 1fr; }
.about li::before { content: counter(s, decimal-leading-zero); font-family: var(--font-mono); font-size: 11px; color: var(--ui-sub); padding-top: 3px; }
.about code { font-family: var(--font-mono); font-size: .85em; background: var(--ui-fill-hover); padding: .1em .35em; border-radius: 4px; }

/* ───────────── Mobile (spec) ───────────── */
@media (max-width: 700px) {
  .name, .tagline { font-size: 16px; top: 72px; translate: 0 10px; }
  .name { white-space: nowrap; }
  .page .tagline { max-width: calc(100% - 160px); text-align: right; line-height: 1.3; }
  .page[data-phase="ready"] .name,
  .page[data-phase="ready"] .tagline { translate: 0 0; }

  .dock { top: auto; bottom: 94px; translate: -50% 8px; }
  .page[data-phase="ready"] .dock { translate: -50% 0; }
  .tab { padding: 7px 11px; font-size: 13px; gap: 5px; }
  .tab-idx, .tab-pre { display: none; }
  .controls { top: 18px; }

  .win {
    left: 8px !important; top: 8px !important; right: 8px; bottom: 8px;
    width: auto !important; height: auto !important; resize: none;
    transform-origin: 50% 100%; transform: translateY(24px);
  }
  .win-bar { cursor: default; }
  .pairs-grid { gap: 7px; }
}
@media (max-width: 600px) {
  .pill { padding: 7px 12px; font-size: 12px; bottom: 12px; left: auto; right: 12px; }
  .pill .pc, .pill .arrow { opacity: .55; }
}
@media (max-width: 900px) and (min-width: 701px) {
  .tab-idx { display: none; }
}

/* ───────────── Theme switch (View Transitions) ───────────── */
::view-transition-old(root),
::view-transition-new(root) { animation: none; mix-blend-mode: normal; }
::view-transition-old(root) { z-index: 1; }
::view-transition-new(root) { z-index: 2; }

/* ───────────── Rotating tagline ───────────── */
.tagline { max-width: min(34vw, 460px); text-align: right; line-height: 1.25; }
.anim-text .w { display: inline-block; white-space: nowrap; }
.anim-text .wm { display: inline-block; white-space: nowrap; overflow: hidden; vertical-align: top; padding-bottom: .08em; }
.anim-text .ch { display: inline-block; white-space: pre; will-change: transform, opacity, filter; }
.anim-text .caret { display: inline-block; width: 2px; height: 1em; margin-left: 3px; vertical-align: -.12em; background: currentColor; animation: blink .9s steps(2) infinite; }
.anim-text.flip { perspective: 600px; }
.name.anim-text { white-space: nowrap; }
.name.shine {
  background: linear-gradient(100deg, currentColor 35%, var(--color-tech) 50%, currentColor 65%) 0 0 / 300% 100%;
  -webkit-background-clip: text; background-clip: text; color: transparent;
}

/* ───────────── Reduced motion ───────────── */
@media (prefers-reduced-motion: reduce) {
  .loader, .logo, .name, .tagline, .dock, .controls { transition: none; }
  .page[data-pill] .pill { animation: none; }
  .win, .card-inner, .msg { transition: none; animation: none; }
}
