/* The cai theme: flat, neutral surfaces with one blue accent, in a light and a dark palette.
   Served at /theme-static/cai.css on every page, including the ones this theme has no template
   for — so it styles every class the shared pages and scripts render, not only its own
   (test_a_theme_styles_every_class_the_shared_markup_renders holds it to that). Every colour
   below resolves to a semantic token declared once in :root: light is the default, dark follows
   prefers-color-scheme and is a separately tuned palette, not an inversion, and
   <html data-theme="light|dark"> (the reader's appearance cookie) overrides both. Layout uses
   logical properties, so Persian is the same design reflected. Persian is set in Shabnam, the
   designer's face, served from this theme's fonts/ with its licence: on a Persian page it sets
   every character, Latin included, as the design draws it; on an English page the same files are
   asked for only when an Arabic-script codepoint is actually used, so English stays in the
   system stack and a reader of English answers downloads nothing. Shabnam has 400, 500 and 700;
   a 600 resolves to 700. Code is JetBrains Mono (400 and 500), falling back to Shabnam for the
   Persian it lacks. The exports keep Vazirmatn (export/fonts): a .docx embeds TrueType.
   Tokens are the designer's visual-refresh v4 (data/design/CAI.visual-refresh.v4.html). */

@font-face {
  font-family: Shabnam; font-style: normal; font-weight: 400; font-display: swap;
  src: url("fonts/Shabnam.woff2") format("woff2");
}
@font-face {
  font-family: Shabnam; font-style: normal; font-weight: 500; font-display: swap;
  src: url("fonts/Shabnam-Medium.woff2") format("woff2");
}
@font-face {
  font-family: Shabnam; font-style: normal; font-weight: 700; font-display: swap;
  src: url("fonts/Shabnam-Bold.woff2") format("woff2");
}
@font-face {
  font-family: "Shabnam Arabic"; font-style: normal; font-weight: 400; font-display: swap;
  src: url("fonts/Shabnam.woff2") format("woff2");
  unicode-range: U+0600-06FF, U+0750-077F, U+08A0-08FF, U+FB50-FDFF, U+FE70-FEFF, U+200C-200F;
}
@font-face {
  font-family: "Shabnam Arabic"; font-style: normal; font-weight: 500; font-display: swap;
  src: url("fonts/Shabnam-Medium.woff2") format("woff2");
  unicode-range: U+0600-06FF, U+0750-077F, U+08A0-08FF, U+FB50-FDFF, U+FE70-FEFF, U+200C-200F;
}
@font-face {
  font-family: "Shabnam Arabic"; font-style: normal; font-weight: 700; font-display: swap;
  src: url("fonts/Shabnam-Bold.woff2") format("woff2");
  unicode-range: U+0600-06FF, U+0750-077F, U+08A0-08FF, U+FB50-FDFF, U+FE70-FEFF, U+200C-200F;
}
@font-face {
  font-family: "JetBrains Mono"; font-style: normal; font-weight: 400; font-display: swap;
  src: url("fonts/JetBrainsMono-Regular.woff2") format("woff2");
}
@font-face {
  font-family: "JetBrains Mono"; font-style: normal; font-weight: 500; font-display: swap;
  src: url("fonts/JetBrainsMono-Medium.woff2") format("woff2");
}

:root {
  color-scheme: light;
  --page-bg: #E3E8F2;
  --canvas: #F5F7FC;
  --surface: #FFFFFF;
  --surface-muted: #EBEFF6;
  --surface-hover: #F4F6F9;
  --surface-pressed: #ECEFF4;
  --surface-raised: #FFFFFF;
  --sidebar-bg: #FFFFFF;
  --border-subtle: #E7EBF0;
  --border: #DCE2EA;
  --border-strong: #C3CCD8;
  --border-control: #7E8A9B;
  --text-primary: #182230;
  --text-body: #2B3747;
  --text-secondary: #526174;
  --text-tertiary: #59667A;
  --text-disabled: #A0A9B6;
  --icon-muted: #768295;
  --accent: #2459D3;
  --accent-hover: #1D4CB8;
  --accent-pressed: #183F9B;
  --on-accent: #FFFFFF;
  --on-accent-track: rgba(255,255,255,.38);
  --accent-text: #2459D3;
  --accent-subtle: #EBF1FD;
  --accent-subtle-hover: #DFE8FB;
  --accent-subtle-border: #C3D3F3;
  --selected-bg: #E1EBFE;
  --selected-bg-hover: #D5E3FD;
  --selected-border: #A9C0EE;
  --selected-fg: #1D4CB8;
  --focus-ring: #2459D3;
  --focus-halo: rgba(36,89,211,.16);
  --accent-halo: rgba(36,89,211,.16);
  --hover-bg: rgba(24,34,48,.05);
  --pressed-bg: rgba(24,34,48,.09);
  --control-bg: #FFFFFF;
  --control-bg-hover: #F3F5F8;
  --control-bg-pressed: #E9EDF2;
  --control-border: #CDD4DE;
  --control-border-hover: #B4BFCC;
  --disabled-bg: #E9ECF0;
  --skeleton: #E6EAEF;
  --skeleton-strong: #E1E6EC;
  --skeleton-highlight: #F6F8FA;
  --success-fg: #17774A;
  --success-bg: #EAF6EF;
  --success-border: #B5DEC7;
  --success-icon-bg: #DAF0E3;
  --warning-fg: #8F5700;
  --warning-bg: #FDF5E6;
  --warning-border: #EED2A0;
  --warning-icon-bg: #F8E5C0;
  --warning-track: rgba(143,87,0,.24);
  --danger-fg: #B42E24;
  --danger-fg-hover: #9E2920;
  --danger-bg: #FDEEEC;
  --danger-bg-hover: #FADCD8;
  --danger-bg-pressed: #FBE5E2;
  --danger-border: #F1C0BA;
  --danger-border-hover: #E49D95;
  --danger-icon-bg: #F9DAD6;
  --danger-track: rgba(180,46,36,.24);
  --info-fg: #0B6487;
  --info-bg: #E9F4F9;
  --info-border: #B4D9E8;
  --info-icon-bg: #D2EAF4;
  --status-neutral-fg: #475566;
  --status-neutral-bg: #EEF1F5;
  --status-neutral-border: #D2D9E2;
  --source-fg: #2459D3;
  --source-bg: #EDF2FD;
  --source-border: #C3D3F3;
  --source-active-fg: #183F9B;
  --source-active-bg: #DAE5FA;
  --source-active-border: #8DA8E4;
  --bubble-user-bg: #E8EDF5;
  --bubble-user-border: #D8E0EC;
  --bubble-cai-bg: #FFFFFF;
  --bubble-cai-border: #DCE2EA;
  --logo-bg: #EBF1FD;
  --logo-border: #C3D3F3;
  --logo-fg: #2459D3;
  --overlay: rgba(24,34,48,.36);
  --shadow-float: 0 8px 24px rgba(16,24,40,.10), 0 1px 3px rgba(16,24,40,.06);
  --shadow-dialog: 0 20px 48px rgba(16,24,40,.16), 0 2px 6px rgba(16,24,40,.06);
  --shadow-hover: 0 4px 14px rgba(16,24,40,.08);
  --frame-shadow: 0 0 0 1px #DCE2EA, 0 1px 3px rgba(16,24,40,.05);
  --sky-surface: #EAF3FF;
  --sky-surface-hover: #DCEBFF;
  --sky-surface-pressed: #D3E5FF;
  --sky-border: #B4CEF4;
  --sky-border-strong: #8DB2EA;
  --lavender-surface: #F0EDFF;
  --lavender-border: #D6CEF6;
  --indigo: #6554C0;
  --entry-bg: var(--sky-surface);
  --entry-bg-hover: var(--sky-surface-hover);
  --entry-bg-pressed: var(--sky-surface-pressed);
  --entry-border: var(--sky-border);
  --entry-border-hover: var(--sky-border-strong);
  --entry-icon-bg: #FFFFFF;
  --entry-icon-border: var(--sky-border);
  --pill-bg: var(--sky-surface);
  --pill-bg-hover: var(--sky-surface-hover);
  --pill-border: var(--sky-border);
  --plan-intro-bg: var(--lavender-surface);
  --plan-eyebrow-fg: var(--indigo);
  --plan-footer-bg: var(--sky-surface);
  --highlight-bg: var(--lavender-surface);
  --highlight-border: var(--lavender-border);
  --highlight-divider: var(--lavender-border);
  --highlight-fg: var(--indigo);
  --avatar-bg: var(--lavender-surface);
  --avatar-border: var(--lavender-border);
  --avatar-alt-bg: var(--lavender-surface);
  --avatar-alt-border: var(--lavender-border);
  --avatar-fg: #4E3FA6;
  --pill-bg-pressed: var(--sky-surface-pressed);
  --ring: 0 0 0 2px var(--surface), 0 0 0 4px var(--focus-ring);
  --r-chip: 999px;
  --r-btn: 12px;
  --r-card: 20px;
  --r-modal: 28px;
  --ease: cubic-bezier(.2,.8,.2,1);
  --dur: 250ms;
  --sans: "Shabnam Arabic", ui-sans-serif, system-ui, sans-serif;
  --mono: "JetBrains Mono", "Shabnam Arabic", ui-monospace, SFMono-Regular, Menlo, monospace;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]):not([data-theme="orange"]) {
    color-scheme: dark;
    --page-bg: #0B0E13;
    --canvas: #11151B;
    --surface: #1A2029;
    --surface-muted: #242D39;
    --surface-hover: #212833;
    --surface-pressed: #1D232D;
    --surface-raised: #1F2631;
    --sidebar-bg: #151A22;
    --border-subtle: #2A3341;
    --border: #354153;
    --border-strong: #4A586C;
    --border-control: #6E7D92;
    --text-primary: #EEF2F7;
    --text-body: #D3DAE4;
    --text-secondary: #ABB7C7;
    --text-tertiary: #96A2B4;
    --text-disabled: #5C6879;
    --icon-muted: #76849A;
    --accent: #8AB4FF;
    --accent-hover: #A3C4FF;
    --accent-pressed: #7299E0;
    --on-accent: #101C30;
    --on-accent-track: rgba(16,28,48,.30);
    --accent-text: #8AB4FF;
    --accent-subtle: rgba(138,180,255,.12);
    --accent-subtle-hover: rgba(138,180,255,.18);
    --accent-subtle-border: rgba(138,180,255,.34);
    --selected-bg: rgba(138,180,255,.13);
    --selected-bg-hover: rgba(138,180,255,.18);
    --selected-border: rgba(138,180,255,.45);
    --selected-fg: #A9C8FF;
    --focus-ring: #8AB4FF;
    --focus-halo: rgba(138,180,255,.24);
    --accent-halo: rgba(138,180,255,.22);
    --hover-bg: rgba(238,242,247,.06);
    --pressed-bg: rgba(238,242,247,.10);
    --control-bg: #242D39;
    --control-bg-hover: #2C3644;
    --control-bg-pressed: #202833;
    --control-border: #3D495C;
    --control-border-hover: #536177;
    --disabled-bg: #20262F;
    --skeleton: #232B36;
    --skeleton-strong: #29323E;
    --skeleton-highlight: #323C4A;
    --success-fg: #6FD39B;
    --success-bg: rgba(111,211,155,.11);
    --success-border: rgba(111,211,155,.32);
    --success-icon-bg: rgba(111,211,155,.20);
    --warning-fg: #F0B54A;
    --warning-bg: rgba(240,181,74,.10);
    --warning-border: rgba(240,181,74,.32);
    --warning-icon-bg: rgba(240,181,74,.20);
    --warning-track: rgba(240,181,74,.30);
    --danger-fg: #FF8F86;
    --danger-fg-hover: #FFB4AE;
    --danger-bg: rgba(255,143,134,.11);
    --danger-bg-hover: rgba(255,143,134,.19);
    --danger-bg-pressed: rgba(255,143,134,.08);
    --danger-border: rgba(255,143,134,.34);
    --danger-border-hover: rgba(255,143,134,.52);
    --danger-icon-bg: rgba(255,143,134,.20);
    --danger-track: rgba(255,143,134,.28);
    --info-fg: #7CC5E6;
    --info-bg: rgba(124,197,230,.10);
    --info-border: rgba(124,197,230,.32);
    --info-icon-bg: rgba(124,197,230,.20);
    --status-neutral-fg: #B4BFCD;
    --status-neutral-bg: rgba(180,191,205,.10);
    --status-neutral-border: rgba(180,191,205,.30);
    --source-fg: #9EC0FF;
    --source-bg: rgba(138,180,255,.12);
    --source-border: rgba(138,180,255,.34);
    --source-active-fg: #C6DAFF;
    --source-active-bg: rgba(138,180,255,.26);
    --source-active-border: rgba(138,180,255,.62);
    --bubble-user-bg: #242D39;
    --bubble-user-border: #2E3846;
    --bubble-cai-bg: #1A2029;
    --bubble-cai-border: #354153;
    --logo-bg: #1F2D47;
    --logo-border: #34496E;
    --logo-fg: #8AB4FF;
    --overlay: rgba(4,6,10,.62);
    --shadow-float: 0 10px 28px rgba(0,0,0,.45), 0 0 0 1px rgba(0,0,0,.2);
    --shadow-dialog: 0 24px 56px rgba(0,0,0,.55);
    --shadow-hover: 0 6px 16px rgba(0,0,0,.32);
    --frame-shadow: 0 0 0 1px #262E3A;
    --entry-bg: var(--surface);
    --entry-bg-hover: var(--surface);
    --entry-bg-pressed: var(--surface);
    --entry-border: var(--border);
    --entry-border-hover: var(--border);
    --entry-icon-bg: var(--accent-subtle);
    --entry-icon-border: var(--accent-subtle-border);
    --pill-bg: var(--control-bg);
    --pill-bg-hover: var(--control-bg-hover);
    --pill-border: var(--control-border);
    --plan-intro-bg: var(--surface);
    --plan-eyebrow-fg: var(--accent-text);
    --plan-footer-bg: var(--surface-muted);
    --highlight-bg: var(--surface-muted);
    --highlight-border: var(--border);
    --highlight-divider: var(--border);
    --highlight-fg: var(--accent-text);
    --avatar-bg: var(--control-bg);
    --avatar-border: var(--control-border);
    --avatar-alt-bg: var(--surface);
    --avatar-alt-border: var(--border);
    --avatar-fg: var(--text-body);
    --pill-bg-pressed: var(--control-bg-hover);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --page-bg: #0B0E13;
  --canvas: #11151B;
  --surface: #1A2029;
  --surface-muted: #242D39;
  --surface-hover: #212833;
  --surface-pressed: #1D232D;
  --surface-raised: #1F2631;
  --sidebar-bg: #151A22;
  --border-subtle: #2A3341;
  --border: #354153;
  --border-strong: #4A586C;
  --border-control: #6E7D92;
  --text-primary: #EEF2F7;
  --text-body: #D3DAE4;
  --text-secondary: #ABB7C7;
  --text-tertiary: #96A2B4;
  --text-disabled: #5C6879;
  --icon-muted: #76849A;
  --accent: #8AB4FF;
  --accent-hover: #A3C4FF;
  --accent-pressed: #7299E0;
  --on-accent: #101C30;
  --on-accent-track: rgba(16,28,48,.30);
  --accent-text: #8AB4FF;
  --accent-subtle: rgba(138,180,255,.12);
  --accent-subtle-hover: rgba(138,180,255,.18);
  --accent-subtle-border: rgba(138,180,255,.34);
  --selected-bg: rgba(138,180,255,.13);
  --selected-bg-hover: rgba(138,180,255,.18);
  --selected-border: rgba(138,180,255,.45);
  --selected-fg: #A9C8FF;
  --focus-ring: #8AB4FF;
  --focus-halo: rgba(138,180,255,.24);
  --accent-halo: rgba(138,180,255,.22);
  --hover-bg: rgba(238,242,247,.06);
  --pressed-bg: rgba(238,242,247,.10);
  --control-bg: #242D39;
  --control-bg-hover: #2C3644;
  --control-bg-pressed: #202833;
  --control-border: #3D495C;
  --control-border-hover: #536177;
  --disabled-bg: #20262F;
  --skeleton: #232B36;
  --skeleton-strong: #29323E;
  --skeleton-highlight: #323C4A;
  --success-fg: #6FD39B;
  --success-bg: rgba(111,211,155,.11);
  --success-border: rgba(111,211,155,.32);
  --success-icon-bg: rgba(111,211,155,.20);
  --warning-fg: #F0B54A;
  --warning-bg: rgba(240,181,74,.10);
  --warning-border: rgba(240,181,74,.32);
  --warning-icon-bg: rgba(240,181,74,.20);
  --warning-track: rgba(240,181,74,.30);
  --danger-fg: #FF8F86;
  --danger-fg-hover: #FFB4AE;
  --danger-bg: rgba(255,143,134,.11);
  --danger-bg-hover: rgba(255,143,134,.19);
  --danger-bg-pressed: rgba(255,143,134,.08);
  --danger-border: rgba(255,143,134,.34);
  --danger-border-hover: rgba(255,143,134,.52);
  --danger-icon-bg: rgba(255,143,134,.20);
  --danger-track: rgba(255,143,134,.28);
  --info-fg: #7CC5E6;
  --info-bg: rgba(124,197,230,.10);
  --info-border: rgba(124,197,230,.32);
  --info-icon-bg: rgba(124,197,230,.20);
  --status-neutral-fg: #B4BFCD;
  --status-neutral-bg: rgba(180,191,205,.10);
  --status-neutral-border: rgba(180,191,205,.30);
  --source-fg: #9EC0FF;
  --source-bg: rgba(138,180,255,.12);
  --source-border: rgba(138,180,255,.34);
  --source-active-fg: #C6DAFF;
  --source-active-bg: rgba(138,180,255,.26);
  --source-active-border: rgba(138,180,255,.62);
  --bubble-user-bg: #242D39;
  --bubble-user-border: #2E3846;
  --bubble-cai-bg: #1A2029;
  --bubble-cai-border: #354153;
  --logo-bg: #1F2D47;
  --logo-border: #34496E;
  --logo-fg: #8AB4FF;
  --overlay: rgba(4,6,10,.62);
  --shadow-float: 0 10px 28px rgba(0,0,0,.45), 0 0 0 1px rgba(0,0,0,.2);
  --shadow-dialog: 0 24px 56px rgba(0,0,0,.55);
  --shadow-hover: 0 6px 16px rgba(0,0,0,.32);
  --frame-shadow: 0 0 0 1px #262E3A;
  --entry-bg: var(--surface);
  --entry-bg-hover: var(--surface);
  --entry-bg-pressed: var(--surface);
  --entry-border: var(--border);
  --entry-border-hover: var(--border);
  --entry-icon-bg: var(--accent-subtle);
  --entry-icon-border: var(--accent-subtle-border);
  --pill-bg: var(--control-bg);
  --pill-bg-hover: var(--control-bg-hover);
  --pill-border: var(--control-border);
  --plan-intro-bg: var(--surface);
  --plan-eyebrow-fg: var(--accent-text);
  --plan-footer-bg: var(--surface-muted);
  --highlight-bg: var(--surface-muted);
  --highlight-border: var(--border);
  --highlight-divider: var(--border);
  --highlight-fg: var(--accent-text);
  --avatar-bg: var(--control-bg);
  --avatar-border: var(--control-border);
  --avatar-alt-bg: var(--surface);
  --avatar-alt-border: var(--border);
  --avatar-fg: var(--text-body);
  --pill-bg-pressed: var(--control-bg-hover);
}
/* Orange: white with an orange accent, chosen by the reader (appearance.py), never by the
   device. It keeps the light palette's text and status colours and warms the rest. The
   accent is a deep orange so white on it, and it on the page, read at 4.5:1 or better. */
