/* ==========================================================================
   Krisp dashboard - design system
   Quiet neutral surfaces, one accent, Inter throughout. The accent is the
   workspace's own colour (dashboard.js applyThemeColor), so everything else
   stays neutral: colour means "act here" or a state, never decoration.

   Contents
     1  Tokens              8  Tabs                 15 Modal and menu
     2  Base                9  Tables and lists     16 Banner
     3  Typography + utils  10 Avatar               17 Meter
     4  Layout primitives   11 Metric               18 Code, snippet, kbd
     5  Buttons             12 Empty / error state  19 Scroll areas
     6  Cards               13 Skeleton, spinner    20 App shell
     7  Forms               14 Toasts               21 Auth screen
        Badges, chips, dots                         22 Motion, print, forced colours

   Conventions
     - Component classes are flat and prefixed by component (.btn, .btn-primary).
     - State classes start with is- (.is-active, .is-loading, .is-invalid).
     - View-specific CSS lives in /assets/views/<id>.css and must scope every
       selector under .view-<id> (the class the shell puts on the view root).
     - Breakpoints: 640 / 768 / 1024 / 1280 (min-width, mobile first).
   ========================================================================== */

/* -- 1. Tokens ------------------------------------------------------------- */

/* Inter, self-hosted (public/assets/fonts, SIL Open Font License). */
@font-face {
  font-family: "Inter";
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url("fonts/inter-latin-wght-normal.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

@font-face {
  font-family: "Inter";
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url("fonts/inter-latin-ext-wght-normal.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

:root {
  /* Surfaces: a cool, quiet neutral. */
  --bg: #F6F7F9;
  --surface: #FFFFFF;
  --card: #FFFFFF;
  --surface-2: #FAFAFB;
  --sunken: #F1F2F5;
  --sunken-strong: #E5E7EC;
  --dark: #121419;
  --dark-raised: #1E2129;
  --field: #FFFFFF;        /* inside an input, a select or a text area */
  --tab-on: #FFFFFF;       /* the selected segment of a pill tab bar */
  --switch-off: #C9CDD5;   /* the track of a toggle that is off */
  --skeleton-hi: #F8F9FB;  /* the light sweep over a loading placeholder */

  /* Ink */
  --ink: #121419;
  --ink-2: #3D424C;
  --muted: #687080;
  --faint: #9AA0AB;
  --placeholder: #9AA0AB;
  --on-ink: #FFFFFF;       /* text on a fill of --ink */
  --on-dark: #F4F5F7;
  --on-dark-muted: #A1A6B2;

  /* Lines */
  --border: #E6E8EC;
  --border-strong: #D6D9DF;
  --border-control: #D1D5DC;
  --border-hover: #B8BDC7;
  --dark-line: #121419;    /* the edge of a --dark surface: invisible here */
  --float-line: #E6E8EC;   /* the edge of what floats: menus, dialogs */

  /* Washes over any surface (hover, pressed), what dims the page behind a
     dialog, and the highlight of selected text. */
  --wash-1: rgba(18, 20, 25, 0.045);
  --wash-2: rgba(18, 20, 25, 0.07);
  --wash-3: rgba(18, 20, 25, 0.12);
  --scrim: rgba(18, 20, 25, 0.42);
  --scrim-soft: rgba(18, 20, 25, 0.18);
  --selection: color-mix(in srgb, var(--accent) 22%, transparent);

  /* Accent: Krisp violet, from the logo. The shell swaps in the workspace's
     own colour, and --accent-fg is the text that reads on it. */
  --accent: #5C4DE6;
  --accent-hover: #4D3FD6;
  --accent-active: #4033BC;
  --accent-ink: #4537C8;
  --accent-soft: #EFEDFD;
  --accent-on-dark: #ABA2F8;
  --accent-fg: #FFFFFF;
  --focus: rgba(92, 77, 230, 0.45);

  /* Semantic */
  --success: #1F9D55;
  --success-ink: #157242;
  --success-soft: #E8F6EE;
  --warning: #D97706;
  --warning-ink: #9A5506;
  --warning-soft: #FEF4E6;
  --danger: #DC3B2F;
  --danger-ink: #B42318;
  --danger-soft: #FDEEEC;
  --info: #2E78C7;
  --info-ink: #1F5F9F;
  --info-soft: #EAF3FC;
  --violet: #7C5CEB;
  --violet-ink: #5B3FC9;
  --violet-soft: #F2EEFE;
  --success-line: #C3E6D0;
  --warning-line: #F7DDB7;
  --danger-line: #F6CFCA;
  --info-line: #CFE0F3;
  --violet-line: #D8CCF0;
  --danger-hover: #B42318;
  --danger-active: #8F1C13;

  /* Internal notes and search hits: the amber paper the team writes on. */
  --note-bg: #FFF6DA;
  --note-line: #C49A3A;
  --note-tab: #F2E2B4;
  --mark-bg: #FDE68A;
  --mark-ink: #1F2937;

  /* Chart series: fixed, independent of the accent, separable for colour vision. */
  --chart-1: #3E63DD;
  --chart-2: #12A594;
  --chart-3: #8E4EC6;
  --chart-grid: #EEF0F3;
  --chart-axis: #D6D9DF;

  /* Type: one family. */
  --font-display: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-body: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, "SF Mono", "Cascadia Mono", "Roboto Mono", Menlo, Consolas, monospace;

  --text-xs: 0.75rem;     /* 12 */
  --text-sm: 0.8125rem;   /* 13 */
  --text-base: 0.875rem;  /* 14 */
  --text-md: 0.9375rem;   /* 15 */
  --text-lg: 1.0625rem;   /* 17 */
  --text-xl: 1.25rem;     /* 20 */
  --text-2xl: 1.5rem;     /* 24 */
  --text-3xl: 1.875rem;   /* 30 */

  /* Space: 4px rhythm */
  --s-1: 4px;
  --s-2: 8px;
  --s-3: 12px;
  --s-4: 16px;
  --s-5: 20px;
  --s-6: 24px;
  --s-8: 32px;
  --s-10: 40px;
  --s-12: 48px;
  --s-16: 64px;

  /* Shape, depth, motion: flat by default; shadows only lift what floats. */
  --radius-sm: 6px;
  --radius: 8px;
  --radius-lg: 10px;
  --radius-pill: 999px;
  --shadow-1: 0 1px 2px rgba(18, 20, 25, 0.05);
  --shadow-2: 0 6px 20px -4px rgba(18, 20, 25, 0.12), 0 1px 3px rgba(18, 20, 25, 0.06);
  --shadow-3: 0 24px 48px -12px rgba(18, 20, 25, 0.24), 0 2px 6px rgba(18, 20, 25, 0.06);
  --ring: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent);
  --ring-danger: 0 0 0 3px rgba(220, 59, 47, 0.2);
  --select-chevron: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23687080' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m7 10 5 5 5-5'/%3E%3C/svg%3E");
  --ease: cubic-bezier(0.2, 0, 0, 1);
  --t: 150ms;

  /* Layout */
  --sidebar-w: 240px;
  --topbar-h: 56px;
  --content-max: 1360px;
  --page-pad: 16px;
  --control-h: 36px;

  color-scheme: light;
}

/* Dark. Written twice - for a chosen dark theme, and for the system when the
   person has not chosen light - so the two blocks below must stay identical
   (tests/dark_mode.test.mjs). public/assets/theme.js sets data-theme. Screen
   only: paper stays white, so a page prints in the light palette. */
@media screen {
  :root[data-theme="dark"] {
    /* Surfaces: cool neutral greys, never pure black. Raised is lighter, and
       hairlines do the separating. --dark is what light keeps deliberately dark
       (toasts, code, the operator's bubble, the sign-in panel): here it is a
       raised surface with an edge (--dark-line). What light fills with --ink
       turns light, and --on-ink is the text on it. */
    --bg: #0E1014;
    --surface: #15171C;
    --card: #15171C;
    --surface-2: #191C22;
    --sunken: #1C1F26;
    --sunken-strong: #262A33;
    --dark: #1E2229;
    --dark-raised: #2A2F39;
    --field: #0F1217;
    --tab-on: #2B303A;
    --switch-off: #3F4551;
    --skeleton-hi: #262A33;

    /* Ink */
    --ink: #E9EBEF;
    --ink-2: #C4C8D0;
    --muted: #969DA9;
    --faint: #7E8591;
    --placeholder: #7E8591;
    --on-ink: #0E1014;
    --on-dark: #F4F5F7;
    --on-dark-muted: #A1A6B2;

    /* Lines */
    --border: #272B33;
    --border-strong: #31363F;
    --border-control: #3A404B;
    --border-hover: #4F5662;
    --dark-line: #363C47;
    --float-line: #3A404B;

    /* Washes, scrims, selected text */
    --wash-1: rgba(255, 255, 255, 0.05);
    --wash-2: rgba(255, 255, 255, 0.08);
    --wash-3: rgba(255, 255, 255, 0.12);
    --scrim: rgba(0, 0, 0, 0.62);
    --scrim-soft: rgba(0, 0, 0, 0.4);
    --selection: color-mix(in srgb, var(--accent) 45%, transparent);

    /* Accent: Krisp violet, as the sign-in screen shows it. Once a workspace is
       open the shell computes these from its colour (lib/theme.js accentTokens). */
    --accent: #5C4DE6;
    --accent-hover: #5346CD;
    --accent-active: #4A3FB5;
    --accent-ink: #8A7FED;
    --accent-soft: #222140;
    --accent-on-dark: #8A7FED;
    --accent-fg: #FFFFFF;
    --focus: rgba(138, 127, 237, 0.85);

    /* Semantic: inks that read on dark, dark tints for the soft fills. */
    --success: #1F9D55;
    --success-ink: #4CC38A;
    --success-soft: #172C25;
    --warning: #D97706;
    --warning-ink: #F0B45C;
    --warning-soft: #342618;
    --danger: #DC3B2F;
    --danger-ink: #F2877D;
    --danger-soft: #351D1F;
    --info: #2E78C7;
    --info-ink: #6CB2F0;
    --info-soft: #192737;
    --violet: #7C5CEB;
    --violet-ink: #B4A0F5;
    --violet-soft: #25223D;
    --success-line: #194630;
    --warning-line: #5A3914;
    --danger-line: #5B2423;
    --info-line: #1E3958;
    --violet-line: #392F64;
    --danger-hover: #C4332A;
    --danger-active: #A62B22;

    /* Internal notes and search hits */
    --note-bg: #2D2319;
    --note-line: #907331;
    --note-tab: #3C2F1C;
    --mark-bg: #6B5514;
    --mark-ink: #FFF4C2;

    /* Chart series: lifted to read on the dark surface, same order and hues. */
    --chart-1: #5B7BEF;
    --chart-2: #2BB9A6;
    --chart-3: #A976DC;
    --chart-grid: #23272F;
    --chart-axis: #343A44;

    /* Depth: shadows are heavier, but the borders still carry the edges. */
    --shadow-1: 0 1px 2px rgba(0, 0, 0, 0.4);
    --shadow-2: 0 8px 24px -4px rgba(0, 0, 0, 0.55), 0 1px 3px rgba(0, 0, 0, 0.3);
    --shadow-3: 0 24px 48px -12px rgba(0, 0, 0, 0.65), 0 2px 6px rgba(0, 0, 0, 0.35);
    --ring: 0 0 0 3px color-mix(in srgb, var(--accent) 32%, transparent);
    --ring-danger: 0 0 0 3px rgba(242, 135, 125, 0.28);
    --select-chevron: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23969DA9' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m7 10 5 5 5-5'/%3E%3C/svg%3E");

    color-scheme: dark;
  }
}

@media screen and (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    /* Surfaces: cool neutral greys, never pure black. Raised is lighter, and
       hairlines do the separating. --dark is what light keeps deliberately dark
       (toasts, code, the operator's bubble, the sign-in panel): here it is a
       raised surface with an edge (--dark-line). What light fills with --ink
       turns light, and --on-ink is the text on it. */
    --bg: #0E1014;
    --surface: #15171C;
    --card: #15171C;
    --surface-2: #191C22;
    --sunken: #1C1F26;
    --sunken-strong: #262A33;
    --dark: #1E2229;
    --dark-raised: #2A2F39;
    --field: #0F1217;
    --tab-on: #2B303A;
    --switch-off: #3F4551;
    --skeleton-hi: #262A33;

    /* Ink */
    --ink: #E9EBEF;
    --ink-2: #C4C8D0;
    --muted: #969DA9;
    --faint: #7E8591;
    --placeholder: #7E8591;
    --on-ink: #0E1014;
    --on-dark: #F4F5F7;
    --on-dark-muted: #A1A6B2;

    /* Lines */
    --border: #272B33;
    --border-strong: #31363F;
    --border-control: #3A404B;
    --border-hover: #4F5662;
    --dark-line: #363C47;
    --float-line: #3A404B;

    /* Washes, scrims, selected text */
    --wash-1: rgba(255, 255, 255, 0.05);
    --wash-2: rgba(255, 255, 255, 0.08);
    --wash-3: rgba(255, 255, 255, 0.12);
    --scrim: rgba(0, 0, 0, 0.62);
    --scrim-soft: rgba(0, 0, 0, 0.4);
    --selection: color-mix(in srgb, var(--accent) 45%, transparent);

    /* Accent: Krisp violet, as the sign-in screen shows it. Once a workspace is
       open the shell computes these from its colour (lib/theme.js accentTokens). */
    --accent: #5C4DE6;
    --accent-hover: #5346CD;
    --accent-active: #4A3FB5;
    --accent-ink: #8A7FED;
    --accent-soft: #222140;
    --accent-on-dark: #8A7FED;
    --accent-fg: #FFFFFF;
    --focus: rgba(138, 127, 237, 0.85);

    /* Semantic: inks that read on dark, dark tints for the soft fills. */
    --success: #1F9D55;
    --success-ink: #4CC38A;
    --success-soft: #172C25;
    --warning: #D97706;
    --warning-ink: #F0B45C;
    --warning-soft: #342618;
    --danger: #DC3B2F;
    --danger-ink: #F2877D;
    --danger-soft: #351D1F;
    --info: #2E78C7;
    --info-ink: #6CB2F0;
    --info-soft: #192737;
    --violet: #7C5CEB;
    --violet-ink: #B4A0F5;
    --violet-soft: #25223D;
    --success-line: #194630;
    --warning-line: #5A3914;
    --danger-line: #5B2423;
    --info-line: #1E3958;
    --violet-line: #392F64;
    --danger-hover: #C4332A;
    --danger-active: #A62B22;

    /* Internal notes and search hits */
    --note-bg: #2D2319;
    --note-line: #907331;
    --note-tab: #3C2F1C;
    --mark-bg: #6B5514;
    --mark-ink: #FFF4C2;

    /* Chart series: lifted to read on the dark surface, same order and hues. */
    --chart-1: #5B7BEF;
    --chart-2: #2BB9A6;
    --chart-3: #A976DC;
    --chart-grid: #23272F;
    --chart-axis: #343A44;

    /* Depth: shadows are heavier, but the borders still carry the edges. */
    --shadow-1: 0 1px 2px rgba(0, 0, 0, 0.4);
    --shadow-2: 0 8px 24px -4px rgba(0, 0, 0, 0.55), 0 1px 3px rgba(0, 0, 0, 0.3);
    --shadow-3: 0 24px 48px -12px rgba(0, 0, 0, 0.65), 0 2px 6px rgba(0, 0, 0, 0.35);
    --ring: 0 0 0 3px color-mix(in srgb, var(--accent) 32%, transparent);
    --ring-danger: 0 0 0 3px rgba(242, 135, 125, 0.28);
    --select-chevron: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23969DA9' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m7 10 5 5 5-5'/%3E%3C/svg%3E");

    color-scheme: dark;
  }
}

@media (min-width: 768px) {
  :root { --page-pad: 24px; }
}

@media (min-width: 1280px) {
  :root { --page-pad: 32px; }
}

/* -- 2. Base --------------------------------------------------------------- */

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  background-color: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: var(--text-base);
  line-height: 1.5;
  font-feature-settings: "cv11";
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

h1, h2, h3, h4, h5, h6, p, figure, blockquote, dl, dd {
  margin: 0;
}

h1, h2, h3 {
  font-family: var(--font-display);
  font-weight: 600;
  line-height: 1.25;
  letter-spacing: -0.018em;
  text-wrap: balance;
}

h4, h5, h6 {
  font-size: var(--text-base);
  font-weight: 600;
  line-height: 1.35;
}

ul, ol {
  margin: 0;
  padding: 0;
  list-style: none;
}

a {
  color: var(--accent-ink);
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
  transition: color var(--t) var(--ease);
}

a:hover {
  color: var(--ink);
}

img, svg, video, canvas {
  display: block;
  max-width: 100%;
}

svg.icon {
  flex: none;
  display: inline-block;
  vertical-align: -0.2em;
}

button, input, select, textarea {
  font: inherit;
  color: inherit;
  letter-spacing: inherit;
  margin: 0;
}

button {
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
  text-align: inherit;
}

button:disabled {
  cursor: not-allowed;
}

table {
  border-collapse: collapse;
  border-spacing: 0;
}

hr {
  border: 0;
  border-top: 1px solid var(--border);
  margin: var(--s-4) 0;
}

[hidden] {
  display: none !important;
}

::selection {
  background: var(--selection);
  color: var(--ink);
}

/* One focus language everywhere: an accent ring, only for keyboard users. */
:focus {
  outline: none;
}

:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

.skip-link {
  position: fixed;
  top: 8px;
  left: 8px;
  z-index: 2000;
  padding: 10px 14px;
  border-radius: var(--radius);
  background: var(--ink);
  color: var(--on-ink);
  font-weight: 600;
  text-decoration: none;
  transform: translateY(-160%);
  transition: transform var(--t) var(--ease);
}

.skip-link:focus {
  transform: none;
  color: var(--on-ink);
}

/* -- 3. Typography and utilities ------------------------------------------- */

.display {
  font-family: var(--font-display);
  font-weight: 600;
  letter-spacing: -0.015em;
  line-height: 1.15;
}

.title-xl { font-size: var(--text-3xl); }
.title-lg { font-size: var(--text-2xl); }
.title-md { font-size: var(--text-xl); }
.title-sm { font-size: var(--text-lg); }

.eyebrow {
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}

.lede {
  font-size: var(--text-md);
  color: var(--ink-2);
  line-height: 1.55;
}

.muted { color: var(--muted); }
.subtle { color: var(--ink-2); }
.small { font-size: var(--text-sm); }
.tiny { font-size: var(--text-xs); }
.strong { font-weight: 600; }
.mono { font-family: var(--font-mono); font-size: 0.92em; }
.tabular { font-variant-numeric: tabular-nums; }
.nowrap { white-space: nowrap; }
.text-right { text-align: right; }
.text-center { text-align: center; }
.text-success { color: var(--success-ink); }
.text-warning { color: var(--warning-ink); }
.text-danger { color: var(--danger-ink); }
.text-info { color: var(--info-ink); }
.text-accent { color: var(--accent-ink); }

.truncate {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}

.clamp-2 {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  overflow: hidden;
}

.break-anywhere {
  overflow-wrap: anywhere;
  word-break: break-word;
}

.link {
  color: var(--accent-ink);
  font-weight: 500;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.link:hover {
  color: var(--ink);
  text-decoration: underline;
}

.sr-only {
  position: absolute !important;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  border: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
}

.hidden { display: none !important; }

.divider {
  height: 1px;
  background: var(--border);
  border: 0;
  margin: var(--s-4) 0;
}

/* -- 4. Layout primitives -------------------------------------------------- */

/* Page: the padded, width-capped column a normal view renders into. The shell
   adds this class to the view root for layout: 'page' views. */
.page {
  width: 100%;
  max-width: var(--content-max);
  margin: 0 auto;
  padding: var(--s-6) var(--page-pad) var(--s-16);
}

.page-narrow { max-width: 760px; }

.page-header {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: var(--s-4);
  margin-bottom: var(--s-6);
}

.page-heading {
  font-size: var(--text-2xl);
  letter-spacing: -0.022em;
}

.page-sub {
  margin-top: 4px;
  color: var(--muted);
  font-size: var(--text-base);
  max-width: 68ch;
  text-wrap: pretty;
}

.page-header > :first-child {
  flex: 1 1 320px;
  min-width: 0;
}

.page-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--s-2);
}

.section {
  margin-top: var(--s-8);
}

.section-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--s-3);
  margin-bottom: var(--s-3);
}

