/* Pebbles Listening — prototype styles
   Layout: app shell (sidebar rail + sticky glass top bar + 12-col content grid);
   bottom floating tab bar under 768px. Pebble motif: soft radii, ripples, layered stones. */

:root {
  /* Canvas and surfaces: warm Pebbles cream, inked in deep pebble green */
  --bg: #F6F3E9;
  --bg-2: #EFEADB;
  --surface: #FFFDF7;
  --surface-2: #F9F6EC;
  --surface-3: #F2EEE1;
  --glass: rgba(255, 253, 247, 0.74);
  --glass-strong: rgba(255, 253, 247, 0.9);
  --line: rgba(8, 72, 47, 0.09);
  --line-2: rgba(8, 72, 47, 0.16);
  --ink: #0A2E21;
  --ink-2: #3D584D;
  --ink-3: #5F7469;
  --ink-inv: #FDF9E5;

  /* Brand (from the deck) */
  --brand: #19B27A;
  --brand-ink: #08482F;
  --sun: #FCCD06;
  --brand-pink: #FF74D7;  /* logo pink piece (deck value); not used for UI fills */
  --violet: #8D8DFD;
  --pink: #FD71D5;
  --mint: #DCF0EC;
  --violet-soft: #E6E4FD;
  --sun-soft: #FCEFB8;
  --pink-soft: #FBDDF1;

  /* Action + focus */
  --accent: #08482F;
  --accent-hover: #0B5A3B;
  --on-accent: #FDF9E5;
  --focus: #19B27A;

  /* Sentiment (diverging; validated for CVD, always paired with icon or label) */
  --pos: #0E9F86;
  --neu: #BCC4BE;
  --neg: #E5534B;
  --pos-soft: rgba(14, 159, 134, 0.12);
  --neg-soft: rgba(229, 83, 75, 0.11);
  --neu-soft: rgba(95, 116, 105, 0.10);
  --pos-text: #087565;
  --neg-text: #B8332C;

  /* Attention (upcoming / medium risk), never danger */
  --warn: #D99A00;
  --warn-soft: rgba(249, 204, 5, 0.22);
  --warn-text: #7A5600;

  /* Categorical (provider categories, layers), fixed order */
  --c1: #7B6CF6; /* violet  · Health */
  --c2: #D99A00; /* amber   · Development */
  --c3: #2E9BDB; /* sky     · Education */
  --c4: #E25DB4; /* pink    · Wellbeing */

  /* Sequential (heatmap): one violet hue, light to dark */
  --seq-0: #F1EFFD;
  --seq-1: #D9D4FB;
  --seq-2: #B3AAF6;
  --seq-3: #8A7CEF;
  --seq-4: #5C4AD6;
  --seq-5: #3A2AA6;

  --chart-grid: rgba(8, 72, 47, 0.08);
  --chart-band: rgba(14, 159, 134, 0.08);

  --shadow-1: 0 0 0 1px rgba(10, 46, 33, 0.04), 0 1px 1px rgba(10, 46, 33, 0.04), 0 2px 6px -2px rgba(10, 46, 33, 0.06), 0 8px 24px -12px rgba(10, 46, 33, 0.10);
  --shadow-2: 0 1px 2px rgba(10, 46, 33, 0.05), 0 18px 48px -20px rgba(10, 46, 33, 0.26);
  --shadow-3: 0 2px 6px rgba(10, 46, 33, 0.06), 0 40px 90px -30px rgba(10, 46, 33, 0.38);

  /* Type */
  --f-ui: "Be Vietnam Pro", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --f-display: "Fraunces", "Be Vietnam Pro", Georgia, "Times New Roman", serif;
  --f-mono: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;

  --t-micro: 0.6875rem;  /* 11 */
  --t-xs: 0.75rem;       /* 12 */
  --t-sm: 0.8125rem;     /* 13 */
  --t-base: 0.875rem;    /* 14 */
  --t-md: 1rem;          /* 16 */
  --t-lg: 1.25rem;       /* 20 */
  --t-xl: 1.625rem;      /* 26 */
  --t-2xl: 2.125rem;     /* 34 */
  --t-hero: 3.5rem;      /* 56 */

  /* Shape */
  --r-xs: 8px;
  --r-sm: 12px;
  --r-md: 16px;
  --r-lg: 22px;
  --r-xl: 28px;
  --r-pill: 999px;

  /* Space */
  --gap: 16px;
  --pad: 20px;
  --gutter: 28px;

  /* Motion */
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  --ease-in-out: cubic-bezier(0.65, 0, 0.35, 1);
  --ease-std: cubic-bezier(0.4, 0, 0.2, 1);
  --ease-in: cubic-bezier(0.4, 0, 1, 1); /* exits that leave the screen */
  --settle: var(--ease-out); /* panels, sheets, thumbs: no overshoot */
  --spring: cubic-bezier(0.34, 1.12, 0.64, 1); /* directly pressed objects only */
  --t-instant: 100ms;
  --t-fast: 150ms;
  --t-med: 200ms;
  --t-slow: 320ms;
  --t-panel: 300ms;
  --t-exit: 200ms;
  --t-enter: 360ms; /* panes and views surfacing */
  --t-reveal: 420ms; /* rows, cards, banners: entry with stagger */
  --t-draw: 700ms; /* line draws, bar grows, ring fills, highlight sweep: once per load */
  --stagger: 50ms; /* the one rhythm between siblings */

  /* Glass: bars and chips / floating overlays */
  --glass-blur: blur(20px) saturate(1.4);
  --glass-blur-strong: blur(28px) saturate(1.5);

  --card-sheen: none;
  --ambient-opacity: 0.5;
  --sidebar-w: 248px;
  --topbar-h: 74px; /* centre (37px) lines up with the sidebar logo; tablet rail: 18px sidebar padding + 4px brand padding + half the 30px mark */

  --chip-line: color-mix(in srgb, var(--ink) 12%, transparent);
  --key-shadow: 0 1px 0 rgba(10, 46, 33, 0.14);

  color-scheme: light;
}

@supports (transition-timing-function: linear(0, 1)) {
  :root {
    --spring: linear(0, 0.006, 0.025 2.8%, 0.101 6.1%, 0.539 18.9%, 0.721 25.3%, 0.849 31.5%, 0.937 38.1%, 0.968 41.8%, 0.991 45.7%, 1.006 50.1%, 1.015 55%, 1.017 63.9%, 1.001);
  }
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
      --bg: #0A0D0C;
      --bg-2: #070908;
      --surface: #111614;
      --surface-2: #161C19;
      --surface-3: #1C2320;
      --glass: rgba(17, 22, 20, 0.62);
      --glass-strong: rgba(21, 27, 24, 0.9);
      --line: rgba(255, 255, 255, 0.065);
      --line-2: rgba(255, 255, 255, 0.11);
      --ink: #F2F5F3;
      --ink-2: #BAC4BF;
      --ink-3: #8C9792;
      --ink-inv: #0A0D0C;
      --mint: #10261F;
      --violet-soft: #1C1B35;
      --sun-soft: #29230B;
      --pink-soft: #2C1426;
      --accent: #3DDC97;
      --accent-hover: #5BE6A9;
      --on-accent: #03170E;
      --focus: #5BE6A9;
      --pos: #22A891;
      --neu: #4D5753;
      --neg: #EA614E;
      --pos-soft: rgba(34, 168, 145, 0.15);
      --neg-soft: rgba(234, 97, 78, 0.14);
      --neu-soft: rgba(255, 255, 255, 0.06);
      --pos-text: #5FD9C0;
      --neg-text: #FF8E7C;
      --warn: #E5AE12;
      --warn-soft: rgba(229, 174, 18, 0.14);
      --warn-text: #F5CD55;
      --c1: #8B7EFF;
      --c2: #B98400;
      --c3: #2B8FCB;
      --c4: #D457A8;
      --seq-0: #161D1A;
      --seq-1: #262B4D;
      --seq-2: #3A3888;
      --seq-3: #5A50C8;
      --seq-4: #8478F2;
      --seq-5: #B9B0FF;
      --chart-grid: rgba(255, 255, 255, 0.06);
      --chart-band: rgba(34, 168, 145, 0.11);
      --card-sheen: linear-gradient(180deg, rgba(255, 255, 255, 0.028), rgba(255, 255, 255, 0) 120px);
      --shadow-1: 0 1px 0 rgba(255, 255, 255, 0.04) inset, 0 1px 2px rgba(0, 0, 0, 0.45), 0 10px 28px -14px rgba(0, 0, 0, 0.7);
      --shadow-2: 0 1px 0 rgba(255, 255, 255, 0.05) inset, 0 2px 4px rgba(0, 0, 0, 0.4), 0 22px 50px -20px rgba(0, 0, 0, 0.8);
      --shadow-3: 0 1px 0 rgba(255, 255, 255, 0.06) inset, 0 40px 90px -30px rgba(0, 0, 0, 0.9);
      --ambient-opacity: 0.26;
      --chip-line: rgba(255, 255, 255, 0.10);
      --key-shadow: 0 1px 0 rgba(0, 0, 0, 0.55);
      color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --bg: #0A0D0C;
  --bg-2: #070908;
  --surface: #111614;
  --surface-2: #161C19;
  --surface-3: #1C2320;
  --glass: rgba(17, 22, 20, 0.62);
  --glass-strong: rgba(21, 27, 24, 0.9);
  --line: rgba(255, 255, 255, 0.065);
  --line-2: rgba(255, 255, 255, 0.11);
  --ink: #F2F5F3;
  --ink-2: #BAC4BF;
  --ink-3: #8C9792;
  --ink-inv: #0A0D0C;
  --mint: #10261F;
  --violet-soft: #1C1B35;
  --sun-soft: #29230B;
  --pink-soft: #2C1426;
  --accent: #3DDC97;
  --accent-hover: #5BE6A9;
  --on-accent: #03170E;
  --focus: #5BE6A9;
  --pos: #22A891;
  --neu: #4D5753;
  --neg: #EA614E;
  --pos-soft: rgba(34, 168, 145, 0.15);
  --neg-soft: rgba(234, 97, 78, 0.14);
  --neu-soft: rgba(255, 255, 255, 0.06);
  --pos-text: #5FD9C0;
  --neg-text: #FF8E7C;
  --warn: #E5AE12;
  --warn-soft: rgba(229, 174, 18, 0.14);
  --warn-text: #F5CD55;
  --c1: #8B7EFF;
  --c2: #B98400;
  --c3: #2B8FCB;
  --c4: #D457A8;
  --seq-0: #161D1A;
  --seq-1: #262B4D;
  --seq-2: #3A3888;
  --seq-3: #5A50C8;
  --seq-4: #8478F2;
  --seq-5: #B9B0FF;
  --chart-grid: rgba(255, 255, 255, 0.06);
  --chart-band: rgba(34, 168, 145, 0.11);
  --card-sheen: linear-gradient(180deg, rgba(255, 255, 255, 0.028), rgba(255, 255, 255, 0) 120px);
  --shadow-1: 0 1px 0 rgba(255, 255, 255, 0.04) inset, 0 1px 2px rgba(0, 0, 0, 0.45), 0 10px 28px -14px rgba(0, 0, 0, 0.7);
  --shadow-2: 0 1px 0 rgba(255, 255, 255, 0.05) inset, 0 2px 4px rgba(0, 0, 0, 0.4), 0 22px 50px -20px rgba(0, 0, 0, 0.8);
  --shadow-3: 0 1px 0 rgba(255, 255, 255, 0.06) inset, 0 40px 90px -30px rgba(0, 0, 0, 0.9);
  --ambient-opacity: 0.26;
  --chip-line: rgba(255, 255, 255, 0.10);
  --key-shadow: 0 1px 0 rgba(0, 0, 0, 0.55);
  color-scheme: dark;
}

/* ───────── Base ───────── */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; scroll-behavior: smooth; }
html, body { min-height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--f-ui);
  font-size: var(--t-base);
  line-height: 1.5;
  font-feature-settings: "ss01", "cv11";
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
}
button, input, select, textarea { font: inherit; color: inherit; }
html { -webkit-tap-highlight-color: transparent; } /* no grey or blue tap flash on links and rows; the app gives its own press feedback */
button { cursor: pointer; background: none; border: 0; padding: 0; }
a { color: inherit; text-decoration: none; }
svg { display: block; }
img { max-width: 100%; }
[hidden] { display: none !important; }
::selection { background: color-mix(in srgb, var(--brand) 28%, transparent); }

:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 6px; }

.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

.ico { width: 18px; height: 18px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.ico-sm { width: 15px; height: 15px; }
.ico-xs { width: 13px; height: 13px; }
.ico-lg { width: 22px; height: 22px; }

.mono { font-family: var(--f-mono); font-feature-settings: normal; letter-spacing: 0; }
.num { font-variant-numeric: tabular-nums; }
.micro {
  font-family: var(--f-mono);
  font-size: var(--t-micro);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-3);
  font-weight: 500;
}
.muted { color: var(--ink-3); }
.ink-2 { color: var(--ink-2); }

/* Ambient backdrop: soft pebble light pools, fixed behind everything */
.ambient {
  position: fixed; inset: 0; z-index: 0; pointer-events: none; overflow: hidden;
}
.ambient span {
  position: absolute; border-radius: 50%; filter: blur(80px); opacity: var(--ambient-opacity);
  will-change: transform;
}
.ambient .a1 { width: 520px; height: 420px; left: -120px; top: -160px; background: color-mix(in srgb, var(--brand) 22%, transparent); }
.ambient .a2 { width: 460px; height: 380px; right: -140px; top: 20%; background: color-mix(in srgb, var(--violet) 20%, transparent); }
.ambient .a3 { width: 420px; height: 360px; left: 30%; bottom: -220px; background: color-mix(in srgb, var(--sun) 16%, transparent); }
/* Touch screens: the pools are a soft-edged mask (rasterised once) instead of a live 80 px filter. Under scrolling glass the filter was
   redone every frame and was the largest cost of a phone scroll on every screen (4x CPU: ~320 dropped frames per scroll on Providers, 7 without it). */