:root[data-theme="orange"] {
  color-scheme: light;
  --page-bg: #FBE9DA;
  --canvas: #FFF8F2;
  --surface: #FFFFFF;
  --surface-muted: #FFF1E5;
  --surface-hover: #FFF6EE;
  --surface-pressed: #FFEBDB;
  --surface-raised: #FFFFFF;
  --sidebar-bg: #FFFFFF;
  --border-subtle: #F7E6D8;
  --border: #F0D9C6;
  --border-strong: #E3BFA2;
  --accent: #CF4A0E;
  --accent-hover: #B93A0B;
  --accent-pressed: #9A3412;
  --accent-text: #C2410C;
  --accent-subtle: #FFF0E5;
  --accent-subtle-hover: #FFE4D1;
  --accent-subtle-border: #FDCBA8;
  --selected-bg: #FFE8D6;
  --selected-bg-hover: #FFDDC2;
  --selected-border: #F8B88A;
  --selected-fg: #B93A0B;
  --focus-ring: #CF4A0E;
  --focus-halo: rgba(207,74,14,.18);
  --accent-halo: rgba(207,74,14,.18);
  --control-border: #EBCFB8;
  --control-border-hover: #DDB495;
  --source-fg: #C2410C;
  --source-bg: #FFF1E8;
  --source-border: #FDCBA8;
  --source-active-fg: #9A3412;
  --source-active-bg: #FFE0CC;
  --source-active-border: #F2A877;
  --bubble-user-bg: #FFEFE2;
  --bubble-user-border: #F8D9C1;
  --bubble-cai-border: #F0D9C6;
  --logo-bg: #FFF0E5;
  --logo-border: #FDCBA8;
  --logo-fg: #C2410C;
  --frame-shadow: 0 0 0 1px #F0D9C6, 0 1px 3px rgba(120,53,15,.06);
  --sky-surface: #FFF3E8;
  --sky-surface-hover: #FFE9D6;
  --sky-surface-pressed: #FFE0C7;
  --sky-border: #F9CFAE;
  --sky-border-strong: #F2B07F;
  --lavender-surface: #FFF1E8;
  --lavender-border: #F7D2BA;
  --indigo: #C2410C;
  --avatar-fg: #9A3412;
}
:root:lang(fa) {
  --sans: Shabnam, ui-sans-serif, system-ui, sans-serif;
  --mono: "JetBrains Mono", Shabnam, ui-monospace, SFMono-Regular, Menlo, monospace;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
/* Persian letters join, and letter-spacing pulls them apart (Safari breaks the joins outright):
   the tracked, uppercase labels drawn for English read "گ ذ ر و ا ژ ه" on a phone. None on a
   Persian page, but for English or left-to-right text inside it — a code, a model name. */
:root:lang(fa) :not(code, kbd, samp, pre, [lang="en"], [lang="en"] *, [dir="ltr"], [dir="ltr"] *) {
  letter-spacing: normal;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--canvas);
  color: var(--text-primary);
  font: 16px/1.6 var(--sans);
  -webkit-font-smoothing: antialiased;
}

button, input, textarea, select { font-family: inherit; color: inherit; }
a { color: var(--accent-text); text-decoration: none; }
a:hover { color: var(--accent-hover); }

.shell { display: flex; align-items: flex-start; min-height: 100vh; }
main { flex: 1; min-width: 0; padding: 36px 40px 80px; }

.sidebar {
  flex: none;
  width: 280px;
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 16px 14px 12px;
  background: var(--sidebar-bg);
  border-inline-end: 1px solid var(--border);
}
.sidebar .brand-lockup { padding: 0 2px 4px; }
.new-topic { width: 100%; gap: 6px; padding: 0; height: 40px; font-size: 13.5px; }

.brand-lockup { display: flex; align-items: center; gap: 10px; color: var(--text-body); text-decoration: none; }
.brand-lockup:hover { color: var(--text-primary); }
/* The emblem cut from the logo, its glow kept as translucency so it sits on the gradient. */
.mark { width: 30px; height: 30px; flex: none; object-fit: contain; }
/* The letters cut from the same file, beside the emblem wherever the bar has room for them. */
.wordmark { height: 16px; width: auto; display: block; }
.logo-lg { width: 120px; height: auto; }
.auth-card { display: flex; flex-direction: column; gap: 20px; padding: 40px; }
.auth-lead { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 8px; }
.auth-lead h1 { font-size: 1.5rem; }
.auth-card form.stack { max-width: none; }
.btn { display: inline-flex; align-items: center; justify-content: center; text-decoration: none; color: var(--on-accent); }
.btn:hover { color: var(--on-accent); }
.auth-google { width: 100%; box-sizing: border-box; }
.auth-or { display: flex; align-items: center; gap: 12px; margin: 0; color: var(--text-body); font-size: .85rem; }
.auth-or::before, .auth-or::after { content: ""; flex: 1; border-top: 1px solid var(--border); }
.brand-name { font-weight: 600; letter-spacing: -.01em; }

.nav { display: flex; flex-direction: column; gap: 4px; }
.nav a {
  padding: 8px 10px; border-radius: 10px;
  color: var(--text-secondary); font-size: 13.5px; text-decoration: none;
}
.nav a:hover { color: var(--text-primary); background: var(--hover-bg); }
.nav a.active { color: var(--text-primary); font-weight: 500; background: var(--selected-bg); }

.lang { display: flex; gap: 8px; }
.lang a {
  flex: 1; text-align: center; font-size: 12px; padding: 6px 8px;
  color: var(--text-secondary); text-decoration: none;
  border: 1px solid var(--border); border-radius: 999px;
  background: var(--surface-muted);
}
.lang a:hover { color: var(--text-primary); }
.lang a.on { color: var(--on-accent); background: var(--accent); border-color: transparent; font-weight: 600; }

/* The account row, and the menu it opens upward from it. Last in the sidebar: the
   version above it takes the free space, or the account itself in the rail, which hides
   the version. */