.section-title {
  font-size: var(--text-md);
  font-weight: 600;
}

/* Vertical rhythm */
.stack { display: flex; flex-direction: column; gap: var(--s-4); }
.stack-xs { gap: var(--s-1); }
.stack-sm { gap: var(--s-2); }
.stack-lg { gap: var(--s-6); }
.stack-xl { gap: var(--s-8); }
.stack > * { min-width: 0; }

/* Horizontal cluster */
.row { display: flex; align-items: center; gap: var(--s-3); min-width: 0; }
.row-sm { gap: var(--s-2); }
.row-lg { gap: var(--s-4); }
.row-wrap { flex-wrap: wrap; }
.row-between { justify-content: space-between; }
.row-end { justify-content: flex-end; }
.row-top { align-items: flex-start; }
.row-baseline { align-items: baseline; }
.grow { flex: 1 1 0; min-width: 0; }
.spacer { flex: 1 1 auto; }
.shrink-0 { flex: none; }

/* Grids: one column on phones, widening at the breakpoints. */
.grid {
  display: grid;
  gap: var(--s-4);
  grid-template-columns: minmax(0, 1fr);
}

.grid > * { min-width: 0; }

.grid-auto {
  grid-template-columns: repeat(auto-fill, minmax(min(100%, var(--grid-min, 260px)), 1fr));
}

@media (min-width: 640px) {
  .grid-2, .grid-3, .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (min-width: 1024px) {
  .grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (min-width: 1280px) {
  .grid { gap: var(--s-5); }
  .grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}

/* Main + aside. Stacks below 1280 (the sidebar already took 240px). */
.split {
  display: grid;
  gap: var(--s-4);
  grid-template-columns: minmax(0, 1fr);
  align-items: start;
}

.split > * { min-width: 0; }

@media (min-width: 1280px) {
  .split { gap: var(--s-5); grid-template-columns: minmax(0, 2fr) minmax(300px, 1fr); }
  .split-even { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* -- 5. Buttons ------------------------------------------------------------ */

.btn {
  --btn-bg: var(--surface);
  --btn-fg: var(--ink);
  --btn-border: var(--border-control);
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: var(--control-h);
  padding: 0 14px;
  border: 1px solid var(--btn-border);
  border-radius: var(--radius);
  background: var(--btn-bg);
  color: var(--btn-fg);
  font-size: var(--text-base);
  font-weight: 500;
  line-height: 1.2;
  text-decoration: none;
  white-space: nowrap;
  user-select: none;
  cursor: pointer;
  transition:
    background-color var(--t) var(--ease),
    border-color var(--t) var(--ease),
    color var(--t) var(--ease),
    box-shadow var(--t) var(--ease);
}

.btn:hover { color: var(--btn-fg); }
.btn:focus-visible { border-radius: var(--radius); }
.btn .icon { flex: none; }

/* Primary: the one action that moves the task forward. Solid, never a gradient. */
.btn-primary {
  --btn-bg: var(--accent);
  --btn-fg: var(--accent-fg);
  --btn-border: var(--accent);
  box-shadow: 0 1px 2px rgba(18, 20, 25, 0.12);
}

.btn-primary:hover { --btn-bg: var(--accent-hover); --btn-border: var(--accent-hover); }
.btn-primary:active { --btn-bg: var(--accent-active); --btn-border: var(--accent-active); box-shadow: none; }

/* Secondary: outlined, on white. */
.btn-secondary { box-shadow: var(--shadow-1); }
.btn-secondary:hover { --btn-bg: var(--surface-2); --btn-border: var(--border-hover); }
.btn-secondary:active { --btn-bg: var(--sunken); box-shadow: none; }

/* Ghost: text only until hovered. */
.btn-ghost {
  --btn-bg: transparent;
  --btn-fg: var(--ink-2);
  --btn-border: transparent;
}

.btn-ghost:hover { --btn-bg: var(--sunken); --btn-fg: var(--ink); }
.btn-ghost:active { --btn-bg: var(--sunken-strong); }

.btn-danger {
  --btn-bg: var(--danger);
  --btn-fg: #FFFFFF;
  --btn-border: var(--danger);
  box-shadow: 0 1px 2px rgba(18, 20, 25, 0.12);
}

.btn-danger:hover { --btn-bg: var(--danger-hover); --btn-border: var(--danger-hover); }
.btn-danger:active { --btn-bg: var(--danger-active); --btn-border: var(--danger-active); box-shadow: none; }

/* Quiet destructive action: reads as text, turns red on hover. */
.btn-danger-ghost {
  --btn-bg: transparent;
  --btn-fg: var(--danger-ink);
  --btn-border: transparent;
}

.btn-danger-ghost:hover { --btn-bg: var(--danger-soft); }

/* For dark cards. */
.btn-on-dark {
  --btn-bg: transparent;
  --btn-fg: var(--on-dark);
  --btn-border: rgba(255, 255, 255, 0.24);
}

.btn-on-dark:hover {
  --btn-bg: rgba(255, 255, 255, 0.08);
  --btn-border: rgba(255, 255, 255, 0.4);
}

.btn-sm {
  min-height: 30px;
  padding: 0 10px;
  border-radius: 7px;
  font-size: var(--text-sm);
  gap: 5px;
}

.btn-lg {
  min-height: 42px;
  padding: 0 18px;
  font-size: var(--text-md);
}

.btn-block {
  display: flex;
  width: 100%;
}

/* Icon button: a square with soft corners. Always give it an aria-label. */
.btn-icon {
  width: var(--control-h);
  min-width: var(--control-h);
  padding: 0;
}

.btn-icon.btn-sm { width: 30px; min-width: 30px; }
.btn-icon.btn-lg { width: 42px; min-width: 42px; }

.btn:disabled,
.btn[aria-disabled="true"],
.btn.is-disabled {
  opacity: 0.5;
  cursor: not-allowed;
  box-shadow: none;
  pointer-events: none;
}

/* Loading: keeps its width, hides the label, shows a spinner. */
.btn.is-loading {
  color: transparent !important;
  pointer-events: none;
  opacity: 1;
}

.btn.is-loading > * {
  visibility: hidden;
}

.btn.is-loading::after {
  content: "";
  position: absolute;
  inset: 0;
  margin: auto;
  width: 16px;
  height: 16px;
  border: 2px solid var(--btn-fg);
  border-right-color: transparent;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

.btn-group {
  display: inline-flex;
  flex-wrap: wrap;
  gap: var(--s-2);
}

/* -- 6. Cards -------------------------------------------------------------- */

/* Flat: a white surface and a hairline. Shadows are for what floats. */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--s-5);
  min-width: 0;
}

.card-flush { padding: 0; overflow: hidden; }
.card-pad-sm { padding: var(--s-4); }
.card-pad-lg { padding: var(--s-6); }

@media (min-width: 1280px) {
  .card-pad-lg { padding: var(--s-8); }
}

.card-hover,
a.card,
button.card {
  transition: border-color var(--t) var(--ease), box-shadow var(--t) var(--ease);
}

a.card,
button.card {
  display: block;
  width: 100%;
  color: inherit;
  text-decoration: none;
  cursor: pointer;
}

.card-hover:hover,
a.card:hover,
button.card:hover {
  border-color: var(--border-strong);
  box-shadow: var(--shadow-1);
}

a.card:focus-visible,
button.card:focus-visible {
  border-radius: var(--radius-lg);
}

.card-sunken {
  background: var(--surface-2);
}

.card-accent {
  background: var(--accent-soft);
  border-color: color-mix(in srgb, var(--accent) 18%, transparent);
}

/* The dark card: featured integration, onboarding hero, upsell. */
.card-dark {
  background: var(--dark);
  border-color: var(--dark-line);
  color: var(--on-dark);
}

.card-dark .muted,
.card-dark .card-sub,
.card-dark .eyebrow { color: var(--on-dark-muted); }
.card-dark a:not(.btn) { color: var(--accent-on-dark); }
.card-dark a:not(.btn):hover { color: var(--on-dark); }
.card-dark :focus-visible { outline-color: var(--accent-on-dark); }

.card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--s-3);
  margin-bottom: var(--s-4);
}

.card-flush > .card-header {
  padding: var(--s-5) var(--s-5) 0;
}

.card-title {
  font-family: var(--font-display);
  font-size: var(--text-md);
  font-weight: 600;
  line-height: 1.35;
  letter-spacing: -0.012em;
}

.card-sub {
  margin-top: 2px;
  font-size: var(--text-sm);
  color: var(--muted);
}

.card-actions {
  display: flex;
  align-items: center;
  gap: var(--s-2);
  flex: none;
}

.card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-3);
  margin-top: var(--s-4);
  padding-top: var(--s-3);
  border-top: 1px solid var(--border);
  font-size: var(--text-sm);
}

