/* ==========================================================================
   Askwell 1.0 — AI chat app UI kit
   One stylesheet for every page. Sections:
     1. Tokens (colours, type, spacing)      6. Overlays: menus, modals, toasts
     2. Base and helpers                     7. Prompt library
     3. Buttons, fields, small parts         8. Playground
     4. App shell: rail, sidebar, top bar    9. Agent runs
     5. Chat: thread, messages, composer    10. Components, sign in, shared chat
                                            11. Responsive, print, reduced motion
   To rebrand, change --accent (and its two partners) below. Nothing else.
   ========================================================================== */

/* 1. Tokens --------------------------------------------------------------- */
:root {
  /* brand: the fill colour, the text that sits on it, and the same hue as readable text */
  --accent: #ffc531;
  --accent-ink: #1b1500;
  --accent-text: #7a5200;

  --canvas: #f6f7f9;
  --side: #eceff3;
  --surface: #ffffff;
  --raised: #ffffff;
  --sunk: #eff1f5;
  --hover: #e6e9ef;
  --ink: #11151c;
  --ink-2: #414856;
  --ink-3: #636b7b;
  --line: #dde1e8;
  --line-2: #c5ccd7;
  --rail: #11151c;
  --rail-ink: #a9b1c0;
  --bubble: #11151c;
  --bubble-ink: #ffffff;

  --ok: #0a7548;
  --warn: #8a5a00;
  --bad: #b4233a;
  --info: #1b5fb0;
  --ok-soft: #e2f4ea;
  --warn-soft: #fbefd3;
  --bad-soft: #fbe6e9;
  --info-soft: #e3eefb;

  --code-bg: #121724;
  --code-bar: #1b2233;
  --code-ink: #e4e8f0;
  --code-dim: #8b95a9;
  --tok-key: #ffb86b;
  --tok-str: #9be28f;
  --tok-num: #7fd1ff;
  --tok-com: #7f8aa0;
  --tok-fn: #c4b1ff;
  --tok-tag: #ff9aa2;

  --font-ui: 'Schibsted Grotesk', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'IBM Plex Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --font-serif: 'Source Serif 4', Georgia, 'Times New Roman', serif;
  --font-read: var(--font-ui);       /* the typeface for answers; Settings can switch it to the serif */
  --read-size: 1rem;

  --r-sm: 7px;
  --r: 10px;
  --r-lg: 16px;
  --r-xl: 22px;
  --shadow-1: 0 1px 2px rgba(17, 21, 28, .06);
  --shadow-2: 0 6px 20px -6px rgba(17, 21, 28, .16), 0 2px 5px rgba(17, 21, 28, .05);
  --shadow-3: 0 24px 60px -18px rgba(17, 21, 28, .32), 0 6px 16px rgba(17, 21, 28, .08);
  --focus: 0 0 0 3px color-mix(in srgb, var(--accent) 55%, transparent);
  --accent-soft: color-mix(in srgb, var(--accent) 20%, var(--surface));
  --thread: 780px;                   /* reading width of the conversation */
  color-scheme: light;
}

[data-theme="dark"] {
  --accent-text: #ffd56b;
  --canvas: #0f1422;
  --side: #0b0f1a;
  --surface: #171d2c;
  --raised: #1e2537;
  --sunk: #121827;
  --hover: #222a3d;
  --ink: #eef1f6;
  --ink-2: #bcc4d2;
  --ink-3: #909aad;
  --line: #283146;
  --line-2: #3a445c;
  --rail: #080b13;
  --rail-ink: #8d97aa;
  --bubble: #283149;
  --bubble-ink: #f3f5f9;
  --ok: #57d39a;
  --warn: #f2c14e;
  --bad: #ff8a98;
  --info: #7fb6f5;
  --ok-soft: #12301f;
  --warn-soft: #33290f;
  --bad-soft: #3a1820;
  --info-soft: #14273f;
  --code-bg: #0a0e18;
  --code-bar: #141a29;
  --shadow-1: 0 1px 2px rgba(0, 0, 0, .4);
  --shadow-2: 0 8px 24px -8px rgba(0, 0, 0, .6), 0 2px 6px rgba(0, 0, 0, .3);
  --shadow-3: 0 28px 70px -20px rgba(0, 0, 0, .8), 0 6px 18px rgba(0, 0, 0, .4);
  color-scheme: dark;
}