.sidebar > .brand { margin-block-start: auto; }
.account {
  position: relative; margin-block-start: auto;
  border-block-start: 1px solid var(--border-subtle); padding-block-start: 8px;
}
.account summary {
  display: flex; align-items: center; gap: 10px; padding: 6px; border-radius: 12px;
  list-style: none; cursor: pointer;
}
.account summary::-webkit-details-marker { display: none; }
.account summary:hover, .account[open] summary { background: var(--hover-bg); }
.account .who {
  flex: 1; min-width: 0; font-size: 12px; color: var(--text-secondary);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.account-menu {
  position: absolute; inset-inline: 0; inset-block-end: calc(100% + 6px); z-index: 5;
  display: flex; flex-direction: column; gap: 2px; padding: 8px;
  border-radius: 16px; background: var(--surface-raised); border: 1px solid var(--border);
  box-shadow: var(--shadow-float);
}
.account-menu a, .account-menu .signout button, .account-menu .install-app {
  display: block; width: 100%; padding: 10px; border-radius: 10px; text-align: start;
  color: var(--text-body); font-size: 13.5px; text-decoration: none;
}
.account-menu a:hover, .account-menu .signout button:hover, .account-menu .install-app:hover { color: var(--text-primary); background: var(--hover-bg); }
.account-menu a.active { color: var(--text-primary); }
.account-menu hr { border: 0; border-block-start: 1px solid var(--border-subtle); margin: 4px 8px; }
.account-menu .signout { margin: 0; }
.account-menu .signout button { text-decoration: none; color: var(--text-secondary); }
.avatar {
  width: 34px; height: 34px; border-radius: 50%; flex: none;
  display: flex; align-items: center; justify-content: center;
  background: var(--avatar-bg); border: 1px solid var(--avatar-border);
  font-size: 13px; font-weight: 600; color: var(--avatar-fg);
}
.brand { font-size: 11px; color: var(--text-tertiary); padding-inline: 8px; }
.brand .version { color: inherit; text-decoration: none; }
.brand .version:hover { color: var(--text-primary); }
.sidebar > .brand + .account { margin-block-start: 0; }

.topbar {
  display: flex; align-items: center; gap: 16px;
  padding: 20px 28px; width: 100%;
}
.topbar .theme-switch { margin-inline-start: auto; }
.app-version { margin-block-start: auto; padding: 16px; text-align: center; font-size: 11px; color: var(--text-tertiary); }
.topbar .lang a { flex: none; padding-inline: 14px; }
body:not(:has(.sidebar)) .shell { flex-direction: column; }
body:not(:has(.sidebar)) main {
  width: min(440px, 100%);
  margin-inline: auto;
  padding-block-start: 8px;
}
/* The sign-in and invite cards stand in the middle of the screen, not under the topbar. */
body:has(.auth-card) main {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

h1 { font-size: 2rem; font-weight: 600; letter-spacing: -.015em; line-height: 1.2; margin: 0 0 .4rem; }
h2 { font-size: 1.25rem; font-weight: 600; letter-spacing: -.01em; margin: 0 0 .35rem; }
h3 {
  font-size: .75rem; margin: 1.6rem 0 .5rem; color: var(--text-tertiary);
  text-transform: uppercase; letter-spacing: .12em;
}
p.meta, .meta { color: var(--text-secondary); font-size: .85rem; }
p.empty, .empty { color: var(--text-secondary); }
code, .mono { font: .85em var(--mono); }
.error { color: var(--danger-fg); }
/* The code under a failure, for quoting to support: quieter than the failure, whole when
   selected, and never broken across lines. */
.reference { display: block; margin-block-start: 4px; font-size: .78rem; color: var(--text-secondary); }
.reference code { user-select: all; white-space: nowrap; color: var(--text-body); }
.notice { color: var(--success-fg); }
.verified { color: var(--success-fg); font-weight: 600; }
.phone-banner { margin-block-end: 12px; }
.phone-banner strong { display: block; }

button, .btn {
  padding: .7rem 1.2rem; border: 1px solid transparent; border-radius: var(--r-btn);
  background: var(--accent); color: var(--on-accent); font-weight: 600; cursor: pointer;
  box-shadow: none;
}
/* Hover and press on a primary link-button. Buttons proper keep their own looks: half of
   them are chips, options and links drawn as buttons, and an accent hover would lie about them. */
.btn { transition: background var(--dur) var(--ease), box-shadow var(--dur) var(--ease), transform var(--dur) var(--ease); }
.btn:not(.secondary):hover { background: var(--accent-hover); box-shadow: none; }
.btn:not(.secondary):active { background: var(--accent-pressed); box-shadow: none; transform: scale(.98); }
button:disabled { opacity: .45; cursor: not-allowed; box-shadow: none; }
button.secondary, .btn.secondary {
  background: var(--control-bg); color: var(--text-body); border: 1px solid var(--control-border);
  box-shadow: none; font-weight: 500;
}
button.secondary:hover, .btn.secondary:hover { color: var(--text-primary); background: var(--control-bg-hover); border-color: var(--control-border-hover); }
details.reset { margin-top: 20px; }
details.reset > summary { list-style: none; display: inline-flex; cursor: pointer; }
details.reset > summary::-webkit-details-marker { display: none; }
.reset-confirm { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-top: 10px; }
button.link, .revise-open, button.quiet {
  padding: 0; background: none; border: 0; box-shadow: none;
  color: var(--text-secondary); font-weight: 400; font-size: .82rem;
  text-decoration: underline; text-underline-offset: 2px; cursor: pointer;
}
button.link:hover, .revise-open:hover { color: var(--text-primary); }

/* Frame 18's input: 48px, 15px text, a quiet placeholder; the accent border and halo on focus, a red
   border when the browser calls the value invalid and the reader has touched it. */
textarea, select, input[type="text"], input[type="email"], input[type="password"], input[type="search"],
input[type="tel"] {
  width: 100%; padding: 0 16px; height: 48px; border-radius: 14px; font-size: 15px;
  background: var(--surface); color: var(--text-primary); box-shadow: none;
  border: 1px solid var(--border-control);
  transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease), background var(--dur) var(--ease);
}
/* A select's own arrow, drawn here: the browser's sat against the border and cannot be moved.
   Two halves of a chevron in the theme's icon colour, 18px in from the inline end (the left
   on a Persian page), with room kept for it so a long choice stops short of it. */
select {
  appearance: none; -webkit-appearance: none; padding-inline-end: 44px;
  background-image: linear-gradient(45deg, transparent 50%, var(--icon-muted) 50%),
    linear-gradient(135deg, var(--icon-muted) 50%, transparent 50%);
  background-position: calc(100% - 24px) 50%, calc(100% - 18px) 50%;
  background-size: 6px 6px, 6px 6px; background-repeat: no-repeat;
}
:root[dir="rtl"] select { background-position: 18px 50%, 24px 50%; }
select:disabled { opacity: .6; cursor: default; }
textarea { height: auto; min-height: 6.5rem; padding-block: 12px; line-height: 1.6; resize: vertical; }
::placeholder { color: var(--text-tertiary); opacity: 1; }
textarea:focus, select:focus, input[type="text"]:focus, input[type="email"]:focus,
input[type="password"]:focus, input[type="search"]:focus, input[type="tel"]:focus {
  background: var(--surface); border-color: var(--focus-ring); box-shadow: 0 0 0 3px var(--focus-halo);
}
input:user-invalid, textarea:user-invalid { background: var(--surface); border-color: var(--danger-fg); }
.control { display: flex; flex-direction: column; gap: .45rem; min-width: 12rem; }
.control label, .control .label {
  font-size: 12px; font-weight: 600; letter-spacing: .12em;
  text-transform: uppercase; color: var(--text-tertiary);
}
/* A label that is a button (the profile's photo picker) keeps the button's look. */
.control label.attach { font-size: 12.5px; font-weight: 500; letter-spacing: 0; text-transform: none; color: var(--text-body); }
.hint { font-size: .78rem; color: var(--text-tertiary); min-height: 1.2em; }
form.stack { display: flex; flex-direction: column; gap: 1rem; }
form.inline { display: flex; flex-wrap: wrap; gap: .75rem; align-items: flex-end; margin: 0 0 1.25rem; }
form.inline .control { flex: 1 1 16rem; }
.check { display: flex; gap: .45rem; align-items: center; }
/* Never squeezed by the words beside them: in a flex row a label that wraps (a long model
   name on a phone) took its room from the box, and the boxes in one list came out in
   different sizes. */
input[type="checkbox"], input[type="radio"] { flex: none; }

.wrap { overflow-x: auto; border-radius: var(--r-card); }
.wrap table { min-width: 30rem; }
.seat .wrap table { min-width: 0; }
/* Wide enough to read on a phone, and scrolled sideways in its .wrap there: the four fixed
   columns shared a 300px screen, a cost broke into pieces and "0.4s" stood one character a
   line. A wider screen keeps the table to its card, as before. */
@media (max-width: 56rem) { .seat .wrap table { min-width: 44rem; } }
table { border-collapse: collapse; width: 100%; font-size: .9rem; }
th, td { padding: .7rem .9rem; text-align: start; border-bottom: 1px solid var(--border-subtle); white-space: nowrap; }
/* Every column is read from where the page's language starts: each heading at that side of
   its column and what is under it there too, the left in English and the right in Persian.
   At the end, the figures ran past their heading in English and the headings stood at the far
   side of their columns in Persian. A side, not `start`: a cell holding a request or a model
   name in the other script takes that script's direction, and its start would be the far
   side. Not inside something marked with the other direction, such as an English report. */
:root[dir="ltr"] :is(th, td):not([dir="rtl"] *) { text-align: left; }
:root[dir="rtl"] :is(th, td):not([dir="ltr"] *) { text-align: right; }
th { font-weight: 600; color: var(--text-tertiary); font-size: .72rem; text-transform: uppercase; letter-spacing: .08em; }
td.prompt { white-space: normal; min-width: 15rem; max-width: 26rem; }
tr.revoked td { color: var(--text-tertiary); }

.badge {
  display: inline-flex; align-items: center; gap: 7px;
  height: 26px; padding: 0 11px; border-radius: 999px;
  font-size: 12px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase;
  background: var(--surface-muted); border: 1px solid var(--border); color: var(--text-secondary);
}
.badge.delivered, .badge.completed { color: var(--success-fg); background: var(--success-bg); border-color: var(--success-border); }
.badge.generating, .badge.running, .badge.queued, .badge.confirmed, .badge.revising { color: var(--warning-fg); background: var(--warning-bg); border-color: var(--warning-border); }
.badge.failed { color: var(--danger-fg); background: var(--danger-bg); border-color: var(--danger-border); }
.badge.chat { color: var(--info-fg); background: var(--info-bg); border-color: var(--info-border); }
.badge.eliciting { color: var(--indigo); background: var(--lavender-surface); border-color: var(--lavender-border); }

.tiles { display: flex; flex-wrap: wrap; gap: 12px; margin: 1.2rem 0 2rem; }
.tile, .card, .panel, .qcard, .plan-pane, .whats-new {
  background: var(--surface); border: 1px solid var(--border); box-shadow: none;
  border-radius: var(--r-card);
}
.tile { flex: 1 1 12rem; padding: 18px; }
.tile .value { font-size: 2rem; font-weight: 600; letter-spacing: -.015em; }
.tile .label { font-size: 12px; font-weight: 600; letter-spacing: .12em; text-transform: uppercase; color: var(--text-tertiary); }
.card, .panel { padding: 22px 24px; margin: 0 0 16px; }
.card header { display: flex; align-items: center; flex-wrap: wrap; gap: .6rem; margin-bottom: .5rem; }
.card .who, .who-label { font-size: .75rem; color: var(--text-tertiary); text-transform: uppercase; letter-spacing: .08em; }
.answer { white-space: pre-wrap; }

.whats-new {
  display: flex; gap: 1rem; align-items: flex-start; justify-content: space-between;
  padding: 16px 18px; margin: 0 0 1.5rem; font-size: .9rem;
  border-inline-start: 3px solid var(--accent);
}
.whats-new ul { margin: .4rem 0; padding-inline-start: 1.2rem; }
.whats-new form { flex: none; }
.release { margin: 0 0 1.5rem; }
.release ul { padding-inline-start: 1.2rem; }

/* Help: each part under the name the app gives it, the name in a column of its own so
   the eye can run down the names. Stacked on a phone, where a column would squeeze the
   explanation into a strip. */
.help { max-width: 52rem; margin: 0 0 2rem; }
.help dl { display: grid; grid-template-columns: minmax(8rem, 12rem) 1fr; gap: .7rem 1.5rem; margin: .8rem 0 0; }
.help dt { font-weight: 600; color: var(--text-primary); }
.help dd { margin: 0; color: var(--text-body); line-height: 1.6; }
.help-states { list-style: none; padding: 0; margin: .6rem 0 0; display: grid; gap: .45rem; }
/* The chip in a column of its own, so a meaning too long for the line wraps beside its
   chip instead of under it. */
.help-states li { display: grid; grid-template-columns: 8.5rem 1fr; align-items: start; gap: .6rem; }
.help-states .badge { justify-content: center; }

.tabs { display: flex; flex-wrap: wrap; gap: 8px; margin-block-end: 1.25rem; }
.tabs a {
  height: 32px; padding: 0 14px; border-radius: 999px;
  display: inline-flex; align-items: center;
  background: var(--surface-muted); border: 1px solid var(--border);
  color: var(--text-secondary); text-decoration: none; font-size: 12.5px; font-weight: 500;
}
.tabs a.on, .filters a.on { background: var(--selected-bg); border-color: var(--border); color: var(--text-primary); }
.filters { display: flex; flex-wrap: wrap; gap: 8px; margin: 1rem 0; }
.filters a {
  color: var(--text-secondary); text-decoration: none; padding: .15rem .7rem;
  border: 1px solid var(--border); border-radius: 999px; font-size: .85rem;
}
.crumb { font-size: .85rem; margin-block-end: .5rem; }
.crumb a { color: var(--text-secondary); }
.pager { display: flex; gap: 1rem; align-items: center; margin-top: 1.25rem; }
.role { font-size: .75rem; color: var(--text-tertiary); }
.role-generation { color: var(--text-primary); }
figure { margin: 1rem 0 0; overflow-x: auto; }

.markdown { white-space: normal; color: var(--text-body); }
.markdown > :first-child { margin-top: 0; }
.markdown > :last-child { margin-bottom: 0; }
.markdown h1, .markdown h2, .markdown h3 { color: var(--text-primary); line-height: 1.35; margin: 1.2em 0 .45em; }
.markdown p { margin: 0 0 .75em; }
.markdown ul, .markdown ol { margin: 0 0 .75em; padding-inline-start: 1.4em; }
.markdown blockquote {
  margin: .6em 0 .9em; padding-inline-start: .9em;
  border-inline-start: 2px solid var(--border); color: var(--text-secondary);
}
.markdown a { color: var(--accent-text); }
.markdown sup a {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 18px; height: 18px; padding: 0 4px; border-radius: 6px;
  background: var(--source-bg); border: 1px solid var(--source-border);
  color: var(--source-fg); font-weight: 500; text-decoration: none;
}
.markdown code { background: var(--surface-muted); border-radius: 4px; padding: .05em .3em; }
.markdown pre {
  direction: ltr; text-align: left;
  background: var(--surface-muted); border: 1px solid var(--border);
  border-radius: 12px; padding: .7em .85em; overflow-x: auto;
  font: .85rem/1.5 var(--mono);
}
.markdown pre code { background: none; padding: 0; }
.markdown table { display: block; overflow-x: auto; border-collapse: collapse; margin: .4em 0 1em; }
.markdown th, .markdown td {
  border: 1px solid var(--border); padding: .4em .7em; text-align: start; white-space: normal;
}
.markdown th { color: var(--text-tertiary); font-size: .75rem; letter-spacing: .08em; text-transform: uppercase; }
.prompt-block { white-space: pre-wrap; font: .9rem/1.55 var(--mono); }

.exports { display: inline-flex; flex-wrap: wrap; gap: .4rem; margin-inline-start: auto; }
.exports a {
  color: var(--text-body); text-decoration: none; font-size: .75rem; font-weight: 600;
  padding: .2rem .65rem; border: 1px solid var(--border); border-radius: 999px;
  background: var(--surface-muted);
}
.exports a:hover { color: var(--text-primary); }

.trace:empty { display: none; }
.trace { margin: .75rem 0 0; padding: .6rem .8rem; border-inline-start: 2px solid var(--border); }
.trace .event { font-size: .84rem; color: var(--text-secondary); }
.trace .event .tag { display: inline-block; min-width: 6.5rem; color: var(--text-primary); font-weight: 600; font-size: .74rem; text-transform: uppercase; }
.trace .event.failed .tag { color: var(--danger-fg); }
.trace .event .target { overflow-wrap: anywhere; }
.vote.pass { color: var(--success-fg); }
.vote.fail { color: var(--danger-fg); }

/* ---- home ---- */
.home { width: min(1000px, 100%); margin-inline: auto; display: flex; flex-direction: column; gap: 32px; padding-block-start: 24px; }
.home h1 { font-size: clamp(2rem, 4vw, 2.6rem); margin: 0; }
.new-project {
  width: 100%; padding: 24px; border-radius: 22px; text-align: start; text-decoration: none;
  background: var(--entry-bg); border: 1px solid var(--entry-border); box-shadow: none; display: flex; align-items: center; gap: 20px; color: inherit;
  transition: transform var(--dur) var(--ease), background var(--dur) var(--ease), border-color var(--dur) var(--ease);
}
.new-project:hover { color: inherit; transform: translateY(-2px); background: var(--entry-bg-hover); border-color: var(--entry-border-hover); box-shadow: var(--shadow-hover); }
.new-project:active { background: var(--entry-bg-pressed); transform: none; }
.new-project .glyph {
  width: 56px; height: 56px; flex: none; border-radius: 18px;
  display: flex; align-items: center; justify-content: center;
  background: transparent; border: 1px solid transparent; color: var(--accent-text);
}
.new-project strong { display: block; font-size: 1.25rem; color: var(--text-primary); }
.new-project span { display: block; color: var(--text-secondary); font-size: .95rem; margin-block-start: 4px; }
.new-project .chev { margin-inline-start: auto; color: var(--text-tertiary); font-size: 1.4rem; }

.continue-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.continue-head .recent-title, .recent-title {
  font-size: 12px; font-weight: 600; letter-spacing: .12em; text-transform: uppercase; color: var(--text-tertiary);
}

/* The sidebar's list: a row per topic, its chip at the end. It takes the height the
   sidebar has left and scrolls inside it, so the account row stays where it is. */
#recent {
  flex: 1 1 auto; min-height: 0; overflow-y: auto; margin-inline: -6px; padding-inline: 6px;
  scrollbar-width: thin; scrollbar-color: var(--border-strong) transparent;
}
.recent-list { display: flex; flex-direction: column; }
.recent-group {
  padding: 12px 8px 4px; font-size: 10px; font-weight: 600; line-height: 1;
  letter-spacing: .12em; text-transform: uppercase; color: var(--text-tertiary);
}
.recent-item {
  display: flex; align-items: center; gap: 8px; padding: 7px 8px; border-radius: 10px;
  color: var(--text-body); text-decoration: none; font-size: 13px;
}
.recent-item:hover { color: var(--text-primary); background: var(--hover-bg); }
.recent-item.current { color: var(--text-primary); background: var(--selected-bg); }
.recent-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.recent-item .badge { flex: none; height: 18px; padding: 0 6px; font-size: 10px; letter-spacing: .03em; }
/* A row in the sidebar: the link, and Delete beside it (recent.js). Delete sits over the
   row's end and shows on hover or keyboard focus, in place of the status chip, so a title
   keeps its width the rest of the time. Where nothing hovers it stays, after the chip. */
.recent-row { position: relative; display: flex; align-items: center; }
.recent-row > .recent-item { flex: 1; min-width: 0; }
button.recent-delete {
  position: absolute; inset-inline-end: 4px; top: 50%; transform: translateY(-50%);
  width: 26px; height: 26px; padding: 0; border-radius: 8px;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--surface-raised); border: 1px solid transparent; color: var(--text-secondary); font-weight: 400;
  opacity: 0; pointer-events: none;
}
.recent-row:is(:hover, :focus-within) > button.recent-delete { opacity: 1; pointer-events: auto; }
.recent-row:is(:hover, :focus-within):has(> button.recent-delete) .badge { visibility: hidden; }
button.recent-delete:hover { color: var(--danger-fg); background: var(--hover-bg); }
@media (hover: none) {
  button.recent-delete { position: static; transform: none; opacity: 1; pointer-events: auto; flex: none; background: none; }
  .recent-row:is(:hover, :focus-within):has(> button.recent-delete) .badge { visibility: visible; }
}

