/*! Tabs & Spaces design language, from @tabs-and-spaces/sdk 0.11.0: https://developer.tabsandspaces.dev/design-language/ */

/* Inter (SIL Open Font License 1.1: fonts/OFL.txt), from fonts/ beside this file. */

/* inter-cyrillic-ext-wght-normal */
@font-face {
  font-family: 'Inter Variable';
  font-style: normal;
  font-display: swap;
  font-weight: 100 900;
  src: url(fonts/inter-cyrillic-ext-wght-normal.woff2) format('woff2-variations');
  unicode-range: U+0460-052F,U+1C80-1C8A,U+20B4,U+2DE0-2DFF,U+A640-A69F,U+FE2E-FE2F;
}

/* inter-cyrillic-wght-normal */
@font-face {
  font-family: 'Inter Variable';
  font-style: normal;
  font-display: swap;
  font-weight: 100 900;
  src: url(fonts/inter-cyrillic-wght-normal.woff2) format('woff2-variations');
  unicode-range: U+0301,U+0400-045F,U+0490-0491,U+04B0-04B1,U+2116;
}

/* inter-greek-ext-wght-normal */
@font-face {
  font-family: 'Inter Variable';
  font-style: normal;
  font-display: swap;
  font-weight: 100 900;
  src: url(fonts/inter-greek-ext-wght-normal.woff2) format('woff2-variations');
  unicode-range: U+1F00-1FFF;
}

/* inter-greek-wght-normal */
@font-face {
  font-family: 'Inter Variable';
  font-style: normal;
  font-display: swap;
  font-weight: 100 900;
  src: url(fonts/inter-greek-wght-normal.woff2) format('woff2-variations');
  unicode-range: U+0370-0377,U+037A-037F,U+0384-038A,U+038C,U+038E-03A1,U+03A3-03FF;
}

/* inter-vietnamese-wght-normal */
@font-face {
  font-family: 'Inter Variable';
  font-style: normal;
  font-display: swap;
  font-weight: 100 900;
  src: url(fonts/inter-vietnamese-wght-normal.woff2) format('woff2-variations');
  unicode-range: U+0102-0103,U+0110-0111,U+0128-0129,U+0168-0169,U+01A0-01A1,U+01AF-01B0,U+0300-0301,U+0303-0304,U+0308-0309,U+0323,U+0329,U+1EA0-1EF9,U+20AB;
}

/* inter-latin-ext-wght-normal */
@font-face {
  font-family: 'Inter Variable';
  font-style: normal;
  font-display: swap;
  font-weight: 100 900;
  src: url(fonts/inter-latin-ext-wght-normal.woff2) format('woff2-variations');
  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;
}

/* inter-latin-wght-normal */
@font-face {
  font-family: 'Inter Variable';
  font-style: normal;
  font-display: swap;
  font-weight: 100 900;
  src: url(fonts/inter-latin-wght-normal.woff2) format('woff2-variations');
  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;
}

/*
 * Tabs & Spaces design tokens.
 *
 * Near-monochrome by design: hierarchy comes from greyscale value, weight,
 * size and spacing, not hue. Colour is reserved for rare semantic moments.
 *
 * Light and dark live side by side via `light-dark()`. The active scheme is
 * driven by `color-scheme`: "light dark" follows the OS (the "System" theme);
 * `data-theme="light" | "dark"` on <html> pins one explicitly.
 */

