/* The assistant page. Tokens are core-ui's (src/input.css there), copied verbatim in
   OKLCH, so the page reads as a page of OptiCx; docs/plan-chat-ui.md "Tokens" and the
   mockup docs/mockups/assistant-ui-v2.html are the spec. The lime of the OE mark (--live)
   means live activity and nothing else. One stylesheet, no inline styles: the
   Content-Security-Policy allows neither. */

@font-face {
  font-family: "Inter";
  src: url("/assistant/static/fonts/Inter-Regular.ttf") format("truetype");
  font-weight: 400;
  font-display: swap;
}
@font-face {
  font-family: "Inter";
  src: url("/assistant/static/fonts/Inter-SemiBold.ttf") format("truetype");
  font-weight: 600;
  font-display: swap;
}

/* ---- tokens ------------------------------------------------------------ */
/* Light. The raw palette and the semantic tokens are core-ui's, value for value; the
   chart, font and most shadow tokens are left out because nothing here uses them. */
:root {
  color-scheme: light dark;

  /* Raw palette: theme-agnostic. */
  --palette-black: oklch(0 0 0);
  --palette-white: oklch(1 0 0);
  --palette-near-white: oklch(0.9551 0 0);
  --palette-primary: oklch(0.5358 0.0618 213.2256);
  --palette-destructive: oklch(0.629 0.1902 23.0704);
  --palette-success: oklch(0.508 0.118 165.612);
  --palette-success-dark: oklch(0.845 0.143 164.978);
  --palette-content-light: oklch(0.967 0.001 286.375);
  --palette-border-light: oklch(0.93 0.0094 286.2156);
  --palette-chrome-dark: oklch(0.17 0.0039 286.0396);
  --palette-content-dark: oklch(0.22 0.0039 286.0396);
  --palette-surface-dark: oklch(0.294 0.004 286.0396);
  --palette-border-dark: oklch(0.3289 0.004 286.0396);

  /* Semantic tokens. */
  --background: var(--palette-content-light);
  --foreground: var(--palette-black);
  --card: var(--palette-white);
  --card-foreground: var(--palette-black);
  --popover: var(--palette-white);
  --popover-foreground: var(--palette-black);
  --primary: var(--palette-primary);
  --primary-foreground: var(--palette-white);
  --muted: oklch(0.94 0.004 286.0396);
  --muted-foreground: oklch(0.4386 0 0);
  --accent: oklch(0.93 0.015 286.0396);
  --accent-foreground: var(--palette-primary);
  --destructive: var(--palette-destructive);
  --destructive-foreground: var(--palette-white);
  --success: var(--palette-success);
  --border: var(--palette-border-light);
  --input: var(--palette-border-light);
  --ring: var(--palette-primary);
  --sidebar: var(--palette-white);
  --sidebar-foreground: var(--palette-black);
  --sidebar-accent: oklch(0.9401 0 0);
  --sidebar-accent-foreground: var(--palette-black);
  --sidebar-border: var(--palette-border-light);
  --radius: 0.5rem;
  --spacing: 0.27rem;
  --tracking-normal: 0.015em;
  --shadow-xs: 0px 2px 3px 0px hsl(0 0% 0% / 0.08);
  --shadow-sm: 0px 2px 3px 0px hsl(0 0% 0% / 0.16), 0px 1px 2px -1px hsl(0 0% 0% / 0.16);
  --shadow-lg: 0px 2px 3px 0px hsl(0 0% 0% / 0.16), 0px 4px 6px -1px hsl(0 0% 0% / 0.16);

  /* This page's additions, all derived from the tokens above except --live. */
  --live: #90c10a;
  --live-soft: color-mix(in oklch, var(--live) 18%, transparent);
  /* The spend chart's second source (Slack); the first (the chat) is --primary. Slot 2 of
     the dataviz skill's categorical palette, checked against --primary on the card with its
     validate_palette.js in both modes (docs/plan-spend-ledger.md, "The page draws it"). */
  --series-2: #eb6834;
  --radius-sm: calc(var(--radius) - 4px);
  --radius-btn: calc(var(--radius) - 2px);
  /* core-ui Card: a 1px foreground/10 ring and no shadow. */
  --card-ring: color-mix(in oklch, var(--foreground) 10%, transparent);
  --user-bubble: color-mix(in oklch, var(--primary) 9%, transparent);
  /* core-ui's primary/80 hover leaves white text at 3.41:1 in light, so light darkens instead
     (6.33:1); dark keeps primary/80 (6.72:1). */
  --primary-hover: color-mix(in oklch, var(--primary) 90%, var(--palette-black));
  --destructive-soft: color-mix(in oklch, var(--destructive) 10%, transparent);
  --destructive-hover: color-mix(in oklch, var(--destructive) 20%, transparent);
  --outline-bg: transparent;
  --outline-hover: color-mix(in oklch, var(--input) 50%, transparent);
  --ghost-hover: var(--muted);
  --code-bg: var(--muted);
  --scrim: color-mix(in oklch, var(--palette-black) 50%, transparent);
  --dur: 150ms;
  --sidebar-width: 16rem;
  --sidebar-width-mobile: 18rem;
  --bar-h: calc(var(--spacing) * 12);
  --measure: 46rem;
  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;

  /* Dark: core-ui's .dark values, defined once here. The two rules below only point the
     semantic tokens at them: one when the OS is dark and the page is not forced light, one
     when the page is forced dark (the theme button puts .light or .dark on <html>). Tokens
     whose dark value is the light one (primary, destructive, ring, ...) are not repeated. */
  --dark-background: var(--palette-content-dark);
  --dark-foreground: var(--palette-near-white);
  --dark-card: var(--palette-chrome-dark);
  --dark-card-foreground: var(--palette-near-white);
  --dark-popover: var(--palette-chrome-dark);
  --dark-popover-foreground: var(--palette-near-white);
  --dark-muted: var(--palette-surface-dark);
  --dark-muted-foreground: oklch(0.7058 0 0);
  --dark-accent: oklch(0.2795 0.008 286.0396);
  --dark-success: var(--palette-success-dark);
  --dark-border: var(--palette-border-dark);
  --dark-input: var(--palette-border-dark);
  --dark-sidebar: var(--palette-chrome-dark);
  --dark-sidebar-foreground: var(--palette-near-white);
  --dark-sidebar-accent: var(--palette-surface-dark);
  --dark-sidebar-accent-foreground: var(--palette-near-white);
  --dark-sidebar-border: var(--palette-border-dark);
  --dark-live-soft: color-mix(in oklch, var(--live) 22%, transparent);
  --dark-series-2: #d95926;
  --dark-user-bubble: color-mix(in oklch, var(--primary) 22%, transparent);
  --dark-primary-hover: color-mix(in oklch, var(--primary) 80%, transparent);
  --dark-destructive-soft: color-mix(in oklch, var(--destructive) 20%, transparent);
  --dark-destructive-hover: color-mix(in oklch, var(--destructive) 30%, transparent);
  --dark-outline-bg: color-mix(in oklch, var(--input) 30%, transparent);
  --dark-outline-hover: color-mix(in oklch, var(--input) 60%, transparent);
  --dark-ghost-hover: color-mix(in oklch, var(--muted) 50%, transparent);
}
:root.light {
  color-scheme: light;
}
/* The two dark rules must stay identical (tests/chat/web-theme.test.ts checks). */
@media (prefers-color-scheme: dark) {
  :root:not(.light) {
    color-scheme: dark;
    --background: var(--dark-background);
    --foreground: var(--dark-foreground);
    --card: var(--dark-card);
    --card-foreground: var(--dark-card-foreground);
    --popover: var(--dark-popover);
    --popover-foreground: var(--dark-popover-foreground);
    --muted: var(--dark-muted);
    --muted-foreground: var(--dark-muted-foreground);
    --accent: var(--dark-accent);
    --success: var(--dark-success);
    --border: var(--dark-border);
    --input: var(--dark-input);
    --sidebar: var(--dark-sidebar);
    --sidebar-foreground: var(--dark-sidebar-foreground);
    --sidebar-accent: var(--dark-sidebar-accent);
    --sidebar-accent-foreground: var(--dark-sidebar-accent-foreground);
    --sidebar-border: var(--dark-sidebar-border);
    --live-soft: var(--dark-live-soft);
    --series-2: var(--dark-series-2);
    --user-bubble: var(--dark-user-bubble);
    --primary-hover: var(--dark-primary-hover);
    --destructive-soft: var(--dark-destructive-soft);
    --destructive-hover: var(--dark-destructive-hover);
    --outline-bg: var(--dark-outline-bg);
    --outline-hover: var(--dark-outline-hover);
    --ghost-hover: var(--dark-ghost-hover);
  }
}
:root.dark {
  color-scheme: dark;
  --background: var(--dark-background);
  --foreground: var(--dark-foreground);
  --card: var(--dark-card);
  --card-foreground: var(--dark-card-foreground);
  --popover: var(--dark-popover);
  --popover-foreground: var(--dark-popover-foreground);
  --muted: var(--dark-muted);
  --muted-foreground: var(--dark-muted-foreground);
  --accent: var(--dark-accent);
  --success: var(--dark-success);
  --border: var(--dark-border);
  --input: var(--dark-input);
  --sidebar: var(--dark-sidebar);
  --sidebar-foreground: var(--dark-sidebar-foreground);
  --sidebar-accent: var(--dark-sidebar-accent);
  --sidebar-accent-foreground: var(--dark-sidebar-accent-foreground);
  --sidebar-border: var(--dark-sidebar-border);
  --live-soft: var(--dark-live-soft);
  --series-2: var(--dark-series-2);
  --user-bubble: var(--dark-user-bubble);
  --primary-hover: var(--dark-primary-hover);
  --destructive-soft: var(--dark-destructive-soft);
  --destructive-hover: var(--dark-destructive-hover);
  --outline-bg: var(--dark-outline-bg);
  --outline-hover: var(--dark-outline-hover);
  --ghost-hover: var(--dark-ghost-hover);
}
@media (min-width: 1440px) {
  :root {
    --measure: 48rem;
  }
}