/* The home page's shelf: the same rows, as cards. */
.continue { display: flex; flex-direction: column; }
.continue-list { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.continue-list .recent-item {
  flex-direction: column-reverse; align-items: flex-start; gap: 12px; padding: 20px;
  border-radius: var(--r-card); background: var(--surface); border: 1px solid var(--border);
  box-shadow: none; color: var(--text-primary); font-size: 1rem; font-weight: 600; line-height: 1.35;
}
.continue-list .recent-item:hover { transform: translateY(-2px); }
.continue-list .recent-name { white-space: normal; }
.continue-list .project-when { width: auto; text-align: start; font-weight: 400; }

/* ---- conversation ---- */
.stage { width: min(840px, 100%); margin-inline: auto; display: flex; flex-direction: column; gap: 20px; /* main pads 36px above and 80px below; the stage fills the screen between the top padding and
   the composer's 16px gap, and takes back the rest of the bottom padding. */
  min-height: calc(100vh - 52px); margin-bottom: -64px; }
.stage > #report:empty { display: none; } /* else its flex gap lifts the composer off the floor */
.stage-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.back {
  width: 36px; height: 36px; border-radius: 12px; display: inline-flex; align-items: center; justify-content: center;
  color: var(--text-secondary); text-decoration: none; font-size: 1.25rem;
}
.back:hover { background: var(--hover-bg); color: var(--text-primary); }
/* The icons (presentation/icons.py). The chevrons and the back arrow lead back and on; they
 * are SVG, which the browser does not mirror, so right-to-left text turns them round here —
 * once. (The glyphs they replaced were Bidi_Mirrored and the browser turned those itself;
 * flipping them here too made Back point forward in Persian, measured 2026-10-04.) Send is
 * an up arrow now and needs no flip. */
.cai-ico { display: block; flex: none; overflow: visible; }
[dir="rtl"] .cai-ico--dir { transform: scaleX(-1); }
.stage-title { font-size: 1rem; font-weight: 600; color: var(--text-body); margin: 0; }

/* The two wrappers draw no box of their own: the thread, the composer and the plan panel are the
   stage's items, so the composer's sticky range is the whole page and not just its own pane. */
.session, .thread-pane { display: contents; }
/* Last, always: a bottom-sticky box only holds back what is below the screen, so anything after
   it in the page would let it scroll away. */
form.compose { order: 9; }
#thread, #questions { display: flex; flex-direction: column; gap: 16px; }
#thread .card { margin: 0; }
.qcard { padding: 16px 18px; }
.qhead { display: flex; align-items: baseline; gap: .5rem; flex-wrap: wrap; }
.chip {
  font-size: .68rem; text-transform: uppercase; letter-spacing: .05em;
  padding: .12rem .4rem; border-radius: 4px; background: var(--surface-muted); color: var(--text-secondary);
}
.qopts { display: flex; flex-wrap: wrap; gap: 8px; margin-top: .7rem; }
.qopt {
  display: inline-flex; align-items: center; gap: .4rem;
  min-height: 34px; padding: 0 14px; border-radius: 999px;
  background: var(--surface-muted); border: 1px solid var(--border);
  font-size: 13px; cursor: pointer;
}
/* "Something else": the pill is the field. The page's text-input look (48px, its own border
   and corners) drew a box inside the pill; here the input is bare text in the pill's own
   size, the pill takes the rest of the row so the placeholder is not cut short, and focus is
   shown on the pill, in the inputs' accent border and halo. */
.qopt:has(> .qother) { flex: 1 1 18rem; cursor: text; }
.qopt input.qother {
  flex: 1 1 auto; min-width: 0; width: auto; height: 32px; padding: 0;
  border: 0; border-radius: 0; background: transparent; box-shadow: none;
  font-size: 13px; color: var(--text-primary);
}
.qopt input.qother:focus { border: 0; background: transparent; box-shadow: none; outline: none; }
.qopt:has(> .qother:focus) { border-color: var(--focus-ring); box-shadow: 0 0 0 3px var(--focus-halo); }
.qactions { display: flex; gap: .6rem; align-items: center; margin-top: .6rem; }
.qactions .ghost {
  background: none; border: 1px solid var(--border); color: var(--text-secondary); box-shadow: none;
}
.qstatus { font-size: .82rem; color: var(--text-tertiary); }
.qtext { font-size: .95rem; }
.qopt-label { font-weight: 500; }
.qopt-desc { color: var(--text-secondary); font-size: .82rem; }

form.compose {
  padding: 20px; border-radius: 22px;
  /* Solid: it floats over the report, and text must not show through. */
  background: var(--surface); border: 1px solid var(--border); box-shadow: none; display: flex; flex-direction: column; gap: 18px;
}
/* Three lines at rest, growing to six, then scrolling inside; the size is the page's, not the reader's.
   A scrolling field clips at its padding edge, and with no padding the top of a tall Persian
   letter (the second stroke of گ) was cut off where the font draws it above the line, as it
   does on macOS. So the field keeps a few pixels of room on every side (`--pad`) and gives
   them back in negative margins: the text sits where it did and only the clip moves out. */
form.compose textarea {
  --lh: 1.6em; --pad: 4px; font-size: 15px; line-height: 1.6;
  padding: var(--pad) calc(var(--pad) / 2); margin: calc(-1 * var(--pad)) calc(-1 * var(--pad) / 2);
  border: 0; background: transparent; box-shadow: none;
  resize: none; overflow-y: auto; field-sizing: content; caret-color: var(--accent-text); height: auto;
  min-height: calc(96px + 2 * var(--pad)); max-height: calc(6 * var(--lh) + 2 * var(--pad));
}
form.compose textarea:focus { background: transparent; border: 0; box-shadow: none; }
form.compose:focus-within { border-color: var(--selected-border); }
/* Nothing written yet: Send is frame 04's quiet square, not the accent button. */
form.compose:has(textarea:placeholder-shown) #send {
  background: var(--disabled-bg); border-color: transparent; box-shadow: none; color: var(--text-disabled);
}
.controls { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.attach {
  display: inline-flex; align-items: center; cursor: pointer;
  height: 32px; padding: 0 12px; border-radius: 10px;
  background: var(--surface-muted); border: 1px solid var(--border);
  color: var(--text-body); font-size: 12.5px; font-weight: 500;
}
.attach:focus-within { box-shadow: var(--ring); }
.attach input[type="file"] { position: absolute; width: 1px; height: 1px; opacity: 0; }
/* In the composer, Attach is frame 04's plain text button: no fill, no border, 62% white,
   a faint fill on hover. The file types it takes are its tooltip, not a line beside it. */
.controls .attach { background: none; border-color: transparent; color: var(--text-secondary); gap: 7px; transition: all var(--dur, .15s) var(--ease, ease); }
.attach-plus { font-size: 16px; line-height: 1; }
.controls .attach:hover { background: var(--hover-bg); color: var(--text-primary); }
/* The arrow centred in its square: the icon is a block, which a button's own centring does
   not move, so it sat against the button's start edge. */
#send {
  margin-inline-start: auto; width: 40px; height: 40px; padding: 0; border-radius: 12px; font-weight: 400; font-size: 17px;
  display: inline-flex; align-items: center; justify-content: center; flex: none;
}
/* Inside the composer, beside Send at the row's end: 12px, plain, no key caps. Under the card,
   where frame 04 drew it, it read as outside the box. It takes the row's free space so Send
   stays at the end; not shown where there is no keyboard to press it on, and Send then takes
   the space back. */
.send-hint {
  margin-inline-start: auto; line-height: 1;
  font-size: 12px; color: var(--text-tertiary); white-space: nowrap;
}
.send-hint + #send { margin-inline-start: 0; }
.send-hint kbd { min-width: 0; padding: 0; border: 0; background: none; font: inherit; color: inherit; }
@media (pointer: coarse) {
  .send-hint { display: none; }
  .send-hint + #send { margin-inline-start: auto; }
}

.attachments { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: .5rem; }
.attachment {
  display: inline-flex; align-items: baseline; gap: .5rem; max-width: 100%;
  padding: .3rem .6rem; border-radius: 10px;
  background: var(--surface-muted); border: 1px solid var(--border); font-size: .85rem;
}
.attachment.unreadable { border-color: var(--danger-fg); }
.attachment-name { overflow-wrap: anywhere; }
.attachment-note { color: var(--text-tertiary); font-size: .78rem; }
/* A file still being read, and one being taken off: present, and plainly not settled. */
.attachment.pending { border-style: dashed; }
.attachment.pending .attachment-name { color: var(--text-secondary); }
.attachment.removing { opacity: .5; }
.attach[aria-busy="true"] { cursor: progress; opacity: .7; }
.attachment-remove { background: none; border: 0; box-shadow: none; color: var(--text-secondary); padding: 0 .2rem; cursor: pointer; min-width: 1.75rem; min-height: 1.75rem; }

.share { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; }
/* Sharing on: a dialog in the middle of the screen (chat.html #share-on, chat-share.js), as
   Rename and Delete are. It used to open as a bar under the title, which read as the page
   moving on rather than asking something. The link runs the dialog's width, cut short on
   screen and whole when selected or copied, which is what it is for. */
dialog.share-dialog #share-url {
  width: 100%; box-sizing: border-box; height: 40px; padding: 0 .75rem; margin-block: 4px 0;
  font-family: var(--mono); font-size: .8rem; text-overflow: ellipsis;
  background: var(--surface-muted);
}
dialog.share-dialog .share-ask { display: flex; flex-direction: column; align-items: flex-start; gap: 10px; margin-block-start: 16px; }
dialog.share-dialog .share-ask[hidden], dialog.share-dialog .dialog-actions[hidden] { display: none; }

.plan-pane { padding: 28px 28px 20px; position: static; }
.plan-title { margin: 0 0 8px; font-size: 12px; letter-spacing: .12em; text-transform: uppercase; color: var(--plan-eyebrow-fg); }
.goal p { margin: .3rem 0 0; color: var(--text-secondary); }
.sections { margin: 12px 0 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 8px; }
/* The plan's language, under its sections: apart from the last card, not touching it. */
#language-row { margin-block-start: 20px; }
.section {
  padding: 14px 16px; border-radius: 16px;
  background: var(--surface-muted); border: 1px solid var(--border);
}
/* Title, then its summary on a line of its own: inline, the summary ran into the next
   title, and in Persian the number landed mid-sentence ("…و1. مقدمه"). */
.section-title { display: block; font-weight: 600; }
.section-summary { display: block; margin-block-start: 3px; font-size: .85rem; color: var(--text-secondary); }
.plan-value { font-size: .9rem; }
.revise { margin-block-start: .35rem; }
.revise-form { display: flex; flex-direction: column; gap: .35rem; margin-block-start: .3rem; }
.revise-form textarea { min-height: 4rem; font-size: .85rem; }
.run-controls { margin-top: 1rem; padding-top: .9rem; border-top: 1px solid var(--border); }
.run-controls-title { font-size: .75rem; color: var(--text-secondary); letter-spacing: .06em; text-transform: uppercase; cursor: pointer; }
summary.run-controls-title { list-style: none; }
summary.run-controls-title::-webkit-details-marker { display: none; }
.run-controls .control { min-width: 0; margin-top: .6rem; }
/* Level: the design's pill in the composer's control row ("✦ Standard ⌄", frame 04) and its
 * popover menu (frame 18). A row is a 30px icon tile, a name and a hint under it; the chosen row is
 * accent-selected with a trailing check. The menu opens upward — the composer is the bottom of the
 * page. Logical properties only, so Persian is the same row mirrored; the glyphs are never
 * flipped. */
.level-wrap { position: relative; }
.level-pill {
  height: 32px; padding: 0 12px; border-radius: 999px; display: inline-flex; align-items: center; gap: 7px;
  border: 1px solid var(--border); background: transparent; color: var(--text-body); box-shadow: none;
  font: 500 12.5px var(--sans); cursor: pointer; transition: all var(--dur) var(--ease);
}
.level-pill:hover { background: var(--hover-bg); }
.level-pill:disabled { cursor: default; opacity: .6; }
.level-spark { color: var(--accent-text); font-size: 12px; }
.level-caret { color: var(--text-tertiary); }
.level-menu {
  position: absolute; inset-block-end: calc(100% + 8px); inset-inline-start: 0; z-index: 20;
  width: min(300px, 86vw); padding: 8px; border-radius: 18px; display: flex; flex-direction: column; gap: 2px;
  background: var(--surface-raised); border: 1px solid var(--border); box-shadow: var(--shadow-float);
}
.level-menu[hidden] { display: none; }
.level-menu button {
  display: grid; grid-template-columns: 30px minmax(0, 1fr) 20px;
  grid-template-areas: "tile name check" "tile hint check"; column-gap: 12px; row-gap: 2px; align-items: center;
  padding: 8px 10px; border-radius: 12px; text-align: start; cursor: pointer;
  border: 1px solid transparent; background: transparent; box-shadow: none; color: var(--text-primary);
  font-weight: 400; transition: all var(--dur) var(--ease);
}
.level-menu button:hover { background: var(--hover-bg); }
.level-menu button[aria-checked="true"] { background: var(--selected-bg); }
.level-menu button:focus-visible { box-shadow: var(--ring); outline: 0; }
.level-tile {
  grid-area: tile; align-self: center; width: 30px; height: 30px; border-radius: 10px;
  display: flex; align-items: center; justify-content: center; font-size: 14px;
  background: var(--surface-muted); color: var(--text-body);
}
.level-menu button[aria-checked="true"] .level-tile { background: var(--surface); color: var(--selected-fg); }
.level-name { grid-area: name; font-size: 13.5px; font-weight: 600; color: var(--text-primary); }
.level-hint { grid-area: hint; font-size: 12px; line-height: 1.45; font-weight: 400; color: var(--text-tertiary); }
.level-check { grid-area: check; justify-self: end; align-self: center; color: var(--accent-text); font-size: 14px; }
.level-check .cai-ico { visibility: hidden; }
.level-menu button[aria-checked="true"] .level-check .cai-ico { visibility: visible; }

#confirm { margin-top: 1rem; }
#resume { margin-inline-start: 8px; }

/* ---- projects ---- */
.projects { display: flex; flex-direction: column; border-radius: 22px; overflow: hidden;
  background: var(--surface); border: 1px solid var(--border); box-shadow: none; }
.project {
  display: flex; align-items: center; gap: 16px; padding: 18px 22px;
  color: inherit; text-decoration: none; border-block-end: 1px solid var(--border-subtle);
}
.project:last-child { border-block-end: 0; }
.project:hover { background: var(--hover-bg); color: inherit; }
.project-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.project-title { font-weight: 600; color: var(--text-primary); }
.project-meta { font-size: 13px; color: var(--text-secondary); }
.project-when { width: 9rem; text-align: end; font-size: 12px; color: var(--text-tertiary); flex: none; }

/* ---- settings ---- */
.settings { width: min(760px, 100%); display: flex; flex-direction: column; gap: 18px; }
.settings .panel h2 { margin-bottom: 4px; }
.lang-choices { display: flex; gap: 10px; flex-wrap: wrap; }
.choice {
  flex: 1; min-width: 10rem; padding: 14px 16px; border-radius: 16px;
  background: var(--surface-muted); border: 1px solid var(--border);
  color: var(--text-body); display: flex; align-items: center; justify-content: space-between; text-decoration: none;
}
.choice.on { background: var(--accent-subtle); border-color: var(--accent-subtle-border); color: var(--text-primary); }
.choice .tick { color: var(--accent-text); }
.choice .rtl-tag { color: var(--text-tertiary); font-size: 12px; }

.tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-block: 4px 14px; }
.tabs a {
  padding: 8px 16px; border-radius: 999px; text-decoration: none; color: var(--text-body);
  background: var(--surface-muted); border: 1px solid var(--border);
}
.tabs a.on { background: var(--accent-subtle); border-color: var(--accent-subtle-border); color: var(--text-primary); }

.narrow { max-width: 26rem; }
.row-actions { display: flex; flex-wrap: wrap; gap: .35rem; align-items: center; }
.row-actions input[type="password"] { width: 11rem; }