/* accent presets: set data-accent on <html>, or pick one in Settings */
[data-accent="cobalt"] { --accent: #2f55f5; --accent-ink: #ffffff; --accent-text: #2443c9; }
[data-accent="jade"]   { --accent: #0b8259; --accent-ink: #ffffff; --accent-text: #08704c; }
[data-accent="rose"]   { --accent: #cf2f66; --accent-ink: #ffffff; --accent-text: #b4204f; }
[data-accent="violet"] { --accent: #6d4be8; --accent-ink: #ffffff; --accent-text: #5a3ad0; }
[data-theme="dark"][data-accent="cobalt"] { --accent: #4466fa; --accent-text: #9db0ff; }
[data-theme="dark"][data-accent="jade"]   { --accent: #12a271; --accent-ink: #04130d; --accent-text: #5fdcaa; }
[data-theme="dark"][data-accent="rose"]   { --accent: #d6386e; --accent-text: #ff9dbb; }
[data-theme="dark"][data-accent="violet"] { --accent: #7858f2; --accent-text: #bcaaff; }

[data-read="serif"] { --font-read: var(--font-serif); --read-size: 1.0625rem; }
[data-density="compact"] { --thread: 720px; }

/* 2. Base and helpers ----------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font-ui);
  font-size: 15px;
  line-height: 1.5;
  color: var(--ink);
  background: var(--canvas);
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, h4, p, ul, ol, figure, blockquote, pre { margin: 0; }
ul, ol { padding: 0; list-style: none; }
img, svg { display: block; max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; }
a { color: inherit; }
[hidden] { display: none !important; }
:focus { outline: none; }
:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; box-shadow: var(--focus); }
::selection { background: color-mix(in srgb, var(--accent) 45%, transparent); }

.icon { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; }
.icon-sm { width: 15px; height: 15px; }
.icon-lg { width: 22px; height: 22px; }
.sr-only { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.mono { font-family: var(--font-mono); font-size: .9em; }
.muted { color: var(--ink-3); }
.grow { flex: 1 1 auto; min-width: 0; }
.row { display: flex; align-items: center; gap: 10px; }
.row-wrap { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.stack { display: grid; grid-template-columns: minmax(0, 1fr); gap: 14px; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.scroll { overflow-y: auto; overscroll-behavior: contain; scrollbar-width: thin; scrollbar-color: var(--line-2) transparent; }
.scroll::-webkit-scrollbar { width: 10px; height: 10px; }
.scroll::-webkit-scrollbar-thumb { background: var(--line-2); border-radius: 10px; border: 3px solid transparent; background-clip: content-box; }

/* 3. Buttons, fields, small parts ---------------------------------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 38px; padding: 0 14px;
  border: 1px solid var(--line-2); border-radius: var(--r);
  background: var(--surface); color: var(--ink);
  font-weight: 600; font-size: .9375rem; line-height: 1.2; text-decoration: none; white-space: nowrap;
  transition: background-color .12s, border-color .12s, transform .06s;
}
.btn:hover { background: var(--hover); }
.btn:active { transform: translateY(1px); }
.btn[disabled], .btn[aria-disabled="true"] { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { background: color-mix(in srgb, var(--accent) 88%, var(--ink)); border-color: color-mix(in srgb, var(--accent) 88%, var(--ink)); }
.btn-ink { background: var(--ink); border-color: var(--ink); color: var(--canvas); }
.btn-ink:hover { background: color-mix(in srgb, var(--ink) 86%, var(--canvas)); }
.btn-quiet { border-color: transparent; background: transparent; }
.btn-danger { color: var(--bad); border-color: color-mix(in srgb, var(--bad) 45%, var(--line)); }
.btn-danger:hover { background: var(--bad-soft); }
.btn-sm { min-height: 32px; padding: 0 10px; font-size: .875rem; border-radius: var(--r-sm); }
.btn-lg { min-height: 46px; padding: 0 20px; font-size: 1rem; }
.btn-block { width: 100%; }

.icon-btn {
  display: inline-grid; place-items: center; width: 34px; height: 34px; flex: none;
  border-radius: var(--r-sm); color: var(--ink-2);
  transition: background-color .12s, color .12s;
}
.icon-btn:hover { background: var(--hover); color: var(--ink); }
.icon-btn[aria-pressed="true"] { color: var(--accent-text); background: var(--accent-soft); }
.icon-btn.sm { width: 28px; height: 28px; }

.field { display: grid; grid-template-columns: minmax(0, 1fr); gap: 6px; align-content: start; min-width: 0; }
.label { font-size: .875rem; font-weight: 600; color: var(--ink); }
.hint { font-size: .8125rem; color: var(--ink-3); }
.error-text { font-size: .8125rem; color: var(--bad); font-weight: 500; }
.input, .select, .textarea {
  width: 100%; min-height: 40px; padding: 8px 12px;
  background: var(--surface); border: 1px solid var(--line-2); border-radius: var(--r);
  color: var(--ink);
  transition: border-color .12s, box-shadow .12s;
}
.textarea { min-height: 96px; resize: vertical; line-height: 1.5; }
.input::placeholder, .textarea::placeholder { color: var(--ink-3); opacity: 1; }
.input:hover, .select:hover, .textarea:hover { border-color: var(--ink-3); }
.input:focus-visible, .select:focus-visible, .textarea:focus-visible { outline: none; border-color: var(--ink); box-shadow: var(--focus); }
.input[aria-invalid="true"], .textarea[aria-invalid="true"] { border-color: var(--bad); }
.select { appearance: none; padding-right: 34px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23818a9c' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 10px center; background-size: 16px; }
.input-icon { position: relative; }
.input-icon > .icon { position: absolute; left: 11px; top: 50%; translate: 0 -50%; color: var(--ink-3); pointer-events: none; }
.input-icon > .input { padding-left: 36px; }

.switch { position: relative; display: inline-flex; align-items: center; gap: 10px; cursor: pointer; }
.switch input { position: absolute; opacity: 0; width: 42px; height: 24px; margin: 0; cursor: pointer; }
.switch i { width: 42px; height: 24px; flex: none; border-radius: 99px; background: var(--line-2); transition: background-color .15s; position: relative; }
.switch i::after { content: ''; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, .3); transition: translate .15s; }
.switch input:checked + i { background: var(--ink); }
[data-theme="dark"] .switch input:checked + i { background: var(--accent); }
[data-theme="dark"] .switch input:checked + i::after { background: var(--accent-ink); }
.switch input:checked + i::after { translate: 18px 0; }
.switch input:focus-visible + i { outline: 2px solid var(--ink); outline-offset: 2px; box-shadow: var(--focus); }

.range { width: 100%; accent-color: var(--ink); height: 24px; }
[data-theme="dark"] .range { accent-color: var(--accent); }

.pill {
  display: inline-flex; align-items: center; gap: 6px; min-height: 26px; padding: 0 10px;
  border-radius: 99px; border: 1px solid var(--line); background: var(--surface);
  font-size: .8125rem; font-weight: 500; color: var(--ink-2); white-space: nowrap;
}
.pill .icon { width: 14px; height: 14px; }
.pill-ok { color: var(--ok); background: var(--ok-soft); border-color: transparent; }
.pill-warn { color: var(--warn); background: var(--warn-soft); border-color: transparent; }
.pill-bad { color: var(--bad); background: var(--bad-soft); border-color: transparent; }
.pill-info { color: var(--info); background: var(--info-soft); border-color: transparent; }
.pill-accent { color: var(--accent-text); background: var(--accent-soft); border-color: transparent; }
button.pill { cursor: pointer; transition: background-color .12s, border-color .12s, color .12s; }
button.pill:hover { border-color: var(--ink-3); color: var(--ink); }
button.pill[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: var(--canvas); }

.kbd { display: inline-grid; place-items: center; min-width: 22px; height: 22px; padding: 0 6px; border: 1px solid var(--line-2); border-bottom-width: 2px; border-radius: 6px; background: var(--surface); font-family: var(--font-mono); font-size: .75rem; color: var(--ink-2); }

.avatar { display: inline-grid; place-items: center; width: 32px; height: 32px; flex: none; border-radius: 50%; background: var(--c, var(--ink)); color: #fff; font-size: .75rem; font-weight: 700; letter-spacing: .01em; }
.mark { display: inline-grid; place-items: center; width: 32px; height: 32px; flex: none; border-radius: 10px; background: var(--ink); color: var(--accent); }
[data-theme="dark"] .mark { background: var(--accent); color: var(--accent-ink); }
.mark svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2.6; stroke-linecap: round; }
.mark.sm { width: 26px; height: 26px; border-radius: 8px; }
.mark.sm svg { width: 16px; height: 16px; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); }
.card-pad { padding: 18px; }
.divider { height: 1px; background: var(--line); border: 0; margin: 0; }

.banner { display: flex; align-items: flex-start; gap: 10px; padding: 11px 14px; border-radius: var(--r); background: var(--info-soft); color: var(--ink); font-size: .9063rem; }
.banner > .icon { margin-top: 2px; color: var(--info); }
.banner-warn { background: var(--warn-soft); }
.banner-warn > .icon { color: var(--warn); }
.banner-bad { background: var(--bad-soft); }
.banner-bad > .icon { color: var(--bad); }
.banner a { font-weight: 600; }

.meter { height: 6px; border-radius: 99px; background: var(--line); overflow: hidden; }
.meter > i { display: block; height: 100%; width: var(--v, 40%); background: var(--ink); border-radius: inherit; }
[data-theme="dark"] .meter > i { background: var(--accent); }

.spinner { width: 16px; height: 16px; flex: none; border-radius: 50%; border: 2px solid var(--line-2); border-top-color: var(--ink); animation: aw-spin .7s linear infinite; }
@keyframes aw-spin { to { rotate: 360deg; } }

.skeleton { border-radius: 6px; background: linear-gradient(90deg, var(--sunk) 0%, var(--hover) 50%, var(--sunk) 100%); background-size: 200% 100%; animation: aw-shimmer 1.3s linear infinite; }
@keyframes aw-shimmer { to { background-position: -200% 0; } }

.tabs { display: inline-flex; justify-self: start; padding: 3px; gap: 2px; border-radius: var(--r); background: var(--sunk); border: 1px solid var(--line); }
.tabs button { min-height: 30px; padding: 0 12px; border-radius: 7px; font-size: .875rem; font-weight: 600; color: var(--ink-2); }
.tabs button:hover { color: var(--ink); }
.tabs button[aria-selected="true"], .tabs button[aria-pressed="true"] { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-1); }

/* 4. App shell: rail, sidebar, top bar ----------------------------------- */
.app-body { height: 100vh; height: 100dvh; overflow: hidden; }
.app { display: grid; grid-template-columns: 60px 280px minmax(0, 1fr); height: 100%; }
.app--wide { grid-template-columns: 60px minmax(0, 1fr); }
.app.is-side-closed { grid-template-columns: 60px 0 minmax(0, 1fr); }
.app.is-side-closed .side { display: none; }

/* the narrow strip with the app sections */
.rail { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 12px 0; background: var(--rail); color: var(--rail-ink); }
.rail-brand { display: grid; place-items: center; width: 36px; height: 36px; margin-bottom: 10px; border-radius: 11px; background: var(--accent); color: var(--accent-ink); }
.rail-brand svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2.6; stroke-linecap: round; }
.rail a, .rail button { position: relative; display: grid; place-items: center; width: 40px; height: 40px; border-radius: 10px; color: var(--rail-ink); transition: background-color .12s, color .12s; }
.rail a:hover, .rail button:hover { background: rgba(255, 255, 255, .09); color: #fff; }
.rail a[aria-current="page"] { background: rgba(255, 255, 255, .12); color: var(--accent); }
.rail a:focus-visible, .rail button:focus-visible { outline-color: #fff; }
.rail-gap { flex: 1; }
.rail .icon { width: 20px; height: 20px; }
/* name of the section, shown beside the icon on hover and keyboard focus */
.rail [data-tip]::after {
  content: attr(data-tip); position: absolute; left: calc(100% + 10px); top: 50%; translate: -4px -50%; z-index: 60;
  padding: 5px 9px; border-radius: 7px; background: var(--ink); color: var(--canvas); font-size: .8125rem; font-weight: 600; white-space: nowrap;
  opacity: 0; pointer-events: none; transition: opacity .12s, translate .12s; box-shadow: var(--shadow-2);
}
[data-theme="dark"] .rail [data-tip]::after { background: var(--raised); color: var(--ink); border: 1px solid var(--line-2); }
.rail [data-tip]:hover::after, .rail [data-tip]:focus-visible::after { opacity: 1; translate: 0 -50%; }

/* conversation list (and, on phones, the whole navigation) */
.side { display: flex; flex-direction: column; min-width: 0; background: var(--side); border-right: 1px solid var(--line); }
.side-head { display: grid; gap: 10px; padding: 14px 12px 10px; }
.side-title { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 0 4px; }
.side-title b { font-size: 1.0625rem; font-weight: 700; letter-spacing: -.01em; }
.side-apps { display: none; padding: 4px 8px 8px; border-bottom: 1px solid var(--line); }
.side-apps a { display: flex; align-items: center; gap: 10px; min-height: 40px; padding: 0 10px; border-radius: var(--r-sm); font-weight: 600; text-decoration: none; color: var(--ink-2); }
.side-apps a:hover { background: var(--hover); color: var(--ink); }
.side-apps a[aria-current="page"] { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-1); }
.side-list { flex: 1; min-height: 0; padding: 0 8px 12px; }
.side-group { margin: 14px 10px 4px; font-size: .75rem; font-weight: 600; color: var(--ink-3); }
.side-empty { margin: 18px 10px; font-size: .875rem; color: var(--ink-3); }

.conv { position: relative; display: flex; align-items: center; border-radius: var(--r-sm); }
.conv:hover, .conv:focus-within { background: var(--hover); }
.conv.is-active { background: var(--surface); box-shadow: var(--shadow-1); }
.conv-link { flex: 1; min-width: 0; display: flex; align-items: center; gap: 7px; min-height: 36px; padding: 0 4px 0 10px; text-align: left; font-size: .9063rem; color: var(--ink-2); border-radius: inherit; }
.conv.is-active .conv-link { color: var(--ink); font-weight: 600; }
.conv-link span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.conv-link .icon { width: 13px; height: 13px; color: var(--accent-text); }
.conv-more { opacity: 0; margin-right: 3px; }
.conv:hover .conv-more, .conv:focus-within .conv-more, .conv-more[aria-expanded="true"], .conv.is-active .conv-more { opacity: 1; }
.conv-rename { flex: 1; min-width: 0; margin: 3px; min-height: 30px; padding: 2px 8px; font-size: .9063rem; }

.side-foot { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-top: 1px solid var(--line); }
.side-user { flex: 1; min-width: 0; display: flex; align-items: center; gap: 10px; padding: 6px; border-radius: var(--r); text-align: left; }
.side-user:hover { background: var(--hover); }
.side-user b { display: block; font-size: .875rem; line-height: 1.25; }
.side-user small { display: block; font-size: .75rem; color: var(--ink-3); line-height: 1.25; }
.usage { padding: 0 14px 12px; display: grid; gap: 6px; font-size: .75rem; color: var(--ink-3); }
.usage b { color: var(--ink-2); font-weight: 600; }

.main { display: flex; flex-direction: column; min-width: 0; min-height: 0; position: relative; }
.topbar { display: flex; align-items: center; gap: 8px; min-height: 56px; padding: 0 14px; border-bottom: 1px solid var(--line); background: var(--canvas); }
.topbar-title { min-width: 0; font-size: 1rem; font-weight: 700; letter-spacing: -.005em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar-sub { font-size: .8125rem; color: var(--ink-3); white-space: nowrap; }
.only-mobile { display: none; }
.model-btn { display: inline-flex; align-items: center; gap: 7px; min-height: 34px; padding: 0 10px; border-radius: var(--r-sm); font-weight: 600; font-size: .9063rem; color: var(--ink); white-space: nowrap; }
.model-btn:hover { background: var(--hover); }
.model-btn .icon { width: 15px; height: 15px; color: var(--ink-3); }
.model-btn i { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 30%, transparent); }

/* pages without a conversation list */
.page { flex: 1; min-height: 0; }
.page-in { max-width: 1120px; margin: 0 auto; padding: 28px 28px 64px; }
.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 14px 24px; margin-bottom: 22px; }
.page-head h1 { font-size: 1.75rem; line-height: 1.15; font-weight: 800; letter-spacing: -.025em; }
.page-head p { margin-top: 6px; max-width: 60ch; color: var(--ink-2); }

/* 5. Chat: thread, messages, composer ------------------------------------ */
.thread { flex: 1; min-height: 0; padding: 18px 0 8px; scroll-padding-bottom: 40px; }
.thread-in { display: flex; flex-direction: column; min-height: 100%; }

.msg { display: grid; grid-template-columns: 32px minmax(0, 1fr); gap: 0 14px; width: 100%; max-width: var(--thread); margin: 0 auto; padding: 12px 20px; }
.msg-body { min-width: 0; display: grid; gap: 10px; justify-items: start; }
.msg-body > * { max-width: 100%; }
.msg-who { display: flex; align-items: baseline; gap: 8px; min-height: 22px; margin-top: 4px; font-size: .875rem; }
.msg-who b { font-weight: 700; }
.msg-who span { color: var(--ink-3); font-size: .8125rem; }

.msg--user { grid-template-columns: minmax(0, 1fr); }
.msg--user .msg-body { justify-items: end; gap: 4px; }
.msg--user { padding-bottom: 2px; }
.msg--user .msg-actions { min-height: 28px; }
.msg--user .msg-actions .icon-btn { width: 28px; height: 28px; }
.bubble { max-width: min(86%, 600px); padding: 10px 15px; border-radius: 18px 18px 5px 18px; background: var(--bubble); color: var(--bubble-ink); white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.5; }
.msg-edit { width: min(100%, 600px); display: grid; gap: 8px; padding: 10px; border: 1px solid var(--line-2); border-radius: var(--r-lg); background: var(--surface); }
.msg-edit textarea { width: 100%; min-height: 70px; border: 0; background: transparent; resize: vertical; padding: 4px 6px; line-height: 1.5; }
.msg-edit textarea:focus-visible { box-shadow: none; outline: none; }
.msg-edit .row { justify-content: flex-end; }

.msg-actions { display: flex; align-items: center; gap: 2px; min-height: 30px; color: var(--ink-3); }
.msg-actions .icon-btn { width: 30px; height: 30px; color: var(--ink-3); }
.msg-actions .icon-btn:hover { color: var(--ink); }
.msg-actions .icon-btn .icon { width: 16px; height: 16px; }
.msg-actions .icon-btn[aria-pressed="true"] { color: var(--accent-text); }
.msg-actions .icon-btn.is-done { color: var(--ok); }
.msg--user .msg-actions { opacity: 0; transition: opacity .12s; }
.msg--user:hover .msg-actions, .msg--user:focus-within .msg-actions { opacity: 1; }
.versions { display: inline-flex; align-items: center; gap: 2px; margin-right: 4px; font-size: .8125rem; font-variant-numeric: tabular-nums; }
.versions .icon-btn { width: 24px; height: 24px; }
.versions .icon-btn[disabled] { opacity: .35; cursor: default; }

/* attachments shown in a message or above the composer */
.files { display: flex; flex-wrap: wrap; gap: 8px; }
.msg--user .files { justify-content: flex-end; }
.file { display: inline-flex; align-items: center; gap: 9px; max-width: 240px; padding: 6px 10px 6px 6px; border: 1px solid var(--line); border-radius: var(--r); background: var(--surface); font-size: .8125rem; }
.file-ico { display: grid; place-items: center; width: 34px; height: 34px; flex: none; border-radius: 7px; background: var(--sunk); color: var(--ink-2); overflow: hidden; }
.file-ico img { width: 100%; height: 100%; object-fit: cover; }
.file b { display: block; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file small { display: block; color: var(--ink-3); font-size: .75rem; }
.file > div { min-width: 0; }
.file .icon-btn { width: 24px; height: 24px; margin-left: 2px; }

/* answer text (rendered Markdown) */
.prose { font-family: var(--font-read); font-size: var(--read-size); line-height: 1.65; color: var(--ink); overflow-wrap: break-word; min-width: 0; width: 100%; }
.prose > * + * { margin-top: .85em; }
.prose h1, .prose h2, .prose h3, .prose h4 { font-family: var(--font-ui); line-height: 1.25; letter-spacing: -.012em; font-weight: 700; }
.prose h1 { font-size: 1.45em; }
.prose h2 { font-size: 1.25em; }
.prose h3 { font-size: 1.1em; }
.prose h4 { font-size: 1em; }
.prose > h1:not(:first-child), .prose > h2:not(:first-child), .prose > h3:not(:first-child) { margin-top: 1.4em; }
.prose a { color: var(--accent-text); text-decoration: underline; text-underline-offset: 3px; text-decoration-thickness: 1.5px; font-weight: 500; }
[data-accent] .prose a { color: var(--accent-text); }
.prose strong { font-weight: 700; }
.prose ul, .prose ol { padding-left: 1.4em; }
.prose ul { list-style: disc; }
.prose ol { list-style: decimal; }
.prose li + li, .prose li > ul, .prose li > ol { margin-top: .3em; }
.prose li::marker { color: var(--ink-3); font-variant-numeric: normal; }
.prose li.task { list-style: none; margin-left: -1.4em; display: flex; gap: 9px; align-items: baseline; }
.prose li.task input { width: 15px; height: 15px; margin: 0; accent-color: var(--ink); translate: 0 2px; flex: none; }
.prose blockquote { padding: 2px 0 2px 14px; border-left: 3px solid var(--accent); color: var(--ink-2); }
.prose hr { border: 0; height: 1px; background: var(--line); margin: 1.4em 0; }
.prose code { font-family: var(--font-mono); font-size: .875em; padding: .12em .38em; border-radius: 5px; background: var(--sunk); border: 1px solid var(--line); }
.prose .table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--r); }
.prose table { width: 100%; border-collapse: collapse; font-family: var(--font-ui); font-size: .9063rem; line-height: 1.45; }
.prose th, .prose td { padding: 8px 12px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: top; }
.prose th { font-weight: 700; background: var(--sunk); white-space: nowrap; }
.prose tr:last-child td { border-bottom: 0; }
.prose img { border-radius: var(--r); }
.prose sup.cite a { display: inline-grid; place-items: center; min-width: 17px; height: 17px; padding: 0 4px; margin: 0 1px; border-radius: 5px; background: var(--sunk); border: 1px solid var(--line); color: var(--ink-2); font-family: var(--font-ui); font-size: .6875rem; font-weight: 700; text-decoration: none; }
.prose sup.cite a:hover { background: var(--ink); color: var(--canvas); border-color: var(--ink); }

/* code block (dark in both themes) */
.code { border-radius: var(--r); background: var(--code-bg); color: var(--code-ink); overflow: hidden; font-family: var(--font-mono); border: 1px solid transparent; }
[data-theme="dark"] .code { border-color: var(--line); }
.code-bar { display: flex; align-items: center; justify-content: space-between; gap: 10px; min-height: 36px; padding: 0 6px 0 14px; background: var(--code-bar); color: var(--code-dim); font-size: .75rem; }
.code-copy { display: inline-flex; align-items: center; gap: 6px; min-height: 26px; padding: 0 8px; border-radius: 6px; color: var(--code-dim); font-family: var(--font-ui); font-size: .75rem; font-weight: 600; }
.code-copy:hover { background: rgba(255, 255, 255, .08); color: #fff; }
.code-copy:focus-visible { outline-color: #fff; }
.code-copy .icon { width: 14px; height: 14px; }
.code pre { margin: 0; padding: 13px 16px 15px; overflow-x: auto; font-size: .8438rem; line-height: 1.6; tab-size: 2; }
.code pre code { font: inherit; padding: 0; border: 0; background: none; color: inherit; white-space: pre; }
.tok-key { color: var(--tok-key); }
.tok-str { color: var(--tok-str); }
.tok-num { color: var(--tok-num); }
.tok-com { color: var(--tok-com); font-style: italic; }
.tok-fn { color: var(--tok-fn); }
.tok-tag { color: var(--tok-tag); }

/* blinking caret at the end of an answer that is still arriving */
.is-streaming .prose > :last-child::after, .is-streaming .prose:empty::after {
  content: ''; display: inline-block; width: .5em; height: 1.05em; margin-left: .15em; vertical-align: -.18em; border-radius: 2px; background: var(--ink); animation: aw-blink 1s steps(2, start) infinite;
}
.is-streaming .prose > .code:last-child::after, .is-streaming .prose > .table-wrap:last-child::after, .is-streaming .prose > hr:last-child::after { content: none; }
@keyframes aw-blink { 50% { opacity: 0; } }

.thinking { display: inline-flex; align-items: center; gap: 9px; min-height: 28px; color: var(--ink-3); font-size: .9063rem; }
.thinking i { display: inline-flex; gap: 4px; }
.thinking i::before, .thinking i::after, .thinking i b { content: ''; width: 6px; height: 6px; border-radius: 50%; background: var(--ink-3); animation: aw-bounce 1.1s ease-in-out infinite; }
.thinking i b { animation-delay: .15s; }
.thinking i::after { animation-delay: .3s; }
@keyframes aw-bounce { 0%, 60%, 100% { translate: 0 0; opacity: .45; } 30% { translate: 0 -4px; opacity: 1; } }

/* what the assistant did before answering (tool calls, searches, reasoning steps) */
.steps { width: 100%; border: 1px solid var(--line); border-radius: var(--r); background: var(--surface); font-size: .875rem; overflow: hidden; }
.steps-head { display: flex; align-items: center; gap: 9px; width: 100%; min-height: 38px; padding: 0 12px; text-align: left; font-weight: 600; color: var(--ink-2); }
.steps-head:hover { background: var(--sunk); }
.steps-head .chev { margin-left: auto; color: var(--ink-3); transition: rotate .15s; }
.steps-head[aria-expanded="true"] .chev { rotate: 90deg; }
.steps-head .spinner { width: 14px; height: 14px; }
.steps-head .icon { width: 16px; height: 16px; }
.steps-list { display: grid; padding: 4px 12px 12px; border-top: 1px solid var(--line); }
.step { position: relative; display: grid; grid-template-columns: 18px minmax(0, 1fr); gap: 0 10px; padding: 8px 0 0; }
.step:not(:last-child)::before { content: ''; position: absolute; left: 8.5px; top: 28px; bottom: -8px; width: 1px; background: var(--line-2); }
.step-dot { display: grid; place-items: center; width: 18px; height: 18px; margin-top: 2px; border-radius: 50%; background: var(--sunk); color: var(--ink-3); }
.step-dot .icon { width: 11px; height: 11px; stroke-width: 2.6; }
.step-dot .spinner { width: 12px; height: 12px; border-width: 1.75px; }
.step.is-done .step-dot { background: var(--ok-soft); color: var(--ok); }
.step.is-error .step-dot { background: var(--bad-soft); color: var(--bad); }
.step.is-running .step-dot { background: transparent; }
.step b { font-weight: 600; color: var(--ink); }
.step.is-pending b { color: var(--ink-3); font-weight: 500; }
.step p { color: var(--ink-3); font-size: .8125rem; overflow-wrap: anywhere; }
.step p code { font-family: var(--font-mono); font-size: .9em; }
.step time { margin-left: 8px; font-size: .75rem; font-weight: 400; color: var(--ink-3); font-variant-numeric: tabular-nums; }

.sources { display: flex; flex-wrap: wrap; gap: 8px; width: 100%; }
.source { display: inline-flex; align-items: center; gap: 8px; max-width: 320px; min-height: 34px; padding: 4px 11px 4px 5px; border: 1px solid var(--line); border-radius: 99px; background: var(--surface); font-size: .8125rem; text-decoration: none; color: var(--ink-2); transition: border-color .12s, color .12s; }
.source:hover { border-color: var(--ink-3); color: var(--ink); }
.source i { display: grid; place-items: center; width: 22px; height: 22px; flex: none; border-radius: 50%; background: var(--sunk); font-style: normal; font-size: .6875rem; font-weight: 700; color: var(--ink-2); }
.source span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.source small { color: var(--ink-3); flex: none; }

.msg-error { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; padding: 10px 12px 10px 14px; border-radius: var(--r); background: var(--bad-soft); font-size: .9063rem; width: 100%; }
.msg-error > .icon { color: var(--bad); }
.msg-error span { flex: 1; min-width: 180px; }
.msg-note { font-size: .8125rem; color: var(--ink-3); }

/* empty conversation */
.welcome { flex: 1; display: grid; align-content: center; justify-items: center; gap: 22px; width: 100%; max-width: var(--thread); margin: 0 auto; padding: 24px 20px; text-align: center; }
.welcome h2 { font-size: clamp(1.6rem, 1.1rem + 2vw, 2.25rem); line-height: 1.12; font-weight: 800; letter-spacing: -.03em; text-wrap: balance; }
.welcome p { color: var(--ink-2); max-width: 46ch; }
.suggest { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; width: 100%; text-align: left; }
.suggest button { display: grid; grid-template-columns: 34px minmax(0, 1fr); gap: 2px 12px; align-items: center; padding: 12px 14px; border: 1px solid var(--line); border-radius: var(--r-lg); background: var(--surface); text-align: left; transition: border-color .12s, translate .12s, box-shadow .12s; }
.suggest button:hover { border-color: var(--ink); box-shadow: 3px 3px 0 var(--accent); translate: -1px -1px; }
.suggest .ico { grid-row: span 2; display: grid; place-items: center; width: 34px; height: 34px; border-radius: 9px; background: var(--accent-soft); color: var(--accent-text); }
.suggest b { font-size: .9375rem; font-weight: 600; }
.suggest span { font-size: .8125rem; color: var(--ink-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* composer */
.dock { position: relative; padding: 0 20px 14px; }
.dock::before { content: ''; position: absolute; left: 0; right: 14px; bottom: 100%; height: 28px; background: linear-gradient(to top, var(--canvas), transparent); pointer-events: none; }
.dock-in { width: 100%; max-width: calc(var(--thread) - 40px); margin: 0 auto; position: relative; }
.composer { display: grid; gap: 4px; padding: 10px 10px 8px 14px; border: 1px solid var(--line-2); border-radius: var(--r-xl); background: var(--surface); box-shadow: var(--shadow-2); transition: border-color .12s, box-shadow .12s; }
.composer:focus-within { border-color: var(--ink); box-shadow: var(--shadow-2), var(--focus); }
.composer.is-drop { border-style: dashed; border-color: var(--ink); background: var(--accent-soft); }
.composer textarea { display: block; width: 100%; min-height: 28px; max-height: 220px; padding: 4px 2px; border: 0; background: transparent; resize: none; line-height: 1.5; font-size: 1rem; overflow-y: auto; }
.composer textarea:focus-visible { outline: none; box-shadow: none; }
.composer textarea::placeholder { color: var(--ink-3); opacity: 1; }
.composer .files { padding: 2px 0 6px; }
.composer-bar { display: flex; align-items: center; gap: 4px; margin-left: -6px; min-width: 0; }
.composer-bar .pill { min-height: 30px; }
.composer-tools { display: flex; align-items: center; gap: 6px; min-width: 0; overflow: hidden; }
.composer-hint { margin-left: auto; padding-right: 4px; font-size: .75rem; color: var(--ink-3); white-space: nowrap; }
.send { display: grid; place-items: center; width: 38px; height: 38px; flex: none; border-radius: 50%; background: var(--accent); color: var(--accent-ink); transition: scale .1s, background-color .12s, opacity .12s; }
.send:hover { scale: 1.06; }
.send:active { scale: .96; }
.send[disabled] { background: var(--line); color: var(--ink-3); cursor: not-allowed; scale: 1; }
.send .icon { width: 20px; height: 20px; stroke-width: 2.2; }
.send.is-stop { background: var(--ink); color: var(--canvas); }
.send.is-stop .icon { fill: currentColor; width: 16px; height: 16px; }
.mic.is-live { color: var(--bad); background: var(--bad-soft); animation: aw-pulse 1.4s ease-in-out infinite; }
@keyframes aw-pulse { 50% { box-shadow: 0 0 0 6px color-mix(in srgb, var(--bad) 18%, transparent); } }
.dock-note { margin-top: 8px; text-align: center; font-size: .75rem; color: var(--ink-3); }
.to-latest { position: absolute; left: 50%; bottom: calc(100% + 12px); translate: -50% 0; z-index: 5; box-shadow: var(--shadow-2); border-radius: 99px; }

/* the "/" prompt picker above the composer */
.slash { position: absolute; left: 0; right: 0; bottom: calc(100% + 8px); z-index: 20; max-height: 280px; padding: 6px; border: 1px solid var(--line-2); border-radius: var(--r-lg); background: var(--raised); box-shadow: var(--shadow-3); }
.slash-item { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 0 12px; width: 100%; padding: 8px 10px; border-radius: var(--r-sm); text-align: left; }
.slash-item b { font-size: .9063rem; font-weight: 600; }
.slash-item span { grid-column: 1; font-size: .8125rem; color: var(--ink-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.slash-item em { grid-row: 1 / span 2; grid-column: 2; align-self: center; font-style: normal; font-size: .75rem; color: var(--ink-3); }
.slash-item[aria-selected="true"], .slash-item:hover { background: var(--hover); }
.slash-empty { padding: 10px; font-size: .875rem; color: var(--ink-3); }

/* 6. Overlays: menus, modals, toasts ------------------------------------- */
.menu { position: fixed; z-index: 80; min-width: 200px; max-width: min(320px, calc(100vw - 16px)); max-height: min(420px, calc(100vh - 16px)); overflow-y: auto; padding: 5px; border: 1px solid var(--line-2); border-radius: var(--r); background: var(--raised); box-shadow: var(--shadow-3); }
.menu[hidden] { display: none; }
.menu-item { display: flex; align-items: center; gap: 10px; width: 100%; min-height: 36px; padding: 6px 10px; border-radius: 7px; text-align: left; font-size: .9063rem; color: var(--ink); text-decoration: none; }
.menu-item:hover, .menu-item:focus-visible { background: var(--hover); outline: none; box-shadow: none; }
.menu-item .icon { width: 16px; height: 16px; color: var(--ink-3); }
.menu-item.danger, .menu-item.danger .icon { color: var(--bad); }
.menu-item small { display: block; font-size: .75rem; color: var(--ink-3); line-height: 1.3; }
.menu-item .check { margin-left: auto; color: var(--ink); visibility: hidden; }
.menu-item[aria-checked="true"] .check { visibility: visible; }
.menu-sep { height: 1px; margin: 5px 4px; background: var(--line); }
.menu-label { padding: 6px 10px 3px; font-size: .75rem; font-weight: 600; color: var(--ink-3); }

.modal { position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; padding: 16px; background: rgba(12, 15, 22, .55); animation: aw-fade .14s ease-out; }
.modal[hidden] { display: none; }
.modal-box { display: flex; flex-direction: column; width: 100%; max-width: 480px; max-height: min(720px, calc(100dvh - 32px)); border-radius: var(--r-lg); background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow-3); animation: aw-rise .18s ease-out; }
.modal-box.wide { max-width: 760px; }
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 16px 12px 20px; }
.modal-head h2 { font-size: 1.125rem; font-weight: 700; letter-spacing: -.01em; }
.modal-body { padding: 4px 20px 20px; overflow-y: auto; display: grid; gap: 16px; align-content: start; }
.modal-foot { display: flex; justify-content: flex-end; flex-wrap: wrap; gap: 8px; padding: 14px 20px; border-top: 1px solid var(--line); }
@keyframes aw-fade { from { opacity: 0; } }
@keyframes aw-rise { from { opacity: 0; translate: 0 10px; } }

/* settings: sections on the left, panel on the right */
.settings { display: grid; grid-template-columns: 170px minmax(0, 1fr); min-height: 420px; }
.settings-nav { display: grid; align-content: start; gap: 2px; padding: 4px 10px 16px 12px; border-right: 1px solid var(--line); }
.settings-nav button { display: flex; align-items: center; gap: 9px; min-height: 36px; padding: 0 10px; border-radius: var(--r-sm); font-weight: 600; font-size: .9063rem; color: var(--ink-2); text-align: left; }
.settings-nav button:hover { background: var(--hover); color: var(--ink); }
.settings-nav button[aria-selected="true"] { background: var(--sunk); color: var(--ink); }
.settings-panel { padding: 4px 20px 22px; display: grid; gap: 18px; align-content: start; overflow-y: auto; }
.setting { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.setting > div:first-child { min-width: 0; }
.setting b { display: block; font-weight: 600; font-size: .9375rem; }
.setting small { display: block; color: var(--ink-3); font-size: .8125rem; }
.swatches { display: flex; gap: 8px; }
.swatch { width: 28px; height: 28px; border-radius: 50%; background: var(--c); border: 2px solid var(--surface); box-shadow: 0 0 0 1px var(--line-2); }
.swatch[aria-pressed="true"] { box-shadow: 0 0 0 2px var(--ink); }

.toasts { position: fixed; left: 50%; bottom: 22px; translate: -50% 0; z-index: 120; display: grid; gap: 8px; justify-items: center; pointer-events: none; width: max-content; max-width: calc(100vw - 24px); }
.toast { display: inline-flex; align-items: center; gap: 9px; min-height: 40px; padding: 8px 16px; border-radius: 99px; background: var(--ink); color: var(--canvas); font-size: .9063rem; font-weight: 500; box-shadow: var(--shadow-3); animation: aw-rise .18s ease-out; pointer-events: auto; }
.toast .icon { width: 16px; height: 16px; }
.toast.is-out { opacity: 0; translate: 0 6px; transition: opacity .2s, translate .2s; }

.scrim { position: fixed; inset: 0; z-index: 69; background: rgba(12, 15, 22, .5); }

.keys { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 10px 20px; align-items: center; font-size: .9375rem; }
.keys dd { margin: 0; display: flex; gap: 4px; justify-content: flex-end; }

/* 7. Prompt library ------------------------------------------------------- */
.filters { display: flex; align-items: center; gap: 14px; margin-bottom: 12px; }
.filters .input-icon { max-width: 420px; }
.cats { margin-bottom: 20px; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.pgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 14px; }
.pcard { display: flex; flex-direction: column; gap: 10px; padding: 16px; border: 1px solid var(--line); border-radius: var(--r-lg); background: var(--surface); transition: border-color .12s, box-shadow .12s; }
.pcard:hover, .pcard:focus-within { border-color: var(--line-2); box-shadow: var(--shadow-2); }
.pcard header { display: flex; align-items: center; justify-content: space-between; }
.pcard h2 { font-size: 1.0625rem; font-weight: 700; letter-spacing: -.01em; }
.pcard footer { display: flex; align-items: center; gap: 6px; margin-top: auto; padding-top: 4px; font-size: .8125rem; }
.pcard [data-fav][aria-pressed="true"] { background: none; color: var(--accent-text); }
.pcard [data-fav][aria-pressed="true"] .icon { fill: var(--accent); stroke: var(--accent-text); }
.pcard-text { font-size: .875rem; line-height: 1.55; color: var(--ink-2); white-space: pre-wrap; overflow-wrap: anywhere; display: -webkit-box; -webkit-line-clamp: 4; line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden; }
.pcard-text mark, .preview mark { padding: 1px 5px; border-radius: 5px; background: var(--accent-soft); color: var(--accent-text); font-family: var(--font-mono); font-size: .9em; font-weight: 500; }
.preview { display: block; max-height: 180px; overflow-y: auto; padding: 10px 12px; border: 1px dashed var(--line-2); border-radius: var(--r); background: var(--sunk); -webkit-line-clamp: unset; line-clamp: unset; }
.empty { grid-column: 1 / -1; display: grid; justify-items: center; gap: 6px; padding: 48px 20px; border: 1px dashed var(--line-2); border-radius: var(--r-lg); text-align: center; color: var(--ink-2); }
.empty b { font-size: 1.0625rem; color: var(--ink); }
.empty p { max-width: 44ch; }

/* 8. Playground ----------------------------------------------------------- */
.pg { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 22px; max-width: 1280px; margin: 0 auto; padding: 28px 28px 56px; align-items: start; }
.pg-main { display: grid; gap: 16px; min-width: 0; }
.pg-side { display: grid; gap: 14px; position: sticky; top: 20px; }
.h-sm { font-size: .9375rem; font-weight: 700; }
.pg-vars { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 10px; }
.pg-outs { display: grid; gap: 14px; }
.pg-outs.is-two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.pg-out { display: flex; flex-direction: column; min-width: 0; min-height: 260px; max-height: 560px; border: 1px solid var(--line); border-radius: var(--r-lg); background: var(--surface); }
.pg-out header { display: flex; align-items: center; gap: 10px; min-height: 44px; padding: 0 8px 0 12px; border-bottom: 1px solid var(--line); font-size: .8125rem; }
.pg-body { flex: 1; min-height: 0; padding: 14px 16px 18px; }
.pg-history { display: grid; gap: 4px; margin: 0 -6px; }
.pg-run { display: grid; gap: 1px; padding: 7px 8px; border-radius: var(--r-sm); text-align: left; }
.pg-run:hover { background: var(--hover); }
.pg-run b { font-size: .875rem; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pg-run span { font-size: .75rem; color: var(--ink-3); }
.kbd-hint { display: inline-flex; gap: 4px; align-items: center; }

/* 9. Agent runs ----------------------------------------------------------- */
.page-in--wide { max-width: 1280px; }
.runs { display: grid; grid-template-columns: 360px minmax(0, 1fr); gap: 18px; align-items: start; }
.runs-left { display: grid; grid-template-columns: minmax(0, 1fr); gap: 14px; min-width: 0; }
.run-list { display: grid; grid-template-columns: minmax(0, 1fr); gap: 8px; }
.run { display: grid; grid-template-columns: minmax(0, 1fr); gap: 9px; width: 100%; padding: 13px 14px; border: 1px solid var(--line); border-radius: var(--r-lg); background: var(--surface); text-align: left; font-size: .8125rem; transition: border-color .12s; }
.run:hover { border-color: var(--ink-3); }
.run.is-active { border-color: var(--ink); box-shadow: 3px 3px 0 var(--accent); }
.run b { font-size: .9375rem; font-weight: 600; }
.run .pill { min-height: 22px; padding: 0 8px; font-size: .75rem; }
.run .pill .spinner, .run-head .pill .spinner { width: 11px; height: 11px; border-width: 1.75px; border-color: color-mix(in srgb, currentColor 30%, transparent); border-top-color: currentColor; }
.run-detail { display: grid; gap: 16px; align-content: start; min-width: 0; min-height: 420px; padding: 20px 22px 24px; }
.run-head { display: flex; flex-wrap: wrap; align-items: flex-start; gap: 12px; }
.run-head h2 { font-size: 1.25rem; font-weight: 700; letter-spacing: -.015em; line-height: 1.25; }
.run-head p { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; margin-top: 6px; font-size: .875rem; }
.run-meter { height: 5px; }
.run-detail .tabs { justify-self: start; }
.run-steps { border-top: 0; padding: 0; font-size: .9375rem; }
.run-steps .step { padding-top: 12px; }
.run-steps .step-dot { width: 22px; height: 22px; margin-top: 0; }
.run-steps .step { grid-template-columns: 22px minmax(0, 1fr); gap: 0 12px; }
.run-steps .step:not(:last-child)::before { left: 10.5px; top: 36px; bottom: -10px; }
.run-steps .step-dot .icon { width: 13px; height: 13px; }
.run-steps .step p { font-size: .875rem; }
.run-log { margin: 0; padding: 14px 16px; max-height: 420px; border-radius: var(--r); background: var(--code-bg); color: var(--code-ink); font-family: var(--font-mono); font-size: .8125rem; line-height: 1.7; white-space: pre-wrap; overflow-wrap: anywhere; overflow-y: auto; }
.run-log .lv-warn { color: var(--tok-key); }
.run-log .lv-error { color: var(--tok-tag); }
.run-back { display: none; }

/* 10. Components, sign in, shared chat ------------------------------------ */
.demo { margin-top: 30px; }
.demo > header { margin-bottom: 12px; }
.demo > header h2 { font-size: 1.125rem; font-weight: 700; letter-spacing: -.01em; }
.demo > header p { color: var(--ink-3); font-size: .9063rem; }
.demo-body { display: grid; gap: 14px; padding: 20px; border: 1px solid var(--line); border-radius: var(--r-lg); background: var(--surface); min-width: 0; }
.demo--flush .demo-body { padding: 8px 0; background: var(--canvas); }
.thread-sample { display: grid; }
.thread-sample .msg { max-width: none; margin: 0; }

/* sign in ---------------------------------------------------------------- */
.auth-body, .share-body { min-height: 100vh; min-height: 100dvh; }
.auth { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); min-height: 100vh; min-height: 100dvh; }
.auth-form { display: flex; flex-direction: column; gap: 22px; width: 100%; max-width: 440px; margin: 0 auto; padding: 32px 28px; }
.auth-brand { display: inline-flex; align-items: center; gap: 10px; text-decoration: none; font-size: 1.125rem; font-weight: 800; letter-spacing: -.01em; }
.auth-view { display: grid; gap: 16px; margin: auto 0; }
.auth-view h1 { font-size: 1.875rem; line-height: 1.12; font-weight: 800; letter-spacing: -.03em; }
.auth-view h1 + p { margin-top: -10px; }
.link { color: var(--ink); font-weight: 600; text-decoration: underline; text-underline-offset: 3px; font-size: inherit; }
.label .link { font-size: .8125rem; font-weight: 500; }
.pw { position: relative; display: block; }
.pw .input { padding-right: 42px; }
.pw-toggle { position: absolute; right: 6px; top: 50%; translate: 0 -50%; }
.check { display: flex; align-items: flex-start; gap: 9px; font-size: .9063rem; color: var(--ink-2); cursor: pointer; }
.check input { width: 17px; height: 17px; margin: 2px 0 0; accent-color: var(--ink); flex: none; }
[data-theme="dark"] .check input { accent-color: var(--accent); }
.or { display: flex; align-items: center; gap: 12px; color: var(--ink-3); font-size: .8125rem; }
.or::before, .or::after { content: ''; flex: 1; height: 1px; background: var(--line); }
.auth-switch { text-align: center; color: var(--ink-2); font-size: .9375rem; }
.auth-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; font-size: .8125rem; }
.auth-side { display: grid; align-content: center; justify-items: center; gap: 26px; padding: 40px; background: var(--rail); color: #fff; }
.auth-card { display: grid; gap: 14px; width: 100%; max-width: 420px; padding: 20px; border-radius: var(--r-xl); background: var(--surface); color: var(--ink); box-shadow: 10px 10px 0 var(--accent); }
.auth-card .bubble { justify-self: end; max-width: 90%; }
.auth-answer { display: grid; grid-template-columns: 26px minmax(0, 1fr); gap: 12px; }
.auth-answer .prose { font-size: .9375rem; }
.auth-card .composer { display: flex; align-items: center; justify-content: space-between; padding: 6px 6px 6px 16px; border-radius: 99px; box-shadow: none; }
.auth-card .send { width: 32px; height: 32px; }
.auth-line { font-size: 1.375rem; font-weight: 700; letter-spacing: -.02em; text-align: center; max-width: 20ch; text-wrap: balance; }

/* shared (read-only) conversation ----------------------------------------- */
.share-top { position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: 12px; min-height: 56px; padding: 0 18px; background: var(--canvas); border-bottom: 1px solid var(--line); }
.share { max-width: 820px; margin: 0 auto; padding: 34px 0 60px; }
.share-head { padding: 0 20px 14px; }
.share-head h1 { font-size: clamp(1.5rem, 1.1rem + 1.6vw, 2.125rem); line-height: 1.15; font-weight: 800; letter-spacing: -.028em; text-wrap: balance; }
.share-head p { margin-top: 8px; font-size: .9063rem; }
.share-foot { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; margin: 26px 20px 0; padding-top: 18px; border-top: 1px solid var(--line); font-size: .875rem; }

/* "Get this kit" in the demo's rail */
.rail .rail-buy { background: var(--accent); color: var(--accent-ink); }
.rail .rail-buy:hover { background: var(--accent); color: var(--accent-ink); filter: brightness(1.08); }

@media (min-width: 861px) { .app--wide .topbar { display: none; } }
@media (max-width: 860px) {
  .auth { grid-template-columns: minmax(0, 1fr); }
  .auth-side { display: none; }
  .pg { grid-template-columns: minmax(0, 1fr); padding: 20px 16px 48px; }
  .pg-side { position: static; }
  .pg-outs.is-two { grid-template-columns: minmax(0, 1fr); }
  .runs { grid-template-columns: minmax(0, 1fr); }
  .run-detail { padding: 16px; }
}
@media (max-width: 560px) {
  .auth-form { padding: 22px 18px; }
  .demo-body { padding: 14px; }
  .share-top { padding: 0 12px; gap: 8px; }
  .share-top .auth-brand b { display: none; }
}

/* 11. Responsive, print, reduced motion ----------------------------------- */
.scrim { display: none; }
.side--nav { display: none; }

@media (max-width: 860px) {
  .app, .app--wide, .app.is-side-closed { grid-template-columns: minmax(0, 1fr); }
  .app.is-side-closed .side { display: flex; }
  .rail { display: none; }
  .side, .side--nav { display: flex; position: fixed; inset: 0 auto 0 0; z-index: 70; width: min(320px, 86vw); translate: -102% 0; transition: translate .2s ease-out; box-shadow: var(--shadow-3); visibility: hidden; }
  .is-side-open .side { translate: 0 0; visibility: visible; }
  .is-side-open .scrim { display: block; }
  .side-apps { display: grid; }
  .only-mobile { display: inline-grid; }
  .hide-mobile { display: none !important; }
  .page-in { padding: 20px 16px 56px; }
  .page-head h1 { font-size: 1.5rem; }
  .msg { padding: 10px 14px; }
  .dock { padding: 0 12px 10px; }
  .settings { grid-template-columns: minmax(0, 1fr); min-height: 0; }
  .settings-nav { display: flex; overflow-x: auto; padding: 0 16px 10px; border-right: 0; border-bottom: 1px solid var(--line); }
  .settings-nav button { flex: none; }
  .settings-panel { padding: 16px 16px 20px; }
}
@media (max-width: 560px) {
  .hide-xs { display: none !important; }
  .msg { grid-template-columns: minmax(0, 1fr); }
  .msg > .mark { display: none; }
  .suggest { grid-template-columns: minmax(0, 1fr); }
  .bubble { max-width: 92%; }
  .grid-2 { grid-template-columns: minmax(0, 1fr); }
  .setting { flex-wrap: wrap; }
  .composer-hint { display: none; }
  .dock-note { font-size: .6875rem; }
  .modal { padding: 10px; align-items: end; }
  .modal-box { max-height: calc(100dvh - 20px); }
  .filters { flex-wrap: wrap; }
  .page-head .row { width: 100%; }
  .page-head .row .btn { flex: 1; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; scroll-behavior: auto !important; }
  .is-streaming .prose > :last-child::after, .is-streaming .prose:empty::after { animation: none; }
}

@media print {
  .rail, .side, .topbar, .dock, .msg-actions, .toasts, .scrim { display: none !important; }
  .app-body { height: auto; overflow: visible; }
  .app { display: block; height: auto; }
  .thread { overflow: visible; }
  .code { break-inside: avoid; }
}