.card-flush > .card-footer {
  margin-top: 0;
  padding: var(--s-3) var(--s-5);
}

/* -- 7. Forms -------------------------------------------------------------- */

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}

.label {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--s-2);
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--ink);
}

.label-optional {
  font-weight: 400;
  color: var(--faint);
}

.input,
.select,
.textarea {
  display: block;
  width: 100%;
  min-height: var(--control-h);
  padding: 0 12px;
  border: 1px solid var(--border-control);
  border-radius: var(--radius);
  background-color: var(--field);
  color: var(--ink);
  font-size: var(--text-base);
  line-height: 1.4;
  box-shadow: var(--shadow-1);
  transition:
    border-color var(--t) var(--ease),
    box-shadow var(--t) var(--ease),
    background-color var(--t) var(--ease);
  appearance: none;
  -webkit-appearance: none;
}

.input::placeholder,
.textarea::placeholder {
  color: var(--placeholder);
  opacity: 1;
}

.input:hover,
.select:hover,
.textarea:hover {
  border-color: var(--border-hover);
}

.input:focus,
.select:focus,
.textarea:focus,
.input:focus-visible,
.select:focus-visible,
.textarea:focus-visible {
  outline: 2px solid transparent; /* visible in forced-colours mode */
  outline-offset: 0;
  border-color: var(--accent);
  border-radius: var(--radius);
  box-shadow: var(--ring);
}

.input:disabled,
.select:disabled,
.textarea:disabled {
  background-color: var(--sunken);
  color: var(--muted);
  border-color: var(--border);
  box-shadow: none;
  cursor: not-allowed;
}

.input[readonly] {
  background-color: var(--surface-2);
}

.textarea {
  min-height: 96px;
  padding: 9px 12px;
  line-height: 1.5;
  resize: vertical;
}

.select {
  padding-right: 34px;
  cursor: pointer;
  background-image: var(--select-chevron);
  background-repeat: no-repeat;
  background-position: right 10px center;
  background-size: 16px;
}

.input-sm,
.select-sm {
  min-height: 30px;
  font-size: var(--text-sm);
  padding-left: 10px;
}

.input-lg {
  min-height: 42px;
  font-size: var(--text-md);
  padding: 0 var(--s-4);
}

.input.is-invalid,
.select.is-invalid,
.textarea.is-invalid,
.input[aria-invalid="true"],
.select[aria-invalid="true"],
.textarea[aria-invalid="true"] {
  border-color: var(--danger);
}

.input.is-invalid:focus,
.textarea.is-invalid:focus,
.input[aria-invalid="true"]:focus,
.textarea[aria-invalid="true"]:focus {
  box-shadow: var(--ring-danger);
}

.hint {
  font-size: var(--text-sm);
  color: var(--muted);
}

.field-error {
  display: flex;
  align-items: flex-start;
  gap: 6px;
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--danger-ink);
}

.field-error .icon { margin-top: 2px; }

/* Input with a leading icon: <div class="input-group">icon + input</div> */
.input-group {
  position: relative;
  display: block;
}

.input-group > .icon {
  position: absolute;
  top: 50%;
  left: 11px;
  transform: translateY(-50%);
  color: var(--faint);
  pointer-events: none;
}

.input-group > .icon + .input {
  padding-left: 34px;
}

/* A trailing control inside the input (show password, clear). */
.input-group > .input-affix {
  position: absolute;
  top: 50%;
  right: 4px;
  transform: translateY(-50%);
}

.input-group.has-affix > .input {
  padding-right: 42px;
}

.form-row {
  display: grid;
  gap: var(--s-4);
  grid-template-columns: minmax(0, 1fr);
}

@media (min-width: 640px) {
  .form-row { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

.form-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: var(--s-2);
  margin-top: var(--s-2);
}

.fieldset {
  border: 0;
  margin: 0;
  padding: 0;
  min-width: 0;
}

.fieldset > legend {
  padding: 0;
  margin-bottom: var(--s-3);
  font-weight: 600;
}

/* Toggle switch, 36x20.
   <label class="toggle"><input type="checkbox" role="switch"><span class="toggle-track"></span><span class="toggle-label">Text</span></label> */
.toggle {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: 24px;
  cursor: pointer;
  user-select: none;
}

.toggle > input {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  opacity: 0;
  pointer-events: none;
}

.toggle-track {
  position: relative;
  flex: none;
  width: 36px;
  height: 20px;
  border-radius: var(--radius-pill);
  background: var(--switch-off);
  transition: background-color var(--t) var(--ease), box-shadow var(--t) var(--ease);
}

.toggle-track::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #FFFFFF;
  box-shadow: 0 1px 2px rgba(18, 20, 25, 0.25);
  transition: transform var(--t) var(--ease);
}

.toggle:hover > input:not(:checked):not(:disabled) + .toggle-track { background: var(--border-hover); }

.toggle > input:checked + .toggle-track {
  background: var(--accent);
}

.toggle > input:checked + .toggle-track::after {
  transform: translateX(16px);
}

.toggle > input:focus-visible + .toggle-track {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

.toggle > input:disabled + .toggle-track {
  opacity: 0.5;
}

.toggle:has(> input:disabled) {
  cursor: not-allowed;
}

.toggle-label {
  font-size: var(--text-base);
  font-weight: 500;
}

/* Setting row: text on the left, control on the right. */
.setting {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-4);
  padding: var(--s-4) 0;
  border-bottom: 1px solid var(--border);
}

.setting:last-child { border-bottom: 0; }
.setting-title { font-weight: 500; }
.setting-text { font-size: var(--text-sm); color: var(--muted); margin-top: 2px; }

.checkbox,
.radio {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: 24px;
  cursor: pointer;
}

.checkbox > input,
.radio > input {
  width: 16px;
  height: 16px;
  margin: 0;
  flex: none;
  accent-color: var(--accent);
  cursor: pointer;
}

/* -- Badges, chips, pills, dots -------------------------------------------- */

/* Badge: a quiet label. Colour only when it carries a state. */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 20px;
  padding: 0 7px;
  border-radius: var(--radius-sm);
  background: var(--sunken);
  color: var(--ink-2);
  font-size: var(--text-xs);
  font-weight: 500;
  line-height: 1;
  white-space: nowrap;
  vertical-align: middle;
}

.badge .icon { margin-left: -1px; }
.badge-lg { height: 24px; padding: 0 9px; font-size: var(--text-sm); }
.badge-accent { background: var(--accent-soft); color: var(--accent-ink); }
.badge-success { background: var(--success-soft); color: var(--success-ink); }
.badge-warning { background: var(--warning-soft); color: var(--warning-ink); }
.badge-danger { background: var(--danger-soft); color: var(--danger-ink); }
.badge-info { background: var(--info-soft); color: var(--info-ink); }
.badge-violet { background: var(--violet-soft); color: var(--violet-ink); }
.badge-dark { background: var(--dark); color: var(--on-dark); }
.badge-amber { background: var(--accent); color: var(--accent-fg); }
.badge-outline { background: transparent; box-shadow: inset 0 0 0 1px var(--border-strong); color: var(--ink-2); }

/* Chip: a toggleable filter. Use <button class="chip" aria-pressed="true|false">. */
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 30px;
  padding: 0 10px;
  border: 1px solid var(--border-control);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink-2);
  font-size: var(--text-sm);
  font-weight: 500;
  white-space: nowrap;
  cursor: pointer;
  transition:
    background-color var(--t) var(--ease),
    border-color var(--t) var(--ease),
    color var(--t) var(--ease);
}

.chip:hover {
  border-color: var(--border-hover);
  color: var(--ink);
}

.chip:focus-visible { border-radius: var(--radius); }

.chip.is-active,
.chip[aria-pressed="true"] {
  background: var(--ink);
  border-color: var(--ink);
  color: var(--on-ink);
}

.chip-count {
  font-variant-numeric: tabular-nums;
  opacity: 0.65;
}

/* Pill: a count. */
.pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: var(--radius-pill);
  background: var(--accent);
  color: var(--accent-fg);
  font-size: 0.6875rem;
  font-weight: 600;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.pill-muted { background: var(--sunken-strong); color: var(--ink-2); }
.pill-danger { background: var(--danger); color: #FFFFFF; }
.pill-dark { background: var(--ink); color: var(--on-ink); }

/* Status dot. Always pair with a text label (never colour alone). */
.dot {
  display: inline-block;
  flex: none;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--faint);
}

.dot-lg { width: 10px; height: 10px; }
.dot-online, .dot-success { background: var(--success); }
.dot-away, .dot-warning { background: var(--warning); }
.dot-danger { background: var(--danger); }
.dot-info { background: var(--info); }
.dot-accent { background: var(--accent); }
.dot-violet { background: var(--violet); }
.dot-offline, .dot-neutral { background: transparent; box-shadow: inset 0 0 0 2px var(--faint); }

.dot-pulse {
  position: relative;
}

.dot-pulse::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: inherit;
  animation: pulse 2s var(--ease) infinite;
}

/* -- 8. Tabs --------------------------------------------------------------- */

/* Underline tabs: <div class="tabs" role="tablist"><button class="tab" role="tab" aria-selected="true">…
   Link tabs work too: <a class="tab" aria-current="page">. */
.tabs {
  display: flex;
  align-items: stretch;
  gap: var(--s-1);
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
  scrollbar-width: none;
}

.tabs::-webkit-scrollbar { display: none; }

.tab {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex: none;
  min-height: 40px;
  padding: 0 10px;
  margin-bottom: -1px;
  border-bottom: 2px solid transparent;
  color: var(--muted);
  font-size: var(--text-base);
  font-weight: 500;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
  transition: color var(--t) var(--ease), border-color var(--t) var(--ease), background-color var(--t) var(--ease);
}

.tab:hover { color: var(--ink); }
.tab:focus-visible { outline-offset: -2px; }

.tab.is-active,
.tab[aria-selected="true"],
.tab[aria-current="page"] {
  color: var(--ink);
  border-bottom-color: var(--ink);
}

.tab-count {
  font-size: var(--text-xs);
  font-weight: 500;
  padding: 1px 6px;
  border-radius: var(--radius-pill);
  background: var(--sunken);
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

/* Segmented control: .tabs.tabs-pill */
.tabs-pill {
  display: inline-flex;
  gap: 2px;
  padding: 2px;
  border: 0;
  border-radius: var(--radius);
  background: var(--sunken);
  max-width: 100%;
}

.tabs-pill .tab {
  min-height: 28px;
  padding: 0 10px;
  margin: 0;
  border: 0;
  border-radius: var(--radius-sm);
  font-size: var(--text-sm);
}

.tabs-pill .tab:focus-visible { outline-offset: 0; border-radius: var(--radius-sm); }

.tabs-pill .tab.is-active,
.tabs-pill .tab[aria-selected="true"],
.tabs-pill .tab[aria-current="page"] {
  background: var(--tab-on);
  color: var(--ink);
  box-shadow: 0 1px 2px rgba(18, 20, 25, 0.08), 0 0 0 1px rgba(18, 20, 25, 0.04);
}

.tabs-block { display: flex; }
.tabs-block .tab { flex: 1 1 0; justify-content: center; }

/* -- 9. Tables and lists --------------------------------------------------- */

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--card);
  -webkit-overflow-scrolling: touch;
}

.card .table-wrap,
.table-wrap.is-plain {
  border: 0;
  border-radius: 0;
  background: transparent;
}

.table {
  width: 100%;
  font-size: var(--text-base);
}

.table thead th {
  padding: 9px var(--s-4);
  border-bottom: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--muted);
  font-size: var(--text-xs);
  font-weight: 500;
  text-align: left;
  white-space: nowrap;
}

/* A row header (th scope="row", e.g. a contact's name) reads like a cell. */
.table td,
.table tbody th {
  padding: 11px var(--s-4);
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
  text-align: left;
}

.table tbody th { font-weight: 500; color: var(--ink); }

.table tbody tr:last-child > * { border-bottom: 0; }
.table tbody tr { transition: background-color var(--t) var(--ease); }
.table tbody tr:hover { background: var(--surface-2); }
.table tr.is-selected { background: var(--accent-soft); }
.table .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.table-compact th { padding: var(--s-2) var(--s-3); }
.table-compact td { padding: var(--s-2) var(--s-3); }
.table caption { caption-side: bottom; padding: var(--s-3) var(--s-4); text-align: left; color: var(--muted); font-size: var(--text-sm); }

.list {
  display: flex;
  flex-direction: column;
}

.list-item {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  padding: var(--s-3) var(--s-4);
  border-bottom: 1px solid var(--border);
  color: inherit;
  text-decoration: none;
  min-width: 0;
}

.list-item:last-child { border-bottom: 0; }
.list-plain > .list-item { padding-left: 0; padding-right: 0; }

a.list-item,
button.list-item,
.list-item-interactive {
  width: 100%;
  cursor: pointer;
  transition: background-color var(--t) var(--ease);
}

a.list-item:hover,
button.list-item:hover,
.list-item-interactive:hover {
  background: var(--surface-2);
  color: inherit;
}

a.list-item:focus-visible,
button.list-item:focus-visible,
.list-item-interactive:focus-visible {
  outline-offset: -2px;
}

.list-item.is-active {
  background: var(--sunken);
  box-shadow: inset 2px 0 0 var(--accent);
}

.list-item-main {
  flex: 1 1 0;
  min-width: 0;
}