:root {
  color-scheme: light dark;

  /* ── Colour: surfaces ─────────────────────────────────────────── */
  /* Warm neutrals: paper and stone, not screen grey. */
  --color-backdrop: light-dark(#f3f2ef, #0b0b0a); /* app frame behind panels, sidebar */
  --color-canvas: light-dark(#ffffff, #151514); /* main content panel */
  --color-surface: light-dark(#f7f6f3, #1b1b19); /* wells, tracks, quiet fills */
  --color-surface-raised: light-dark(#ffffff, #222220); /* cards on surface, menus, pills */
  --color-hover: light-dark(rgb(28 25 20 / 0.045), rgb(255 250 240 / 0.055));
  --color-active: light-dark(rgb(28 25 20 / 0.075), rgb(255 250 240 / 0.09));

  /* ── Colour: lines ────────────────────────────────────────────── */
  --color-border: light-dark(#ebe9e4, #262624);
  --color-border-strong: light-dark(#dcd9d2, #353532);

  /* ── Colour: text (all pass WCAG AA on canvas, surface and backdrop) */
  --color-text: light-dark(#1a1917, #edece8);
  --color-text-muted: light-dark(#57544e, #aeaca6);
  --color-text-subtle: light-dark(#6b6862, #8f8d87);

  /* ── Colour: emphasis ─────────────────────────────────────────── */
  --color-accent: light-dark(#1a1917, #edece8);
  --color-accent-hover: light-dark(#34322e, #ffffff);
  --color-on-accent: light-dark(#ffffff, #151514);
  --color-focus-ring: light-dark(#1a1917, #edece8);
  /* Something new arrived (the Inbox's glow, decision 196): warm, so it reads as news even in
     the default ink; a workspace's own accent replaces it. */
  --color-notify: light-dark(#c26a12, #f0a54a);
  --ring: 0 0 0 3px light-dark(rgb(28 25 20 / 0.1), rgb(255 250 240 / 0.14));

  /* ── Colour: semantic (muted, used sparingly) ─────────────────── */
  --color-danger: light-dark(#b42318, #f97066);
  --color-success: light-dark(#1f7a4d, #47cd89);

  /* ── Colour: charts (decision 224) ────────────────────────────── */
  /* The one place hue carries meaning: a chart's series, in this fixed order (never cycled).
     Validated for colour-vision deficiency on adjacent pairs, against surface-raised, in both
     modes; three light steps sit under 3:1, so charts always offer a legend and a table. */
  --color-chart-1: light-dark(#2a78d6, #3987e5); /* blue */
  --color-chart-2: light-dark(#eb6834, #d95926); /* orange */
  --color-chart-3: light-dark(#1baf7a, #199e70); /* aqua */
  --color-chart-4: light-dark(#eda100, #c98500); /* yellow */
  --color-chart-5: light-dark(#e87ba4, #d55181); /* magenta */
  --color-chart-6: light-dark(#008300, #008300); /* green */

  /* ── Typography ───────────────────────────────────────────────── */
  --font-sans:
    "Inter Variable", "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  --font-mono:
    ui-monospace, "SF Mono", "JetBrains Mono", "Cascadia Code", Menlo, Consolas, monospace;

  --text-xs: 0.75rem; /* 12 */
  --text-sm: 0.8125rem; /* 13 */
  --text-md: 0.875rem; /* 14, the UI base */
  --text-lg: 1rem; /* 16 */
  --text-xl: 1.25rem; /* 20 */
  --text-2xl: 1.5rem; /* 24 */
  --text-3xl: 2rem; /* 32 */
  --text-4xl: 2.75rem; /* 44 */

  --leading-tight: 1.2;
  --leading-snug: 1.35;
  --leading-normal: 1.5;

  --weight-regular: 400;
  --weight-medium: 500;
  --weight-semibold: 600;

  --tracking-tight: -0.02em;
  --tracking-display: -0.035em;

  /* ── Spacing (4px grid) ───────────────────────────────────────── */
  --space-0-5: 0.125rem; /* 2 */
  --space-1: 0.25rem; /* 4 */
  --space-1-5: 0.375rem; /* 6 */
  --space-2: 0.5rem; /* 8 */
  --space-3: 0.75rem; /* 12 */
  --space-4: 1rem; /* 16 */
  --space-5: 1.25rem; /* 20 */
  --space-6: 1.5rem; /* 24 */
  --space-8: 2rem; /* 32 */
  --space-10: 2.5rem; /* 40 */
  --space-12: 3rem; /* 48 */
  --space-16: 4rem; /* 64 */

  /* ── Shape ────────────────────────────────────────────────────── */
  --radius-sm: 6px;
  --radius-md: 9px;
  --radius-lg: 14px;
  --radius-xl: 18px;
  --radius-full: 999px;
  --border-width: 1px;

  /* Layered, warm-tinted shadows; dark mode leans on a hairline highlight instead. */
  --shadow-xs:
    0 0 0 1px light-dark(rgb(28 25 20 / 0.06), rgb(255 250 240 / 0.06)),
    0 1px 2px light-dark(rgb(28 25 20 / 0.06), rgb(0 0 0 / 0.5));
  --shadow-sm:
    0 0 0 1px light-dark(rgb(28 25 20 / 0.05), rgb(255 250 240 / 0.06)),
    0 1px 2px light-dark(rgb(28 25 20 / 0.04), rgb(0 0 0 / 0.4)),
    0 2px 6px light-dark(rgb(28 25 20 / 0.04), rgb(0 0 0 / 0.3));
  --shadow-panel:
    0 0 0 1px light-dark(rgb(28 25 20 / 0.055), rgb(255 250 240 / 0.05)),
    0 1px 3px light-dark(rgb(28 25 20 / 0.04), rgb(0 0 0 / 0.4)),
    0 12px 32px -12px light-dark(rgb(28 25 20 / 0.08), rgb(0 0 0 / 0.5));
  --shadow-popover:
    0 0 0 1px light-dark(rgb(28 25 20 / 0.07), rgb(255 250 240 / 0.08)),
    0 4px 8px light-dark(rgb(28 25 20 / 0.04), rgb(0 0 0 / 0.3)),
    0 16px 40px -8px light-dark(rgb(28 25 20 / 0.14), rgb(0 0 0 / 0.6));

  /* ── Motion ───────────────────────────────────────────────────── */
  --duration-fast: 120ms;
  --duration-base: 200ms;
  --duration-slow: 320ms;
  --ease-out: cubic-bezier(0.2, 0.8, 0.2, 1);
  --ease-in-out: cubic-bezier(0.65, 0, 0.35, 1);

  /* ── Layout ───────────────────────────────────────────────────── */
  --sidebar-width: 256px;
  --sidebar-width-collapsed: 60px;
  --control-height-sm: 30px;
  --control-height-md: 36px;
  --panel-inset: 8px; /* gap between the app frame and the content panel */
}

:root[data-theme="light"] {
  color-scheme: light;
}

:root[data-theme="dark"] {
  color-scheme: dark;
}

@media (prefers-reduced-motion: reduce) {
  :root {
    --duration-fast: 0ms;
    --duration-base: 0ms;
    --duration-slow: 0ms;
  }
}

/* A small, opinionated reset on top of the tokens. */

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

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

body {
  margin: 0;
  min-height: 100dvh;
  background: var(--color-canvas);
  color: var(--color-text);
  font-family: var(--font-sans);
  font-size: var(--text-md);
  line-height: var(--leading-normal);
  font-optical-sizing: auto;
  font-feature-settings: "cv11", "ss03";
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

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

h1,
h2,
h3,
h4 {
  font-weight: var(--weight-semibold);
  line-height: var(--leading-tight);
  letter-spacing: var(--tracking-tight);
  text-wrap: balance;
}

p {
  text-wrap: pretty;
}

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

button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}

/* iOS's own button padding is about 1em a side (every browser there is WebKit),
   which squeezes an icon button's SVG (max-width: 100%) to nothing: use
   Chrome's everywhere, so a class that sets none looks the same on every phone. */
button {
  padding: 1px 6px;
}

code,
kbd,
pre,
samp {
  font-family: var(--font-mono);
  font-size: 0.925em;
}

a {
  color: inherit;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.2em;
}

::selection {
  background: var(--color-accent);
  color: var(--color-on-accent);
}

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

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0ms !important;
    transition-duration: 0ms !important;
  }
}

/*
 * The parts of the workspace's look, for your own tabs and home pages: the
 * same buttons, fields, cards, lists, menus, dialogs and tables as the app's
 * own (packages/ui and apps/web), on its tokens. Every class starts with
 * `ts-`, so they sit beside your own. scripts/design.mjs puts them after the
 * fonts, tokens and base styles in design/tabs-and-spaces.css (decisions 287,
 * 289; see https://developer.tabsandspaces.dev/design-language/).
 */

/* ── A tab's page ─────────────────────────────────────────────── */

.ts-page {
  display: flex;
  flex-direction: column;
  gap: var(--space-6);
  padding: var(--space-6);
}

@media (max-width: 36rem) {
  .ts-page {
    padding: var(--space-4);
  }
}

.ts-header {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-3) var(--space-4);
}

.ts-title {
  font-size: var(--text-xl);
  font-weight: var(--weight-semibold);
  letter-spacing: var(--tracking-tight);
  line-height: var(--leading-tight);
}

.ts-muted {
  color: var(--color-text-muted);
}

.ts-subtle {
  color: var(--color-text-subtle);
}

.ts-small {
  font-size: var(--text-sm);
  line-height: var(--leading-snug);
}

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

/* A titled group: a sentence-case title, a line under it, then its parts. */
.ts-section {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.ts-section-title {
  font-size: 0.9375rem;
  font-weight: var(--weight-semibold);
  letter-spacing: -0.01em;
}

/* ── Buttons ──────────────────────────────────────────────────── */

.ts-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-1-5);
  height: var(--control-height-md);
  padding-inline: var(--space-4);
  border: var(--border-width) solid transparent;
  border-radius: var(--radius-md);
  /* The main action: ink, with a soft top highlight and contact shadow. */
  background: var(--color-accent);
  background-image: linear-gradient(
    light-dark(rgb(255 255 255 / 0.1), rgb(255 255 255 / 0.5)),
    transparent
  );
  box-shadow:
    inset 0 1px 0 light-dark(rgb(255 255 255 / 0.12), rgb(255 255 255 / 0.6)),
    0 0 0 1px var(--color-accent),
    0 1px 2px light-dark(rgb(28 25 20 / 0.2), rgb(0 0 0 / 0.5));
  color: var(--color-on-accent);
  font-size: var(--text-md);
  font-weight: var(--weight-medium);
  white-space: nowrap;
  text-decoration: none;
  cursor: pointer;
  user-select: none;
  transition:
    background-color var(--duration-fast) var(--ease-out),
    box-shadow var(--duration-fast) var(--ease-out),
    transform var(--duration-fast) var(--ease-out);
}

.ts-button:hover:not(:disabled) {
  background-color: var(--color-accent-hover);
}

.ts-button:active:not(:disabled) {
  transform: scale(0.98);
}

.ts-button:disabled {
  opacity: 0.38;
  box-shadow: none;
  cursor: not-allowed;
}

/* Everything else: raised paper. */
.ts-button[data-variant="secondary"] {
  background: var(--color-surface-raised);
  box-shadow: var(--shadow-xs);
  color: var(--color-text);
}

.ts-button[data-variant="secondary"]:hover:not(:disabled) {
  background: var(--color-hover);
}

/* Quiet actions in a row or a toolbar. */
.ts-button[data-variant="ghost"] {
  background: transparent;
  box-shadow: none;
  color: var(--color-text-muted);
}

.ts-button[data-variant="ghost"]:hover:not(:disabled) {
  background: var(--color-hover);
  color: var(--color-text);
}

/* Only where something can't be undone. */
.ts-button[data-variant="danger"] {
  background: var(--color-danger);
  box-shadow:
    inset 0 1px 0 rgb(255 255 255 / 0.14),
    0 1px 2px light-dark(rgb(120 20 10 / 0.25), rgb(0 0 0 / 0.5));
  color: light-dark(#ffffff, #2a0a06);
}

.ts-button[data-variant="danger"]:hover:not(:disabled) {
  background: color-mix(in srgb, var(--color-danger) 88%, black);
}

.ts-button[data-size="sm"] {
  height: var(--control-height-sm);
  padding-inline: var(--space-3);
  border-radius: var(--radius-sm);
  font-size: var(--text-sm);
}

/* ── Fields ───────────────────────────────────────────────────── */

.ts-field {
  display: flex;
  flex-direction: column;
  gap: var(--space-1-5);
}

.ts-label {
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
}

.ts-input {
  width: 100%;
  height: calc(var(--control-height-md) + 2px);
  padding-inline: var(--space-3);
  border: var(--border-width) solid var(--color-border-strong);
  border-radius: var(--radius-md);
  background: var(--color-surface-raised);
  box-shadow: 0 1px 1px light-dark(rgb(28 25 20 / 0.03), rgb(0 0 0 / 0.2));
  font-size: var(--text-md);
  transition:
    border-color var(--duration-fast) var(--ease-out),
    box-shadow var(--duration-fast) var(--ease-out);
}

textarea.ts-input {
  height: auto;
  min-height: 88px;
  padding-block: var(--space-2);
  line-height: var(--leading-normal);
  resize: vertical;
}

.ts-input::placeholder {
  color: var(--color-text-subtle);
}

.ts-input:hover:not(:disabled, :focus-visible) {
  border-color: light-dark(#c9c5bd, #45443f);
}

.ts-input:focus-visible {
  outline: none;
  border-color: light-dark(#a9a49b, #5c5a55);
  box-shadow: var(--ring);
}

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

.ts-input:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.ts-hint {
  color: var(--color-text-subtle);
  font-size: var(--text-sm);
  line-height: var(--leading-snug);
}

.ts-error {
  color: var(--color-danger);
  font-size: var(--text-sm);
  line-height: var(--leading-snug);
}

/* A native <select>, inside <span class="ts-select">, which draws its chevron. */
.ts-select {
  position: relative;
  display: inline-flex;
}

.ts-select select {
  flex: 1;
  min-width: 0;
  appearance: none;
  height: var(--control-height-md);
  padding-inline: var(--space-3) var(--space-8);
  border: none;
  border-radius: var(--radius-md);
  background: var(--color-surface-raised);
  box-shadow: var(--shadow-xs);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  cursor: pointer;
}

.ts-select select:focus-visible {
  outline: none;
  box-shadow: var(--shadow-xs), var(--ring);
}

.ts-select::after {
  content: "";
  position: absolute;
  top: 50%;
  right: 13px;
  width: 6px;
  height: 6px;
  border-right: 1.5px solid var(--color-text-subtle);
  border-bottom: 1.5px solid var(--color-text-subtle);
  rotate: 45deg;
  translate: 0 -70%;
  pointer-events: none;
}

/* Two to five choices: radios in a sunken track, the chosen one raised. */
.ts-segmented {
  display: inline-flex;
  flex: none;
  gap: 2px;
  padding: 3px;
  border-radius: calc(var(--radius-md) + 1px);
  background: light-dark(#efede8, #0f0f0e);
  box-shadow: inset 0 1px 2px light-dark(rgb(28 25 20 / 0.05), rgb(0 0 0 / 0.4));
}

.ts-segmented label {
  position: relative;
  display: inline-flex;
}

.ts-segmented input {
  position: absolute;
  inset: 0;
  margin: 0;
  opacity: 0;
  cursor: pointer;
}

.ts-segmented span {
  display: inline-flex;
  align-items: center;
  height: calc(var(--control-height-md) - 6px);
  padding-inline: var(--space-3);
  border-radius: calc(var(--radius-md) - 2px);
  color: var(--color-text-muted);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  white-space: nowrap;
  transition:
    background-color var(--duration-fast) var(--ease-out),
    color var(--duration-fast) var(--ease-out);
}

.ts-segmented label:hover span {
  color: var(--color-text);
}

.ts-segmented input:checked + span {
  background: var(--color-surface-raised);
  box-shadow: var(--shadow-xs);
  color: var(--color-text);
}

.ts-segmented input:focus-visible + span {
  outline: 2px solid var(--color-focus-ring);
  outline-offset: 1px;
}

/* On or off, at once: <button class="ts-switch" role="switch" aria-checked="…">. */
.ts-switch {
  position: relative;
  flex: none;
  width: 38px;
  height: 22px;
  padding: 0;
  border: none;
  border-radius: var(--radius-full);
  background: light-dark(#dcd9d2, #3a3936);
  box-shadow: inset 0 1px 2px light-dark(rgb(28 25 20 / 0.08), rgb(0 0 0 / 0.4));
  cursor: pointer;
  transition: background-color var(--duration-base) var(--ease-out);
}

.ts-switch::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 18px;
  height: 18px;
  border-radius: var(--radius-full);
  background: light-dark(#ffffff, #f4f3f0);
  box-shadow:
    0 1px 2px rgb(0 0 0 / 0.18),
    0 2px 6px rgb(0 0 0 / 0.08);
  transition: translate var(--duration-base) cubic-bezier(0.3, 1.4, 0.5, 1);
}

.ts-switch[aria-checked="true"] {
  background: var(--color-accent);
}

.ts-switch[aria-checked="true"]::after {
  translate: 16px 0;
}

.ts-switch:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

/* ── Cards, rows and lists ────────────────────────────────────── */

/* A card on the page; its direct children are parted by hairlines. */
.ts-card {
  display: flex;
  flex-direction: column;
  border: var(--border-width) solid var(--color-border);
  border-radius: var(--radius-lg);
  background: var(--color-canvas);
  box-shadow: 0 1px 2px light-dark(rgb(28 25 20 / 0.03), rgb(0 0 0 / 0.2));
}

.ts-card > * + * {
  border-top: var(--border-width) solid var(--color-border);
}

.ts-pad {
  padding: var(--space-4) var(--space-5);
}

/* A setting: what it is on the left, its control on the right. */
.ts-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-6);
  min-height: 64px;
  padding: var(--space-4) var(--space-5);
}

.ts-row-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.ts-row-label {
  font-weight: var(--weight-medium);
}

.ts-row-hint {
  color: var(--color-text-subtle);
  font-size: var(--text-sm);
  line-height: var(--leading-snug);
}

@media (max-width: 36rem) {
  .ts-row {
    flex-direction: column;
    align-items: flex-start;
    gap: var(--space-3);
  }
}

/* Things in a list: a hairline box, a hairline between each. */
.ts-list {
  display: flex;
  flex-direction: column;
  margin: 0;
  padding: 0;
  border: var(--border-width) solid var(--color-border);
  border-radius: var(--radius-lg);
  list-style: none;
}

.ts-list > li {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  min-width: 0;
  padding: var(--space-3) var(--space-4);
}

.ts-list > li + li {
  border-top: var(--border-width) solid var(--color-border);
}

.ts-list a,
.ts-list button.ts-item {
  color: inherit;
  text-decoration: none;
}

.ts-item-text {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.ts-item-name {
  overflow: hidden;
  font-weight: var(--weight-medium);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ts-item-detail {
  color: var(--color-text-muted);
  font-size: var(--text-sm);
  line-height: var(--leading-snug);
}

/* A number at a glance. */
.ts-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(6.5rem, 1fr));
  gap: var(--space-3);
}

.ts-stat {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-lg);
  background: var(--color-surface);
}

.ts-stat strong {
  font-size: var(--text-2xl);
  font-weight: var(--weight-semibold);
  letter-spacing: var(--tracking-tight);
  line-height: var(--leading-tight);
  font-variant-numeric: tabular-nums;
}

.ts-stat span {
  color: var(--color-text-muted);
  font-size: var(--text-sm);
}

/* ── Status ───────────────────────────────────────────────────── */

/* A word about a thing's state. Colour only adds to the word, never replaces it. */
.ts-badge {
  display: inline-flex;
  flex: none;
  align-items: center;
  gap: var(--space-1);
  padding: 1px var(--space-2);
  border-radius: var(--radius-full);
  background: var(--color-active);
  color: var(--color-text-muted);
  font-size: var(--text-xs);
  font-weight: var(--weight-medium);
  line-height: 1.5;
  white-space: nowrap;
}

.ts-badge[data-tone="success"] {
  background: color-mix(in srgb, var(--color-success) 14%, transparent);
  color: var(--color-success);
}

.ts-badge[data-tone="danger"] {
  background: color-mix(in srgb, var(--color-danger) 12%, transparent);
  color: var(--color-danger);
}

.ts-badge[data-tone="accent"] {
  background: var(--color-accent);
  color: var(--color-on-accent);
}

.ts-dot {
  flex: none;
  width: 7px;
  height: 7px;
  border-radius: var(--radius-full);
  background: var(--color-text-subtle);
}

.ts-dot[data-tone="success"] {
  background: var(--color-success);
}

.ts-dot[data-tone="danger"] {
  background: var(--color-danger);
}

/* A line to read before going on: quiet, with a mark at its edge. */
.ts-notice {
  display: flex;
  gap: var(--space-2);
  padding: 10px var(--space-3);
  border: var(--border-width) solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-surface);
  color: var(--color-text-muted);
  font-size: var(--text-sm);
  line-height: var(--leading-snug);
}

.ts-notice::before {
  content: "";
  flex: none;
  align-self: stretch;
  width: 3px;
  border-radius: var(--radius-full);
  background: var(--color-text-subtle);
}

.ts-notice[data-tone="success"]::before {
  background: var(--color-success);
}

.ts-notice[data-tone="danger"]::before {
  background: var(--color-danger);
}

/* Nothing here yet: say so, and what to do. */
.ts-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-12) var(--space-6);
  border: var(--border-width) dashed var(--color-border-strong);
  border-radius: var(--radius-lg);
  color: var(--color-text-muted);
  text-align: center;
  text-wrap: balance;
}

/* ── Icons ────────────────────────────────────────────────────── */

/* An icon from icons.js beside text: the text's colour and size. */
.ts-icon {
  display: inline-block;
  flex: none;
  width: 1em;
  height: 1em;
  vertical-align: -0.125em;
}

.ts-button .ts-icon {
  width: 16px;
  height: 16px;
}

/* An icon alone as a button: give it a name (aria-label) and a title. */
.ts-icon-button {
  display: inline-flex;
  flex: none;
  align-items: center;
  justify-content: center;
  width: var(--control-height-sm);
  height: var(--control-height-sm);
  padding: 0;
  border: none;
  border-radius: var(--radius-md);
  background: none;
  color: var(--color-text-subtle);
  cursor: pointer;
  transition:
    background-color var(--duration-fast) var(--ease-out),
    color var(--duration-fast) var(--ease-out);
}

.ts-icon-button:hover:not(:disabled) {
  background: var(--color-hover);
  color: var(--color-text);
}

.ts-icon-button .ts-icon {
  width: 16px;
  height: 16px;
}

/* ── Menus ────────────────────────────────────────────────────── */

/*
 * A popover: <div class="ts-menu" id="…" popover>, opened by a button with
 * popovertarget="…". Its items close it with popovertargetaction="hide". It
 * opens under its button where the browser can place it (CSS anchor
 * positioning), else in the middle of the page.
 */
.ts-menu {
  min-width: 13rem;
  max-width: 20rem;
  padding: 5px;
  border: none;
  border-radius: var(--radius-lg);
  background: var(--color-surface-raised);
  box-shadow: var(--shadow-popover);
  color: var(--color-text);
}

@supports (position-area: block-end) {
  .ts-menu {
    inset: auto;
    margin: var(--space-1) 0;
    position-area: block-end span-inline-end;
    position-try-fallbacks: flip-block, flip-inline;
  }
}

.ts-menu-item {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  width: 100%;
  min-height: 34px;
  padding-inline: 9px;
  border: none;
  border-radius: 7px;
  background: transparent;
  color: var(--color-text);
  font-size: var(--text-sm);
  text-align: left;
  text-decoration: none;
  cursor: pointer;
}

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

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

.ts-menu-item[aria-checked="true"]::after {
  content: "";
  width: 8px;
  height: 4px;
  margin-left: auto;
  border-bottom: 1.5px solid currentColor;
  border-left: 1.5px solid currentColor;
  rotate: -45deg;
  translate: 0 -2px;
}

.ts-menu-item[data-tone="danger"] {
  color: var(--color-danger);
}

.ts-menu-separator {
  height: var(--border-width);
  margin: 5px -5px;
  background: var(--color-border);
}

.ts-menu-label {
  display: block;
  padding: var(--space-1-5) 9px var(--space-1);
  color: var(--color-text-subtle);
  font-size: var(--text-xs);
  font-weight: var(--weight-medium);
}

/* ── Dialogs ──────────────────────────────────────────────────── */

/*
 * A native <dialog class="ts-dialog">, opened with showModal(); a
 * <form method="dialog"> inside closes it. From the bottom on a phone.
 */
.ts-dialog {
  width: calc(100% - 2 * var(--space-4));
  max-width: 30rem;
  padding: var(--space-6);
  border: none;
  border-radius: var(--radius-xl);
  background: var(--color-canvas);
  box-shadow: var(--shadow-popover);
  color: var(--color-text);
}

.ts-dialog[open] {
  display: flex;
  flex-direction: column;
  gap: var(--space-5);
  animation: ts-rise var(--duration-slow) var(--ease-out);
}

.ts-dialog::backdrop {
  background: light-dark(rgb(28 25 20 / 0.28), rgb(0 0 0 / 0.6));
  backdrop-filter: blur(3px);
}

.ts-dialog[data-size="sm"] {
  max-width: 24rem;
}

.ts-dialog[data-size="lg"] {
  max-width: 44rem;
}

.ts-dialog-title {
  font-size: var(--text-xl);
  font-weight: var(--weight-semibold);
  letter-spacing: -0.025em;
  line-height: var(--leading-tight);
}

.ts-dialog-description {
  margin-top: var(--space-1);
  color: var(--color-text-muted);
  font-size: var(--text-sm);
  line-height: var(--leading-snug);
}

.ts-dialog-footer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: var(--space-2);
  margin: var(--space-1) 0 0;
}

@media (max-width: 30rem) {
  .ts-dialog {
    width: 100%;
    max-width: none;
    margin: auto 0 0;
    border-radius: var(--radius-xl) var(--radius-xl) 0 0;
    padding-bottom: calc(var(--space-6) + env(safe-area-inset-bottom, 0px));
  }
}

@keyframes ts-rise {
  from {
    opacity: 0;
    translate: 0 8px;
    scale: 0.985;
  }
}

/* ── Tables ───────────────────────────────────────────────────── */

/* Rows of figures: in a hairline box that scrolls sideways on its own, not the page. */
.ts-table-wrap {
  overflow-x: auto;
  border: var(--border-width) solid var(--color-border);
  border-radius: var(--radius-lg);
}

.ts-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--text-sm);
  font-variant-numeric: tabular-nums;
}

.ts-table th,
.ts-table td {
  padding: var(--space-3) var(--space-4);
  text-align: left;
  vertical-align: top;
}

.ts-table thead th {
  color: var(--color-text-muted);
  font-weight: var(--weight-medium);
  white-space: nowrap;
}

.ts-table tbody tr {
  border-top: var(--border-width) solid var(--color-border);
}

.ts-table tbody tr:hover {
  background: var(--color-hover);
}

/* Figures line up on the right. */
.ts-table [data-align="end"] {
  text-align: right;
}