.seat header strong { font-weight: 600; }
/* One compact row per job: what it is, who does it, what that costs. */
.card.seat { padding: 14px 18px; margin-block-end: 10px; }
.seat-row {
  display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1.2fr) auto;
  gap: 10px 20px; align-items: center;
}
.seat-row header { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.seat-row .controls { flex-wrap: nowrap; min-width: 0; }
.seat-row .control { min-width: 0; flex: 1; }
/* The column says what it is; the label stays for a screen reader. */
.seat-row .control label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
/* The writing seat ticks several models: one line each, the ids left-to-right. */
.seat .writers { border: 0; margin: 0; padding: 0; min-width: 0; flex: 1; display: flex; flex-direction: column; gap: 4px; }
.seat .writers legend { padding: 0; margin-block-end: 2px; font-size: .82rem; color: var(--text-secondary); }
.seat .writer { display: flex; align-items: center; gap: 8px; }
.seat .writer input { width: auto; margin: 0; }
.seat .writers small { color: var(--text-secondary); }
.seat-now { font: .85rem var(--mono); color: var(--text-body); white-space: nowrap; text-align: end; }
.seat-models { margin-block-start: 10px; }
.seat-models > summary { font-size: .82rem; color: var(--text-secondary); }
.seat-models[open] > summary { margin-block-end: 8px; }
.seat table { margin-top: .25rem; table-layout: fixed; }
.seat th:nth-child(1) { width: 26%; }
.seat th:nth-child(2) { width: 20%; }
.seat th:nth-child(3) { width: 12%; }
.seat th:nth-child(4) { width: 42%; }
.seat th, .seat td { white-space: normal; vertical-align: top; }
.seat td { overflow-wrap: anywhere; }
/* A price and a time are read whole. */
.seat td:nth-child(2), .seat td:nth-child(3) { white-space: nowrap; overflow-wrap: normal; }
.seat th:nth-child(4), .seat td.note { text-align: start; }
.seat summary { cursor: pointer; }
.seat tr.current td:first-child { border-inline-start: 3px solid var(--success-fg); }
.seat tr.current td { font-weight: 500; }

.compare-panel { margin-top: 1rem; }

/* What sits beside a report — the report, each model's own report, what reading them found, the
   report written from it — is a row of tabs and one pane at a time, each at the card's whole
   width. Two columns of a long report were about 390px each; a tab says that they are read one
   at a time anyway. The bar scrolls sideways inside itself, never the page. */
.compare-tabs {
  display: flex; gap: 4px; overflow-x: auto; scrollbar-width: thin;
  border-bottom: 1px solid var(--border);
}
button.compare-tab {
  flex: none; display: inline-flex; align-items: center; gap: .5rem; min-height: 0;
  margin-bottom: -1px; padding: .55rem .95rem; border-radius: 12px 12px 0 0;
  border: 1px solid transparent; border-bottom: 2px solid transparent;
  background: transparent; box-shadow: none; color: var(--text-secondary); font-size: .9rem; font-weight: 500;
  cursor: pointer; transition: color var(--dur) var(--ease), background var(--dur) var(--ease);
}
button.compare-tab:hover { color: var(--text-primary); background: var(--hover-bg); }
button.compare-tab[aria-selected="true"] {
  color: var(--text-primary); font-weight: 600; background: var(--selected-bg);
  border-color: var(--border); border-bottom-color: var(--accent);
}
.tab-label { white-space: nowrap; }
/* A model still writing, one that failed, a result nobody has opened — said without opening it. */
.tab-dot { flex: none; width: 8px; height: 8px; border-radius: 50%; }
.tab-dot:not(.running):not(.failed):not(.new) { display: none; }
.tab-dot.running { background: var(--warning-fg); animation: tab-pulse 1.4s ease-in-out infinite; }
.tab-dot.failed { background: var(--danger-fg); }
.tab-dot.new { background: var(--accent); box-shadow: 0 0 0 3px var(--accent-halo); }
@keyframes tab-pulse { 50% { opacity: .35; transform: scale(.8); } }
@media (prefers-reduced-motion: reduce) { .tab-dot.running { animation: none; } }

.compare { margin-top: 0; }
/* A pane. `display` here would beat the `hidden` attribute, so hidden is said again. */
.compare-col { min-width: 0; display: flex; flex-direction: column; padding: 16px 0 0; }
.compare-col[hidden] { display: none; }
.report-pane, .results-pane, .consensus { min-width: 0; }
/* The best-of report is a card made like any other and lives in a tab: no second frame round it,
   and no second comparison inside the one it came from. */
/* `!important` on the width because the "wide card" rule for a report with contents is more
   specific than this one and would push the card past the pane it is in. */
#report .best-pane > .card {
  width: auto !important; margin-inline: 0 !important; padding: 0; border: 0; background: none;
  box-shadow: none; border-radius: 0;
}
.compare-head { display: flex; align-items: baseline; flex-wrap: wrap; gap: .5rem; margin-bottom: .5rem; }
.compare-note { font-size: .78rem; color: var(--text-tertiary); }
/* What the server is still doing for a topic whose first report is already in. Readable rather
   than faint: it is the reason the topic still says it is writing. */
.ensemble-note, .consensus-coming, .best-coming { color: var(--text-body); margin: 0 0 8px; }
/* The Export of the report a tab shows, at the top of that tab. */
.pane-actions { display: flex; justify-content: flex-end; margin-block-end: 8px; }
.compare-who {
  font-size: .78rem; font-weight: 600; text-transform: uppercase; letter-spacing: .04em;
  overflow-wrap: anywhere;
}
/* The reading: three counts, a card for the report written from it, and a card each for what
   the models agree on, contradict and said once. Logical properties throughout, so the same rules
   serve a Persian page. */
.consensus-head { display: flex; align-items: center; flex-wrap: wrap; gap: .4rem .8rem; }
.consensus-title { margin: 0; font-size: 1.15rem; text-transform: none; letter-spacing: 0; color: var(--text-primary); }
.consensus-body { margin-top: .2rem; }
.consensus-caveat { margin: .5rem 0 0; }
.consensus-empty { margin: 0; font-size: .86rem; color: var(--text-tertiary); }
.consensus-dropped { margin: 1rem 0 0; }

.reading-tiles { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; margin: 14px 0 6px; }
button.reading-tile {
  --accent: var(--accent-text);
  display: flex; flex-direction: column; align-items: flex-start; gap: 2px; min-height: 0;
  padding: 12px 14px; border-radius: 16px; text-align: start; cursor: pointer; box-shadow: none;
  color: var(--text-body); font-weight: 400;
  background: linear-gradient(160deg, color-mix(in srgb, var(--accent) 17%, transparent), var(--surface-muted));
  border: 1px solid color-mix(in srgb, var(--accent) 40%, transparent);
  transition: transform var(--dur) var(--ease), border-color var(--dur) var(--ease);
}
button.reading-tile:hover { transform: translateY(-1px); border-color: var(--accent); color: var(--text-primary); }
button.reading-tile.differ { --accent: var(--warning-fg); }
button.reading-tile.alone { --accent: var(--indigo); }
.tile-num { font-size: 1.9rem; font-weight: 700; line-height: 1.1; color: var(--accent); font-variant-numeric: tabular-nums; }
.tile-label { font-size: .8rem; line-height: 1.3; overflow-wrap: break-word; hyphens: auto; }
@media (max-width: 40rem) {
  .reading-tiles { gap: 8px; }
  button.reading-tile { padding: 10px 10px; }
  .tile-num { font-size: 1.6rem; }
  .tile-label { font-size: .7rem; }
}

.insight-card {
  --accent: var(--accent-text); position: relative; margin-top: 14px; padding: 16px 18px; overflow: hidden;
  border-radius: 20px; background: var(--control-bg); border: 1px solid var(--control-border); box-shadow: none;
  scroll-margin-top: 16px;
}
/* Billing's Day / Month / Year land here (billing.html), clear of the screen's top edge. */
#activity { scroll-margin-top: 16px; }
.insight-card::before {
  content: ""; position: absolute; inset-block: 0; inset-inline-start: 0; width: 4px;
  background: var(--accent); opacity: .9;
}
.insight-card.differ { --accent: var(--warning-fg); }
.insight-card.alone { --accent: var(--indigo); }
.insight-card.flash { animation: insight-flash 1.2s var(--ease); }
@keyframes insight-flash {
  from { box-shadow: 0 0 0 0 color-mix(in srgb, var(--accent) 60%, transparent); }
  to { box-shadow: 0 0 0 14px transparent; }
}
.insight-head { display: flex; align-items: center; gap: 12px; }
.insight-icon {
  flex: none; display: grid; place-items: center; width: 38px; height: 38px; border-radius: 12px;
  color: var(--accent); background: color-mix(in srgb, var(--accent) 16%, transparent);
  border: 1px solid color-mix(in srgb, var(--accent) 32%, transparent);
}
.insight-words { min-width: 0; flex: 1; }
.insight-title { margin: 0; font-size: 1.05rem; font-weight: 600; text-transform: none; letter-spacing: 0; }
.insight-hint { margin: 2px 0 0; font-size: .8rem; color: var(--text-secondary); }
.insight-count {
  flex: none; min-width: 2.2rem; padding: .2rem .7rem; border-radius: 999px; text-align: center;
  font-weight: 700; font-variant-numeric: tabular-nums; color: var(--accent);
  background: color-mix(in srgb, var(--accent) 16%, transparent);
}
.insight-body { margin-top: 12px; }

.consensus-list { list-style: none; margin: 0; padding: 0; display: grid; gap: .6rem; }
.consensus-point, .consensus-side {
  min-width: 0; padding: .75rem .9rem; border-radius: 14px;
  background: var(--surface-muted); border: 1px solid var(--border-subtle);
}
.consensus-text { display: block; margin: 0; overflow-wrap: anywhere; }
.consensus-dispute + .consensus-dispute { margin-top: 1rem; }
.consensus-topic { margin: 0; font-weight: 600; overflow-wrap: anywhere; }
.consensus-sides { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 14rem), 1fr)); gap: .6rem; margin-top: .5rem; }
.who-row { display: flex; flex-wrap: wrap; gap: .4rem; margin-top: .45rem; }
.who-cell { display: flex; flex-direction: column; align-items: flex-start; gap: .3rem; min-width: 0; max-width: 100%; }
/* A model's name is Latin text and stays one run of it, in either direction. */
.who-chip {
  font-size: .74rem; padding: .12rem .55rem; border-radius: 999px; unicode-bidi: isolate;
  background: var(--accent-subtle); border: 1px solid var(--accent-subtle-border); color: var(--accent-text);
  overflow-wrap: anywhere;
}
button.who-chip { cursor: pointer; box-shadow: none; font-weight: 500; min-height: 0; }
button.who-chip:hover { color: var(--text-primary); background: var(--hover-bg); }
.who-quote {
  margin: 0; padding: .45rem .65rem; max-width: 100%; border-radius: 8px; font-size: .88rem;
  border-inline-start: 3px solid var(--accent-subtle-border); background: var(--surface-muted); overflow-wrap: anywhere;
}
.who-find { display: block; margin-top: .35rem; font-size: .76rem; }
::highlight(consensus-quote) { background: var(--warning-bg); color: inherit; }

.best-of-mark, .best-of-unlinked { margin-inline-start: .6rem; }

/* The round of replies: the outcome of each dispute and lone point, the side still held, and what
   each model said. Read-only: nothing here is pressed to start or retry it. */
.outcome {
  display: inline-block; margin: .45rem 0 0; padding: .1rem .55rem; border-radius: 999px;
  font-size: .74rem; font-weight: 600; border: 1px solid var(--border);
  background: var(--surface-muted); color: var(--text-body);
}
.consensus-topic .outcome { margin: 0; margin-inline-start: .4rem; vertical-align: middle; }
.outcome.resolved, .outcome.confirmed { color: var(--success-fg); background: var(--success-bg); border-color: var(--success-border); }
.outcome.narrowed, .outcome.mixed { color: var(--warning-fg); background: var(--warning-bg); border-color: var(--warning-border); }
.outcome.contested, .outcome.disputed { color: var(--danger-fg); background: var(--danger-bg); border-color: var(--danger-border); }
p.outcome { display: block; width: fit-content; max-width: 100%; font-weight: 500; }
.consensus-side.held { border-color: var(--accent-subtle-border); }
.consensus-side.conceded { opacity: .62; }
.argue-note { margin: .2rem 0 .6rem; }
.argue-said { margin-top: .5rem; font-size: .88rem; }
.argue-said > summary { cursor: pointer; color: var(--text-secondary); font-size: .8rem; }
.argue-row { margin-top: .5rem; padding-inline-start: .6rem; border-inline-start: 2px solid var(--border); }
.argue-row .consensus-text { margin-top: .25rem; }

@media (max-width: 56rem) {
  /* Stretch, not the desktop `flex-start`: in a column that means "size to your content",
     and `main` took the width of the widest table in it and carried the page sideways. */
  .shell { flex-direction: column; align-items: stretch; }
  .sidebar { width: auto; height: auto; position: static; }
  .nav { flex-direction: row; flex-wrap: wrap; }
  main { padding: 24px 16px 64px; }
  .connection { margin: -24px -16px 16px; padding-inline: 16px; }
  .continue-list { grid-template-columns: 1fr; }
  .seat-row { grid-template-columns: minmax(0, 1fr); }
  .seat-now { text-align: start; }
  /* Above the page rather than beside it, the list would push the page off the first
     screen. Topics is one tap away and the home page shelves the newest. */
  .sidebar #recent { display: none; }
  .project { flex-wrap: wrap; }
  .project-when { width: auto; text-align: start; }
}

/* ---- a wait in progress ----
   Three dots, a word for what is happening, a clock; in-progress amber, the same one the
   running badge uses. The dots are the only thing that moves, and they stop when the work
   does — `.stopped` is a wait this page has stopped hearing about, which keeps its clock
   but must not look alive. Built by waiting.js. */