.list-item-title {
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.list-item-sub {
  font-size: var(--text-sm);
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.list-item-meta {
  flex: none;
  font-size: var(--text-xs);
  color: var(--muted);
  white-space: nowrap;
  text-align: right;
}

/* Key / value rows */
.kv {
  display: flex;
  flex-direction: column;
  gap: var(--s-2);
}

.kv-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--s-4);
  font-size: var(--text-sm);
}

.kv-key { color: var(--muted); flex: 1 1 auto; min-width: 0; }
.kv-value { flex: 0 1 auto; font-weight: 500; text-align: right; min-width: 0; overflow-wrap: anywhere; }
.kv-value.tabular, .kv-value.nowrap { flex: none; white-space: nowrap; }

/* -- 10. Avatar ------------------------------------------------------------ */

.avatar {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--avatar-bg, var(--accent));
  color: #FFFFFF;
  font-size: 0.8125rem;
  font-weight: 600;
  letter-spacing: 0;
  line-height: 1;
  user-select: none;
}

.avatar-on-light { color: #121419; } /* fixed: a light avatar colour needs dark initials in either theme */
.avatar-xs { width: 20px; height: 20px; font-size: 0.5625rem; }
.avatar-sm { width: 28px; height: 28px; font-size: 0.6875rem; }
.avatar-lg { width: 48px; height: 48px; font-size: 1rem; }
.avatar-xl { width: 64px; height: 64px; font-size: 1.375rem; }

.avatar-presence {
  position: absolute;
  right: -1px;
  bottom: -1px;
  width: 10px;
  height: 10px;
  border: 2px solid var(--card);
  box-shadow: none;
}

.avatar-presence.dot-offline { background: var(--faint); }

.avatar-group { display: inline-flex; }
.avatar-group > .avatar { box-shadow: 0 0 0 2px var(--card); }
.avatar-group > .avatar + .avatar { margin-left: -8px; }

/* -- 11. Metric ------------------------------------------------------------ */

/* <div class="card metric"><div class="metric-top"><span class="metric-label">…</span><span class="metric-icon">icon</span></div>
     <div class="metric-value">128<span class="metric-unit">open</span></div><div class="metric-meta">…</div></div>
   The number is the content: no decorative icon tile beside the label. */
.metric {
  display: flex;
  flex-direction: column;
  min-height: 116px;
}

.metric-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-2);
}

.metric-label {
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--muted);
}

.metric-icon {
  display: none;
}

.metric-value {
  margin-top: var(--s-2);
  font-size: 1.75rem;
  font-weight: 600;
  line-height: 1.15;
  letter-spacing: -0.025em;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}

.metric-value.is-empty { color: var(--faint); }

.metric-unit {
  margin-left: 4px;
  font-size: var(--text-base);
  font-weight: 500;
  letter-spacing: 0;
  color: var(--muted);
}

.metric-meta {
  margin-top: auto;
  padding-top: var(--s-3);
  font-size: var(--text-sm);
  color: var(--muted);
}

.metric-delta {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  font-weight: 500;
}

.metric-delta.is-up { color: var(--success-ink); }
.metric-delta.is-down { color: var(--danger-ink); }

/* -- 12. Empty and error states --------------------------------------------- */

.empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: var(--s-12) var(--s-6);
}

.empty-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  margin-bottom: var(--s-4);
  border-radius: var(--radius-lg);
  background: var(--sunken);
  color: var(--muted);
}

.empty-title {
  font-size: var(--text-md);
  font-weight: 600;
}

.empty-text {
  margin-top: 4px;
  max-width: 46ch;
  color: var(--muted);
  font-size: var(--text-base);
}

.empty-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: var(--s-2);
  margin-top: var(--s-5);
}

.empty-compact { padding: var(--s-6) var(--s-4); }
.empty-compact .empty-icon { width: 36px; height: 36px; margin-bottom: var(--s-3); }
.empty-compact .empty-title { font-size: var(--text-base); }
.empty-compact .empty-actions { margin-top: var(--s-3); }
.empty-error .empty-icon { background: var(--danger-soft); color: var(--danger-ink); }

/* Full-view state (missing view, 404, crash): a centred card. */
.state-page {
  display: grid;
  place-items: center;
  min-height: min(70vh, 640px);
}

.state-card {
  width: 100%;
  max-width: 560px;
}

.state-card > .empty { padding-bottom: var(--s-6); }
.state-card > .empty-actions { margin-top: 0; padding-bottom: var(--s-6); }

.state-detail {
  padding-top: var(--s-4);
  border-top: 1px solid var(--border);
  max-width: 100%;
  text-align: center;
}

/* -- 13. Skeleton and spinner ----------------------------------------------- */

.skeleton {
  display: block;
  border-radius: var(--radius-sm);
  background: linear-gradient(90deg, var(--sunken) 0%, var(--skeleton-hi) 45%, var(--sunken) 90%);
  background-size: 220% 100%;
  animation: shimmer 1.5s ease-in-out infinite;
}

.skeleton-text { height: 12px; margin: 6px 0; }
.skeleton-title { height: 24px; }
.skeleton-circle { width: 36px; height: 36px; border-radius: 50%; flex: none; }
.skeleton-block { height: 120px; border-radius: var(--radius-lg); }
.skeleton-lines { display: flex; flex-direction: column; }
.skeleton-row { display: flex; align-items: center; gap: var(--s-3); padding: var(--s-3) 0; }
.skeleton-row-lines { flex: 1 1 0; min-width: 0; }

.spinner {
  display: inline-block;
  flex: none;
  width: 18px;
  height: 18px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  vertical-align: -0.2em;
}

/* Content being refreshed in place: hold the previous render, dimmed. */
.is-refreshing {
  opacity: 0.6;
  transition: opacity var(--t) var(--ease);
}

/* -- 14. Toasts ------------------------------------------------------------- */

/* Top right, under the top bar: never over a composer or a Send button. */
.toast-stack {
  position: fixed;
  top: calc(var(--topbar-h) + 12px);
  right: var(--s-4);
  z-index: 1200;
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: min(360px, calc(100vw - 32px));
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 12px 12px 14px;
  border-radius: var(--radius-lg);
  background: var(--dark);
  color: var(--on-dark);
  box-shadow: inset 0 0 0 1px var(--dark-line), var(--shadow-3);
  pointer-events: auto;
  animation: toast-in 200ms var(--ease) both;
}

.toast.is-leaving { animation: toast-out 160ms ease-in both; }
.toast-icon { flex: none; margin-top: 1px; color: var(--on-dark-muted); }
.toast-success .toast-icon { color: #6FD39B; }
.toast-error .toast-icon { color: #F59B90; }
.toast-body { flex: 1 1 0; min-width: 0; padding-top: 1px; }
.toast-title { font-weight: 600; font-size: var(--text-base); }
.toast-message { font-size: var(--text-base); line-height: 1.45; overflow-wrap: anywhere; }
.toast-title + .toast-message { color: var(--on-dark-muted); }

.toast-action {
  flex: none;
  align-self: center;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  color: var(--on-dark);
  font-size: var(--text-sm);
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.toast-action:hover { background: rgba(255, 255, 255, 0.1); }

/* A toast with a title has more to say: its action goes under the words. */
.toast:has(.toast-title) {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  grid-template-areas: "icon body close" ". action .";
  column-gap: 10px;
}

.toast:has(.toast-title) .toast-icon { grid-area: icon; }
.toast:has(.toast-title) .toast-body { grid-area: body; }
.toast:has(.toast-title) .toast-close { grid-area: close; }
.toast:has(.toast-title) .toast-action { grid-area: action; justify-self: start; margin: 6px 0 0 -8px; }

.toast-close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
  width: 26px;
  height: 26px;
  margin: -3px -2px 0 0;
  border-radius: var(--radius-sm);
  color: var(--on-dark-muted);
  transition: background-color var(--t) var(--ease), color var(--t) var(--ease);
}

.toast-close:hover { background: rgba(255, 255, 255, 0.1); color: var(--on-dark); }
.toast :focus-visible { outline-color: var(--accent-on-dark); border-radius: var(--radius-sm); }
.toast .toast-action:focus-visible { border-radius: var(--radius-sm); }

@media (max-width: 639px) {
  .toast-stack {
    top: auto;
    left: var(--s-4);
    right: var(--s-4);
    bottom: var(--s-4);
    width: auto;
  }
}

/* -- 15. Modal and menu ------------------------------------------------------ */

.has-modal { overflow: hidden; }

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: grid;
  place-items: center;
  padding: var(--s-4);
  overflow-y: auto;
  background: var(--scrim);
  animation: fade-in 140ms ease-out both;
}

.modal-backdrop.is-leaving { animation: fade-out 120ms ease-in both; }

.modal {
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 520px;
  max-height: calc(100vh - 32px);
  max-height: calc(100dvh - 32px);
  border-radius: 12px;
  background: var(--surface);
  border: 1px solid var(--float-line);
  box-shadow: var(--shadow-3);
  animation: modal-in 200ms var(--ease) both;
}

.modal:focus-visible { outline: none; }
.modal-sm { max-width: 420px; }
.modal-lg { max-width: 760px; }

.modal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--s-3);
  padding: var(--s-5) var(--s-4) 0 var(--s-6);
}

.modal-title {
  padding-top: 3px;
  font-size: var(--text-lg);
  font-weight: 600;
}

.modal-close { margin: -2px -2px 0 0; }

.modal-body {
  padding: var(--s-3) var(--s-6) var(--s-5);
  overflow-y: auto;
  min-height: 0;
}

.modal-body:empty { padding-bottom: var(--s-2); }
.modal-text { color: var(--ink-2); }

.modal-footer {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: var(--s-2);
  padding: var(--s-3) var(--s-6);
  border-top: 1px solid var(--border);
  background: var(--surface-2);
  border-radius: 0 0 12px 12px;
}

@media (max-width: 479px) {
  .modal-footer { flex-direction: column-reverse; }
  .modal-footer .btn { width: 100%; }
}

.menu {
  position: fixed;
  z-index: 1100;
  min-width: 200px;
  max-width: min(320px, calc(100vw - 16px));
  max-height: calc(100vh - 16px);
  overflow-y: auto;
  padding: 4px;
  border: 1px solid var(--float-line);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow-2);
  animation: menu-in 120ms var(--ease) both;
}

.menu:focus-visible { outline: none; }

.menu-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 32px;
  padding: 0 8px;
  border-radius: var(--radius-sm);
  color: var(--ink);
  font-size: var(--text-base);
  font-weight: 450;
  text-decoration: none;
  text-align: left;
  cursor: pointer;
}

.menu-item .icon { color: var(--muted); }

.menu-item:hover,
.menu-item:focus-visible {
  background: var(--sunken);
  color: var(--ink);
  outline: none;
}

.menu-item.is-danger,
.menu-item.is-danger .icon { color: var(--danger-ink); }
.menu-item.is-danger:hover,
.menu-item.is-danger:focus-visible { background: var(--danger-soft); }
.menu-item:disabled { opacity: 0.5; cursor: not-allowed; }
.menu-item-label { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.menu-item-hint { flex: none; color: var(--muted); font-size: var(--text-xs); }
.menu-separator { height: 1px; margin: 4px; background: var(--border); }
.menu-header { padding: var(--s-2) 8px; }
.menu-label { color: var(--muted); font-size: var(--text-xs); font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase; }

/* -- 16. Banner -------------------------------------------------------------- */

.banner {
  display: flex;
  align-items: flex-start;
  gap: var(--s-3);
  padding: 12px 14px;
  border: 1px solid var(--info-line);
  border-radius: var(--radius-lg);
  background: var(--info-soft);
  color: var(--ink);
}

.banner-icon { flex: none; margin-top: 1px; color: var(--info-ink); }
.banner-body { flex: 1 1 0; min-width: 0; }
.banner-title { font-weight: 600; }
.banner-text { font-size: var(--text-base); color: var(--ink-2); overflow-wrap: anywhere; }
.banner-actions { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-2); flex: none; align-self: center; }
.banner-close { margin: -4px -6px -4px 0; }
.banner-warning { background: var(--warning-soft); border-color: var(--warning-line); }
.banner-warning .banner-icon { color: var(--warning-ink); }
.banner-critical { background: var(--danger-soft); border-color: var(--danger-line); }
.banner-critical .banner-icon { color: var(--danger-ink); }
.banner-success { background: var(--success-soft); border-color: var(--success-line); }
.banner-success .banner-icon { color: var(--success-ink); }

@media (max-width: 639px) {
  .banner { flex-wrap: wrap; }
  .banner-actions { flex-basis: 100%; padding-left: 32px; }
}

/* -- 17. Meter / progress ----------------------------------------------------- */

/* <div class="meter" role="meter" aria-valuenow="42" aria-valuemin="0" aria-valuemax="100" aria-label="…">
     <div class="meter-fill" style="width:42%"></div></div> */
.meter {
  --meter-fill: var(--accent);
  --meter-track: var(--sunken-strong);
  position: relative;
  height: 6px;
  border-radius: var(--radius-pill);
  background: var(--meter-track);
  overflow: hidden;
}

.meter-fill {
  height: 100%;
  min-width: 0;
  max-width: 100%;
  border-radius: inherit;
  background: var(--meter-fill);
  transition: width 400ms var(--ease);
}

.meter-sm { height: 4px; }
.meter-lg { height: 10px; }
.meter-success { --meter-fill: var(--success); --meter-track: color-mix(in srgb, var(--success) 20%, var(--surface)); }
.meter-warning { --meter-fill: var(--warning); --meter-track: color-mix(in srgb, var(--warning) 20%, var(--surface)); }
.meter-danger { --meter-fill: var(--danger); --meter-track: color-mix(in srgb, var(--danger) 20%, var(--surface)); }
.meter-info { --meter-fill: var(--info); --meter-track: color-mix(in srgb, var(--info) 20%, var(--surface)); }
.meter-neutral { --meter-fill: var(--ink-2); --meter-track: var(--sunken-strong); }

.meter-indeterminate .meter-fill {
  width: 40%;
  animation: meter-slide 1.4s ease-in-out infinite;
}

.meter-labels {
  display: flex;
  justify-content: space-between;
  gap: var(--s-3);
  margin-top: 6px;
  font-size: var(--text-sm);
  color: var(--muted);
}