/* ---- base -------------------------------------------------------------- */
* {
  box-sizing: border-box;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}
html,
body {
  height: 100%;
  margin: 0;
}
/* The dynamic viewport: on iOS 100% is the tallest the page can be, with Safari's
   toolbars collapsed, so the bottom of the shell hid behind them. */
@supports (height: 100dvh) {
  body {
    height: 100dvh;
  }
}
body {
  background: var(--background);
  color: var(--foreground);
  font: 400 0.875rem / 1.5 var(--font);
  letter-spacing: var(--tracking-normal);
  -webkit-font-smoothing: antialiased;
  display: flex;
  flex-direction: column;
}
h1,
h2,
h3,
p,
ul,
ol {
  margin: 0;
}
button,
input,
textarea,
select {
  font: inherit;
  color: inherit;
  letter-spacing: inherit;
}
button,
select,
summary {
  cursor: pointer;
}
/* One focus indicator everywhere: a solid 2px ring in --ring, 2px out. */
:focus-visible {
  outline: 2px solid var(--ring);
  outline-offset: 2px;
}
.muted {
  color: var(--muted-foreground);
}
/* --destructive as text is under 4.5:1 on the page (3.50 light), so an error is
   --foreground text behind a red rail. A note under a reply draws its own rail. */
.error {
  color: var(--foreground);
}
.error:not(.note) {
  border-left: 3px solid var(--destructive);
  padding-left: 0.5rem;
}
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}
.sprite {
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
}

.spinner {
  display: inline-block;
  width: 1rem;
  height: 1rem;
  flex: none;
  border-radius: 50%;
  border: 1.5px solid color-mix(in oklch, var(--muted-foreground) 25%, transparent);
  border-top-color: var(--muted-foreground);
  animation: spin 0.8s linear infinite;
}

/* The pulsing lime dot of live activity: the Working pill, the active step, the
   working conversation's row. */
.live-dot,
.conv .dot,
.step.active .pulse {
  position: relative;
  width: 6px;
  height: 6px;
  flex: none;
  border-radius: 50%;
  background: var(--live);
}
.live-dot::before,
.conv .dot::before,
.step.active .pulse::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: var(--live);
  animation: ping 1.4s cubic-bezier(0, 0, 0.2, 1) infinite;
}