@media (pointer: coarse) {
  .ambient span { filter: none; will-change: auto; transform: scale(1.3); -webkit-mask-image: radial-gradient(closest-side, #000 15%, transparent); mask-image: radial-gradient(closest-side, #000 15%, transparent); }
}

/* ───────── App shell ───────── */
.app {
  position: relative; z-index: 1;
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
  min-height: 100vh;
  min-height: 100dvh;
}

.sidebar {
  position: sticky; top: 0;
  height: 100vh; height: 100dvh;
  display: flex; flex-direction: column;
  padding: 15px 14px 14px; /* brand block (mark + wordmark, 46px) centres at 37px, level with the topbar centre */
  border-right: 1px solid var(--line);
  background: color-mix(in srgb, var(--surface) 55%, transparent);
  -webkit-backdrop-filter: var(--glass-blur);
  backdrop-filter: var(--glass-blur);
  z-index: 20;
}
.brand {
  display: flex; align-items: center; gap: 11px;
  padding: 4px 8px 18px;
}
.brand-mark { width: 30px; height: 30px; flex: none; }
/* outlined deck wordmark (symbol #i-wordmark, 224.7 x 45 units); height sets the size */
.brand-name { display: block; width: 75px; height: 15px; flex: none; }
.brand-sub { display: block; margin-top: 5px; }

.nav { display: flex; flex-direction: column; gap: 2px; position: relative; }
.nav-label { padding: 14px 10px 6px; }
.nav-item {
  position: relative; z-index: 1;
  display: flex; align-items: center; gap: 12px;
  height: 40px; padding: 0 10px;
  border-radius: var(--r-sm);
  color: var(--ink-2);
  font-weight: 500; font-size: var(--t-base);
  transition: color var(--t-fast) var(--ease-std), --sl var(--t-fast) var(--ease-std);
  white-space: nowrap;
}
.nav-item .ico { color: var(--ink-3); transition: color var(--t-fast) var(--ease-out), transform var(--t-med) var(--spring); }
@media (hover: hover) {
  .nav-item:hover { color: var(--ink); }
  .nav-item:hover .ico { color: var(--ink); }
  .nav-item:active .ico { transform: scale(0.9); }
}
.nav-item.pressing .ico { transform: scale(0.9); }
.nav-item[aria-current="page"] { color: var(--ink); }
.nav-item[aria-current="page"] .ico { color: var(--brand); }
.nav-pill {
  position: absolute; left: 0; right: 0; top: 0; height: 40px; z-index: 0;
  border-radius: var(--r-sm);
  background: var(--surface);
  box-shadow: var(--shadow-1), 0 0 0 1px var(--line);
  transition: transform var(--t-slow) var(--settle), opacity var(--t-fast) var(--ease-std);
  pointer-events: none;
}
.nav-badge {
  margin-left: auto;
  min-width: 20px; height: 20px; padding: 0 6px;
  display: inline-grid; place-items: center;
  border-radius: var(--r-pill);
  font-size: var(--t-micro); font-weight: 600;
  font-variant-numeric: tabular-nums;
  background: var(--neg-soft); color: var(--neg-text);
}
.nav-badge.soft { background: color-mix(in srgb, var(--ink) 7%, transparent); color: var(--ink-2); }

.sidebar-foot { margin-top: auto; display: flex; flex-direction: column; gap: 10px; }
.health {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px;
  border-radius: var(--r-sm);
  border: 1px solid var(--line);
  background: var(--surface);
  font-size: var(--t-xs); color: var(--ink-2);
  text-align: left; width: 100%;
  transition: border-color var(--t-fast) var(--ease-std);
}
.health:hover { border-color: var(--line-2); }
.health-dots { display: flex; gap: 3px; flex-wrap: wrap; width: 46px; flex: none; }
.health-dots i { width: 6px; height: 6px; border-radius: 2px; background: var(--pos); }
.health-dots i.warn { background: var(--warn); }
.health-dots i.down { background: var(--neg); }
.health b { display: block; color: var(--ink); font-weight: 600; font-size: var(--t-sm); }

.me {
  display: flex; align-items: center; gap: 10px;
  padding: 8px; border-radius: var(--r-sm);
  transition: background-color var(--t-fast) var(--ease-std);
  text-align: left; width: 100%;
}
.me:hover { background: color-mix(in srgb, var(--ink) 4%, transparent); }
.avatar, .x-avatar {
  width: 34px; height: 34px; flex: none; border-radius: 50%;
  display: grid; place-items: center;
  font-size: var(--t-xs); font-weight: 600; letter-spacing: 0.02em;
  color: var(--brand-ink);
  background: linear-gradient(135deg, var(--sun) 0%, #FFE27A 100%);
  box-shadow: 0 0 0 2px var(--surface), 0 0 0 3px var(--line-2);
}
.avatar.sm, .x-avatar.sm { width: 26px; height: 26px; font-size: 10px; box-shadow: 0 0 0 2px var(--surface); }
.avatar.v, .x-avatar.v { background: linear-gradient(135deg, #B9B8FF, var(--violet)); color: #1B1A55; }
.avatar.p, .x-avatar.p { background: linear-gradient(135deg, #FFB3EA, var(--pink)); color: #4B0F3A; }
.avatar.g, .x-avatar.g { background: linear-gradient(135deg, #8FE3C3, var(--brand)); color: #05301F; }
.avatar.s, .x-avatar.s { background: linear-gradient(135deg, #A8DCF7, #4DB0E8); color: #06304A; }
.me-name { font-weight: 600; font-size: var(--t-sm); line-height: 1.25; }
.me-role { font-size: var(--t-xs); color: var(--ink-3); }

/* Main column */
.main { min-width: 0; display: flex; flex-direction: column; }

.topbar {
  position: sticky; top: 0; z-index: 15;
  height: var(--topbar-h);
  display: flex; align-items: center; gap: 12px;
  padding: 0 max(var(--gutter), calc((100% - 1480px) / 2 + var(--gutter))); /* on wide screens the bar keeps to the 1480px content column (.view), so title and controls line up with the cards below */
  background-color: transparent; /* flat over the page at rest, glass once content scrolls under it (JS sets .scrolled) */
  -webkit-backdrop-filter: var(--glass-blur);
  backdrop-filter: var(--glass-blur);
  border-bottom: 1px solid transparent;
  transition: border-color var(--t-med) var(--ease-std), background-color var(--t-med) var(--ease-std);
}
.topbar.scrolled { background-color: var(--glass); border-bottom-color: var(--line); }
.topbar { container: topbar / inline-size; }
.topbar-title { display: flex; flex-direction: column; min-width: 0; flex: 0 1 auto; }
.topbar-title h1 {
  margin: 0; font-size: var(--t-md); font-weight: 600; letter-spacing: -0.01em; line-height: 1.2;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.topbar-title span { font-size: var(--t-xs); color: var(--ink-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-mobile-brand { display: none; }
.spacer { flex: 1; }

.search-btn {
  display: flex; align-items: center; gap: 10px;
  height: 38px; padding: 0 8px 0 12px; min-width: 240px;
  border-radius: var(--r-pill);
  background: var(--surface);
  border: 1px solid var(--line);
  color: var(--ink-3);
  font-size: var(--t-sm);
  box-shadow: var(--shadow-1);
  transition: border-color var(--t-fast) var(--ease-std), box-shadow var(--t-med) var(--ease-std);
  flex: none; white-space: nowrap; /* the label never wraps; the bar steps down instead (below) */
}
.search-btn:hover { border-color: var(--line-2); }
.search-btn .label-short { display: none; }
/* Not enough room for the full label next to a long page subtitle: keep one word, drop the key hint */
@container topbar (max-width: 1119px) {
  .search-btn { min-width: 0; padding-right: 14px; }
  .search-btn .label, .search-btn .kbd-group, .search-btn .label-short { display: none; }
  .search-btn .label-short { display: inline; }
}
/* Keycap (Raycast): hairline border, bottom edge as inset shadow, mono 11px */
kbd {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 20px; height: 20px; padding: 0 6px; box-sizing: border-box;
  font-family: var(--f-mono); font-size: var(--t-micro); font-weight: 500;
  border-radius: 5px;
  background: var(--surface-3); color: var(--ink-3);
  border: 1px solid var(--line-2);
  box-shadow: inset var(--key-shadow);
  line-height: 1; white-space: nowrap;
}
kbd.sym { font-size: 14px; }
.kbd-group { display: inline-flex; gap: 3px; margin-left: auto; }

/* Status chip (Arrakis): outlined, mono caps, status dot */
.live-chip, .status.tag {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 8px; border-radius: 4px;
  border: 1px solid var(--chip-line);
  font-family: var(--f-mono); font-size: 10.5px; font-weight: 500; line-height: 1.2;
  letter-spacing: 0.06em; text-transform: uppercase;
}
.live-chip { color: var(--ink-2); }
.health .live-chip { display: flex; width: fit-content; margin-bottom: 5px; }
.live-chip i { width: 6px; height: 6px; border-radius: 50%; background: var(--pos); flex: none; }

/* Segmented control with sliding thumb */
.seg {
  position: relative; display: inline-flex; padding: 3px; gap: 0;
  border-radius: var(--r-pill);
  background: color-mix(in srgb, var(--ink) 5.5%, transparent);
  border: 1px solid var(--line);
  isolation: isolate;
}
.seg button {
  position: relative; z-index: 1;
  height: 30px; padding: 0 13px;
  border-radius: var(--r-pill);
  font-size: var(--t-sm); font-weight: 500;
  color: var(--ink-3);
  transition: color var(--t-med) var(--ease-out);
  white-space: nowrap;
}
.seg button[aria-pressed="true"] { color: var(--ink); }
.seg button:hover { color: var(--ink); }
.seg-thumb {
  position: absolute; z-index: 0; top: 3px; bottom: 3px; left: 0;
  border-radius: var(--r-pill);
  background: var(--surface);
  box-shadow: 0 1px 2px rgba(10, 46, 33, 0.12), 0 0 0 1px var(--line);
  /* travel is animated in app.js (moveThumb): it stretches over from and to */
}
.seg-n { margin-left: 3px; font-size: 0.92em; font-weight: 500; color: var(--ink-3); opacity: 0.85; }
.seg button[aria-pressed="true"] .seg-n { color: var(--ink-2); }
/* a control that has the row to itself fills it in equal segments (the Appearance choice in Settings at every width, the provider tabs on phone) */
.card > .seg[data-seg="theme"] { display: flex; }
.card > .seg[data-seg="theme"] > button { flex: 1 1 0; justify-content: center; }
.seg.sm button { height: 26px; padding: 0 11px; font-size: var(--t-xs); }

.icon-btn {
  width: 38px; height: 38px; flex: none;
  display: grid; place-items: center;
  border-radius: 50%;
  color: var(--ink-2);
  border: 1px solid var(--line);
  background: var(--surface);
  box-shadow: var(--shadow-1);
  transition: color var(--t-fast) var(--ease-std), border-color var(--t-fast) var(--ease-std), transform var(--t-med) var(--spring);
  position: relative;
}
.icon-btn:hover { color: var(--ink); border-color: var(--line-2); }
@media (hover: hover) { .icon-btn:active { transform: scale(0.94); } }
.icon-btn.pressing { transform: scale(0.94); }
.icon-btn.ghost { border-color: transparent; background: transparent; box-shadow: none; }
.icon-btn.ghost:hover { background: color-mix(in srgb, var(--ink) 5%, transparent); }
.icon-btn.sm { width: 30px; height: 30px; }
.icon-btn .dot { position: absolute; top: 7px; right: 8px; width: 7px; height: 7px; border-radius: 50%; background: var(--neg); box-shadow: 0 0 0 2px var(--surface); }

.refresh {
  display: inline-flex; align-items: center; gap: 8px;
  height: 38px; padding: 0 9px 0 10px;
  border-radius: var(--r-pill);
  font-size: var(--t-xs); color: var(--ink-3);
  transition: background-color var(--t-fast) var(--ease-std), color var(--t-fast) var(--ease-std);
  white-space: nowrap;
}
.refresh:hover { background: color-mix(in srgb, var(--ink) 5%, transparent); color: var(--ink); }
.refresh .ico { transition: transform var(--t-draw) var(--ease-out); }
/* Ring to the next scheduled update (--p is the percentage elapsed, set in app.js) */
.next-ring { --p: 0; position: relative; flex: none; width: 24px; height: 24px; display: grid; place-items: center; }
.next-ring::before {
  content: ""; position: absolute; inset: 0; border-radius: 50%;
  background: conic-gradient(var(--brand) calc(var(--p) * 1%), var(--line-2) 0);
  -webkit-mask: radial-gradient(farthest-side, transparent calc(100% - 2px), #000 calc(100% - 1.5px));
  mask: radial-gradient(farthest-side, transparent calc(100% - 2px), #000 calc(100% - 1.5px));
}
.refresh.spinning .ico { animation: spin 900ms linear infinite; } /* named effect: spinner */
.live-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--pos); position: relative; flex: none; }
.live-dot::after { content: ""; position: absolute; inset: -4px; border-radius: 50%; border: 1.5px solid var(--pos); opacity: 0; animation: ping 2.4s var(--ease-out) infinite; }

@keyframes spin { to { transform: rotate(360deg); } }
@keyframes ping { 0% { transform: scale(0.5); opacity: 0.8; } 80%, 100% { transform: scale(1.6); opacity: 0; } }

/* ───────── View + grid ───────── */
.view {
  position: relative;
  width: 100%; max-width: 1480px; margin: 0 auto;
  padding: 8px var(--gutter) 64px;
  min-width: 0;
}
.view.entering { animation: viewIn var(--t-enter) var(--ease-out) both; }
@keyframes viewIn {
  from { opacity: 0; transform: translate3d(0, 6px, 0); }
  to { opacity: 1; transform: none; }
}
.view.busy { opacity: 0.55; transition: opacity var(--t-med) var(--ease-std); pointer-events: none; }

.page-head {
  display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap;
  padding: 18px 0 20px;
}
.page-head h2 {
  margin: 0;
  font-family: var(--f-display);
  font-variation-settings: "SOFT" 100, "opsz" 72;
  font-weight: 400;
  font-size: var(--t-2xl);
  letter-spacing: -0.025em;
  line-height: 1.08;
  text-wrap: balance;
}
.page-head p { margin: 6px 0 0; color: var(--ink-2); max-width: 64ch; text-wrap: pretty; }
.page-head .actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

.grid {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  gap: var(--gap);
}
.span-12 { grid-column: span 12; }
.span-8 { grid-column: span 8; }
.span-7 { grid-column: span 7; }
.span-6 { grid-column: span 6; }
.span-5 { grid-column: span 5; }
.span-4 { grid-column: span 4; }
.span-3 { grid-column: span 3; }
.stack { display: flex; flex-direction: column; gap: var(--gap); min-width: 0; }

/* Card */
.card {
  position: relative;
  min-width: 0;
  background: var(--card-sheen), var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-1);
  padding: var(--pad);
  display: flex; flex-direction: column;
  transition: border-color var(--t-med) var(--ease-std), box-shadow var(--t-med) var(--ease-std), transform var(--t-med) var(--ease-out);
}
.card.link { cursor: pointer; }
@media (hover: hover) {
  .card.link:hover { border-color: var(--line-2); }
  .card.link:active { transform: scale(0.995); }
}
.card.link.pressing { transform: scale(0.995); }
.card-head {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 12px;
  margin-bottom: 14px;
}
.card-title { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.card-title h3 {
  margin: 0; font-size: var(--t-md); font-weight: 600; letter-spacing: -0.012em; line-height: 1.3;
  display: flex; align-items: center; gap: 6px;
}
.card-title p { margin: 0; font-size: var(--t-sm); color: var(--ink-3); text-wrap: pretty; }
.card-tools { display: flex; align-items: center; gap: 4px; flex: none; }
.card-foot {
  margin-top: auto; padding-top: 14px;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  font-size: var(--t-xs); color: var(--ink-3);
}

.hint {
  display: inline-grid; place-items: center;
  width: 18px; height: 18px; border-radius: 50%;
  vertical-align: middle; margin-top: -2px; /* centred on the x-height of the text it explains, not sitting on its baseline */
  color: var(--ink-3);
  transition: color var(--t-fast) var(--ease-std), background-color var(--t-fast) var(--ease-std);
}
.hint:focus-visible, .hint[aria-expanded="true"] { color: var(--ink); background: color-mix(in srgb, var(--ink) 6%, transparent); }
@media (hover: hover) { .hint:hover { color: var(--ink); background: color-mix(in srgb, var(--ink) 6%, transparent); } }
.hint:focus:not(:focus-visible) { outline: none; } /* a ring only for keyboard focus; the open state is the tint above */
/* The insight card's ⓘ says what it does from tablet up (phones show the same words in the folded menu) */
@media (min-width: 768px) {
  .insight .card-tools .hint {
    display: inline-flex; align-items: center; gap: 6px;
    width: auto; height: 32px; padding: 0 12px; margin-top: 0;
    border-radius: var(--r-pill);
    font-size: var(--t-xs); font-weight: 600; letter-spacing: -0.005em; color: var(--ink-2);
  }
  /* the three tools read as one row: same height, type, padding and icon size as "Mark a moment" (.btn.quiet.sm) */
  .insight .card-tools .hint .ico { width: 15px; height: 15px; }
  .insight .card-tools .icon-btn { width: 32px; height: 32px; }
  .insight .card-tools .hint::after { content: "How to read"; }
  /* a narrow card (the laptop grid with the side rail) keeps the row: the ⓘ goes back to an icon */
  @container insight-head (max-width: 560px) {
    .insight .card-tools .hint { width: 30px; height: 30px; padding: 0; justify-content: center; border-radius: 50%; }
    .insight .card-tools .hint::after { content: none; }
  }
}
.insight .card-head { container: insight-head / inline-size; }

.text-btn {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: var(--t-sm); font-weight: 500; color: var(--ink-2);
  padding: 6px 8px; margin: -6px -8px; border-radius: var(--r-xs);
  transition: color var(--t-fast) var(--ease-std), background-color var(--t-fast) var(--ease-std);
}
.text-btn:hover { color: var(--ink); background: color-mix(in srgb, var(--ink) 5%, transparent); }
.text-btn .ico { transition: transform var(--t-med) var(--spring); }
.text-btn:hover .ico.arrow { transform: translateX(3px); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 40px; padding: 0 16px;
  border-radius: var(--r-pill);
  font-size: var(--t-sm); font-weight: 600; letter-spacing: -0.005em;
  white-space: nowrap;
  transition: background-color var(--t-fast) var(--ease-std), color var(--t-fast) var(--ease-std), border-color var(--t-fast) var(--ease-std), transform var(--t-med) var(--spring), box-shadow var(--t-med) var(--ease-std);
}
/* Press: :active only on hover devices (a mouse); a finger gets .pressing from app.js once it rests, so a scroll never shows a pressed control */
@media (hover: hover) { .btn:active { transform: scale(0.98); } }
.btn.pressing { transform: scale(0.98); }
.btn.primary { background: var(--accent); color: var(--on-accent); box-shadow: 0 1px 0 rgba(255,255,255,0.12) inset, 0 6px 18px -8px color-mix(in srgb, var(--accent) 70%, transparent); }
.btn.primary:hover { background: var(--accent-hover); }
/* Label roll: the label moves up and out, a copy (data-t) comes in from below. Same box, same width. */
.btn-roll { position: relative; display: inline-block; overflow: hidden; line-height: 1.3; padding-block: 1px; margin-block: -1px; white-space: nowrap; }
.btn-roll-a { display: inline-block; }
@media (hover: hover) and (pointer: fine) and (prefers-reduced-motion: no-preference) {
  .btn-roll-a, .btn-roll::after { transition: transform var(--t-slow) var(--ease-out), opacity var(--t-med) var(--ease-std); }
  .btn-roll::after {
    content: attr(data-t); content: attr(data-t) / "";
    position: absolute; left: 0; top: 1px; white-space: nowrap; opacity: 0; transform: translateY(110%);
  }
  .btn.primary:not(:disabled):hover .btn-roll-a { transform: translateY(-110%); opacity: 0; }
  .btn.primary:not(:disabled):hover .btn-roll::after { transform: none; opacity: 1; }
}
.btn.secondary { background: var(--surface); color: var(--ink); border: 1px solid var(--line-2); }
.btn.secondary:hover { border-color: color-mix(in srgb, var(--ink) 30%, transparent); }
.btn.quiet { color: var(--ink-2); }
.btn.quiet:hover { background: color-mix(in srgb, var(--ink) 5%, transparent); color: var(--ink); }
.btn.sm { height: 32px; padding: 0 12px; font-size: var(--t-xs); }
/* A long label may wrap at very large text sizes instead of pushing the page sideways */
.btn.btn-wrap { white-space: normal; height: auto; min-height: 32px; max-width: 100%; padding-block: 6px; line-height: 1.25; text-align: left; }
.btn.block { width: 100%; }

/* Chips + sentiment tags */
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  height: 24px; padding: 0 9px;
  border-radius: var(--r-pill);
  font-size: var(--t-xs); font-weight: 500;
  background: color-mix(in srgb, var(--ink) 5.5%, transparent);
  color: var(--ink-2);
  white-space: nowrap;
}
.chip .ico { width: 12px; height: 12px; }
/* MW3: a chip whose state changes in place (sentiment corrected, status) changes colour instead of snapping */
.chip { transition: background-color var(--t-fast) var(--ease-std), color var(--t-fast) var(--ease-std); }
.sent-dot { transition: background-color var(--t-fast) var(--ease-std); }
.chip.pos { background: var(--pos-soft); color: var(--pos-text); }
.chip.neg { background: var(--neg-soft); color: var(--neg-text); }
.chip.neu { background: var(--neu-soft); color: var(--ink-2); }
.chip.warn { background: var(--warn-soft); color: var(--warn-text); }
.chip.outline { background: transparent; box-shadow: inset 0 0 0 1px var(--line-2); }
.chip.closed { background: var(--violet-soft); color: color-mix(in srgb, var(--c1) 80%, var(--ink)); }
.chip.sample { background: var(--sun-soft); color: var(--warn-text); font-family: var(--f-mono); font-size: 10.5px; letter-spacing: 0.04em; text-transform: uppercase; height: 22px; }

.sent-dot { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.sent-dot.pos { background: var(--pos); }
.sent-dot.neu { background: var(--neu); }
.sent-dot.neg { background: var(--neg); }

.delta { display: inline; font-weight: 600; font-size: var(--t-xs); font-variant-numeric: tabular-nums; white-space: nowrap; }
.delta .ico { vertical-align: -0.16em; margin-right: 3px; } /* inline (not flex) so the number sits on the text baseline of its row */
.delta.good { color: var(--pos-text); }
.delta.bad { color: var(--neg-text); }
.delta.flat { color: var(--ink-3); }

/* Source monograms */
.src {
  width: 26px; height: 26px; flex: none;
  display: inline-grid; place-items: center;
  border-radius: 8px;
  font-family: var(--f-mono); font-size: 9.5px; font-weight: 600; letter-spacing: 0;
  color: var(--ink-2);
  background: var(--surface-3);
  box-shadow: inset 0 0 0 1px var(--line);
}
.src.lg { width: 34px; height: 34px; border-radius: 10px; font-size: 11px; }

/* Risk stripe */
/* Risk edge: part of the card itself. It fills the card (border-radius: inherit), so the coloured edge is an inset line that follows the
   card's curve and tapers into the corners, with a soft wash of the same colour fading into the surface over the first ~110 px. */
.risk-stripe, .x-risk-stripe {
  --rc: var(--neu);
  position: absolute; inset: -1px; border-radius: inherit; pointer-events: none;
  box-shadow: inset 3px 0 0 var(--rc);
  background: linear-gradient(90deg, color-mix(in oklab, var(--rc) 9%, transparent), color-mix(in oklab, var(--rc) 3%, transparent) 64px, transparent 112px);
}
.risk-stripe.high, .x-risk-stripe.high { --rc: var(--neg); }
.risk-stripe.med, .x-risk-stripe.med { --rc: var(--warn); }
.risk-stripe.low, .x-risk-stripe.low { --rc: var(--neu); }
@supports not (background: color-mix(in oklab, red 10%, transparent)) { .risk-stripe, .x-risk-stripe { background: none; } }

/* ───────── Overview: hero ───────── */
.hero {
  position: relative; overflow: hidden; overflow: clip; /* clip, not a scroll box: focus or scrollIntoView on a hint inside must never scroll the hero content out of its card */
  padding: 26px 28px 24px;
  border-radius: var(--r-xl);
  min-height: 340px;
  isolation: isolate;
}
.hero-canvas { position: absolute; inset: 0; width: 100%; height: 100%; z-index: -1; }
.hero-stones { position: absolute; inset: 0; z-index: -1; pointer-events: none; }
.hero-stones i {
  position: absolute; display: block;
  border-radius: 48% 52% 46% 54% / 56% 50% 50% 44%;
  will-change: transform;
}
.hero-stones i.settling { transition: transform 900ms var(--ease-out); /* named effect: settle-back, 900 ms */ } /* JS adds it on pointerleave for the return to rest; per-frame writes need no CSS transition */
.hero-stones .s1 { width: 190px; height: 150px; right: -40px; top: -50px; background: radial-gradient(120% 120% at 30% 25%, color-mix(in srgb, var(--brand) 26%, transparent), transparent 65%); }
.hero-stones .s2 { width: 120px; height: 96px; right: 120px; bottom: -36px; background: radial-gradient(120% 120% at 30% 25%, color-mix(in srgb, var(--sun) 30%, transparent), transparent 68%); }
.hero-stones .s3 { width: 70px; height: 56px; right: 40px; bottom: 70px; background: radial-gradient(120% 120% at 30% 25%, color-mix(in srgb, var(--violet) 30%, transparent), transparent 70%); }
.hero::after {
  content: ""; position: absolute; inset: 0; z-index: -1; pointer-events: none;
  background: linear-gradient(90deg, var(--surface) 0%, color-mix(in srgb, var(--surface) 88%, transparent) 46%, color-mix(in srgb, var(--surface) 30%, transparent) 100%);
}
.hero-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.hero-greet { display: flex; align-items: center; gap: 10px; }
.verdict {
  margin: 18px 0 0;
  max-width: 30ch;
  font-family: var(--f-display);
  font-variation-settings: "SOFT" 100, "opsz" 96;
  font-weight: 400;
  font-size: clamp(1.6rem, 1.1rem + 1.5vw, 2.25rem);
  line-height: 1.12;
  letter-spacing: -0.028em;
  text-wrap: balance;
}
.verdict em { font-style: italic; font-variation-settings: "SOFT" 100, "opsz" 96; }
/* highlighter word: soft brand block that sweeps in once per session (JS adds .sweep; without it the highlight is static) */
.verdict em.hl-word {
  padding: 0 0.12em; margin: 0 -0.06em; border-radius: 6px;
  background: linear-gradient(color-mix(in srgb, var(--brand) 18%, transparent), color-mix(in srgb, var(--brand) 18%, transparent)) no-repeat left center / 100% 100%;
  -webkit-box-decoration-break: clone; box-decoration-break: clone;
}
.verdict em.hl-word.sweep { animation: hlSweep var(--t-draw) var(--ease-out) 350ms backwards; }
@keyframes hlSweep { from { background-size: 0% 100%; } to { background-size: 100% 100%; } }
.verdict .hl-pos { color: var(--pos-text); }
.verdict .hl-neg { color: var(--neg-text); }
.hero-metrics {
  margin-top: 26px;
  display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 28px; align-items: end;
}
.hero-num { display: flex; flex-direction: column; gap: 6px; }
.hero-num .big {
  font-size: var(--t-hero); font-weight: 600; letter-spacing: -0.045em; line-height: 0.95;
  font-feature-settings: "ss01", "lnum";
}
.hero-num .big small { font-size: 0.45em; letter-spacing: -0.02em; color: var(--ink-3); font-weight: 500; margin-left: 2px; }
.hero-num .lbl { display: flex; align-items: center; gap: 6px; font-size: var(--t-sm); color: var(--ink-2); font-weight: 500; }
.share { display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.share-bar { display: flex; gap: 2px; height: 12px; border-radius: var(--r-pill); overflow: hidden; }
.share-bar span { display: block; height: 100%; transition: flex-grow var(--t-enter) var(--settle); min-width: 3px; } /* period change: the segments slide to the new split (JS keeps the old values first) */
.share-bar span:first-child { border-radius: 6px 0 0 6px; }
.share-bar span:last-child { border-radius: 0 6px 6px 0; }
.share-bar .pos { background: var(--pos); }
.share-bar .neu { background: var(--neu); }
.share-bar .neg { background: var(--neg); }
.share-legend { display: flex; gap: 18px; flex-wrap: wrap; font-size: var(--t-sm); color: var(--ink-2); }
.share-legend > span { display: inline-flex; align-items: center; gap: 7px; white-space: nowrap; }
.share-legend b { color: var(--ink); font-weight: 600; font-variant-numeric: tabular-nums; }
.hero-foot {
  margin-top: 22px; padding-top: 16px;
  border-top: 1px solid var(--line);
  display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 20px;
}
.kv { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.kv .v { font-size: var(--t-lg); font-weight: 600; letter-spacing: -0.02em; line-height: 1.2; display: flex; align-items: baseline; gap: 8px; }
.kv .k { font-size: var(--t-xs); color: var(--ink-3); }

/* Needs you */
.needs .progress { display: flex; align-items: center; gap: 12px; }
.ring { width: 40px; height: 40px; flex: none; transform: rotate(-90deg); }
.ring circle { fill: none; stroke-width: 4; }
.ring .track { stroke: color-mix(in srgb, var(--ink) 8%, transparent); }
.ring .fill { stroke: var(--brand); stroke-linecap: round; transition: stroke-dashoffset var(--t-draw) var(--ease-out); }
.task-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.task {
  position: relative;
  display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 12px; align-items: start;
  padding: 12px 12px 12px 14px;
  border-radius: var(--r-md);
  background: var(--surface-2);
  border: 1px solid var(--line);
  text-align: left; width: 100%;
  transition: background-color var(--t-fast) var(--ease-std), border-color var(--t-fast) var(--ease-std), transform var(--t-med) var(--ease-out), opacity var(--t-med) var(--ease-std), --sl var(--t-fast) var(--ease-std);
}
@media (hover: hover) { .task:hover { border-color: var(--line-2); } .task:active { transform: scale(0.99); } }
.task.pressing { transform: scale(0.99); }
.task .t-title { font-weight: 600; font-size: var(--t-sm); line-height: 1.35; letter-spacing: -0.005em; }
.task .t-meta { margin-top: 4px; display: flex; gap: 8px; flex-wrap: wrap; align-items: center; font-size: var(--t-xs); color: var(--ink-3); }
.task .ico.chev { color: var(--ink-3); margin-top: 2px; }
/* Done rows are dimmed through their content, not through the whole row, so the row stays opaque while it travels past others */
.task > * { transition: opacity var(--t-med) var(--ease-std); }
.task.done > * { opacity: 0.6; }
.task.done { border-color: color-mix(in srgb, var(--line) 55%, transparent); }
.task.done .t-title { text-decoration: line-through; text-decoration-color: var(--ink-3); }
.check {
  width: 22px; height: 22px; border-radius: 50%; flex: none;
  display: grid; place-items: center;
  border: 1.5px solid var(--line-2);
  color: transparent;
  transition: border-color var(--t-med) var(--ease-std), background-color var(--t-med) var(--ease-std), color var(--t-med) var(--ease-std), transform var(--t-med) var(--spring);
}
.check:hover { border-color: var(--brand); }
.task.done .check { background: var(--brand); border-color: var(--brand); color: #fff; }
.check .ico { width: 12px; height: 12px; stroke-width: 2.6; }

/* Layers */
.layer { gap: 0; }
.layer-top { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.layer-icon {
  width: 32px; height: 32px; border-radius: 10px; flex: none;
  display: grid; place-items: center;
}
.layer-icon .ico { width: 17px; height: 17px; }
.layer-icon.l1 { background: var(--mint); color: var(--brand-ink); }
.layer-icon.l2 { background: var(--violet-soft); color: color-mix(in srgb, var(--c1) 75%, var(--ink)); }
.layer-icon.l3 { background: var(--sun-soft); color: var(--warn-text); }
:root[data-theme="dark"] .layer-icon.l1 { color: var(--accent); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .layer-icon.l1 { color: var(--accent); } }
.layer-name { font-weight: 600; font-size: var(--t-sm); line-height: 1.25; }
.layer-sub { font-size: var(--t-xs); color: var(--ink-3); }
.layer-body { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; }
.layer-num { font-size: 2rem; font-weight: 600; letter-spacing: -0.04em; line-height: 1; }
.layer-num small { font-size: 0.42em; color: var(--ink-3); font-weight: 500; letter-spacing: 0; margin-left: 4px; }
.layer-note { margin: 12px 0 0; font-size: var(--t-sm); color: var(--ink-2); text-wrap: pretty; }
.spark { overflow: visible; }

/* Charts */
.chart { position: relative; width: 100%; min-width: 0; }
.chart svg { width: 100%; height: auto; overflow: visible; }
.chart text { font-family: var(--f-ui); font-size: 11px; fill: var(--ink-3); }
.chart .tick-label, .chart .x-tick-label { font-variant-numeric: tabular-nums; }
.chart .grid-line { stroke: var(--chart-grid); stroke-width: 1; shape-rendering: crispEdges; }
.chart .axis-line { stroke: var(--line-2); stroke-width: 1; shape-rendering: crispEdges; }
.chart .hit, .chart .x-hit { fill: transparent; cursor: crosshair; }
.chart .hit-label { cursor: default; pointer-events: bounding-box; } /* the name opens the same tooltip as its dot; bounding-box so the gaps between letters count too */
/* touch (charts.js touchTip): a vertical swipe scrolls the page, a sideways drag scrubs the chart; no text selection or callout on a long press */
.chart svg, .heat .cell { touch-action: pan-y; } /* on the svg: touch-action is not read on SVG shapes such as .hit */
.chart svg, .heat { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
.chart .focus-line { stroke: var(--ink-3); stroke-width: 1; opacity: 0; transition: opacity var(--t-fast) var(--ease-std); pointer-events: none; }
.chart.hovering .focus-line { opacity: 0.5; }
.chart .focus-dot { opacity: 0; transition: opacity var(--t-fast) var(--ease-std); pointer-events: none; }
.chart.hovering .focus-dot { opacity: 1; }
.chart .draw { stroke-dasharray: var(--len); stroke-dashoffset: var(--len); animation: draw var(--t-draw) var(--ease-out) forwards; }
@keyframes draw { to { stroke-dashoffset: 0; } }
.chart .fade-in { animation: none; }
/* Fade-in only when the screen is entered, never on a redraw (period, resize, tab) */
.view.on-enter .chart .fade-in { animation: fadeIn var(--t-reveal) var(--ease-out) both; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
/* MW3 (P-8): the Themes detail chart grows once when the screen is entered, not every time another theme is picked (that is a swap) */
.view:not(.on-enter) #themeChart .grow, .view:not(.on-enter) .bento .hbar .track span, .view:not(.on-enter) .bento .div-track span { animation: none; }
.chart .grow { transform-box: fill-box; transform-origin: bottom; animation: growY var(--t-draw) var(--ease-out) both; }
.chart .grow.down { transform-origin: top; }
@keyframes growY { from { transform: scaleY(0); } to { transform: scaleY(1); } }

.anno { cursor: pointer; }
.anno circle.badge { transform-box: fill-box; transform-origin: center; transition: transform var(--t-med) var(--spring); }
.anno text { font-family: var(--f-mono); font-size: 10px; font-weight: 600; fill: #fff; pointer-events: none; }
.anno:hover circle.badge, .anno.lit circle.badge { transform: scale(1.22); }

.legend { display: flex; gap: 16px; flex-wrap: wrap; font-size: var(--t-xs); color: var(--ink-2); }
.legend span { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.legend i { width: 14px; height: 3px; border-radius: 2px; display: inline-block; }
.legend i.box { width: 10px; height: 10px; border-radius: 3px; }

/* Tooltip */
.tip {
  position: fixed; left: 0; top: 0; z-index: 100;
  min-width: 168px; max-width: 260px;
  padding: 10px 12px;
  border-radius: var(--r-sm);
  background: var(--glass-strong);
  -webkit-backdrop-filter: var(--glass-blur);
  backdrop-filter: var(--glass-blur);
  border: 1px solid var(--line-2);
  box-shadow: var(--shadow-2);
  font-size: var(--t-xs);
  color: var(--ink-2);
  pointer-events: none;
  opacity: 0;
  transform: translate3d(0, 4px, 0) scale(0.98);
  transition: opacity var(--t-fast) var(--ease-out), transform var(--t-fast) var(--ease-out);
}
.tip.show { opacity: 1; transform: translate3d(0, 0, 0) scale(1); }
.tip-title { font-weight: 600; color: var(--ink); font-size: var(--t-sm); margin-bottom: 6px; }
.tip-row { display: flex; align-items: center; justify-content: space-between; gap: 14px; line-height: 1.7; }
.tip-row span { display: inline-flex; align-items: center; gap: 6px; }
.tip-row b { color: var(--ink); font-weight: 600; font-variant-numeric: tabular-nums; }
.tip-note { margin-top: 6px; padding-top: 6px; border-top: 1px solid var(--line); color: var(--ink-3); }
.tip-text { color: var(--ink); line-height: 1.5; max-width: 240px; } /* an info hint (app.js showHint) */

/* Why it changed */
.why-list { display: flex; flex-direction: column; gap: 12px; margin: 0; padding: 0; list-style: none; }
.why-item {
  display: grid; grid-template-columns: 22px minmax(0, 1fr); gap: 12px; align-items: start;
  padding: 12px; margin: -2px -12px; border-radius: var(--r-md);
  transition: background-color var(--t-fast) var(--ease-std), --sl var(--t-fast) var(--ease-std);
  cursor: pointer;
}
.why-badge {
  width: 22px; height: 22px; border-radius: 50%;
  display: grid; place-items: center;
  font-family: var(--f-mono); font-size: 10px; font-weight: 600; color: #fff;
}
.why-badge.neg { background: var(--neg); }
.why-badge.pos { background: var(--pos); }
.why-badge.rel { background: var(--ink-2); }
.why-item h4 { margin: 0; font-size: var(--t-sm); font-weight: 600; line-height: 1.35; }
.why-item p { margin: 4px 0 0; font-size: var(--t-sm); color: var(--ink-2); text-wrap: pretty; }
.evidence { margin-top: 8px; display: flex; gap: 6px; flex-wrap: wrap; }

.quote {
  margin: 10px 0 0; padding: 10px 12px;
  border-radius: var(--r-sm);
  background: var(--surface-2);
  border: 1px solid var(--line);
  font-size: var(--t-sm); color: var(--ink-2);
}
.quote .vi { display: block; margin-top: 4px; font-size: var(--t-xs); color: var(--ink-3); font-style: italic; }

/* Diverging theme bars */
.div-head, .div-row { display: grid; grid-template-columns: minmax(110px, 1.1fr) minmax(0, 2.6fr) 64px; gap: 14px; align-items: center; }
.div-head { padding-bottom: 8px; border-bottom: 1px solid var(--line); }
.div-head .scale { display: flex; justify-content: space-between; }
.div-row {
  padding: 9px 8px; margin: 0 -8px; border-radius: var(--r-sm);
  transition: background-color var(--t-fast) var(--ease-std), --sl var(--t-fast) var(--ease-std);
  cursor: pointer; text-align: left; width: calc(100% + 16px);
}
.div-row .name { font-size: var(--t-sm); font-weight: 500; color: var(--ink); line-height: 1.25; display: flex; flex-direction: column; min-width: 0; }
.div-row .name small { color: var(--ink-3); font-weight: 400; font-size: var(--t-xs); }
.div-track { position: relative; height: 14px; display: grid; grid-template-columns: 1fr 1fr; gap: 2px; }
.div-track .l, .div-track .r { position: relative; height: 100%; }
.div-track .l span { position: absolute; right: 0; top: 0; bottom: 0; background: var(--neg); border-radius: 4px 0 0 4px; transform-origin: right; animation: growX var(--t-draw) var(--ease-out) both; }
.div-track .r span { position: absolute; left: 0; top: 0; bottom: 0; background: var(--pos); border-radius: 0 4px 4px 0; transform-origin: left; animation: growX var(--t-draw) var(--ease-out) both; }
.div-track::before { content: ""; position: absolute; left: 50%; top: -4px; bottom: -4px; width: 1px; background: var(--line-2); transform: translateX(-0.5px); }
@keyframes growX { from { transform: scaleX(0); } to { transform: scaleX(1); } }
.div-row .net { text-align: right; font-weight: 600; font-size: var(--t-sm); font-variant-numeric: tabular-nums; }

/* Horizontal bars (sources) */
.hbars { display: flex; flex-direction: column; gap: 4px; }
.hbar {
  display: grid; grid-template-columns: 26px minmax(96px, 1fr) minmax(0, 1.6fr) 44px; gap: 12px; align-items: center;
  padding: 7px 8px; margin: 0 -8px; border-radius: var(--r-sm);
  transition: background-color var(--t-fast) var(--ease-std), --sl var(--t-fast) var(--ease-std);
  cursor: pointer; text-align: left; width: calc(100% + 16px);
}
.hbar .name { font-size: var(--t-sm); font-weight: 500; min-width: 0; line-height: 1.25; }
.hbar .name small { display: block; font-weight: 400; font-size: var(--t-xs); color: var(--ink-3); }
.hbar .track { position: relative; height: 10px; border-radius: 0 4px 4px 0; display: flex; gap: 2px; }
.hbar .track span { height: 100%; transform-origin: left; animation: growX var(--t-draw) var(--ease-out) both; }
.hbar .track .base { background: color-mix(in srgb, var(--ink) 18%, transparent); border-radius: 0; }
.hbar .track .negp { background: var(--neg); border-radius: 0 4px 4px 0; }
.hbar .val { text-align: right; font-size: var(--t-sm); font-weight: 600; font-variant-numeric: tabular-nums; }
.hbar.ch { grid-template-columns: minmax(110px, 1.2fr) minmax(0, 1.4fr) 44px; cursor: default; } /* channels: no source badge */
@media (max-width: 767px) {
  /* Sources on a phone: name and count on one line, the bar under them across the full width (no two-line names squeezed next to a short bar) */
  .hbar { grid-template-columns: 26px minmax(0, 1fr) auto; grid-template-areas: "b n v" "b t t"; column-gap: 10px; row-gap: 7px; align-items: center; padding: 10px 8px; }
  .hbar > .src { grid-area: b; align-self: start; }
  .hbar .name { grid-area: n; }
  .hbar .name small { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .hbar .val { grid-area: v; align-self: start; }
  .hbar .track { grid-area: t; height: 8px; }
  .hbar.ch { grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "n v" "t t"; }
  /* "Mood over time" reads "Mood" so the three tabs fit beside the tools button; the full words stay in the accessible name */
  .seg .seg-more { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
}

/* Table view toggle */
.data-table { width: 100%; border-collapse: collapse; font-size: var(--t-sm); }
.data-table th { text-align: left; font-weight: 500; color: var(--ink-3); font-size: var(--t-xs); padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.data-table td { padding: 9px 10px; border-bottom: 1px solid var(--line); font-variant-numeric: tabular-nums; }
.data-table tr:last-child td { border-bottom: 0; }
.data-table td.r, .data-table th.r { text-align: right; }
.table-wrap { overflow-x: auto; max-height: 340px; overflow-y: auto; -webkit-overflow-scrolling: touch; }

/* Closing card (end of the one-minute read) */
.closing {
  display: flex; align-items: center; gap: 18px; flex-wrap: wrap;
  padding: 18px 22px;
  border-radius: var(--r-lg);
  background: linear-gradient(120deg, var(--mint), color-mix(in srgb, var(--mint) 40%, var(--surface)));
  border: 1px solid var(--line);
}
.closing p { margin: 0; flex: 1 1 280px; font-size: var(--t-md); color: var(--ink); text-wrap: pretty; }
.closing p span { color: var(--ink-2); }
.closing-stones { width: 46px; height: 46px; flex: none; }

/* ───────── Mentions ───────── */
.filters {
  display: flex; gap: 8px; flex-wrap: wrap; align-items: center;
  padding: 10px; margin-bottom: var(--gap);
  border-radius: var(--r-lg);
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-1);
  position: sticky; top: calc(var(--topbar-h) + 8px); z-index: 5;
}
.field {
  position: relative; display: flex; align-items: center; gap: 8px;
  height: 34px; padding: 0 10px;
  border-radius: var(--r-pill);
  background: var(--surface-2);
  border: 1px solid var(--line);
  font-size: var(--t-sm); color: var(--ink-2);
  transition: border-color var(--t-fast) var(--ease-std);
}
.field:focus-within { border-color: var(--focus); }
.field input { border: 0; outline: 0; background: transparent; min-width: 0; width: 180px; font-size: var(--t-sm); color: var(--ink); }
.field input::placeholder { color: var(--ink-3); }
.field select {
  appearance: none; -webkit-appearance: none;
  border: 0; outline: 0; background: transparent;
  padding-right: 18px; font-size: var(--t-sm); color: var(--ink); font-weight: 500;
  cursor: pointer;
}
.field .caret { position: absolute; right: 10px; pointer-events: none; color: var(--ink-3); }
.field .flabel { color: var(--ink-3); }
.result-count { margin-left: auto; font-size: var(--t-xs); color: var(--ink-3); padding-right: 6px; white-space: nowrap; }

.split { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.05fr); gap: var(--gap); align-items: start; }
.mention-list { display: flex; flex-direction: column; gap: 8px; }
.mention, .x-mention {
  position: relative;
  display: flex; flex-direction: column; gap: 8px;
  padding: 14px 16px 14px 18px;
  border-radius: var(--r-md);
  background: var(--surface);
  border: 1px solid var(--line);
  text-align: left; width: 100%;
  transition: border-color var(--t-fast) var(--ease-std), box-shadow var(--t-med) var(--ease-std), transform var(--t-med) var(--ease-out), --sl var(--t-fast) var(--ease-std);
}
/* Rows surface only on screen entry and only the first six (class r-in, set in mentionCard); filters and edits swap in place */
.view.on-enter .mention.r-in, .view.on-enter .x-mention.r-in { animation: rise var(--t-reveal) var(--ease-out) calc(var(--i, 0) * var(--stagger)) backwards; }
/* Rows enter from a soft blur; the stagger (--i x 50 ms) covers the first six. The filter is gone at the end. */
@keyframes rise { from { opacity: 0; transform: translate3d(0, 8px, 0); filter: blur(3px); } to { opacity: 1; transform: none; filter: none; } }
@media (hover: hover) { .mention:hover, .x-mention:hover { border-color: var(--line-2); box-shadow: var(--shadow-1); } }
.mention[aria-selected="true"], .x-mention[aria-selected="true"] { border-color: color-mix(in srgb, var(--brand) 55%, transparent); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--brand) 55%, transparent), inset 0 0 0 4px color-mix(in srgb, var(--brand) 10%, transparent); }
.m-head { display: flex; align-items: center; gap: 10px; min-width: 0; }
.m-src, .x-m-src { min-width: 0; flex: 1; }
.m-src b, .x-m-src b { display: block; font-size: var(--t-sm); font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.m-src span, .x-m-src span { display: block; font-size: var(--t-xs); color: var(--ink-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.m-time { font-size: var(--t-xs); color: var(--ink-3); white-space: nowrap; }
.m-text, .x-m-text { margin: 0; font-size: var(--t-base); line-height: 1.5; color: var(--ink); display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; text-wrap: pretty; }
.m-orig, .x-m-orig { margin: 0; font-size: var(--t-xs); line-height: 1.5; color: var(--ink-3); font-style: italic; display: -webkit-box; -webkit-line-clamp: 1; -webkit-box-orient: vertical; overflow: hidden; }
.m-foot, .x-m-foot { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.m-foot .reach, .x-m-foot .reach { margin-left: auto; font-size: var(--t-xs); color: var(--ink-3); display: inline-flex; gap: 5px; align-items: center; white-space: nowrap; }

.detail { position: sticky; top: calc(var(--topbar-h) + 76px); max-height: calc(100vh - var(--topbar-h) - 96px); overflow: auto; overscroll-behavior: contain; scrollbar-width: thin; }
.detail-inner { display: flex; flex-direction: column; gap: 18px; }
.d-section, .x-d-section { display: flex; flex-direction: column; gap: 8px; }
.d-section > .micro, .x-d-section > .micro { margin-bottom: 2px; }
.bilingual { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.lang-box { padding: 14px; border-radius: var(--r-md); border: 1px solid var(--line); background: var(--surface-2); min-width: 0; }
.lang-box .micro { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 8px; }
.lang-box p { margin: 0; font-size: var(--t-base); line-height: 1.6; text-wrap: pretty; }
.lang-box.orig p { color: var(--ink-2); }
.meta-grid, .x-meta-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 10px; }
.meta-cell, .x-meta-cell { padding: 10px 12px; border-radius: var(--r-sm); background: var(--surface-2); border: 1px solid var(--line); min-width: 0; }
.meta-cell .k, .x-meta-cell .k { font-size: var(--t-xs); color: var(--ink-3); }
.meta-cell .v, .x-meta-cell .v { font-size: var(--t-sm); font-weight: 600; margin-top: 2px; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.conf { display: flex; align-items: center; gap: 8px; }
.conf-bar { flex: 1; height: 6px; border-radius: 3px; background: color-mix(in srgb, var(--ink) 8%, transparent); overflow: hidden; min-width: 50px; }
.conf-bar span { display: block; height: 100%; border-radius: 3px; background: var(--ink-2); }
.reply-box { padding: 14px; border-radius: var(--r-md); border: 1px dashed var(--line-2); background: color-mix(in srgb, var(--violet-soft) 45%, var(--surface)); }
.reply-box p { margin: 0; font-size: var(--t-sm); line-height: 1.6; }
.reply-box .en { margin-top: 6px; color: var(--ink-3); font-size: var(--t-xs); }
.reply-actions, .x-reply-actions { margin-top: 12px; display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.assignees { display: flex; gap: 6px; flex-wrap: wrap; }
.assignee {
  display: inline-flex; align-items: center; gap: 8px;
  height: 36px; padding: 0 12px 0 5px;
  border-radius: var(--r-pill);
  border: 1px solid var(--line);
  background: var(--surface);
  font-size: var(--t-xs); font-weight: 500;
  transition: border-color var(--t-fast) var(--ease-std), background-color var(--t-fast) var(--ease-std), transform var(--t-med) var(--spring), --sl var(--t-fast) var(--ease-std);
}
.assignee:hover { border-color: var(--line-2); }
@media (hover: hover) { .assignee:active { transform: scale(0.96); } }
.assignee.pressing { transform: scale(0.96); }
.assignee[aria-pressed="true"] { border-color: var(--brand); background-color: color-mix(in srgb, var(--brand) 9%, var(--surface)); }
.assignee small { color: var(--ink-3); font-weight: 400; }

/* ───────── Alerts ───────── */
.alert-group-label, .x-alert-group-label { padding: 0 2px; margin: 24px 0 10px; line-height: 1.2; }
.alert-group-label:first-child, .x-alert-group-label:first-child { margin-top: 0; }
.alert-item, .x-alert-item {
  position: relative;
  display: grid; grid-template-columns: 36px minmax(0, 1fr) auto; gap: 14px; align-items: start;
  padding: 14px 16px;
  border-radius: var(--r-md);
  background: var(--surface);
  border: 1px solid var(--line);
  text-align: left; width: 100%;
  transition: border-color var(--t-fast) var(--ease-std), opacity var(--t-med) var(--ease-std), transform var(--t-med) var(--ease-out), background-color var(--t-fast) var(--ease-std), --sl var(--t-fast) var(--ease-std);
}
.alert-item + .alert-item, .x-alert-item + .x-alert-item { margin-top: 10px; }
@media (hover: hover) { .alert-item:hover, .x-alert-item:hover { border-color: var(--line-2); } }
.alert-item.read, .x-alert-item.read { background-color: transparent; }
.alert-item.read .a-title, .x-alert-item.read .x-a-title { color: var(--ink-2); font-weight: 500; }
.a-icon, .x-a-icon { width: 36px; height: 36px; border-radius: 12px; display: grid; place-items: center; }
.a-icon.high, .x-a-icon.high { background: var(--neg-soft); color: var(--neg-text); }
.a-icon.med, .x-a-icon.med { background: var(--warn-soft); color: var(--warn-text); }
.a-icon.pos, .x-a-icon.pos { background: var(--pos-soft); color: var(--pos-text); }
.a-icon.info, .x-a-icon.info { background: color-mix(in srgb, var(--ink) 6%, transparent); color: var(--ink-2); }
.a-title, .x-a-title { font-weight: 600; font-size: var(--t-sm); line-height: 1.35; }
.a-body, .x-a-body { margin: 4px 0 0; font-size: var(--t-sm); color: var(--ink-2); text-wrap: pretty; }
.a-meta, .x-a-meta { margin-top: 8px; display: flex; gap: 8px; flex-wrap: wrap; align-items: center; font-size: var(--t-xs); color: var(--ink-3); }
.a-side, .x-a-side { display: flex; flex-direction: column; align-items: flex-end; gap: 8px; line-height: calc(var(--t-sm) * 1.35); padding-top: 0; font-size: var(--t-xs); color: var(--ink-3); white-space: nowrap; }
.unread-dot, .x-unread-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--brand); box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 20%, transparent); }

.variants { display: grid; grid-template-columns: 1fr; gap: 8px; }
.variant {
  position: relative;
  display: grid; grid-template-columns: 20px minmax(0, 1fr); gap: 12px; align-items: start;
  padding: 12px 14px;
  border-radius: var(--r-md);
  border: 1px solid var(--line);
  background: var(--surface);
  text-align: left; width: 100%;
  transition: border-color var(--t-fast) var(--ease-std), background-color var(--t-fast) var(--ease-std), box-shadow var(--t-med) var(--ease-std);
}
.variant:hover { border-color: var(--line-2); }
.variant[aria-checked="true"] { border-color: color-mix(in srgb, var(--brand) 60%, transparent); background: color-mix(in srgb, var(--brand) 6%, var(--surface)); box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 12%, transparent); }
.radio { width: 18px; height: 18px; margin-top: 1px; border-radius: 50%; border: 1.5px solid var(--line-2); display: grid; place-items: center; transition: border-color var(--t-fast) var(--ease-std); }
.radio::after { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--brand); transform: scale(0); transition: transform var(--t-med) var(--spring); }
.variant[aria-checked="true"] .radio { border-color: var(--brand); }
.variant[aria-checked="true"] .radio::after { transform: scale(1); }
.variant b { font-size: var(--t-sm); font-weight: 600; }
.variant p { margin: 3px 0 0; font-size: var(--t-xs); color: var(--ink-3); text-wrap: pretty; }

.toggle-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 12px 0; border-top: 1px solid var(--line); }
.toggle-row b { display: block; font-size: var(--t-sm); font-weight: 600; }
.toggle-row span { font-size: var(--t-xs); color: var(--ink-3); }
.switch {
  position: relative; width: 44px; height: 26px; flex: none;
  border-radius: var(--r-pill);
  background: color-mix(in srgb, var(--ink) 14%, transparent);
  transition: background-color var(--t-med) var(--ease-out);
}
.switch::after {
  content: ""; position: absolute; top: 3px; left: 3px;
  width: 20px; height: 20px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,0.2), 0 0 0 0.5px rgba(0,0,0,0.04);
  transition: transform var(--t-slow) var(--spring), width var(--t-med) var(--ease-out);
}
.switch[aria-checked="true"] { background: var(--brand); }
.switch[aria-checked="true"]::after { transform: translateX(18px); }
@media (hover: hover) {
  .switch:active::after { width: 24px; }
  .switch[aria-checked="true"]:active::after { transform: translateX(14px); }
}
.switch.pressing::after { width: 24px; }
.switch[aria-checked="true"].pressing::after { transform: translateX(14px); }

/* ───────── Providers ───────── */
.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--gap); }
.kpi { padding: 16px 18px; }
.kpi .k { font-size: var(--t-xs); color: var(--ink-3); display: flex; align-items: center; gap: 6px; }
.kpi .v { margin-top: 6px; font-size: 1.75rem; font-weight: 600; letter-spacing: -0.035em; line-height: 1.05; display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.kpi .v small { font-size: 0.5em; color: var(--ink-3); font-weight: 500; letter-spacing: 0; }
.kpi .s { margin-top: 6px; font-size: var(--t-xs); color: var(--ink-3); }
.kpi.alert { background: linear-gradient(160deg, color-mix(in srgb, var(--neg) 9%, var(--surface)), var(--surface) 70%); border-color: color-mix(in srgb, var(--neg) 22%, var(--line)); }

.ptable-wrap { overflow-x: auto; margin: 0 calc(var(--pad) * -1); padding: 0 var(--pad); -webkit-overflow-scrolling: touch; }
.ptable, .x-ptable { width: 100%; border-collapse: separate; border-spacing: 0; font-size: var(--t-sm); min-width: 860px; }
.ptable th, .x-ptable th {
  position: sticky; top: 0;
  text-align: left; font-weight: 500; color: var(--ink-3); font-size: var(--t-xs);
  padding: 10px 12px; border-bottom: 1px solid var(--line);
  white-space: nowrap; background: var(--surface);
}
.ptable th button, .x-ptable th button { display: inline-flex; align-items: center; gap: 4px; color: inherit; font-weight: 500; }
.ptable th button:hover, .x-ptable th button:hover { color: var(--ink); }
.ptable th[aria-sort] button, .x-ptable th[aria-sort] button { color: var(--ink); }
/* Sort chevron: on every sortable header (so widths never change), visible on the active one; ascending points up. app.js turns / fades it. */
.ptable th button .ico { opacity: 0; }
.ptable th[aria-sort] button .ico { opacity: 1; }
.ptable th[aria-sort="ascending"] button .ico { transform: rotate(180deg); }
/* Rows in flight during a sort: solid background so text never reads through text. Stack, bottom to top: leaving copy, rows going down,
   rows going up, entering row (all under the sticky header, z 5). The solid backing is on the row, so the sorted-column wash (td.sc) still shows on top. */
.ptable tbody tr.sort-fly { position: relative; background-color: var(--surface); transition: none; will-change: transform, opacity; }
.ptable tbody tr.sort-out { z-index: 1; }
.ptable tbody tr.sort-down { z-index: 2; }
.ptable tbody tr.sort-up { z-index: 3; }
.ptable tbody tr.sort-in { z-index: 4; }
.ptable thead th { z-index: 5; }
/* Sort on phone: the cards have no headers, so one select (same state as the desktop headers) sits left of Add provider */
.psort { display: none; }
.pcards .pcard.sort-fly { position: relative; transition: none; will-change: transform, opacity; }
.pcards .pcard.sort-out { z-index: 1; }
.pcards .pcard.sort-down { z-index: 2; }
.pcards .pcard.sort-up { z-index: 3; }
.pcards .pcard.sort-in { z-index: 4; }
@media (max-width: 767px) {
  /* One row, edge to edge: what to sort by (takes the room), turn-around, then a short "Add" */
  .toolbar .addprov-tools { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; align-items: center; }
  .toolbar .addprov-tools > :not(.psort-group):not(.addprov-add) { grid-column: 1 / -1; }
  .toolbar .addprov-tools .addprov-add { margin-left: 0; padding: 0 16px; }
  .toolbar .addprov-tools .addprov-word { display: none; }
  .psort-group { display: flex; gap: 6px; min-width: 0; }
  .psort { display: flex; align-items: center; gap: 8px; box-sizing: border-box; height: 44px; min-height: 44px; padding: 0 30px 0 14px; background: var(--surface); border-color: var(--line-2); flex: 1; min-width: 0; color: var(--ink-3); }
  .psort .ui-select-btn { max-width: none; min-width: 0; flex: 1; }
  .psort .ui-val { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .psort .caret { right: 12px; }
  .psort-dir { flex: none; width: 44px; height: 44px; border: 1px solid var(--line-2); background: var(--surface); }
  .psort-dir .ico { transform: rotate(90deg); transition: transform var(--t-panel) var(--settle); } /* arrow points down: the natural order */
  .psort-dir.flip .ico { transform: rotate(-90deg); }
}
/* The sorted column: a wash of ink on its cells and its header, fading in over 200 ms as the rows move (and out of the column that was sorted) */
.ptable td, .ptable thead th { transition: background-color var(--t-med) var(--ease-std); }
.ptable td.sc { background-color: color-mix(in srgb, var(--ink) 3.5%, transparent); }
.ptable thead th[aria-sort] { background-color: color-mix(in srgb, var(--ink) 3.5%, var(--surface)); }
@media (prefers-reduced-motion: reduce) { .ptable td, .ptable thead th { transition: none; } }
.ptable th.r, .ptable td.r, .x-ptable th.r, .x-ptable td.r { text-align: right; }
.ptable th.r button, .x-ptable th.r button { flex-direction: row-reverse; }
.ptable td, .x-ptable td { padding: 11px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; font-variant-numeric: tabular-nums; white-space: nowrap; }
.ptable tbody tr, .x-ptable tbody tr { cursor: pointer; transition: background-color var(--t-fast) var(--ease-std); }
.ptable tbody tr:hover td, .x-ptable tbody tr:hover td { background-color: var(--surface-2); }
.ptable tbody tr:hover td.sc { background-color: color-mix(in srgb, var(--ink) 3.5%, var(--surface-2)); }
.ptable tbody tr:last-child td, .x-ptable tbody tr:last-child td { border-bottom: 0; }
.p-name, .x-p-name { display: flex; align-items: center; gap: 10px; min-width: 0; }
.p-name b, .x-p-name b { font-weight: 600; display: block; }
.p-name span, .x-p-name span { font-size: var(--t-xs); color: var(--ink-3); }
.p-logo { width: 32px; height: 32px; border-radius: 10px; flex: none; display: grid; place-items: center; font-weight: 700; font-size: 12px; letter-spacing: -0.02em; background: color-mix(in srgb, var(--cat) 16%, var(--surface)); color: color-mix(in srgb, var(--cat) 72%, var(--ink)); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--cat) 22%, transparent); }
.cat { display: inline-flex; align-items: center; gap: 6px; font-size: var(--t-xs); color: var(--ink-2); }
.cat i { width: 8px; height: 8px; border-radius: 3px; }
.stars, .x-stars { display: inline-flex; align-items: center; gap: 4px; font-weight: 600; }
.stars .ico, .x-stars .ico { width: 13px; height: 13px; fill: var(--sun); stroke: var(--sun); }
.reply-meter, .x-reply-meter { display: inline-flex; align-items: center; gap: 8px; }
.reply-meter .bar, .x-reply-meter .bar { width: 52px; height: 6px; border-radius: 3px; background: color-mix(in srgb, var(--ink) 9%, transparent); overflow: hidden; }
.reply-meter .bar span, .x-reply-meter .bar span { display: block; height: 100%; border-radius: 3px; background: var(--ink-2); }
.reply-meter .bar span.low, .x-reply-meter .bar span.low { background: var(--warn); }

.pcards { display: none; flex-direction: column; gap: 8px; }
.pcard, .x-pcard { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 10px; padding: 14px; border-radius: var(--r-md); border: 1px solid var(--line); background: var(--surface-2); text-align: left; width: 100%; position: relative; transition: background-color var(--t-fast) var(--ease-std), --sl var(--t-fast) var(--ease-std); }
.pcard .row, .x-pcard .row { display: flex; gap: 14px; flex-wrap: wrap; margin-top: 10px; font-size: var(--t-xs); color: var(--ink-3); }
.pcard .row b, .x-pcard .row b { color: var(--ink); font-weight: 600; }
/* the numbers row spans the whole card, under the name and the status column, so it never breaks into a narrow stack */
.pcard > span:not(.risk-stripe):not(.pcard-status) { display: contents; }
.pcard .p-name { grid-column: 1; grid-row: 1; }
.pcard > span.pcard-status { grid-column: 2; grid-row: 1; }
.pcard > span.pcard-status, .x-pcard > span.pcard-status { display: flex; flex-direction: column; align-items: flex-end; gap: 8px; }
.pcard .row { grid-column: 1 / -1; grid-row: 2; margin-top: 2px; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; padding-top: 10px; border-top: 1px solid var(--line); }
.pcard .row > span { display: flex; flex-direction: column; gap: 1px; min-width: 0; overflow-wrap: anywhere; } /* the label may wrap at large text sizes, never clipped */
.pcard .row b { font-size: var(--t-base); letter-spacing: -0.01em; }
/* Large text on a narrow phone: the status chip and sparkline get their own line under the name, so the name keeps the card's width */
.pcards { container-type: inline-size; }
@container (max-width: 18em) {
  .pcard .p-name, .pcard .row { grid-row: auto; }
  .pcard > span.pcard-status { grid-column: 1 / -1; grid-row: auto; order: 1; flex-direction: row; align-items: center; justify-content: space-between; }
  .pcard .row { order: 2; }
}

.cq { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.cq-col h5 { margin: 0 0 8px; font-size: var(--t-xs); font-weight: 600; color: var(--ink-2); display: flex; align-items: center; gap: 6px; }
.cq-col ul { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 6px; }
.cq-col li { display: flex; justify-content: space-between; gap: 10px; font-size: var(--t-sm); padding: 8px 10px; border-radius: var(--r-xs); background: var(--surface-2); }
.cq-col li span:last-child { color: var(--ink-3); font-variant-numeric: tabular-nums; }

/* ───────── Themes ───────── */
.theme-list { display: flex; flex-direction: column; gap: 6px; }
.theme-head, .theme-row { display: grid; grid-template-columns: 28px minmax(0, 1fr) 90px 70px; gap: 12px; }
.theme-head { padding: 0 13px 8px; font-size: var(--t-micro); font-weight: 500; letter-spacing: 0.06em; text-transform: uppercase; font-family: var(--f-mono); color: var(--ink-3); align-items: end; line-height: 1.3; }
.theme-head span:last-child { grid-column: 3 / 5; text-align: right; white-space: nowrap; }
.theme-row {
  align-items: center;
  padding: 12px; border-radius: var(--r-md);
  border: 1px solid transparent;
  text-align: left; width: 100%;
  transition: background-color var(--t-fast) var(--ease-std), border-color var(--t-fast) var(--ease-std), --sl var(--t-fast) var(--ease-std);
}
.theme-row[aria-selected="true"] { background-color: var(--surface-2); border-color: var(--line-2); }
.rank { font-family: var(--f-mono); font-size: var(--t-xs); color: var(--ink-3); text-align: center; }
.theme-row .tn { font-weight: 600; font-size: var(--t-sm); line-height: 1.3; }
.theme-row .ts { font-size: var(--t-xs); color: var(--ink-3); margin-top: 2px; display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.theme-row .ts + .ts { margin-top: 3px; }
.theme-row .prio { color: var(--ink-2); margin-left: -2px; }
.theme-row .mood.neg { color: var(--neg-text); }
.theme-row .ts + .ts { column-gap: 6px; white-space: nowrap; flex-wrap: nowrap; }
@media (max-width: 1439px) and (min-width: 768px) { .theme-head, .theme-row { grid-template-columns: 24px minmax(0, 1fr) 72px 76px; gap: 10px; } .theme-row .tspark svg { width: 72px; } .theme-row .pw { display: none; } }
@media (max-width: 1180px) and (min-width: 768px) { .theme-head, .theme-row { grid-template-columns: 24px minmax(0, 1fr) 76px; } .theme-row .tspark { display: none; } } /* the detail beside it has the chart */
.meta-cell .mood.neg { color: var(--neg-text); }
.meta-cell .mood-word { font-size: var(--t-xs); font-weight: 400; color: var(--ink-3); }
.pb.theme-sheet .meta-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.pb .meta-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.trend-line { margin: 0 0 12px; font-size: var(--t-sm); color: var(--ink-2); line-height: 1.45; }
.trend-line.bad b { color: var(--neg-text); }
.trend-line.good b { color: var(--pos-text); }
/* Lens tiles: Negative / Positive / Mood switch what the list and the chart show */
.meta-cell.lens { text-align: left; font: inherit; color: inherit; cursor: pointer; position: relative; transition: background-color var(--t-fast) var(--ease-std), border-color var(--t-fast) var(--ease-std), box-shadow var(--t-fast) var(--ease-std); }
@media (hover: hover) { .meta-cell.lens:hover { border-color: var(--line-2); } }
.meta-cell.lens.on { background: var(--surface); border-color: var(--ink-3); box-shadow: var(--shadow-1); }
.meta-cell.lens.on .k { color: var(--ink); font-weight: 600; }
.meta-cell.lens:focus-visible { outline: 2px solid var(--focus, var(--brand)); outline-offset: 2px; }
.theme-step { display: flex; justify-content: space-between; gap: 8px; margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--line); }
.theme-step .btn { min-height: 44px; max-width: 49%; }
.theme-step .btn { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ico-flip { display: inline-flex; transform: scaleX(-1); }
.theme-sheet .card-head { margin-bottom: 12px; }
/* Lens change: each little line draws again left to right (a 35 ms ripple down the list), its end dot and the new number follow */
.theme-list.lens-in .spark .ln { stroke-dasharray: 1; stroke-dashoffset: 1; animation: draw var(--t-reveal) var(--settle) forwards; animation-delay: calc(var(--i, 0) * 35ms); }
.theme-list.lens-in .spark .ar, .theme-list.lens-in .spark .pt { animation: fadeIn var(--t-med) var(--ease-std) both; animation-delay: calc(var(--i, 0) * 35ms + 260ms); }
.theme-list.lens-in .tlast, .theme-list.lens-in .ts:first-of-type { animation: fadeIn var(--t-med) var(--ease-std) both; animation-delay: calc(var(--i, 0) * 35ms + 80ms); }
.view .pb.lens-in #themeChart .grow { animation: growY var(--t-panel) var(--settle) both; }
.pb.lens-in .trend-line, .pb.lens-in .micro { animation: fadeIn var(--t-med) var(--ease-std) both; }
.tlast { display: flex; flex-direction: column; align-items: flex-end; line-height: 1.2; }
.tlast b { font-size: var(--t-md); font-weight: 600; }
.tlast small { font-size: var(--t-xs); color: var(--ink-3); white-space: nowrap; }
.tlast.bad small { color: var(--neg-text); font-weight: 500; }
.tlast.good small { color: var(--pos-text); font-weight: 500; }
.tlast small::before { margin-right: 3px; }
.tlast.rise small::before { content: "↑"; }
.tlast.fall small::before { content: "↓"; }

.sev { display: inline-flex; gap: 2px; }
.sev i { width: 6px; height: 12px; border-radius: 2px; background: color-mix(in srgb, var(--ink) 10%, transparent); }
.sev i.on { background: var(--neg); }
.sev.med i.on { background: var(--warn); }

/* ───────── Landscape ───────── */
.heat { display: grid; grid-template-columns: 34px repeat(24, minmax(0, 1fr)); gap: 3px; align-items: center; }
.heat .hl { font-size: 10.5px; color: var(--ink-3); font-variant-numeric: tabular-nums; }
.heat .hx { font-size: 10px; color: var(--ink-3); text-align: center; font-variant-numeric: tabular-nums; }
.heat .cell { aspect-ratio: 1 / 1; border-radius: 4px; background: var(--seq-0); transition: transform var(--t-med) var(--spring), box-shadow var(--t-fast) var(--ease-std); min-height: 8px; }
.heat .cell:hover { transform: scale(1.35); box-shadow: 0 0 0 2px var(--surface); position: relative; z-index: 2; }
.seq-legend { display: flex; align-items: center; gap: 8px; font-size: var(--t-xs); color: var(--ink-3); }
.seq-legend .ramp { display: flex; gap: 2px; }
.seq-legend .ramp i { width: 18px; height: 8px; border-radius: 2px; }

.callout, .x-callout {
  display: flex; gap: 12px; align-items: flex-start;
  padding: 12px 14px; border-radius: var(--r-md);
  background: var(--surface-2); border: 1px solid var(--line);
  font-size: var(--t-sm); color: var(--ink-2);
}
.callout .ico, .x-callout .ico { color: var(--c1); margin-top: 2px; }
.callout b, .x-callout b { color: var(--ink); font-weight: 600; }
.callout.warn, .x-callout.warn { background: var(--warn-soft); border-color: transparent; color: var(--ink); }
.callout.warn .ico, .x-callout.warn .ico { color: var(--warn-text); }
.callout.err, .x-callout.err { background: var(--neg-soft); border-color: transparent; color: var(--ink); }
.callout.err .ico, .x-callout.err .ico { color: var(--neg-text); }

/* ───────── Digest ───────── */
.digest { max-width: 760px; margin: 0 auto; }
.digest-paper { padding: 40px 44px; border-radius: var(--r-xl); }
.digest-paper h2 { margin: 6px 0 4px; font-family: var(--f-display); font-variation-settings: "SOFT" 100, "opsz" 96; font-weight: 400; font-size: 2.5rem; letter-spacing: -0.03em; line-height: 1.05; text-wrap: balance; }
.digest-paper h3 { margin: 30px 0 8px; font-size: var(--t-md); font-weight: 600; letter-spacing: -0.01em; }
.digest-paper p, .digest-paper li { font-size: 1rem; line-height: 1.7; color: var(--ink-2); max-width: 64ch; text-wrap: pretty; }
.digest-paper ul { padding-left: 1.1em; }
.digest-paper li::marker { color: var(--brand); }
.digest-paper strong { color: var(--ink); font-weight: 600; }
.digest-stats, .x-digest-stats { margin: 22px 0 6px; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
.digest-stats .meta-cell .v, .x-digest-stats .x-meta-cell .v { font-size: var(--t-lg); letter-spacing: -0.02em; }
.archive { display: flex; flex-direction: column; gap: 4px; }
.archive button { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 10px 12px; border-radius: var(--r-sm); font-size: var(--t-sm); text-align: left; width: 100%; transition: background-color var(--t-fast) var(--ease-std), --sl var(--t-fast) var(--ease-std); }
.archive button[aria-current="true"] { background-color: var(--surface-2); }
.archive span { color: var(--ink-3); font-size: var(--t-xs); }

/* ───────── Settings / coverage ───────── */
.src-row { display: grid; grid-template-columns: 34px minmax(0, 1.9fr) minmax(0, 1fr) minmax(0, 0.8fr) 88px; /* fixed status column: a wider pill (PAUSED) no longer pulls the Method/Account and Last success columns out of line */  gap: 14px; align-items: center; padding: 12px 0; border-top: 1px solid var(--line); }
.src-row:first-child { border-top: 0; }
.src-row > .status { justify-self: end; }
.src-row b { font-size: var(--t-sm); font-weight: 600; display: block; }
.src-row span { font-size: var(--t-xs); color: var(--ink-3); }
.status { display: inline-flex; align-items: center; gap: 6px; font-size: var(--t-xs); font-weight: 600; white-space: nowrap; }
.status.tag i { width: 6px; height: 6px; }
.status i { width: 7px; height: 7px; border-radius: 50%; }
.status.ok { color: var(--pos-text); } .status.ok i { background: var(--pos); }
.status.warn { color: var(--warn-text); } .status.warn i { background: var(--warn); }
.status.down { color: var(--neg-text); } .status.down i { background: var(--neg); }

/* ───────── States ───────── */
.skel { position: relative; overflow: hidden; background: color-mix(in srgb, var(--ink) 6%, transparent); border-radius: var(--r-sm); }
.skel::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(90deg, transparent, color-mix(in srgb, var(--surface) 65%, transparent), transparent);
  transform: translateX(-100%);
  animation: shimmer 1.3s var(--ease-in-out) infinite;
}
@keyframes shimmer { to { transform: translateX(100%); } }
.skel-line { height: 12px; margin-top: 10px; }
.skel-block { height: 220px; margin-top: 8px; border-radius: var(--r-md); }

.empty {
  display: flex; flex-direction: column; align-items: center; text-align: center; gap: 10px;
  padding: 48px 20px;
}
.empty h4 { margin: 8px 0 0; font-size: var(--t-lg); font-weight: 600; letter-spacing: -0.015em; }
.empty p { margin: 0; color: var(--ink-2); max-width: 44ch; text-wrap: pretty; }
.empty .stones { width: 120px; height: 90px; }
.empty .stones .st { animation: settle var(--t-draw) var(--settle) both; transform-box: fill-box; transform-origin: center bottom; }
.empty .stones .st:nth-child(2) { animation-delay: calc(var(--stagger) * 2); }
.empty .stones .st:nth-child(3) { animation-delay: calc(var(--stagger) * 4); }
@keyframes settle { from { transform: translateY(-28px) rotate(-8deg); opacity: 0; } to { transform: none; opacity: 1; } }

.banner {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 10px 14px; margin-bottom: var(--gap);
  border-radius: var(--r-md);
  font-size: var(--t-sm);
  animation: rise var(--t-reveal) var(--ease-out) backwards;
}
.banner.warn { background: var(--warn-soft); color: var(--ink); }
.banner.warn .ico { color: var(--warn-text); }
.banner.err { background: var(--neg-soft); color: var(--ink); }
.banner.err .ico { color: var(--neg-text); }
.banner .text-btn { margin-left: auto; }

/* ───────── Overlays ───────── */
.scrim {
  position: fixed; inset: 0; z-index: 40;
  background: color-mix(in srgb, #02100A 34%, transparent);
  opacity: 0; pointer-events: none;
  transition: opacity var(--t-med) var(--ease-out);
}
.scrim.show { opacity: 1; pointer-events: auto; }

.drawer {
  position: fixed; z-index: 41;
  top: 10px; right: 10px; bottom: 10px;
  width: min(480px, calc(100vw - 20px));
  display: flex; flex-direction: column;
  border-radius: var(--r-xl);
  background: var(--surface);
  border: 1px solid var(--line-2);
  box-shadow: var(--shadow-3);
  transform: translate3d(calc(100% + 24px), 0, 0);
  transition: transform var(--t-exit) var(--settle), visibility 0s linear var(--t-exit);
  overflow: hidden;
  visibility: hidden;
}
.drawer.show { transform: none; visibility: visible; transition: transform var(--t-panel) var(--settle), visibility 0s; }
.drawer-head { display: flex; align-items: center; gap: 12px; padding: 16px 16px 12px 20px; border-bottom: 1px solid var(--line); }
.drawer-head h3 { margin: 0; font-size: var(--t-md); font-weight: 600; flex: 1; min-width: 0; letter-spacing: -0.01em; }
.drawer-body { flex: 1; overflow: auto; padding: 18px 20px 24px; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; }
.drawer-grip { display: none; }

.palette {
  position: fixed; z-index: 60;
  left: 50%; top: 12vh;
  width: min(620px, calc(100vw - 24px));
  border-radius: var(--r-lg);
  background: var(--glass-strong);
  -webkit-backdrop-filter: var(--glass-blur-strong);
  backdrop-filter: var(--glass-blur-strong);
  border: 1px solid var(--line-2);
  box-shadow: var(--shadow-3);
  transform: translate3d(-50%, -8px, 0) scale(0.97);
  opacity: 0; pointer-events: none;
  transition: opacity var(--t-exit) var(--ease-out), transform var(--t-exit) var(--settle);
  overflow: hidden;
}
/* Open: the glass layer is at full opacity from the first frame (so the blur is complete and no sharp page text shows through a
   half-transparent pane); it unrolls downward from the search bar with a clip, and its contents surface 40 ms later (follow-through).
   Close: the whole pane fades. */
.palette.show { opacity: 1; transform: translate3d(-50%, 0, 0) scale(1); pointer-events: auto; transition: opacity 0s, transform var(--t-panel) var(--settle); animation: paletteUnroll var(--t-panel) var(--settle) backwards; }
.palette.show > * { animation: paletteContent var(--t-med) var(--ease-std) 40ms backwards; }
@keyframes paletteUnroll { from { clip-path: inset(-40px -40px calc(100% - 58px) -40px round var(--r-lg)); } to { clip-path: inset(-40px -40px -80px -40px round var(--r-lg)); } }
@keyframes paletteContent { from { opacity: 0; } to { opacity: 1; } }
.palette-input { display: flex; align-items: center; gap: 12px; padding: 0 18px; height: 58px; border-bottom: 1px solid var(--line); }
.palette-input input { flex: 1; border: 0; outline: 0; background: transparent; font-size: var(--t-md); color: var(--ink); min-width: 0; }
.palette-input input::placeholder { color: var(--ink-3); }
.palette-list { max-height: min(420px, 60vh); overflow: auto; padding: 8px; }
.palette-group { padding: 8px 10px 4px; }
.palette-item {
  display: flex; align-items: center; gap: 12px;
  width: 100%; text-align: left;
  padding: 10px 12px; border-radius: var(--r-sm);
  font-size: var(--t-sm); color: var(--ink-2);
  transition: color var(--t-fast) var(--ease-std), --sl var(--t-fast) var(--ease-std);
}
.palette-item .ico { color: var(--ink-3); }
.palette-item small { margin-left: auto; color: var(--ink-3); font-size: var(--t-xs); }
.palette-item[aria-selected="true"] { color: var(--ink); }
.palette-item[aria-selected="true"] .ico { color: var(--brand); }
.palette-answer { margin: 4px 8px 10px; padding: 14px; border-radius: var(--r-md); background: var(--violet-soft); font-size: var(--t-sm); color: var(--ink); line-height: 1.55; }
.palette-answer .micro { display: flex; align-items: center; gap: 6px; margin-bottom: 6px; color: color-mix(in srgb, var(--c1) 80%, var(--ink)); }
.palette-foot { display: flex; gap: 14px; padding: 10px 16px; border-top: 1px solid var(--line); font-size: var(--t-xs); color: var(--ink-3); flex-wrap: wrap; }
.palette-cancel { display: none; flex: none; height: 44px; padding: 0 10px; margin: 0 -10px 0 0; }
/* Touch-only devices (no mouse or trackpad at all) have no keys to press: key hints (.key-hint: the Ctrl K chip, Esc, the palette's
   arrow and Enter tips) go, aria-keyshortcuts stay for assistive tech, and the palette gets a Cancel button where Esc was.
   A touch laptop or a tablet with a trackpad has a pointer that hovers, so it keeps them. */
@media (any-hover: none) and (any-pointer: coarse) {
  .key-hint { display: none; }
  .palette-cancel { display: inline-flex; }
}

/* Toasts: one morphing pill */
.toasts { position: fixed; z-index: 80; left: 50%; bottom: 24px; transform: translateX(-50%); display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none; width: max-content; max-width: calc(100vw - 24px); }
.toast, .x-toast {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 10px 10px 16px; min-height: 44px;
  border-radius: var(--r-pill);
  background: #0B1E17; color: #EAF2EC;
  box-shadow: 0 16px 40px -16px rgba(0, 0, 0, 0.5), 0 0 0 1px rgba(255,255,255,0.06) inset;
  font-size: var(--t-sm); font-weight: 500;
  pointer-events: auto;
  animation: land var(--t-reveal) var(--settle) both;
}
.toast.out, .x-toast.out { animation: toastOut var(--t-med) var(--ease-in) forwards; }
.toast .ico, .x-toast .ico { color: #3DD39A; }
.toast button, .x-toast button { color: #9FE8C8; font-weight: 600; padding: 6px 10px; border-radius: var(--r-pill); }
.toast button:hover, .x-toast button:hover { background: rgba(255, 255, 255, 0.08); }
.toast .toast-btn-ghost, .x-toast .toast-btn-ghost { color: #9FE8C8; font-weight: 600; padding: 6px 10px; }
/* land: drops in and touches down with a 1 px give; no spring (the toast was not touched) */
@keyframes land { 0% { opacity: 0; transform: translate3d(0, -6px, 0); } 60% { opacity: 1; transform: translate3d(0, 1px, 0); } 100% { opacity: 1; transform: none; } }
@keyframes toastOut { to { opacity: 0; transform: translate3d(0, 4px, 0); } }

.mobile-period { display: none !important; margin-bottom: 14px; }

/* Mobile tab bar + more panel */
.tabbar { display: none; }
.more-panel { display: none; }

/* Tablet: icon rail */
@media (max-width: 1279px) {
  :root { --sidebar-w: 76px; --gutter: 24px; }
  .sidebar { padding: 18px 12px 12px; align-items: stretch; }
  .brand { justify-content: center; padding: 4px 0 18px; }
  .brand-text, .nav-label, .nav-item .label, .nav-badge, .health-text, .me-text { display: none; }
  .nav-item { justify-content: center; padding: 0; height: 44px; }
  .nav-pill { height: 44px; }
  .nav-item .badge-dot { position: absolute; top: 9px; right: 14px; width: 7px; height: 7px; border-radius: 50%; background: var(--neg); box-shadow: 0 0 0 2px var(--bg); }
  .nav-sep { height: 1px; background: var(--line); margin: 10px 8px; }
  .health { justify-content: center; padding: 10px 0; }
  .health-dots { width: 30px; }
  .me { justify-content: center; padding: 6px 0; }
  .search-btn { min-width: 0; width: 38px; padding: 0; justify-content: center; }
  .search-btn .label, .search-btn .kbd-group, .search-btn .label-short { display: none; }
  .span-8, .span-7 { grid-column: span 12; }
  .span-5, .span-4 { grid-column: span 6; }
  .layers .span-4 { grid-column: span 4; }
}
@media (min-width: 1280px) {
  .nav-item .badge-dot, .nav-sep { display: none; }
}

@media (max-width: 1023px) {
  .split { grid-template-columns: minmax(0, 1fr); }
  .split .detail { display: none; }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .span-6 { grid-column: span 12; }
  .layers .span-4 { grid-column: span 12; }
  .layers { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .layers > .span-4 { grid-column: span 1; }
  .refresh .label { display: none; }
}

/* Phone */
@media (max-width: 767px) {
  :root { --gutter: 16px; --pad: 16px; --gap: 12px; --topbar-h: 56px; }
  .app { grid-template-columns: minmax(0, 1fr); }
  .sidebar { display: none; }
  .topbar { gap: 8px; padding-top: env(safe-area-inset-top, 0px); height: calc(var(--topbar-h) + env(safe-area-inset-top, 0px)); }
  .topbar-mobile-brand { display: flex; align-items: center; gap: 8px; }
  .topbar-mobile-brand .brand-mark { width: 28px; height: 28px; }
  .topbar-title span { display: none; }
  .topbar .seg, .refresh, .topbar .theme-btn { display: none; }
  .view { padding-bottom: calc(110px + env(safe-area-inset-bottom, 0px)); }
  .page-head { padding: 10px 0 16px; }
  .page-head h2 { font-size: 1.75rem; }
  .mobile-period { display: flex !important; }
  .mobile-period > button { flex: 1 1 0; justify-content: center; } /* three equal segments across the full width */
  /* Topics lens on phone: same full-width, three equal segments as the period control above it; note and button line up left under it */
  .toolbar [data-seg="themeLens"] { display: flex; width: 100%; flex: 1 1 100%; }
  .toolbar [data-seg="themeLens"] > button { flex: 1 1 0; justify-content: center; }
  .toolbar:has([data-seg="themeLens"]) { flex-direction: column; align-items: flex-start; }
  .toolbar:has([data-seg="themeLens"]) .grow { display: none; }
  .seg[data-seg="providerTab"] { display: flex; width: 100%; }
  .seg[data-seg="providerTab"] > button { flex: 1 1 0; justify-content: center; }
  .span-8, .span-7, .span-6, .span-5, .span-4, .span-3 { grid-column: span 12; }
  .layers { display: flex; overflow-x: auto; scroll-snap-type: x mandatory; gap: 10px; margin: 0 calc(var(--gutter) * -1); padding: 2px var(--gutter) 6px; scrollbar-width: none; }
  .layers::-webkit-scrollbar { display: none; }
  .layers > .card { flex: 0 0 82%; scroll-snap-align: start; }
  .hero { padding: 20px 18px 18px; border-radius: var(--r-lg); min-height: 0; }
  .hero::after { background: linear-gradient(180deg, color-mix(in srgb, var(--surface) 92%, transparent), color-mix(in srgb, var(--surface) 70%, transparent)); }
  .hero-metrics { grid-template-columns: minmax(0, 1fr); gap: 18px; margin-top: 20px; }
  .hero-num .big { font-size: 3rem; }
  .hero-foot { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px 20px; }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .kpi { padding: 14px; }
  .kpi .v { font-size: 1.5rem; }
  .bilingual { grid-template-columns: minmax(0, 1fr); }
  .cq { grid-template-columns: minmax(0, 1fr); }
  .div-head, .div-row { grid-template-columns: minmax(92px, 1fr) minmax(0, 1.6fr) 44px; gap: 10px; }
  .ptable-wrap { display: none; }
  .pcards { display: flex; }
  .src-row { grid-template-columns: 34px minmax(0, 1fr) 88px; }
  .src-row .hide-sm { display: none; }
  .filters { top: calc(var(--topbar-h) + env(safe-area-inset-top, 0px) + 6px); flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; margin-left: calc(var(--gutter) * -1); margin-right: calc(var(--gutter) * -1); border-radius: 0; border-left: 0; border-right: 0; padding: 8px var(--gutter); }
  .filters::-webkit-scrollbar { display: none; }
  .filters .field { flex: none; }
  .field input { width: 140px; }
  .result-count { display: none; }
  .digest-paper { padding: 26px 20px; }
  .digest-paper h2 { font-size: 2rem; }
  .digest-stats, .x-digest-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .heat { grid-template-columns: 28px repeat(24, minmax(0, 1fr)); gap: 2px; }
  .heat .hx:nth-child(odd) { visibility: hidden; }
  .theme-head, .theme-row { grid-template-columns: 20px minmax(0, 1fr) 52px 76px; gap: 8px; }
  .theme-row .tspark svg { width: 52px; height: 22px; }
  .tlast small { white-space: normal; text-align: right; line-height: 1.25; }
  .theme-row .pw { display: none; }
  .theme-head { display: flex; justify-content: space-between; padding-left: 47px; }
  .theme-head span:first-child { display: none; }

  .drawer {
    top: auto; left: 0; right: 0; bottom: 0;
    width: 100%; max-height: 92dvh; max-height: 92vh;
    border-radius: var(--r-xl) var(--r-xl) 0 0;
    border-bottom: 0;
    transform: translate3d(0, 105%, 0);
    padding-bottom: env(safe-area-inset-bottom, 0px);
  }
  @supports (max-height: 92dvh) { .drawer { max-height: 92dvh; } }
  .drawer.dragging { transition: none; }
  .drawer-grip { display: block; width: 40px; height: 5px; border-radius: 3px; background: var(--line-2); margin: 8px auto 0; flex: none; }
  .drawer-head { padding: 10px 14px 12px 18px; touch-action: none; }

  .tabbar {
    display: flex;
    position: fixed; z-index: 30;
    left: 50%; bottom: calc(12px + env(safe-area-inset-bottom, 0px));
    transform: translateX(-50%);
    width: min(440px, calc(100vw - 24px));
    padding: 6px;
    border-radius: 26px;
    background: var(--glass-strong);
    -webkit-backdrop-filter: var(--glass-blur);
    backdrop-filter: var(--glass-blur);
    border: 1px solid var(--line-2);
    box-shadow: var(--shadow-3);
    transition: border-radius var(--t-slow) var(--settle);
  }
  .tab {
    position: relative; z-index: 1;
    flex: 1; min-width: 0;
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
    height: 54px; border-radius: 20px;
    font-size: 10.5px; font-weight: 500; color: var(--ink-3);
    transition: color var(--t-med) var(--ease-std);
  }
  .tab .ico { width: 21px; height: 21px; transition: transform var(--t-med) var(--spring); }
  .tab.pressing .ico { transform: scale(0.86); }
  @media (hover: hover) { .tab:active .ico { transform: scale(0.86); } }
  .tab[aria-current="page"] { color: var(--ink); }
  .tab[aria-current="page"] .ico { color: var(--brand); }
  .tab .tdot { position: absolute; top: 8px; left: calc(50% + 7px); width: 7px; height: 7px; border-radius: 50%; background: var(--neg); box-shadow: 0 0 0 2px var(--surface); }
  .tab-thumb {
    position: absolute; z-index: 0; top: 6px; left: 0; height: 54px;
    border-radius: 20px;
    background: color-mix(in srgb, var(--ink) 6.5%, transparent);
    transition: opacity var(--t-fast) var(--ease-std); /* travel: moveThumb in app.js */
  }
  .more-panel {
    display: block;
    position: fixed; z-index: 31;
    left: 50%; bottom: calc(84px + env(safe-area-inset-bottom, 0px));
    width: min(440px, calc(100vw - 24px));
    padding: 8px;
    border-radius: 24px;
    background: var(--glass-strong);
    -webkit-backdrop-filter: var(--glass-blur-strong);
    backdrop-filter: var(--glass-blur-strong);
    border: 1px solid var(--line-2);
    box-shadow: var(--shadow-3);
    /* container morph: the panel grows out of the More tab (origin sits on the tab), contents blur in while it grows */
    transform-origin: 90% calc(100% + 39px);
    transform: translate3d(-50%, 0, 0) scale(0.2);
    opacity: 0; pointer-events: none; visibility: hidden;
    transition: transform var(--t-exit) var(--ease-out), opacity var(--t-exit) var(--ease-out), visibility 0s linear var(--t-exit);
  }
  .more-panel > * { opacity: 0; filter: blur(8px); transition: opacity var(--t-instant) var(--ease-out), filter var(--t-instant) var(--ease-out); }
  .more-panel.show { transform: translate3d(-50%, 0, 0) scale(1); opacity: 1; pointer-events: auto; visibility: visible; transition: transform var(--t-med) var(--ease-out), opacity var(--t-instant) var(--ease-out), visibility 0s; }
  .more-panel.show > * { opacity: 1; filter: none; transition: opacity var(--t-instant) var(--ease-out) 70ms, filter var(--t-fast) var(--ease-out) 70ms; /* follow-through: contents 70 ms behind the panel */ }
  .more-panel .nav-item { justify-content: flex-start; padding: 0 14px; height: 50px; border-radius: 16px; font-size: var(--t-base); }
  .more-panel .nav-item .label { display: inline; }
  .more-panel .nav-item .nav-badge { display: inline-grid; }
  .more-panel .more-row { display: flex; gap: 8px; padding: 8px 6px 4px; border-top: 1px solid var(--line); margin-top: 6px; align-items: center; justify-content: space-between; }
  .toasts { bottom: calc(96px + env(safe-area-inset-bottom, 0px)); }
}

/* Desktop nav labels visible */
@media (min-width: 1280px) {
  .nav-item .label { display: inline; }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 1ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 1ms !important;
    scroll-behavior: auto !important;
  }
  .live-dot::after { display: none; }
}

/* Forced colors */
@media (forced-colors: active) {
  .share-bar span, .div-track span, .hbar .track span { forced-color-adjust: none; }
  .card, .task, .mention, .x-mention { border: 1px solid CanvasText; }
}

/* Thin scrollbars */
* { scrollbar-width: thin; scrollbar-color: var(--line-2) transparent; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--line-2); border-radius: 10px; border: 3px solid transparent; background-clip: content-box; }
::-webkit-scrollbar-track { background: transparent; }

/* ═══════════ v2: app screens that fit the window ═══════════ */
:root { --hero-glow: 0.55; --ripple-gain: 1.45; --hero-light: radial-gradient(62% 90% at 84% 8%, color-mix(in srgb, var(--brand) 17%, transparent), transparent 72%), radial-gradient(48% 70% at 98% 92%, color-mix(in srgb, var(--sun) 14%, transparent), transparent 74%); }
:root[data-theme="dark"] { --hero-glow: 1; --ripple-gain: 1; --hero-light: none; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) { --hero-glow: 1; --ripple-gain: 1; --hero-light: none; } }

.toolbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; min-height: 44px; min-width: 0; }
.toolbar .grow { flex: 1 1 auto; }
.toolbar-note { font-size: var(--t-sm); color: var(--ink-3); min-width: 0; }
.screen { display: grid; gap: var(--gap); min-width: 0; padding-top: 4px; }
.screen > * { min-width: 0; }
.card-scroll {
  flex: 1 1 auto; min-height: 0; overflow: auto;
  margin: 0 calc(var(--pad) * -1); padding: 2px var(--pad) 12px;
  scrollbar-gutter: stable;
}
/* Edge fade: classes from app.js (edgeFade) mark the sides that still have content beyond them */
@property --fade-t { syntax: "<length>"; inherits: false; initial-value: 0px; }
@property --fade-b { syntax: "<length>"; inherits: false; initial-value: 0px; }
@property --fade-l { syntax: "<length>"; inherits: false; initial-value: 0px; }
@property --fade-r { syntax: "<length>"; inherits: false; initial-value: 0px; }
.fade-t, .fade-b, .fade-l, .fade-r {
  --edge-mask: linear-gradient(180deg, transparent, #000 var(--fade-t), #000 calc(100% - var(--fade-b)), transparent), linear-gradient(90deg, transparent, #000 var(--fade-l), #000 calc(100% - var(--fade-r)), transparent);
  -webkit-mask-image: var(--edge-mask); mask-image: var(--edge-mask);
  -webkit-mask-composite: source-in; mask-composite: intersect;
  transition: --fade-t var(--t-med) var(--ease-std), --fade-b var(--t-med) var(--ease-std), --fade-l var(--t-med) var(--ease-std), --fade-r var(--t-med) var(--ease-std);
}
.fade-t { --fade-t: 22px; } .fade-b { --fade-b: 22px; } .fade-l { --fade-l: 24px; } .fade-r { --fade-r: 24px; }
.pane { min-width: 0; min-height: 0; }
.pane-scroll { overflow: auto; padding: 2px 4px 16px 2px; margin: -2px -4px 0 -2px; }

.stats { display: flex; gap: 10px 28px; flex-wrap: wrap; align-items: flex-end; }
.stat, .x-stat { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.stat .k, .x-stat .k { font-size: var(--t-xs); color: var(--ink-3); display: flex; align-items: center; gap: 5px; white-space: nowrap; }
.stat .v, .x-stat .v { font-size: var(--t-lg); font-weight: 600; letter-spacing: -0.02em; line-height: 1.2; display: flex; align-items: baseline; gap: 6px; white-space: nowrap; }
.stat .v small, .x-stat .v small { font-size: 0.62em; color: var(--ink-3); font-weight: 500; letter-spacing: 0; }
.stat.alert .v, .x-stat.alert .v { color: var(--neg-text); }

/* Today */
.today {
  grid-template-columns: minmax(0, 1fr) minmax(300px, 372px);
  grid-template-areas: "hero rail" "insight rail";
  align-items: stretch;
}
.today > .hero { grid-area: hero; }
.today > .rail { grid-area: rail; display: flex; flex-direction: column; gap: var(--gap); min-width: 0; min-height: 0; }
.today > .insight { grid-area: insight; }
.rail > .needs { flex: 0 1 auto; min-height: 0; }
.rail > .why { flex: 1 1 auto; min-height: 0; }
.insight .chart-area { position: relative; display: flex; flex-direction: column; min-height: 360px; flex: 1 1 auto; }
.insight .chart-area > .chart { flex: 1 1 auto; min-height: 0; }
.insight .tab-pane { display: flex; flex-direction: column; flex: 1 1 auto; min-height: 0; }
/* The soft blur surfaces the pane only when the screen is entered; period changes and tab/table swaps do not re-blur it */
.view.on-enter .insight :not(.swap-in) > .tab-pane { animation: paneIn var(--t-enter) var(--ease-out) backwards; }
@keyframes paneIn { from { opacity: 0; transform: translate3d(0, 6px, 0); filter: blur(6px); } to { opacity: 1; transform: none; filter: none; } }
.insight .card-head { align-items: center; flex-wrap: wrap; }
/* Insight tools (app.js insightTools): inline from tablet up. On a phone the tabs keep the row and the tools fold
   behind one "more" button at its right end; the menu glides out of that button (MOTION.md glide, no overshoot). */
.tools-more { display: none; }
.tools-menu { display: contents; }
@media (max-width: 767px) {
  .insight .card-head { flex-wrap: nowrap; gap: 6px; }
  .insight .card-title { flex: 1 1 auto; }
  .insight .card-title .seg { max-width: 100%; overflow-x: auto; scrollbar-width: none; }
  .insight .card-title .seg::-webkit-scrollbar { display: none; }
  .insight .card-title .seg button { flex: 1 1 0; padding: 0 11px; } /* equal tabs; the pill ends at the "more" button; a label wider than its share keeps its width and the pill scrolls */
  .insight .card-tools { position: relative; margin-right: -14.5px; } /* the right dot sits on the content edge (44 px target, 15 px glyph); the target reaches into the padding */
  /* the page scrolls on a phone, not these boxes: no gutter for a scrollbar that never comes, so lists end on the same edge as their card head */
  .card-scroll { scrollbar-gutter: auto; }
  .tools-more { display: grid; width: 44px; height: 44px; }
  .tools-menu {
    display: flex; flex-direction: column;
    position: absolute; z-index: 6; top: calc(100% + 4px); right: 4px;
    min-width: 220px; padding: 6px;
    border-radius: var(--r-md);
    background: var(--glass-strong);
    -webkit-backdrop-filter: var(--glass-blur);
    backdrop-filter: var(--glass-blur);
    border: 1px solid var(--line-2);
    box-shadow: var(--shadow-2);
    transform-origin: calc(100% - 18px) -8px;
    transform: translate3d(0, -4px, 0) scale(0.94);
    opacity: 0; visibility: hidden; pointer-events: none;
    transition: transform var(--t-exit) var(--ease-out), opacity var(--t-instant) var(--ease-std), visibility 0s linear var(--t-exit);
  }
  .card-tools.open .tools-menu { transform: none; opacity: 1; visibility: visible; pointer-events: auto; transition: transform var(--t-panel) var(--ease-out), opacity var(--t-instant) var(--ease-out), visibility 0s; }
  .card-tools.open .tools-more { background: color-mix(in srgb, var(--ink) 6%, transparent); color: var(--ink); }
  .insight .card-tools .tools-menu > button {
    display: flex; align-items: center; justify-content: flex-start; gap: 12px;
    width: 100%; height: 44px; padding: 0 12px;
    border: 0; border-radius: calc(var(--r-md) - 6px); background: transparent; box-shadow: none;
    font-size: var(--t-sm); font-weight: 500; color: var(--ink); white-space: nowrap;
  }
  .insight .card-tools .tools-menu > button:active { background: color-mix(in srgb, var(--ink) 6%, transparent); transform: none; }
  .tools-menu > button .ico { width: 16px; height: 16px; flex: none; color: var(--ink-2); }
  .tools-menu .mark-btn .ico { color: var(--violet); }
  .insight .tools-menu .mark-btn-l { display: inline; }
  .tools-menu .hint::after { content: "How to read this chart"; }
  .tools-menu [data-action="table"]::after { content: attr(aria-label); }
}

/* Hero v2 */
.hero { min-height: 0; padding: 24px 26px 22px; background: var(--hero-light), var(--card-sheen), var(--surface); } /* light only: one soft light source behind the pond, the gradient itself is the blur */
.hero::before {
  content: ""; position: absolute; z-index: -1; pointer-events: none;
  right: -12%; bottom: -45%; width: 80%; height: 90%;
  background:
    radial-gradient(50% 50% at 45% 55%, color-mix(in srgb, var(--brand) 26%, transparent), transparent 70%),
    radial-gradient(40% 45% at 80% 35%, color-mix(in srgb, var(--violet) 22%, transparent), transparent 70%),
    radial-gradient(30% 35% at 20% 30%, color-mix(in srgb, var(--sun) 14%, transparent), transparent 70%);
  filter: blur(18px);
  opacity: var(--hero-glow);
}
.verdict { margin-top: 14px; max-width: 34ch; font-size: clamp(1.45rem, 0.95rem + 1.2vw, 2.05rem); }
.hero-metrics { margin-top: 18px; grid-template-columns: auto minmax(0, 1fr); gap: 26px; align-items: end; }
.share-meta { font-size: var(--t-xs); color: var(--ink-3); display: flex; flex-wrap: wrap; row-gap: 6px; }
.share-meta b { color: var(--ink-2); font-weight: 600; font-variant-numeric: tabular-nums; }
/* hairline stat strip: items split by 1px vertical lines, no gaps or boxes */
.share-meta > span { padding: 0 14px; border-left: 1px solid var(--line); }
.share-meta > span:first-child { padding-left: 0; border-left: 0; }
/* Hero stat area: the left block and the right block share three rows (figure / label+legend / delta+meta), and the legend and the meta row share
   one 3-column grid, so Positive sits above mentions, Neutral above could reach, Negative above left out. Hairlines sit on the column starts. */
@media (min-width: 1024px) {
  .hero-metrics { grid-template-rows: auto auto auto; row-gap: 8px; align-items: stretch; }
  .hero-num, .share { display: grid; grid-row: 1 / span 3; grid-template-rows: subgrid; gap: 0; row-gap: 8px; }
  .hero-num > :nth-child(1), .share-bar { align-self: end; }
  .hero-num > :nth-child(n+2), .share-legend, .share-meta { align-self: baseline; } /* label row and delta row share a baseline with the legend and the meta row */
}
/* The third column is a little wider: it holds Negative plus its delta, which must stay on one line */
.share-legend { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) minmax(0, 1.35fr); column-gap: 0; align-items: baseline; }
@media (min-width: 768px) { .share-meta { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) minmax(0, 1.35fr); column-gap: 0; align-items: baseline; } }
.share-legend > span { display: block; padding: 0 0 0 12px; white-space: nowrap; }
.share-legend .delta { font-size: var(--t-xs); margin-left: 6px; }
.share-legend > span:first-child { padding-left: 0; }
.share-legend .lg { display: inline; white-space: nowrap; }
.share-legend .lg .sent-dot { display: inline-block; vertical-align: 0.05em; margin-right: 7px; }
.share-legend .lg b { margin-left: 4px; }
.share-meta > span { padding: 0 0 0 12px; }
/* When the stat block is too narrow for the three aligned columns (hero beside the rail at about 1180-1440 px, ~360-450 px wide):
   each cell stays on one line with its delta and ⓘ, and cells wrap as a whole instead of the ⓘ dropping onto its own line */
.share { container: share / inline-size; }
@media (min-width: 768px) {
  @container share (max-width: 479px) {
    .share-legend, .share-meta { display: flex; flex-wrap: wrap; column-gap: 14px; row-gap: 4px; }
    .share-legend > span, .share-meta > span { white-space: nowrap; padding-left: 0; border-left: 0; }
  }
}
/* Phone: two clean stat rows of three equal columns with hairlines between them.
   Row A (sentiment): dot + label on top, value below, delta after the value. Row B (meta): value on top, label below. */
@media (max-width: 767px) {
  .share { gap: 14px; }
  /* the first column is a little wider: "1,284 mentions +25%" is the longest cell and must clear the divider (both rows keep the same columns so the dividers line up) */
  .share-legend, .share-meta { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1.05fr) minmax(0, 0.9fr); column-gap: 0; align-items: start; }
  .share-legend > span, .share-meta > span {
    display: grid; grid-template-columns: auto minmax(0, 1fr); align-items: baseline; justify-content: start;
    padding: 0 0 0 12px; border-left: 1px solid var(--line); white-space: nowrap; min-width: 0;
  }
  .share-legend > span:first-child, .share-meta > span:first-child { padding-left: 0; border-left: 0; }
  /* row A */
  .share-legend .lg { display: contents; }
  .share-legend .lg-l { grid-column: 1 / -1; grid-row: 1; font-size: var(--t-micro); color: var(--ink-3); font-weight: 500; }
  .share-legend .lg .sent-dot { margin-right: 6px; }
  .share-legend .lg b { grid-column: 1; grid-row: 2; margin: 1px 0 0; font-size: var(--t-base); letter-spacing: -0.01em; }
  .share-legend .delta { grid-column: 2; grid-row: 2; margin: 0 0 0 5px; }
  /* row B */
  .share-meta { padding-top: 14px; border-top: 1px solid var(--line); }
  .share-meta b { grid-column: 1 / -1; grid-row: 1; font-size: var(--t-base); color: var(--ink); letter-spacing: -0.01em; }
  .share-meta .m-l { grid-column: 1; grid-row: 2; margin-top: 1px; font-size: var(--t-micro); }
  .share-legend .delta, .share-meta .delta { font-size: var(--t-micro); }
  .share-legend .delta .ico, .share-meta .delta .ico { margin-right: 2px; }
  .share-meta .m-l .delta { margin-left: 3px; }
  .share-legend > span:first-child, .share-meta > span:first-child { padding-right: 8px; }
  .share-meta .m-l { white-space: normal; } /* on the narrowest phones the delta drops under its label instead of running into the next column */
  .share-meta .hint { grid-column: 2; grid-row: 2; margin-left: 4px; align-self: center; }
}
.layer-strip { margin-top: 20px; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; will-change: transform; }
.layer-strip.settling { transition: transform 900ms var(--ease-out); } /* settle-back, 900 ms */
.layer-tile {
  position: relative;
  display: flex; flex-direction: column; gap: 6px;
  padding: 12px 14px 12px;
  border-radius: var(--r-md);
  background: var(--glass);
  -webkit-backdrop-filter: var(--glass-blur);
  backdrop-filter: var(--glass-blur);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-1);
  text-align: left; min-width: 0;
  transition: transform var(--t-med) var(--ease-out), border-color var(--t-panel) var(--ease-std), box-shadow var(--t-med) var(--ease-std);
}
/* Link affordance: the chevron is the arrow chip (fades up, nudges 2px), the border darkens; no lift */
.layer-tile .lt-top .ico { opacity: 0.45; transition: opacity var(--t-panel) var(--ease-std), transform var(--t-panel) var(--ease-out), color var(--t-panel) var(--ease-std); }
@media (hover: hover) {
  .layer-tile:hover { border-color: color-mix(in srgb, var(--ink) 24%, transparent); }
  .layer-tile:hover .lt-top .ico { opacity: 1; transform: translateX(2px); color: var(--ink); }
  .layer-tile:active { transform: scale(0.985); }
}
.layer-tile.pressing { transform: scale(0.985); }
/* Touch screens: glass on content that scrolls is a denser fill, not a backdrop blur (re-blurred every frame of a scroll); the fixed bars keep theirs */
@media (pointer: coarse) { .layer-tile { -webkit-backdrop-filter: none; backdrop-filter: none; background: var(--glass-strong); } }
.lt-top { display: flex; align-items: center; gap: 8px; font-size: var(--t-xs); color: var(--ink-2); font-weight: 500; min-width: 0; }
.lt-top span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lt-dot { width: 8px; height: 8px; border-radius: 3px; flex: none; }
.lt-top .ico { margin-left: auto; color: var(--ink-3); flex: none; }
.lt-val { display: flex; align-items: flex-end; justify-content: space-between; gap: 8px; min-width: 0; }
.lt-val b { font-size: 1.4rem; font-weight: 600; letter-spacing: -0.03em; line-height: 1; white-space: nowrap; }
.lt-val b small { font-size: 0.5em; color: var(--ink-3); font-weight: 500; letter-spacing: 0; margin-left: 4px; }
.lt-val .spark { flex: none; }
.lt-note { font-size: var(--t-xs); color: var(--ink-3); line-height: 1.4; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; min-height: 2.8em; }

/* Needs you v2 */
.needs .card-head { margin-bottom: 10px; }
/* Empty "All clear": the card is capped at 62% of the rail, so the roomy default padding clipped the text; centre it in the space left */
.needs .empty {
  display: grid; grid-template-columns: auto minmax(0, 1fr); column-gap: 14px; row-gap: 2px;
  align-items: center; text-align: left; padding: 4px 0 2px; flex: none;
}
.rail > .needs:has(> .empty) { flex-shrink: 0; } /* compact enough to always show whole; Why it changed takes the rest */
.needs .empty .stones { grid-row: 1 / span 2; width: 64px; height: 48px; }
.needs .empty h4 { margin: 0; align-self: end; font-size: var(--t-md); }
.needs .empty p { align-self: start; font-size: var(--t-sm); }
/* Needs you, UX wave 1: a flat list of up to 3 one-line rows, no inner scroll, no cards inside the card; the card sizes to its content */
.rail > .needs { flex: 0 0 auto; align-self: start; width: 100%; }
.needs .task-list.flat { gap: 0; }
.needs .flat > li + li .task { border-top: 1px solid var(--line); }
.needs .flat .task { grid-template-columns: auto minmax(0, 1fr); align-items: start; gap: 10px; padding: 8px 4px; border: 0; border-radius: 0; background: none; }
.needs .flat .check { margin-top: 1px; }
.needs .flat .task.done { border-color: var(--line); }
/* title up to 2 lines, the source as a small line under it; the risk dot sits on the first line */
.needs .flat .t-open { display: grid; grid-template-columns: 8px minmax(0, 1fr); column-gap: 8px; row-gap: 1px; align-items: start; min-width: 0; min-height: 32px; width: 100%; text-align: left; }
.needs .flat .risk-dot { grid-column: 1; grid-row: 1; margin-top: 6px; }
.needs .flat .t-title { grid-column: 2; grid-row: 1; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden; min-width: 0; line-height: 1.35; }
.needs .flat .t-src { grid-column: 2; grid-row: 2; font-size: var(--t-xs); color: var(--ink-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.risk-dot { width: 8px; height: 8px; border-radius: 50%; flex: none; background: var(--neu); }
.risk-dot.high { background: var(--neg); }
.risk-dot.med { background: var(--warn); }
.needs-more { margin: 4px 0 0 32px; font-size: var(--t-xs); }
@media (max-width: 767px) { .needs .flat .t-open { min-height: 44px; } } /* touch target on phones */
.needs .card-foot { margin-top: 10px; }
.pebbles { display: inline-flex; align-items: flex-end; gap: 3px; height: 20px; }
.pebbles i {
  display: block; width: 15px; height: 11px;
  border-radius: 52% 48% 46% 54% / 62% 58% 42% 38%;
  background: color-mix(in srgb, var(--ink) 10%, transparent);
  transition: background-color var(--t-med) var(--ease-out);
}
.pebbles i:nth-child(2) { width: 13px; height: 10px; }
.pebbles i:nth-child(3) { width: 12px; height: 9px; }
.pebbles i:nth-child(4) { width: 10px; height: 8px; }
.pebbles i.on { background: var(--brand); }
.pebbles i.plop { animation: plop 420ms var(--settle) 130ms backwards; } /* story beat Done: the pebble drops in 130 ms in, as the row leaves, squash on impact */
@keyframes plop { /* waits as an empty slot, lifts a little, drops, squashes on impact, rests */
  0% { transform: none; background-color: color-mix(in srgb, var(--ink) 10%, transparent); }
  18% { transform: translateY(-10px) scale(0.85); background-color: var(--brand); }
  58% { transform: translateY(0) scale(1.15, 0.85); }
  100% { transform: none; }
}
.progress-label { font-size: var(--t-xs); color: var(--ink-3); font-variant-numeric: tabular-nums; white-space: nowrap; }
.task { grid-template-columns: auto minmax(0, 1fr); padding: 11px 12px; gap: 12px; }
.task .t-title { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.task .t-open { text-align: left; min-width: 0; display: block; width: 100%; }
.task .t-meta { margin-top: 5px; }
.task .t-meta span:last-child { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.needs .card-foot { gap: 10px; padding-top: 12px; }

/* Split screens */
.split-screen {
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.08fr);
  grid-template-areas: "bar bar" "a b";
  align-items: start;
}
.split-screen.wide-a { grid-template-columns: minmax(0, 1.55fr) minmax(300px, 1fr); }
.split-screen.narrow-b { grid-template-columns: minmax(0, 1fr) minmax(280px, 340px); }
.split-screen > .toolbar { grid-area: bar; }
.split-screen > .pa { grid-area: a; }
.split-screen > .pb { grid-area: b; }
.single-screen { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto auto; }
.bento { grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); grid-auto-rows: auto; }
.bento .chart.fill { min-height: 240px; }

.detail { position: static; max-height: none; overflow: visible; }
.filters { position: static; margin-bottom: 0; box-shadow: none; }
.x-ptable thead th { z-index: 2; } /* .ptable thead th: z 5, above rows in a sort (see the sort block) */

/* Fit mode: big enough screens behave like an app window, panes scroll inside */
@media (min-width: 1024px) and (min-height: 700px) {
  html, body { height: 100%; overflow: hidden; }
  .app { height: 100vh; height: 100dvh; min-height: 0; }
  .sidebar { height: 100%; }
  .main { height: 100vh; height: 100dvh; min-height: 0; }
  .view { flex: 1 1 auto; min-height: 0; overflow: auto; display: flex; flex-direction: column; padding-bottom: 20px; overscroll-behavior: contain; }
  /* Panes only hold their scroll here, where they have a height to scroll in. Below fit mode they grow with their content and the page scrolls:
     a contained pane that cannot scroll would swallow every swipe that starts on it (the page would not move). */
  .card-scroll, .pane-scroll { overscroll-behavior: contain; }
  .view > .screen { flex: 1 1 auto; min-height: 0; }
  .split-screen, .single-screen { grid-template-rows: auto minmax(0, 1fr); align-items: stretch; }
  .split-screen > .pa, .split-screen > .pb, .single-screen > .pa { min-height: 0; display: flex; flex-direction: column; }
  .split-screen > .pa.pane-scroll, .split-screen > .pb.pane-scroll { display: block; overflow: auto; }
  .bento { grid-template-rows: minmax(0, 1fr) minmax(0, 1fr); align-items: stretch; }
  .bento > .card { min-height: 0; }
  .bento .chart.fill { min-height: 0; flex: 1 1 auto; }
}
@media (min-width: 1180px) and (min-height: 700px) {
  .today { grid-template-rows: auto minmax(0, 1fr); }
  .today > .rail { contain: size; }
  .rail > .why { min-height: 180px; }
  .today > .insight { min-height: 0; }
  .insight .chart-area { min-height: 0; }
}
@media (min-width: 1180px) and (max-height: 780px) {
  .verdict { font-size: 1.3rem; max-width: 46ch; }
  .hero-num .big { font-size: 2.5rem; }
  .lt-val .spark { display: none; }
  .layer-tile { padding: 10px 12px; }
}
@media (min-width: 1180px) and (max-height: 860px) {
  .hero { padding: 20px 22px 18px; }
  .verdict { font-size: clamp(1.3rem, 0.9rem + 1vw, 1.75rem); margin-top: 10px; }
  .hero-metrics { margin-top: 14px; }
  .hero-num .big { font-size: 2.9rem; }
  .layer-strip { margin-top: 14px; }
  .lt-note { display: none; }
}
@media (max-width: 1179px) {
  .today { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); grid-template-areas: none; }
  .today > .rail { display: contents; }
  .today > .hero, .today > .insight, .rail > .needs, .rail > .why { grid-area: auto; }
  .today > .hero, .today > .insight { grid-column: 1 / -1; }
  .today > .hero { order: 1; } .rail > .needs { order: 2; } .rail > .why { order: 3; } .today > .insight { order: 4; }
  .split-screen.wide-a, .split-screen.narrow-b { grid-template-columns: minmax(0, 1fr) minmax(280px, 0.8fr); }
}
@media (max-width: 1023px) {
  .split-screen, .split-screen.wide-a, .split-screen.narrow-b { grid-template-columns: minmax(0, 1fr); grid-template-areas: "bar" "a" "b"; }
  .split-screen.hide-b-sm > .pb { display: none; }
  .bento { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 767px) {
  .hero-metrics { grid-template-columns: minmax(0, 1fr); gap: 16px; }
  /* Layer tiles: a snap carousel that bleeds to the hero card edges; the first tile sits on the content edge, the next one peeks deliberately */
  .layer-strip { --hero-pad: 18px; display: flex; overflow-x: auto; overscroll-behavior-x: contain; scroll-snap-type: x mandatory; scroll-padding-inline: var(--hero-pad); margin: 20px calc(var(--hero-pad) * -1) -10px; padding: 6px var(--hero-pad) 16px; gap: 10px; scrollbar-width: none; }
  .layer-strip::-webkit-scrollbar { display: none; }
  .layer-tile { flex: 0 0 78%; scroll-snap-align: start; }
  .lt-note { white-space: normal; }
  .insight .chart-area { min-height: 320px; }
  .toolbar { gap: 8px; }
  .toolbar .seg { max-width: 100%; overflow-x: auto; scrollbar-width: none; }
  .stats { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 16px; align-items: start; width: 100%; } /* two even columns, so labels and values line up in both rows */
  .stats .stat .v { flex-wrap: wrap; row-gap: 0; } /* "64 name Pebbles" drops under its number when the half column is too narrow (large text sizes) */
  .stats .stat .k, .stats .stat .v small { white-space: normal; }
  .filters { position: sticky; }
}

/* Ripple: the pebble drop, used as press feedback across the app */
.rp { position: absolute; inset: 0; border-radius: inherit; overflow: hidden; pointer-events: none; z-index: 0; }
.rp i {
  position: absolute; border-radius: 50%;
  box-shadow: inset 0 0 0 1.5px color-mix(in srgb, currentColor 30%, transparent);
  background: radial-gradient(circle, color-mix(in srgb, currentColor 9%, transparent) 0 55%, transparent 56%);
  transform: translate(-50%, -50%) scale(0.06);
  animation: rpl 450ms var(--ease-out) forwards; /* named effect: ripple, 450 ms */
}
@keyframes rpl { 70% { opacity: 0.9; } to { transform: translate(-50%, -50%) scale(1); opacity: 0; } }
.btn, .task, .theme-row, .div-row, .hbar, .assignee, .palette-item, .layer-tile, .alert-item, .pcard, .archive button, .x-alert-item, .x-pcard { position: relative; }

/* Live arrival */
.mention.arrived, .x-mention.arrived { animation: rise var(--t-reveal) var(--ease-out) backwards, arriveEdge 1400ms var(--ease-out) backwards; /* edge flash: one-off, 1.4 s */ }
@keyframes arriveEdge { from { border-color: color-mix(in srgb, var(--brand) 55%, transparent); } }
/* The slot opens (0fr to 1fr, 320 ms) while the row rises. margin-bottom cancels the list gap while it is closed. */
.slot { display: grid; grid-template-rows: 1fr; }
.slot > .slot-in { min-height: 0; overflow: hidden; }
.slot.opening { animation: slotOpen var(--t-slow) var(--ease-out) both; }
.slot.opened { display: contents; }
@keyframes slotOpen { from { grid-template-rows: 0fr; margin-bottom: -8px; } to { grid-template-rows: 1fr; margin-bottom: 0; } }

/* Value roll (period change): old value out up, new value in from below; the wrapper is removed when done */
.roll { position: relative; display: inline-block; clip-path: inset(-1px -4px); vertical-align: baseline; }
.roll::before { content: attr(data-old); position: absolute; left: 0; top: 0; white-space: nowrap; animation: rollOut var(--t-fast) var(--ease-out) var(--roll-delay, 0s) both; } /* the outgoing value is generated content: not in innerText */
.roll-new { display: inline-block; animation: rollIn var(--t-med) var(--ease-out) var(--roll-delay, 0s) both; /* no delay: the new value enters while the old one leaves (MW2) */ }
@keyframes rollOut { to { opacity: 0; transform: translate3d(0, -40%, 0); filter: blur(6px); } }
@keyframes rollIn { from { opacity: 0; transform: translate3d(0, 40%, 0); filter: blur(6px); } to { opacity: 1; transform: none; filter: none; } }

/* Task list changes: the row that leaves is a ghost (scale + fade 130 ms); siblings slide into the gap via JS (200 ms) */
.task-list { position: relative; isolation: isolate; }
.task-ghost { position: absolute; left: 0; right: 0; margin: 0; pointer-events: none; animation: rowOut var(--t-instant) var(--ease-out) both; }
@keyframes rowOut { to { opacity: 0; transform: scale(0.96); filter: blur(2px); } }

/* Tab content swap: old content fades out (100 ms) as a ghost, new content fades in (100 ms) */
/* ghost item classes are renamed x-<name> in JS (GHOST_ITEMS in app.js); every rule that styles one lists the x- twin next to the original */
.swap-ghost { position: absolute; z-index: 1; pointer-events: none; margin: 0; animation: swapOut var(--t-instant) var(--ease-std) both; }
.swap-ghost *, .swap-ghost *::before, .swap-ghost *::after { animation: none !important; }
.swap-ghost .draw { stroke-dashoffset: 0 !important; }
@keyframes swapOut { to { opacity: 0; } }
@keyframes swapIn { from { opacity: 0; } to { opacity: 1; } }
.swap-in .tab-pane, .swap-in .pane-scroll { animation: swapIn var(--t-instant) var(--ease-std) backwards; }
.swap-in .mention, .swap-in .x-mention { animation: none; }
/* MW3: the ghost keeps the class of the pane it copies (.pane-scroll, .tab-pane), so it must beat the swapIn rule above: it fades OUT */
.swap-in > .swap-ghost.swap-ghost { animation: swapOut var(--t-instant) var(--ease-std) both; }

/* MW3: new content of a swapped region fades in (100 ms) while the old one leaves as a ghost; same rule as .swap-in, for the regions of
   Providers, Digest, Themes and the table toggles (see SWAP_SEL in app.js) */
.swap-new { animation: swapIn var(--t-instant) var(--ease-std) backwards; }

/* Palette: results swap (old list leaves as a ghost over the list, 100 ms) and one indicator slides to the selected result (150 ms) */
.palette-list { position: relative; }
#palette > .pal-ghost { position: absolute; left: 0; right: 0; overflow: hidden; pointer-events: none; animation: swapOut var(--t-instant) var(--ease-std) both; }
.pal-swap > :not(.pal-ind) { animation: swapIn var(--t-instant) var(--ease-std) backwards; }
.pal-ind { position: absolute; left: 8px; right: 8px; top: 0; border-radius: var(--r-sm); background: color-mix(in srgb, var(--ink) 6%, transparent); pointer-events: none; transition: transform var(--t-fast) var(--settle), height var(--t-fast) var(--settle), opacity var(--t-fast) var(--ease-std); }
.palette-list.has-ind .palette-item[aria-selected="true"]:not(:active, .pressing) { --sl: 0%; }

/* Toast that is being replaced: out of the flow (the new toast does not move), centred where it was */
.toast.replaced, .x-toast.replaced { position: absolute; bottom: 0; left: 50%; translate: -50% 0; pointer-events: none; }

/* Disclosure (<details class="disclose">): height and chevron are driven from app.js; the chevron turns back as soon as it closes */
.disclose-body { overflow: hidden; }
.disclose.is-closing[open] summary .ico { transform: none; }

/* Push notification */
.push {
  position: fixed; z-index: 90;
  top: calc(14px + env(safe-area-inset-top, 0px)); right: 16px;
  width: min(380px, calc(100vw - 24px));
  display: grid; grid-template-columns: 40px minmax(0, 1fr) auto; gap: 12px; align-items: start;
  padding: 12px 12px 12px 14px;
  border-radius: 20px;
  background: var(--glass-strong);
  -webkit-backdrop-filter: var(--glass-blur-strong);
  backdrop-filter: var(--glass-blur-strong);
  border: 1px solid var(--line-2);
  box-shadow: var(--shadow-3);
  transform: translate3d(0, calc(-100% - 30px), 0);
  transition: transform var(--t-exit) var(--settle);
  cursor: pointer; text-align: left;
}
.push.show { transform: none; transition: transform var(--t-panel) var(--settle); }
.push .app-ic { width: 40px; height: 40px; border-radius: 11px; background: #08482F; display: grid; place-items: center; position: relative; }
.push .app-ic svg { width: 26px; height: 26px; }
.push .app-ic::after { content: ""; position: absolute; inset: -3px; border-radius: 14px; border: 2px solid var(--neg); opacity: 0; animation: ping 1.8s var(--ease-out) 3; }
.push b { display: block; font-size: var(--t-sm); font-weight: 600; color: var(--ink); line-height: 1.3; }
.push p { margin: 2px 0 0; font-size: var(--t-xs); color: var(--ink-2); line-height: 1.45; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.push .when { font-size: 10.5px; color: var(--ink-3); white-space: nowrap; }
@media (max-width: 767px) { .push { left: 50%; right: auto; margin-left: calc(min(380px, calc(100vw - 24px)) / -2); } }

/* Forms (insider report, notes) */
.form { display: flex; flex-direction: column; gap: 14px; }
.fl { display: flex; flex-direction: column; gap: 6px; font-size: var(--t-xs); color: var(--ink-2); font-weight: 500; }
.input, .textarea, .select-in {
  width: 100%; min-width: 0;
  border: 1px solid var(--line-2); background: var(--surface-2);
  border-radius: var(--r-sm); padding: 10px 12px;
  font-size: 16px; color: var(--ink); outline: 0;
  transition: border-color var(--t-fast) var(--ease-std), box-shadow var(--t-med) var(--ease-std);
  -webkit-appearance: none; appearance: none;
}
.input::placeholder, .textarea::placeholder { color: var(--ink-3); }
.input:focus, .textarea:focus, .select-in:focus { border-color: var(--focus); box-shadow: 0 0 0 3px color-mix(in srgb, var(--focus) 18%, transparent); }
.textarea { min-height: 92px; resize: vertical; line-height: 1.5; }
@media (min-width: 768px) { .input, .textarea, .select-in { font-size: var(--t-base); } }
.drop {
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  border: 1.5px dashed var(--line-2); border-radius: var(--r-md);
  padding: 18px; text-align: center; color: var(--ink-3); font-size: var(--t-sm);
  cursor: pointer; transition: border-color var(--t-fast) var(--ease-std), background-color var(--t-fast) var(--ease-std);
}
.drop:hover, .drop.over { border-color: var(--brand); background: color-mix(in srgb, var(--brand) 6%, transparent); color: var(--ink-2); }
.drop b { color: var(--ink); font-weight: 600; }
.checkline { display: flex; gap: 10px; align-items: flex-start; font-size: var(--t-sm); color: var(--ink-2); cursor: pointer; }
.checkline input { width: 18px; height: 18px; accent-color: var(--brand); margin: 2px 0 0; flex: none; }
.note-item { padding: 10px 12px; border-radius: var(--r-sm); background: var(--surface-2); border: 1px solid var(--line); font-size: var(--t-sm); display: flex; gap: 10px; align-items: flex-start; }
.note-item p { margin: 0; color: var(--ink-2); }
.note-item small { display: block; color: var(--ink-3); font-size: var(--t-xs); margin-bottom: 2px; }
.note-row { display: flex; gap: 8px; }
.note-row .input { flex: 1; }

/* State layer: one overlay for hover (6%) and press (10%) on clickable rows; replaces per-item background swaps.
   The layer is ink on light and near-white on dark (--ink flips with the theme). Hover and :active only where a hover device exists;
   a finger presses through .pressing (app.js), which waits until the touch rests and is taken back when it turns into a scroll. */
@property --sl { syntax: "<percentage>"; inherits: false; initial-value: 0%; }
.mention, .alert-item, .theme-row, .div-row, .pcard, .task, .why-item, .palette-item, .nav-item, .assignee, .hbar, .archive button, .x-mention, .x-alert-item, .x-pcard {
  background-image: linear-gradient(color-mix(in srgb, var(--ink) var(--sl), transparent), color-mix(in srgb, var(--ink) var(--sl), transparent));
}
@media (hover: hover) {
  .mention:hover, .alert-item:hover, .theme-row:hover, .div-row:hover, .pcard:hover, .task:hover, .why-item:hover, .nav-item:hover, .assignee:hover, .hbar:hover, .archive button:hover, .x-mention:hover, .x-alert-item:hover, .x-pcard:hover { --sl: 6%; }
}
.div-row:focus-visible, .hbar:focus-visible, .why-item.lit, .palette-item[aria-selected="true"] { --sl: 6%; }
@media (hover: hover) {
  .mention:active, .alert-item:active, .theme-row:active, .div-row:active, .pcard:active, .task:active, .why-item:active, .palette-item:active, .nav-item:active, .assignee:active, .hbar:active, .archive button:active, .x-mention:active, .x-alert-item:active, .x-pcard:active { --sl: 10%; }
}
.mention.pressing, .alert-item.pressing, .theme-row.pressing, .div-row.pressing, .pcard.pressing, .task.pressing, .why-item.pressing, .palette-item.pressing, .nav-item.pressing, .assignee.pressing, .hbar.pressing, .archive button.pressing, .x-mention.pressing, .x-alert-item.pressing, .x-pcard.pressing { --sl: 10%; }

/* Cursor label on the Today layer tiles (position is driven from app.js) */
.cursor-label {
  position: fixed; left: 0; top: 0; z-index: 60; pointer-events: none;
  padding: 4px 10px; border-radius: var(--r-pill);
  background: var(--ink); color: var(--bg);
  font-size: var(--t-xs); font-weight: 500; white-space: nowrap;
  box-shadow: var(--shadow-2);
  opacity: 0; transition: opacity var(--t-instant) var(--ease-std);
}
.cursor-label.on { opacity: 1; transition-duration: var(--t-fast); }
.cursor-label { display: none; }
@media (min-width: 1024px) and (hover: hover) and (pointer: fine) and (prefers-reduced-motion: no-preference) { .cursor-label { display: block; } }

/* Pond loader (answers, refresh) */
.pond-loader { position: relative; width: 44px; height: 20px; flex: none; }
.pond-loader i { position: absolute; left: 50%; top: 50%; width: 40px; height: 17px; border-radius: 50%; border: 1.5px solid var(--brand); transform: translate(-50%, -50%) scale(0.1); opacity: 0; animation: pondl 1.5s var(--ease-out) infinite; }
.pond-loader i:nth-child(2) { animation-delay: 0.5s; }
.pond-loader i:nth-child(3) { animation-delay: 1s; }
/* Reduced motion: rings rest visible and static instead of ending at opacity 0 (placed after the base rules to win the cascade) */
@media (prefers-reduced-motion: reduce) {
  .pond-loader i { animation: none; opacity: 0.5; transform: translate(-50%, -50%) scale(0.6); }
  .pond-loader i:nth-child(2) { opacity: 0.35; transform: translate(-50%, -50%) scale(0.8); }
}
@keyframes pondl { 0% { transform: translate(-50%, -50%) scale(0.1); opacity: 0.9; } 100% { transform: translate(-50%, -50%) scale(1); opacity: 0; } }

/* Theme switch ripple (View Transitions) */
::view-transition-old(root), ::view-transition-new(root) { animation: none; mix-blend-mode: normal; }
::view-transition-new(root) { z-index: 2; }
/* Theme switch: the colours change in one frame (set by switchTheme in app.js, lifted after the reveal). Without this every hover/press colour
   transition on the page runs at once and repaints the glass each frame, which is what made the switch stutter on phones. */
.theme-switching, .theme-switching *, .theme-switching *::before, .theme-switching *::after { transition: none !important; }

/* Table polish */
.ptable, .x-ptable { min-width: 820px; }
.tabs-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.mini-legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: var(--t-xs); color: var(--ink-2); margin: -4px 0 6px; }
.mini-legend span { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.mini-legend i { width: 14px; height: 3px; border-radius: 2px; display: inline-block; }
.mini-legend i.box { width: 10px; height: 10px; border-radius: 3px; }
.kv-list { display: flex; flex-direction: column; }
.kv-row, .x-kv-row { display: flex; justify-content: space-between; gap: 12px; padding: 9px 0; border-top: 1px solid var(--line); font-size: var(--t-sm); }
.kv-row:first-child, .x-kv-row:first-child { border-top: 0; }
.kv-row > span:first-child, .x-kv-row > span:first-child { color: var(--ink-2); min-width: 0; }
.kv-row > span:last-child, .x-kv-row > span:last-child { font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; flex: none; }
.role { font-size: var(--t-xs); padding: 2px 8px; border-radius: var(--r-pill); background: color-mix(in srgb, var(--ink) 6%, transparent); color: var(--ink-2); white-space: nowrap; }
.section-label { margin: 18px 0 6px; }
.section-label:first-child { margin-top: 0; }
.insight .tab-pane > .chart { flex: 1 1 auto; min-height: 0; }
.insight .tab-pane > .card-scroll { margin-bottom: -8px; }
@media (max-width: 767px) {
  .hero { padding: 20px 18px 18px; }
  .insight .tab-pane > .chart { min-height: 280px; }
}
@media (max-width: 767px) {
  .today { grid-template-columns: minmax(0, 1fr); }
  .today > .insight { order: 3; } .rail > .why { order: 4; }
  .seg button { height: 36px; }
  .seg.sm button { height: 32px; }
  .topbar-mobile-brand { padding: 4px; margin: -4px; }
}
@media (max-width: 767px) {
  .icon-btn.sm { width: 36px; height: 36px; }
  .check { width: 32px; height: 32px; }
}
@media (max-width: 1179px), (max-height: 699px) {
  .view > .today { flex: 0 0 auto; }
}
@media (max-width: 1023px), (max-height: 699px) {
  .view > .screen { flex: 0 0 auto; }
}

.lang-box .micro { flex-wrap: wrap; }
.meta-cell .chip, .x-meta-cell .chip { white-space: normal; height: auto; min-height: 24px; padding-block: 3px; line-height: 1.3; }
@media (max-width: 767px) {
  .field { height: 42px; }
  .field select, .field input { height: 100%; }
  .switch { width: 52px; height: 32px; }
  .switch::after { width: 26px; height: 26px; }
  .switch[aria-checked="true"]::after { transform: translateX(20px); }
  .switch.pressing::after { width: 30px; }
  .switch[aria-checked="true"].pressing::after { transform: translateX(16px); }
  @media (hover: hover) {
    .switch:active::after { width: 30px; }
    .switch[aria-checked="true"]:active::after { transform: translateX(16px); }
  }
}
.topbar { flex: none; }
.ico { display: inline-block; vertical-align: -0.18em; }
.field select { max-width: 150px; text-overflow: ellipsis; }
.field input { width: 168px; }
@media (min-width: 1024px) and (max-width: 1279px) { .filters .flabel, .filters .result-count { display: none; } .field input { width: 120px; } }
.toolbar > .filters { flex: 1 1 auto; min-width: 0; padding: 6px; }
.filters .result-count { margin-left: auto; }
@media (max-width: 767px) { .toolbar > .filters { flex: 1 1 100%; } .toolbar > .filters + .btn { margin-left: auto; } }
@media (max-width: 767px) {
  .toolbar > .filters { margin-left: 0; margin-right: 0; border-radius: var(--r-lg); border: 1px solid var(--line); padding: 6px; }
  .filters .seg { max-width: none; overflow: visible; flex: none; }
}
.insight .tab-pane > .chart, .bento .chart.fill { flex: 1 1 0; }
@media (min-width: 1180px) and (max-height: 780px) {
  .hero-top { position: absolute; top: 16px; right: 20px; left: auto; }
  .hero-top .micro { display: none; }
  .verdict { margin-top: 0; max-width: 58ch; padding-right: 110px; }
  .hero-metrics { margin-top: 10px; }
  .share-meta { display: none; }
  /* no meta row to align with here: the legend takes its natural widths so Negative and its delta stay on one line */
  .share-legend { grid-template-columns: auto auto auto; justify-content: space-between; column-gap: 8px; min-width: 0; }
  .share-legend > span { padding-left: 0; }
  .share-legend .lg .sent-dot { margin-right: 5px; }
  .share-legend .delta { margin-left: 4px; }
  .hero-num .lbl { font-size: var(--t-xs); }
}

/* Pebbles principles (strategy lens) */
.pb-n, .x-pb-n { width: 26px; height: 26px; flex: none; display: inline-grid; place-items: center; border-radius: 50% 50% 46% 54% / 58% 56% 44% 42%; background: var(--mint); color: var(--brand-ink); font-family: var(--f-mono); font-size: 11px; font-weight: 600; }
.pb-n.sm, .x-pb-n.sm { width: 22px; height: 22px; font-size: 10px; }
:root[data-theme="dark"] .pb-n, :root[data-theme="dark"] .x-pb-n { color: var(--accent); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .pb-n, :root:not([data-theme="light"]) .x-pb-n { color: var(--accent); } }
.principle-box, .x-principle-box { margin-top: 12px; padding: 12px 14px; border-radius: var(--r-md); background: color-mix(in srgb, var(--mint) 55%, var(--surface)); border: 1px solid var(--line); }
.principle-box .micro, .x-principle-box .micro { display: block; margin-bottom: 8px; }
.pb-row { display: flex; gap: 12px; align-items: flex-start; }
.pb-row > div { flex: 1; min-width: 0; }
.pb-row b { font-size: var(--t-sm); font-weight: 600; }
.pb-row p { margin: 2px 0 0; font-size: var(--t-xs); color: var(--ink-2); }

/* ═════════ Story beats on Today (MW2) ═════════ */
/* Change of view: the old verdict leaves as a ghost while the new one surfaces (JS), the chart follows at 100 ms */
.verdict-ghost { position: absolute; margin: 0; pointer-events: none; z-index: 1; }
.vw { display: inline-block; } /* verdict words during the arrival only (unwrapped afterwards) */
.view.on-period .today .chart .draw { animation-duration: 460ms; animation-delay: 100ms; animation-timing-function: var(--ease-in-out); }
.view.on-period .today .chart .fade-in { animation: fadeIn 240ms var(--ease-out) calc(100ms + var(--fx, 0) * 340ms) both; } /* markers appear as the line passes them (--fx = x position 0..1) */
.view.on-period .today .chart svg { animation: fadeIn 120ms var(--ease-std) 60ms backwards; } /* new chart surfaces while the old one (ghost) leaves */
.chart-ghost { position: absolute; left: 0; top: 0; z-index: 2; pointer-events: none; max-width: none; }
.chart-ghost, .chart-ghost * { animation: none !important; }
.view.on-period .today .chart .grow { animation-duration: 360ms; animation-delay: calc(100ms + var(--gi, 0) * 240ms / var(--gn, 1)) !important; }
.view.on-period .today .chart .end-dot { animation: fadeIn 120ms var(--ease-out) 500ms backwards; }

/* Arrival (first visit of Today per session, about 1.1 s): hero text 0 to 210 ms (JS lines), number 180, share bar 300,
   tiles 420 + 50 each, then the cards 570 / 620 / 670 and the chart line 600 to 1120. The view itself does not fade: each part surfaces on its own. */
@keyframes arrIn { from { opacity: 0; transform: translate3d(0, 8px, 0); } to { opacity: 1; transform: none; } }
.view.arrive.entering { animation: none; }
.view.arrive .hero-canvas, .view.arrive .hero-stones { animation: fadeIn 600ms var(--ease-out) backwards; }
.view.arrive .hero-top { animation: arrIn var(--t-enter) var(--settle) backwards; }
.view.arrive .hero-num { animation: arrIn var(--t-enter) var(--settle) 180ms backwards; }
.view.arrive .share-bar { transform-origin: left center; animation: growX 520ms var(--settle) 300ms backwards; }
.view.arrive .share-legend, .view.arrive .share-meta { animation: arrIn var(--t-enter) var(--settle) 380ms backwards; }
.view.arrive .layer-tile { animation: arrIn var(--t-enter) var(--settle) calc(420ms + var(--k, 0) * var(--stagger)) backwards; }
.view.arrive .layer-tile:nth-child(2) { --k: 1; }
.view.arrive .layer-tile:nth-child(3) { --k: 2; }
.view.arrive .today > .insight { animation: arrIn var(--t-enter) var(--settle) 570ms backwards; }
.view.arrive .rail > .needs { animation: arrIn var(--t-enter) var(--settle) 620ms backwards; }
.view.arrive .rail > .why { animation: arrIn var(--t-enter) var(--settle) 670ms backwards; }
.view.arrive .insight .tab-pane { animation: none; } /* the card surfaces as a whole */
.view.arrive .today .chart .draw { animation-duration: 520ms; animation-delay: 600ms; animation-timing-function: var(--ease-in-out); }
.view.arrive .today .chart .fade-in { animation-delay: calc(600ms + var(--fx, 0) * 400ms); animation-duration: 280ms; }
.view.arrive .today .chart .grow { animation-duration: 400ms; animation-delay: calc(600ms + var(--gi, 0) * 150ms / var(--gn, 1)) !important; }
.view.arrive .today .chart .end-dot { animation: fadeIn 150ms var(--ease-out) 1050ms backwards; }

/* Done: with the last open task a soft ring spreads from the pebble counter (pond colours; JS animates it, 600 ms) */
.needs { overflow: hidden; }
.done-ring { position: absolute; width: 360px; height: 150px; border-radius: 50%; border: 1.5px solid var(--brand); pointer-events: none; z-index: 0; }

/* Reduced motion: the pebble reaches its end state at once (the 130 ms delay would otherwise still apply) */
@media (prefers-reduced-motion: reduce) { .pebbles i.plop { animation: none; } }

/* No backdrop-filter (older browsers, some privacy modes): glass has nothing to blur, so every glass surface becomes nearly opaque and stays readable */
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  :root { --glass: rgba(255, 253, 247, 0.94); --glass-strong: rgba(255, 253, 247, 0.98); }
  @media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) { --glass: rgba(17, 22, 20, 0.94); --glass-strong: rgba(21, 27, 24, 0.98); } }
  :root[data-theme="dark"] { --glass: rgba(17, 22, 20, 0.94); --glass-strong: rgba(21, 27, 24, 0.98); }
}

/* ───────── Select menu (ui-select.js): trigger keeps the pill look; the list is a glass panel ───────── */
.ui-sel-native { position: absolute !important; width: 1px; height: 1px !important; margin: -1px; padding: 0 !important; border: 0; overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); opacity: 0; pointer-events: none; }
.ui-select-btn {
  appearance: none; -webkit-appearance: none; border: 0; outline: 0; background: transparent; cursor: pointer;
  font: inherit; font-size: var(--t-sm); font-weight: 500; color: var(--ink); text-align: left;
  padding: 0 18px 0 0; height: 100%; max-width: 150px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.ui-select-btn .ui-val { display: block; overflow: hidden; text-overflow: ellipsis; }
.ui-select-btn:focus-visible { outline: 0; }
.field:has(.ui-select-btn:focus-visible) { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: var(--r-pill); }
.field:has(.ui-select-btn) { cursor: pointer; }
.field:has(.ui-select-btn[aria-expanded="true"]) { border-color: var(--line-2); }
.field:has(.ui-select-btn[aria-expanded="true"]) .caret { transform: rotate(180deg); }
.field .caret { transition: transform var(--t-med) var(--settle); }
/* a select that had no .field gets one from ui-select.js: same pill, sized to its content, never wider than its box */
.ui-field-auto { display: inline-flex; height: 32px; max-width: 100%; vertical-align: middle; }
.ui-field-auto .ui-select-btn { max-width: none; min-width: 0; }

.ui-menu {
  position: fixed; z-index: 200; top: 0; left: 0;
  display: flex; flex-direction: column;
  padding: 6px; box-sizing: border-box;
  border-radius: var(--r-md);
  background: var(--glass-strong);
  -webkit-backdrop-filter: var(--glass-blur-strong); backdrop-filter: var(--glass-blur-strong);
  border: 1px solid var(--line-2); box-shadow: var(--shadow-3);
  opacity: 0; visibility: hidden; pointer-events: none;
  transform: translateY(-4px) scale(0.98); transform-origin: top left;
  transition: opacity 120ms var(--ease-std), transform 120ms var(--ease-in), visibility 0s linear 120ms;
}
.ui-menu.is-up { transform: translateY(4px) scale(0.98); transform-origin: bottom left; }
.ui-menu.show { opacity: 1; visibility: visible; pointer-events: auto; transform: none; transition: opacity 160ms var(--ease-std), transform 180ms var(--settle), visibility 0s; }
.ui-list { overflow: auto; overscroll-behavior: contain; min-height: 0; display: flex; flex-direction: column; gap: 1px; scrollbar-width: thin; outline: 0; }
.ui-list.fade-t { --fade-t: 14px; } .ui-list.fade-b { --fade-b: 14px; } /* only the edge with rows beyond it fades: at rest the first row is crisp */
.ui-opt {
  position: relative; display: flex; align-items: center; gap: 8px; flex: none;
  min-height: 36px; padding: 0 12px; border-radius: var(--r-sm);
  font-size: var(--t-sm); color: var(--ink); cursor: pointer; user-select: none;
  transition: background var(--t-fast) var(--ease-std);
}
.ui-opt .ui-lab { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ui-opt .ui-note { flex: none; font-size: var(--t-micro); line-height: 1; padding: 3px 7px; border-radius: var(--r-pill); background: color-mix(in srgb, var(--ink) 6%, transparent); color: var(--ink-3); }
.ui-opt .ui-count { flex: none; font-size: var(--t-xs); color: var(--ink-3); }
.ui-opt .ui-check { flex: none; width: 16px; height: 16px; opacity: 0; color: var(--ink-2); transform: scale(0.8); transition: opacity var(--t-fast) var(--ease-std), transform var(--t-fast) var(--settle); }
.ui-opt[aria-selected="true"] { background: color-mix(in srgb, var(--ink) 8%, transparent); font-weight: 600; }
.ui-opt[aria-selected="true"] .ui-check { opacity: 1; transform: none; }
.ui-opt.is-active { background: color-mix(in srgb, var(--ink) 6%, transparent); }
.ui-opt[aria-selected="true"].is-active { background: color-mix(in srgb, var(--ink) 11%, transparent); }
.ui-opt[aria-disabled="true"] { opacity: 0.45; cursor: default; }
.ui-top, .ui-scrim { display: none; }

/* Phone: a bottom sheet built like the drawer sheet: opaque surface (no glass while it slides over busy content), grip, title,
   then rows inset from the rounded edges. The top (grip + title) is the drag handle (ui-select.js dragSheet). */
@media (max-width: 767px) {
  .ui-opt { min-height: 44px; }
  .ui-menu.is-sheet {
    top: auto; left: 0; right: 0; bottom: 0; width: 100%; min-width: 0 !important; max-height: 70vh;
    border-radius: var(--r-xl) var(--r-xl) 0 0; border-bottom: 0;
    background: var(--surface); -webkit-backdrop-filter: none; backdrop-filter: none;
    overflow: hidden; /* nothing ever pokes past the rounded top corners, also mid-slide */
    padding: 0 0 calc(8px + env(safe-area-inset-bottom, 0px));
    transform: translate3d(0, 105%, 0); transform-origin: bottom;
    transition: transform 200ms var(--ease-in), opacity 0s linear 200ms, visibility 0s linear 200ms;
  }
  .ui-menu.is-sheet.show { opacity: 1; transform: none; transition: transform var(--t-panel) var(--settle), opacity 0s, visibility 0s; }
  .ui-menu.is-sheet.dragging { transition: none; }
  .ui-menu.is-sheet .ui-top { display: block; flex: none; padding: 0 20px 6px; touch-action: none; }
  .ui-menu.is-sheet .ui-grip { width: 40px; height: 5px; border-radius: 3px; background: var(--line-2); margin: 8px auto 0; }
  .ui-menu.is-sheet .ui-title { padding-top: 10px; font-size: var(--t-md); font-weight: 600; letter-spacing: -0.01em; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .ui-menu.is-sheet .ui-list { padding: 4px 8px 0; }
  .ui-scrim.is-sheet { display: block; position: fixed; inset: 0; z-index: 199; background: rgba(10, 46, 33, 0.28); opacity: 0; visibility: hidden; transition: opacity 200ms var(--ease-std), visibility 0s linear 200ms; }
  .ui-scrim.is-sheet.show { opacity: 1; visibility: visible; transition: opacity var(--t-panel) var(--ease-std), visibility 0s; }
}
@media (prefers-reduced-motion: reduce) {
  .ui-menu, .ui-menu.show, .ui-menu.is-sheet, .ui-menu.is-sheet.show { transition: none; }
  .ui-opt .ui-check, .field .caret { transition: none; }
}

/* ───────── Date picker (ui-date.js): the trigger is a field; the month grid is a glass popover, inline on phones ───────── */
.ui-date-native { position: absolute !important; width: 1px; height: 1px !important; min-height: 0 !important; margin: -1px; padding: 0 !important; border: 0; overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); opacity: 0; pointer-events: none; }
.ui-date { position: relative; display: flex; flex-direction: column; min-width: 0; font-weight: 400; }
.ui-date-btn {
  display: flex; align-items: center; gap: 10px; min-height: 44px; text-align: left; cursor: pointer;
  font-family: inherit; font-weight: 500; color: var(--ink); font-variant-numeric: tabular-nums;
}
.ui-date-btn:hover { border-color: color-mix(in srgb, var(--ink) 26%, transparent); }
.ui-date-btn:focus-visible { outline: 0; }
.ui-date-btn[aria-expanded="true"] { border-color: var(--focus); box-shadow: 0 0 0 3px color-mix(in srgb, var(--focus) 18%, transparent); }
.ui-date-btn .ui-date-ico { color: var(--ink-3); }
.ui-date-btn .ui-val { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ui-date-btn.is-empty .ui-val { color: var(--ink-3); font-weight: 400; }
.ui-date-rel { flex: none; font-size: var(--t-micro); font-weight: 500; line-height: 1; padding: 4px 8px; border-radius: var(--r-pill); background: color-mix(in srgb, var(--ink) 6%, transparent); color: var(--ink-2); }
.ui-date-caret { margin-left: auto; color: var(--ink-3); transition: transform var(--t-med) var(--settle); }
.ui-date-btn[aria-expanded="true"] .ui-date-caret { transform: rotate(180deg); }
/* a narrow field keeps the whole date and drops the "Today" tag (the container is the button: one on .ui-date would trap the fixed popover) */
.ui-date-btn { container-type: inline-size; }
@container (max-width: 290px) { .ui-date-rel { display: none; } }

.ui-cal {
  position: fixed; z-index: 200; top: 0; left: 0; width: 320px; box-sizing: border-box;
  padding: 12px; overflow: auto; overscroll-behavior: contain;
  border-radius: var(--r-lg); background: var(--glass-strong);
  -webkit-backdrop-filter: var(--glass-blur-strong); backdrop-filter: var(--glass-blur-strong);
  border: 1px solid var(--line-2); box-shadow: var(--shadow-3);
  font-size: var(--t-sm); font-weight: 400; color: var(--ink);
  opacity: 0; visibility: hidden; pointer-events: none;
  transform: translateY(-4px) scale(0.98); transform-origin: top left;
  transition: opacity 120ms var(--ease-std), transform 120ms var(--ease-in), visibility 0s linear 120ms;
}
.ui-cal.is-up { transform: translateY(4px) scale(0.98); transform-origin: bottom left; }
.ui-cal.show { opacity: 1; visibility: visible; pointer-events: auto; transform: none; transition: opacity 160ms var(--ease-std), transform 180ms var(--settle), visibility 0s; }

.ui-cal-picks { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; margin-bottom: 10px; }
.ui-cal-picks[hidden] { display: none; }
.ui-cal-pick {
  display: flex; flex-direction: column; justify-content: center; align-items: flex-start; gap: 1px; min-width: 0; min-height: 44px;
  padding: 5px 11px; border-radius: var(--r-sm); border: 1px solid transparent; text-align: left;
  background: color-mix(in srgb, var(--ink) 4.5%, transparent);
  font-size: var(--t-sm); font-weight: 600; color: var(--ink); line-height: 1.25;
  transition: background-color var(--t-fast) var(--ease-std), border-color var(--t-fast) var(--ease-std), transform var(--t-med) var(--spring);
}
.ui-cal-pick > * { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ui-cal-pick small { font-size: var(--t-xs); font-weight: 400; color: var(--ink-2); } /* ink-3 falls under 4.5:1 on the tinted pick over glass */
.ui-cal-pick:hover { background: color-mix(in srgb, var(--ink) 8%, transparent); }
.ui-cal-pick:active { transform: scale(0.98); }
.ui-cal-pick[aria-pressed="true"] { background: color-mix(in srgb, var(--accent) 11%, transparent); border-color: color-mix(in srgb, var(--accent) 38%, transparent); }
.ui-cal-pick[aria-disabled="true"] { opacity: 0.45; cursor: default; transform: none; background: color-mix(in srgb, var(--ink) 4.5%, transparent); }
.ui-cal-pick:focus-visible { outline-offset: 1px; border-radius: var(--r-sm); }

.ui-cal-head { display: flex; align-items: center; gap: 2px; padding: 0 0 4px 6px; }
.ui-cal-title { flex: 1; min-width: 0; font-size: var(--t-base); font-weight: 600; letter-spacing: -0.01em; color: var(--ink); }
.ui-cal-nav { width: 36px; height: 36px; flex: none; display: grid; place-items: center; border-radius: 50%; color: var(--ink-2); transition: background-color var(--t-fast) var(--ease-std), color var(--t-fast) var(--ease-std), opacity var(--t-fast) var(--ease-std); }
.ui-cal-nav[data-nav="-1"] .ico { transform: scaleX(-1); }
.ui-cal-nav:hover { background: color-mix(in srgb, var(--ink) 6%, transparent); color: var(--ink); }
.ui-cal-nav[aria-disabled="true"] { opacity: 0.3; cursor: default; background: none; color: var(--ink-2); }
.ui-cal-nav:focus-visible { border-radius: 50%; }

.ui-cal-grid { width: 100%; border-collapse: collapse; table-layout: fixed; }
.ui-cal-grid th { height: 28px; padding: 0; font-size: var(--t-micro); font-weight: 600; color: var(--ink-2); text-align: center; letter-spacing: 0.02em; }
.ui-cal-grid td { position: relative; height: 40px; padding: 0; text-align: center; vertical-align: middle; outline: 0; font-variant-numeric: tabular-nums; }
.ui-cal-grid td[data-d] { cursor: pointer; -webkit-tap-highlight-color: transparent; }
.ui-cal-d {
  position: relative; z-index: 1; display: inline-grid; place-items: center; width: 36px; height: 36px; border-radius: 50%;
  font-size: var(--t-sm); color: var(--ink);
  transition: background-color var(--t-fast) var(--ease-std), color var(--t-fast) var(--ease-std), box-shadow var(--t-fast) var(--ease-std);
}
@media (hover: hover) { .ui-cal-grid td[data-d]:not([aria-disabled="true"]):not([aria-selected="true"]):hover .ui-cal-d { background: color-mix(in srgb, var(--ink) 7%, transparent); } }
.ui-cal-grid td:focus-visible .ui-cal-d { outline: 2px solid var(--focus); outline-offset: 1px; }
.ui-cal-grid td.is-today .ui-cal-d { font-weight: 700; }
.ui-cal-grid td.is-today .ui-cal-d::after { content: ""; position: absolute; left: 50%; bottom: 5px; width: 4px; height: 4px; margin-left: -2px; border-radius: 50%; background: var(--brand); }
.ui-cal-grid td[aria-selected="true"] .ui-cal-d { background: var(--accent); color: var(--on-accent); font-weight: 600; }
.ui-cal-grid td[aria-selected="true"].is-today .ui-cal-d::after { background: var(--on-accent); }
.ui-cal-grid td.r-cap .ui-cal-d, .ui-cal-grid td.is-hover .ui-cal-d { box-shadow: inset 0 0 0 1.5px color-mix(in srgb, var(--accent) 60%, transparent); font-weight: 600; }
.ui-cal-grid td[aria-disabled="true"] { cursor: default; }
.ui-cal-grid td[aria-disabled="true"] .ui-cal-d { color: var(--ink-3); opacity: 0.5; }
/* Range: one soft band from the first to the last day, rounded where a week or the month breaks it */
.ui-cal-grid td.in-range::before, .ui-cal-grid td.r-start::before, .ui-cal-grid td.r-end::before {
  content: ""; position: absolute; top: 2px; bottom: 2px; left: 0; right: 0; background: color-mix(in srgb, var(--accent) 12%, transparent);
}
.ui-cal-grid td.r-start::before { left: 50%; }
.ui-cal-grid td.r-end::before { right: 50%; }
.ui-cal-grid td.in-range:first-child::before, .ui-cal-grid td.in-range.m-first::before, .ui-cal-grid td.r-end:first-child::before, .ui-cal-grid td.r-end.m-first::before { left: 2px; border-radius: 18px 0 0 18px; }
.ui-cal-grid td.in-range:last-child::before, .ui-cal-grid td.in-range.m-last::before, .ui-cal-grid td.r-start:last-child::before, .ui-cal-grid td.r-start.m-last::before { right: 2px; border-radius: 0 18px 18px 0; }
.ui-cal-grid td.r-end:first-child::before, .ui-cal-grid td.r-end.m-first::before { right: 50%; }
.ui-cal-grid td.r-start:last-child::before, .ui-cal-grid td.r-start.m-last::before { left: 50%; }

@media (max-width: 767px) {
  /* Inline: the calendar unfolds inside the form under its field, so the drawer sheet carries it */
  .ui-cal.is-inline {
    position: static; width: auto; padding: 0; overflow: visible; border: 0; border-radius: 0; box-shadow: none;
    background: none; -webkit-backdrop-filter: none; backdrop-filter: none; opacity: 1; transform: none;
    display: grid; grid-template-rows: 0fr;
    transition: grid-template-rows var(--t-exit) var(--ease-std), visibility 0s linear var(--t-exit);
  }
  .ui-cal.is-inline.show { grid-template-rows: 1fr; transition: grid-template-rows var(--t-med) var(--settle), visibility 0s; }
  .ui-cal.is-inline > .ui-cal-in { min-height: 0; overflow: hidden; margin: 0 -12px; padding: 0 2px; }
  .ui-cal.is-inline .ui-cal-body {
    margin: 8px 0 2px; padding: 10px 4px 6px; border-radius: var(--r-md);
    background: var(--surface-2); border: 1px solid var(--line);
    opacity: 0; transform: translateY(-6px); transition: opacity var(--t-instant) var(--ease-std), transform var(--t-instant) var(--ease-std);
  }
  .ui-cal.is-inline.show .ui-cal-body { opacity: 1; transform: none; transition: opacity 160ms var(--ease-std) 40ms, transform var(--t-med) var(--settle) 40ms; }
  .ui-cal.is-inline .ui-cal-picks { padding: 0 6px; }
  .ui-cal.is-inline .ui-cal-head { padding: 0 2px 2px 12px; }
  .ui-cal-nav { width: 44px; height: 44px; }
  .ui-cal-grid td { height: 44px; }
  .ui-cal-d { width: 40px; height: 40px; font-size: var(--t-base); }
  .ui-cal-grid td.is-today .ui-cal-d::after { bottom: 6px; }
}
@media (prefers-reduced-motion: reduce) {
  .ui-cal, .ui-cal.show, .ui-cal.is-inline, .ui-cal.is-inline.show, .ui-cal.is-inline .ui-cal-body, .ui-cal.is-inline.show .ui-cal-body { transition: none; }
  .ui-date-caret, .ui-cal-d, .ui-cal-pick { transition: none; }
  /* the global 1 ms rule would give every cell a 1 ms "all" transition; WebKit never runs it while the panel is hidden, so the cells stayed invisible */
  .ui-cal *, .ui-cal *::before, .ui-cal *::after { transition: none !important; }
}

/* Focus ring on list items sits inside the card: it never grows the card, never touches a neighbour or the scroll container's edge */
.alert-item:focus-visible, .x-alert-item:focus-visible, .mention:focus-visible, .x-mention:focus-visible, .pcard:focus-visible, .x-pcard:focus-visible, .theme-row:focus-visible, .div-row:focus-visible, .task:focus-visible, .archive button:focus-visible { outline-offset: -2px; border-radius: var(--r-md); }

/* ───────── Mentions filters on phone: two tidy rows, 44px targets, aligned to the content edges ───────── */
.report-mini { display: none; }
@media (max-width: 767px) {
  .toolbar > .filters:has(.report-mini) {
    display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) 44px 44px; gap: 8px; align-items: center;
    overflow: visible; flex-wrap: wrap; padding: 8px; margin-left: 0; margin-right: 0; border-radius: var(--r-lg); border: 1px solid var(--line);
  }
  .toolbar > .filters:has(.report-mini) + .btn { display: none; }
  .filters:has(.report-mini) .seg { grid-column: 1 / -1; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); width: 100%; max-width: none; overflow: visible; box-sizing: border-box; }
  .filters:has(.report-mini) .seg button { height: 38px; padding: 0 2px; display: flex; align-items: center; justify-content: center; font-size: var(--t-xs); min-width: 0; }
  .filters:has(.report-mini) .seg .seg-n { margin-left: 4px; font-size: 0.9em; }
  .filters:has(.report-mini) .field { height: 44px; min-width: 0; }
  .filters:has(.report-mini) .field .ui-select-btn { flex: 1; max-width: none; min-width: 0; }
  .filters:has(.report-mini) .field-search { position: relative; width: 44px; padding: 0; justify-content: center; }
  .filters:has(.report-mini) .field-search input { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; padding: 0; cursor: pointer; font-size: 16px; }
  .filters:has(.report-mini) .field-search .ico { color: var(--ink-2); pointer-events: none; }
  .filters:has(.report-mini) .report-mini { display: inline-grid; place-items: center; width: 44px; height: 44px; }
  /* Searching: the field takes row 2 and the selects step aside */
  .filters:has(.report-mini):has(#fQ:focus, #fQ:not(:placeholder-shown)) .field:not(.field-search), .filters:has(.report-mini):has(#fQ:focus, #fQ:not(:placeholder-shown)) .report-mini { height: 0; min-height: 0; padding: 0; border-width: 0; margin: -4px 0; overflow: hidden; opacity: 0; pointer-events: none; }
  .filters:has(.report-mini):has(#fQ:focus, #fQ:not(:placeholder-shown)) .field-search { grid-column: 1 / -1; width: auto; justify-content: flex-start; padding: 0 12px; gap: 8px; }
  .filters:has(.report-mini):has(#fQ:focus, #fQ:not(:placeholder-shown)) .field-search input { position: static; opacity: 1; flex: 1; min-width: 0; cursor: text; }
}
@media (max-width: 767px) {
  .filters:has(.report-mini) .field:not(.field-search) { padding: 0 8px 0 12px; gap: 6px; }
  .filters:has(.report-mini) .field:not(.field-search) .flabel { font-size: var(--t-xs); }
  .filters:has(.report-mini) .field .ui-select-btn { padding-right: 14px; }
  .filters:has(.report-mini) .field .caret { right: 8px; }
}
