/* ChatDsh design system: neutral bluish greys with a single blue accent, tuned for long-form reading. */

/* Full-width Chinese quotation marks (system fonts only; the page loads no web fonts). */
@font-face { font-family: quote-cjk-patch; src: local("PingFangSC-Regular"), local("PingFang SC"), local("Microsoft YaHei"); unicode-range: U+2018-2019, U+201C-201D; }

:root {
  color-scheme: light;
  --wallpaper-opacity: .62;
  --font-sans: quote-cjk-patch, "Inter", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC", Roboto, "Helvetica Neue", sans-serif;
  --font-mono: Menlo, Monaco, Consolas, "Cascadia Mono", "JetBrains Mono", "Fira Code", "Roboto Mono", "Courier New", monospace;

  /* One accent colour per palette (see the data-accent rules below); every brand tint derives from it. */
  --accent: #3964fe;
  --brand: var(--accent);
  --brand-hover: color-mix(in srgb, var(--accent) 84%, #fff);
  --brand-text: color-mix(in srgb, var(--accent) 92%, #000);
  --brand-dim: color-mix(in srgb, var(--accent) 34%, #fff);
  --brand-soft: color-mix(in srgb, var(--accent) 8%, #fff);
  --brand-soft-hover: color-mix(in srgb, var(--accent) 13%, #fff);
  --brand-line: color-mix(in srgb, var(--accent) 34%, #fff);
  --brand-glow: color-mix(in srgb, var(--accent) 14%, transparent);

  --bg: #fff;
  --bg-sidebar: #f9fafb;
  --bg-raised: #fff;
  --bg-menu: #fff;
  --bg-input: #fff;
  --bg-muted: #f5f6f7;
  --bg-field: #f9fafb;
  --bg-bubble: var(--brand-soft);
  --bg-code: #f9fafb;
  --bg-code-head: #f1f3f5;
  --bg-inline-code: #ebeef2;
  --bg-hover: rgba(38, 49, 72, .06);
  --bg-active: rgba(38, 49, 72, .1);
  --bg-nav-hover: #f1f3f5;
  --bg-nav-active: #ebeef2;
  --bg-nav-selected: var(--brand-soft-hover);
  --bg-select: #f1f3f5;
  --bg-skeleton: rgba(0, 0, 0, .05);

  --text: #0f1115;
  --text-2: #61666b;
  --text-3: #81858c;
  --text-4: #adb2b8;
  --line-1: rgba(0, 0, 0, .04);
  --line-2: rgba(0, 0, 0, .08);
  --line-3: rgba(0, 0, 0, .12);
  --line-4: rgba(0, 0, 0, .18);

  --danger: #ec1313;
  --danger-hover: #c90f0f;
  --danger-soft: rgba(236, 19, 19, .06);
  --danger-soft-hover: rgba(236, 19, 19, .1);
  --danger-solid: #e5281f;
  --danger-solid-hover: #c91f17;
  --success: #22c55e;
  --success-text: #15803d;
  --success-soft: rgba(34, 197, 94, .1);
  --warn: #dd8629;
  --warn-text: #b45309;
  --warn-soft: rgba(221, 134, 41, .1);
  --tooltip: #2c2c2e;
  --toast: #353638;
  --scrim: rgba(15, 17, 21, .32);
  --scroll: rgba(0, 0, 0, .1);
  --scroll-hover: rgba(0, 0, 0, .2);
  --hover-filter: brightness(.96);

  --shadow-1: 0 2px 4px 0 rgba(0, 0, 0, .05);
  --shadow-2: 0 4px 12px 0 rgba(0, 0, 0, .02), 0 2px 8px 0 rgba(0, 0, 0, .04);
  --shadow-3: 0 0 1px 0 rgba(0, 0, 0, .2), 0 0 4px 0 rgba(0, 0, 0, .02), 0 12px 32px 0 rgba(0, 0, 0, .08);
  --shadow-composer: 0 0 0 .5px rgba(0, 0, 0, .02), 0 12px 40px -6px rgba(0, 0, 0, .07), 0 2px 8px rgba(0, 0, 0, .02);

  --tok-keyword: #a626a4;
  --tok-string: #50a14f;
  --tok-number: #986801;
  --tok-comment: #a0a1a7;
  --tok-function: #4078f2;
  --tok-type: #c18401;
  --tok-tag: #e45649;

  --sidebar-w: 261px;
  --topbar-h: 56px;
  --column: 712px;
  --gutter: 36px;
  --composer-w: 760px;
  --ease: cubic-bezier(.4, 0, .2, 1);
  --ease-out: cubic-bezier(.16, 1, .3, 1);
  --ease-spring: cubic-bezier(.34, 1.45, .64, 1);
  --ease-drawer: cubic-bezier(.32, .72, 0, 1);
  --sheet-bg: #f3f4f6;
  --sheet-card: #fff;
  --icon-chevron: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m10 7 5 5-5 5'/%3E%3C/svg%3E");
  --icon-check: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m5 12.5 4.5 4.5L19 7.5'/%3E%3C/svg%3E");
  --dur: .2s;
  --icon-inbox: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M3.5 13.5h4.5l1.5 2.5h5l1.5-2.5h4.5'/%3E%3Cpath d='M5.8 6.2A2 2 0 0 1 7.6 5h8.8a2 2 0 0 1 1.8 1.2l2.3 7.3V18a1.5 1.5 0 0 1-1.5 1.5h-14A1.5 1.5 0 0 1 3.5 18v-4.5Z'/%3E%3C/svg%3E");
  --icon-chat: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M20.5 11.5a8 8 0 0 1-11.6 7.2l-4.4 1.3 1.3-4.1a8 8 0 1 1 14.7-4.4Z'/%3E%3Cpath d='M8.5 11.5h.01M12 11.5h.01M15.5 11.5h.01' stroke-width='2.2'/%3E%3C/svg%3E");
  --icon-alert: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='1.9' stroke-linecap='round'%3E%3Ccircle cx='12' cy='12' r='8.5'/%3E%3Cpath d='M12 8v4.5M12 15.8h.01'/%3E%3C/svg%3E");
}

[data-theme="dark"] {
  color-scheme: dark;
  --wallpaper-opacity: .42;
  --accent: #5686fe;
  --brand-hover: color-mix(in srgb, var(--accent) 82%, #000);
  --brand-text: color-mix(in srgb, var(--accent) 82%, #fff);
  --brand-dim: color-mix(in srgb, var(--accent) 30%, #151517);
  --brand-soft: color-mix(in srgb, var(--accent) 15%, #1b1b1c);
  --brand-soft-hover: color-mix(in srgb, var(--accent) 24%, #1b1b1c);
  --brand-line: color-mix(in srgb, var(--accent) 52%, #151517);
  --brand-glow: color-mix(in srgb, var(--accent) 22%, transparent);

  --bg: #151517;
  --bg-sidebar: #1b1b1c;
  --bg-raised: #232324;
  --bg-menu: #2c2c2e;
  --bg-input: #232324;
  --bg-muted: #232324;
  --bg-field: #1b1b1c;
  --bg-bubble: #2c2c2e;
  --bg-code: #1b1b1c;
  --bg-code-head: #2c2c2e;
  --bg-inline-code: #2c2c2e;
  --bg-hover: rgba(255, 255, 255, .08);
  --bg-active: rgba(255, 255, 255, .14);
  /* Translucent so hover still shows on raised panels and menus, whose surfaces are already #232324/#2c2c2e. */
  --bg-nav-hover: rgba(255, 255, 255, .07);
  --bg-nav-active: rgba(255, 255, 255, .11);
  --bg-nav-selected: #353638;
  --bg-select: #353638;
  --bg-skeleton: rgba(255, 255, 255, .07);

  --text: #f9fafb;
  --text-2: #cfd3d6;
  --text-3: #adb2b8;
  --text-4: #81858c;
  --line-1: rgba(255, 255, 255, .06);
  --line-2: rgba(255, 255, 255, .1);
  --line-3: rgba(255, 255, 255, .14);
  --line-4: rgba(255, 255, 255, .22);

  --danger: #f25a5a;
  --danger-hover: #f47a7a;
  --danger-soft: rgba(242, 90, 90, .14);
  --danger-soft-hover: rgba(242, 90, 90, .22);
  /* Solid red that still carries white text in the dark theme. */
  --danger-solid: #d63a3a;
  --danger-solid-hover: #e24c4c;
  --success-text: #4ade80;
  --success-soft: rgba(74, 222, 128, .12);
  --warn-text: #fbbf24;
  --warn-soft: rgba(251, 191, 36, .12);
  --tooltip: #43454a;
  --toast: #43454a;
  --sheet-bg: #18181a;
  --sheet-card: #2a2a2c;
  --scrim: rgba(0, 0, 0, .56);
  --scroll: rgba(255, 255, 255, .14);
  --scroll-hover: rgba(255, 255, 255, .24);
  --hover-filter: brightness(1.12);

  --shadow-1: 0 2px 4px 0 rgba(0, 0, 0, .3);
  --shadow-2: 0 4px 14px 0 rgba(0, 0, 0, .3);
  --shadow-3: 0 0 1px 0 rgba(255, 255, 255, .16), 0 12px 32px 0 rgba(0, 0, 0, .45);
  --shadow-composer: 0 0 0 .5px rgba(255, 255, 255, .02), 0 12px 40px -6px rgba(0, 0, 0, .5);

  --tok-keyword: #c678dd;
  --tok-string: #98c379;
  --tok-number: #d19a66;
  --tok-comment: #7f848e;
  --tok-function: #61afef;
  --tok-type: #e5c07b;
  --tok-tag: #e06c75;
}

/* Accent palettes. A rule also matches a swatch carrying the same data-accent, so it previews its colour. */
[data-accent="violet"] { --accent: #7c3aed; }
[data-accent="teal"] { --accent: #0d9488; }
[data-accent="green"] { --accent: #16a34a; }
[data-accent="amber"] { --accent: #ea580c; }
[data-accent="rose"] { --accent: #e0457b; }
[data-accent="graphite"] { --accent: #414855; }
[data-accent="indigo"] { --accent: #3964fe; }
:is([data-theme="dark"][data-accent], [data-theme="dark"] [data-accent])[data-accent="indigo"] { --accent: #5686fe; }
:is([data-theme="dark"][data-accent], [data-theme="dark"] [data-accent])[data-accent="violet"] { --accent: #9a6bff; }
:is([data-theme="dark"][data-accent], [data-theme="dark"] [data-accent])[data-accent="teal"] { --accent: #20b2a3; }
:is([data-theme="dark"][data-accent], [data-theme="dark"] [data-accent])[data-accent="green"] { --accent: #2fb563; }
:is([data-theme="dark"][data-accent], [data-theme="dark"] [data-accent])[data-accent="amber"] { --accent: #f07a2f; }
:is([data-theme="dark"][data-accent], [data-theme="dark"] [data-accent])[data-accent="rose"] { --accent: #ec5f92; }
:is([data-theme="dark"][data-accent], [data-theme="dark"] [data-accent])[data-accent="graphite"] { --accent: #737c8c; }

/* Base */
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; margin: 0; }
body {
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.6;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  -webkit-tap-highlight-color: transparent;
}
button, input, textarea, select { font: inherit; color: inherit; letter-spacing: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; }
a { color: var(--brand-text); }
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
::selection { background: color-mix(in srgb, var(--brand) 22%, transparent); }
svg { width: 20px; height: 20px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; pointer-events: none; }
.icons { position: absolute; width: 0; height: 0; overflow: hidden; }
.logo-mark { color: var(--brand); }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0; }
.muted { color: var(--text-3); }
/* Loading: a small spinner and a line of text; empty: a muted icon above the hint. */
.loading-line { display: flex; align-items: center; gap: 10px; margin: 8px 0; color: var(--text-3); font-size: 13px; line-height: 20px; animation: fade .3s var(--ease) .15s backwards; }
.loading-line + .btn, .notice[data-error] + .btn { margin-top: 12px; }
:is(.panel-empty, .history-empty)::before {
  content: ""; display: block; width: 28px; height: 28px; margin: 0 auto 8px; background: var(--text-4);
  -webkit-mask: var(--icon-inbox) center / contain no-repeat; mask: var(--icon-inbox) center / contain no-repeat;
}
.history-empty::before { width: 26px; height: 26px; -webkit-mask-image: var(--icon-chat); mask-image: var(--icon-chat); }
.notice { margin: 0; color: var(--text-3); font-size: 13px; line-height: 20px; overflow-wrap: anywhere; }
.notice:empty { display: none; }
/* Errors written into a status line read as a compact alert with an icon. */
:is(.notice, .auth-status, .composer-status, .appearance-feedback)[data-error]:not(:empty) {
  display: flex; align-items: flex-start; gap: 8px;
  padding: 9px 12px; border-radius: 12px; background: var(--danger-soft); color: var(--danger);
  font-size: 13px; line-height: 20px; text-align: left;
}
:is(.notice, .auth-status, .composer-status, .appearance-feedback)[data-error]:not(:empty)::before {
  content: ""; flex: none; width: 16px; height: 16px; margin-top: 2px; background: currentColor;
  -webkit-mask: var(--icon-alert) center / contain no-repeat; mask: var(--icon-alert) center / contain no-repeat;
}
* { scrollbar-width: thin; scrollbar-color: var(--scroll) transparent; }
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: var(--scroll); border-radius: 8px; border: 2px solid transparent; background-clip: content-box; }
::-webkit-scrollbar-thumb:hover { background: var(--scroll-hover); background-clip: content-box; }
::-webkit-scrollbar-track { background: transparent; }

/* Buttons */
.btn {
  position: relative;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 36px; padding: 0 16px;
  border: 1px solid transparent; border-radius: 999px;
  font-size: 14px; font-weight: 500; line-height: 1; white-space: nowrap; text-decoration: none;
  transition: background-color var(--dur) var(--ease), border-color var(--dur) var(--ease), color var(--dur) var(--ease), opacity var(--dur), transform .2s var(--ease-spring), box-shadow .25s var(--ease);
}
.btn svg { width: 16px; height: 16px; }
.btn-sm { height: 32px; padding: 0 12px; font-size: 13px; }
.btn-lg { height: 44px; padding: 0 20px; font-size: 15px; }
.btn-block { width: 100%; }
.btn-primary { background: var(--brand); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--brand-hover); box-shadow: 0 4px 14px -4px color-mix(in srgb, var(--brand) 60%, transparent); }
.btn-primary:disabled { background: var(--brand-dim); color: rgba(255, 255, 255, .9); }
.btn-secondary { background: var(--bg-raised); border-color: var(--line-3); color: var(--text); }
.btn-secondary:hover:not(:disabled) { background: var(--bg-nav-hover); }
.btn-secondary:disabled { color: var(--text-4); }
.btn-ghost { background: transparent; color: var(--text-2); }
.btn-ghost:hover:not(:disabled) { background: var(--bg-hover); color: var(--text); }
.btn-danger { background: var(--danger-solid); color: #fff; }
.btn-danger:hover:not(:disabled) { background: var(--danger-solid-hover); }
.btn-danger:disabled { opacity: .45; }
.btn:active:not(:disabled) { transform: scale(.98); }
/* A running action keeps the button's size and swaps its label for a spinner. */
.btn.is-loading { color: transparent !important; opacity: 1; cursor: progress; }
.btn.is-loading > * { visibility: hidden; }
.btn.is-loading::after {
  content: ""; position: absolute; inset: 0; margin: auto; width: 16px; height: 16px;
  border: 2px solid rgba(255, 255, 255, .4); border-top-color: #fff; border-radius: 50%; animation: spin .7s linear infinite;
}
.btn-secondary.is-loading::after, .btn-ghost.is-loading::after { border-color: var(--line-3); border-top-color: var(--text-2); }
.btn-danger-soft { background: var(--danger-soft); color: var(--danger); }
.btn-danger-soft:hover:not(:disabled) { background: var(--danger-soft-hover); }
.btn-danger-soft:disabled, .btn-ghost:disabled { opacity: .45; }
.link-button { padding: 0; border: 0; background: none; color: var(--text); font-size: inherit; text-decoration: underline; text-underline-offset: 3px; text-decoration-color: var(--line-4); }
.link-button:hover { text-decoration-color: currentColor; }

.icon-btn {
  position: relative;
  display: inline-grid; place-items: center; flex: none;
  width: 32px; height: 32px; padding: 0;
  border: 0; border-radius: 8px; background: transparent; color: var(--text-2);
  transition: background-color var(--dur) var(--ease), color var(--dur) var(--ease);
}
.icon-btn:hover:not(:disabled) { background: var(--bg-hover); color: var(--text); }
.icon-btn[aria-expanded="true"], .icon-btn[aria-pressed="true"] { background: var(--bg-active); color: var(--text); }
.icon-btn:disabled { color: var(--text-4); }
.icon-btn-sm { width: 26px; height: 26px; border-radius: 7px; }
.icon-btn-sm svg { width: 16px; height: 16px; }

/* Tooltips for icon controls on devices with a pointer. */
@media (hover: hover) and (pointer: fine) {
  [data-tip]::after {
    content: attr(data-tip);
    position: absolute; left: 50%; top: calc(100% + 6px); z-index: 70;
    max-width: 260px; width: max-content;
    padding: 6px 10px; border-radius: 8px;
    background: var(--tooltip); color: #fff;
    font-size: 12px; font-weight: 400; line-height: 18px; text-align: left; white-space: normal;
    box-shadow: var(--shadow-2);
    opacity: 0; visibility: hidden; transform: translate(-50%, -2px);
    transition: opacity .12s var(--ease), transform .12s var(--ease), visibility 0s .12s;
    pointer-events: none;
  }
  [data-tip]:hover::after {
    opacity: 1; visibility: visible; transform: translate(-50%, 0);
    transition: opacity .12s var(--ease) .45s, transform .12s var(--ease) .45s, visibility 0s .45s;
  }
  [data-tip][aria-expanded="true"]::after { display: none; }
  [data-tip-pos="top"]::after { top: auto; bottom: calc(100% + 6px); transform: translate(-50%, 2px); }
  [data-tip-align="start"]::after { left: 0; transform: translate(0, -2px); }
  [data-tip-align="start"]:hover::after { transform: none; }
  [data-tip-align="end"]::after { left: auto; right: 0; transform: translate(0, -2px); }
  [data-tip-align="end"]:hover::after { transform: none; }
  [data-tip-pos="top"][data-tip-align="end"]::after { transform: translate(0, 2px); }
}

/* Sign-in */
.auth { min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; background: var(--bg); }
.auth-main { flex: 1; display: grid; grid-template-columns: minmax(0, 1fr); place-items: center; padding: 48px 20px 24px; }
.auth-panel { width: min(100%, 360px); display: flex; flex-direction: column; }
.auth-logo { display: flex; align-items: center; justify-content: center; gap: 10px; margin-bottom: 28px; color: var(--brand); font-size: 30px; font-weight: 650; letter-spacing: -.035em; }
.auth-logo .logo-mark { width: 36px; height: 36px; }
.auth-title { margin: 0; text-align: center; font-size: 18px; font-weight: 600; line-height: 26px; }
.auth-description { margin: 6px 0 0; text-align: center; color: var(--text-3); font-size: 13px; line-height: 20px; }
.auth-stack { display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; margin-top: 24px; }
.auth-field {
  position: relative; display: flex; align-items: center;
  height: 48px; padding: 0 20px 0 16px;
  border: 1px solid var(--line-2); border-radius: 28px; background: var(--bg-field);
  transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}
.auth-field:focus-within { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
.auth-field input { flex: 1; min-width: 0; height: 100%; padding: 0; border: 0; outline: 0; background: transparent; font-size: 14px; }
.auth-field input::placeholder { color: var(--text-4); }
.auth-reveal { display: grid; place-items: center; width: 32px; height: 32px; margin-right: -10px; border: 0; border-radius: 50%; background: none; color: var(--text-3); }
.auth-reveal:hover { color: var(--text); background: var(--bg-hover); }
.auth-reveal svg { width: 18px; height: 18px; }
.auth-agreement { display: flex; align-items: center; flex-wrap: wrap; gap: 2px; color: var(--text-3); font-size: 12px; line-height: 20px; }
.auth-agreement input { width: 14px; height: 14px; margin: 0 6px 0 2px; accent-color: var(--brand); cursor: pointer; }
.auth-agreement label { cursor: pointer; }
/* Sign-up: an inline code button, field hints, and the switch between signing in and signing up. */
.auth-field:has(input[aria-invalid="true"]) { border-color: var(--danger); }
.auth-field:has(input[aria-invalid="true"]):focus-within { box-shadow: 0 0 0 3px var(--danger-soft-hover); }
.auth-code-send {
  flex: none; margin-right: -6px; padding: 0 0 0 12px; border: 0; border-left: 1px solid var(--line-2);
  background: none; color: var(--brand-text); font-size: 13px; line-height: 20px; white-space: nowrap;
}
.auth-code-send:disabled { color: var(--text-4); cursor: default; }
.auth-code-send:not(:disabled):hover { text-decoration: underline; text-underline-offset: 3px; }
.auth-hint { margin: -8px 0 0; padding: 0 16px; color: var(--text-3); font-size: 12px; line-height: 18px; overflow-wrap: anywhere; }
.auth-turnstile { display: flex; justify-content: center; min-height: 65px; }
.auth-turnstile[hidden] { display: none; }
.auth-turnstile-status { margin: -8px 0 0; text-align: center; color: var(--text-3); font-size: 12px; line-height: 18px; }
.auth-turnstile-status:empty { display: none; }
.auth-gate { display: grid; justify-items: center; gap: 12px; padding: 22px 20px 20px; border: 1px solid var(--line-2); border-radius: 16px; background: var(--bg-muted); }
.auth-gate-icon { display: grid; place-items: center; width: 44px; height: 44px; border-radius: 50%; background: var(--brand-soft); color: var(--brand); }
.auth-gate-icon svg { width: 22px; height: 22px; }
.auth-gate-account { max-width: 100%; margin: 0; padding: 3px 12px; border-radius: 999px; background: var(--bg-raised); color: var(--text-2); font-size: 13px; line-height: 20px; overflow-wrap: anywhere; }
.auth-gate-points { display: grid; gap: 8px; width: 100%; margin: 4px 0 0; padding: 0; list-style: none; color: var(--text-2); font-size: 13px; line-height: 20px; }
.auth-gate-points li { display: flex; gap: 10px; }
.auth-gate-points li::before { content: ""; flex: none; width: 6px; height: 6px; margin-top: 7px; border-radius: 50%; background: var(--success); }
.auth-switch { margin: 0; text-align: center; color: var(--text-3); font-size: 13px; line-height: 20px; }
.auth-switch .link-button { margin-left: 2px; color: var(--brand-text); font-weight: 500; text-decoration: none; }
.auth-switch .link-button:hover { text-decoration: underline; text-underline-offset: 3px; }
.auth-switch .link-button:disabled { color: var(--text-4); cursor: default; text-decoration: none; }
.auth-status { margin: 16px 0 0; text-align: center; color: var(--text-3); font-size: 13px; line-height: 20px; overflow-wrap: anywhere; }
.auth-status:empty { display: none; }
.auth-status[data-error]:not(:empty) { margin-top: 18px; animation: shake .32s var(--ease); }
#login-retry { margin-top: 12px; }
.auth-links { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 8px 20px; margin: 20px 0 0; font-size: 13px; }
.auth-links a { color: var(--brand-text); text-decoration: none; }
.auth-links a:hover { text-decoration: underline; text-underline-offset: 3px; }
.auth-links a.primary {
  flex: 1 1 100%; display: flex; align-items: center; justify-content: center; height: 44px;
  border-radius: 999px; background: var(--brand); color: #fff; font-size: 15px; font-weight: 500; text-decoration: none;
}
.auth-links a.primary:hover { background: var(--brand-hover); }
.auth-footer { padding: 16px 20px max(20px, env(safe-area-inset-bottom)); text-align: center; color: var(--text-4); font-size: 12px; }
.agreement-docs { max-height: min(52vh, 420px); overflow: auto; padding: 14px 16px; border-radius: 12px; background: var(--bg-muted); color: var(--text-2); font-size: 13px; line-height: 22px; white-space: pre-wrap; overflow-wrap: anywhere; }
.agreement-docs strong { display: block; margin-bottom: 4px; color: var(--text); font-size: 14px; }
.agreement-docs p { margin: 0 0 14px; }
.agreement-docs p:last-child { margin-bottom: 0; }

/* Workspace layout */
.workspace {
  container: workspace / size;
  position: relative; top: var(--composer-viewport-top, 0);
  height: 100vh; height: min(100dvh, var(--composer-viewport-height, 100dvh));
  padding-inline: env(safe-area-inset-left) env(safe-area-inset-right);
  display: grid; grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
  overflow: hidden;
  transition: grid-template-columns .22s var(--ease);
}
.workspace.sidebar-collapsed { grid-template-columns: 0 minmax(0, 1fr); }

.sidebar {
  position: relative; z-index: 5;
  display: flex; flex-direction: column;
  min-width: 0; min-height: 0; overflow: hidden; overflow: clip;
  background: var(--bg-sidebar); border-right: 1px solid var(--line-2);
}
.sidebar > * { flex: none; width: calc(var(--sidebar-w) - 1px); }
.workspace.sidebar-collapsed .sidebar { visibility: hidden; transition: visibility 0s .22s; }
.sidebar-head { display: flex; align-items: center; justify-content: space-between; height: 60px; padding: 0 10px 0 16px; }
.sidebar-brand { display: inline-flex; align-items: center; gap: 8px; color: var(--brand); font-size: 21px; font-weight: 650; letter-spacing: -.035em; text-decoration: none; border-radius: 8px; }
.sidebar-brand .logo-mark { width: 28px; height: 28px; }
.sidebar-head-actions { display: flex; gap: 2px; }
.new-chat {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  height: 40px; margin: 6px 12px 10px; width: calc(var(--sidebar-w) - 25px);
  border: 1px solid var(--line-2); border-radius: 999px;
  background: var(--bg-raised); color: var(--text); box-shadow: var(--shadow-1);
  font-size: 14px; font-weight: 500;
  transition: background-color var(--dur) var(--ease);
}
.new-chat:hover { background: var(--bg-nav-hover); }
.new-chat svg { width: 18px; height: 18px; }
.history {
  flex: 1 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior: contain;
  padding: 0 8px 16px;
  -webkit-mask-image: linear-gradient(to bottom, #000 calc(100% - 28px), transparent);
  mask-image: linear-gradient(to bottom, #000 calc(100% - 28px), transparent);
}
.history-group + .history-group { margin-top: 14px; }
.history-label h3 { margin: 0; font: inherit; min-width: 0; }
#partner-add {
  display: inline-flex; align-items: center; gap: 6px; height: 40px; margin: 6px 4px 2px; padding: 0 16px;
  border: 1px solid var(--line-2); border-radius: 999px; background: var(--bg-raised); color: var(--text);
  box-shadow: var(--shadow-1); font-size: 14px; font-weight: 500;
}
#partner-add:hover { background: var(--bg-nav-hover); }
#partner-add svg { width: 18px; height: 18px; }
.partner-group .avatar-mark { flex: none; --message-avatar-size: 36px; }
.history-label {
  position: sticky; top: 0; z-index: 2;
  display: flex; align-items: center; justify-content: space-between; gap: 4px;
  height: 40px; margin: 0; padding: 0 4px 0 12px;
  background: var(--bg-sidebar); color: var(--text-3);
  font-size: 13px; font-weight: 500;
}
.chat-group .history-label { padding-left: 0; }
.history-fold {
  display: inline-flex; align-items: center; gap: 8px; max-width: 100%; height: 34px; padding: 0 8px 0 12px;
  border: 0; border-radius: 10px; background: none; color: var(--text-2); font: inherit;
}
.history-fold:hover { background: var(--bg-nav-hover); }
.history-fold svg { flex: none; width: 18px; height: 18px; color: var(--text-3); }
.history-fold .fold-icon { width: 16px; height: 16px; margin-left: -2px; color: var(--text-4); transition: transform var(--dur) var(--ease); }
.history-fold[aria-expanded="false"] .fold-icon { transform: rotate(-90deg); }
.history-count { color: var(--text-4); font-size: 12px; font-weight: 400; }
.history-count:empty { display: none; }
.history-actions { display: flex; gap: 2px; flex: none; }
.history-list { padding-top: 2px; }
.history-empty { margin: 32px 12px; color: var(--text-3); font-size: 13px; line-height: 20px; text-align: center; }
.history-retry { display: block; margin: 12px auto; padding: 6px 10px; border: 0; border-radius: 8px; background: none; color: var(--brand-text); font-size: 13px; }
.history-retry:hover { background: var(--bg-hover); }
.conversation { position: relative; display: flex; align-items: center; min-height: 40px; margin: 1px 0; border-radius: 12px; transition: background-color .18s var(--ease); }
.conversation:hover { background: var(--bg-nav-hover); }
.conversation.active { background: var(--bg-nav-selected); }
.conversation-select {
  flex: 1; min-width: 0; align-self: stretch;
  display: flex; align-items: center; gap: 8px;
  padding: 0 12px; border: 0; border-radius: 12px; background: none;
  color: var(--text-2); font-size: 14px; text-align: left;
}
.conversation.active .conversation-select { color: var(--text); font-weight: 500; }
.conversation-title { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.conversation-time { flex: none; margin-left: auto; color: var(--text-4); font-size: 12px; font-weight: 400; white-space: nowrap; }
.conversation:hover .conversation-select, .conversation:focus-within .conversation-select, .conversation.menu-open .conversation-select { padding-right: 40px; }
.conversation:is(:hover, :focus-within, .menu-open) .conversation-select > .conversation-time,
.conversation:is(:hover, :focus-within, .menu-open) .partner-line > .conversation-time,
.conversation.running .conversation-time { display: none; }
.partner-group .conversation { min-height: 56px; border-radius: 14px; }
.partner-group .conversation-select { gap: 12px; padding: 8px 12px 8px 10px; border-radius: 14px; }
.partner-text { flex: 1; min-width: 0; display: grid; gap: 1px; }
.partner-line { display: flex; align-items: baseline; gap: 6px; min-width: 0; }
.partner-line .conversation-title { color: var(--text); font-weight: 500; line-height: 21px; }
.partner-about { overflow: hidden; color: var(--text-3); font-size: 12px; line-height: 17px; text-overflow: ellipsis; white-space: nowrap; }
.conversation-menu { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); opacity: 0; }
.conversation:hover .conversation-menu, .conversation:focus-within .conversation-menu, .conversation-menu[aria-expanded="true"] { opacity: 1; }
.conversation.running .conversation-select::after {
  content: ""; flex: none; width: 7px; height: 7px; margin-left: auto; border-radius: 50%;
  background: var(--brand); animation: pulse 1.2s var(--ease) infinite;
}
.conversation-check { display: none; flex: none; width: 15px; height: 15px; margin: 0; accent-color: var(--brand); cursor: pointer; }
.history.is-batch .conversation-check { display: block; }
.history.is-batch .conversation-select { cursor: pointer; }
.history.is-batch .conversation-menu { display: none; }
.history.is-batch .conversation:hover .conversation-select { padding-right: 12px; }
.conversation.checked { background: var(--bg-nav-selected); }
.conversation-rename {
  flex: 1; min-width: 0; height: 32px; margin: 0 4px; padding: 0 8px;
  border: 1px solid var(--brand); border-radius: 8px; outline: 0;
  background: var(--bg-raised); color: var(--text); font-size: 14px;
  box-shadow: 0 0 0 3px var(--brand-soft);
}
.batch-bar { display: flex; align-items: center; gap: 8px; padding: 10px 12px; border-top: 1px solid var(--line-2); background: var(--bg-sidebar); }
.batch-all { display: flex; align-items: center; gap: 6px; flex: 1; min-width: 0; color: var(--text-2); font-size: 13px; cursor: pointer; }
.batch-all input { width: 15px; height: 15px; margin: 0; accent-color: var(--brand); }
.skeleton { display: grid; gap: 10px; padding: 12px; }
.skeleton span { display: block; height: 14px; border-radius: 7px; background: var(--bg-skeleton); animation: shimmer 1.4s ease-in-out infinite; }
.skeleton span:nth-child(2n) { width: 72%; }
.skeleton span:nth-child(3n) { width: 86%; }

.sidebar > .account {
  position: relative; flex: none; display: flex; align-items: center; gap: 10px;
  width: calc(var(--sidebar-w) - 25px); margin: 9px 12px 12px; padding: 8px;
  border: 0; border-radius: 16px; background: none; color: inherit; text-align: left;
  transition: background-color var(--dur) var(--ease);
}
.sidebar > .account::before { content: ""; position: absolute; left: 4px; right: 4px; top: -9px; height: 1px; background: var(--line-2); pointer-events: none; }
.sidebar > .account:hover { background: var(--bg-nav-hover); }
.sidebar > .account:active { background: var(--bg-nav-active); }
.avatar {
  width: 32px; height: 32px; flex: none; display: grid; place-items: center;
  border-radius: 50%; background: var(--brand-soft); color: var(--brand-text);
  font-size: 14px; font-weight: 600; overflow: hidden;
}
.avatar img, .avatar-mark img { display: block; width: 100%; height: 100%; object-fit: cover; }
.account-identity { flex: 1; min-width: 0; display: grid; }
.account-identity > * { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#account-name { color: var(--text); font-size: 14px; font-weight: 600; line-height: 20px; }
#account-plan { color: var(--text-3); font-size: 12px; line-height: 16px; }
#account-plan:empty { display: none; }
.account-more { flex: none; width: 20px; height: 20px; color: var(--text-3); }

/* Menus */
.menu {
  display: grid; gap: 2px; min-width: 188px; padding: 6px;
  border: 1px solid var(--line-1); border-radius: 14px;
  background: var(--bg-menu); box-shadow: var(--shadow-3);
}
.menu-floating {
  position: fixed; z-index: 80; max-width: calc(100vw - 16px); max-height: calc(100dvh - 16px);
  overflow-y: auto; overscroll-behavior: contain; animation: menu-in .22s var(--ease-out);
}
.menu-item { transition: background-color .14s var(--ease); }
.menu-item {
  display: flex; align-items: center; gap: 10px; width: 100%; min-height: 38px;
  padding: 8px 10px; border: 0; border-radius: 10px; background: none;
  color: var(--text); font-size: 14px; line-height: 20px; text-align: left; text-decoration: none; white-space: nowrap;
}
.menu-item > svg { width: 18px; height: 18px; color: var(--text-2); }
.menu-item:hover, .menu-item:focus-visible { background: var(--bg-nav-hover); outline: none; }
.menu-item[aria-disabled="true"] { color: var(--text-4); cursor: default; }
.menu-item[aria-disabled="true"]:hover { background: none; }
.menu-item[aria-disabled="true"]:focus-visible { background: var(--bg-nav-hover); }
.menu-item[aria-disabled="true"] > svg { color: var(--text-4); }
.menu-item.danger, .menu-item.danger > svg { color: var(--danger); }
.menu-item.danger:hover, .menu-item.danger:focus-visible { background: var(--danger-soft); }
.menu-floating .menu-item { white-space: normal; overflow-wrap: anywhere; }
.menu-text { display: grid; gap: 1px; min-width: 0; }
.menu-desc { color: var(--text-3); font-size: 12px; line-height: 18px; white-space: normal; }
.menu-item[aria-disabled="true"] .menu-desc { color: var(--text-4); }
.menu-badge { margin-left: auto; padding: 0 6px; border-radius: 6px; background: var(--bg-muted); color: var(--text-3); font-size: 11px; line-height: 18px; white-space: nowrap; }
.menu-check { margin-left: auto; width: 16px; height: 16px; color: var(--brand-text) !important; visibility: hidden; }
.menu-item[aria-checked="true"] .menu-check { visibility: visible; }
.menu-item-rich { align-items: flex-start; }
.menu-item-rich > svg { margin-top: 1px; }
.menu-title { padding: 6px 10px 4px; color: var(--text-3); font-size: 12px; }
.menu-sep { height: 1px; margin: 4px 6px; background: var(--line-2); }

/* Phone action sheets (see openMenu in ui.js). */
.menu-scrim { position: fixed; inset: 0; z-index: 80; background: var(--scrim); animation: fade .3s var(--ease); }
.menu-scrim.is-leaving { animation: fade-out .26s var(--ease) forwards; }
.menu.menu-sheet {
  left: 8px; right: 8px; top: auto; bottom: max(8px, env(safe-area-inset-bottom)); z-index: 81;
  min-width: 0; max-width: none; max-height: min(72dvh, 560px); overflow-y: auto; overscroll-behavior: contain;
  padding: 6px 8px 8px; border-radius: 24px; animation: sheet-up .42s var(--ease-drawer);
}
.menu-sheet::before { content: ""; justify-self: center; width: 36px; height: 5px; margin: 2px 0 6px; border-radius: 3px; background: var(--line-3); }
.menu-sheet .menu-item { min-height: 52px; padding: 12px 14px; border-radius: 16px; font-size: 16px; }
.menu-sheet .menu-item > svg { width: 22px; height: 22px; }
.menu-sheet .menu-item:active { background: var(--bg-nav-active); }
.menu-sheet .menu-title { padding: 8px 14px 4px; font-size: 13px; }
.menu-sheet.is-leaving { animation: sheet-down .26s var(--ease) forwards; pointer-events: none; }

/* Main column */
.chat {
  position: relative; min-width: 0; min-height: 0;
  display: grid; grid-template-rows: var(--topbar-h) minmax(0, 1fr) auto; grid-template-columns: minmax(0, 1fr);
  background: var(--bg);
}
.chat-wallpaper { position: absolute; inset: var(--topbar-h) 0 0; overflow: hidden; pointer-events: none; }
.chat-wallpaper img, .appearance-preview-background {
  position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; opacity: var(--wallpaper-opacity);
}
.chat-wallpaper:not([hidden]) img { animation: fade-from-clear .6s var(--ease); }
.chat.is-billing .chat-wallpaper { display: none; }
.topbar {
  grid-row: 1; position: relative; z-index: 4;
  display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, auto) minmax(0, 1fr); align-items: center; gap: 8px;
  padding: 0 14px;
  background: var(--bg);
}
.topbar::after { content: ""; position: absolute; left: 0; right: 0; top: 100%; height: 16px; background: linear-gradient(var(--bg), transparent); pointer-events: none; }
.topbar-start { display: flex; align-items: center; gap: 10px; min-width: 0; }
.topbar-logo { display: grid; place-items: center; width: 32px; height: 32px; border-radius: 8px; }
.topbar-logo .logo-mark { width: 28px; height: 28px; }
.tool-pill {
  display: inline-flex; align-items: center; gap: 2px; padding: 3px;
  border: 1px solid var(--line-2); border-radius: 999px;
  background: var(--bg-raised); box-shadow: var(--shadow-1);
}
.tool-pill .icon-btn { width: 30px; height: 30px; border-radius: 50%; }
.tool-pill .icon-btn svg { width: 18px; height: 18px; }
.workspace:not(.sidebar-collapsed) .topbar-start > * { display: none; }
.mobile-icon, #mobile-new-chat { display: none; }
.topbar-title {
  display: flex; justify-content: center; margin: 0; min-width: 0; max-width: min(56vw, 640px);
  color: var(--text); font-size: 16px; font-weight: 600; line-height: 22px; text-align: center;
  outline: none;
}
.title-button {
  display: inline-flex; align-items: center; gap: 6px; min-width: 0; max-width: 100%; height: 40px; padding: 0 10px;
  border: 0; border-radius: 12px; background: none; color: inherit; font: inherit;
}
.title-button:not(:disabled):hover, .title-button[aria-expanded="true"] { background: var(--bg-hover); }
.title-button:disabled { cursor: default; }
.title-text { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.title-chevron { flex: none; width: 16px; height: 16px; color: var(--text-3); }
.title-button:disabled .title-chevron { display: none; }
.title-avatar { flex: none; display: grid; }
.title-avatar .avatar-mark { --message-avatar-size: 28px; font-size: 12px; }
.topbar-end { grid-column: 3; display: flex; align-items: center; justify-content: flex-end; gap: 2px; }
.chat.is-empty .topbar-title { visibility: hidden; }

.chat-scroll { grid-row: 2; z-index: 1; min-height: 0; overflow-y: auto; overscroll-behavior-y: contain; scroll-padding-bottom: 24px; }
.welcome { display: flex; flex-direction: column; align-items: center; justify-content: flex-end; gap: 8px; min-height: 100%; padding: 24px 20px 28px; text-align: center; }
.welcome-copy { display: grid; justify-items: center; gap: 8px; }
.welcome-title { display: flex; align-items: center; justify-content: center; gap: 12px; margin: 0; font-size: 24px; font-weight: 600; line-height: 32px; letter-spacing: -.01em; }
.welcome-title .logo-mark { width: 36px; height: 36px; }
.welcome-sub { margin: 0; color: var(--text-3); font-size: 14px; }
.chat.is-empty { grid-template-rows: var(--topbar-h) minmax(0, 1fr) auto minmax(0, 1.15fr); }
.chat.is-empty .chat-footer { padding-bottom: 0; }
.chat.is-empty .composer-note { visibility: hidden; }
.transcript {
  --message-avatar-size: 32px;
  --message-avatar-gap: 14px;
  width: min(100%, calc(var(--column) + 2 * var(--gutter)));
  margin: 0 auto; padding: 12px var(--gutter) 40px;
  display: flex; flex-direction: column; gap: 32px;
}
.transcript:empty { display: none; }

/* Messages */
.message { position: relative; min-width: 0; }
.message.user, .message.assistant { display: grid; align-items: start; column-gap: var(--message-avatar-gap); }
.message.user { grid-template-columns: minmax(0, 1fr) var(--message-avatar-size); }
.user-message-body { position: relative; min-width: 0; display: flex; flex-direction: column; align-items: flex-end; }
.bubble {
  max-width: min(85%, 600px); padding: 9px 18px;
  border-radius: 20px; background: var(--bg-bubble); color: var(--text);
  font-size: 16px; line-height: 28px; white-space: pre-wrap; overflow-wrap: anywhere;
}
.message.is-pending .bubble { opacity: .75; }
.message.assistant { grid-template-columns: var(--message-avatar-size) minmax(0, 1fr); }
.avatar-mark {
  width: var(--message-avatar-size, 32px); height: var(--message-avatar-size, 32px); display: grid; place-items: center;
  border: 1px solid var(--line-2); border-radius: 50%; background: var(--bg); color: var(--brand);
  font-size: 14px; font-weight: 600; overflow: hidden;
}
[data-chat-avatar="userAvatar"].avatar-mark { background: var(--brand-soft); color: var(--brand-text); }
.avatar-mark svg { width: 62.5%; height: 62.5%; }
.message-body { min-width: 0; padding-top: 2px; }
.chat.has-wallpaper :is(.message.assistant .message-body, .welcome-copy) { position: relative; isolation: isolate; }
.chat.has-wallpaper :is(.message.assistant .message-body, .welcome-copy)::before {
  content: ""; position: absolute; inset: -8px -10px; z-index: -1; border-radius: 12px; background: var(--bg); pointer-events: none;
}
.chat.has-wallpaper .welcome-sub { color: var(--text-2); }
.message-actions { display: flex; align-items: center; gap: 2px; margin-top: 10px; opacity: 0; transition: opacity .15s var(--ease); }
.message.user .message-actions { position: absolute; top: 100%; right: 0; margin-top: 2px; }
.message:hover .message-actions, .message:focus-within .message-actions, .message.is-last .message-actions { opacity: 1; }
.message.is-streaming .message-actions, .message.is-pending .message-actions, .message.editing .message-actions { display: none; }
.msg-action { position: relative; display: grid; place-items: center; width: 30px; height: 30px; padding: 0; border: 0; border-radius: 8px; background: none; color: var(--text-3); }
.msg-action:hover { background: var(--bg-hover); color: var(--text); }
.msg-action svg { width: 18px; height: 18px; }
.msg-action.is-done { color: var(--success); }
.greeting-hint { margin: 8px 0 0; color: var(--text-3); font-size: 12px; line-height: 18px; }
.message.is-greeting-preview:not(:has(.greeting-switch:not([hidden]))) .greeting-hint { display: none; }

.trace-chip {
  display: inline-flex; align-items: center; gap: 6px; max-width: 100%;
  height: 32px; padding: 0 12px; border: 0; border-radius: 10px;
  background: var(--bg-muted); color: var(--text-2);
  font-size: 12px; font-weight: 500; line-height: 1; white-space: nowrap;
  transition: background-color var(--dur) var(--ease);
}
button.trace-chip:hover:not(:disabled) { background: var(--bg-nav-active); }
.trace-chip:disabled { cursor: default; }
.trace-chip > svg { width: 15px; height: 15px; }
.trace-chip .chevron { width: 14px; height: 14px; transition: transform var(--dur) var(--ease); }
.agent-trace { display: flex; flex-wrap: wrap; align-items: flex-start; gap: 6px; margin: 0 0 12px; min-width: 0; }
.agent-trace .trace-label { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.trace-step { cursor: default; }
.trace-step.is-error { color: var(--danger); }
.search-chip .chevron { transform: rotate(-90deg); }
.memory-chip .chevron { transform: rotate(-90deg); }
.memory-chip[aria-expanded="true"] .chevron { transform: none; }
.memory-list {
  flex-basis: 100%; display: grid; gap: 4px; margin: 2px 0 4px; padding: 2px 0 2px 26px;
  border-left: 2px solid var(--line-3); color: var(--text-3); font-size: 13px; line-height: 21px; overflow-wrap: anywhere;
}
.site-stack { display: inline-flex; margin-left: 2px; }
.site-stack .site-dot + .site-dot { margin-left: -5px; }
.site-dot {
  display: inline-grid; place-items: center; flex: none;
  width: 16px; height: 16px; border-radius: 50%; border: 1.5px solid var(--bg-muted);
  color: #fff; font-size: 9px; font-weight: 600; line-height: 1; text-transform: uppercase;
}
.hue-0 { background: #3964fe; } .hue-1 { background: #0ea5e9; } .hue-2 { background: #10b981; } .hue-3 { background: #f59e0b; }
.hue-4 { background: #ef4444; } .hue-5 { background: #8b5cf6; } .hue-6 { background: #ec4899; } .hue-7 { background: #64748b; }
.thinking { margin: 0 0 14px; }
.thinking .chevron { transform: rotate(-90deg); }
.thinking[data-open="true"] .chevron { transform: none; }
/* Opening and closing animate the height through a 0fr/1fr grid row; closed content leaves the a11y tree. */
.thinking-body {
  display: grid; grid-template-rows: 1fr; color: var(--text-3); font-size: 14px; line-height: 26px;
  transition: grid-template-rows .36s var(--ease), opacity .28s var(--ease), visibility 0s;
}
.thinking[data-open="false"] .thinking-body {
  grid-template-rows: 0fr; opacity: 0; visibility: hidden;
  transition: grid-template-rows .36s var(--ease), opacity .2s var(--ease), visibility 0s .36s;
}
.thinking-inner { min-height: 0; overflow: hidden; }
.reasoning-content { margin-top: 12px; padding: 0 0 0 13px; border-left: 2px solid var(--line-3); white-space: pre-wrap; overflow-wrap: anywhere; }
.reasoning-content.markdown { white-space: normal; font-size: 14px; line-height: 26px; color: var(--text-3); }
.reasoning-content.markdown :is(h2, h3, h4, h5, h6) { font-size: 15px; line-height: 26px; color: var(--text-2); }
.is-live .trace-label {
  background: linear-gradient(90deg, var(--text-3) 0%, var(--text-3) 40%, var(--text) 50%, var(--text-3) 60%, var(--text-3) 100%);
  background-size: 250% 100%;
  -webkit-background-clip: text; background-clip: text; color: transparent;
  animation: sheen 1.8s linear infinite;
}
.spinner { width: 14px; height: 14px; border-radius: 50%; border: 2px solid var(--line-3); border-top-color: var(--brand); animation: spin .8s linear infinite; flex: none; }
.message-content { min-width: 0; color: var(--text); font-size: 16px; line-height: 28px; overflow-wrap: anywhere; }
.message-content:empty { display: none; }
.markdown-plain { white-space: pre-wrap; overflow-wrap: anywhere; }
.typing { display: inline-flex; align-items: center; gap: 5px; height: 28px; }
.typing span { width: 7px; height: 7px; border-radius: 50%; background: var(--text-4); animation: typing 1.2s var(--ease) infinite; }
.typing span:nth-child(2) { animation-delay: .15s; }
.typing span:nth-child(3) { animation-delay: .3s; }
.message-status { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; margin: 10px 0 0; color: var(--text-3); font-size: 13px; line-height: 20px; }
.message-status:empty { display: none; }
.message-status[data-tone="error"] { padding: 10px 12px; border-radius: 12px; background: var(--danger-soft); color: var(--danger); }
.message-status[data-tone="error"] > svg { width: 16px; height: 16px; }
.message-status .btn { margin-left: auto; }
.message.is-streaming .message-content > :is(p, h2, h3, h4, h5, h6):last-child::after,
.message.is-streaming .message-content > :is(ul, ol):last-child > li:last-child::after {
  content: ""; display: inline-block; width: 9px; height: 9px; margin-left: 5px; border-radius: 50%;
  vertical-align: 1px; background: var(--brand); animation: pulse 1s var(--ease) infinite;
}
.edit-box { width: min(100%, 680px); padding: 12px; border: 1px solid var(--brand-line); border-radius: 18px; background: var(--bg-input); box-shadow: 0 0 0 3px var(--brand-soft); }
.edit-input { display: block; width: 100%; min-height: 56px; max-height: 40vh; padding: 2px 4px; border: 0; outline: 0; resize: none; background: transparent; font-size: 16px; line-height: 26px; }
.edit-actions { display: flex; justify-content: flex-end; align-items: center; gap: 8px; margin-top: 8px; }
.edit-hint { margin-right: auto; color: var(--text-3); font-size: 12px; }

/* Markdown */
.markdown { min-width: 0; white-space: normal; }
.markdown > :first-child { margin-top: 0; }
.markdown > :last-child { margin-bottom: 0; }
.markdown p { margin: 0 0 16px; }
.markdown :is(h2, h3, h4, h5, h6) { margin: 24px 0 12px; color: var(--text); }
.markdown h2 { font-size: 24px; font-weight: 700; line-height: 34px; }
.markdown h3 { font-size: 22px; font-weight: 700; line-height: 32px; }
.markdown h4 { font-size: 20px; font-weight: 700; line-height: 30px; }
.markdown :is(h5, h6) { font-size: 16px; font-weight: 600; line-height: 28px; }
.markdown strong { font-weight: 600; }
.markdown-prose, .markdown-action { font-style: normal; }
.markdown-action { color: var(--text-2); }
.markdown-dialogue { color: var(--text); }
.markdown :is(ul, ol) { margin: 0 0 16px; padding-left: 26px; }
.markdown li { margin: 4px 0; }
.markdown li > :is(ul, ol) { margin: 4px 0; }
.markdown li > p { margin: 4px 0; }
.markdown li::marker { color: var(--text-3); }
.markdown-task { list-style: none; }
.markdown-task > input, .markdown-task > p > input { margin: 0 .45em 0 -1.3em; accent-color: var(--brand); }
.markdown blockquote { margin: 0 0 16px; padding: 0 0 0 14px; border-left: 3px solid var(--line-3); color: var(--text-2); }
.markdown blockquote > :last-child { margin-bottom: 0; }
.markdown code { padding: 2px 6px; border-radius: 6px; background: var(--bg-inline-code); font-family: var(--font-mono); font-size: .875em; }
.markdown hr { height: 1px; margin: 24px 0; border: 0; background: var(--line-2); }
.markdown a { color: var(--brand-text); text-decoration: none; }
.markdown a:hover { text-decoration: underline; text-underline-offset: 3px; }
.markdown-table { max-width: 100%; margin: 0 0 16px; overflow-x: auto; border: 1px solid var(--line-2); border-radius: 12px; }
.markdown table { min-width: 100%; border-collapse: collapse; font-size: 15px; line-height: 25px; }
.markdown :is(th, td) { max-width: 36ch; padding: 8px 14px; text-align: start; vertical-align: top; border-bottom: 1px solid var(--line-2); }
.markdown :is(th, td):not(:last-child) { border-right: 1px solid var(--line-2); }
.markdown th { background: var(--bg-code); font-weight: 500; white-space: nowrap; }
.markdown tbody tr:last-child td { border-bottom: 0; }
.markdown .markdown-align-left { text-align: left; }
.markdown .markdown-align-center { text-align: center; }
.markdown .markdown-align-right { text-align: right; }
.markdown-image { color: var(--text-2); font-size: .94em; }
.code-block { margin: 0 0 16px; overflow: hidden; border: 1px solid var(--line-1); border-radius: 12px; background: var(--bg-code); }
.code-head { display: flex; align-items: center; justify-content: space-between; height: 38px; padding: 0 6px 0 14px; background: var(--bg-code-head); color: var(--text-3); font-size: 12px; }
.code-lang { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-family: var(--font-mono); text-transform: lowercase; }
.code-copy { display: inline-flex; flex: none; align-items: center; gap: 4px; height: 28px; padding: 0 8px; border: 0; border-radius: 8px; background: none; color: var(--text-3); font-size: 12px; }
.code-copy:hover { background: var(--bg-hover); color: var(--text); }
.code-copy svg { width: 14px; height: 14px; }
.markdown pre { max-width: 100%; margin: 0; padding: 14px 16px; overflow-x: auto; white-space: pre; tab-size: 4; font: 13px/22px var(--font-mono); }
.markdown pre code { padding: 0; border-radius: 0; background: none; font-size: inherit; }
.tok-k { color: var(--tok-keyword); }
.tok-s { color: var(--tok-string); }
.tok-n { color: var(--tok-number); }
.tok-c { color: var(--tok-comment); font-style: italic; }
.tok-f { color: var(--tok-function); }
.tok-t { color: var(--tok-type); }
.tok-g { color: var(--tok-tag); }
.citation {
  display: inline-grid; place-items: center; min-width: 18px; height: 18px; padding: 0 5px; margin: 0 2px;
  border-radius: 9px; background: var(--bg-inline-code); color: var(--text-2) !important;
  font-size: 11px; font-weight: 500; line-height: 1; vertical-align: 2px; text-decoration: none !important;
  transition: background-color .15s, color .15s;
}
.citation:hover, .citation:focus-visible { background: var(--brand); color: #fff !important; }

/* Composer */
.chat-footer { grid-row: 3; position: relative; z-index: 3; padding: 0 16px max(12px, env(safe-area-inset-bottom)); background: var(--bg); }
.chat-footer::before { content: ""; position: absolute; left: 0; right: 0; bottom: 100%; height: 24px; background: linear-gradient(transparent, var(--bg)); pointer-events: none; }
.chat.is-empty .chat-footer::before { display: none; }
/* Over a wallpaper the composer floats on the picture rather than on a band of page colour. */
.chat.has-wallpaper .chat-footer { background: transparent; }
.chat.has-wallpaper .chat-footer::before { display: none; }
.composer {
  container: composer / inline-size;
  position: relative; display: flex; flex-direction: column; gap: 8px;
  width: min(100%, var(--composer-w)); margin: 0 auto; padding: 12px 12px 10px;
  border: 1px solid var(--line-3); border-radius: 24px;
  background: var(--bg-input); box-shadow: var(--shadow-composer);
  transition: border-color var(--dur) var(--ease);
}
.composer { transition: border-color .25s var(--ease), box-shadow .3s var(--ease); }
.composer:focus-within { border-color: var(--brand-line); box-shadow: var(--shadow-composer), 0 0 0 4px var(--brand-glow); }
.composer.is-disabled { opacity: .7; }
#prompt {
  display: block; width: 100%; min-height: 48px; max-height: min(40vh, 336px);
  padding: 2px 6px; border: 0; outline: 0; resize: none; overflow-y: auto;
  background: transparent; color: var(--text); font-size: 16px; line-height: 24px;
}
#prompt::placeholder { color: var(--text-4); }
.composer-bar { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-width: 0; }
.composer-chips { display: flex; align-items: center; gap: 8px; min-width: 0; }
.composer-actions { display: flex; align-items: center; gap: 8px; flex: none; }
.composer-count { align-self: flex-end; padding-inline-end: 6px; color: var(--text-4); font-size: 12px; font-variant-numeric: tabular-nums; }
.composer-count[data-warn] { color: var(--warn); }
.chip {
  position: relative; display: inline-flex; align-items: center; gap: 5px;
  height: 32px; padding: 0 12px; border: 1px solid var(--line-3); border-radius: 999px;
  background: var(--bg-input); color: var(--text-2);
  font-size: 13px; font-weight: 500; line-height: 1; white-space: nowrap;
  transition: background-color var(--dur) var(--ease), border-color var(--dur) var(--ease), color var(--dur) var(--ease);
}
.chip svg { width: 16px; height: 16px; }
.chip:hover:not(:disabled) { background: var(--bg-nav-hover); }
.chip[aria-pressed="true"], .chip-split.is-active .chip { border-color: var(--brand-line); background: var(--brand-soft); color: var(--brand-text); }
.chip[aria-pressed="true"]:hover:not(:disabled), .chip-split.is-active .chip:hover:not(:disabled) { background: var(--brand-soft-hover); }
.chip:disabled, #search:not([aria-pressed]) { opacity: .5; }
.chip-level { padding: 2px 5px; border-radius: 6px; background: var(--brand); color: #fff; font-size: 10px; line-height: 1; }
.chip-split { display: inline-flex; }
.chip-split > .chip:first-child { border-radius: 999px 0 0 999px; padding-right: 8px; }
.chip-split > .chip-caret { width: 26px; padding: 0 6px 0 3px; border-left-width: 0; border-radius: 0 999px 999px 0; }
.chip-split > .chip-caret svg { width: 14px; height: 14px; }
.chip-split > .chip-caret::before { content: ""; position: absolute; left: 0; top: 7px; bottom: 7px; width: 1px; background: var(--line-3); }
.chip-split.is-active > .chip-caret::before { background: var(--brand-line); }
.composer-more { width: 34px; height: 34px; border: 1px solid var(--line-3); border-radius: 50%; color: var(--text-2); }
.composer-more svg { width: 20px; height: 20px; }
.send-btn {
  position: relative; display: grid; place-items: center; flex: none;
  width: 34px; height: 34px; padding: 0; border: 0; border-radius: 50%;
  background: var(--brand); color: #fff;
  transition: background-color var(--dur) var(--ease), transform .25s var(--ease-spring), box-shadow .25s var(--ease);
}
.send-btn:hover:not(:disabled) { background: var(--brand-hover); transform: translateY(-1px); box-shadow: 0 4px 12px -2px color-mix(in srgb, var(--brand) 50%, transparent); }
.send-btn:active:not(:disabled) { transform: scale(.92); box-shadow: none; }
.send-btn svg { transition: transform .3s var(--ease-spring); }
.send-btn:hover:not(:disabled):not(.is-stop) svg { transform: translateY(-1px); }
.send-btn:disabled { background: var(--brand-dim); }
.send-btn svg { width: 18px; height: 18px; stroke-width: 2.1; }
.send-btn.is-stop svg { width: 22px; height: 22px; }
.composer-status { width: min(100%, var(--composer-w)); margin: 8px auto 0; padding: 0 12px; color: var(--text-3); font-size: 13px; line-height: 20px; }
.composer-status:empty { display: none; }
.composer-status[data-error]:not(:empty) { padding: 9px 12px; animation: fade-in-up .2s var(--ease-out); }
.composer-note { margin: 8px 0 0; color: var(--text-4); font-size: 12px; line-height: 18px; text-align: center; }
.scroll-bottom {
  position: absolute; left: 50%; bottom: calc(100% + 12px); z-index: 4;
  display: grid; place-items: center; width: 34px; height: 34px; padding: 0;
  border: 1px solid var(--line-2); border-radius: 50%;
  background: var(--bg-raised); color: var(--text-2); box-shadow: var(--shadow-2);
  transform: translateX(-50%); animation: fade-up .16s var(--ease);
}
.scroll-bottom:hover { color: var(--text); background: var(--bg-nav-hover); }
.scroll-bottom svg { width: 18px; height: 18px; }

/* Search results panel */
.sources-panel {
  position: absolute; top: 0; right: 0; bottom: 0; z-index: 12;
  display: flex; flex-direction: column; width: min(400px, 100%);
  border-left: 1px solid var(--line-2); background: var(--bg-raised); box-shadow: var(--shadow-3);
  animation: slide-left .2s var(--ease);
}
.sources-head { display: flex; align-items: center; justify-content: space-between; height: var(--topbar-h); padding: 0 12px 0 20px; }
.sources-head h2 { margin: 0; font-size: 16px; font-weight: 600; }
.sources-note { margin: 0; padding: 0 20px 10px; color: var(--text-3); font-size: 12px; }
.sources-list { display: grid; align-content: start; gap: 8px; flex: 1; min-height: 0; margin: 0; padding: 4px 12px 24px; overflow-y: auto; list-style: none; }
.source-card > a {
  display: grid; gap: 6px; padding: 12px 14px;
  border: 1px solid var(--line-2); border-radius: 14px;
  color: inherit; text-decoration: none;
  transition: background-color var(--dur) var(--ease), border-color var(--dur) var(--ease);
}
.source-card > a:hover { background: var(--bg-nav-hover); }
.source-card.is-highlight > a { border-color: var(--brand-line); background: var(--brand-soft); }
.source-meta { display: flex; align-items: center; gap: 6px; min-width: 0; color: var(--text-3); font-size: 12px; line-height: 18px; }
.source-meta .site-dot { border-color: transparent; }
.source-site { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.source-index { margin-left: auto; min-width: 20px; height: 18px; padding: 0 5px; display: grid; place-items: center; border-radius: 9px; background: var(--bg-inline-code); color: var(--text-2); font-size: 11px; font-weight: 500; }
.source-title { color: var(--text); font-size: 14px; font-weight: 500; line-height: 22px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.source-snippet { color: var(--text-3); font-size: 13px; line-height: 20px; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }

/* Dialogs: fade and lift in, and (where supported) fade out again before leaving the top layer. */
.dialog {
  width: min(420px, calc(100% - 32px)); max-height: calc(100dvh - 48px);
  padding: 0; border: 1px solid var(--line-1); border-radius: 20px;
  background: var(--bg-raised); color: var(--text); box-shadow: var(--shadow-3), 0 24px 64px -12px rgba(0, 0, 0, .18);
  opacity: 1; transform: none;
  transition: opacity .2s var(--ease-out), transform .24s var(--ease-out), overlay .2s allow-discrete, display .2s allow-discrete;
}
.dialog:not([open]) { opacity: 0; transform: translateY(6px) scale(.985); pointer-events: none; transition-duration: .14s; }
@starting-style { .dialog[open] { opacity: 0; transform: translateY(10px) scale(.97); } }
.dialog-md { width: min(560px, calc(100% - 32px)); }
.dialog::backdrop {
  background: var(--scrim); -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px);
  opacity: 1; transition: opacity .2s var(--ease), overlay .2s allow-discrete, display .2s allow-discrete;
}
.dialog:not([open])::backdrop { opacity: 0; }
@starting-style { .dialog[open]::backdrop { opacity: 0; } }
.dialog-form { display: grid; gap: 14px; padding: 24px; }
.dialog-head { display: flex; align-items: center; gap: 12px; min-width: 0; }
.dialog-icon {
  display: grid; place-items: center; flex: none; width: 40px; height: 40px; border-radius: 12px;
  background: var(--brand-soft); color: var(--brand-text);
}
.dialog-icon svg { width: 20px; height: 20px; }
.dialog[data-tone="danger"] .dialog-icon { background: var(--danger-soft); color: var(--danger); }
.dialog-title { margin: 0; min-width: 0; font-size: 18px; font-weight: 600; line-height: 26px; overflow-wrap: anywhere; }
.dialog-text { margin: 0; color: var(--text-2); font-size: 14px; line-height: 22px; overflow-wrap: anywhere; }
.dialog-head + .dialog-text { margin-top: -4px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 6px; }
.dialog-actions .btn { min-width: 80px; }
.field input {
  width: 100%; height: 42px; padding: 0 14px;
  border: 1px solid var(--line-3); border-radius: 12px; background: var(--bg-field);
  font-size: 15px; outline: 0; transition: border-color var(--dur), box-shadow var(--dur);
}
.field input:focus { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }

.search-dialog { width: min(640px, calc(100% - 32px)); margin-top: max(10vh, 24px); border-radius: 20px; overflow: hidden; }
.search-head { display: flex; align-items: center; gap: 10px; height: 58px; padding: 0 12px 0 18px; border-bottom: 1px solid var(--line-2); }
.search-head > svg { width: 20px; height: 20px; color: var(--text-3); }
.search-head input { flex: 1; min-width: 0; height: 100%; padding: 0; border: 0; outline: 0; background: transparent; font-size: 16px; }
.search-head input::placeholder { color: var(--text-4); }
.search-head input::-webkit-search-cancel-button { display: none; }
.search-results { max-height: min(60vh, 520px); overflow-y: auto; padding: 8px; }
.search-group-label { padding: 10px 12px 4px; color: var(--text-3); font-size: 12px; font-weight: 500; }
.search-item {
  display: flex; align-items: center; gap: 10px; width: 100%; min-height: 42px;
  padding: 0 12px; border: 0; border-radius: 10px; background: none;
  color: var(--text); font-size: 14px; text-align: left;
}
.search-item > svg { width: 18px; height: 18px; color: var(--text-3); }
.search-item[aria-selected="true"] { background: var(--bg-nav-hover); }
.search-item-title { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.search-item-title mark { background: none; color: var(--brand-text); font-weight: 600; }
.search-item-meta { flex: none; color: var(--text-4); font-size: 12px; }
.search-empty { padding: 40px 16px; color: var(--text-3); font-size: 14px; text-align: center; overflow-wrap: anywhere; }

.settings-dialog { width: min(880px, calc(100% - 32px)); height: min(640px, calc(100dvh - 48px)); border-radius: 24px; overflow: hidden; }
.settings { display: grid; grid-template-columns: 216px minmax(0, 1fr); grid-template-rows: minmax(0, 1fr); height: 100%; }
.settings-nav, .settings-body { overflow-y: auto; overscroll-behavior: contain; }
.settings-nav { padding: 24px 12px 24px 20px; background: var(--bg-sidebar); border-right: 1px solid var(--line-1); }
.settings-mode { width: 100%; margin-top: 16px; gap: 12px; border-bottom: 0; }
.settings-mode-icon { display: none; flex: none; width: 22px; height: 22px; color: var(--text); }
.settings-mode-text { flex: 1; min-width: 0; display: grid; gap: 2px; }
.settings-mode-desc { color: var(--text-3); font-size: 12px; line-height: 17px; }
.settings-profile-card, .settings-tab.settings-link, .settings-logout, .settings-tab-value { display: none; }
.settings-nav .dialog-title { margin: 6px 0 18px; font-size: 16px; }
.settings-tabs { display: grid; gap: 4px; }
.settings-group { display: grid; gap: 4px; }
.settings-group-label { margin: 14px 12px 4px; color: var(--text-4); font-size: 12px; line-height: 16px; }
.settings-group-label:first-child { margin-top: 0; }
.drawer-search, .settings-detail-head { display: none; }
.settings-tab {
  display: flex; align-items: center; gap: 10px; height: 40px; padding: 0 12px;
  border: 0; border-radius: 10px; background: none; color: var(--text); font-size: 14px; text-align: left; white-space: nowrap;
}
.settings-tab svg { width: 18px; height: 18px; color: var(--text-2); }
.settings-tab:hover { background: var(--bg-nav-hover); }
.settings-tab[aria-selected="true"] { background: var(--bg-nav-selected); font-weight: 500; }
.settings-tab[aria-selected="true"] svg { color: var(--brand-text); }
.settings-body { position: relative; min-width: 0; padding: 74px 32px 28px 28px; }
.settings-close { position: absolute; top: 20px; right: 20px; z-index: 2; }
.settings-panel { outline: none; }
.settings-label { margin: 0 0 12px; color: var(--text); font-size: 14px; font-weight: 500; }
.settings-label:not(:first-child) { margin-top: 24px; }
.theme-options { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin-bottom: 8px; }
.theme-option {
  position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
  height: 82px; border: 1px solid var(--line-3); border-radius: 12px; cursor: pointer;
  color: var(--text); font-size: 14px;
  transition: background-color var(--dur) var(--ease), border-color var(--dur) var(--ease);
}
.theme-option input { position: absolute; opacity: 0; pointer-events: none; }
.theme-option svg { width: 18px; height: 18px; }
.theme-option:hover { background: var(--bg-nav-hover); }
.theme-option:has(input:checked) { border-color: var(--brand-line); background: var(--brand-soft); color: var(--brand-text); box-shadow: 0 0 0 1px var(--brand-line); }
.theme-option:has(input:focus-visible) { outline: 2px solid var(--brand); outline-offset: 2px; }
.theme-option svg { transition: transform .35s var(--ease-spring); }
.theme-option:hover svg { transform: scale(1.15) rotate(-8deg); }
.accent-options { display: flex; flex-wrap: wrap; gap: 12px 10px; margin-bottom: 8px; }
.accent-option { position: relative; display: grid; justify-items: center; gap: 6px; width: 56px; cursor: pointer; color: var(--text-3); font-size: 12px; line-height: 16px; }
.accent-option input { position: absolute; opacity: 0; pointer-events: none; }
.accent-dot {
  display: grid; place-items: center; width: 34px; height: 34px; border-radius: 50%;
  background: linear-gradient(145deg, color-mix(in srgb, var(--accent) 88%, #fff), color-mix(in srgb, var(--accent) 88%, #000)); color: #fff;
  box-shadow: 0 0 0 2px var(--bg-raised), 0 0 0 2px transparent, 0 2px 6px -1px color-mix(in srgb, var(--accent) 45%, transparent);
  transition: transform .3s var(--ease-spring), box-shadow .25s var(--ease);
}
.accent-dot svg { width: 16px; height: 16px; stroke-width: 2.6; opacity: 0; transform: scale(.4); transition: opacity .2s var(--ease), transform .35s var(--ease-spring); }
.accent-option:hover .accent-dot { transform: translateY(-2px) scale(1.06); }
.accent-option:active .accent-dot { transform: scale(.92); }
.accent-option:has(input:checked) .accent-dot { box-shadow: 0 0 0 2px var(--bg-raised), 0 0 0 4px var(--accent), 0 4px 12px -2px color-mix(in srgb, var(--accent) 55%, transparent); }
.accent-option:has(input:checked) .accent-dot svg { opacity: 1; transform: none; }
.accent-option:has(input:checked) .accent-name { color: var(--text); font-weight: 500; }
.accent-option:has(input:focus-visible) .accent-dot { outline: 2px solid var(--accent); outline-offset: 5px; }
.settings-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; min-height: 60px; border-bottom: 1px solid var(--line-2); font-size: 14px; }
.settings-row:last-child { border-bottom: 0; }
.settings-row > label { cursor: default; }
/* Chat appearance: the preview is also the background picker; two portrait cards pick the avatars. */
.appearance-preview {
  position: relative; isolation: isolate; min-height: 148px; overflow: hidden;
  display: grid; align-content: center; gap: 10px; padding: 16px 14px 54px;
  border: 1px solid var(--line-2); border-radius: 18px; background: var(--bg-muted);
  outline: 2px dashed transparent; outline-offset: -4px;
  transition: box-shadow .25s var(--ease), outline-color .2s var(--ease);
}
.appearance-preview.is-draft { box-shadow: 0 0 0 2px var(--brand); }
.appearance-preview.is-drop { outline-color: var(--brand); }
.appearance-preview-background { z-index: -1; transition: opacity .3s var(--ease); }
.appearance-preview-line { display: flex; align-items: center; gap: 8px; }
.appearance-preview-line.is-user { justify-content: flex-end; }
.appearance-preview-line.is-user .avatar-mark { background: var(--brand-soft); color: var(--brand-text); }
.appearance-preview-bubble { padding: 5px 12px; border-radius: 14px; background: var(--bg); color: var(--text); font-size: 13px; }
.appearance-preview-line.is-user .appearance-preview-bubble { background: var(--bg-bubble); }
.appearance-preview.is-busy::after, .appearance-slot.is-busy .avatar-pick::after {
  content: ""; position: absolute; inset: 0; margin: auto; width: 22px; height: 22px;
  border: 2px solid var(--line-3); border-top-color: var(--brand); border-radius: 50%; animation: spin .7s linear infinite;
}
.background-tools { position: absolute; right: 10px; bottom: 10px; z-index: 1; display: flex; gap: 6px; }
:is(.background-pick, .background-tools .appearance-reset) {
  display: inline-flex; align-items: center; gap: 6px; height: 34px; padding: 0 14px;
  border: 1px solid var(--line-2); border-radius: 999px; color: var(--text); font-size: 13px; font-weight: 500;
  background: color-mix(in srgb, var(--bg-raised) 80%, transparent); -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px);
  box-shadow: var(--shadow-2); transition: transform .25s var(--ease-spring), background-color .2s var(--ease);
}
.background-pick svg { width: 16px; height: 16px; }
.background-tools .appearance-reset { color: var(--text-2); font-weight: 400; }
.background-pick:hover:not(:disabled) { transform: translateY(-1px); background: var(--bg-raised); }
.background-pick:active:not(:disabled) { transform: scale(.96); }
.background-pick:disabled { opacity: .6; }
.appearance-slot.is-background { display: flex; align-items: center; flex-wrap: wrap; gap: 8px 12px; padding-top: 10px; }
.appearance-slot.is-background .appearance-feedback { flex: 1 1 auto; }
.appearance-slot.is-background .appearance-actions { margin-left: auto; }
.appearance-slot.is-background:not(.is-draft):has(.appearance-feedback:empty) { display: none; }
.appearance-slot-name { color: var(--text-2); font-size: 13px; font-weight: 500; }
.appearance-reset { padding: 2px 0; border: 0; background: none; color: var(--text-3); font-size: 13px; transition: color .15s var(--ease); }
.appearance-reset:hover:not(:disabled) { color: var(--danger); }
.appearance-actions { display: flex; justify-content: flex-end; gap: 8px; animation: fade-in-up .22s var(--ease-out); }
.appearance-feedback { flex: 1 0 100%; margin: 0; color: var(--text-3); font-size: 13px; }
.appearance-feedback:empty { display: none; }
#appearance-settings > .appearance-feedback:not(:empty), #appearance-settings > button { margin-top: 8px; }
.appearance-avatars { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin-top: 14px; }
.appearance-slot.is-avatar {
  display: grid; grid-template-columns: minmax(0, 1fr); justify-items: center; align-content: start; gap: 8px; min-width: 0;
  padding: 18px 10px 14px; border: 1px solid var(--line-2); border-radius: 18px; background: var(--sheet-card); text-align: center;
  transition: border-color .2s var(--ease), background-color .2s var(--ease);
}
.appearance-slot.is-avatar.is-draft { border-color: var(--brand-line); background: var(--brand-soft); }
.appearance-slot.is-avatar .appearance-feedback { flex: none; font-size: 12px; line-height: 18px; }
.appearance-slot.is-avatar .appearance-actions { max-width: 100%; flex-wrap: wrap; justify-content: center; }
.avatar-pick { position: relative; padding: 0; border: 0; border-radius: 50%; background: none; }
.avatar-pick .avatar-mark {
  width: 64px; height: 64px; font-size: 24px;
  transition: transform .3s var(--ease-spring), box-shadow .2s var(--ease), opacity .2s var(--ease);
}
.appearance-avatars > :first-child .avatar-mark { background: var(--brand-soft); color: var(--brand-text); }
.avatar-pick:hover:not(:disabled) .avatar-mark { transform: scale(1.05); }
.avatar-pick:active:not(:disabled) .avatar-mark { transform: scale(.95); }
.avatar-pick.is-drop .avatar-mark, .is-draft .avatar-pick .avatar-mark { box-shadow: 0 0 0 3px var(--brand); }
.appearance-slot.is-busy .avatar-mark { opacity: .45; }
.pick-badge {
  position: absolute; right: -3px; bottom: -3px; display: grid; place-items: center; width: 26px; height: 26px;
  border: 2px solid var(--sheet-card); border-radius: 50%; background: var(--brand); color: #fff;
  transition: transform .3s var(--ease-spring);
}
.avatar-pick:hover:not(:disabled) .pick-badge { transform: scale(1.12); }
.pick-badge svg { width: 14px; height: 14px; stroke-width: 2; }
.settings-row-block { align-items: center; padding: 14px 0; }
.settings-row-block > div:first-child, .settings-row-text { min-width: 0; flex: 1; }
.settings-row-block strong { display: block; font-size: 14px; font-weight: 500; }
.settings-row-block p { margin: 4px 0 0; color: var(--text-3); font-size: 13px; line-height: 20px; }
:is(.memory-dialog, .context-dialog) { overflow-y: auto; overscroll-behavior: contain; }
.memory-context-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.memory-context-item { display: grid; gap: 6px; font-size: 13px; color: var(--text-2); min-width: 0; }
.memory-context-item .select-pill, .memory-context-item .select-pill select { width: 100%; }
.context-mode-cards { display: grid; gap: 8px; }
.context-mode-card {
  display: flex; align-items: flex-start; gap: 10px; padding: 10px 12px;
  border: 1px solid var(--line-2); border-radius: 12px; background: var(--bg-field);
  cursor: pointer; transition: border-color .18s var(--ease), background-color .18s var(--ease), box-shadow .18s var(--ease);
}
.context-mode-card:hover:not(:has(input:disabled)) { border-color: var(--line-3); background: var(--bg-nav-hover); }
.context-mode-card:has(input:checked) { border-color: var(--brand-line); background: var(--brand-soft); box-shadow: 0 0 0 1px var(--brand-line); }
.context-mode-card:has(input:focus-visible) { outline: 2px solid var(--brand); outline-offset: 2px; }
.context-mode-card:has(input:disabled) { opacity: .6; cursor: not-allowed; }
.context-mode-card input { margin: 3px 0 0; accent-color: var(--brand); flex: none; }
.context-mode-card > span { min-width: 0; }
.context-mode-card strong { display: block; font-size: 14px; font-weight: 500; color: var(--text); }
.context-mode-card small { display: block; margin-top: 2px; font-size: 12px; line-height: 18px; color: var(--text-3); overflow-wrap: anywhere; }
.context-advanced { border-top: 1px solid var(--line-2); padding-top: 10px; }
.context-advanced summary {
  cursor: pointer; list-style: none; font-size: 13px; font-weight: 500; color: var(--text-2);
  display: flex; align-items: center; gap: 6px; padding: 4px 2px; border-radius: 6px;
  transition: color .15s var(--ease);
}
.context-advanced summary:hover { color: var(--text); }
.context-advanced summary:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
.context-advanced summary::-webkit-details-marker { display: none; }
.context-advanced summary::before { content: "▸"; font-size: 11px; color: var(--text-3); transition: transform .18s var(--ease); }
.context-advanced[open] summary::before { transform: rotate(90deg); }
.context-advanced[open] .memory-context-grid { margin-top: 10px; }
.settings-context-advanced { margin-top: 6px; border-top: 0; padding-top: 4px; }
.context-dialog-actions { flex-wrap: wrap; align-items: center; }
.context-dialog-actions #context-reset { margin-right: auto; min-width: 0; padding-inline: 10px; }
@media (max-width: 520px) {
  .memory-context-grid { grid-template-columns: minmax(0, 1fr); }
  #settings-chat .settings-row, .settings-row-block { flex-wrap: wrap; gap: 10px 16px; padding: 12px 0; }
  .settings-row-block > div:first-child { flex: 1 1 180px; }
}
@media (max-width: 420px) {
  :is(.memory-dialog, .context-dialog) .dialog-form { padding: 20px; }
}
.settings-value { min-width: 0; color: var(--text-2); text-align: right; overflow-wrap: anywhere; }
.settings-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; justify-content: flex-end; }
.settings-profile { display: flex; align-items: center; gap: 14px; padding: 4px 0 18px; border-bottom: 1px solid var(--line-2); }
.settings-profile .avatar { width: 48px; height: 48px; font-size: 20px; }
.settings-profile > div { min-width: 0; overflow-wrap: anywhere; }
.settings-profile strong { display: block; font-size: 16px; font-weight: 600; }
.settings-profile span { color: var(--text-3); font-size: 13px; }
.select-pill { position: relative; display: inline-flex; align-items: center; flex: none; max-width: 100%; }
.select-pill select {
  appearance: none; -webkit-appearance: none;
  max-width: 100%; height: 36px; padding: 0 34px 0 14px; border: 0; border-radius: 999px;
  background: var(--bg-select); color: var(--text); font-size: 14px; cursor: pointer;
  overflow: hidden; text-overflow: ellipsis;
}
.select-pill svg { position: absolute; right: 12px; width: 16px; height: 16px; color: var(--text-2); }
kbd {
  display: inline-grid; place-items: center; min-width: 24px; height: 24px; padding: 0 6px;
  border: 1px solid var(--line-3); border-bottom-width: 2px; border-radius: 6px;
  background: var(--bg-raised); color: var(--text-2); font: 12px/1 var(--font-sans);
}
.disclaimer-card {
  display: grid; gap: 12px; padding: 20px; border: 1px solid var(--line-2); border-radius: 16px;
  background: var(--sheet-card); color: var(--text-2); font-size: 14px; line-height: 1.6;
}
.disclaimer-card h3 { margin: 0; color: var(--text); font-size: 16px; font-weight: 600; }
.disclaimer-card p { margin: 0; }

/* Toasts: an inverted card at the top centre. The region follows the topmost modal dialog (see ui.js). */
.toast-region {
  position: fixed; top: max(16px, env(safe-area-inset-top)); left: 50%; z-index: 100;
  display: grid; justify-items: center; gap: 8px; width: max-content; max-width: calc(100vw - 24px);
  margin: 0; padding: 0; transform: translateX(-50%); pointer-events: none;
}
.toast {
  display: inline-flex; align-items: flex-start; gap: 10px; max-width: min(480px, calc(100vw - 24px));
  padding: 10px 16px 10px 14px; border-radius: 14px; background: var(--toast); color: #fff;
  font-size: 14px; line-height: 20px; box-shadow: 0 10px 30px -6px rgba(0, 0, 0, .3), 0 0 0 1px rgba(255, 255, 255, .06) inset;
  pointer-events: auto; animation: toast-in .32s var(--ease-out);
}
.toast-text { min-width: 0; overflow-wrap: anywhere; }
.toast-icon { width: 18px; height: 18px; margin-top: 1px; stroke-width: 1.9; }
.toast[data-tone="info"] .toast-icon { color: #8fb1ff; }
.toast[data-tone="success"] .toast-icon { color: #4ed17e; }
.toast[data-tone="warn"] .toast-icon { color: #fbbf24; }
.toast[data-tone="error"] .toast-icon { color: #f87171; }
.toast-close {
  display: grid; place-items: center; flex: none; width: 22px; height: 22px; margin: -1px -6px -1px 2px; padding: 0;
  border: 0; border-radius: 6px; background: none; color: rgba(255, 255, 255, .6);
}
.toast-close:hover { background: rgba(255, 255, 255, .12); color: #fff; }
.toast-close svg { width: 14px; height: 14px; stroke-width: 2; }
.toast.is-leaving { animation: toast-out .18s var(--ease) forwards; }

/* Account, billing and usage */
.billing { grid-row: 2 / -1; min-height: 0; overflow-y: auto; overscroll-behavior-y: contain; }
.chat.is-billing .chat-scroll, .chat.is-billing .chat-footer, .chat.is-billing .topbar-title { display: none; }
.billing-inner { width: min(880px, calc(100% - 48px)); margin: 0 auto; padding: 4px 0 max(48px, env(safe-area-inset-bottom)); }
.billing-header { display: grid; gap: 6px; margin-bottom: 20px; }
.billing-back { justify-self: start; margin-left: -10px; }
.billing-header h1 { margin: 6px 0 0; font-size: 28px; font-weight: 650; line-height: 36px; letter-spacing: -.02em; outline: none; }
.billing-sub { margin: 0; color: var(--text-3); font-size: 14px; }
.segmented { display: inline-flex; flex-wrap: wrap; gap: 4px; margin-bottom: 20px; padding: 4px; border-radius: 999px; background: var(--bg-select); }
.segmented a { padding: 7px 16px; border-radius: 999px; color: var(--text-2); font-size: 14px; line-height: 18px; text-decoration: none; transition: background-color var(--dur), color var(--dur); }
.segmented a:hover { color: var(--text); }
/* Dark text-2 is already close to text, so unselected segments also get a background on hover. */
[data-theme="dark"] .segmented a:not([aria-current]):hover, [data-theme="dark"] .segmented button:not([aria-pressed="true"]):hover { background: var(--bg-hover); }
.segmented a[aria-current] { background: var(--bg-raised); color: var(--text); font-weight: 500; box-shadow: var(--shadow-1); }
.billing-inner > .notice:not(:empty) { margin: 0 0 14px; }
.billing-content { display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; }
.billing-skeleton { display: grid; gap: 16px; }
.skeleton-card { display: grid; align-content: start; gap: 12px; min-height: 120px; }
.skeleton-card span { display: block; height: 14px; border-radius: 7px; background: var(--bg-skeleton); animation: shimmer 1.4s ease-in-out infinite; }
.skeleton-card span:first-child { width: 30%; height: 18px; }
.skeleton-card span:nth-child(2) { width: 80%; }
.skeleton-card span:nth-child(3) { width: 55%; }
.skeleton-card.is-plan { min-height: 220px; }
.skeleton-card.is-chart { min-height: 200px; }
.billing-content > .btn { justify-self: start; }
.billing-card { padding: 20px 24px; border: 1px solid var(--line-2); border-radius: 18px; background: var(--bg-raised); }
.billing-card h2, .billing-catalog > h2 { margin: 0 0 12px; font-size: 16px; font-weight: 600; }
.billing-card p, .billing-catalog p { margin: 0; font-size: 14px; line-height: 22px; overflow-wrap: anywhere; }
.billing-settlement-note { margin: 0 0 14px !important; color: var(--text-3); font-size: 13px !important; }
.billing-current { display: grid; gap: 16px; background: linear-gradient(135deg, var(--brand-soft) 0%, var(--bg-raised) 75%); border-color: var(--brand-line); }
.billing-current-head { display: flex; align-items: flex-end; justify-content: space-between; flex-wrap: wrap; gap: 4px 16px; }
.billing-current-head > div { display: grid; gap: 2px; }
.billing-current-head h2 { margin: 0; color: var(--brand-text); font-size: 26px; font-weight: 650; line-height: 34px; }
.billing-current-head .muted { font-size: 13px; }
.quotas { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 220px), 1fr)); gap: 12px 24px; }
.quota { display: grid; gap: 6px; }
.quota-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; color: var(--text-2); font-size: 14px; }
.quota-head strong { color: var(--text); font-size: 20px; font-weight: 650; font-variant-numeric: tabular-nums; }
.quota-bar { height: 8px; overflow: hidden; border-radius: 999px; background: var(--bg-select); }
.quota-bar span { display: block; height: 100%; border-radius: inherit; background: var(--brand); transition: width var(--dur); }
.quota-bar.is-low span { background: var(--danger, #e5484d); }
.quota-note { color: var(--text-3); font-size: 12px; font-variant-numeric: tabular-nums; }
.heatmap { --gap: 3px; display: grid; gap: 10px; max-width: 560px; margin: 0; }
.heatmap-scroll { display: grid; gap: 6px; overflow-x: auto; padding-bottom: 2px; }
.heatmap-months, .heatmap-grid { display: grid; grid-template-columns: repeat(26, minmax(10px, 1fr)); column-gap: var(--gap); min-width: calc(26 * 10px + 25 * var(--gap)); }
.heatmap-months { color: var(--text-3); font-size: 11px; line-height: 14px; }
.heatmap-months span { grid-row: 1; white-space: nowrap; }
.heatmap-grid { grid-template-rows: repeat(7, auto); grid-auto-flow: column; row-gap: var(--gap); }
.heat { display: block; aspect-ratio: 1; border-radius: 3px; background: var(--bg-select); transition: box-shadow .12s var(--ease); }
.heatmap-grid button.heat { padding: 0; border: 0; }
.heatmap-grid .heat:hover { box-shadow: 0 0 0 1.5px var(--text-3); }
.heatmap-grid .heat[aria-pressed="true"] { box-shadow: inset 0 0 0 2px var(--text); }
.heatmap-grid .heat:focus-visible { outline: 2px solid var(--brand-text); outline-offset: -2px; }
.heatmap-scale .heat { width: 11px; }
.heat[data-level="1"] { background: color-mix(in srgb, var(--brand) 25%, var(--bg-select)); }
.heat[data-level="2"] { background: color-mix(in srgb, var(--brand) 50%, var(--bg-select)); }
.heat[data-level="3"] { background: color-mix(in srgb, var(--brand) 75%, var(--bg-select)); }
.heat[data-level="4"] { background: var(--brand); }
.heatmap-legend { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 8px; font-size: 12px; }
.heatmap-controls { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 8px; font-size: 12px; }
.heatmap-controls output { text-align: center; overflow-wrap: anywhere; }
.heatmap-scale { display: inline-flex; align-items: center; gap: 3px; }
.heatmap-scale .muted:first-child { margin-right: 3px; }
.heatmap-scale .muted:last-child { margin-left: 3px; }
.billing-payment { margin-top: 16px; }
.billing-payment .billing-total { margin-bottom: 14px; font-weight: 600; }
.billing-payment .billing-total:empty { display: none; }
.billing-payment .notice:not(:empty) { margin-top: 10px; }
.billing-payment-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }
.billing-order-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.billing-redeem { margin-top: 16px; }
.billing-redeem-form { display: flex; align-items: center; gap: 8px; }
.billing-redeem-form .btn { height: 42px; padding-inline: 20px; }
.billing-redeem-form input { flex: 1; min-width: 0; height: 42px; padding: 0 14px; border: 1px solid var(--line-3); border-radius: 12px; background: var(--bg-field); color: inherit; font: inherit; font-size: 15px; letter-spacing: 0.02em; outline: none; }
.billing-redeem-form input:focus { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
.billing-redeem .notice:not(:empty) { margin-top: 10px; }

/* 套餐: the current plan strip, selectable plan cards and one action, like Android's PlansPage. */
.plan-strip {
  display: grid; gap: 4px; padding: 14px 16px; border: 1px solid var(--line-2); border-radius: 20px;
  background: var(--bg-raised); color: var(--text); text-decoration: none;
  transition: background-color var(--dur) var(--ease);
}
.plan-strip:hover { background: var(--bg-nav-hover); }
.plan-strip-top { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.plan-strip-top strong { font-size: 16px; font-weight: 600; }
.plan-strip-link { display: inline-flex; align-items: center; gap: 2px; color: var(--text-2); font-size: 14px; font-weight: 500; }
.plan-strip-link::after {
  content: ""; width: 16px; height: 16px; background: var(--text-3);
  -webkit-mask: var(--icon-chevron) center / contain no-repeat; mask: var(--icon-chevron) center / contain no-repeat;
}
.plan-strip-detail { color: var(--text-3); font-size: 12px; line-height: 18px; }
.plan-strip-bar { display: block; height: 4px; margin-top: 6px; overflow: hidden; border-radius: 2px; background: var(--bg-muted); }
.plan-strip-bar > span { display: block; height: 100%; border-radius: inherit; background: var(--brand); }
.plan-strip-bar.is-low > span { background: var(--danger); }
.billing-card.billing-choose { margin-top: 20px; padding: 0; border: 0; background: none; box-shadow: none; }
.billing-choose > h2 { margin: 0 0 10px 4px; }
.plan-options { display: grid; gap: 10px; }
.plan-option {
  display: flex; align-items: center; gap: 12px; width: 100%; padding: 14px 16px;
  border: 1px solid var(--line-2); border-radius: 20px; background: var(--bg-raised); color: var(--text); text-align: left;
  transition: background-color var(--dur) var(--ease), border-color var(--dur) var(--ease);
}
.plan-option:hover { background: var(--bg-nav-hover); }
.plan-option[aria-checked="true"] { border-color: var(--brand); background: var(--brand-soft); box-shadow: inset 0 0 0 .5px var(--brand); }
.plan-option-dot { flex: none; width: 18px; height: 18px; border: 1.5px solid var(--line-4); border-radius: 50%; }
.plan-option[aria-checked="true"] .plan-option-dot { border: 5px solid var(--brand); }
.plan-option-text { flex: 1; min-width: 0; display: grid; gap: 2px; }
.plan-option-head { display: flex; align-items: center; gap: 8px; }
.plan-option-head strong { font-size: 16px; font-weight: 600; line-height: 24px; }
.plan-option-sub { color: var(--text-3); font-size: 13px; line-height: 19px; }
.plan-option-price { flex: none; display: flex; align-items: baseline; gap: 2px; }
.plan-option-price strong { font-size: 20px; font-weight: 600; font-variant-numeric: tabular-nums; }
.plan-option-price span { color: var(--text-3); font-size: 12px; }
.billing-tag { padding: 1px 6px; border-radius: 6px; background: var(--bg-muted); color: var(--text-2); font-size: 11px; font-weight: 500; line-height: 17px; }
.billing-tag.is-brand { background: var(--brand); color: #fff; }
.plan-perks { margin-top: 14px; padding: 14px 16px; border-radius: 16px; background: var(--bg-field); }
.plan-perks h3 { margin: 0 0 6px; font-size: 14px; font-weight: 600; }
.plan-perks ul { display: grid; gap: 4px; margin: 0; padding: 0; list-style: none; color: var(--text-2); font-size: 13px; line-height: 20px; }
.plan-perks li { display: flex; gap: 8px; }
.plan-perks li::before {
  content: ""; flex: none; width: 16px; height: 20px; background: var(--brand);
  -webkit-mask: var(--icon-check) center / 14px no-repeat; mask: var(--icon-check) center / 14px no-repeat;
}
.plan-action {
  position: sticky; bottom: 0; z-index: 2; display: grid; gap: 6px; margin: 0 -4px; padding: 12px 4px max(12px, env(safe-area-inset-bottom));
  background: linear-gradient(transparent, var(--bg) 18px);
}
.plan-buy { width: 100%; min-height: 48px; font-size: 15px; }
.plan-action-note { margin: 0; color: var(--text-3); font-size: 12px; line-height: 18px; text-align: center; }
.billing-card-sub { margin: -6px 0 12px; color: var(--text-3); font-size: 13px; }

/* Animations */
/* Attachments */
.attachments { display: flex; gap: 8px; overflow-x: auto; overscroll-behavior-x: contain; padding: 7px; }
.attachment {
  position: relative; display: inline-flex; align-items: center; gap: 10px; flex: none;
  width: 232px; max-width: 100%; height: 56px; padding: 8px 12px 8px 8px;
  border: 1px solid var(--line-2); border-radius: 14px; background: var(--bg-raised);
  transition: background-color var(--dur) var(--ease), border-color var(--dur) var(--ease);
}
.attachment-icon { display: grid; place-items: center; flex: none; width: 38px; height: 38px; border-radius: 10px; background: #8b929c; color: #fff; }
.attachment-icon svg { width: 20px; height: 20px; }
:is(.attachment-icon, .file-badge)[data-tone="red"] { background: #ef4444; }
:is(.attachment-icon, .file-badge)[data-tone="blue"] { background: #3964fe; }
:is(.attachment-icon, .file-badge)[data-tone="green"] { background: #16a34a; }
:is(.attachment-icon, .file-badge)[data-tone="orange"] { background: #f97316; }
:is(.attachment-icon, .file-badge)[data-tone="purple"] { background: #8b5cf6; }
:is(.attachment-icon, .file-badge)[data-tone="slate"] { background: #475569; }
:is(.attachment-icon, .file-badge)[data-tone="teal"] { background: #0d9488; }
.attachment-text { display: grid; gap: 2px; min-width: 0; }
.attachment-name { overflow: hidden; color: var(--text); font-size: 13px; font-weight: 500; line-height: 18px; text-overflow: ellipsis; white-space: nowrap; }
.attachment-meta { overflow: hidden; color: var(--text-3); font-size: 12px; line-height: 16px; text-overflow: ellipsis; white-space: nowrap; font-variant-numeric: tabular-nums; }
.attachment.is-image { width: 56px; padding: 0; overflow: hidden; background: var(--bg-muted); }
.attachment.is-image img { display: block; width: 100%; height: 100%; object-fit: cover; }
.attachment.is-missing img { visibility: hidden; }
.attachment.is-error { border-color: var(--danger-soft-hover); background: var(--danger-soft); }
.attachment.is-error .attachment-meta { color: var(--danger); }
.attachment.is-error .attachment-icon { background: var(--danger); }
.attachment.is-uploading .attachment-icon { opacity: .55; }
.attachment-veil { position: absolute; inset: 0; display: grid; place-items: center; background: rgba(0, 0, 0, .35); }
.attachment-veil .spinner { border-color: rgba(255, 255, 255, .35); border-top-color: #fff; }
.attachment-remove {
  position: absolute; top: -6px; right: -6px; z-index: 1;
  display: grid; place-items: center; width: 20px; height: 20px; padding: 0;
  border: 1px solid var(--line-3); border-radius: 50%; background: var(--bg-raised); color: var(--text-2); box-shadow: var(--shadow-1);
  opacity: 0; transition: opacity .15s var(--ease);
}
.attachment-remove svg { width: 12px; height: 12px; stroke-width: 2.2; }
.attachment-remove:hover { color: var(--text); background: var(--bg-nav-hover); }
.attachment.is-image .attachment-remove { top: 3px; right: 3px; }
.attachment:hover .attachment-remove, .attachment:focus-within .attachment-remove, .attachment.is-error .attachment-remove { opacity: 1; }
.attachment.is-openable { cursor: pointer; }
.attachment.is-openable:hover { background: var(--bg-nav-hover); }
.attachment.is-openable:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
.message-attachments { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; max-width: min(85%, 600px); margin-bottom: 8px; }
.message-attachments .attachment.is-image { width: 120px; height: 120px; border-radius: 16px; }
.message-attachments .attachment.is-image:only-child { width: auto; max-width: min(100%, 280px); height: auto; max-height: 280px; }
.message-attachments .attachment.is-image:only-child img { width: auto; max-width: 100%; height: auto; max-height: 280px; }
.message-attachments .attachment.is-openable:hover { background: var(--bg-muted); filter: var(--hover-filter); }

/* Persona chip: on a narrow composer the persona moves into the + menu instead. */

/* Slash commands */
.command-menu {
  position: absolute; left: 10px; right: 10px; bottom: calc(100% + 8px); z-index: 20;
  display: grid; align-content: start; gap: 2px; max-height: min(300px, 46vh); padding: 6px; overflow-y: auto;
  border: 1px solid var(--line-1); border-radius: 16px; background: var(--bg-menu); box-shadow: var(--shadow-3);
  animation: menu-up .12s var(--ease);
}
.command-menu.is-below { top: calc(100% + 8px); bottom: auto; animation-name: menu-in; }
.command-option { display: grid; gap: 2px; padding: 8px 12px; border-radius: 10px; cursor: pointer; }
.command-option[aria-selected="true"] { background: var(--bg-nav-hover); }
.command-head { display: flex; align-items: baseline; flex-wrap: wrap; gap: 8px; }
.command-name { color: var(--text); font-family: var(--font-mono); font-size: 13px; font-weight: 600; }
.command-alias { color: var(--text-3); font-size: 12px; }
.command-desc { color: var(--text-3); font-size: 12px; line-height: 18px; }
.command-desc:empty { display: none; }

/* Dropping files on the chat */
.drop-overlay {
  position: absolute; inset: 0; z-index: 30; display: none; place-items: center; padding: 24px;
  background: color-mix(in srgb, var(--bg) 82%, transparent); backdrop-filter: blur(2px); pointer-events: none;
}
.chat.is-dropping .drop-overlay { display: grid; animation: fade .12s var(--ease); }
.drop-card {
  display: grid; justify-items: center; gap: 6px; width: min(100%, 420px); padding: 36px 28px;
  border: 2px dashed var(--brand-line); border-radius: 24px; background: var(--brand-soft); color: var(--brand-text); text-align: center;
}
.drop-card svg { width: 30px; height: 30px; }
.drop-card strong { font-size: 16px; font-weight: 600; }
.drop-card span { color: var(--text-2); font-size: 13px; }

/* Settings panels */
.panel-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 6px; }
.panel-head .settings-label { margin: 0 0 4px; font-size: 16px; font-weight: 600; }
.panel-head .settings-actions { flex: none; }
.panel-head-text { min-width: 0; }
.panel-desc { margin: 0; color: var(--text-3); font-size: 13px; line-height: 20px; }
.settings-panel > .panel-desc:last-child { margin-top: 16px; }
.switch {
  position: relative; flex: none; width: 40px; height: 24px; padding: 0;
  border: 0; border-radius: 999px; background: var(--line-4); transition: background-color var(--dur) var(--ease);
}
.switch-thumb {
  position: absolute; top: 2px; left: 2px; width: 20px; height: 20px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, .2); transition: transform .32s var(--ease-spring), width .2s var(--ease);
}
.switch:active:not(:disabled) .switch-thumb { width: 24px; }
.switch[aria-checked="true"]:active:not(:disabled) .switch-thumb { transform: translateX(12px); }
.switch[aria-checked="true"] { background: var(--brand); }
.switch[aria-checked="true"] .switch-thumb { transform: translateX(16px); }
.switch:disabled { opacity: .45; cursor: default; }
.switch:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
.panel-empty { margin: 12px 0; padding: 28px 20px 26px; border: 1px dashed var(--line-3); border-radius: 14px; background: color-mix(in srgb, var(--bg-muted) 50%, transparent); color: var(--text-3); font-size: 13px; line-height: 20px; text-align: center; text-wrap: balance; }
.panel-tools { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px 12px; margin: 18px 0 6px; }
.panel-tools .select-pill, .panel-tools .select-pill select { max-width: 100%; }
.panel-tools .select-pill select { min-width: 0; text-overflow: ellipsis; }
.panel-search {
  display: flex; align-items: center; gap: 6px; flex: 1 1 180px; max-width: 260px; height: 34px; padding: 0 12px;
  border-radius: 999px; background: var(--bg-select); color: var(--text-3);
}
.panel-search svg { width: 16px; height: 16px; flex: none; }
.panel-search input { flex: 1; min-width: 0; height: 100%; padding: 0; border: 0; outline: 0; background: transparent; color: var(--text); font-size: 13px; }
.panel-search input::placeholder { color: var(--text-4); }
.panel-search:focus-within { box-shadow: 0 0 0 2px var(--brand-line); }
.panel-add, .panel-edit { display: flex; align-items: center; gap: 8px; }
.panel-add { margin: 16px 0 0; }
.panel-edit { width: 100%; }
:is(.panel-add, .panel-edit) input, .number-input {
  flex: 1; min-width: 0; height: 36px; padding: 0 14px;
  border: 1px solid var(--line-3); border-radius: 999px; background: var(--bg-input); color: var(--text); font-size: 14px; outline: 0;
  transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}
:is(.panel-add, .panel-edit) input:focus, .number-input:focus { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
.number-input { flex: none; width: 96px; height: 34px; padding: 0 12px; border-radius: 10px; text-align: right; font-variant-numeric: tabular-nums; }
.number-input:disabled { opacity: .5; }
.segmented-sm { margin: 0; padding: 3px; }
.segmented button {
  padding: 5px 12px; border: 0; border-radius: 999px; background: none;
  color: var(--text-2); font-size: 13px; line-height: 18px; transition: background-color var(--dur), color var(--dur);
}
.segmented button:hover { color: var(--text); }
.segmented button[aria-pressed="true"] { background: var(--bg-raised); color: var(--text); font-weight: 500; box-shadow: var(--shadow-1); }
.panel-list { display: grid; margin: 0; padding: 0; list-style: none; }
.panel-head + .panel-list { margin-top: 12px; border-top: 1px solid var(--line-2); }
.panel-item { display: flex; align-items: center; gap: 12px; min-height: 56px; padding: 10px 2px; border-bottom: 1px solid var(--line-2); }
.panel-item:last-child { border-bottom: 0; }
.panel-item-body { flex: 1; min-width: 0; }
.panel-item-title { margin: 0; color: var(--text); font-size: 14px; line-height: 22px; overflow-wrap: anywhere; }
.panel-item-meta { margin: 2px 0 0; color: var(--text-3); font-size: 12px; line-height: 18px; overflow-wrap: anywhere; }
.panel-item-warn { margin: 4px 0 0; color: var(--warn); font-size: 12px; line-height: 18px; }
.panel-item-actions { display: flex; align-items: center; gap: 2px; flex: none; }
.memory-item.is-pinned .panel-item-title { font-weight: 500; }
.icon-btn.is-on { color: var(--brand-text); }
.icon-btn.is-danger:hover:not(:disabled) { background: var(--danger-soft); color: var(--danger); }
.panel-foot { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--line-2); }
.badge {
  display: inline-flex; align-items: center; margin-left: 6px; padding: 0 6px; border-radius: 6px;
  background: var(--bg-muted); color: var(--text-3); font-size: 11px; font-weight: 500; line-height: 18px; vertical-align: 1px; white-space: nowrap;
}
.persona-form { display: grid; gap: 14px; margin: 14px 0 6px; padding: 18px; border: 1px solid var(--line-2); border-radius: 16px; background: var(--bg-field); }
.form-title { margin: 0; font-size: 15px; font-weight: 600; }
.form-field { display: grid; gap: 6px; min-width: 0; margin: 0; padding: 0; border: 0; }
.form-label { padding: 0; color: var(--text-2); font-size: 13px; font-weight: 500; }
.form-field :is(input:not([type=radio], [type=checkbox]), textarea) {
  width: 100%; padding: 8px 12px; border: 1px solid var(--line-3); border-radius: 10px;
  background: var(--bg-input); color: var(--text); font-size: 14px; line-height: 22px; outline: 0;
  transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}
.form-field textarea { min-height: 128px; resize: vertical; }
.form-field :is(input, textarea):focus { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
.form-field :is(input, textarea)::placeholder { color: var(--text-4); }
.form-hint { color: var(--text-3); font-size: 12px; line-height: 18px; }
.form-actions { display: flex; justify-content: flex-end; gap: 8px; }
.radio-row { display: flex; flex-wrap: wrap; gap: 8px 18px; }
.check { display: inline-flex; align-items: center; gap: 6px; color: var(--text); font-size: 13px; line-height: 20px; cursor: pointer; }
.check input { width: 16px; height: 16px; margin: 0; accent-color: var(--brand); }
.check-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px 12px; padding: 10px 12px; border-radius: 10px; background: var(--bg-muted); }
.usage-meter { display: grid; gap: 6px; flex: 1 1 220px; max-width: 360px; color: var(--text-3); font-size: 12px; font-variant-numeric: tabular-nums; }
.usage-bar { height: 6px; overflow: hidden; border-radius: 999px; background: var(--bg-select); }
.usage-bar span { display: block; height: 100%; min-width: 2px; border-radius: inherit; background: var(--brand); }
.file-badge {
  display: grid; place-items: center; flex: none; min-width: 46px; height: 28px; padding: 0 8px;
  border-radius: 8px; background: #8b929c; color: #fff; font-size: 11px; font-weight: 600; letter-spacing: .02em;
}
.plugin-card { margin: 14px 0 0; padding: 14px 16px; border: 1px solid var(--line-2); border-radius: 16px; background: var(--bg-raised); }
.plugin-card.is-off :is(.plugin-desc, .plugin-meta, .settings-row) { opacity: .6; }
.plugin-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.plugin-title { display: flex; align-items: baseline; flex-wrap: wrap; gap: 4px 8px; min-width: 0; }
.plugin-title strong { font-size: 15px; font-weight: 600; }
.plugin-title .badge { margin-left: 0; }
.plugin-version { color: var(--text-4); font-family: var(--font-mono); font-size: 11px; }
.plugin-desc { margin: 6px 0 0; color: var(--text-2); font-size: 13px; line-height: 20px; }
.plugin-meta { margin: 6px 0 0; color: var(--text-3); font-size: 12px; line-height: 18px; overflow-wrap: anywhere; }
.plugin-card .settings-row { min-height: 0; margin-top: 12px; padding: 12px 0 0; border-top: 1px solid var(--line-2); border-bottom: 0; }
.data-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(118px, 1fr)); gap: 10px; margin: 16px 0 8px; }
.data-stat { display: grid; gap: 2px; padding: 12px 14px; border-radius: 14px; background: var(--bg-muted); }
.data-stat strong { font-size: 20px; font-weight: 600; line-height: 28px; font-variant-numeric: tabular-nums; }
.data-stat span { color: var(--text-3); font-size: 12px; line-height: 18px; }

/* Motion: views and panels ease in, new messages rise into place. */
.workspace:not([hidden]) { animation: fade .4s var(--ease); }
.auth-panel { animation: rise-in .5s var(--ease-out); }
.chat.is-empty .welcome-copy { animation: rise-in .55s var(--ease-out); }
.chat.is-empty .composer { animation: rise-in .6s var(--ease-out) .05s backwards; }
.settings-panel:not([hidden]) { animation: panel-in .3s var(--ease-out); }
.settings-tab { transition: background-color .18s var(--ease), color .18s var(--ease); }
.settings-tab svg { transition: color .18s var(--ease), transform .3s var(--ease-spring); }
.settings-tab:hover svg { transform: scale(1.1); }
.billing-content > * { animation: rise-in .45s var(--ease-out) backwards; }
.billing-content > :nth-child(2) { animation-delay: .05s; }
.billing-content > :nth-child(3) { animation-delay: .1s; }
.billing-content > :nth-child(n + 4) { animation-delay: .15s; }
.message.user.is-pending { animation: message-in .3s var(--ease-out); }
.message.assistant.is-streaming { animation: message-in .4s var(--ease-out); }
.quota-bar span { transition: width .8s var(--ease-out); animation: bar-in .9s var(--ease-out); }
.chip svg { transition: transform .3s var(--ease-spring); }
.chip:active:not(:disabled) svg { transform: scale(.85); }
.chip[aria-pressed="true"] > svg:first-child { animation: pop .35s var(--ease-spring); }
.msg-action svg, .icon-btn svg { transition: transform .25s var(--ease-spring); }
.msg-action:active svg, .icon-btn:active:not(:disabled) svg { transform: scale(.85); }
.scroll-bottom { transition: background-color var(--dur), color var(--dur), transform .25s var(--ease-spring); }
.scroll-bottom:hover { transform: translateX(-50%) translateY(2px); }

/* Switching theme or accent: the new look spreads out from the press as a circle (View Transitions). */
::view-transition-old(root), ::view-transition-new(root) { animation: none; mix-blend-mode: normal; }
::view-transition-new(root) { animation: theme-reveal .6s var(--ease-out); }
.theme-switching *, .theme-switching *::before, .theme-switching *::after { transition: none !important; }

@keyframes spin { to { transform: rotate(360deg); } }
@keyframes pulse { 0%, 100% { opacity: 1; transform: scale(1); } 50% { opacity: .35; transform: scale(.8); } }
@keyframes typing { 0%, 80%, 100% { opacity: .3; transform: translateY(0); } 40% { opacity: 1; transform: translateY(-3px); } }
@keyframes fade-from-clear { from { opacity: 0; } }
@keyframes sheen { from { background-position: 100% 0; } to { background-position: -150% 0; } }
@keyframes shimmer { 0%, 100% { opacity: 1; } 50% { opacity: .45; } }
@keyframes fade { from { opacity: 0; } }
@keyframes fade-up { from { opacity: 0; transform: translate(-50%, 6px); } }
@keyframes menu-in { from { opacity: 0; transform: scale(.94) translateY(-4px); } }
@keyframes menu-up { from { opacity: 0; transform: translateY(6px); } }
@keyframes slide-left { from { transform: translateX(24px); opacity: 0; } }
@keyframes slide-up { from { transform: translateY(32px); opacity: 0; } }
@keyframes toast-in { from { opacity: 0; transform: translateY(-12px) scale(.96); } }
@keyframes toast-out { to { opacity: 0; transform: translateY(-6px) scale(.98); } }
@keyframes fade-in-up { from { opacity: 0; transform: translateY(4px); } }
@keyframes sheet-up { from { transform: translateY(110%); } }
@keyframes sheet-down { to { transform: translateY(110%); } }
@keyframes fade-out { to { opacity: 0; } }
@keyframes rise-in { from { opacity: 0; transform: translateY(12px); } }
@keyframes panel-in { from { opacity: 0; transform: translateX(8px); } }
@keyframes message-in { from { opacity: 0; transform: translateY(10px); } }
@keyframes bar-in { from { width: 0; } }
@keyframes grow-y { from { transform: scaleY(0); } }
@keyframes pop { 50% { transform: scale(1.25); } }
@keyframes theme-reveal {
  from { clip-path: circle(0 at var(--reveal-x, 50%) var(--reveal-y, 50%)); }
  to { clip-path: circle(150vmax at var(--reveal-x, 50%) var(--reveal-y, 50%)); }
}
@keyframes shake { 0%, 100% { transform: none; } 25% { transform: translateX(-4px); } 50% { transform: translateX(3px); } 75% { transform: translateX(-2px); } }

/* Narrow screens: the sidebar becomes a drawer and controls tighten. */
@media (max-width: 768px) {
  :root { --gutter: 16px; --topbar-h: 52px; --drawer-w: min(82vw, 340px); }
  .workspace, .workspace.sidebar-collapsed { grid-template-columns: minmax(0, 1fr); background: var(--bg-sidebar); }
  .workspace { --drawer-progress: 0; }
  .workspace.drawer-open { --drawer-progress: 1; }

  /* Drawer: the history lies under the chat, which slides right as a rounded card (progress 0 to 1). */
  .sidebar {
    position: fixed; z-index: 1; inset: 0 auto 0 env(safe-area-inset-left); width: var(--drawer-w);
    padding-top: env(safe-area-inset-top); border-right: 0; background: var(--bg-sidebar);
    transform: translateX(calc(-18% * (1 - var(--drawer-progress))));
    visibility: hidden;
    transition: transform .42s var(--ease-drawer), visibility 0s .42s;
  }
  .workspace:is(.drawer-open, .drawer-dragging) .sidebar { visibility: visible; transition: transform .42s var(--ease-drawer); }
  .sidebar .history, .sidebar .drawer-search, .sidebar .account { opacity: calc(.55 + .45 * var(--drawer-progress)); transition: opacity .42s var(--ease-drawer); }
  .workspace.drawer-dragging .sidebar :is(.history, .drawer-search, .account) { transition: none; }
  .sidebar > * { width: var(--drawer-w); }
  .sidebar-head, .sidebar .new-chat { display: none; }
  .drawer-search {
    display: flex; align-items: center; gap: 10px; flex: none;
    width: calc(var(--drawer-w) - 28px); height: 46px; margin: 14px 14px 10px; padding: 0 16px;
    border: 1px solid var(--line-2); border-radius: 23px; background: var(--bg-raised); color: var(--text-4);
    font-size: 16px; text-align: left; box-shadow: var(--shadow-1);
    transition: transform .2s var(--ease-spring), background-color .2s var(--ease);
  }
  .drawer-search svg { width: 20px; height: 20px; color: var(--text-3); }
  .drawer-search:active { transform: scale(.98); background: var(--bg-nav-hover); }
  .history { padding: 2px 10px 16px; }
  .history-group + .history-group { margin-top: 10px; }
  .history-label { height: 44px; padding-left: 12px; font-size: 13px; }
  .chat-group .history-label { padding-left: 0; }
  .conversation { min-height: 48px; margin: 2px 0; border-radius: 12px; }
  .conversation-select { padding: 0 12px; font-size: 15px; }
  .partner-group .conversation { min-height: 60px; }
  .partner-group .avatar-mark { --message-avatar-size: 40px; }
  .partner-line .conversation-title { font-size: 15px; }
  .conversation:active { background: var(--bg-nav-active); }
  .conversation-menu { color: var(--text-4); }
  .sidebar > .account { width: calc(var(--drawer-w) - 21px); margin: 7px 10px max(12px, env(safe-area-inset-bottom)); padding: 8px 10px; }
  .sidebar > .account::before { top: -7px; }
  .account .avatar { width: 36px; height: 36px; }
  #account-name { font-size: 16px; line-height: 22px; }
  #account-name { font-size: 16px; }

  /* The chat only slides; a shadow on its left edge and a light dim set it above the history. */
  .chat {
    z-index: 2; overflow: hidden; overflow: clip;
    transform: translate3d(calc(var(--drawer-w) * var(--drawer-progress)), 0, 0);
    border-radius: calc(24px * var(--drawer-progress)) 0 0 calc(24px * var(--drawer-progress));
    box-shadow: -1px 0 0 var(--line-2), -16px 0 40px -12px rgba(0, 0, 0, calc(.35 * var(--drawer-progress)));
    transition: transform .42s var(--ease-drawer), border-radius .42s var(--ease-drawer), box-shadow .42s var(--ease-drawer);
    will-change: transform;
  }
  .chat::after {
    content: ""; position: absolute; inset: 0; z-index: 60; background: #000; pointer-events: none;
    opacity: calc(.12 * var(--drawer-progress)); transition: opacity .42s var(--ease-drawer);
  }
  [data-theme="dark"] .chat::after { opacity: calc(.28 * var(--drawer-progress)); }
  .workspace.drawer-dragging :is(.sidebar, .chat) { transition: none; }
  .workspace.drawer-dragging .chat::after { transition: none; }
  .scrim { position: fixed; inset: 0 0 0 calc(var(--drawer-w) + env(safe-area-inset-left)); z-index: 3; padding: 0; border: 0; background: transparent; }
  .chat-scroll { touch-action: pan-y pinch-zoom; }
  .chat-wallpaper { inset: 0; }

  /* Top bar: floating frosted buttons over the conversation, which scrolls underneath. */
  .chat, .chat.is-empty { grid-template-rows: 0 minmax(0, 1fr) auto; }
  .topbar {
    position: absolute; top: 0; left: 0; right: 0; z-index: 6;
    grid-template-columns: 48px minmax(0, 1fr) 48px; gap: 4px;
    height: calc(52px + env(safe-area-inset-top)); padding: env(safe-area-inset-top) 4px 0;
    background: var(--bg);
  }
  .topbar::after { display: block; height: 12px; }
  .chat.has-wallpaper .topbar { background: color-mix(in srgb, var(--bg) 90%, transparent); }
  .chat.has-wallpaper .topbar::after { display: none; }
  .workspace .topbar-start > .tool-pill { display: inline-flex; }
  .topbar-start > .topbar-logo, #pill-search, #pill-new-chat { display: none !important; }
  .tool-pill, .topbar-end { display: inline-flex; align-items: center; justify-content: center; padding: 0; border: 0; background: none; box-shadow: none; }
  .tool-pill .icon-btn, .topbar-end .icon-btn { width: 48px; height: 48px; border-radius: 50%; color: var(--text); }
  .tool-pill .icon-btn svg, .topbar-end .icon-btn svg { width: 24px; height: 24px; }
  .desktop-icon { display: none; }
  .mobile-icon { display: block; stroke-width: 2; }
  #mobile-new-chat { display: inline-grid; }
  .topbar-title { max-width: 100%; font-size: 16px; font-weight: 600; }
  .title-button { padding: 0 8px; }
  .chat.is-empty .topbar-title { visibility: hidden; }
  .chat-scroll { grid-row: 2; padding-top: calc(var(--topbar-h) + env(safe-area-inset-top)); scroll-padding-top: calc(var(--topbar-h) + 12px); }

  /* Empty chat: the greeting centred on the page, the composer at the bottom edge. */
  .welcome { justify-content: center; padding: 24px 24px 12vh; }
  .welcome-title { flex-direction: column; gap: 14px; font-size: 20px; line-height: 28px; }
  .welcome-title .logo-mark { width: 46px; height: 46px; }
  .welcome-sub { font-size: 14px; }
  .chat.is-empty .chat-footer { padding-bottom: max(10px, env(safe-area-inset-bottom)); }

  .transcript { --message-avatar-size: 24px; --message-avatar-gap: 8px; gap: 26px; padding-top: 4px; padding-bottom: 28px; }
  /* Phones give the whole width to the text until the reader picks an avatar (Android ChatPane). */
  .chat:not(.has-chat-avatars) .message:is(.user, .assistant) { grid-template-columns: minmax(0, 1fr); column-gap: 0; }
  .chat:not(.has-chat-avatars) .message > .avatar-mark { display: none; }
  .chat:not(.has-chat-avatars) .message.user .bubble { max-width: 84%; }
  .message .avatar-mark { font-size: 12px; }
  .bubble { max-width: 100%; padding: 9px 16px; border-radius: 22px; }
  .message-actions { opacity: 1; }
  .chat-footer { padding: 0 10px max(10px, env(safe-area-inset-bottom)); }
  .composer {
    gap: 10px; padding: 12px 12px 10px; border-color: var(--line-2); border-radius: 26px;
    box-shadow: 0 10px 30px -14px rgba(0, 0, 0, .3), 0 0 0 .5px var(--line-1);
  }
  #prompt { min-height: 44px; padding: 2px 6px; }
  .chip { height: 34px; padding: 0 13px; font-size: 13px; }
  .chip svg { width: 18px; height: 18px; }
  .chip-split > .chip-caret { width: 30px; }
  .composer-more { width: 36px; height: 36px; border: 1px solid var(--line-3); color: var(--text); }
  .send-btn { width: 36px; height: 36px; }
  .composer-note { font-size: 11px; margin-top: 6px; }
  .scroll-bottom { width: 38px; height: 38px; -webkit-backdrop-filter: blur(16px); backdrop-filter: blur(16px); background: color-mix(in srgb, var(--bg-raised) 80%, transparent); }

  .sources-panel {
    top: auto; left: 0; width: 100%; max-height: 80%; border-left: 0; border-radius: 26px 26px 0 0;
    padding-bottom: env(safe-area-inset-bottom); animation: sheet-up .45s var(--ease-drawer);
  }
  .sources-panel::before { content: ""; align-self: center; flex: none; width: 36px; height: 5px; margin-top: 8px; border-radius: 3px; background: var(--line-3); }

  /* Sheets: settings and search rise from the bottom; the page behind steps back. */
  .workspace { transition: transform .5s var(--ease-drawer), border-radius .5s var(--ease-drawer), filter .5s var(--ease-drawer); }
  body:has(:is(#settings-dialog, #search-dialog)[open]) { background: #000; }
  body:has(:is(#settings-dialog, #search-dialog)[open]) .workspace { transform: translateY(6px) scale(.93); border-radius: 24px; overflow: hidden; filter: brightness(.82); }
  :is(.settings-dialog, .search-dialog) {
    width: 100%; max-width: 100%; height: calc(100dvh - max(16px, env(safe-area-inset-top)) - 12px); max-height: none;
    margin: auto 0 0; border-width: 1px 0 0; border-radius: 26px 26px 0 0;
    transition-duration: .5s; transition-timing-function: var(--ease-drawer);
  }
  :is(.settings-dialog, .search-dialog):not([open]) { opacity: 1; transform: translateY(100%); transition-duration: .32s; transition-timing-function: var(--ease); }
  @starting-style { :is(.settings-dialog, .search-dialog)[open] { opacity: 1; transform: translateY(100%); } }
  .search-dialog[open] { display: flex; flex-direction: column; }
  .search-head { flex: none; height: 64px; padding: 6px 12px 0 20px; }
  .search-results { flex: 1; max-height: none; padding-bottom: max(16px, env(safe-area-inset-bottom)); }
  .search-item { min-height: 50px; font-size: 16px; border-radius: 14px; }

  .settings-dialog { background: var(--sheet-bg); }
  .settings { grid-template-columns: 100% 100%; transition: transform .5s var(--ease-drawer); }
  .settings.is-detail { transform: translateX(-100%); }
  .settings-nav {
    padding: 14px 16px max(28px, env(safe-area-inset-bottom)); border-right: 0; background: var(--sheet-bg);
    transition: transform .5s var(--ease-drawer), opacity .5s var(--ease-drawer);
  }
  .settings.is-detail .settings-nav { transform: translateX(70%); opacity: 0; }
  .settings-nav .dialog-title { margin: 0 0 6px; font-size: 17px; line-height: 36px; text-align: center; }
  .settings-tabs { display: block; }
  .settings-group-label { margin: 22px 16px 8px; color: var(--text-3); font-size: 13px; }
  .settings-group-label:first-child { margin-top: 12px; }
  .settings-group { gap: 0; overflow: hidden; border-radius: 18px; background: var(--sheet-card); }
  .settings-tab { position: relative; gap: 14px; height: 56px; padding: 0 14px 0 16px; border-radius: 0; font-size: 16px; }
  .settings-tab svg { width: 22px; height: 22px; color: var(--text); }
  .settings-tab[aria-selected="true"] { background: none; font-weight: 400; }
  .settings-tab[aria-selected="true"] svg { color: var(--text); }
  .settings-tab:hover { background: none; }
  .settings-tab:active { background: var(--bg-nav-active); }
  .settings-tab:hover svg { transform: none; }
  .settings-tab::after {
    content: ""; flex: none; width: 18px; height: 18px; margin-left: auto; background: var(--text-4);
    -webkit-mask: var(--icon-chevron) center / contain no-repeat; mask: var(--icon-chevron) center / contain no-repeat;
  }
  .settings-tab + .settings-tab::before { content: ""; position: absolute; top: 0; left: 52px; right: 0; height: 1px; background: var(--line-2); }
  /* The profile card stands in for 账号管理, as on Android's settings home. */
  #settings-tab-account { display: none; }
  #settings-tab-account + .settings-tab::before { display: none; }
  .settings-tab.settings-link { display: flex; }
  .settings-tab-value {
    display: block; min-width: 0; max-width: 46%; margin-left: auto; overflow: hidden;
    color: var(--text-3); font-size: 15px; text-overflow: ellipsis; white-space: nowrap;
  }
  .settings-tab-value:empty { display: none; }
  .settings-tab:has(.settings-tab-value:not(:empty))::after { margin-left: 4px; }
  .settings-profile-card {
    position: relative; display: flex; align-items: center; gap: 14px; width: 100%; margin: 10px 0 0; padding: 14px 14px 14px 16px;
    border: 0; border-radius: 18px; background: var(--sheet-card); color: var(--text); text-align: left;
  }
  .settings-profile-card:active { background: var(--bg-nav-active); }
  .settings-profile-card::after {
    content: ""; flex: none; width: 18px; height: 18px; background: var(--text-4);
    -webkit-mask: var(--icon-chevron) center / contain no-repeat; mask: var(--icon-chevron) center / contain no-repeat;
  }
  .settings-profile-card .avatar { width: 56px; height: 56px; font-size: 22px; }
  .settings-profile-text { flex: 1; min-width: 0; display: grid; gap: 2px; }
  .settings-profile-name { display: flex; align-items: center; gap: 8px; min-width: 0; }
  .settings-profile-name strong { min-width: 0; overflow: hidden; font-size: 18px; font-weight: 600; line-height: 26px; text-overflow: ellipsis; white-space: nowrap; }
  .plan-tag { flex: none; padding: 1px 8px; border-radius: 6px; background: var(--bg-muted); color: var(--text-2); font-size: 12px; line-height: 18px; }
  .plan-tag.is-paid { background: var(--brand-soft); color: var(--brand-text); }
  .settings-profile-email { overflow: hidden; color: var(--text-3); font-size: 13px; line-height: 18px; text-overflow: ellipsis; white-space: nowrap; }
  .settings-nav .settings-mode { min-height: 64px; margin-top: 22px; padding: 10px 14px 10px 16px; border: 0; border-radius: 18px; background: var(--sheet-card); }
  .settings-mode-icon { display: block; }
  .settings-mode label { font-size: 16px; }
  .settings-logout {
    display: block; width: 100%; height: 56px; margin-top: 16px; border: 0; border-radius: 18px;
    background: var(--sheet-card); color: var(--danger); font-size: 16px; font-weight: 500;
  }
  .settings-logout:active { background: var(--danger-soft); }
  .settings-body { position: relative; z-index: 1; padding: 0 16px max(28px, env(safe-area-inset-bottom)); background: var(--sheet-bg); }
  .settings-detail-head {
    position: sticky; top: 0; z-index: 3; display: grid; grid-template-columns: 38px minmax(0, 1fr) 38px; align-items: center;
    margin: 0 -16px 10px; padding: 14px 14px 10px;
    background: color-mix(in srgb, var(--sheet-bg) 86%, transparent); -webkit-backdrop-filter: blur(16px); backdrop-filter: blur(16px);
  }
  .settings-detail-title { grid-column: 2; margin: 0; overflow: hidden; font-size: 17px; font-weight: 600; line-height: 24px; text-align: center; text-overflow: ellipsis; white-space: nowrap; }
  :is(.settings-back, .settings-close) {
    width: 38px; height: 38px; border-radius: 50%; color: var(--text);
    background: var(--sheet-card); box-shadow: 0 2px 8px -2px rgba(0, 0, 0, .18), 0 0 0 1px var(--line-1);
  }
  :is(.settings-back, .settings-close) svg { width: 20px; height: 20px; stroke-width: 2; }
  .settings-close { top: 13px; right: 14px; z-index: 5; }
  .settings-panel:not([hidden]) { animation: none; }
  .accent-options { gap: 10px 2px; justify-content: space-between; }
  .accent-option { width: 44px; }
  .accent-dot { width: 30px; height: 30px; }
  .panel-head { flex-wrap: wrap; }
  .panel-search { max-width: none; }
  .panel-item { align-items: flex-start; flex-wrap: wrap; }
  .panel-item-actions { margin-left: auto; }
  .attachment { width: 200px; }
  .message-attachments { max-width: 100%; }
  .message-attachments .attachment.is-image { width: 96px; height: 96px; }
  .theme-options { gap: 8px; }
  .theme-option { height: 72px; background: var(--sheet-card); }
  .billing-inner { width: calc(100% - 28px); padding-top: calc(var(--topbar-h) + env(safe-area-inset-top)); }
  .billing-card { padding: 16px; }
}

/* Personas, the character workshop and world books. */
.badge-brand { background: var(--brand-soft); color: var(--brand-text); }
.settings-panel.is-dropping { border-radius: 16px; box-shadow: inset 0 0 0 2px var(--brand-line); background: color-mix(in srgb, var(--brand-soft) 45%, transparent); }
.avatar-initial { font-size: .95em; line-height: 1; }
.user-persona { margin: 14px 0 0; padding: 12px 14px; border: 1px solid var(--line-2); border-radius: 14px; background: var(--bg-field); }
.user-persona-summary { display: flex; align-items: center; gap: 12px; }
.user-persona-summary > svg { width: 20px; height: 20px; flex: none; color: var(--text-3); }
.user-persona-fields { display: grid; gap: 12px; }
.user-persona .form-field textarea, .persona-editor .form-field textarea, .lore-form .form-field textarea, .memory-dialog .form-field textarea { min-height: 0; }
.persona-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; margin: 14px 0 0; padding: 0; list-style: none; }
.persona-card {
  display: flex; flex-direction: column; gap: 8px; min-width: 0; padding: 14px;
  border: 1px solid var(--line-2); border-radius: 16px; background: var(--bg-raised);
  transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}
.persona-card:hover { border-color: var(--line-3); box-shadow: var(--shadow-1); }
.persona-card.is-default { border-color: var(--brand-line); }
.persona-card-top { display: flex; align-items: center; gap: 12px; min-width: 0; }
.avatar-mark.persona-avatar { --message-avatar-size: 44px; flex: none; font-size: 18px; }
.persona-card-title { display: grid; gap: 4px; min-width: 0; }
.persona-card-title strong { overflow: hidden; font-size: 15px; font-weight: 600; line-height: 22px; text-overflow: ellipsis; white-space: nowrap; }
.persona-badges { display: flex; flex-wrap: wrap; gap: 4px; }
.persona-badges .badge { margin: 0; }
.persona-card-desc {
  display: -webkit-box; margin: 0; overflow: hidden; color: var(--text-2); font-size: 13px; line-height: 20px;
  -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow-wrap: anywhere;
}
.persona-card-desc:empty { display: none; }
.persona-card-tags { margin: 0; overflow: hidden; color: var(--text-3); font-size: 12px; line-height: 18px; text-overflow: ellipsis; white-space: nowrap; }
.persona-card-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; margin-top: auto; padding-top: 4px; }
.persona-card-actions .btn:first-child { margin-right: auto; }
.panel-back { margin: 0 0 8px -8px; }
.settings-body:has(#settings-personas:not([hidden])) { transition-property: none; }
.settings-body:has(#settings-personas:not([hidden]) > .persona-editor) { display: flex; flex-direction: column; overflow: hidden; padding-bottom: 0; }
#settings-personas:has(> .persona-editor) { flex: 1; min-height: 0; }
.persona-editor { display: grid; height: 100%; min-height: 0; grid-template-rows: minmax(0, 1fr) auto; }
.editor-scroll {
  display: grid; align-content: start; gap: 18px; min-width: 0; min-height: 0; overflow-y: auto; overscroll-behavior: contain;
  padding: 4px 4px 18px; scroll-padding-block: 6px 18px;
  mask-image: linear-gradient(to bottom, #000 calc(100% - 12px), transparent);
}
.editor-head { display: grid; gap: 2px; }
.editor-head .form-title, .persona-editor .check, #settings-lorebooks .settings-label { overflow-wrap: anywhere; }
.editor-head .panel-back { justify-self: start; margin-bottom: 0; }
.workshop { display: grid; gap: 8px; padding: 14px; border: 1px solid var(--brand-line); border-radius: 16px; background: color-mix(in srgb, var(--brand-soft) 60%, var(--bg-raised)); }
.workshop-title { margin: 0; color: var(--brand-text); font-size: 13px; font-weight: 600; }
.workshop-head { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 6px; }
.workshop-images { display: grid; gap: 6px; min-width: 0; margin: 0; padding: 0; list-style: none; }
.workshop-image {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: start; gap: 4px;
  min-width: 0; padding: 5px 6px; border-radius: 10px; background: var(--bg-input);
}
.workshop-image summary { display: grid; grid-template-columns: 48px minmax(0, 1fr) auto; align-items: center; gap: 8px; cursor: pointer; }
.workshop-image summary::-webkit-details-marker { display: none; }
.workshop-image summary svg { width: 14px; height: 14px; color: var(--text-3); }
.workshop-image img { width: 48px; height: 48px; object-fit: contain; border-radius: 4px; }
.workshop-image .workshop-image-preview { display: block; width: 100%; height: auto; max-height: 42dvh; margin-top: 6px; }
.workshop-image details[open] svg { transform: rotate(180deg); }
.workshop-image-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text-2); font-size: 13px; }
.workshop-image .icon-btn { width: 44px; height: 44px; }
.workshop-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; }
.workshop textarea {
  width: 100%; min-width: 0; min-height: 0; padding: 8px 12px; border: 1px solid var(--line-3); border-radius: 12px;
  background: var(--bg-input); color: var(--text); font: inherit; font-size: 14px; line-height: 22px; resize: vertical; outline: 0;
}
.workshop textarea:focus { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
.workshop-row .btn { flex: none; }
.workshop .notice[data-error] { color: var(--danger); }
.editor-section { display: grid; gap: 12px; padding-top: 16px; border-top: 1px solid var(--line-2); }
.editor-section-title { margin: 0; color: var(--text); font-size: 14px; font-weight: 600; }
.editor-identity { display: flex; align-items: flex-start; gap: 18px; }
.editor-avatar { display: grid; justify-items: center; gap: 4px; flex: none; }
.persona-avatar-picker { position: relative; padding: 0; border: 0; border-radius: 50%; background: none; cursor: pointer; }
.persona-avatar-picker .avatar-mark.persona-avatar { --message-avatar-size: 84px; font-size: 32px; }
.persona-avatar-edit {
  position: absolute; inset: auto 0 0; padding: 3px 0 6px; border-radius: 0 0 42px 42px;
  background: rgba(0, 0, 0, .5); color: #fff; font-size: 11px; opacity: 0; transition: opacity var(--dur) var(--ease);
}
.persona-avatar-picker:is(:hover, :focus-visible) .persona-avatar-edit { opacity: 1; }
.editor-fields { display: grid; gap: 12px; flex: 1; min-width: 0; }
.persona-kind { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; width: min(100%, 17rem); }
.persona-kind-option {
  display: flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 6px 8px;
  border: 1px solid var(--line-3); border-radius: 10px; background: var(--bg-input);
  color: var(--text-2); font-size: 14px; line-height: 20px; cursor: pointer;
}
.persona-kind-option input { flex: none; width: 16px; height: 16px; margin: 0; accent-color: var(--brand); }
@media (hover: hover) {
  .persona-kind-option:hover { border-color: var(--line-4); background: var(--bg-hover); }
}
.persona-kind-option:has(:checked) { border-color: var(--brand); background: var(--brand-soft); color: var(--text); font-weight: 600; }
.persona-kind-option:has(:focus-visible) { outline: 2px solid var(--brand); outline-offset: 2px; }
.persona-kind-option input:focus-visible { outline: none; }
.persona-kind-option:has(:disabled) { opacity: .6; cursor: default; }
.editor-split { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.editor-split-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.editor-split .select-pill, .editor-split .select-pill select { width: 100%; }
.persona-editor .form-field > .btn { justify-self: start; }
.persona-avatar-picker .avatar-mark svg { width: 36%; height: 36%; color: var(--text-3); }
.alternates { display: grid; gap: 8px; }
.alternates > .btn { justify-self: start; }
.alternate-row { display: flex; align-items: flex-start; gap: 6px; }
.alternate-row textarea {
  flex: 1; min-width: 0; padding: 8px 12px; border: 1px solid var(--line-3); border-radius: 10px;
  background: var(--bg-input); color: var(--text); font: inherit; font-size: 14px; line-height: 22px; resize: vertical; outline: 0;
}
.alternate-row textarea:focus { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
/* Let paragraphs grow in place, with room left to reach the surrounding form. */
.persona-editor .editor-scroll textarea {
  --text-height-limit: min(22rem, 48dvh);
  field-sizing: content; min-width: 0; max-width: 100%;
  min-height: min(calc(var(--textarea-rows) * 1lh + 18px), var(--text-height-limit));
  max-height: var(--text-height-limit); overflow-y: auto; overflow-wrap: anywhere;
  font-size: 15px; line-height: 1.6; scroll-margin-block: 10px;
}
.persona-editor .editor-scroll :is(input[type=text], textarea)::placeholder {
  color: color-mix(in srgb, var(--text-2), var(--text-3)); opacity: 1;
}
.editor-advanced { padding-top: 14px; border-top: 1px solid var(--line-2); }
.editor-advanced > summary { color: var(--text-2); font-size: 14px; font-weight: 600; cursor: pointer; }
.editor-advanced[open] { display: grid; gap: 12px; }
.editor-actions { align-items: center; flex-wrap: wrap; padding: 12px 4px max(12px, env(safe-area-inset-bottom)); border-top: 1px solid var(--line-2); }
.editor-feedback { flex: 1 1 65px; min-width: 0; }
.editor-count { margin: 0; }
.editor-feedback .notice[data-error] + .editor-count { display: none; }
.editor-feedback .notice[data-error], .lore-form .notice[data-error] { color: var(--danger); }
.lore-heading { margin: 22px 0 0; }
.book-settings { margin-top: 10px; }
.lore-list { grid-template-columns: minmax(0, 1fr); }
.lore-item .panel-item-title .badge { margin-left: 6px; }
.lore-item.is-off .panel-item-title, .lore-item.is-off .lore-preview { opacity: .55; }
.lore-preview { margin: 4px 0 0; overflow: hidden; color: var(--text-3); font-size: 12px; line-height: 18px; text-overflow: ellipsis; white-space: nowrap; }
.lore-form-item { list-style: none; }
.lore-form-item .persona-form { margin: 8px 0; }
.lore-test { display: grid; gap: 6px; margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--line-2); }
.lore-test-result:empty { display: none; }

/* Characters in the chat: a name over each reply and switchable opening lines. */
.message-name { margin: 0 0 4px; overflow-wrap: anywhere; color: var(--text-2); font-size: 13px; font-weight: 600; line-height: 20px; }
.message-name[hidden] { display: none; }
.greeting-switch { display: inline-flex; align-items: center; gap: 0; margin-left: 4px; }
.greeting-switch[hidden] { display: none; }
.greeting-position { min-width: 40px; color: var(--text-3); font-size: 12px; font-variant-numeric: tabular-nums; text-align: center; }
.message-actions:has(.greeting-switch:not([hidden])) { opacity: 1; }
.msg-action:disabled { opacity: .4; pointer-events: none; }
.memory-summary-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.memory-summary-head .btn { margin-right: -8px; }

/* Phones: confirmations and agreements rise from the bottom edge like a sheet. */
@media (max-width: 520px) {
  .settings-panel .panel-list { grid-template-columns: minmax(0, 1fr); }
  .settings-panel .panel-item:has(.panel-edit) > :is(.file-badge, .panel-item-actions) { display: none; }
  .settings-panel :is(.panel-add, .panel-edit) { flex-wrap: wrap; justify-content: flex-end; }
  .settings-panel :is(.panel-add, .panel-edit) input { flex-basis: 100%; }
  .settings-panel :is(.panel-add, .panel-edit) .select-pill { margin-right: auto; }
  .billing .btn, .billing-redeem-form input { min-height: 44px; }
  #billing-tabs a { padding-block: 13px; }
  .billing-order-actions .btn { flex: 1 1 auto; }
  .dialog:is(.dialog-sm, .dialog-md) {
    width: 100%; max-width: 100%; margin: auto 0 0; border-width: 1px 0 0; border-radius: 22px 22px 0 0;
    max-height: calc(100dvh - 24px);
  }
  .dialog:is(.dialog-sm, .dialog-md):not([open]) { transform: translateY(24px); }
  @starting-style { .dialog:is(.dialog-sm, .dialog-md)[open] { transform: translateY(100%); } }
  .dialog:is(.dialog-sm, .dialog-md) .dialog-form { padding: 22px 20px max(16px, env(safe-area-inset-bottom)); }
  .dialog:is(.dialog-sm, .dialog-md) .dialog-actions { flex-direction: column-reverse; }
  .dialog:is(.dialog-sm, .dialog-md) .dialog-actions .btn { width: 100%; height: 44px; font-size: 15px; }
  .persona-grid { grid-template-columns: minmax(0, 1fr); }
  .editor-identity { flex-direction: column; align-items: stretch; }
  .editor-avatar { justify-self: center; align-self: center; }
  .editor-split, .editor-split-3 { grid-template-columns: minmax(0, 1fr); }
}

@container composer (max-width: 345px) {
  .chip { padding: 0 9px; }
  .chip-split > .chip:first-child { padding-right: 6px; }
}

@container composer (max-width: 315px) {
  .composer-chips:has(.chip-split) #search span { display: none; }
}
@container composer (max-width: 295px) {
  #search span { display: none; }
}
@container composer (max-width: 265px) {
  .chip-split #thinking-label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
}

/* iOS zooms into small text fields when the software keyboard opens. */
@media (any-pointer: coarse) {
  :is(#login, #workspace, dialog) :is(input:not([type=checkbox], [type=radio], [type=range], [type=file], [type=hidden]), textarea) {
    font-size: max(16px, 1rem);
  }
}

@media (max-height: 480px) {
  .composer { gap: 4px; padding-block: 8px; }
  #prompt { min-height: 32px; max-height: min(20dvh, 88px); }
}

/* A landscape keyboard can leave only one line of the page visible. */
@container workspace (max-height: 180px) {
  .chat:not(.is-billing) { grid-template-rows: minmax(0, 1fr) auto; }
  .chat:not(.is-billing) :is(.topbar, .chat-scroll) { grid-area: 1 / 1; }
  .chat:not(.is-billing) .topbar { position: relative; align-self: start; max-height: 100%; overflow: clip; }
  .chat-footer { grid-row: 2; max-height: 100cqh; overflow-y: auto; overscroll-behavior: contain; }
  .composer { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; }
  .composer-bar { display: contents; }
  #prompt, .composer-actions { grid-row: 1; }
  #prompt { max-height: min(48px, 48cqh); }
  .composer-actions { grid-column: 2; }
  .composer-chips, .composer-count, .attachments, .command-menu { grid-column: 1 / -1; }
  .command-menu { position: static; }
}

@media (hover: none) {
  .conversation-menu { opacity: 1; }
  .attachment-remove { opacity: 1; }
  .conversation .conversation-select { padding-right: 40px; }
  /* Touch screens always show the row menu, so the time stays beside it (as on Android). */
  .conversation:not(.running) .conversation-select > .conversation-time,
  .conversation:not(.running) .partner-line > .conversation-time { display: inline; }
}

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

/* Invite friends: the account's code, how to pass it on, and what it has earned. */
.invite-card { display: grid; justify-items: start; gap: 10px; margin-top: 16px; padding: 18px 20px; border-radius: 16px;
  background: var(--brand-soft); }
.invite-label { color: var(--text-3); font-size: 13px; }
.invite-code { color: var(--brand-text); font-size: 30px; font-weight: 650; letter-spacing: 0.16em; line-height: 38px;
  font-variant-numeric: tabular-nums; user-select: all; }
.invite-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.invite-empty { margin: 0; color: var(--text-2); font-size: 14px; line-height: 22px; }
.invite-rules { margin: 8px 0 0; padding-left: 18px; color: var(--text-3); font-size: 13px; line-height: 21px; }
.quota-extra { align-content: start; }
#register-invite { text-transform: uppercase; }
#register-invite::placeholder { text-transform: none; }