/* ---- buttons (core-ui's button variants) -------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: calc(var(--spacing) * 1.5);
  height: calc(var(--spacing) * 8);
  padding: 0 calc(var(--spacing) * 3);
  border: 1px solid transparent;
  border-radius: var(--radius-btn);
  font-size: 0.875rem;
  font-weight: 500;
  white-space: nowrap;
  text-decoration: none;
  background: var(--primary);
  color: var(--primary-foreground);
  transition:
    background-color var(--dur) ease,
    color var(--dur) ease,
    border-color var(--dur) ease;
}
.btn:hover {
  background: var(--primary-hover);
}
.btn:active {
  transform: translateY(1px);
}
.btn:disabled {
  opacity: 0.5;
  pointer-events: none;
}
.btn.outline {
  background: var(--outline-bg);
  border-color: var(--border);
  color: var(--foreground);
}
.btn.outline:hover {
  background: var(--outline-hover);
}
.btn.ghost {
  background: transparent;
  color: var(--foreground);
}
.btn.ghost:hover {
  background: var(--ghost-hover);
}
/* Delete in the header: the label stays --foreground, the icon carries the red
   (the icon colours are under "icon colours", after every other icon rule). */
.btn.ghost.danger:hover {
  background: var(--destructive-soft);
}
/* core-ui's destructive variant, a red tint. The label is --foreground: --destructive as
   text is 3.39:1 on its own tint in light. Stop, and the delete dialog's confirm. */
.btn.destructive {
  background: var(--destructive-soft);
  color: var(--foreground);
}
.btn.destructive:hover {
  background: var(--destructive-hover);
}
/* A text link. --foreground and underlined: --primary as text is 3.45:1 in dark. */
.btn.link {
  background: none;
  padding: 0;
  height: auto;
  color: var(--foreground);
  text-decoration: underline;
  text-decoration-color: color-mix(in oklch, var(--foreground) 40%, transparent);
  text-underline-offset: 4px;
}
.btn.link:hover {
  text-decoration-color: var(--foreground);
}
.btn.sm {
  height: calc(var(--spacing) * 7);
  padding: 0 calc(var(--spacing) * 2.5);
  font-size: 0.8125rem;
}
.btn.icon {
  width: calc(var(--spacing) * 8);
  padding: 0;
}
.btn svg {
  width: 1rem;
  height: 1rem;
  flex: none;
}
/* The spinner inside a button shows only while its request is out. */
.btn .spinner {
  display: none;
  border-color: color-mix(in oklch, currentColor 30%, transparent);
  border-top-color: currentColor;
}
.btn[aria-busy="true"] .spinner {
  display: inline-block;
}
@media (pointer: coarse) {
  .btn:not(.link) {
    min-height: 44px;
  }
  .btn.icon {
    min-width: 44px;
  }
}

/* ---- inputs ------------------------------------------------------------ */
/* core-ui Input: border-input, rounded-md, shadow-xs; focus is the page's solid ring. */
.input {
  width: 100%;
  height: 2.25rem;
  padding: 0 0.7rem;
  background: var(--card);
  color: var(--foreground);
  border: 1px solid var(--input);
  border-radius: var(--radius-btn);
  box-shadow: var(--shadow-xs);
  transition: border-color var(--dur) ease;
}
.input:focus {
  border-color: var(--ring);
}
.input::placeholder {
  color: var(--muted-foreground);
  opacity: 1;
}
label.field {
  display: grid;
  gap: 0.35rem;
  font-size: 0.8125rem;
  font-weight: 500;
}