/* -- 18. Code, snippet, kbd ---------------------------------------------------- */

.code {
  padding: 1px 5px;
  border-radius: var(--radius-sm);
  background: var(--sunken);
  color: var(--ink);
  font-family: var(--font-mono);
  font-size: 0.86em;
  overflow-wrap: anywhere;
}

/* <div class="snippet"><pre>…</pre><button class="snippet-copy" aria-label="Copy">icon</button></div> */
.snippet {
  display: flex;
  align-items: flex-start;
  gap: var(--s-2);
  border-radius: var(--radius-lg);
  background: var(--dark);
  color: #E6E8EC;
}

.snippet pre {
  flex: 1 1 0;
  min-width: 0;
  margin: 0;
  padding: 13px var(--s-4);
  overflow-x: auto;
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  line-height: 1.65;
  white-space: pre;
  tab-size: 2;
  scrollbar-width: thin;
  scrollbar-color: #4A4F5C transparent;
}

.snippet pre:focus-visible { outline-color: var(--accent-on-dark); outline-offset: -2px; }

.snippet-wrap pre {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.snippet-light pre { scrollbar-color: var(--border-strong) transparent; }

/* Icon only (with an aria-label), or icon and a short word such as "Copy". */
.snippet-copy {
  flex: none;
  margin: 7px 7px 7px 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-width: 30px;
  height: 30px;
  padding: 0 8px;
  font-size: var(--text-xs);
  font-weight: 500;
  white-space: nowrap;
  border-radius: var(--radius-sm);
  background: var(--dark-raised);
  color: var(--on-dark-muted);
  transition: background-color var(--t) var(--ease), color var(--t) var(--ease);
}

.snippet-copy:hover { background: color-mix(in srgb, var(--on-dark) 7%, var(--dark-raised)); color: var(--on-dark); }
.snippet-copy:focus-visible { outline-color: var(--accent-on-dark); border-radius: var(--radius-sm); }

.snippet-light {
  background: var(--sunken);
  color: var(--ink);
}

.snippet-light .snippet-copy { background: var(--surface); color: var(--ink-2); box-shadow: var(--shadow-1); }
.snippet-light .snippet-copy:hover { background: var(--card); color: var(--ink); }
.snippet-light .snippet-copy:focus-visible { outline-color: var(--focus); }

.kbd {
  display: inline-block;
  min-width: 20px;
  height: 20px;
  padding: 0 5px;
  border: 1px solid var(--border-strong);
  border-radius: 5px;
  background: var(--surface);
  box-shadow: inset 0 -1px 0 var(--border-strong);
  color: var(--muted);
  font-family: var(--font-body);
  font-size: 0.6875rem;
  font-weight: 500;
  line-height: 18px;
  text-align: center;
  vertical-align: middle;
}

/* -- 19. Scroll areas ----------------------------------------------------------- */

.scroll-y,
.scroll-x,
.scroll {
  scrollbar-width: thin;
  scrollbar-color: var(--border-strong) transparent;
  -webkit-overflow-scrolling: touch;
}

.scroll-y { overflow-y: auto; overflow-x: hidden; overscroll-behavior: contain; min-height: 0; }
.scroll-x { overflow-x: auto; overflow-y: hidden; }
.scroll { overflow: auto; overscroll-behavior: contain; min-height: 0; }

.scroll-y::-webkit-scrollbar,
.scroll-x::-webkit-scrollbar,
.scroll::-webkit-scrollbar { width: 10px; height: 10px; }

.scroll-y::-webkit-scrollbar-thumb,
.scroll-x::-webkit-scrollbar-thumb,
.scroll::-webkit-scrollbar-thumb {
  border: 3px solid transparent;
  border-radius: var(--radius-pill);
  background: var(--border-strong);
  background-clip: content-box;
}

/* -- Charts (lib/chart.js) and bar lists ------------------------------------------- */

.chart {
  display: flex;
  flex-direction: column;
  gap: var(--s-3);
  min-width: 0;
}

.chart-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 6px var(--s-5);
  font-size: var(--text-sm);
}

.chart-legend-item {
  display: inline-flex;
  align-items: center;
  gap: var(--s-2);
  color: var(--ink-2);
}

.chart-legend-value {
  color: var(--ink);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

/* Series key: a short stroke of the series colour. Text never wears the colour. */
.chart-key {
  display: inline-block;
  flex: none;
  width: 14px;
  height: 3px;
  border-radius: 2px;
}

.chart-stage {
  position: relative;
  min-width: 0;
}

.chart-plot {
  min-height: 120px;
  border-radius: var(--radius);
  touch-action: pan-y;
  cursor: crosshair;
}

.chart-plot:focus-visible { outline-offset: 4px; border-radius: var(--radius); }
.chart-svg { display: block; overflow: visible; }
.chart-grid line { stroke: var(--chart-grid); stroke-width: 1; shape-rendering: crispEdges; }
.chart-grid .chart-baseline { stroke: var(--chart-axis); }
.chart-tick { fill: var(--muted); font-family: var(--font-body); font-size: 11px; font-variant-numeric: tabular-nums; }
.chart-line { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart-area { opacity: 0.1; stroke: none; }
.chart-marker { stroke: var(--card); stroke-width: 2; }
.chart-cross-line { stroke: var(--border-control); stroke-width: 1; shape-rendering: crispEdges; }

.chart-tooltip {
  position: absolute;
  z-index: 5;
  min-width: 148px;
  padding: 10px var(--s-3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--card);
  box-shadow: var(--shadow-2);
  font-size: var(--text-sm);
  pointer-events: none;
  white-space: nowrap;
}

.chart-tooltip-title {
  margin-bottom: 6px;
  color: var(--muted);
  font-size: var(--text-xs);
  font-weight: 600;
}

.chart-tooltip-row {
  display: flex;
  align-items: center;
  gap: var(--s-2);
  line-height: 1.7;
}

.chart-tooltip-value {
  min-width: 2ch;
  color: var(--ink);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.chart-tooltip-label { color: var(--muted); }

/* Ranked list with magnitude bars (top intents, cost by model...).
   <ul class="barlist"><li class="barlist-row"><span class="barlist-label">…</span><span class="barlist-value">12</span>
     <span class="barlist-bar"><span class="barlist-fill" style="width:60%"></span></span></li></ul> */
.barlist {
  display: flex;
  flex-direction: column;
  gap: var(--s-3);
}

.barlist-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: baseline;
  gap: 6px var(--s-3);
  font-size: 0.875rem;
}

.barlist-label {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 500;
}

.barlist-value {
  color: var(--ink);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.barlist-sub {
  color: var(--muted);
  font-weight: 400;
}

.barlist-bar {
  grid-column: 1 / -1;
  display: block;
  height: 6px;
  border-radius: var(--radius-pill);
  background: var(--sunken);
  overflow: hidden;
}

.barlist-fill {
  display: block;
  height: 100%;
  min-width: 2px;
  border-radius: inherit;
  background: var(--chart-1);
  transition: width 400ms var(--ease);
}

/* -- 20. App shell ---------------------------------------------------------------- */

#app {
  min-height: 100vh;
  min-height: 100dvh;
}

.boot {
  display: grid;
  place-items: center;
  min-height: 100vh;
  min-height: 100dvh;
  padding: var(--s-6);
}

.boot-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--s-4);
  color: var(--muted);
  font-size: 0.875rem;
}

.boot-mark { animation: breathe 1.8s ease-in-out infinite; }

.shell {
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
}

/* Sidebar */
.sidebar {
  display: flex;
  flex-direction: column;
  gap: var(--s-2);
  min-height: 0;
  padding: var(--s-4) var(--s-3) var(--s-3);
  background: var(--surface);
  border-right: 1px solid var(--border);
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--border-strong) transparent;
}

.sidebar-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-2);
  padding: 2px 6px var(--s-4);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--ink);
  text-decoration: none;
  border-radius: var(--radius);
}

.brand:hover { color: var(--ink); }

.brand-name {
  font-family: var(--font-display);
  font-size: 1.25rem;
  font-weight: 600;
  letter-spacing: -0.015em;
  line-height: 1;
}

.sidebar-close { display: none; }

/* -- Workspace switcher (top of the sidebar) ------------------------------------
   One account, any number of workspaces. The mark is a flat tile in the
   workspace's colour (or a hue from its id), so each window is recognisable. */
.ws-switch {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1 1 auto;
  min-width: 0;
  padding: 6px 8px 6px 6px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  background: transparent;
  color: var(--ink);
  text-align: left;
  cursor: pointer;
  transition: background-color var(--t) var(--ease);
}
.ws-switch:hover { background: var(--sunken); }
.ws-switch[aria-expanded="true"] { background: var(--sunken); }
.ws-switch > .icon { flex: none; color: var(--muted); transition: transform var(--t) var(--ease); }
.ws-switch[aria-expanded="true"] > .icon { transform: rotate(180deg); }

.ws-mark {
  --ws-hue: 248;
  display: inline-grid;
  place-items: center;
  flex: none;
  width: 28px;
  height: 28px;
  border-radius: 7px;
  background: var(--ws-bg, hsl(var(--ws-hue) 48% 50%));
  color: var(--ws-fg, #fff);
  font-family: var(--font-body);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0;
  line-height: 1;
  overflow: hidden;
}
/* A logo sits on white in both themes: most are drawn for a light page, and a
   dark one with a transparent background would vanish on a dark surface. */
.ws-mark.has-logo {
  background: #FFFFFF;
  box-shadow: inset 0 0 0 1px var(--border);
}
.ws-mark-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* All workspaces: a dot in each one's colour - two to a row, so three make a
   triangle - bare in the switcher's menu, on a plain tile in the switcher. */
.ws-all-mark {
  display: inline-flex;
  flex-wrap: wrap;
  align-content: center;
  justify-content: center;
  gap: 2px;
  flex: none;
  width: 16px;
  height: 16px;
  padding: 1px;
}
.ws-all-dot {
  flex: none;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--ws-color, var(--muted));
}
.ws-mark.ws-all-mark {
  display: inline-flex;
  width: 28px;
  height: 28px;
  padding: 5px;
  gap: 4px;
  background: var(--sunken);
  box-shadow: inset 0 0 0 1px var(--border);
}
.ws-mark.ws-all-mark .ws-all-dot { width: 7px; height: 7px; }

.ws-switch-text { display: flex; flex-direction: column; gap: 2px; flex: 1 1 auto; min-width: 0; }
.ws-switch-name {
  overflow: hidden;
  font-family: var(--font-display);
  font-size: var(--text-base);
  font-weight: 600;
  letter-spacing: -0.01em;
  line-height: 1.15;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.ws-switch-sub {
  overflow: hidden;
  color: var(--muted);
  font-size: var(--text-xs);
  line-height: 1.2;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.ws-switch-dot {
  flex: none;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: 999px;
  background: var(--accent);
  color: var(--accent-fg);
  font-size: 0.6875rem;
  font-weight: 700;
  line-height: 20px;
  text-align: center;
}
@keyframes ws-pulse {
  0%, 100% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--accent) 35%, transparent); }
  50% { box-shadow: 0 0 0 5px color-mix(in srgb, var(--accent) 0%, transparent); }
}
@media (prefers-reduced-motion: reduce) { .ws-switch-dot { animation: none; } }