.waiting {
  display: inline-flex; align-items: baseline; flex-wrap: wrap; gap: 0 8px;
  font-size: .86rem; color: var(--text-secondary);
}
#thread > .waiting { display: flex; padding: 10px 4px; }
.waiting .dots { display: inline-flex; gap: 4px; align-self: center; }
.waiting .dot {
  width: 6px; height: 6px; border-radius: 50%; background: var(--warning-fg);
  animation: waiting-dot 1.2s ease-in-out infinite;
}
.waiting .dot:nth-child(2) { animation-delay: .15s; }
.waiting .dot:nth-child(3) { animation-delay: .3s; }
.waiting.stopped .dot { animation: none; opacity: .35; }
.waiting .phase { color: var(--text-body); }
.waiting .detail { overflow-wrap: anywhere; }
.waiting .detail:empty { display: none; }
.waiting .elapsed { font-variant-numeric: tabular-nums; color: var(--text-tertiary); }
.revision-wait, .gate-wait:not(:empty) { margin: 6px 0 10px; }
.section.pending { animation: pending-pulse 1.6s ease-in-out infinite; }
@keyframes waiting-dot {
  0%, 80%, 100% { opacity: .25; transform: translateY(0); }
  40% { opacity: 1; transform: translateY(-3px); }
}
.plan-pane.pending :is(#goal, #sections, #plan-empty) { animation: pending-pulse 1.6s ease-in-out infinite; }
@keyframes pending-pulse { 0%, 100% { opacity: 1; } 50% { opacity: .45; } }
@media (prefers-reduced-motion: reduce) {
  .waiting .dot { animation: none; opacity: .7; }
  .plan-pane.pending :is(#goal, #sections, #plan-empty) { animation: none; opacity: .6; }
  .section.pending { animation: none; opacity: .6; }
  .btn, .btn:active, .new-project:hover, .continue-list .recent-item:hover { transition: none; transform: none; }
}

/* Keyboard focus: every control gets a ring that reads on the surface, not the browser default.
   What is pressed takes the design's --ring, a shadow that follows the control's radius and
   wins over its own shadow; the design drops it while the pointer is over the control, which
   would leave a keyboard user with no mark wherever the mouse happens to rest, so it stays.
   A field keeps an outline, which its own inset look does not fight. */
a:focus-visible, button:focus-visible, summary:focus-visible { outline: none; box-shadow: var(--ring) !important; }
input:focus-visible, textarea:focus-visible, select:focus-visible { outline: none; }
/* A checkbox has no field look of its own to carry a focus mark, so it takes the ring. */
input[type="checkbox"]:focus-visible { box-shadow: var(--ring); }

.badge.stopped { color: var(--text-tertiary); background: var(--surface-muted); border-color: var(--border); }

/* ---- the page losing its hold on the service (static/connection.js) ----
   The amber row is progress, not failure: it clears itself. */
.connection {
  position: sticky; top: 0; z-index: 10; margin: -36px -40px 24px; padding: 10px 40px;
  background: var(--warning-bg); border-block-end: 1px solid var(--warning-border);
  color: var(--warning-fg); font-size: .88rem; font-weight: 500;
}
.signed-out {
  position: fixed; inset: 0; z-index: 50; display: flex; align-items: center; justify-content: center;
  padding: 16px; background: var(--canvas);
}
.signed-out-card {
  width: min(420px, 100%); padding: 36px; display: flex; flex-direction: column; gap: 12px; align-items: flex-start;
  border-radius: var(--r-card); background: var(--surface); border: 1px solid var(--border);
  box-shadow: none;
}
.signed-out-card h1 { font-size: 1.4rem; margin: 0; }
.signed-out-card .btn { margin-block-start: 8px; }

/* A topic that is not there. */
.missing {
  width: min(560px, 100%); margin: 12vh auto 0; display: flex; flex-direction: column; gap: 10px;
}
.missing-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-block-start: 10px; }

/* An export in flight, and one that failed, with its reason under the row. */
.exports a[aria-busy="true"] { opacity: .55; cursor: progress; }
.exports a.failed { color: var(--danger-fg); border-color: var(--danger-border); }
.export-note { flex-basis: 100%; font-size: .82rem; color: var(--danger-fg); }

/* What the research is looking at, folded under the wait. */
.reading { margin: 6px 0 0; font-size: .86rem; color: var(--text-secondary); }
.reading summary { cursor: pointer; }
.reading-list { list-style: none; margin: 6px 0 0; padding: 0; max-height: 11rem; overflow-y: auto; }
.reading-list li { padding: 2px 0; }
.reading-kind { color: var(--text-secondary); }
.reading-what { color: var(--text-body); overflow-wrap: anywhere; }

/* What the report stands on, one quiet line above its text; the amber caveat below is for
 * the report that read nothing. */
.standing { margin: 2px 0 10px; font-size: .86rem; color: var(--text-secondary); }

/* A report whose research read no web page: a warning, not a failure, so amber. */
.sources-caveat {
  margin: 4px 0 14px; padding: 12px 14px; border-radius: 12px;
  background: var(--warning-bg); border: 1px solid var(--warning-border);
  border-inline-start: 3px solid var(--warning-fg);
  color: var(--text-body); font-size: .9rem; line-height: 1.55;
}
.sources-caveat strong { color: var(--warning-fg); font-weight: 600; }
.flag { margin-block: 22px; padding-block-end: 14px; border-block-end: 1px solid var(--border-subtle); }

/* The claim check on a report (static/chat-ledger.js): a quiet panel above the answer, never red;
   it points at sentences and does not judge the report. Logical properties only, so it mirrors. */
.ledger {
  margin: 4px 0 14px; padding: 10px 14px; border-radius: 12px;
  background: var(--surface-muted); border: 1px solid var(--border);
  border-inline-start: 3px solid var(--text-secondary);
  color: var(--text-body); font-size: .9rem; line-height: 1.55;
}
.ledger > summary { cursor: pointer; font-weight: 600; }
.ledger-how { margin: 8px 0; color: var(--text-secondary); font-size: .84rem; }
.ledger-group { margin-block: 8px; }
.ledger-group > summary { cursor: pointer; }
.ledger-list { margin: 6px 0 0; padding-inline-start: 1.2rem; }
.ledger-row { margin-block: 6px; }
.ledger-sentence { overflow-wrap: anywhere; }
.ledger-pointer { margin: 8px 0; color: var(--text-secondary); font-size: .88rem; }
.rating { margin-block: 12px; display: flex; flex-wrap: wrap; align-items: center; gap: 8px; font-size: .9rem; }
.rating-ask { color: var(--text-secondary); }
.rating button[aria-pressed="true"] { outline: 2px solid currentColor; }
.rating-thanks { color: var(--text-secondary); font-size: .84rem; }
.ledger-source { margin-inline-start: 4px; font-size: .84rem; white-space: nowrap; }
.badge.estimates { color: var(--warning-fg); background: var(--warning-bg); border-color: var(--warning-border); }

/* A shared topic, read by link (templates/shared.html): a bar in place of the sidebar, and
   the page at reading width rather than the sign-in card's. */
.reader-bar { border-block-end: 1px solid var(--border-subtle); background: var(--surface-muted); }
.reader-label { color: var(--text-secondary); font-size: .85rem; }
.reader-actions { margin-inline-start: auto; }
.reader-actions .exports { margin: 0; }
body:has(.reader-bar) main { width: min(880px, 100%); margin-inline: auto; padding-block-start: 32px; }

/* Users: Make admin and Disable as text links; Set password and Add credit as buttons, each
   opening its row's dialog (templates/users.html, static/users.js). */
/* At the cell's start, under the Manage heading as every other column's figures are under
   theirs (a flex row ignores the cell's own text-align). */
.row-tools { display: flex; flex-wrap: nowrap; align-items: center; justify-content: flex-start; gap: 8px 16px; text-align: start; }
.row-tools > .row-actions { display: inline-flex; flex-wrap: nowrap; gap: 14px; }
.row-tools > button.row-open { padding: .4rem .8rem; font-size: .82rem; white-space: nowrap; }
/* One line on a phone too, so a row is one row high: the table scrolls sideways in its
   .wrap rather than stacking the buttons. */
/* A dialog drawn inside a table cell takes the dialog's own alignment, not the cell's. */
dialog.row-dialog { text-align: start; white-space: normal; }
dialog.row-dialog form.stack { max-width: none; gap: 12px; }
dialog.row-dialog .dialog-actions { margin-block-start: 4px; }
/* Each of the Users page's sections (Invite someone, Invitations, Add a user with a password)
   stands apart from the form above it; with no space the two forms read as one. */
h2.page-section { margin-block-start: 40px; }

/* ---- the conversation, as the design draws it (frames 05, S3) ----
   What the person said is their own bubble, on the side the language ends on; what the
   system said is plain text beside its mark. The "you" / app-name labels stay in the
   markup for a screen reader and are drawn nowhere. */
#thread > .card { margin: 0; }
#thread > .card > .who {
  position: absolute; width: 1px; height: 1px; margin: -1px; overflow: hidden;
  clip-path: inset(50%); white-space: nowrap;
}
/* What the person said is on the right in either language, as a chat draws one's own words:
   at the start of an English page it stood on the left, under the system's mark, and read as
   someone else's. The squared corner is the bottom right, the side it hangs from. */
#thread > .card.mine {
  align-self: flex-end; max-width: min(78%, 36rem); padding: 14px 20px; border-radius: 18px;
  background: var(--bubble-user-bg); border: 1px solid var(--bubble-user-border); border-bottom-right-radius: 6px; box-shadow: none;
}
/* A column's cross end is its inline end, the left on a Persian page: the start there. */
[dir="rtl"] #thread > .card.mine { align-self: flex-start; }
#thread > .card:not(.mine) {
  display: grid; grid-template-columns: 30px minmax(0, 1fr); column-gap: 14px;
  padding: 0; background: none; border: 0; box-shadow: none;
}
#thread > .card:not(.mine)::before {
  content: ""; grid-column: 1; grid-row: 1 / span 20; align-self: start;
  width: 30px; height: 30px; background: url(/theme-static/logo-mark.png) center / contain no-repeat;
}
#thread > .card:not(.mine) > * { grid-column: 2; }
#thread > .card:not(.mine) > header { display: flex; align-items: center; gap: 8px; }

/* The header: the topic, where it is, and — for a report on its way — the stages. */
#stage-status { flex: none; }
/* Title and chip together at the start, Share at the end: spread apart, a Persian title on
   an English page sat against Share, away from the way back. */
.stage-head { justify-content: flex-start; }
.stage-head .stage-title { flex: 0 1 auto; min-width: 0; }
.stage-actions { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; margin-inline-start: auto; }
/* Nothing in it on a new topic: no empty row on a phone. */
.stage-actions:not(:has(> :not([hidden]))) { display: none; }
/* Empty until there is something to say, and then still a gap between two buttons. */
.share #share-note:empty { display: none; }
.topic-actions { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; }
.topic-actions[hidden] { display: none; }
.topic-actions .danger-text { color: var(--danger-fg); }
.stepper {
  display: flex; align-items: center; justify-content: center; flex-wrap: wrap; gap: 6px 10px;
  list-style: none; margin: 0 auto; padding: 8px 16px; border-radius: 999px; width: fit-content; max-width: 100%;
  background: var(--surface-muted); border: 1px solid var(--border);
  font-size: 11px; font-weight: 600; letter-spacing: .1em; text-transform: uppercase; color: var(--text-secondary);
}
.stepper li { display: inline-flex; align-items: center; gap: 7px; }
/* Writing, once the report stands (chat-wizard.js); the rule above would otherwise keep it. */
.stepper li[hidden] { display: none; }
.stepper li::before {
  content: ""; width: 7px; height: 7px; border-radius: 50%; border: 1.5px solid var(--text-tertiary);
}
.stepper li + li::after { content: none; }
.stepper li + li { padding-inline-start: 10px; border-inline-start: 1px solid var(--border); }
.stepper li.done { color: var(--text-body); }
.stepper li.done::before { background: var(--accent); border-color: var(--accent); }
.stepper li[aria-current="step"] { color: var(--text-primary); }
.stepper li[aria-current="step"]::before { background: var(--accent); border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-halo); }

/* A step that has been reached is a button that opens it; one not reached yet is a word. */
.stepper button.step {
  all: unset; cursor: pointer; display: inline-flex; align-items: center; gap: 7px;
  font: inherit; letter-spacing: inherit; text-transform: inherit; color: inherit;
  border-radius: 999px; padding: 2px 6px; margin: -2px -6px;
}
.stepper button.step:disabled { cursor: default; }
.stepper li.reached button.step:not(:disabled):hover { color: var(--text-primary); background: var(--hover-bg); }
/* The dot is the item's, so it stays put whether the step is a button or a word. */
.stepper li:has(button[aria-current="step"]) { color: var(--text-primary); }
.stepper li:has(button[aria-current="step"])::before {
  background: var(--accent); border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-halo);
}

/* ---- the page by step (chat-wizard.js sets `data-view` on .stage) ----
   One step on screen at a time. A plain chat has no `data-view` and none of this applies. */
.wizard-heading { scroll-margin-top: 16px; margin: 0; font-size: 1.35rem; letter-spacing: -.01em; outline: none; }
.wizard-request:empty { display: none; }
.wizard-card {
  padding: 24px 28px; border-radius: 18px; display: flex; flex-direction: column; gap: 8px;
  background: var(--surface); border: 1px solid var(--border); box-shadow: none;
}
.wizard-goal { margin: 0; font-size: 1.05rem; color: var(--text-body); }
.wizard-card .meta { margin: 0; }
.answered { display: flex; flex-direction: column; gap: 10px; }
.answered-title { margin: 0; font-size: .75rem; color: var(--text-secondary); text-transform: uppercase; letter-spacing: .08em; }
.answered-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.answered-row {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px 12px; align-items: start;
  padding: 12px 16px; border-radius: 14px; background: var(--surface); border: 1px solid var(--border);
}
.answered-q { grid-column: 1; color: var(--text-secondary); font-size: .88rem; }
.answered-a { grid-column: 1; color: var(--text-primary); }
.answered-row > .ghost { grid-column: 2; grid-row: 1 / span 2; align-self: center; }
.answered-edit { grid-column: 1 / -1; display: flex; flex-direction: column; gap: 6px; }
.answered-edit textarea { width: 100%; min-height: 3.2rem; }
.wizard-foot { display: flex; align-items: center; gap: 10px; }
.wizard-foot .next { margin-inline-start: auto; }
.wizard-foot .foot-note { margin: 0; color: var(--muted, inherit); font-size: 0.9em; }
.conversation > summary { cursor: pointer; color: var(--text-secondary); font-size: .88rem; padding-block: 4px; width: fit-content; }
.conversation > summary:hover { color: var(--text-primary); }
.conversation > summary .count:not(:empty)::before { content: "· "; }
.conversation[open] > summary { margin-block-end: 12px; }
.stage:not([data-view]) .conversation > summary { display: none; }