/* ---- sign-in and code cards -------------------------------------------- */
.screen {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.card {
  width: 100%;
  max-width: 360px;
  background: var(--card);
  color: var(--card-foreground);
  border: 1px solid var(--card-ring);
  border-radius: var(--radius);
  padding: 1.6rem;
  display: grid;
  gap: 1rem;
}
.card .brand {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 0.2rem;
}
.card .brand-mark {
  width: 34px;
  height: 32px;
  flex: none;
}
.brand h1 {
  font-size: 1.0625rem;
  font-weight: 600;
  letter-spacing: calc(var(--tracking-normal) - 0.025em);
}
.brand p {
  font-size: 0.8125rem;
}
.card .btn {
  height: 2.25rem;
}
.card .btn.link {
  height: auto;
}
.card .row {
  display: flex;
  justify-content: space-between;
  font-size: 0.8125rem;
}
.card .error,
.card [role="status"] {
  font-size: 0.8125rem;
}

/* ---- the app shell (core-ui SidebarProvider + AppSidebar + TopNav) ------- */
.app {
  flex: 1;
  display: grid;
  grid-template-columns: var(--sidebar-width) minmax(0, 1fr);
  min-height: 0;
}
.sidebar {
  min-width: 0;
  overflow: hidden;
  background: var(--sidebar);
  color: var(--sidebar-foreground);
  border-right: 1px solid var(--sidebar-border);
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.sidebar-head {
  height: var(--bar-h);
  flex: none;
  display: flex;
  align-items: center;
  gap: calc(var(--spacing) * 2);
  padding: 0 calc(var(--spacing) * 3);
  border-bottom: 1px solid var(--sidebar-border);
}
.sidebar-head .mark {
  width: calc(var(--spacing) * 8);
  height: calc(var(--spacing) * 8);
  flex: none;
}
.sidebar-head .name {
  font-size: 1.125rem;
  font-weight: 600;
  letter-spacing: calc(var(--tracking-normal) - 0.025em);
  white-space: nowrap;
}
.sidebar-new {
  padding: calc(var(--spacing) * 2) calc(var(--spacing) * 2) 0;
}
.sidebar-new .btn {
  width: 100%;
  justify-content: flex-start;
}
.conversations {
  flex: 1;
  overflow-y: auto;
  padding: 0 calc(var(--spacing) * 2) calc(var(--spacing) * 2);
}
/* core-ui SidebarGroupLabel: h-8, px-2, sidebar-foreground/70. */
.conversations h2,
.sidebar-links h2 {
  display: flex;
  align-items: center;
  height: calc(var(--spacing) * 8);
  margin-top: calc(var(--spacing) * 2);
  padding: 0 calc(var(--spacing) * 2);
  font-size: 0.8125rem;
  font-weight: 500;
  color: color-mix(in oklch, var(--sidebar-foreground) 70%, transparent);
}
.conversation-list,
.admin-links {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 1px;
}
.conversation-list li {
  min-width: 0;
}
/* core-ui SidebarMenuButton: h-8, px-2, gap-2, rounded-md; the open row is a primary fill. */
.conv {
  display: flex;
  align-items: center;
  gap: calc(var(--spacing) * 2);
  width: 100%;
  min-width: 0;
  height: calc(var(--spacing) * 8);
  padding: 0 calc(var(--spacing) * 2);
  background: transparent;
  border: 0;
  border-radius: var(--radius-btn);
  text-align: left;
  font-size: 0.875rem;
  color: var(--sidebar-foreground);
  transition:
    background-color var(--dur) ease,
    color var(--dur) ease;
}
.conv:hover {
  background: var(--sidebar-accent);
  color: var(--sidebar-accent-foreground);
}
.conv .title {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.conv .when {
  font-size: 0.75rem;
  color: var(--muted-foreground);
  flex: none;
}
.conv[aria-current="true"] {
  background: var(--primary);
  color: var(--primary-foreground);
  font-weight: 500;
}
.conv[aria-current="true"]:hover {
  background: var(--primary-hover);
}
/* Full white on the teal fill: anything fainter drops under 4.5:1. */
.conv[aria-current="true"] .when {
  color: inherit;
}
.conv .dot {
  box-shadow: 0 0 0 3px var(--live-soft);
}
.load-more {
  width: 100%;
  margin-top: 6px;
}
.btn.ghost.load-more {
  color: var(--muted-foreground);
}
.list-error {
  padding: 8px;
  font-size: 0.8125rem;
}
/* The Admin group: a heading and one row per page, above the footer. */
.sidebar-links {
  padding: 0 calc(var(--spacing) * 2) calc(var(--spacing) * 2);
  border-top: 1px solid var(--sidebar-border);
}
.sidebar-links h2 {
  margin-top: calc(var(--spacing) * 1);
}
.conv .nav-ico {
  width: 1rem;
  height: 1rem;
  flex: none;
  color: var(--muted-foreground);
}
.conv[aria-current="true"] .nav-ico {
  color: inherit;
}
.sidebar-foot {
  display: flex;
  align-items: center;
  gap: calc(var(--spacing) * 2.5);
  padding: calc(var(--spacing) * 2.5) calc(var(--spacing) * 3)
    calc(var(--spacing) * 2.5 + env(safe-area-inset-bottom, 0px));
  border-top: 1px solid var(--sidebar-border);
}
/* --muted and --foreground: the old primary-on-accent was 2.91:1 in dark. */
.avatar {
  width: calc(var(--spacing) * 8);
  height: calc(var(--spacing) * 8);
  flex: none;
  border-radius: 50%;
  background: var(--muted);
  color: var(--foreground);
  display: grid;
  place-items: center;
  font-size: 0.75rem;
  font-weight: 600;
}
.sidebar-foot .who {
  flex: 1;
  min-width: 0;
  line-height: 1.3;
}
.who strong {
  display: block;
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.who span {
  display: block;
  font-size: 0.75rem;
  color: var(--muted-foreground);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ---- main column ------------------------------------------------------- */
.main {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
}
.topbar {
  height: var(--bar-h);
  flex: none;
  display: flex;
  align-items: center;
  gap: calc(var(--spacing) * 2);
  padding: 0 max(calc(var(--spacing) * 3), env(safe-area-inset-right, 0px)) 0
    max(calc(var(--spacing) * 4), env(safe-area-inset-left, 0px));
  background: var(--sidebar);
  border-bottom: 1px solid var(--sidebar-border);
}
.topbar h1 {
  flex: 1;
  min-width: 0;
  font-size: 0.9375rem;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
/* In the chat the Working pill sits right after the title; its status region takes the
   free space, so the actions and the theme button stay at the right. */
.chat-topbar h1 {
  flex: 0 1 auto;
}
.topbar .menu {
  display: none;
}
/* Rename: the title becomes this input, the same size as the title. */
.topbar .title-input {
  flex: 4 1 0;
  min-width: 0;
  max-width: 36rem;
  height: calc(var(--spacing) * 8);
  font-size: 0.9375rem;
  font-weight: 600;
}
.live-status {
  flex: 1 1 0;
  min-width: 0;
  display: flex;
  align-items: center;
}
.live-pill {
  display: inline-flex;
  align-items: center;
  gap: calc(var(--spacing) * 1.5);
  flex: none;
  height: calc(var(--spacing) * 6);
  padding: 0 calc(var(--spacing) * 2.5) 0 calc(var(--spacing) * 2);
  border-radius: 999px;
  background: var(--live-soft);
  color: var(--muted-foreground);
  font-size: 0.75rem;
  font-weight: 500;
}
.chat-actions {
  display: inline-flex;
  gap: 4px;
  flex: none;
}

/* The thread scrolls at full width; its padding centres a --measure column. */
.messages {
  flex: 1;
  min-height: 0;
  min-width: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  padding: 1.75rem
    max(1.25rem, calc((100% - var(--measure)) / 2 + 1.25rem), env(safe-area-inset-right, 0px))
    2.5rem max(1.25rem, calc((100% - var(--measure)) / 2 + 1.25rem), env(safe-area-inset-left, 0px));
}

/* ---- files ------------------------------------------------------------- */
.files {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}
/* A chart: a core-ui Card with the server's PNG and a caption (title, Download PNG). */
.chart {
  width: 100%;
  max-width: 40rem;
  margin: 0;
  border: 1px solid var(--card-ring);
  border-radius: var(--radius);
  background: var(--card);
  color: var(--card-foreground);
  overflow: hidden;
}
.chart .cap {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  padding: 0.5rem 1rem;
  border-top: 1px solid var(--border);
  font-size: 0.8125rem;
  color: var(--muted-foreground);
}
.chart .cap-title {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.chart .cap .btn {
  flex: none;
}
.file-chart {
  display: block;
}
.file-chart img {
  display: block;
  width: 100%;
  height: auto;
  background: #fff;
}
/* Until the image arrives: the chart's shape, a spinner and "Drawing the chart". */
.chart.pending,
.chart.missing {
  aspect-ratio: 16 / 7;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px;
  font-size: 0.8125rem;
  color: var(--muted-foreground);
  text-align: center;
}
.chart.pending::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(
    90deg,
    transparent 0,
    color-mix(in oklch, var(--foreground) 5%, transparent) 50%,
    transparent 100%
  );
  animation: shimmer 1.4s linear infinite;
}
.file-link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: calc(var(--spacing) * 8);
  padding: 6px 10px;
  width: fit-content;
  max-width: 100%;
  border: 1px solid var(--card-ring);
  border-radius: var(--radius-btn);
  background: var(--card);
  color: inherit;
  text-decoration: none;
  transition: background-color var(--dur) ease;
}
.file-link:hover {
  background: var(--muted);
}
.file-link svg {
  width: 1rem;
  height: 1rem;
  flex: none;
  color: var(--muted-foreground);
}

/* The streaming caret, in the lime of live activity. */
.cursor {
  display: inline-block;
  width: 2px;
  height: 1.05em;
  margin-left: 2px;
  vertical-align: -0.17em;
  background: var(--live);
  animation: blink 1s steps(2) infinite;
}

/* ---- the trace: what the agent is doing, one row per step --------------- */
.steps {
  list-style: none;
  margin: 0;
  padding: 0.25rem 0.75rem;
  display: flex;
  flex-direction: column;
  font-size: 0.8125rem;
  color: var(--muted-foreground);
}
/* While the run is going the list is its own card; once folded, the <details> is. */
.trace-slot > .steps,
details.trace {
  background: var(--card);
  color: var(--muted-foreground);
  border: 1px solid var(--card-ring);
  border-radius: var(--radius);
}
.step {
  display: grid;
  grid-template-columns: 1rem minmax(0, 1fr) auto;
  gap: 0.6rem;
  align-items: center;
  padding: 0.4rem 0;
}
.step + .step {
  border-top: 1px solid var(--border);
}
.step .ico {
  width: 1rem;
  height: 1rem;
  display: grid;
  place-items: center;
  color: var(--success);
}
.ico > svg {
  width: 0.9rem;
  height: 0.9rem;
}
.step .line {
  min-width: 0;
  overflow-wrap: anywhere;
}
.step .ms {
  font-variant-numeric: tabular-nums;
  font-size: 0.75rem;
}
.step.active {
  color: var(--foreground);
  font-weight: 500;
}
.step.active .pulse {
  width: 8px;
  height: 8px;
}
.step.failed {
  color: var(--foreground);
}
.step.failed .ico {
  color: var(--destructive);
}
details.trace {
  overflow: hidden;
  font-size: 0.8125rem;
}
details.trace > summary {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  min-height: calc(var(--spacing) * 8);
  padding: 0 0.75rem;
  list-style: none;
  font-weight: 500;
  user-select: none;
  transition:
    color var(--dur) ease,
    background-color var(--dur) ease;
}
details.trace > summary::-webkit-details-marker {
  display: none;
}
details.trace > summary:hover {
  color: var(--foreground);
  background: var(--muted);
}
details.trace[open] > summary {
  border-bottom: 1px solid var(--border);
}
details.trace .chev {
  width: 1rem;
  height: 1rem;
  flex: none;
  transition: transform var(--dur) ease;
}
details.trace[open] .chev {
  transform: rotate(90deg);
}

/* ---- messages ---------------------------------------------------------- */
.msg {
  min-width: 0;
  overflow-wrap: anywhere;
}
.msg.user {
  align-self: flex-end;
  max-width: 80%;
  background: var(--user-bubble);
  border-radius: var(--radius) var(--radius) var(--radius-sm) var(--radius);
  padding: 0.6rem 0.9rem;
  white-space: pre-wrap;
}
.msg.assistant {
  display: grid;
  grid-template-columns: 1.75rem minmax(0, 1fr);
  gap: 0.75rem;
  align-items: start;
}
.msg.assistant > .mark {
  width: 1.75rem;
  height: 1.75rem;
  border-radius: 50%;
  background: var(--card);
  border: 1px solid var(--card-ring);
  display: grid;
  place-items: center;
}
/* The reply's round mark (the sidebar's .mark is the svg itself). */
.mark > svg {
  width: 1rem;
  height: 1rem;
}
.msg.assistant .body {
  min-width: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 0.75rem;
  align-content: start;
}
.msg.assistant .body > :empty {
  display: none;
}
/* "AI Assistant" beside the mark; on a phone the mark moves into the label. */
.reply-label {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  min-height: 1.75rem;
  margin-bottom: -0.35rem;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--muted-foreground);
}
.reply-label .mini {
  display: none;
  width: 0.9rem;
  height: 0.9rem;
}
.content {
  line-height: 1.6;
}
.content > :first-child {
  margin-top: 0;
}
.content > :last-child {
  margin-bottom: 0;
}
/* Prose stops at a readable measure; tables and code may use the whole column. */
.content > p,
.content > ul,
.content > ol {
  max-width: 72ch;
}
.content p {
  margin: 0 0 0.6rem;
}
.content h1,
.content h2,
.content h3,
.content h4 {
  font-size: 0.9375rem;
  font-weight: 600;
  margin: 0.8rem 0 0.3rem;
}
.content ul,
.content ol {
  padding-left: 1.2rem;
  margin: 0 0 0.6rem;
}
.content li {
  margin: 0.2rem 0;
}
.content li::marker {
  color: var(--muted-foreground);
}
.content strong {
  font-weight: 600;
}
.content table {
  border-collapse: collapse;
  margin: 0.4rem 0 0.8rem;
  font-variant-numeric: tabular-nums;
  line-height: 1.5;
  display: block;
  overflow-x: auto;
  max-width: 100%;
  width: fit-content;
}
.content th,
.content td {
  border: 1px solid var(--border);
  padding: 0.3rem 0.65rem;
  text-align: left;
  white-space: nowrap;
}
.content th {
  background: var(--muted);
  font-weight: 500;
}
.content code {
  background: var(--code-bg);
  border-radius: var(--radius-sm);
  padding: 0.1em 0.35em;
  font: 0.85em var(--mono);
}
.content pre {
  background: var(--code-bg);
  border-radius: var(--radius);
  padding: 0.7rem;
  overflow-x: auto;
  line-height: 1.5;
}
.content pre code {
  padding: 0;
  background: none;
}
/* Links are --foreground and underlined: --primary as text is 3.45:1 in dark. */
.content a,
.table a,
.q-meta a {
  color: var(--foreground);
  text-decoration: underline;
  text-decoration-color: color-mix(in oklch, var(--foreground) 40%, transparent);
  text-underline-offset: 3px;
  transition: text-decoration-color var(--dur) ease;
}
.content a:hover,
.table a:hover,
.q-meta a:hover {
  text-decoration-color: var(--foreground);
}

/* ---- notes attached to a reply ----------------------------------------- */
.notes {
  display: grid;
  gap: 6px;
}
.note {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  font-size: 0.8125rem;
  color: var(--muted-foreground);
}
.note .text {
  min-width: 0;
  overflow-wrap: anywhere;
}
.note.error .text {
  color: var(--foreground);
}
.note.error::before {
  content: "";
  width: 3px;
  height: 1.3rem;
  flex: none;
  border-radius: 2px;
  background: var(--destructive);
}

/* ---- the delete dialog (core-ui's alert dialog) ------------------------- */
.dialog {
  width: min(28rem, calc(100vw - 32px));
  padding: 1.5rem;
  border: 1px solid var(--card-ring);
  border-radius: var(--radius);
  background: var(--popover);
  color: var(--popover-foreground);
  box-shadow: var(--shadow-lg);
}
/* Custom properties do not reach ::backdrop in every browser, so the scrim is spelt out. */
.dialog::backdrop {
  background: oklch(0 0 0 / 0.5);
}
.dialog h2 {
  font-size: 1.0625rem;
  font-weight: 600;
  letter-spacing: calc(var(--tracking-normal) - 0.025em);
}
.dialog p {
  margin-top: 0.5rem;
  color: var(--muted-foreground);
}
.dialog-actions {
  display: flex;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 1.25rem;
}

/* ---- composer (core-ui Textarea: border-input, bg-card, rounded) --------- */
.composer-wrap {
  position: relative;
  flex: none;
  padding: 0.5rem max(1.25rem, env(safe-area-inset-right, 0px))
    calc(1rem + env(safe-area-inset-bottom, 0px)) max(1.25rem, env(safe-area-inset-left, 0px));
  background: var(--background);
}
.banner {
  max-width: var(--measure);
  margin: 0 auto 8px;
  font-size: 0.8125rem;
  overflow-wrap: anywhere;
}
.composer {
  max-width: var(--measure);
  margin: 0 auto;
  position: relative;
  background: var(--card);
  border: 1px solid var(--input);
  border-radius: var(--radius);
  overflow: hidden;
  transition: border-color var(--dur) ease;
}
/* The textarea draws no outline of its own; the whole box takes the page's ring. */
.composer:focus-within {
  border-color: var(--ring);
  outline: 2px solid var(--ring);
  outline-offset: 2px;
}
.composer textarea {
  display: block;
  width: 100%;
  min-height: 3.25rem;
  max-height: 12rem;
  resize: none;
  border: 0;
  outline: 0;
  background: transparent;
  padding: 0.85rem 1rem 0.4rem;
  line-height: 1.5;
}
.composer textarea::placeholder {
  color: var(--muted-foreground);
  opacity: 1;
}
.composer textarea:disabled {
  color: var(--muted-foreground);
  cursor: not-allowed;
}
.composer .bar {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0 0.5rem 0.5rem 1rem;
}
.composer .hint {
  flex: 1;
  min-width: 0;
  font-size: 0.75rem;
  color: var(--muted-foreground);
}
/* core-ui's progress animation, in the live lime. */
.composer .progress {
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  height: 2px;
  overflow: hidden;
}
.composer .progress::after {
  content: "";
  display: block;
  width: 25%;
  height: 100%;
  background: var(--live);
  animation: progress 1.5s ease-in-out infinite;
}
/* "Jump to latest": over the thread, just above the composer, while the reader is
   scrolled up and something new has come in. Tokens only, no lime. */
.jump {
  position: absolute;
  left: 50%;
  bottom: calc(100% + 0.5rem);
  z-index: 2;
  transform: translateX(-50%);
  display: inline-flex;
  align-items: center;
  gap: calc(var(--spacing) * 1.5);
  height: calc(var(--spacing) * 8);
  padding: 0 calc(var(--spacing) * 3);
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--card);
  color: var(--foreground);
  font-size: 0.8125rem;
  font-weight: 500;
  white-space: nowrap;
  box-shadow: var(--shadow-sm);
  transition: background-color var(--dur) ease;
}
.jump:hover {
  background: var(--muted);
}
.jump svg {
  width: 1rem;
  height: 1rem;
  flex: none;
}

/* ---- empty state ------------------------------------------------------- */
.empty {
  width: 100%;
  max-width: 36rem;
  margin: 0 auto;
  padding: 4rem 0;
}
.empty-mark {
  display: block;
  width: 2.75rem;
  height: 2.75rem;
  margin-bottom: 1.25rem;
}
.empty h2 {
  font-size: 1.5rem;
  line-height: 1.2;
  font-weight: 600;
  letter-spacing: calc(var(--tracking-normal) - 0.025em);
  margin-bottom: 0.6rem;
  text-wrap: balance;
}
.empty p {
  margin: 0 0 1.75rem;
  color: var(--muted-foreground);
  line-height: 1.6;
}
.examples {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0.5rem;
}
.example {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  width: 100%;
  min-height: 2.75rem;
  padding: 0.6rem 0.9rem;
  text-align: left;
  font-size: 0.875rem;
  background: var(--card);
  color: var(--card-foreground);
  border: 1px solid var(--card-ring);
  border-radius: var(--radius);
  transition:
    background-color var(--dur) ease,
    border-color var(--dur) ease;
}
.example:hover {
  background: var(--muted);
}
.example svg {
  width: 1rem;
  height: 1rem;
  flex: none;
  color: var(--muted-foreground);
  transition:
    transform var(--dur) ease,
    color var(--dur) ease;
}
.example:hover svg {
  color: var(--foreground);
  transform: translateX(2px);
}

/* ---- icon colours ------------------------------------------------------- */
/* Red marks a destructive button by its icon alone; the label stays --foreground. */
.btn.destructive svg,
.btn.ghost.danger svg {
  color: var(--destructive);
}

/* ---- skeletons --------------------------------------------------------- */
.skeleton {
  background: var(--muted);
  border-radius: var(--radius-btn);
  animation: pulse 1.6s ease-in-out infinite;
}
.sk-conv {
  display: grid;
  gap: 8px;
  padding: 10px 8px;
}
.sk-conv .skeleton {
  height: 1.3rem;
}
.sk-conv .sk-label {
  height: 0.9rem;
}
.sk-conv .sk-gap {
  margin-top: 8px;
}
.sk-thread {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}
.sk-question {
  align-self: flex-end;
  width: 55%;
  height: 2.4rem;
}
.sk-reply {
  display: grid;
  gap: 0.75rem;
}
.sk-line {
  height: 0.9rem;
}
.sk-chart {
  height: 9rem;
  margin-top: 4px;
  border-radius: var(--radius);
}
.w38 {
  width: 38%;
}
.w40 {
  width: 40%;
}
.w64 {
  width: 64%;
}
.w70 {
  width: 70%;
}
.w76 {
  width: 76%;
}
.w88 {
  width: 88%;
}
.w92 {
  width: 92%;
}
.w95 {
  width: 95%;
}

/* ---- the spend page ------------------------------------------------------ */
.scroll {
  flex: 1;
  min-height: 0;
  min-width: 0;
  overflow-y: auto;
}
.topbar-note {
  flex: none;
  font-size: 0.8125rem;
  color: var(--muted-foreground);
  white-space: nowrap;
}
.page {
  max-width: 56rem;
  margin: 0 auto;
  padding: 24px 20px 40px;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 20px;
}
/* The header carries the note; a phone has no room there, so it moves into the page. */
.page-note {
  display: none;
  font-size: 0.8125rem;
  color: var(--muted-foreground);
}
.page-banner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 10px;
  font-size: 0.8125rem;
  overflow-wrap: anywhere;
}
.page-banner-text {
  min-width: 0;
}
.spend-skeleton,
.spend-content {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 20px;
}
.tiles {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}
/* Tiles and panels are core-ui Cards, like the chat's cards. */
.tile,
.panel {
  background: var(--card);
  color: var(--card-foreground);
  border: 1px solid var(--card-ring);
  border-radius: var(--radius);
  min-width: 0;
}
.tile {
  padding: 14px 16px;
  display: grid;
  /* Rows from the top: a tile without a split line keeps its value where the others have theirs. */
  align-content: start;
  gap: 2px;
}
.tile .k,
.tile .s,
.tile .d {
  font-size: 0.8125rem;
  color: var(--muted-foreground);
}
.tile .v {
  font-size: 1.5rem;
  font-weight: 600;
  letter-spacing: calc(var(--tracking-normal) - 0.025em);
  font-variant-numeric: tabular-nums;
}
.panel {
  overflow: hidden;
}
.panel .head {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 2px 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
}
.panel .head h3 {
  font-size: 0.9375rem;
  font-weight: 600;
}
.panel .head-note {
  font-size: 0.8125rem;
  color: var(--muted-foreground);
}
.spend-chart {
  display: block;
  width: 100%;
  height: auto;
}
.spend-chart .grid line {
  stroke: var(--border);
  stroke-width: 1;
}
.spend-chart .labels text {
  fill: var(--muted-foreground);
  font-size: 11px;
  letter-spacing: 0;
}
/* One colour per source, keyed by its name (spend.js colourKey); any other source is muted. */
.spend-chart .seg {
  fill: var(--muted-foreground);
}
.spend-chart .seg.src-chat {
  fill: var(--primary);
}
.spend-chart .seg.src-slack {
  fill: var(--series-2);
}
/* The whole day's slot carries its tooltip. */
.spend-chart .hit {
  fill: transparent;
}
/* Lime means live: a rule under today's stack, whose segments keep their colours. */
.spend-chart .today-rule {
  fill: var(--live);
}
.chart-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 16px;
  margin: 0;
  padding: 0 16px 14px;
  list-style: none;
  font-size: 0.8125rem;
  color: var(--muted-foreground);
}
.chart-legend li {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.chart-legend .swatch {
  width: 10px;
  height: 10px;
  border-radius: 2px;
  background: var(--muted-foreground);
}
.chart-legend .swatch.src-chat {
  background: var(--primary);
}
.chart-legend .swatch.src-slack {
  background: var(--series-2);
}
.table-wrap {
  overflow-x: auto;
}
.table {
  width: 100%;
  border-collapse: collapse;
  font-variant-numeric: tabular-nums;
}
.table th,
.table td {
  padding: 9px 16px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  vertical-align: top;
}
.table th {
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--muted-foreground);
}
.table .num {
  text-align: right;
}
.table tr:last-child td {
  border-bottom: 0;
}
/* The title wraps; every other column stays on one line. */
.table .conv-cell {
  white-space: normal;
  min-width: 14rem;
  overflow-wrap: anywhere;
}
.table .sub {
  display: block;
  font-size: 0.75rem;
  color: var(--muted-foreground);
}
.table .empty-row {
  color: var(--muted-foreground);
  white-space: normal;
}
.spend-skeleton .tile {
  gap: 8px;
}
.sk-k {
  width: 40%;
  height: 0.8rem;
}
.sk-v {
  width: 55%;
  height: 1.6rem;
}
.sk-d {
  width: 75%;
  height: 0.8rem;
}
.sk-h {
  width: 30%;
  height: 0.9rem;
}
.sk-plot {
  padding: 16px;
}
.sk-plot .skeleton {
  height: 9rem;
}

/* ---- the questions page --------------------------------------------------- */
/* clip, not hidden: the day headings stick to the top of the scrolling page,
   which an overflow: hidden panel would stop. */
.questions-panel {
  overflow: clip;
}
.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--card);
}
.filters .search {
  position: relative;
  flex: 1;
  min-width: 14rem;
}
.search-ico {
  position: absolute;
  left: 10px;
  top: 50%;
  width: 0.9rem;
  height: 0.9rem;
  transform: translateY(-50%);
  color: var(--muted-foreground);
  pointer-events: none;
}
.filters .search input {
  padding-left: 2rem;
  height: calc(var(--spacing) * 8);
}
/* The menus look like the search box: core-ui's control, the page's focus ring. */
.filters select {
  height: calc(var(--spacing) * 8);
  max-width: 100%;
  padding: 0 0.6rem;
  border: 1px solid var(--input);
  border-radius: var(--radius-btn);
  background: var(--card);
  color: var(--foreground);
  box-shadow: var(--shadow-xs);
  transition: border-color var(--dur) ease;
}
.filters select:focus {
  border-color: var(--ring);
}
.filters .count {
  margin-left: auto;
  font-size: 0.8125rem;
  color: var(--muted-foreground);
  overflow-wrap: anywhere;
}
.qlist {
  list-style: none;
  margin: 0;
  padding: 0;
}
/* Each heading sticks until the next one slides over it. */
.qlist .qday {
  position: sticky;
  top: 0;
  z-index: 1;
}
/* Like the sidebar's group labels. */
.qday-label {
  font-size: 0.8125rem;
  font-weight: 500;
  color: color-mix(in oklch, var(--foreground) 70%, transparent);
  padding: 12px 16px 4px;
  background: var(--background);
}
.q {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 4px 16px;
  padding: 12px 16px;
  border-top: 1px solid var(--border);
}
.q-text {
  grid-column: 1;
  color: var(--foreground);
  overflow-wrap: anywhere;
}
.q-meta {
  grid-column: 1;
  display: flex;
  flex-wrap: wrap;
  gap: 4px 14px;
  font-size: 0.8125rem;
  color: var(--muted-foreground);
  align-items: center;
  min-width: 0;
}
.q-meta > * {
  min-width: 0;
  overflow-wrap: anywhere;
}
.q-when {
  grid-column: 2;
  grid-row: 1;
  font-size: 0.8125rem;
  color: var(--muted-foreground);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.outcome {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.outcome-ico {
  width: 0.8rem;
  height: 0.8rem;
  flex: none;
}
.outcome.ok {
  color: var(--success);
}
/* "Failed" is --foreground beside a red cross: --destructive as text is 3.85:1 on a card. */
.outcome.failed {
  color: var(--foreground);
}
.outcome.failed .outcome-ico {
  color: var(--destructive);
}
.outcome.stopped,
.outcome.running {
  color: var(--muted-foreground);
}
.qmore {
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  text-align: center;
}
.sk-q {
  display: grid;
  gap: 8px;
  padding: 14px 16px;
  border-top: 1px solid var(--border);
}
.sk-q:first-child {
  border-top: 0;
}
.sk-q .skeleton {
  height: 0.9rem;
}
.sk-q .sk-meta {
  height: 0.7rem;
}
.empty-admin {
  padding: 40px 16px;
  text-align: center;
  color: var(--muted-foreground);
}

/* ---- narrow screens ---------------------------------------------------------
   Below 1024 px the sidebar is a drawer behind the menu button (docked at 768 it would
   leave a chart too little room); below 768 the header's actions are icons and the
   reply's mark moves into its label; below 480 the composer drops its hint. */
.scrim {
  display: none;
}
@media (max-width: 1023px) {
  .app {
    grid-template-columns: minmax(0, 1fr);
  }
  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: calc(min(var(--sidebar-width-mobile), 86vw) + env(safe-area-inset-left, 0px));
    padding-left: env(safe-area-inset-left, 0px);
    z-index: 30;
    transform: translateX(-100%);
    transition: transform 200ms ease;
  }
  .sidebar.open {
    transform: none;
  }
  .topbar {
    padding-left: max(calc(var(--spacing) * 3), env(safe-area-inset-left, 0px));
    gap: calc(var(--spacing) * 1.5);
  }
  .topbar .menu {
    display: inline-flex;
    margin-left: calc(var(--spacing) * -1.5);
  }
  .scrim:not([hidden]) {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 20;
    background: var(--scrim);
  }
}
@media (max-width: 767px) {
  .topbar .act-label {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
  }
  .topbar .act {
    width: calc(var(--spacing) * 8);
    padding: 0;
  }
  .messages {
    gap: 1.25rem;
    padding: 1.25rem max(1rem, env(safe-area-inset-right, 0px)) 2rem
      max(1rem, env(safe-area-inset-left, 0px));
  }
  .composer-wrap {
    padding: 0.4rem max(0.75rem, env(safe-area-inset-right, 0px))
      calc(0.75rem + env(safe-area-inset-bottom, 0px)) max(0.75rem, env(safe-area-inset-left, 0px));
  }
  .msg.user {
    max-width: 90%;
  }
  .msg.assistant {
    grid-template-columns: minmax(0, 1fr);
    gap: 0.5rem;
  }
  .msg.assistant > .mark {
    display: none;
  }
  .reply-label .mini {
    display: inline;
  }
  .empty {
    padding: 2.5rem 0;
  }
  .topbar-note {
    display: none;
  }
  .page-note {
    display: block;
  }
  .page {
    padding: 16px 12px 32px;
    gap: 16px;
  }
  .spend-content,
  .spend-skeleton {
    gap: 16px;
  }
  .tiles {
    grid-template-columns: minmax(0, 1fr);
  }
  .filters .count {
    margin-left: 0;
    width: 100%;
  }
  .q {
    grid-template-columns: minmax(0, 1fr);
  }
  .q-when {
    grid-column: 1;
    grid-row: auto;
  }
}
/* On a touch screen every field is at least 16px: iOS Safari zooms the page in when a
   smaller one takes focus, and the zoom stays for the rest of the session. The classed
   selectors are listed so this wins over their own sizes. */
@media (pointer: coarse) {
  input,
  select,
  textarea,
  .input,
  .topbar .title-input,
  .composer textarea,
  .filters select {
    font-size: max(16px, 1em);
  }
}
@media (max-width: 479px) {
  .composer .hint {
    display: none;
  }
  .composer .bar {
    justify-content: flex-end;
  }
  .live-pill .pill-text {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
  }
  .live-pill {
    padding: 0 calc(var(--spacing) * 2);
  }
}

/* `hidden` wins over the display these components set. */
.screen[hidden],
.app[hidden],
.main[hidden],
.page-banner[hidden],
.spend-skeleton[hidden],
.spend-content[hidden],
.q-skeleton[hidden],
.qlist[hidden],
.qmore[hidden],
.empty-admin[hidden],
.btn[hidden],
.sk-conv[hidden],
.sk-thread[hidden],
.empty[hidden],
.live-pill[hidden],
.chat-actions[hidden],
.jump[hidden],
.topbar h1[hidden],
.topbar .title-input[hidden] {
  display: none;
}

@keyframes pulse {
  50% {
    opacity: 0.5;
  }
}
@keyframes progress {
  0% {
    transform: translateX(-100%);
  }
  100% {
    transform: translateX(400%);
  }
}
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}
@keyframes ping {
  75%,
  100% {
    transform: scale(2.2);
    opacity: 0;
  }
}
@keyframes blink {
  50% {
    opacity: 0;
  }
}
@keyframes shimmer {
  from {
    transform: translateX(-100%);
  }
  to {
    transform: translateX(100%);
  }
}

/* Reduced motion stops every animation and transition on the page: the pulse and ping,
   the caret, skeletons, spinners, the chart placeholder, hovers and the drawer. The
   progress bar stays as a still lime line so a pending reply is still marked. */
@media (prefers-reduced-motion: reduce) {
  .skeleton,
  .spinner,
  .btn .spinner,
  .cursor,
  .chart.pending::after,
  .composer .progress::after {
    animation: none;
  }
  .live-dot::before,
  .conv .dot::before,
  .step.active .pulse::before {
    display: none;
    animation: none;
  }
  .composer .progress::after {
    width: 100%;
    opacity: 0.6;
  }
  .btn,
  .input,
  .conv,
  .sidebar,
  .example,
  .example svg,
  .file-link,
  .composer,
  .jump,
  .filters select,
  details.trace > summary,
  details.trace .chev,
  .content a,
  .table a,
  .q-meta a {
    transition: none;
  }
}