.ws-menu-head {
  padding: 4px 10px 2px;
  color: var(--muted);
  font-size: var(--text-xs);
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

/* A workspace in the switcher: its colour (the one its conversations carry in
   All workspaces), its name over its website, what is unread, its key. */
.menu-item .ws-menu-dot {
  flex: none;
  width: 10px;
  height: 10px;
  margin: 0 3px;
  border-radius: 50%;
  background: var(--ws-color, var(--muted));
}
.menu-item:has(.ws-menu-site) { min-height: 44px; padding-block: 4px; }
.menu-item .ws-menu-name,
.menu-item .ws-menu-site { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.menu-item .ws-menu-name { font-weight: 550; }
.menu-item .ws-menu-site { color: var(--muted); font-size: var(--text-xs); }
.menu-item .menu-item-hint:has(.ws-menu-unread, .kbd, .icon) { display: inline-flex; align-items: center; gap: 6px; }
.menu-item .ws-menu-unread {
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 9px;
  background: var(--accent);
  color: var(--accent-fg);
  font-size: 0.6875rem;
  font-weight: 600;
  line-height: 18px;
  text-align: center;
}

.sidebar-brand {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin: 0 6px var(--s-2);
  color: var(--muted);
  font-size: var(--text-xs);
  font-weight: 600;
  text-decoration: none;
}
.sidebar-brand:hover { color: var(--ink); }

/* "Install the desktop app": offered only when the browser can install. */
.sidebar-install {
  display: flex;
  align-items: center;
  gap: var(--s-2);
  width: 100%;
  min-height: 32px;
  padding: 0 6px;
  border-radius: var(--radius);
  color: var(--muted);
  font-size: var(--text-xs);
  text-align: left;
  cursor: pointer;
  transition: background-color var(--t) var(--ease), color var(--t) var(--ease);
}
.sidebar-install[hidden] { display: none; }
.sidebar-install:hover { background: var(--sunken); color: var(--ink); }
.sidebar-install-icon { display: inline-flex; flex: none; }
.sidebar-install-text { display: flex; min-width: 0; }
.sidebar-install-text strong { font-size: var(--text-xs); font-weight: 500; }
.sidebar-install-text span { display: none; }

.install-steps { display: grid; gap: 8px; margin: 0; padding-left: 1.3em; color: var(--ink-2); }
.install-steps li::marker { color: var(--accent); font-weight: 700; }

.device-heading { margin: var(--s-2) 0 0; font-size: var(--text-sm, 0.875rem); font-weight: 700; }
.device-list { display: grid; gap: 6px; margin: 0; padding: 0; list-style: none; }
.device-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.device-row > .icon { flex: none; color: var(--muted); }
.device-main { display: flex; flex: 1 1 auto; flex-direction: column; min-width: 0; }
.device-main strong { overflow: hidden; font-size: var(--text-sm, 0.875rem); text-overflow: ellipsis; white-space: nowrap; }
.device-main span { color: var(--muted); font-size: var(--text-xs); }
.device-empty { color: var(--muted); font-size: var(--text-sm, 0.875rem); }

/* -- Join-link page (/join/<token>) ---------------------------------------------- */
.join-mark {
  --ws-hue: 248;
  display: grid;
  place-items: center;
  width: 56px;
  height: 56px;
  margin-bottom: var(--s-4);
  border-radius: 12px;
  background: hsl(var(--ws-hue) 48% 50%);
  color: #fff;
  font-family: var(--font-display);
  font-size: 1.375rem;
  font-weight: 600;
  overflow: hidden;
  animation: join-pop 420ms var(--ease) both;
}
.join-mark.has-logo {
  background: var(--surface);
  box-shadow: inset 0 0 0 1px var(--border);
}
@keyframes join-pop { from { opacity: 0; transform: scale(0.85) translateY(6px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .join-mark { animation: none; } }

.join-icon {
  display: grid;
  place-items: center;
  width: 52px;
  height: 52px;
  margin-bottom: var(--s-4);
  border-radius: 14px;
  background: var(--accent-soft, color-mix(in srgb, var(--accent) 10%, transparent));
  color: var(--accent-ink, var(--accent));
}
.join-icon.is-ended { background: var(--wash-2); color: var(--muted); }

.join-facts {
  display: grid;
  gap: 8px;
  margin: var(--s-4) 0 var(--s-5, 20px);
  padding: var(--s-3) var(--s-4);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg, 12px);
  background: var(--surface-2, rgba(18, 20, 25, 0.025));
  list-style: none;
}
.join-facts li { display: flex; align-items: center; gap: 10px; color: var(--ink-2); font-size: var(--text-sm, 0.875rem); }
.join-facts .icon { flex: none; color: var(--accent-ink, var(--accent)); }

.join-who {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg, 12px);
  background: var(--card);
}
.join-who > div { display: flex; flex-direction: column; min-width: 0; }
.join-who strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.join-who span { overflow: hidden; color: var(--muted); font-size: var(--text-xs); text-overflow: ellipsis; white-space: nowrap; }
.join-note { margin-top: var(--s-3); text-align: center; }

.nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.nav-item {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 34px;
  padding: 0 10px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  color: var(--ink-2);
  font-size: var(--text-base);
  font-weight: 500;
  text-decoration: none;
  transition:
    background-color var(--t) var(--ease),
    color var(--t) var(--ease),
    border-color var(--t) var(--ease),
    box-shadow var(--t) var(--ease);
}

.nav-item .icon {
  color: var(--muted);
  transition: color var(--t) var(--ease);
}

.nav-item:hover {
  background: var(--sunken);
  color: var(--ink);
}

.nav-item:hover .icon { color: var(--ink-2); }
.nav-item:focus-visible { border-radius: var(--radius); outline-offset: 1px; }

.nav-item[aria-current="page"] {
  background: var(--sunken);
  color: var(--ink);
  font-weight: 600;
}

.nav-item[aria-current="page"] .icon { color: var(--accent); }

.nav-label { flex: 1 1 auto; min-width: 0; }
.nav-badge { flex: none; }

/* The workspaces' own inboxes, under Inbox (dashboard.js renderInboxNav): each
   in its colour, lined up with the word Inbox, with how many of its
   conversations are open - in bold while one of them is unread. */
.nav-sub {
  display: flex;
  flex-direction: column;
  gap: 1px;
  margin: 2px 0 6px;
}

.nav-sub[hidden] { display: none; }

.nav-sub-heading {
  overflow: hidden;
  padding: 8px 10px 2px 39px;
  color: var(--faint);
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-overflow: ellipsis;
  text-transform: uppercase;
  white-space: nowrap;
}

.nav-sub-item {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  min-height: 30px;
  padding: 0 10px 0 39px;
  border-radius: var(--radius);
  color: var(--ink-2);
  font-size: var(--text-sm);
  font-weight: 500;
  text-align: left;
  text-decoration: none;
  transition: background-color var(--t) var(--ease), color var(--t) var(--ease);
}

.nav-sub-item:hover { background: var(--sunken); color: var(--ink); }
.nav-sub-item:focus-visible { border-radius: var(--radius); outline-offset: 1px; }

.nav-sub-item[aria-current="page"] {
  background: var(--sunken);
  color: var(--ink);
  font-weight: 600;
}

.nav-sub-dot {
  flex: none;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--box-color, var(--muted));
}

.nav-sub-label {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.nav-sub-count {
  flex: none;
  color: var(--muted);
  font-size: var(--text-xs);
  font-variant-numeric: tabular-nums;
}

.nav-sub-item.is-unread { color: var(--ink); font-weight: 600; }
.nav-sub-item.is-unread .nav-sub-count { color: var(--ink-2); font-weight: 600; }

/* "New inbox": its plus centred where the dots are, its words where the names are. */
.nav-sub-add { gap: 5px; color: var(--muted); font-weight: 500; }
.nav-sub-add .icon { flex: none; margin-left: -3px; }
.nav-sub-add:hover { color: var(--ink); }

@media (pointer: coarse) {
  .nav-sub-item { min-height: 40px; }
}

/* A second group of links under its own heading (Platform, for the people who run the server). */
.nav-group {
  margin-top: var(--s-3);
  padding-top: var(--s-3);
  border-top: 1px solid var(--border);
}

.nav-heading {
  margin: 0 0 var(--s-1);
  padding: 0 10px;
  color: var(--faint);
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

/* Said above every page while it holds, such as a suspended workspace. */
.shell-notice { flex: none; }
.shell-notice[hidden] { display: none; }

.shell-notice-inner {
  max-width: var(--content-max);
  margin: 0 auto;
  padding: var(--s-3) var(--page-pad) 0;
}

.shell-body.is-fill .shell-notice-inner { max-width: none; padding-bottom: var(--s-3); }

.sidebar-foot {
  margin-top: auto;
  padding: var(--s-3) var(--s-2) var(--s-1);
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: var(--text-xs);
}

.sidebar-foot-button {
  display: flex;
  align-items: center;
  gap: var(--s-2);
  width: 100%;
  min-height: 32px;
  padding: 0 6px;
  border-radius: var(--radius);
  color: var(--muted);
  font-size: var(--text-xs);
  font-weight: 500;
  transition: background-color var(--t) var(--ease), color var(--t) var(--ease);
}

.sidebar-foot-button:hover { background: var(--sunken); color: var(--ink); }
.sidebar-foot-button .kbd { margin-left: auto; }

/* Right-hand column: sticky top bar over a scrolling main. */
.shell-body {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-gutter: stable;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  flex: none;
  height: var(--topbar-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.topbar-inner {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  height: 100%;
  max-width: var(--content-max);
  margin: 0 auto;
  padding: 0 var(--page-pad);
}

.topbar-menu { display: none; margin-left: -8px; }

.topbar-title {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: var(--text-md);
  font-weight: 600;
  letter-spacing: -0.012em;
}

/* A view that shows its own heading takes the title from the bar: one title
   per page. It stays for screen readers. */
.shell-body:has(.view .page-heading) .topbar-title {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
}

.shell-body:has(.view .page-heading) .topbar-inner > .topbar-search-btn { margin-right: auto; }

.topbar-actions {
  display: flex;
  align-items: center;
  gap: var(--s-2);
  flex: none;
}

/* Realtime indicator: a dot while all is well, words only when it is not. */
.rt-status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 26px;
  padding: 0 9px;
  border-radius: var(--radius-pill);
  background: var(--success-soft);
  color: var(--success-ink);
  font-size: var(--text-xs);
  font-weight: 500;
  white-space: nowrap;
  transition: background-color var(--t) var(--ease), color var(--t) var(--ease);
}

.rt-status[data-status="online"] {
  width: 26px;
  padding: 0;
  justify-content: center;
  background: transparent;
}

.rt-status[data-status="online"] .rt-label {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.rt-status[data-status="connecting"] { background: var(--warning-soft); color: var(--warning-ink); }
.rt-status[data-status="offline"] { background: var(--danger-soft); color: var(--danger-ink); }

/* The workspace is named in the sidebar switcher - except while it says All
   workspaces and the page is one workspace's own (its contacts, reports,
   settings): then this says whose (dashboard.js renderWorkspaceChip). */
.workspace-chip {
  display: none;
  align-items: center;
  gap: 6px;
  min-width: 0;
  height: 28px;
  padding: 0 10px 0 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  color: var(--ink-2);
}

.workspace-chip.is-shown { display: inline-flex; }
.workspace-chip .badge { display: none; }

.workspace-chip-dot {
  flex: none;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--ws-color, var(--muted));
}

.workspace-name {
  max-width: 180px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: var(--text-sm);
  font-weight: 500;
}

.presence-toggle .dot { width: 9px; height: 9px; }

/* Alerts: the bell in the top bar, and its settings dialog (lib/alerts.js). */
.topbar-alerts { position: relative; }

.topbar-alerts-dot {
  position: absolute;
  top: 5px;
  right: 5px;
  width: 8px;
  height: 8px;
  border: 2px solid var(--surface);
  border-radius: 50%;
  background: var(--accent);
}

.alerts-settings { display: grid; gap: var(--s-4); }
.alerts-intro { margin: 0; color: var(--muted); font-size: var(--text-sm); }

.alerts-group {
  display: grid;
  gap: var(--s-3);
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

.alerts-group > legend {
  margin-bottom: var(--s-2);
  padding: 0;
  color: var(--muted);
  font-size: var(--text-xs);
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.alerts-toggle { align-items: flex-start; }
.alerts-toggle .toggle-track { flex: none; margin-top: 2px; }
.alerts-toggle .toggle-label { display: grid; gap: 2px; }
.alerts-toggle-hint { color: var(--muted); font-size: var(--text-sm); font-weight: 400; }

.alerts-status,
.alerts-foot,
.alerts-tried {
  margin: 0;
  color: var(--muted);
  font-size: var(--text-sm);
}

.alerts-try { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-2) var(--s-3); }

.user-button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 8px 3px 3px;
  border-radius: var(--radius-pill);
  color: var(--ink-2);
  transition: background-color var(--t) var(--ease);
}

.user-button:hover,
.user-button[aria-expanded="true"] { background: var(--sunken); }
.user-button:focus-visible { border-radius: var(--radius-pill); }

/* The avatar's presence dot stands in for the presence toggle on phones. */
.user-button .avatar-presence { display: none; border-color: var(--bg); }

.user-card {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  min-width: 0;
}

.user-card-name { font-weight: 600; font-size: 0.875rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-card-email { color: var(--muted); font-size: var(--text-xs); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.main {
  flex: 1 0 auto;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.main:focus-visible { outline: none; }

.view {
  flex: 1 0 auto;
  min-width: 0;
  animation: view-in 160ms var(--ease) both;
}

/* layout: 'fill' views own the whole area under the top bar and scroll
   internally (the inbox). The page itself does not scroll. */
.shell-body.is-fill { overflow: hidden; scrollbar-gutter: auto; }
.shell-body.is-fill .topbar-inner { max-width: none; }
.shell-body.is-fill .main { flex: 1 1 0; min-height: 0; }

.view-fill {
  flex: 1 1 0;
  display: flex;
  flex-direction: column;
  min-height: 0;
  height: 100%;
  overflow: hidden;
}

/* A fill view must not grow its container while it animates in: fade only. */
.view-fill { animation-name: fade-in; }

.drawer-scrim { display: none; }

/* Below 1024: the sidebar becomes a drawer behind a hamburger. */
@media (max-width: 1023px) {
  .shell { grid-template-columns: minmax(0, 1fr); }

  .sidebar {
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    z-index: 60;
    width: min(288px, 86vw);
    padding-top: var(--s-3);
    box-shadow: var(--shadow-3);
    transform: translateX(-104%);
    visibility: hidden;
    transition: transform 260ms var(--ease), visibility 0s linear 260ms;
  }

  .shell.is-drawer-open .sidebar {
    transform: none;
    visibility: visible;
    transition: transform 260ms var(--ease), visibility 0s linear 0s;
  }

  .drawer-scrim {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 50;
    background: var(--scrim);
    opacity: 0;
    visibility: hidden;
    transition: opacity 260ms var(--ease), visibility 0s linear 260ms;
  }

  .shell.is-drawer-open .drawer-scrim {
    opacity: 1;
    visibility: visible;
    transition: opacity 260ms var(--ease), visibility 0s linear 0s;
  }

  .sidebar-close { display: inline-flex; }
  .topbar-menu { display: inline-flex; }
  .nav-item { min-height: 44px; }
  .sidebar-foot-button .kbd { display: none; }
}

@media (max-width: 767px) {
  :root { --topbar-h: 56px; }
  .topbar-title { font-size: var(--text-md); }
  .workspace-chip,
  .workspace-chip.is-shown { display: none; }
  .topbar-actions { gap: var(--s-1); }
}

@media (max-width: 639px) {
  .rt-status { width: 28px; padding: 0; justify-content: center; }
  .rt-status .rt-label {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
  }
  /* Presence moves into the account menu; the avatar shows the state. */
  .presence-toggle { display: none; }
  .user-button .avatar-presence { display: block; }
  .user-button .icon { display: none; }
  .user-button { padding: 6px; }
  .metric { min-height: 0; }
  .metric-value { margin-top: var(--s-2); font-size: 1.75rem; }
  .metric-meta { padding-top: var(--s-2); }
}

/* Touch: every control reaches 44px. */
@media (pointer: coarse), (max-width: 767px) {
  .btn { min-height: 44px; }
  .btn-icon, .btn-icon.btn-sm { width: 44px; min-width: 44px; }
  .input, .select { min-height: 44px; font-size: 1rem; }
  .textarea { font-size: 1rem; }
  .chip { min-height: 44px; padding: 0 var(--s-4); }
  .tab { min-height: 44px; }
  .tabs-pill .tab { min-height: 44px; }
  .menu-item { min-height: 44px; }
  .toggle { min-height: 44px; }
  .checkbox, .radio { min-height: 44px; }
  .snippet-copy { min-width: 44px; height: 44px; }
  .toast-close { width: 36px; height: 36px; }
  .sidebar-foot-button { min-height: 44px; }
  .user-button { min-width: 44px; min-height: 44px; justify-content: center; }
  .rt-status { min-height: 28px; }
}

/* -- 21. Auth screen ---------------------------------------------------------------- */

.auth {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: auto 1fr;
  min-height: 100vh;
  min-height: 100dvh;
}

.auth-brand {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: var(--s-6);
  padding: var(--s-6) var(--s-5) var(--s-8);
  background: var(--dark);
  color: var(--on-dark);
  overflow: hidden;
  isolation: isolate;
}

/* No glow: the panel is a calm, flat dark surface. */
.auth-brand::before { content: none; }

.auth-brand .brand { color: var(--on-dark); }
.auth-brand .brand:hover { color: var(--on-dark); }
.auth-brand :focus-visible { outline-color: var(--accent-on-dark); }

.auth-headline {
  font-size: clamp(1.75rem, 3.6vw, 2.75rem);
  font-weight: 600;
  line-height: 1.1;
  letter-spacing: -0.03em;
  max-width: 14ch;
}

.auth-headline em {
  font-style: normal;
  color: var(--on-dark-muted);
}

.auth-lede {
  margin-top: var(--s-4);
  max-width: 46ch;
  color: var(--on-dark-muted);
  font-size: var(--text-md);
  line-height: 1.55;
}

.auth-points {
  display: none;
  flex-direction: column;
  gap: var(--s-4);
  max-width: 48ch;
}

.auth-point {
  display: flex;
  align-items: flex-start;
  gap: var(--s-3);
  font-size: var(--text-base);
  line-height: 1.5;
  color: var(--on-dark-muted);
}

.auth-point-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
  width: 32px;
  height: 32px;
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.07);
  color: var(--on-dark);
}

.auth-point strong { display: block; color: var(--on-dark); font-weight: 600; }

/* Faux conversation: shows the product's idea without a screenshot. */
.auth-demo {
  display: none;
  flex-direction: column;
  gap: 10px;
  max-width: 420px;
  padding: var(--s-4);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.04);
}

.auth-bubble {
  max-width: 86%;
  padding: 10px 14px;
  border-radius: 14px;
  font-size: 0.875rem;
  line-height: 1.45;
}

.auth-bubble-visitor {
  align-self: flex-start;
  border-bottom-left-radius: 4px;
  background: rgba(255, 255, 255, 0.1);
  color: var(--on-dark);
}

.auth-bubble-reply {
  align-self: flex-end;
  border-bottom-right-radius: 4px;
  background: var(--accent);
  color: var(--accent-fg);
}

.auth-demo-meta {
  align-self: flex-end;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--on-dark-muted);
  font-size: var(--text-xs);
}

.auth-demo-meta .icon { color: var(--on-dark-muted); }

.auth-fineprint {
  margin-top: auto;
  color: var(--on-dark-muted);
  font-size: var(--text-xs);
  display: none;
}

.auth-panel {
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: var(--s-8) var(--s-5) var(--s-12);
}

.auth-card {
  width: 100%;
  max-width: 420px;
}

.auth-title {
  font-size: var(--text-2xl);
}

.auth-sub {
  margin-top: 6px;
  color: var(--muted);
}

.auth-tabs { margin: var(--s-6) 0 var(--s-5); }

.auth-form {
  display: flex;
  flex-direction: column;
  gap: var(--s-4);
}

.auth-submit { margin-top: var(--s-2); }

.auth-invite-email { margin: 0; font-weight: 600; }
.auth-invite-email[readonly] { background-color: var(--sunken); }

.auth-switch {
  margin-top: var(--s-5);
  color: var(--muted);
  font-size: 0.875rem;
  text-align: center;
}

.auth-switch button {
  color: var(--accent-ink);
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 3px;
  text-decoration-thickness: 1px;
}

.auth-switch button:hover { color: var(--ink); }

/* Live password rules */
.pw-rules {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 4px var(--s-3);
  margin-top: 2px;
}

.pw-rule {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: var(--text-xs);
  transition: color var(--t) var(--ease);
}

.pw-rule .icon { color: var(--faint); transition: color var(--t) var(--ease); }
.pw-rule.is-met { color: var(--success-ink); }
.pw-rule.is-met .icon { color: var(--success); }

@media (min-width: 640px) {
  .auth-brand { padding: var(--s-8) var(--s-10) var(--s-10); }
  .auth-panel { padding: var(--s-12) var(--s-8); }
}

@media (min-width: 1024px) {
  .auth { grid-template-columns: minmax(0, 1.08fr) minmax(0, 1fr); grid-template-rows: minmax(0, 1fr); }
  .auth-brand { padding: var(--s-10) clamp(40px, 5vw, 72px) var(--s-10); gap: var(--s-8); }
  .auth-brand-main { margin-top: auto; }
  .auth-points, .auth-demo { display: flex; }
  .auth-fineprint { display: block; }
  .auth-panel { align-items: center; padding: var(--s-10) var(--s-8); }
}

@media (min-width: 1024px) and (max-height: 760px) {
  .auth-demo { display: none; }
}

/* Keyboard shortcut sheet */
.shortcut-list {
  display: grid;
  gap: var(--s-2);
}

.shortcut-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-4);
  padding: 6px 0;
  font-size: 0.875rem;
}

.shortcut-keys {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: var(--text-xs);
}

/* -- 22. Motion, print, forced colours ----------------------------------------------- */

@keyframes spin {
  to { transform: rotate(360deg); }
}

@keyframes shimmer {
  0% { background-position: 100% 0; }
  100% { background-position: -100% 0; }
}

@keyframes pulse {
  0% { transform: scale(1); opacity: 0.55; }
  70%, 100% { transform: scale(2.6); opacity: 0; }
}

@keyframes breathe {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(0.94); opacity: 0.75; }
}

