/* The design system: tokens, type, and the few components every page uses (docs/design.md).
   Pages add layout in their own stylesheet and take every colour, size, radius, border width
   and shadow from here: there are no raw values outside this file (test/web/design.test.ts).
   The look is Glass (D0028): frosted translucent surfaces over soft colour fields and a fine grain. */

/* ---------- fonts: self-hosted, variable, OFL (licences beside the files) ---------- */
@font-face {
  font-family: "Geist Variable";
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url("fonts/geist-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Geist Variable";
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url("fonts/geist-latin-ext.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: "Geist Mono Variable";
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url("fonts/geist-mono-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Geist Mono Variable";
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url("fonts/geist-mono-latin-ext.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
/* What shows until Geist has loaded (and for scripts it lacks): the system face, at Geist's width
   so the swap doesn't move the lines. */
@font-face {
  font-family: "Geist Fallback";
  src: local("Segoe UI Variable Text"), local("Segoe UI Variable"), local("Segoe UI"), local("Helvetica Neue"), local("Arial");
  size-adjust: 105%;
}

/* ---------- tokens ---------- */
:root {
  color-scheme: light dark;

  /* The window's ground, under the backdrop's colour fields (.backdrop, below): the chat view and
     the settings page. Text on it is checked with the fields and the grain under it. */
  --bg: #eceef4;
  /* The backdrop's soft colour fields: large shapes, blurred out of focus, muted. */
  --field-1: rgb(240 138 93 / 0.24);
  --field-2: rgb(110 193 178 / 0.26);
  --field-3: rgb(143 124 201 / 0.24);
  /* Frosted panels over the backdrop (.glass), and over the real desktop (.glass-float: the pop-up,
     the snip's box, the dock), denser there since the desktop may be any colour at all. */
  --glass: rgb(250 250 253 / 0.62);
  --glass-float: rgb(250 250 253 / 0.88);
  /* The glass's rim where it is drawn as a ring (the dock's island). */
  --glass-rim: rgb(22 24 44 / 0.12);
  /* A Mac's notch, the same black in every scheme: the dock grows out of it as one object (D0035). */
  --notch: rgb(0 0 0);
  /* The person's own message: a bubble tinted with the accent. */
  --bubble: rgb(75 99 230 / 0.13);
  /* On glass, back to front: wells for code and output; inputs and inner cards. */
  --sunken: rgb(22 24 44 / 0.05);
  --surface: rgb(255 255 255 / 0.55);
  /* A row or quiet control under the pointer, and the selected row. */
  --hover: rgb(22 24 44 / 0.06);
  --selected: rgb(22 24 44 / 0.1);
  /* Hairlines: --line between things, --line-strong around controls. */
  --line: rgb(22 24 44 / 0.1);
  --line-strong: rgb(22 24 44 / 0.18);
  --text: #16161c;
  --muted: #4a4d5a;
  /* The inverse chip: the chosen workspace in the pop-up and the snip. */
  --ink: #16161c;
  --ink-text: #ffffff;
  /* The one accent: the primary button, links, focus. */
  --accent: #3148c8;
  --accent-text: #ffffff;
  --accent-soft: rgb(75 99 230 / 0.22);
  /* Status: a session that is running, one that needs approval, one that failed; each dot glows. */
  --running: #0e7a50;
  --warn: #7a4700;
  --danger: #a82a24;
  --glow-running: rgb(19 133 90 / 0.35);
  --glow-warn: rgb(151 88 0 / 0.35);
  --glow-danger: rgb(196 55 44 / 0.35);
  /* A glass surface's edge: a fine inner highlight all round and a light along its top. */
  --glass-edge: inset 0 0 0 var(--edge) rgb(255 255 255 / 0.7), inset 0 var(--hairline) 0 rgb(255 255 255 / 0.6), 0 0 0 var(--edge) rgb(22 24 44 / 0.08);
  /* Only for what floats (the pop-up, a menu, the snip's box, a dialog): the edge and a soft deep shadow. */
  --shadow: var(--glass-edge), 0 24px 50px rgb(15 20 40 / 0.22);
  /* The grain over the backdrop: how strong, blended as an overlay (less in light, where it shows more). */
  --grain-strength: 0.2;

  --font: "Geist Variable", "Geist Fallback", system-ui, sans-serif;
  --mono: "Geist Mono Variable", "Cascadia Code", "SF Mono", Consolas, ui-monospace, monospace;
  /* The type scale: labels and key hints, meta and code, the interface and prose, titles and the task box. */
  --text-xs: 11px;
  --text-s: 12px;
  --text-m: 13px;
  --text-l: 16px;
  --leading: 1.5;
  --leading-tight: 1.3;
  --track-l: -0.014em;
  --track-caps: 0.05em;
  --regular: 400;
  --medium: 500;
  --semibold: 600;

  /* One device pixel: 0.5px where a CSS pixel is two or more of them (below). */
  --hairline: 1px;
  /* A glass edge's inner highlight: half a CSS pixel, as fine as the screen draws. */
  --edge: 0.5px;
  --ring: 2px;

  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 24px;
  --space-6: 40px;
  /* Radii: key hints and task marks; rows and wells; inputs and inner cards; panels and cards; what
     floats; and the pill every button and chip is. */
  --radius-xs: 6px;
  --radius-s: 10px;
  --radius-m: 14px;
  --radius: 18px;
  --radius-l: 22px;
  --radius-pill: 999px;
  /* Heights: buttons, inputs and rows; small controls and key hints; the status dot. */
  --control: 28px;
  --control-s: 20px;
  --dot: 7px;
  /* Chat view: the sidebar's width and the widest a line of the stream gets. */
  --sidebar: 256px;
  --measure: 720px;
  /* Frosting: what a glass surface does to what is behind it. */
  --frost: blur(26px) saturate(180%);
  /* How out of focus the backdrop's colour fields are. */
  --field-blur: blur(70px);
  /* The grain: fractal noise, desaturated, tiled. The namespace is the SVG's name, not a request. */
  --grain: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='240' height='240'%3E%3Cfilter id='g'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix type='saturate' values='0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23g)'/%3E%3C/svg%3E");
  /* The grain under a dim (the snip's), a little less. */
  --grain-dim: 0.28;
  --motion: 150ms;
  --ease: cubic-bezier(0.2, 0, 0, 1);
  /* Springs (docs/design.md, "Motion"): src/web/motion.js makes gentle and snappy from a stiffness
     and a damping and holds bouncy and soft as copied from the Glass reference (`bun src/web/motion.js`
     prints all four); test/web/motion.test.ts fails when they differ. Each curve goes with its
     duration. Gentle: near critical, for things that slide. Bouncy: about 12% over, for opening
     and arriving. Soft: about 1%, for closing. Snappy: quick, for an answer to a key. */
  --ease-gentle: linear(0, 0.007, 0.027, 0.057, 0.094, 0.137, 0.184, 0.233, 0.283, 0.334, 0.384, 0.433, 0.481, 0.526, 0.57, 0.611, 0.649, 0.685, 0.719, 0.749, 0.778, 0.804, 0.827, 0.849, 0.868, 0.886, 0.901, 0.915, 0.928, 0.939, 0.949, 0.957, 0.965, 0.971, 0.977, 0.982, 0.986, 0.99, 0.993, 0.995, 1);
  --dur-gentle: 290ms;
  --ease-snappy: linear(0, 0.009, 0.034, 0.071, 0.116, 0.166, 0.22, 0.276, 0.332, 0.387, 0.441, 0.493, 0.542, 0.588, 0.631, 0.671, 0.708, 0.741, 0.772, 0.8, 0.825, 0.847, 0.868, 0.886, 0.902, 0.916, 0.928, 0.939, 0.948, 0.957, 0.964, 0.97, 0.976, 0.98, 0.984, 0.987, 0.99, 0.992, 0.994, 0.996, 1);
  --dur-snappy: 190ms;
  --ease-bouncy: linear(0, 0.032, 0.106, 0.209, 0.328, 0.453, 0.576, 0.692, 0.796, 0.89, 0.963, 1.021, 1.063, 1.092, 1.11, 1.117, 1.117, 1.11, 1.099, 1.086, 1.071, 1.057, 1.043, 1.03, 1.018, 1.009, 1.001, 0.995, 0.991, 0.988, 0.987, 0.986, 0.987, 0.988, 0.989, 0.991, 0.993, 0.994, 0.996, 0.997, 0.998, 0.999, 1, 1.001, 1);
  --dur-bouncy: 680ms;
  --ease-soft: linear(0, 0.022, 0.071, 0.143, 0.219, 0.3, 0.389, 0.468, 0.543, 0.618, 0.68, 0.735, 0.788, 0.829, 0.868, 0.898, 0.923, 0.945, 0.961, 0.974, 0.985, 0.993, 0.999, 1.004, 1.006, 1.008, 1.009, 1.01, 1.01, 1.009, 1.009, 1.008, 1.007, 1.006, 1.006, 1.005, 1.004, 1.003, 1.003, 1.002, 1.002, 1.001, 1.001, 1.001, 1);
  --dur-soft: 460ms;
  /* Fades, not springs: a fade in (a dim, a page's contents) and the quick soft way out. */
  --dur-fade: 120ms;
  --dur-out: 110ms;
  /* A button's lift and squash: the bouncy curve, quicker, as the reference has it. */
  --dur-press: 380ms;
  /* How far a thing that springs in travels: it rises this far, grows from this scale, and its
     blur clears from this much. */
  --rise: 10px;
  --pop: 0.94;
  --blur-in: blur(6px);
  /* A button under the pointer lifts this far, and squashes to this scale while pressed. */
  --lift: -1px;
  --squash: 0.92;
  /* Rows that arrive together, one after the other; and how far the island's width lags its height. */
  --stagger: 40ms;
  --lag: 40ms;
  /* How much of the island shows while nothing is going on. */
  --island-quiet: 0.55;
  /* The island's size as drawn. dock.js sets both on the island; until it has, nothing is drawn. */
  --island-w: 0px;
  --island-h: 0px;
  /* The most it is drawn at, in open and the chat (dock.js sets both there, D0042): elsewhere nothing holds it. */
  --cap-w: 100vw;
  --cap-h: 100vh;
  /* A Mac's notch and the wings beside it, as dock.js measures them (?notch=WxH); 0 without one. */
  --notch-w: 0px;
  --notch-h: 0px;
  --wing: 0px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #101219;
    --field-1: rgb(240 138 93 / 0.16);
    --field-2: rgb(110 193 178 / 0.14);
    --field-3: rgb(143 124 201 / 0.2);
    --glass: rgb(18 18 24 / 0.56);
    --glass-float: rgb(18 18 24 / 0.86);
    --glass-rim: rgb(255 255 255 / 0.2);
    /* A Mac's notch, the same black in every scheme: the dock grows out of it as one object (D0035). */
    --notch: rgb(0 0 0);
    --bubble: rgb(124 156 255 / 0.3);
    --surface: rgb(255 255 255 / 0.07);
    --sunken: rgb(0 0 0 / 0.22);
    --hover: rgb(255 255 255 / 0.08);
    --selected: rgb(255 255 255 / 0.12);
    --line: rgb(255 255 255 / 0.1);
    --line-strong: rgb(255 255 255 / 0.18);
    --text: #f3f4f8;
    --muted: #b4b6c4;
    --ink: #f3f4f8;
    --ink-text: #14151b;
    --accent: #9bb4ff;
    --accent-text: #0b1030;
    --accent-soft: rgb(124 156 255 / 0.32);
    --running: #6ee7b7;
    --warn: #ffc46b;
    --danger: #ff9a90;
    --glow-running: rgb(110 231 183 / 0.55);
    --glow-warn: rgb(255 196 107 / 0.6);
    --glow-danger: rgb(241 122 110 / 0.55);
    --glass-edge: inset 0 0 0 var(--edge) rgb(255 255 255 / 0.22), inset 0 var(--hairline) 0 rgb(255 255 255 / 0.18);
    --shadow: var(--glass-edge), 0 30px 70px rgb(8 10 30 / 0.45);
    --grain-strength: 0.34;
  }
}
/* Dark whatever the scheme: the dock's page (<body class="dark">) is one dark island on any desktop.
   The same values as the dark scheme above; test/web/dock.test.ts fails when the two differ. */
.dark {
  color-scheme: dark;
  --bg: #101219;
  --field-1: rgb(240 138 93 / 0.16);
  --field-2: rgb(110 193 178 / 0.14);
  --field-3: rgb(143 124 201 / 0.2);
  --glass: rgb(18 18 24 / 0.56);
  --glass-float: rgb(18 18 24 / 0.86);
  --glass-rim: rgb(255 255 255 / 0.2);
  /* A Mac's notch, the same black in every scheme: the dock grows out of it as one object (D0035). */
  --notch: rgb(0 0 0);
  --bubble: rgb(124 156 255 / 0.3);
  --surface: rgb(255 255 255 / 0.07);
  --sunken: rgb(0 0 0 / 0.22);
  --hover: rgb(255 255 255 / 0.08);
  --selected: rgb(255 255 255 / 0.12);
  --line: rgb(255 255 255 / 0.1);
  --line-strong: rgb(255 255 255 / 0.18);
  --text: #f3f4f8;
  --muted: #b4b6c4;
  --ink: #f3f4f8;
  --ink-text: #14151b;
  --accent: #9bb4ff;
  --accent-text: #0b1030;
  --accent-soft: rgb(124 156 255 / 0.32);
  --running: #6ee7b7;
  --warn: #ffc46b;
  --danger: #ff9a90;
  --glow-running: rgb(110 231 183 / 0.55);
  --glow-warn: rgb(255 196 107 / 0.6);
  --glow-danger: rgb(241 122 110 / 0.55);
  --glass-edge: inset 0 0 0 var(--edge) rgb(255 255 255 / 0.22), inset 0 var(--hairline) 0 rgb(255 255 255 / 0.18);
  --shadow: var(--glass-edge), 0 30px 70px rgb(8 10 30 / 0.45);
  --grain-strength: 0.34;
}
/* The theme the person chose (Settings, Appearance). theme.js sets data-theme on <html> to light
   or dark, and removes it for "system", which leaves the choice to prefers-color-scheme above.
   An attribute on :root outranks the plain :root in the media rule, whatever the order. Each set
   repeats its scheme's values: test/web/theme.test.ts fails when they differ, so the contrasts
   design.test.ts checks hold here too. .light, like .dark, gives one part of a page the light
   values whatever the theme (the settings page's previews). */
:root[data-theme="light"], .light {
  color-scheme: light;
  --bg: #eceef4;
  --field-1: rgb(240 138 93 / 0.24);
  --field-2: rgb(110 193 178 / 0.26);
  --field-3: rgb(143 124 201 / 0.24);
  --glass: rgb(250 250 253 / 0.62);
  --glass-float: rgb(250 250 253 / 0.88);
  --glass-rim: rgb(22 24 44 / 0.12);
  /* A Mac's notch, the same black in every scheme: the dock grows out of it as one object (D0035). */
  --notch: rgb(0 0 0);
  --bubble: rgb(75 99 230 / 0.13);
  --surface: rgb(255 255 255 / 0.55);
  --sunken: rgb(22 24 44 / 0.05);
  --hover: rgb(22 24 44 / 0.06);
  --selected: rgb(22 24 44 / 0.1);
  --line: rgb(22 24 44 / 0.1);
  --line-strong: rgb(22 24 44 / 0.18);
  --text: #16161c;
  --muted: #4a4d5a;
  --ink: #16161c;
  --ink-text: #ffffff;
  --accent: #3148c8;
  --accent-text: #ffffff;
  --accent-soft: rgb(75 99 230 / 0.22);
  --running: #0e7a50;
  --warn: #7a4700;
  --danger: #a82a24;
  --glow-running: rgb(19 133 90 / 0.35);
  --glow-warn: rgb(151 88 0 / 0.35);
  --glow-danger: rgb(196 55 44 / 0.35);
  --glass-edge: inset 0 0 0 var(--edge) rgb(255 255 255 / 0.7), inset 0 var(--hairline) 0 rgb(255 255 255 / 0.6), 0 0 0 var(--edge) rgb(22 24 44 / 0.08);
  --shadow: var(--glass-edge), 0 24px 50px rgb(15 20 40 / 0.22);
  --grain-strength: 0.2;
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #101219;
  --field-1: rgb(240 138 93 / 0.16);
  --field-2: rgb(110 193 178 / 0.14);
  --field-3: rgb(143 124 201 / 0.2);
  --glass: rgb(18 18 24 / 0.56);
  --glass-float: rgb(18 18 24 / 0.86);
  --glass-rim: rgb(255 255 255 / 0.2);
  /* A Mac's notch, the same black in every scheme: the dock grows out of it as one object (D0035). */
  --notch: rgb(0 0 0);
  --bubble: rgb(124 156 255 / 0.3);
  --surface: rgb(255 255 255 / 0.07);
  --sunken: rgb(0 0 0 / 0.22);
  --hover: rgb(255 255 255 / 0.08);
  --selected: rgb(255 255 255 / 0.12);
  --line: rgb(255 255 255 / 0.1);
  --line-strong: rgb(255 255 255 / 0.18);
  --text: #f3f4f8;
  --muted: #b4b6c4;
  --ink: #f3f4f8;
  --ink-text: #14151b;
  --accent: #9bb4ff;
  --accent-text: #0b1030;
  --accent-soft: rgb(124 156 255 / 0.32);
  --running: #6ee7b7;
  --warn: #ffc46b;
  --danger: #ff9a90;
  --glow-running: rgb(110 231 183 / 0.55);
  --glow-warn: rgb(255 196 107 / 0.6);
  --glow-danger: rgb(241 122 110 / 0.55);
  --glass-edge: inset 0 0 0 var(--edge) rgb(255 255 255 / 0.22), inset 0 var(--hairline) 0 rgb(255 255 255 / 0.18);
  --shadow: var(--glass-edge), 0 30px 70px rgb(8 10 30 / 0.45);
  --grain-strength: 0.34;
}
@media (min-resolution: 2dppx) {
  :root { --hairline: 0.5px; }
}
/* The snip overlay's marks over a frozen screen, the same in both schemes: neutral, never the
   accent, light on the dim around them. --device-px is one device pixel; snip.js sets it from the
   display's scale so the selection's edge is crisp at 125% and 150% too. */
:root {
  --device-px: 1px;
  --snip-line: rgb(255 255 255 / 0.9);
  --snip-mark: rgb(255 255 255 / 0.96);
  --snip-label: rgb(255 255 255 / 0.18);
  --snip-dim: 0.5;
  /* The corner marks' width: two device pixels. */
  --snip-mark-w: calc(var(--device-px) * 2);
  /* The selection's edge, as a ring just outside it (a shadow's spread keeps a width under one CSS
     pixel, which an outline or a border would round up), a soft light glow around it, and a faint
     light inside it that lifts it a little above the dim. */
  --snip-edge: 0 0 0 var(--device-px) var(--snip-line), 0 0 30px rgb(255 255 255 / 0.18), inset 0 0 var(--space-5) rgb(255 255 255 / 0.07);
}
/* Reduced motion: nothing travels, grows, blurs or overshoots. A page's own reduced-motion rule keeps
   only its fades, which these make plain: no rise, no pop, a short linear fade. */
@media (prefers-reduced-motion: reduce) {
  :root {
    --rise: 0px;
    --pop: 1;
    --blur-in: none;
    --lift: 0px;
    --squash: 1;
    --stagger: 0ms;
    --lag: 0ms;
    --ease-gentle: linear;
    --ease-bouncy: linear;
    --ease-soft: linear;
    --ease-snappy: linear;
    --dur-gentle: var(--dur-fade);
    --dur-bouncy: var(--dur-fade);
    --dur-soft: var(--dur-fade);
    --dur-snappy: var(--dur-fade);
    --dur-press: var(--dur-fade);
  }
}

/* ---------- the page ---------- */
*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: var(--regular) var(--text-m) / var(--leading) var(--font);
  font-synthesis: none;
  font-kerning: normal;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
  scrollbar-color: var(--line-strong) transparent;
  scrollbar-width: thin;
}
[hidden] { display: none !important; }

/* ---------- glass and the backdrop (one of each for every page) ---------- */
/* The backdrop of a window that has its own ground (the chat view, the settings page): soft colour
   fields far out of focus, and over them a fine film grain. Frosted panels sit on top, and their
   blur smooths the grain away under their text. Put .backdrop on <body>. */
body.backdrop { background: var(--bg); }
body.backdrop::before, body.backdrop::after { content: ""; position: fixed; pointer-events: none; z-index: -1; }
body.backdrop::before {
  inset: calc(var(--space-6) * -2);
  background:
    radial-gradient(closest-side, var(--field-1), transparent) 30% 4% / 46% 52% no-repeat,
    radial-gradient(closest-side, var(--field-2), transparent) 88% 0% / 50% 54% no-repeat,
    radial-gradient(closest-side, var(--field-3), transparent) 4% 82% / 56% 62% no-repeat,
    radial-gradient(closest-side, var(--field-1), transparent) 96% 96% / 52% 50% no-repeat;
  filter: var(--field-blur);
}
body.backdrop::after { inset: 0; background: var(--grain); opacity: var(--grain-strength); mix-blend-mode: overlay; }
/* A frosted surface: over the backdrop (.glass), or over the real desktop (.glass-float, denser,
   with the shadow of what floats). The dock's island and the pop-up float over the desktop, which
   the shell shows through their windows and blurs; their own page is clear. */
.glass, .glass-float { -webkit-backdrop-filter: var(--frost); backdrop-filter: var(--frost); }
.glass { background: var(--glass); box-shadow: var(--glass-edge); }
.glass-float { background: var(--glass-float); box-shadow: var(--shadow); }
::selection { background: var(--accent-soft); }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
p, h1, h2, h3, pre { margin: 0; }
button, input, textarea, select { font: inherit; letter-spacing: inherit; color: inherit; }
:focus-visible { outline: var(--ring) solid var(--accent); outline-offset: var(--hairline); }

/* ---------- type ---------- */
.title { font-size: var(--text-l); font-weight: var(--semibold); line-height: var(--leading-tight); letter-spacing: var(--track-l); }
.small { font-size: var(--text-s); }
.muted { color: var(--muted); }
.strong { font-weight: var(--medium); }
/* A caption over a block: "Input", "Result", "Clipboard", in the mono face. */
.label { font-family: var(--mono); font-size: var(--text-xs); font-weight: var(--medium); letter-spacing: var(--track-caps); text-transform: uppercase; color: var(--muted); }
/* Times, durations and costs line up. */
time, .num { font-variant-numeric: tabular-nums; }
code, pre, .mono { font-family: var(--mono); font-size: var(--text-s); font-variant-ligatures: none; }
pre { white-space: pre-wrap; word-break: break-word; }
/* A block of code or output: sunken into the glass. */
.well {
  padding: var(--space-2) var(--space-3);
  background: var(--sunken);
  border: var(--hairline) solid var(--line);
  border-radius: var(--radius-s);
}

/* ---------- button: plain, .primary, .quiet; every one a pill that lifts and squashes ---------- */
button, .button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  height: var(--control);
  padding: 0 var(--space-3);
  border: var(--hairline) solid var(--line-strong);
  border-radius: var(--radius-pill);
  background: var(--surface);
  color: var(--text);
  font-weight: var(--medium);
  line-height: 1;
  white-space: nowrap;
  cursor: pointer;
  transition: background-color var(--motion) var(--ease), border-color var(--motion) var(--ease), color var(--motion) var(--ease), transform var(--dur-press) var(--ease-bouncy);
}
button:hover, .button:hover { background: var(--hover); text-decoration: none; transform: translateY(var(--lift)); }
button:active, .button:active { transform: scale(var(--squash)); }
button.primary, .button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
button.primary:hover, .button.primary:hover { background: var(--accent); filter: brightness(1.08); }
button.quiet, .button.quiet { border-color: transparent; background: transparent; color: var(--muted); }
button.quiet:hover, .button.quiet:hover { background: var(--hover); color: var(--text); }
button.small, .button.small { height: var(--control-s); padding: 0 var(--space-2); }
button:disabled, .button[aria-disabled="true"] { opacity: 0.5; cursor: default; pointer-events: none; }

/* ---------- input and textarea ---------- */
.input {
  display: block;
  width: 100%;
  min-height: var(--control);
  padding: calc((var(--control) - var(--text-m) * var(--leading)) / 2 - var(--hairline)) var(--space-3);
  border: var(--hairline) solid var(--line-strong);
  border-radius: var(--radius-m);
  background: var(--surface);
  resize: none;
  transition: border-color var(--motion) var(--ease), outline-color var(--motion) var(--ease);
  outline: var(--ring) solid transparent;
  outline-offset: 0;
}
.input::placeholder { color: var(--muted); }
.input:focus-visible { border-color: var(--accent); outline-color: var(--accent-soft); }
.input:disabled { background: var(--sunken); border-color: var(--line); }

/* ---------- dropdown: .select on a <select>, with .quiet and .small ---------- */
/* A real <select>, so its keys, its change event and what a screen reader hears stay the browser's.
   Where the select can be styled (appearance: base-select, Chromium 135+: Electron 45 is 140) its
   list is drawn here, like a menu, instead of by the OS; elsewhere the OS's list shows. */
.select {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  min-width: 0;
  height: var(--control);
  min-height: var(--control);
  padding: 0 var(--space-2) 0 var(--space-3);
  border: var(--hairline) solid var(--line-strong);
  border-radius: var(--radius-m);
  background: var(--surface);
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  cursor: pointer;
  outline: var(--ring) solid transparent;
  outline-offset: 0;
  transition: background-color var(--motion) var(--ease), border-color var(--motion) var(--ease), color var(--motion) var(--ease), outline-color var(--motion) var(--ease);
}
/* Focused, it is an input: an accent border and the soft halo. The quiet one takes the plain ring. */
.select:focus-visible { border-color: var(--accent); outline-color: var(--accent-soft); }
.select.quiet:focus-visible { border-color: transparent; outline-color: var(--accent); outline-offset: var(--hairline); }
.select:hover { background: var(--hover); }
.select:disabled { background: var(--sunken); border-color: var(--line); cursor: default; }
.select.quiet { border-color: transparent; background: transparent; color: var(--muted); }
.select.quiet:hover { background: var(--hover); color: var(--text); }
.select.small { height: var(--control-s); min-height: var(--control-s); padding: 0 var(--space-1) 0 var(--space-2); border-radius: var(--radius-pill); }

@supports (appearance: base-select) {
  .select, .select::picker(select) { appearance: base-select; }
  .select.quiet:open { background: var(--hover); color: var(--text); }
  /* The chosen option shows in <button><selectedcontent></selectedcontent></button>, the select's
     first child, so a long one ends in "…" instead of pushing the chevron out (the browser's own
     label can't shrink). The button is the select's own part, not a page button. */
  .select > button {
    all: unset;
    display: flex;
    align-items: center;
    flex: 1;
    min-width: 0;
    height: 100%;
  }
  .select selectedcontent { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  /* The chevron: two hairlines turned into a "v", which turns over while the list is open. */
  .select::picker-icon {
    content: "";
    width: var(--space-1);
    height: var(--space-1);
    margin: 0 var(--space-1) 0 auto;
    border: 0;
    border-right: var(--hairline) solid currentColor;
    border-bottom: var(--hairline) solid currentColor;
    color: var(--muted);
    transform: translateY(calc(0px - var(--space-1) / 2)) rotate(45deg);
    transition: transform var(--dur-snappy) var(--ease-snappy);
  }
  .select:open::picker-icon { transform: translateY(calc(var(--space-1) / 2)) rotate(225deg); }

  /* The list floats over the page like a menu: floating glass with the shadow, a hair below the button,
     at least as wide as it. It pops in from its middle, so it looks the same whether the browser
     puts it below the button or, short of room, above; it fades out quickly. */
  .select::picker(select) {
    min-width: anchor-size(width);
    margin-block: var(--space-1);
    padding: var(--space-1);
    border: 0;
    border-radius: var(--radius-m);
    background: var(--glass-float);
    -webkit-backdrop-filter: var(--frost);
    backdrop-filter: var(--frost);
    color: var(--text);
    box-shadow: var(--shadow);
    scrollbar-width: thin;
    opacity: 0;
    transition: opacity var(--dur-out) var(--ease), display var(--dur-out) allow-discrete, overlay var(--dur-out) allow-discrete;
  }
  .select::picker(select):popover-open {
    opacity: 1;
    transform: none;
    transition: opacity var(--dur-fade) var(--ease), transform var(--dur-snappy) var(--ease-snappy), display var(--dur-fade) allow-discrete, overlay var(--dur-fade) allow-discrete;
  }
  @starting-style {
    .select::picker(select):popover-open { opacity: 0; transform: scale(var(--pop)); }
  }

  /* Options are rows, like a menu's: the one under the pointer or the keys is highlighted (the
     list's focus, so no ring), and the chosen one has a check at its end. */
  .select option {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    min-height: var(--control);
    padding: 0 var(--space-2);
    border-radius: var(--radius-s);
    background: transparent;
    color: var(--text);
    cursor: pointer;
    transition: background-color var(--motion) var(--ease);
  }
  .select option:is(:hover, :focus) { background: var(--selected); outline: none; }
  .select option::checkmark { order: 1; margin-inline-start: auto; color: var(--muted); }
  .select option:checked { font-weight: var(--medium); }
  .select option:disabled { color: var(--muted); cursor: default; }
}

/* ---------- card: a frosted panel ---------- */
.card { min-width: 0; border-radius: var(--radius); }
.card:not(.glass, .glass-float) { background: var(--surface); box-shadow: var(--glass-edge); }
/* The person's own message: a bubble in the accent's tint, its corner to the right. */
.msg.user.card { background: var(--bubble); box-shadow: none; border-radius: var(--radius-m) var(--radius-m) var(--radius-xs) var(--radius-m); }

/* ---------- list row: .row, selected with aria-current="true" ---------- */
.row {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  min-height: var(--control);
  padding: var(--space-1) var(--space-2);
  border-radius: var(--radius-s);
  color: inherit;
  transition: background-color var(--motion) var(--ease);
}
.row:hover { background: var(--hover); text-decoration: none; }
.row[aria-current="true"], .row[aria-selected="true"] { background: var(--selected); }
.row:focus-visible { outline-offset: calc(0px - var(--ring)); }

/* ---------- status dot: data-status is a session's status; a lit one glows, running breathes ---------- */
.dot { width: var(--dot); height: var(--dot); border-radius: 50%; background: var(--line-strong); flex: none; }
.dot[data-status="running"] { background: var(--running); box-shadow: 0 0 var(--space-2) var(--edge) var(--glow-running); animation: breathe calc(var(--dur-bouncy) * 1.2) var(--ease-gentle) infinite alternate; }
.dot[data-status="waiting_approval"] { background: var(--warn); box-shadow: 0 0 var(--space-2) var(--edge) var(--glow-warn); }
.dot[data-status="error"] { background: var(--danger); box-shadow: 0 0 var(--space-2) var(--edge) var(--glow-danger); }
/* A breath: the dot draws in and dims, then back. */
@keyframes breathe { to { transform: scale(0.65); opacity: var(--island-quiet); } }

/* ---------- keyboard hint ---------- */
kbd {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: var(--control-s);
  height: var(--control-s);
  padding: 0 var(--space-1);
  border: var(--hairline) solid var(--line-strong);
  border-radius: var(--radius-xs);
  font: var(--medium) var(--text-xs) / 1 var(--mono);
  color: var(--muted);
}

/* ---------- tool call: <details class="tool">, one closed row until opened ---------- */
.tool { min-width: 0; border: var(--hairline) solid var(--line); border-radius: var(--radius-m); background: var(--surface); }
.tool > summary {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  min-height: var(--control);
  padding: 0 var(--space-3);
  border-radius: inherit;
  cursor: pointer;
  list-style: none;
  transition: background-color var(--motion) var(--ease);
}
.tool > summary:hover { background: var(--hover); }
.tool > summary::-webkit-details-marker { display: none; }
.tool > summary::before { content: "›"; color: var(--muted); transition: transform var(--motion) var(--ease); }
.tool[open] > summary::before { transform: rotate(90deg); }
.tool[open] > summary { border-bottom-left-radius: 0; border-bottom-right-radius: 0; }
.tool-name { flex: none; font-size: var(--text-s); font-weight: var(--medium); }
.tool-line { flex: 1; min-width: 0; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tool-mark { flex: none; color: var(--danger); }
.tool-body { display: grid; gap: var(--space-1); padding: var(--space-3); border-top: var(--hairline) solid var(--line); }
.tool-body .label:not(:first-child) { margin-top: var(--space-2); }
.tool-body pre { max-height: 50vh; overflow: auto; }
.tool[data-error] .tool-result { border-color: var(--danger); }

/* ---------- approval card: data-state is open, allow, deny or unanswered ---------- */
/* Open, it is the one accented thing on the page, in the amber of its session's dot; decided,
   it is as quiet as a tool call. */
.approval {
  display: grid;
  gap: var(--space-2);
  min-width: 0;
  padding: var(--space-2) var(--space-3);
  border: var(--hairline) solid var(--line);
  border-radius: var(--radius-m);
}
.approval[data-state="open"] { padding-block: var(--space-3); background: var(--surface); border-color: var(--warn); box-shadow: 0 0 var(--space-5) calc(var(--space-1) * -1) var(--glow-warn); }
.approval-head { display: flex; align-items: center; gap: var(--space-2); min-height: calc(var(--control) - var(--space-2) * 2); }
.approval-head::before { content: ""; width: var(--dot); height: var(--dot); border-radius: 50%; background: var(--line-strong); flex: none; }
.approval[data-state="open"] .approval-head::before { background: var(--warn); box-shadow: 0 0 var(--space-2) var(--edge) var(--glow-warn); }
.approval[data-state="deny"] .approval-head::before { background: var(--danger); }
.approval-tool { font-size: var(--text-s); font-weight: var(--medium); overflow-wrap: anywhere; }
.approval-state { color: var(--muted); }
.approval[data-state="open"] .approval-state { color: var(--warn); font-weight: var(--medium); }
.approval[data-state="deny"] .approval-state { color: var(--danger); }
.approval-path, .approval-reason { overflow-wrap: anywhere; }
.approval-input { max-height: 40vh; overflow: auto; }
.approval-actions { display: flex; align-items: center; flex-wrap: wrap; gap: var(--space-2); margin-top: var(--space-1); }
.approval-error { min-width: 0; overflow-wrap: anywhere; }
/* An agent's questions in the card (questions.js, D0039): each a group of options to pick, a row
   each, the label over its description, then a line for the person's own words. Answered, each
   question over its answer. */
.questions { display: grid; gap: var(--space-3); min-width: 0; }
.question { display: grid; gap: var(--hairline); min-width: 0; margin: 0; padding: 0; border: 0; }
.question-text { display: flex; flex-wrap: wrap; align-items: baseline; gap: var(--space-2); padding: 0 0 var(--space-1); font-weight: var(--medium); overflow-wrap: anywhere; }
.question-header { color: var(--muted); font-weight: var(--regular); }
.option { display: flex; align-items: flex-start; gap: var(--space-2); min-width: 0; padding: var(--space-1) var(--space-2); border-radius: var(--radius-s); cursor: pointer; transition: background-color var(--motion) var(--ease); }
.option:hover { background: var(--hover); }
.option:has(input:checked) { background: var(--hover); }
.option > input { flex: none; margin: calc((var(--text-m) * var(--leading) - var(--text-m)) / 2) 0 0; accent-color: var(--accent); }
.option-words { display: grid; min-width: 0; overflow-wrap: anywhere; }
.option-own { margin-top: var(--space-1); }
.question:disabled .option { cursor: default; opacity: 0.5; }
.question-answers { display: grid; gap: var(--space-1); min-width: 0; margin: 0; overflow-wrap: anywhere; }
.question-answers dd { margin: 0 0 var(--space-1); }

/* ---------- markdown: an assistant's message, drawn by markdown.js ---------- */
/* Compact: a chat, not a document. Headings stay near the text size, lists are indented by about
   the type size, code and tables scroll sideways inside their hairline instead of widening the page. */
.md { display: grid; gap: var(--space-2); min-width: 0; overflow-wrap: anywhere; }
.md :is(h1, h2, h3, h4, h5, h6) { margin: 0; font-size: var(--text-m); font-weight: var(--semibold); line-height: var(--leading-tight); }
.md h1 { font-size: var(--text-l); letter-spacing: var(--track-l); }
.md :is(h4, h5, h6) { font-weight: var(--medium); }
.md :is(h5, h6) { color: var(--muted); }
.md > :not(h1, h2, h3, h4, h5, h6) + :is(h1, h2, h3, h4, h5, h6) { margin-top: var(--space-1); }
.md strong { font-weight: var(--semibold); }
/* Geist's italic isn't served here: an <em> is slanted by the browser, the one synthesis allowed (D0013). */
.md em { font-style: italic; font-synthesis: style; }
.md del { color: var(--muted); }
.md a { text-decoration: underline; text-decoration-color: var(--accent-soft); text-decoration-thickness: var(--hairline); text-underline-offset: calc(var(--space-1) / 2); }
.md a:hover { text-decoration-color: var(--accent); }
.md :not(pre) > code { padding: 0 var(--space-1); background: var(--sunken); border: var(--hairline) solid var(--line); border-radius: var(--radius-xs); overflow-wrap: anywhere; }
.md :is(ul, ol) { margin: 0; padding-inline-start: calc(var(--text-m) * 1.5); display: grid; gap: var(--space-1); }
.md li > * + * { margin-top: var(--space-1); }
.md li::marker { color: var(--muted); }
.md ul.tasks { padding-inline-start: 0; }
.md li.task { list-style: none; display: grid; grid-template-columns: auto minmax(0, 1fr); column-gap: var(--space-2); }
.md li.task > :not(.task-mark) { grid-column: 2; }
.md li.task > .task-mark + * { margin-top: 0; }
.task-mark {
  grid-row: 1;
  display: inline-grid;
  place-items: center;
  width: var(--text-m);
  height: var(--text-m);
  margin-top: calc((var(--leading) - 1) * var(--text-m) / 2);
  border: var(--hairline) solid var(--line-strong);
  border-radius: calc(var(--radius-xs) / 2);
  font-size: var(--text-xs);
  line-height: 1;
}
.md li.task[data-done="true"] > .task-mark { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.md li.task[data-done="true"] > .task-mark + * { color: var(--muted); }
.md blockquote { margin: 0; display: grid; gap: var(--space-2); padding-inline-start: var(--space-3); border-left: var(--hairline) solid var(--line-strong); color: var(--muted); }
.md hr { width: 100%; margin: var(--space-1) 0; border: 0; border-top: var(--hairline) solid var(--line); }
.md pre.code-block { white-space: pre; word-break: normal; overflow-wrap: normal; overflow-x: auto; }
.md pre.code-block[data-lang]::before {
  content: attr(data-lang);
  position: sticky;
  left: 0;
  display: block;
  width: fit-content;
  margin-bottom: var(--space-1);
  font-family: var(--font);
  font-size: var(--text-xs);
  font-weight: var(--medium);
  letter-spacing: var(--track-caps);
  text-transform: uppercase;
  color: var(--muted);
}
.md .table { overflow-x: auto; }
.md table { border-collapse: collapse; font-variant-numeric: tabular-nums; }
.md :is(th, td) { padding: var(--space-1) var(--space-3) var(--space-1) 0; text-align: left; vertical-align: top; border-bottom: var(--hairline) solid var(--line); overflow-wrap: normal; }
.md th { font-weight: var(--medium); border-bottom-color: var(--line-strong); }
.md :is(th, td):last-child { padding-inline-end: 0; }
.md [data-align="center"] { text-align: center; }
.md [data-align="right"] { text-align: right; }

/* ---------- the shortcuts guide (shortcuts-sheet.js, D0046): what each key does, its keycaps at the right ---------- */
.guide { display: grid; align-items: start; gap: var(--space-4); }
.guide-section { display: grid; align-content: start; gap: var(--space-1); min-width: 0; }
.guide-rows { display: grid; margin: 0; }
.guide-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  min-height: var(--control);
  border-bottom: var(--hairline) solid var(--line);
}
.guide-row:last-child { border-bottom: 0; }
.guide-what { min-width: 0; font-size: var(--text-s); }
.guide-keys { display: flex; flex: none; align-items: center; gap: var(--space-1); margin: 0; }
.guide-or { font-size: var(--text-xs); }
.combo { display: inline-flex; gap: var(--edge); }
.combo kbd { color: var(--text); }

/* The sheet: a calm panel over the page or the island, its list scrolling under a fixed head. */
.sheet {
  position: absolute;
  z-index: 3;
  display: flex;
  flex-direction: column;
  border-radius: var(--radius);
  overflow: hidden;
  animation: sheet-in var(--dur-snappy) var(--ease-snappy);
}
.sheet[hidden] { display: none; }
@keyframes sheet-in { from { opacity: 0; transform: translateY(calc(var(--rise) / 2)); } }
.sheet-head { display: flex; align-items: center; justify-content: space-between; gap: var(--space-2); padding: var(--space-2) var(--space-2) var(--space-2) var(--space-4); border-bottom: var(--hairline) solid var(--line); }
.sheet-title { margin: 0; font-size: var(--text-m); }
.sheet-body { flex: 1 1 auto; min-height: 0; padding: var(--space-3) var(--space-4) var(--space-4); overflow-y: auto; overscroll-behavior: contain; }

/* A tooltip the page draws (shortcuts-sheet.js): small, quiet, inside the element it belongs to. */
.tip {
  position: absolute;
  z-index: 4;
  max-width: calc(var(--sidebar) + var(--space-6));
  padding: var(--space-1) var(--space-2);
  border-radius: var(--radius-xs);
  background: var(--ink);
  color: var(--ink-text);
  line-height: var(--leading-tight);
  white-space: pre-line;
  overflow-wrap: anywhere;
  pointer-events: none;
  animation: tip-in var(--dur-fade) var(--ease);
}
.tip[hidden] { display: none; }
@keyframes tip-in { from { opacity: 0; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after, .select::picker-icon { animation: none !important; transition: none !important; }
}