/* What each step shows: everything that belongs to another step is put away. */
.stage[data-view]:not([data-view="request"]) .wizard-request,
.stage[data-view]:not([data-view="clarify"]) :is(#questions, .answered, .wizard-clear),
.stage[data-view]:not([data-view="plan"]) .plan-pane,
.stage:is([data-view="request"], [data-view="clarify"], [data-view="plan"]) > #report { display: none !important; }

/* In order, on every step: the step's own content, the way back and on, the conversation, and
   the composer last (main's rule: a bottom-sticky box must be the last thing on the page). The
   two wrappers draw no box, so these are all the stage's own items. */
.stage[data-view] :is(.wizard-request, .wizard-clear, #questions, .answered, .plan-pane),
.stage[data-view] > #report { order: 1; }
.stage[data-view] .wizard-foot { order: 2; }
.stage[data-view] .conversation { order: 3; }

/* The outline is the plan step's main object, drawn as a card. */
.stage[data-view="plan"] .plan-pane {
  padding: 32px; background: var(--surface); border-color: var(--border); box-shadow: none;
}
.stage[data-view="plan"] .plan-pane #goal-text { font-size: 1.05rem; color: var(--text-body); }

/* The composer stays at the foot of the screen, so the next thing to say is never a
   scroll away; on a short page margin-top:auto carries it down there. Its solid base is
   what keeps a step's questions from showing through it. */
form.compose { position: sticky; bottom: 16px; z-index: 4; margin-top: auto; }

/* On a step of the journey the composer is a side path — "Optional — add anything the questions
   above don't cover" — and the full box (a 96px field and a row of controls, about 200px) sat over
   the step's own content. At rest it is one line with only Send, and it opens to the full box the
   moment it has focus, text or a file: `:focus-within` also holds it open while the level menu or
   the file picker is in use. A plain chat has no `data-view` and keeps the full box; so does a
   new topic, where the composer is the page. */
.stage[data-view] form.compose:not(:focus-within, :has(textarea:not(:placeholder-shown)), :has(#attachments:not([hidden]))) {
  flex-direction: row; align-items: center; gap: 10px;
  padding-block: 8px; padding-inline: 18px 8px; border-radius: 16px;
}
.stage[data-view] form.compose:not(:focus-within, :has(textarea:not(:placeholder-shown)), :has(#attachments:not([hidden]))) textarea {
  flex: 1; min-width: 0; min-height: calc(var(--lh) + 2 * var(--pad)); max-height: calc(var(--lh) + 2 * var(--pad)); overflow: hidden;
}
.stage[data-view] form.compose:not(:focus-within, :has(textarea:not(:placeholder-shown)), :has(#attachments:not([hidden]))) textarea::placeholder {
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.stage[data-view] form.compose:not(:focus-within, :has(textarea:not(:placeholder-shown)), :has(#attachments:not([hidden]))) :is(.controls > :not(#send), .send-hint) {
  display: none;
}

/* A new topic: the question, then the composer, in the middle of the page. */
.compose-hero { text-align: center; display: flex; flex-direction: column; gap: 8px; margin-block: auto 28px; }
.compose-hero h2 { font-size: clamp(1.8rem, 3.4vw, 2.5rem); letter-spacing: -.02em; margin: 0; }
.thread-pane:has(#thread .card) .compose-hero,
.thread-pane:has(#thread .card) .prompt-chips { display: none; }
.prompt-chips { order: 10; display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; margin-block: 28px auto; }
/* On a new topic the composer is not pinned to the foot: it sits under the question, the chips
   under it, and the three are centred in the page together, as frame 04 draws it. */
.thread-pane:has(.compose-hero):not(:has(#thread .card)) form.compose { position: relative; margin-top: 0; 
  /* Nothing scrolls behind it here, so it is frame 04's plain surface. */
  background: var(--surface); }
.prompt-chip {
  height: 34px; padding: 0 16px; border-radius: 999px; cursor: pointer;
  background: var(--control-bg); border: 1px solid var(--control-border); box-shadow: none; font: 500 13px var(--sans); color: var(--text-body);
  transition: transform var(--dur) var(--ease), color var(--dur) var(--ease);
}
.prompt-chip:hover { transform: translateY(-1px); color: var(--text-primary); }

/* ---- the report (frame 09): its contents beside it, its copies behind one Export ---- */
#report .card:has(> .report-contents:not([hidden])) {
  --wide: min(1180px, calc(100vw - 280px - 80px));
  width: var(--wide);
  margin-inline: calc((100% - var(--wide)) / 2);
  display: grid; grid-template-columns: 210px minmax(0, 1fr); column-gap: 32px;
}
#report .card:has(> .report-contents:not([hidden])) > * { grid-column: 2; }
/* As specific as the rule above that sends every child to column 2, or it loses to it. */
#report .card:has(> .report-contents:not([hidden])) > .report-contents {
  grid-column: 1; grid-row: 1 / span 20; align-self: start;
  position: sticky; top: 24px; font-size: .86rem;
}
.contents-title { font-size: 11px; font-weight: 600; letter-spacing: .12em; text-transform: uppercase; color: var(--text-tertiary); margin-block-end: 8px; }
.contents-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }
.contents-list a { display: block; padding: 6px 10px; border-radius: 10px; border-inline-start: 2px solid transparent; color: var(--text-secondary); text-decoration: none; line-height: 1.4; }
.contents-list a:hover { color: var(--text-primary); background: var(--hover-bg); }
/* The section being read (chat.js watchContents). A bar on the inline start, so Persian
   carries it on the right. */
.contents-list a[aria-current] {
  color: var(--text-primary); font-weight: 600; background: var(--surface-muted);
  border-inline-start-color: var(--accent);
}
/* A comparison's tabs each carry their own contents (chat-rounds.js gives each writer
   its own tab, each making its own contents), so the card is as wide
   as one with contents beside it, and the columns are the tab's. The card itself stays a
   block: its children are the tabs, not the report. */
#report .card:has(> .compare-panel:not([hidden]) .report-contents:not([hidden])) {
  --wide: min(1180px, calc(100vw - 280px - 80px));
  width: var(--wide);
  margin-inline: calc((100% - var(--wide)) / 2);
}
#report .card:has(> .compare-panel:not([hidden])) { display: block; }
/* The rows around a card that breaks out wider than the stage break out with it, so their
   ends are the card's ends: the Report and Runs tabs, the topic's own row (title and status
   at the start; Share, Rename and Delete at the end), the step's heading ("Report") and,
   under the card, the steps' Back row, the folded conversation and the composer. In the
   stage's own column they stood 50-100px inside the card's edges, which read as floating
   in the middle of what is under or over them. The rows under the card are not the stage's
   children in the markup, but `.session` and `.thread-pane` are `display: contents`, so the
   stage lays them out and their 100% is the stage's width.
   The stepper stays centred. Not on a phone, where the card does not break out (below). */
@media (min-width: 56.01rem) {
  /* The card's width, set apart from the rule that uses it: that one names #report, and an
     id would outweigh the rail's override. */
  .stage :is(.stage > .tabs, .stage > .stage-head, .stage > .wizard-heading, .wizard-foot, .conversation, form.compose) {
    --wide: min(1180px, calc(100vw - 280px - 80px));
  }
  :root[data-sidebar="rail"] .stage :is(.stage > .tabs, .stage > .stage-head, .stage > .wizard-heading, .wizard-foot, .conversation, form.compose) {
    --wide: min(1180px, calc(100vw - 72px - 80px));
  }
  .stage[data-view="report"]:is(
    :has(#report .card > .report-contents:not([hidden])),
    :has(#report .card > .compare-panel:not([hidden]) .report-contents:not([hidden]))
  ) :is(.stage > .tabs, .stage > .stage-head, .stage > .wizard-heading, .wizard-foot, .conversation, form.compose) {
    width: var(--wide);
    margin-inline: calc((100% - var(--wide)) / 2);
  }
}
.compare-col:not([hidden]):has(> .report-contents:not([hidden])) {
  display: grid; grid-template-columns: 210px minmax(0, 1fr); column-gap: 32px;
}
.compare-col:has(> .report-contents:not([hidden])) > * { grid-column: 2; }
.compare-col:has(> .report-contents:not([hidden])) > .report-contents {
  grid-column: 1; grid-row: 1 / span 20; align-self: start;
  position: sticky; top: 24px; font-size: .86rem;
}

.export-menu { position: relative; }
.export-menu > summary {
  list-style: none; cursor: pointer; font-size: .75rem; font-weight: 600; color: var(--on-accent);
  display: inline-flex; align-items: center; gap: 4px;
  padding: .25rem .8rem; border-radius: 999px; background: var(--accent); border: 1px solid transparent;
}
.export-menu > summary::-webkit-details-marker { display: none; }
.export-list {
  position: absolute; inset-inline-end: 0; top: calc(100% + 6px); z-index: 6; min-width: 11rem;
  display: flex; flex-direction: column; gap: 2px; padding: 6px;
  border-radius: 14px; background: var(--surface-raised); border: 1px solid var(--border); box-shadow: var(--shadow-float);
}
.exports .export-list a { border: 0; background: none; border-radius: 10px; padding: 8px 12px; font-size: .85rem; }
.exports .export-list a:hover { background: var(--hover-bg); }

/* After the rules above, which it has to overrule: stacked on a phone, the report is the
   card and nothing beside it. */
@media (max-width: 56rem) {
  #report .card:has(> .report-contents:not([hidden])),
  #report .card:has(> .compare-panel:not([hidden]) .report-contents:not([hidden])) {
    width: auto; margin-inline: 0; display: block;
  }
  #report .card > .report-contents, .compare-col > .report-contents { display: none; }
  .compare-col:not([hidden]):has(> .report-contents:not([hidden])) { display: flex; }
}

/* ---- credit (templates/billing.html, static/wallet.js) ---- */
.credit-chip {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 8px 12px; border-radius: 12px; text-decoration: none;
  background: var(--control-bg); border: 1px solid var(--control-border); color: var(--text-secondary); font-size: 12px;
}
.credit-chip:hover, .credit-chip.active { color: var(--text-primary); border-color: var(--accent-subtle-border); }
.credit-figure { font: 500 13px var(--mono); color: var(--accent-text); }
.credit-unit { font-size: 11px; color: var(--text-secondary); }
.credit-chip.empty .credit-figure { color: var(--danger-fg); }
.credit-chip.low .credit-figure { color: var(--warning-fg); }
.wallet-balance { display: flex; flex-direction: column; gap: 6px; }
/* Smaller on a phone, where a nine-digit balance and its unit ran out of the card at 2.4rem;
   and should even that not fit, the unit goes under the figure rather than past the edge. */
.wallet-figure { font-size: clamp(1.6rem, 7.5vw, 2.4rem); font-weight: 600; letter-spacing: -.02em; color: var(--accent-text); min-width: 0; }
.wallet-figure .money { white-space: normal; }
.wallet-balance.empty .wallet-figure { color: var(--danger-fg); }
.notice-empty { color: var(--danger-fg); margin: 0; }
/* A figure and its unit stay on one line: "250,000" with "Toman" wrapped away reads as a count. */
.money { white-space: nowrap; }
.wallet-pay { display: flex; flex-direction: column; gap: 10px; }
.wallet-pay h2 { margin: 0; }
.pay-form { display: flex; flex-direction: column; gap: 10px; }
.pay-presets { display: flex; flex-wrap: wrap; gap: 8px; }
.pay-custom { display: flex; align-items: center; gap: 8px; }
.pay-custom input { flex: 1; max-width: 220px; }
/* `.notice` further down is an error box; a payment that went through, or is still being
   confirmed, must not read as one. Doubled for the specificity that outranks it. */
.notice.notice-paid { background: var(--accent-subtle); border-color: var(--accent-subtle-border); }
.notice.notice-pending { background: var(--warning-bg); border-color: var(--warning-border); }
.notice-failed, .notice-amount, .notice-bank { color: var(--danger-fg); }
.wallet-payments tr.failed td { color: var(--text-secondary); }
.wallet-activity tr.grant td, .wallet-activity tr.opening td { color: var(--success-fg); }

/* ---- profile (design N2) ---- */
img.avatar { object-fit: cover; padding: 0; }
.avatar-lg { width: 72px; height: 72px; font-size: 24px; }
.account-id { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.account-name { font-size: 13px; font-weight: 500; color: var(--text-primary); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.profile-form { gap: 18px; }
.photo-pick { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.photo-chosen { overflow-wrap: anywhere; }
.profile-face { display: flex; align-items: center; gap: 20px; flex-wrap: wrap; }
.profile-face .control { flex: 1 1 16rem; }
.home-hello { margin: 0; color: var(--text-secondary); font-size: 1.05rem; }

/* Read by a screen reader, drawn nowhere. */
.sr-only { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0; }

/* Help on a phone: the name above its explanation. After `.help dl`, which it overrules. */
@media (max-width: 56rem) {
  .help dl { grid-template-columns: 1fr; gap: .2rem; }
  .help dd { margin-block-end: .6rem; }
}

/* ---- empty states (design: Component · EmptyState) ----
   One skeleton in three sizes: a page (72 tile, 480 wide, centred), a block that fills a
   card or a list, and an inline banner inside content. The icon is drawn bare, in the muted
   icon colour: the accent is for what acts, and an empty state is not an action. A
   primary button only when there is exactly one thing to do. */
.empty-state {
  display: flex; flex-direction: column; align-items: center; text-align: center; gap: 10px;
}
.empty-state.page { width: min(480px, 100%); margin: 10vh auto 0; }
.empty-state.block { padding: 40px 24px; }
.empty-glyph {
  width: 56px; height: 56px; border-radius: 18px; flex: none;
  display: flex; align-items: center; justify-content: center;
  background: none; border: 0; box-shadow: none;
  color: var(--icon-muted); font-size: 22px; margin-block-end: 6px;
}
.empty-state.page .empty-glyph { width: 72px; height: 72px; border-radius: 22px; font-size: 28px; }
.empty-title { margin: 0; font-size: 1.25rem; font-weight: 600; color: var(--text-primary); letter-spacing: -.01em; text-transform: none; }
.empty-state.page .empty-title { font-size: 1.5rem; }
.empty-body { margin: 0; color: var(--text-secondary); font-size: .92rem; line-height: 1.55; max-width: 34rem; }
.empty-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; margin-block-start: 8px; }
.empty-state.inline {
  flex-direction: row; align-items: flex-start; text-align: start; gap: 12px;
  padding: 12px 14px; border-radius: 12px;
  background: var(--surface-muted); border: 1px solid var(--border);
}
.empty-state.inline .empty-glyph {
  width: 20px; height: 20px; border: 0; background: none; box-shadow: none; font-size: 16px; margin: 0;
}
.empty-state.inline .empty-title { font-size: .95rem; }
.empty-state.inline .empty-actions { justify-content: flex-start; margin-block-start: 4px; }
.empty-state.inline > div { display: flex; flex-direction: column; gap: 4px; }

/* ---- errors (design: Error / Inline · Block · Page) ----
   What happened, what it means for you, what to do now — in that order. Retry is primary
   wherever there is one, the way back a ghost after it, and the reference code on a line
   of its own at the foot. */
.error-block {
  display: flex; flex-direction: column; align-items: flex-start; gap: 8px;
  padding: 18px 20px; border-radius: 16px; white-space: normal;
  background: var(--danger-bg); border: 1px solid var(--danger-border);
  border-inline-start: 3px solid var(--danger-fg);
}
.error-title { margin: 0; font-size: 1.05rem; font-weight: 600; color: var(--danger-fg); }
.error-body { margin: 0; color: var(--text-body); font-size: .92rem; }
.error-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-block-start: 4px; }
.error-block .reference { margin-block-start: 2px; }
.gate-block:empty { display: none; }
.gate-block { margin-block-start: 1rem; }

/* ---- button types and states (design 18) ---- */
button.ghost, .btn.ghost {
  background: none; color: var(--text-body); border: 1px solid var(--border); box-shadow: none; font-weight: 500;
}
button.ghost:hover, .btn.ghost:hover { color: var(--text-primary); background: var(--hover-bg); }
button.danger, .btn.danger {
  background: var(--danger-bg); color: var(--danger-fg); border-color: var(--danger-border); box-shadow: none;
}
button.danger:hover, .btn.danger:hover { background: var(--danger-bg-hover); color: var(--danger-fg-hover); border-color: var(--danger-border-hover); }
button.danger:active, .btn.danger:active { background: var(--danger-bg-pressed); color: var(--danger-fg); border-color: var(--danger-border); }
button[aria-busy="true"], .btn[aria-busy="true"] { cursor: progress; opacity: .8; }

/* ---- the home page with nothing to continue (E1): starters in place of the cards ---- */
.starters { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.starter {
  display: block; padding: 20px; border-radius: var(--r-card); text-decoration: none;
  background: var(--control-bg); border: 1px solid var(--control-border); box-shadow: none;
  color: var(--text-primary); font-weight: 500; line-height: 1.4;
}
.starter:hover { color: var(--text-primary); background: var(--surface); border-color: var(--border); }
.explainer { margin: 0 0 20px; max-width: 720px; }
.explainer video { display: block; width: 100%; aspect-ratio: 16 / 9; border-radius: 12px; background: #000; }
.explainer figcaption { margin-top: 8px; color: var(--text-secondary); font-size: .9rem; }
.starters-note { margin: 12px 0 0; color: var(--text-secondary); font-size: .9rem; }

/* ---- the sidebar folded to a rail (frames 11, 11b) ----
   The chevron in the brand row folds it; the rail keeps the mark, New topic, Topics and
   the account. `data-sidebar` sits on the root so the choice applies before first paint.
   Logical properties throughout, so a Persian page keeps its rail on the right. */
.brand-row { display: flex; align-items: center; gap: 8px; }
.brand-row .brand-lockup { flex: 1; min-width: 0; }
button.sidebar-toggle {
  flex: none; width: 30px; height: 30px; padding: 0; border-radius: 9px;
  display: inline-flex; align-items: center; justify-content: center;
  background: none; border: 1px solid transparent; box-shadow: none; color: var(--text-secondary); font-weight: 400;
}
button.sidebar-toggle:hover { color: var(--text-primary); background: var(--hover-bg); }
.sidebar-toggle .chev-fold { display: inline-block; font-size: 1.1rem; line-height: 1; }
.nav-glyph { display: none; }
@media (min-width: 56.01rem) {
  :root[data-sidebar="rail"] .sidebar { width: 72px; padding-inline: 12px; align-items: center; }
  /* Folded, the way back out sits on the mark rather than under it, where it took a row of
     its own and pushed everything down: the mark is shown, and pointing at it (or reaching
     the button by keyboard) turns it into the expand button. On top, so a click there
     expands; the brand's link home is a click away once the sidebar is open. */
  :root[data-sidebar="rail"] .brand-row { position: relative; justify-content: center; }
  :root[data-sidebar="rail"] .sidebar .brand-lockup { flex: none; padding: 0; transition: opacity var(--dur) var(--ease); }
  :root[data-sidebar="rail"] button.sidebar-toggle {
    /* Centred on the mark by its own middle: it is wider than the row, which `inset: 0;
       margin: auto` cannot centre (it settled 3px to one side). */
    position: absolute; top: 50%; left: 50%; translate: -50% -50%; width: 36px; height: 36px; border-radius: 10px;
    color: var(--text-primary); background: var(--hover-bg);
    opacity: 0; transition: opacity var(--dur) var(--ease);
  }
  :root[data-sidebar="rail"] .brand-row:is(:hover, :has(> .sidebar-toggle:focus-visible)) > .sidebar-toggle { opacity: 1; }
  :root[data-sidebar="rail"] .brand-row:is(:hover, :has(> .sidebar-toggle:focus-visible)) > .brand-lockup { opacity: 0; }
  :root[data-sidebar="rail"] .sidebar .brand-name,
  :root[data-sidebar="rail"] .sidebar .credit-chip,
  :root[data-sidebar="rail"] .sidebar #recent,
  :root[data-sidebar="rail"] .sidebar .brand,
  :root[data-sidebar="rail"] .sidebar .account-id,
  :root[data-sidebar="rail"] .sidebar .new-topic-label,
  :root[data-sidebar="rail"] .sidebar .nav-label { display: none; }
  :root[data-sidebar="rail"] .sidebar .nav-glyph { display: inline-flex; }
  :root[data-sidebar="rail"] .sidebar .new-topic { width: 44px; height: 44px; }
  :root[data-sidebar="rail"] .sidebar .nav a { display: flex; justify-content: center; width: 44px; }
  :root[data-sidebar="rail"] .sidebar .account { width: 100%; display: flex; justify-content: center; margin-block-start: auto; }
  :root[data-sidebar="rail"] .sidebar .account summary { justify-content: center; }
  :root[data-sidebar="rail"] .sidebar .account-menu { inset-inline-end: auto; width: 200px; }
  :root[data-sidebar="rail"] .sidebar-toggle .chev-fold { transform: scaleX(-1); }
  :root[data-sidebar="rail"] #report .card:has(> .report-contents:not([hidden])),
  :root[data-sidebar="rail"] #report .card:has(> .compare-panel:not([hidden]) .report-contents:not([hidden])) {
    --wide: min(1180px, calc(100vw - 72px - 80px));
  }
}

button.menu-toggle { display: none; }
@media (max-width: 56rem) {
  .starters { grid-template-columns: 1fr; }
  /* Stacked on a phone the sidebar is a strip above the page, not beside it: no rail. */
  button.sidebar-toggle { display: none; }
  /* One row — the brand, New topic, Menu — and the rest behind Menu (sidebar.js). Open
     all the time it took the first 309px of a 390x844 screen on every page. */
  .sidebar { flex-direction: row; flex-wrap: wrap; align-items: center; gap: 8px; padding: 10px 16px; }
  .sidebar .brand-row { flex: 1 1 auto; min-width: 0; }
  .sidebar .brand-lockup { padding: 0; }
  .sidebar .new-topic { width: auto; padding: 0 14px; }
  /* A row of their own under the title, from its start: wrapped one at a time beside a long
     title they were scattered across two rows. */
  .stage-actions { flex-basis: 100%; margin-inline-start: 0; }
  button.menu-toggle {
    display: inline-flex; align-items: center; justify-content: center; width: 40px; height: 40px;
    border-radius: 12px; background: var(--surface-muted); color: var(--text-primary); font-size: 1.1rem;
  }
  button.menu-toggle[aria-expanded="true"] { background: var(--surface-muted); }
  .sidebar > :is(.credit-chip, .nav, .account, .brand) { display: none; }
  :root[data-menu="open"] .sidebar > :is(.credit-chip:not([hidden]), .nav, .brand) {
    display: flex; flex-basis: 100%;
  }
  :root[data-menu="open"] .sidebar > .account { display: block; flex-basis: 100%; }
  /* Here the account is near the top of the page, so a menu opening upward ran off the
     screen and Settings could not be reached. It opens below the row, in the flow, where
     the page scrolls to it. */
  .account summary { inline-size: fit-content; }
  .account-menu { position: static; margin-block-start: 6px; }
}

/* ---- the outline, edited by hand (frames 06, 07, E4; static/chat.js) ----
   A number, the title over its summary, and the tools — shown on hover or keyboard focus,
   so the outline reads as an outline until someone reaches for it. One row open at a
   time; the rest are locked and say so. */
.section.editable {
  display: grid; grid-template-columns: 28px minmax(0, 1fr) auto auto; align-items: start; gap: 4px 12px;
}
.section-num {
  width: 26px; height: 26px; border-radius: 8px; display: flex; align-items: center; justify-content: center;
  background: var(--surface-muted); border: 1px solid var(--border);
  font-size: 12px; font-weight: 600; color: var(--text-body);
}
.section-text { min-width: 0; }
.section-tools { display: flex; gap: 2px; opacity: 0; transition: opacity var(--dur) var(--ease); }
.section.editable:hover .section-tools, .section.editable:focus-within .section-tools { opacity: 1; }
button.section-tool {
  width: 30px; height: 30px; padding: 0; border-radius: 9px;
  display: inline-flex; align-items: center; justify-content: center;
  background: none; border: 1px solid transparent; box-shadow: none; color: var(--text-secondary); font-weight: 400;
}
button.section-tool:hover:not(:disabled) { color: var(--text-primary); background: var(--hover-bg); }
.section-handle { color: var(--text-tertiary); cursor: grab; padding: 4px 2px; user-select: none; }
.section.locked { opacity: .55; }
.section.locked .section-handle { cursor: default; }
.section.dragging { opacity: .4; }
.section.drop { border-color: var(--accent-subtle-border); box-shadow: inset 0 0 0 1px var(--accent-halo); }
.section.removing { grid-template-columns: 28px minmax(0, 1fr) auto auto; border-style: dashed; }
.section.removing .section-text { text-decoration: line-through; color: var(--text-secondary); }
.section-flag { align-self: center; font-size: 12px; color: var(--danger-fg); }
.section.removing > button { padding: .35rem .8rem; font-size: .82rem; }
.section.rewriting .section-text { color: var(--text-secondary); }
.section.editing { border-color: var(--accent-subtle-border); background: var(--accent-subtle); }
.section-form { display: flex; flex-direction: column; gap: 8px; }
.section-form textarea { min-height: 3.5rem; font-size: .88rem; }
.section-form-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.section-form-actions .hint { min-height: 0; }
.outline-foot { margin-block-start: 8px; }
.outline-foot:empty { display: none; }
button.add-section { width: 100%; border-style: dashed; padding: .6rem 1rem; }
.outline-empty { border-radius: 16px; border: 1px dashed var(--border); }
@media (prefers-reduced-motion: reduce) { .section-tools { transition: none; } }
/* Touch has no hover: the tools stay in view. */
@media (hover: none) { .section-tools { opacity: 1; } }
.section-form > p.hint { margin: 0; min-height: 0; }
.section-form > p.hint:empty { display: none; }

/* ---- the Topics library (frames 11, E3a, E3b; static topics.js) ---- */
.topic-search { margin: 18px 0 0; max-width: 32rem; }
.topic-search input[type="search"] { border-radius: 999px; padding-inline: 1.1rem; background: var(--surface-muted); }
.filters a { display: inline-flex; align-items: center; gap: 6px; }
.filters a:hover { color: var(--text-primary); }
.filters .count { font-variant-numeric: tabular-nums; color: var(--text-tertiary); font-size: .8rem; }
.filters a.on .count { color: var(--text-body); }
/* A row is a link to the topic and, beside it, its chip, its time and its menu: a menu
   inside the link would follow the link on every click. */
.project { padding: 0; padding-inline-end: 14px; }
.project-link {
  flex: 1; min-width: 0; display: flex; align-items: center; gap: 16px;
  padding-block: 18px; padding-inline: 22px 0; color: inherit; text-decoration: none;
}
.project-link:hover { color: inherit; }
.project-link:hover .project-title { color: var(--accent-hover); }
.project-meta { overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 1; -webkit-box-orient: vertical; }
.project > .project-main { flex: 1; padding-block: 12px; padding-inline: 22px 0; }
.rename-input { padding: .5rem .8rem; }
.rename-input.invalid { border-color: var(--danger-fg); }
.row-menu { position: relative; flex: none; }
.row-menu > summary {
  list-style: none; cursor: pointer; width: 32px; height: 32px; border-radius: 10px;
  display: flex; align-items: center; justify-content: center; color: var(--text-secondary); font-size: 1.1rem;
}
.row-menu > summary::-webkit-details-marker { display: none; }
.row-menu > summary:hover, .row-menu[open] > summary { color: var(--text-primary); background: var(--hover-bg); }
.row-menu-list {
  position: absolute; inset-inline-end: 0; top: calc(100% + 4px); z-index: 6; min-width: 10rem;
  display: flex; flex-direction: column; gap: 2px; padding: 6px;
  border-radius: 14px; background: var(--surface-raised); border: 1px solid var(--border); box-shadow: var(--shadow-float);
}
.row-menu-list button.link {
  display: block; width: 100%; text-align: start; padding: 8px 12px; border-radius: 10px;
  text-decoration: none; color: var(--text-body); font-size: .88rem;
}
.row-menu-list button.link:hover { background: var(--hover-bg); color: var(--text-primary); }
.row-menu-list button.danger-text, .row-menu-list button.danger-text:hover { color: var(--danger-fg); }
/* The rows' card clips its corners; an open menu has to show past it. */
.projects:has(.row-menu[open]) { overflow: visible; }

/* A confirmation (the design's modal) over a dimmed page. */
dialog.confirm-dialog {
  width: min(440px, calc(100vw - 32px)); padding: 28px; border-radius: var(--r-card);
  color: var(--text-primary); background: var(--surface-raised); border: 1px solid var(--border); box-shadow: var(--shadow-dialog);
}
dialog.confirm-dialog::backdrop { background: var(--overlay); }
dialog.confirm-dialog h2 { margin: 0 0 6px; }
dialog.confirm-dialog p { margin: 0 0 10px; color: var(--text-body); }
.dialog-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-block-start: 16px; }
.delete-name { font-weight: 600; color: var(--text-primary); }
/* Renaming a topic from its page (chat.html, chat-topic.js): the name across the dialog. */
dialog.confirm-dialog .rename-input { width: 100%; box-sizing: border-box; margin-block: 10px 6px; }
dialog.confirm-dialog .rename-note:empty { display: none; }

/* The keyboard shortcuts (base.html, keys.js). */
dialog.keys-dialog { width: min(480px, calc(100vw - 32px)); }
.keys-list { display: grid; grid-template-columns: auto 1fr; gap: 8px 16px; margin: 12px 0 16px; }
.keys-list dt { white-space: nowrap; color: var(--text-body); }
.keys-list dd { margin: 0; color: var(--text-body); }
kbd {
  display: inline-block; min-width: 1.6em; padding: 1px 6px; border-radius: 6px; text-align: center;
  font: 500 .82rem/1.5 var(--mono); color: var(--text-primary);
  background: var(--surface-muted); border: 1px solid var(--border);
}
.keys { white-space: nowrap; unicode-bidi: isolate; }
.keys-switch { display: flex; align-items: center; gap: 8px; color: var(--text-primary); }
.delete-note:empty { display: none; }

@media (max-width: 56rem) {
  .project { padding-inline: 0 8px; }
  .project-link { padding-inline: 16px 0; flex-basis: 100%; }
  .project .badge, .project .project-when { margin-inline-start: 16px; }
}

/* An error the page is showing, above the step it happened on (chat.html #notice). */
.notice { margin: 0 0 12px; padding: 8px 12px; border-radius: 10px; color: var(--text-primary);
  background: var(--danger-bg); border: 1px solid var(--danger-border); }
.notice:empty { display: none; }

/* Revise, in the report (chat.js placeRevise): gone while a revision is running. */
#report:not([data-status="delivered"]) .report-revise { display: none; }
.report-revise { margin: 4px 0 12px; }
.revise-rest { margin-block-start: 24px; padding-block-start: 12px; border-block-start: 1px solid var(--border); }
.revise-rest .report-revise { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.revise-rest-title { flex: 1 1 12rem; }

/* "Just answer me" kept an outline: the way back to it (chat.html #kept-outline). */
.kept-outline { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 0 0 12px;
  padding: 10px 12px; border-radius: 10px; background: var(--surface-muted); color: var(--text-primary); }
.kept-outline[hidden] { display: none; }
.kept-goal { flex: 1 1 14rem; font-weight: 600; }

/* Stop, asked twice (chat.js stopButton). */
.stop-ask { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.stop-ask[hidden] { display: none; }
.stop-control { display: inline-flex; align-items: center; }
.round-stop { display: inline-flex; margin-inline-start: auto; }
.stop-question { color: var(--text-primary); }

/* What a report usually takes, beside Generate (chat.js showEstimate). */
.run-estimate { margin-block-start: 8px; }
.run-estimate.short { color: var(--warning-fg); }
.start-own { margin-inline-start: 12px; color: var(--accent-text); font-weight: 600; }

/* "Skip to content": off screen until a keyboard reaches it (base.html). */
.skip-link { position: absolute; inset-inline-start: 12px; top: -48px; z-index: 50; padding: 8px 14px;
  border-radius: 10px; background: var(--surface); color: var(--text-primary); border: 1px solid var(--border); }
.skip-link:focus { top: 12px; }
main:focus { outline: none; }

/* Stop sharing, asked first (chat-share.js). */
.share-ask { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.share-ask[hidden] { display: none; }
.share-ask-answers { display: inline-flex; flex-wrap: wrap; gap: 6px; }

/* Why a rename was refused, beside the box (topics.js). */
.rename-error { display: block; margin-top: 4px; font-size: .85rem; color: var(--danger-fg); }

/* A topic shown from the copy the service worker saved (connection.js `savedCopy`). It is
   read, not used: what needs the service is inert (`[data-needs-service]`) and the controls
   that would only fail are not drawn. */
html[data-saved] .revise,
html[data-saved] .export-menu { display: none; }
html[data-saved] [data-needs-service] { opacity: .5; }

/* Support: a thread of messages, the operator's view of what the page knew, and the
   summary of what a new request carries. Logical properties throughout, so a Persian page
   mirrors without a second rule. */
.thread { display: flex; flex-direction: column; gap: 12px; max-width: 46rem; margin: 1rem 0 1.5rem; }
.message { padding: 12px 16px; border-radius: 12px; border: 1px solid var(--border); background: var(--surface); }
.message.operator { border-color: transparent; background: var(--accent); }
.message p { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.message p.meta { margin-block-end: 4px; }
.facts { display: grid; grid-template-columns: minmax(7rem, 10rem) 1fr; gap: .4rem 1.5rem; max-width: 46rem; margin: 1rem 0; font-size: .9rem; }
.facts dt { color: var(--text-secondary); }
.facts dd { margin: 0; overflow-wrap: anywhere; }
.attached { max-width: 46rem; font-size: .9rem; color: var(--text-body); }
.attached summary { cursor: pointer; }
.attached ul { margin: .5rem 0 0; padding-inline-start: 1.2rem; }

/* Files on a support message: a screenshot shown at a readable size, a text file as a link. */
.attachments { list-style: none; margin: .6rem 0 0; padding: 0; display: flex; flex-wrap: wrap; gap: 10px; }
.shot { display: block; max-width: 100%; max-height: 22rem; border-radius: 8px; border: 1px solid var(--border); }

/* Inviting friends (templates/invite_friends.html). */
/* `.stack` spaces only a form; this is a div. */
.invite-form { display: flex; flex-direction: column; gap: 1rem; }
.invite-actions { display: flex; flex-wrap: wrap; gap: .5rem; }
/* A link and a button take different default sizes; the row should read as one set. */
.invite-actions .btn, .invite-actions button { font-size: .9rem; line-height: 1.3; }
/* Grows to fit where the browser can (a Persian message runs to six lines on a phone), and
   keeps a floor where it cannot. */
#invite-message { width: 100%; min-height: 8rem; field-sizing: content; resize: vertical; }
#invite-link { width: 100%; }

/* Appearance in one icon: the palette in force, linking to the other of Light and Dark.
   With nothing pinned both links are in the page and the device's scheme picks one. */
.theme-switch { display: inline-flex; flex: none; }
.theme-switch a[data-scheme="dark"] { display: none; }
@media (prefers-color-scheme: dark) {
  .theme-switch a[data-scheme="light"] { display: none; }
  .theme-switch a[data-scheme="dark"] { display: inline-flex; }
}
.theme-switch a {
  display: inline-flex; align-items: center; justify-content: center;
  width: 32px; height: 32px; border-radius: 10px; color: var(--text-secondary);
  text-decoration: none;
}
.theme-switch a:hover { color: var(--text-primary); background: var(--hover-bg); }
/* Signed in, it stands in the page's top corner across from the sidebar (top left on a
   Persian page), inside main's top padding, so it covers nothing and scrolls away with
   the page. On a phone the sidebar is a strip above the page, so it takes its own row. */
.page-corner { position: absolute; inset-block-start: 2px; inset-inline-end: 12px; z-index: 4; }
@media (max-width: 56rem) {
  .page-corner { position: static; display: flex; justify-content: flex-end; margin-block: -16px 4px; }
}

/* A success said for a moment at the top of the screen (static/toast.js): green, as the
   design's success is, on an opaque surface so the page under it does not show through
   the dark palette's translucent tint. Above the page, below the signed-out dialog. */
.toast {
  position: fixed; inset-block-start: 16px; inset-inline: 0; margin-inline: auto; z-index: 40;
  width: fit-content; max-width: calc(100% - 32px); box-sizing: border-box;
  padding: 10px 18px; border-radius: 12px; font-size: .9rem; font-weight: 500;
  color: var(--success-fg); border: 1px solid var(--success-border);
  background: linear-gradient(var(--success-bg), var(--success-bg)), var(--surface-raised);
  box-shadow: var(--shadow-float);
  opacity: 0; visibility: hidden; transform: translateY(-8px); pointer-events: none;
  transition: opacity var(--dur) var(--ease), transform var(--dur) var(--ease), visibility 0s linear var(--dur);
}
.toast.shown {
  opacity: 1; visibility: visible; transform: none;
  transition: opacity var(--dur) var(--ease), transform var(--dur) var(--ease), visibility 0s;
}
@media (prefers-reduced-motion: reduce) { .toast, .toast.shown { transform: none; } }