@keyframes fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes fade-out {
  from { opacity: 1; }
  to { opacity: 0; }
}

@keyframes modal-in {
  from { opacity: 0; transform: translateY(10px) scale(0.985); }
  to { opacity: 1; transform: none; }
}

@keyframes menu-in {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: none; }
}

@keyframes toast-in {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: none; }
}

@keyframes toast-out {
  from { opacity: 1; transform: none; }
  to { opacity: 0; transform: translateY(-6px); }
}

@keyframes view-in {
  from { opacity: 0; transform: translateY(3px); }
  to { opacity: 1; transform: none; }
}

@keyframes meter-slide {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(250%); }
}

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

  .skeleton { animation: none; background: var(--sunken); }
  .spinner, .btn.is-loading::after { animation-duration: 1.2s !important; animation-iteration-count: infinite !important; }
  .btn:hover, .card-hover:hover, a.card:hover, button.card:hover { transform: none; }
}

@media (forced-colors: active) {
  .btn, .input, .select, .textarea, .card, .badge, .chip { border: 1px solid CanvasText; }
  .toggle-track { border: 1px solid CanvasText; }
  .meter { border: 1px solid CanvasText; }
  .meter-fill { background: Highlight; }
  .nav-item[aria-current="page"],
  .nav-sub-item[aria-current="page"] { outline: 2px solid Highlight; }
  .nav-sub-dot { forced-color-adjust: none; }
}

@media print {
  .sidebar, .topbar, .toast-stack, .drawer-scrim, .skip-link { display: none !important; }
  .shell { display: block; height: auto; overflow: visible; }
  .shell-body { overflow: visible; }
  body { background: #FFFFFF; }
  .card { box-shadow: none; break-inside: avoid; }
}

/* -- 23. Dialogs opened from views (mounted outside .view-*, so unscoped) ---- */

/* Share a conversation: teammate link + read-only transcript links */
.ib-share { display: flex; flex-direction: column; gap: 18px; }
.ib-share-section {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
}
.ib-share-head { display: flex; align-items: flex-start; gap: 12px; }
.ib-share-head .hint { margin: 2px 0 0; }
.ib-share-title { margin: 0; font-family: var(--font-display); font-size: var(--text-md); font-weight: 600; }
.ib-share-icon {
  display: grid;
  flex: none;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: var(--radius);
  background: var(--sunken);
  color: var(--ink-2);
}
.ib-share-copy { display: flex; gap: 8px; }
.ib-share-url { flex: 1 1 auto; min-width: 0; font-family: var(--font-mono); font-size: var(--text-xs); }
.ib-share-create { display: flex; flex-wrap: wrap; gap: 8px; }
.ib-share-create .select { flex: 1 1 180px; }
.ib-share-list { display: flex; flex-direction: column; gap: 8px; margin: 0; padding: 0; list-style: none; }
.ib-share-link {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  animation: ib-share-in 200ms var(--ease) both;
}
.ib-share-link.is-off { opacity: 0.6; background: var(--bg); }
.ib-share-link-top { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.ib-share-link-meta { color: var(--muted); font-size: var(--text-xs); }
.ib-share-link-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.ib-share-link-actions .ib-share-copy { flex: 1 1 260px; }
.ib-share-off { color: var(--danger-ink); }
.ib-share-locked {
  display: flex;
  gap: 10px;
  padding: 12px 14px;
  border-radius: var(--radius-lg);
  background: var(--sunken);
  color: var(--ink-2);
  font-size: var(--text-sm);
}
.ib-share-locked p { margin: 4px 0 0; color: var(--ink-2); }
.ib-share-locked a { color: var(--accent); font-weight: 600; }

/* Edit a contact */
.ib-contact-form { display: flex; flex-direction: column; gap: 14px; }
.ib-contact-form .hint { margin: 0; }

/* Contact profile pieces shared by the inbox and Contacts (views/inbox/profile.js) */
.ib-blocked-note {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 12px;
  padding: 8px 10px;
  border-radius: 10px;
  background: var(--danger-soft);
  color: var(--danger-ink);
  font-size: var(--text-sm);
  font-weight: 500;
}

.ib-tag {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  max-width: 100%;
  padding: 1px 3px 1px 8px;
  border-radius: var(--radius-sm);
  background: var(--sunken);
  box-shadow: inset 0 0 0 1px var(--border);
  color: var(--ink-2);
  font-size: var(--text-xs);
  font-weight: 500;
  line-height: 1.6;
  white-space: nowrap;
  animation: ib-tag-in 180ms var(--ease) both;
}
.ib-tag > span { overflow: hidden; text-overflow: ellipsis; }
.ib-tag-sm { padding: 0 6px; font-size: 0.6875rem; line-height: 1.6; animation: none; }
.ib-tag-more { color: var(--muted); font-size: 0.6875rem; font-weight: 600; }
.ib-tag-x {
  display: inline-grid;
  place-items: center;
  width: 18px;
  height: 18px;
  border-radius: 4px;
  color: var(--muted);
  opacity: 0.7;
  transition: opacity var(--t) var(--ease), background-color var(--t) var(--ease);
}
.ib-tag-x:hover { opacity: 1; background: var(--sunken-strong); color: var(--ink); }
.ib-tag-editor { display: flex; flex-direction: column; gap: 8px; }
.ib-tag-editor.is-busy { opacity: 0.75; }
.ib-tags { display: flex; flex-wrap: wrap; gap: 6px; margin: 0; padding: 0; list-style: none; }
.ib-tags:empty { display: none; }
.ib-tag-add {
  display: flex;
  align-items: center;
  gap: 6px;
  min-height: 34px;
  padding: 0 10px;
  border: 1px dashed var(--border-strong);
  border-radius: 10px;
  color: var(--muted);
  transition: border-color var(--t) var(--ease), background-color var(--t) var(--ease), box-shadow var(--t) var(--ease);
}
.ib-tag-add:focus-within { border-style: solid; border-color: var(--accent); background: var(--surface); box-shadow: var(--ring); }
.ib-tag-input { flex: 1 1 auto; min-width: 0; border: 0; outline: 0; background: transparent; color: var(--ink); font: inherit; font-size: var(--text-sm); }

.ib-kvedit-wrap { display: flex; flex-direction: column; gap: 10px; }
.ib-kvedit-wrap .ib-none { margin: 0; color: var(--muted); font-size: var(--text-sm); }
.ib-kvedit { display: flex; flex-direction: column; gap: 2px; margin: 0; }
.ib-kvedit-row {
  display: grid;
  grid-template-columns: minmax(70px, 38%) 1fr auto;
  align-items: center;
  gap: 8px;
  min-height: 32px;
  padding: 4px 4px 4px 10px;
  border-radius: 8px;
  font-size: var(--text-sm);
  transition: background-color var(--t) var(--ease);
}
.ib-kvedit-row:nth-child(odd) { background: var(--bg); }
.ib-kvedit.is-readonly .ib-kvedit-row { grid-template-columns: minmax(70px, 38%) 1fr; }
.ib-kvedit-key { overflow: hidden; color: var(--muted); font-family: var(--font-mono); font-size: var(--text-xs); text-overflow: ellipsis; white-space: nowrap; }
.ib-kvedit-value { margin: 0; color: var(--ink); font-weight: 500; }
.ib-kvedit-x {
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border-radius: 6px;
  color: var(--faint);
  opacity: 0;
  transition: opacity var(--t) var(--ease), color var(--t) var(--ease), background-color var(--t) var(--ease);
}
.ib-kvedit-row:hover .ib-kvedit-x,
.ib-kvedit-x:focus-visible { opacity: 1; }
.ib-kvedit-x:hover { color: var(--danger); background: var(--danger-soft); }
.ib-kvedit-add { display: grid; grid-template-columns: 1fr 1.3fr auto; gap: 6px; }
.ib-kvedit-add .input { min-width: 0; }
.ib-subtitle {
  display: flex;
  align-items: center;
  gap: 5px;
  margin: 0 0 6px;
  color: var(--muted);
  font-size: var(--text-xs);
  font-weight: 600;
  letter-spacing: 0.02em;
}

@keyframes ib-tag-in {
  from { opacity: 0; transform: scale(0.85); }
  to { opacity: 1; transform: none; }
}

@media (hover: none), (pointer: coarse) {
  .ib-kvedit-x { opacity: 1; }
}

@keyframes ib-share-in {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: none; }
}

@media (max-width: 520px) {
  .ib-share-copy { flex-direction: column; }
}

/* An inbox's editor (lib/inboxes.js): its tags, with the workspace's own to
   pick from, its channels, and its colour. */
.ibx-suggest { display: flex; flex-wrap: wrap; gap: 6px; }
.ibx-suggest:empty { display: none; }
.ibx-tag {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 8px;
  border-radius: var(--radius-sm);
  background: var(--card);
  box-shadow: inset 0 0 0 1px var(--border);
  color: var(--ink-2);
  font-size: var(--text-xs);
  font-weight: 500;
  transition: background-color var(--t) var(--ease), box-shadow var(--t) var(--ease), color var(--t) var(--ease);
}
.ibx-tag:hover { background: var(--sunken); color: var(--ink); }
.ibx-tag.is-chosen { background: var(--accent-soft); box-shadow: inset 0 0 0 1px var(--accent); color: var(--accent-ink); }
.ibx-channels {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(128px, 1fr));
  gap: 6px 12px;
  margin-top: var(--s-2);
}
.ibx-swatches { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; }
.ibx-swatch {
  position: relative;
  display: inline-grid;
  place-items: center;
  width: 26px;
  height: 30px;
  cursor: pointer;
}
.ibx-swatch-input {
  position: absolute;
  inset: 0;
  margin: 0;
  opacity: 0;
  cursor: pointer;
}
.ibx-swatch-dot {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--swatch, transparent);
}
.ibx-swatch-input:checked + .ibx-swatch-dot { box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--ink); }
.ibx-swatch-input:focus-visible + .ibx-swatch-dot { outline: 2px solid var(--accent); outline-offset: 4px; }
/* None chosen: the workspace's own colour, said in words. */
.ibx-swatch-auto { width: auto; margin-right: 4px; }
.ibx-auto {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 26px;
  padding: 0 10px 0 8px;
  border-radius: var(--radius-pill);
  box-shadow: inset 0 0 0 1px var(--border-strong);
  color: var(--ink-2);
  font-size: var(--text-xs);
  font-weight: 500;
  white-space: nowrap;
}
.ibx-auto-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--swatch, var(--muted)); }
.ibx-swatch-input:checked + .ibx-auto { box-shadow: inset 0 0 0 2px var(--ink); color: var(--ink); }
.ibx-swatch-input:focus-visible + .ibx-auto { outline: 2px solid var(--accent); outline-offset: 2px; }

/* A dialog's destructive action keeps to the left, away from the one that saves. */
.modal-footer > .btn-danger-ghost:first-child { margin-right: auto; }

@media (pointer: coarse) {
  .ibx-swatch { width: 36px; height: 36px; }
}

@media (forced-colors: active) {
  .ibx-swatch-dot,
  .ibx-auto-dot { forced-color-adjust: none; }
}

/* -- Two-step sign-in (lib/mfa.js, the sign-in screen) ------------------------------ */
.auth-alt { display: flex; justify-content: center; margin-top: var(--s-2); }
.auth-code,
.mfa-code { font-family: var(--font-mono); font-size: 1.25rem; letter-spacing: 0.3em; text-align: center; }
.mfa-code { max-width: 240px; }

.mfa-steps { margin: 0; padding-left: 1.25em; display: grid; gap: 4px; color: var(--ink-2); font-size: var(--text-sm); }

.mfa-scan {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: var(--s-5);
  padding: var(--s-4);
  border-radius: var(--radius);
  background: var(--sunken);
}

/* The code stays dark on white in either theme, as scanners expect. */
.mfa-qr { padding: 8px; border-radius: var(--radius-sm); background: #ffffff; line-height: 0; }
.mfa-qr .qr { display: block; width: 180px; height: 180px; }
.mfa-key { display: block; padding: 8px 10px; border-radius: var(--radius-sm); background: var(--card); font-size: var(--text-sm); letter-spacing: 0.08em; overflow-wrap: anywhere; }

.mfa-recovery { display: grid; gap: var(--s-3); }

.mfa-codes {
  margin: 0;
  padding: var(--s-3) var(--s-4) var(--s-3) 2.5em;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px var(--s-6);
  border-radius: var(--radius);
  background: var(--sunken);
  font-size: var(--text-md);
}

@media (max-width: 479px) {
  .mfa-scan { grid-template-columns: 1fr; justify-items: center; text-align: center; }
  .mfa-codes { grid-template-columns: 1fr; }
}

/* -- 24. Global Workspace Search Popup & Quick-View Chat Pane -------------------- */

.topbar-search-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-width: 240px;
  max-width: 380px;
  height: 34px;
  padding: 0 6px 0 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-2);
  color: var(--muted);
  font-size: var(--text-sm);
  cursor: pointer;
  transition: border-color var(--t) var(--ease), background-color var(--t) var(--ease), box-shadow var(--t) var(--ease);
}
.topbar-search-btn:hover {
  border-color: var(--border-strong);
  background: var(--surface);
  color: var(--ink);
}
.topbar-search-text {
  flex: 1 1 auto;
  overflow: hidden;
  text-align: left;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.topbar-search-kbd {
  flex: none;
  font-size: 0.6875rem;
}
@media (max-width: 767px) {
  .topbar-search-btn {
    justify-content: center;
    width: var(--control-h);
    min-width: var(--control-h);
    height: var(--control-h);
    padding: 0;
    border-color: transparent;
    background: transparent;
    color: var(--ink-2);
  }
  .topbar-search-text,
  .topbar-search-kbd {
    display: none;
  }
}

.modal.modal-ws-search {
  max-width: 680px;
  width: 94vw;
  padding: 0;
  overflow: hidden;
  border-radius: 14px;
  transition: max-width 200ms var(--ease);
}
.modal.modal-ws-search.is-split {
  max-width: 1120px;
}
.modal.modal-ws-search > .modal-header {
  display: none;
}
.modal.modal-ws-search > .modal-body {
  padding: 0;
  overflow: hidden;
}

.ws-search-modal {
  display: flex;
  flex-direction: column;
  min-height: 460px;
  max-height: 82vh;
  background: var(--surface);
}
.ws-search-split {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
}
.modal.modal-ws-search.is-split .ws-search-split {
  grid-template-columns: minmax(320px, 1.05fr) minmax(340px, 0.95fr);
}
.ws-search-left {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
}

.ws-search-head {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 54px;
  padding: 8px 14px 8px 16px;
  border-bottom: 2px solid var(--accent);
  background: var(--surface);
}
.ws-search-ic {
  flex: none;
  color: var(--muted);
}
.ws-search-input.input {
  flex: 1 1 auto;
  min-width: 0;
  height: 36px;
  padding: 0 4px;
  border: 0 !important;
  box-shadow: none !important;
  background: transparent !important;
  font-size: 0.95rem;
}
.ws-search-head-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: none;
}
.ws-search-sep {
  width: 1px;
  height: 18px;
  background: var(--border);
}
.ws-search-resume {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  border: 1.5px solid var(--accent);
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-ink);
  font-size: var(--text-xs);
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}
.ws-search-resume:hover {
  background: var(--accent-soft);
}
.ws-search-clear {
  padding: 4px 8px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--danger-ink);
  font-size: var(--text-xs);
  font-weight: 600;
  cursor: pointer;
}
.ws-search-clear:hover {
  background: var(--danger-soft);
}
.ws-search-active-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  background: var(--accent-soft);
  color: var(--accent-ink);
  font-size: var(--text-xs);
  font-weight: 600;
  cursor: pointer;
}

.ws-search-body {
  flex: 1 1 auto;
  min-height: 320px;
  max-height: 64vh;
  overflow-y: auto;
}
.ws-search-pad {
  padding: 14px 16px;
}

.ws-search-hint-box {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg);
}
.ws-search-chips-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}
.ws-search-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  background: var(--accent-soft);
  color: var(--accent-ink);
  font-size: var(--text-xs);
  font-weight: 600;
  cursor: pointer;
  transition: background-color 140ms ease, border-color 140ms ease;
}
.ws-search-chip:hover,
.ws-search-chip.is-active {
  border-color: var(--accent);
  background: var(--accent);
  color: var(--accent-fg);
}

.ws-search-section-title {
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--ink);
  margin-bottom: 4px;
}
.ws-search-recent-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.ws-search-recent-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 8px 10px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--ink-2);
  font-size: var(--text-sm);
  text-align: left;
  cursor: pointer;
}
.ws-search-recent-item:hover,
.ws-search-recent-item.is-active {
  background: var(--bg);
  color: var(--ink);
}

.ws-search-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}
.ws-search-tabs,
.ws-search-toolbar-right {
  display: flex;
  align-items: center;
  gap: 6px;
}
.ws-search-tab,
.ws-search-date-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: var(--surface);
  color: var(--ink-2);
  font-size: var(--text-xs);
  font-weight: 600;
  cursor: pointer;
}
.ws-search-tab.is-active,
.ws-search-date-btn.is-active {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent-ink);
}
.ws-search-more-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 8px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--accent);
  font-size: var(--text-xs);
  font-weight: 600;
  cursor: pointer;
}
.ws-search-more-btn:hover,
.ws-search-more-btn.is-active {
  background: var(--accent-soft);
}
.ws-search-more-drawer {
  padding: 8px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
}

.ws-search-count {
  font-size: var(--text-sm);
  font-weight: 700;
  color: var(--ink);
}
.ws-search-group-head {
  display: flex;
  align-items: center;
  gap: 6px;
  font-weight: 600;
}
.ws-search-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  cursor: pointer;
  transition: border-color 140ms ease, box-shadow 140ms ease, background-color 140ms ease;
}
.ws-search-card:hover,
.ws-search-card.is-selected {
  border-color: var(--border-strong);
  background: var(--bg);
}
.ws-search-card.is-viewing {
  border: 1.5px solid var(--ink);
  background: var(--surface);
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.06);
}
.ws-search-card-avatar {
  position: relative;
  flex: none;
}
.ws-search-card-ch {
  position: absolute;
  right: -2px;
  bottom: -2px;
  display: grid;
  place-items: center;
  width: 16px;
  height: 16px;
  border: 1.5px solid var(--surface);
  border-radius: 50%;
  background: var(--bg);
  color: var(--ink-2);
}
.ws-search-card-main {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.ws-search-card-top {
  display: flex;
  align-items: center;
  gap: 6px;
}
.ws-search-card-name {
  font-size: var(--text-sm);
  color: var(--ink);
}
.ws-search-card-snippet {
  font-size: var(--text-sm);
  color: var(--ink-2);
}
.ws-search-card-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: none;
}
.ws-search-qv-btn {
  opacity: 0;
  transition: opacity 140ms ease;
}
.ws-search-card:hover .ws-search-qv-btn,
.ws-search-card:focus-within .ws-search-qv-btn,
.ws-search-card.is-selected .ws-search-qv-btn {
  opacity: 1;
}
.ws-search-mark {
  padding: 0 2px;
  border-radius: 3px;
  background: var(--mark-bg);
  color: var(--mark-ink);
  font-weight: 600;
}
.ws-search-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 180px;
}

/* Quick View Side Panel (Screenshot 3) */
.ws-qv-pane {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  border-left: 1px solid var(--border);
  background: var(--surface);
}
.ws-qv-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-height: 54px;
  padding: 8px 14px;
  border-bottom: 1px solid var(--border);
}
.ws-qv-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: var(--text-sm);
  color: var(--ink-2);
}
.ws-qv-subhead {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 8px 14px;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
  font-size: var(--text-sm);
}
.ws-qv-thread {
  flex: 1 1 auto;
  min-height: 260px;
  max-height: 52vh;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  overflow-y: auto;
  background: var(--surface-2);
}
.ws-qv-day {
  display: flex;
  justify-content: center;
  margin: 4px 0;
}
.ws-qv-day-pill {
  padding: 2px 10px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--muted);
  font-size: 0.7rem;
  font-weight: 600;
}
.ws-qv-msg-wrap {
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.ws-qv-msg-row {
  display: flex;
  align-items: flex-end;
  gap: 8px;
}
.ws-qv-msg-wrap.is-visitor .ws-qv-msg-row {
  justify-content: flex-start;
}
.ws-qv-msg-wrap.is-operator .ws-qv-msg-row {
  justify-content: flex-end;
}
.ws-qv-bubble {
  max-width: 78%;
  padding: 9px 13px;
  border-radius: 14px;
  font-size: var(--text-sm);
  line-height: 1.45;
  word-break: break-word;
}
.ws-qv-bubble.is-visitor {
  border: 1px solid var(--border);
  border-bottom-left-radius: 4px;
  background: var(--card);
  color: var(--ink);
}
.ws-qv-bubble.is-operator {
  border-bottom-right-radius: 4px;
  background: var(--accent);
  color: var(--accent-fg);
}
.ws-qv-bubble.is-note {
  border: 1px solid var(--note-line);
  background: var(--note-bg);
  color: var(--warning-ink);
}
.ws-qv-bubble.is-matched {
  outline: 2px solid var(--warning);
  outline-offset: 1px;
}
.ws-qv-delivered {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 4px;
  padding-right: 34px;
  font-size: 0.7rem;
}
.ws-qv-foot {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 10px 14px;
  border-top: 1px solid var(--border);
  background: var(--surface);
}
.ws-qv-open-btn {
  background: var(--ink);
  color: var(--on-ink);
  border-color: var(--ink);
}
.ws-qv-open-btn:hover {
  background: var(--ink-2);
  border-color: var(--ink-2);
}

.ws-search-foot {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 9px 16px;
  border-top: 1px solid var(--border);
  background: var(--bg);
}
.ws-search-foot-left,
.ws-search-foot-right {
  display: flex;
  align-items: center;
  gap: 10px;
}
.ws-search-switch {
  position: relative;
  width: 30px;
  height: 17px;
  padding: 2px;
  border: 0;
  border-radius: 999px;
  background: var(--border-strong);
  cursor: pointer;
  transition: background-color 140ms ease;
}
.ws-search-switch.is-on {
  background: var(--accent);
}
.ws-search-switch-thumb {
  display: block;
  width: 13px;
  height: 13px;
  border-radius: 50%;
  background: #FFFFFF;
  transition: transform 140ms ease;
}
.ws-search-switch.is-on .ws-search-switch-thumb {
  transform: translateX(13px);
}
.ws-search-cmd-btn {
  padding: 2px 6px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--ink);
  font-size: var(--text-xs);
  font-weight: 600;
  cursor: pointer;
}
.ws-search-cmd-btn:hover {
  background: var(--surface);
}

@media (max-width: 820px) {
  .modal.modal-ws-search.is-split .ws-search-split {
    grid-template-columns: 1fr;
  }
}

