/*
 * Plain CSS, served by Propshaft. No build step.
 * Structure and density inspired by Linear, warm colors inspired by Claude.
 * Order of layers: tokens → base → layout → components → utilities → motion.
 */
@layer tokens, base, layout, components, utilities, motion;

/* Typed custom properties: they can be animated, and they are computed where they are set. */
@property --index {
  syntax: "<integer>";
  inherits: true;
  initial-value: 0;
}

/* Scroll fades: how much of each edge fades out, animated by the scroll position. */
@property --fade-start {
  syntax: "<length>";
  inherits: false;
  initial-value: 0px;
}

@property --fade-end {
  syntax: "<length>";
  inherits: false;
  initial-value: 0px; /* no fade when the element doesn't scroll (its scroll timeline is inactive) */
}

@property --reveal {
  syntax: "<angle>";
  inherits: false;
  initial-value: 360deg;
}

@layer tokens {
  /*
   * Every color is light-dark(light, dark). The browser picks one based on color-scheme:
   * "light dark" follows the system, data-theme on <html> forces one (set on the account page).
   */
  :root {
    color-scheme: light dark;
    interpolate-size: allow-keywords; /* lets height animate to auto (used by the FAQ) */

    /* Neutrals: warm in light mode (Claude), deep in dark mode (Linear) */
    --color-bg: light-dark(#f8f7f4, #0d0e10);
    --color-sidebar: light-dark(#f3f2ee, #0a0b0c);
    --color-surface: light-dark(#ffffff, #141518);
    --color-surface-muted: light-dark(#f4f3ef, #1a1b1f);
    --color-surface-hover: light-dark(#efeee9, #1f2024);
    --color-border: light-dark(#e7e5df, #232428);
    --color-border-strong: light-dark(#d9d6ce, #2e3035);
    --color-text: light-dark(#1f1e1c, #ececee);
    --color-text-muted: light-dark(#6b6963, #9a9ba1);
    --color-text-subtle: light-dark(#9a978f, #6b6c72);

    --color-accent: light-dark(#c15f3c, #e07a55);
    --color-accent-hover: light-dark(#ad5333, #ea8b68);
    --color-accent-soft: light-dark(#f6e9e3, #2b1d17);
    /* Filled accent (primary button, badges): white text in both themes, so dark mode keeps the deeper orange. */
    --color-accent-fill: #b55734; /* white on it: 4.8:1 (WCAG AA) */
    --color-accent-fill-hover: light-dark(#a24c2d, #c15f3c);
    --color-accent-contrast: #ffffff;
    --color-positive-contrast: light-dark(#ffffff, #07150e);
    --color-negative-contrast: light-dark(#ffffff, #1c0807);

    --color-positive: light-dark(#1f7a4d, #4cc38a);
    --color-positive-soft: light-dark(#e5f2ea, #13261c);
    --color-negative: light-dark(#b93a32, #f0736b);
    --color-negative-soft: light-dark(#f8e7e5, #2c1615);
    --color-warning: light-dark(#9a6200, #e5b350);
    --color-warning-soft: light-dark(#f7eedb, #2a2213);

    /* Categorical chart palette, a validated step per mode (see dataviz skill) */
    --chart-1: light-dark(#2a78d6, #3987e5);
    --chart-2: light-dark(#eb6834, #d95926);
    --chart-3: light-dark(#1baf7a, #199e70);
    --chart-4: light-dark(#eda100, #c98500);
    --chart-5: light-dark(#e87ba4, #d55181);
    --chart-6: light-dark(#008300, #008300);
    --chart-7: light-dark(#4a3aa7, #9085e9);
    --chart-other: light-dark(#c9c6be, #45464c);
    --chart-bar: light-dark(#86b6ef, #1c5cab);
    --chart-bar-highlight: light-dark(#2a78d6, #3987e5);
    --chart-grid: light-dark(#efede8, #1d1e22);

    --radius-large: 12px;
    --radius: 10px;
    --radius-small: 6px;
    --control-radius: 8px; /* every control: buttons, inputs, selects, segmented navs, chips */
    --shadow-small: 0 1px 2px light-dark(rgb(31 30 28 / 0.04), transparent);
    --shadow: 0 1px 3px light-dark(rgb(31 30 28 / 0.06), transparent), 0 1px 2px light-dark(rgb(31 30 28 / 0.04), transparent);
    --shadow-large: 0 8px 24px light-dark(rgb(31 30 28 / 0.08), rgb(0 0 0 / 0.5)), 0 2px 6px light-dark(rgb(31 30 28 / 0.04), transparent);

    --space-1: 4px;
    --space-2: 8px;
    --space-3: 12px;
    --space-4: 16px;
    --space-5: 24px;
    --space-6: 32px;
    --space-7: 48px;

    --font-sans: ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; /* the system font: nothing to load */
    --font-mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, monospace;
    --text-xs: 11.5px;
    --text-sm: 12.5px;
    --text-base: 13.5px;
    --text-md: 15px;
    --text-lg: 18px;
    --text-xl: 24px;
    /* Buttons, inputs and segmented navs share one height, so they line up side by side. */
    --control-height: 32px;
    /* Big figures and display titles */
    --text-figure: 21px;   /* the number in a stat tile */
    --text-figure-lg: 28px; /* the headline number of a card */
    --weight-display: 650;  /* hero, section and display titles, big numbers */

    --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
    --ease-in-out: cubic-bezier(0.65, 0, 0.35, 1);
    --duration-fast: 120ms;
    --duration: 220ms;
    --duration-slow: 600ms;

    --sidebar-expanded-width: 232px;
    --sidebar-width: var(--sidebar-expanded-width);
    --content-gutter: var(--space-6);
    --content-max: 1240px;
  }

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

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

  /* Always reserve space for the scrollbar, so short and long pages line up. No bigger text when a phone turns. */
  html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; scrollbar-gutter: stable; }

  body {
    margin: 0;
    background: var(--color-bg);
    color: var(--color-text);
    font-family: var(--font-sans);
    font-size: var(--text-base);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
  }

  h1, h2, h3, p, ul, ol, dl, dd, figure { margin: 0; }
  h1, h2, h3 { font-weight: 600; letter-spacing: -0.011em; }
  a { color: inherit; text-decoration: none; }
  strong { font-weight: 600; }
  code { font-family: var(--font-mono); font-size: 0.92em; background: var(--color-surface-muted); border: 1px solid var(--color-border); padding: 0.05em 0.35em; border-radius: 4px; }
  ::selection { background: var(--color-accent-soft); }

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

  input[type="email"], input[type="password"], input[type="text"], input[type="number"], select {
    width: 100%;
    height: var(--control-height);
    padding: 0 var(--space-3);
    background: var(--color-surface);
    border: 1px solid var(--color-border-strong);
    border-radius: var(--control-radius);
    font-size: var(--text-base);
    transition: border-color 0.12s, box-shadow 0.12s;
  }
  /* iOS zooms in on a field with text under 16px. On touch screens fields get 16px, so the page stays put.
     Pinch zoom keeps working: people who need bigger text must always be able to zoom (WCAG 1.4.4). */
  @media (pointer: coarse) {
    input[type="email"], input[type="password"], input[type="text"], input[type="number"], select, textarea { font-size: 16px; }
  }
  /* A quick second tap on a control is a second tap, not a zoom. */
  a, button, input, select, textarea, label, summary { touch-action: manipulation; }
  input:hover, select:hover { border-color: var(--color-text-subtle); }
  /* A transparent outline stays visible in Windows high contrast mode, where shadows are not drawn. */
  input:focus, select:focus { outline: 2px solid transparent; border-color: var(--color-accent); box-shadow: 0 0 0 3px var(--color-accent-soft); }

  a:focus-visible, button:focus-visible, summary:focus-visible {
    outline: 2px solid var(--color-accent);
    outline-offset: 2px;
    border-radius: var(--radius-small);
  }

  turbo-frame { display: contents; }
  .turbo-progress-bar { height: 2px; background: var(--color-accent); }
}

@layer layout {
  .app-shell {
    display: grid;
    grid-template-columns: var(--sidebar-width) minmax(0, 1fr);
    min-height: 100dvh;
    transition: grid-template-columns var(--duration) var(--ease-in-out);
  }

  /*
   * The main area is a grid with three columns: gutter, content, gutter.
   * Every block sits in the content column, also the children of a Turbo Frame (display: contents).
   * On wide screens the gutters grow, so the content column is centered next to the sidebar.
   */
  .app-main, .demo-banner {
    display: grid;
    grid-template-columns:
      [full-start] minmax(var(--content-gutter), 1fr)
      [content-start] minmax(0, var(--content-max))
      [content-end] minmax(var(--content-gutter), 1fr)
      [full-end];
  }
  /* clip, not hidden: no page-wide sideways scroll from hidden chart tooltips, and sticky still works */
  .app-main { overflow-x: clip; }
  .app-main {
    align-content: start;
    row-gap: var(--space-5);
    padding-bottom: var(--space-7);
    min-width: 0;
  }
  .app-main > *, .app-main > turbo-frame > * { grid-column: content; min-width: 0; }

  .auth-main {
    display: grid;
    place-items: center;
    min-height: 100dvh;
    padding: var(--space-5) var(--space-4);
    background:
      radial-gradient(ellipse 80% 50% at 50% -10%, var(--color-accent-soft), transparent 70%),
      var(--color-bg);
  }

  .grid { display: grid; gap: var(--space-4); }
  .grid--2 { grid-template-columns: repeat(auto-fit, minmax(min(100%, 400px), 1fr)); }

  @media (width <= 900px) {
    :root { --content-gutter: var(--space-4); }
    .app-shell { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto 1fr; } /* the extra height goes to the page, not the nav */
  }
}

@layer components {
  /* Sidebar */
  .sidebar {
    position: sticky; top: 0;
    height: 100dvh;
    overflow: hidden; /* clips the fixed-width inner part while the column gets narrower */
    background: var(--color-sidebar);
    border-right: 1px solid var(--color-border);
  }
  .sidebar__inner {
    display: flex; flex-direction: column; gap: var(--space-1);
    width: calc(var(--sidebar-expanded-width) - 1px);
    height: 100%;
    padding: var(--space-3);
  }
  .sidebar form { display: contents; }
  .sidebar__brand { display: flex; align-items: center; gap: var(--space-2); height: 40px; padding-inline: var(--space-2); margin-bottom: var(--space-3); font-weight: 600; font-size: var(--text-md); letter-spacing: -0.01em; white-space: nowrap; }
  .sidebar__heading { position: relative; height: 32px; padding: var(--space-4) var(--space-3) 0; font-size: var(--text-xs); font-weight: 500; color: var(--color-text-subtle); white-space: nowrap; }
  .sidebar__nav { display: contents; }
  .sidebar__group { list-style: none; padding: 0; display: flex; flex-direction: column; gap: 1px; }
  .sidebar__link {
    display: flex; align-items: center; gap: var(--space-3);
    width: 100%; height: 32px; padding: 0 var(--space-3);
    border: 0; border-radius: var(--radius-small);
    background: none; color: var(--color-text-muted);
    font: inherit; font-weight: 500; text-align: left; white-space: nowrap; cursor: pointer;
    transition: background var(--duration-fast), color var(--duration-fast);
  }
  .sidebar__link .icon { color: var(--color-text-subtle); transition: color var(--duration-fast); }
  /* Hover only styles items that are not active: the active state always wins. */
  .sidebar__link:not(.sidebar__link--active):hover { background: var(--color-surface-hover); color: var(--color-text); }
  .sidebar__link--active { background: var(--color-surface); color: var(--color-text); box-shadow: var(--shadow-small), inset 0 0 0 1px var(--color-border); }
  .sidebar__link--active .icon, .sidebar__link:not(.sidebar__link--active):hover .icon { color: var(--color-accent); }

  .sidebar__footer { margin-top: auto; display: flex; flex-direction: column; gap: 1px; padding-top: var(--space-3); border-top: 1px solid var(--color-border); }
  /* The avatar is wider than an icon: less padding and gap, so it centres in the rail and the email starts where the other labels start. */
  .sidebar__user { padding-left: var(--space-2); gap: var(--space-2); }
  .sidebar__email { overflow: hidden; text-overflow: ellipsis; }

  .segmented-nav button.segmented-nav__item { border: 0; background: none; cursor: pointer; font: inherit; font-size: var(--text-sm); font-weight: 500; }
  .segmented-nav button.segmented-nav__item--active { background: var(--color-surface); }

  .avatar { flex: none; display: grid; place-items: center; width: 24px; height: 24px; border-radius: 50%; background: var(--color-accent-soft); color: var(--color-accent); font-size: var(--text-xs); font-weight: 600; }

  .logo { flex: none; }
  .logo__tile { fill: var(--color-text); }
  .logo__stem { fill: none; stroke: var(--color-bg); }
  .logo__ink { fill: var(--color-bg); stroke: var(--color-bg); }
  .wordmark__letters { fill: var(--color-text); }
  .wordmark__dot { fill: var(--color-text); stroke: var(--color-text); }
  .wordmark { flex: none; translate: 0 -1%; } /* the capitals sit a bit above the middle of the icon */
  .logo__leaf { fill: var(--color-accent); stroke: var(--color-accent); }
  .wordmark { display: block; width: auto; flex: none; }

  /*
   * Collapsed: only the column width animates (on .app-shell). Labels fade out in the first part
   * of that animation; the layout itself never changes, so nothing jumps.
   * Links keep their accessible name; the title attribute shows a tooltip.
   */
  .sidebar__label { transition: opacity var(--duration-fast) var(--ease-out); }
  /* In the rail, dividers are short lines centred on the icons (32px), and links become 40px squares,
     so the active and hover background never runs to the clipped edge. */
  .sidebar__heading::after, .sidebar__footer::before {
    content: ""; position: absolute; left: 12px; width: 16px; height: 1px;
    background: var(--color-border-strong); opacity: 0; transition: opacity var(--duration-fast);
  }
  .sidebar__heading::after { bottom: 8px; }
  .sidebar__footer { position: relative; transition: border-color var(--duration-fast); }
  .sidebar__footer::before { top: -1px; }
  .sidebar__link { transition: background var(--duration-fast), color var(--duration-fast), width var(--duration) var(--ease-in-out); }

  @media (width > 900px) {
    [data-sidebar="collapsed"] { --sidebar-width: 64px; }
    [data-sidebar="collapsed"] .sidebar__label { opacity: 0; }
    [data-sidebar="collapsed"] .sidebar__heading::after, [data-sidebar="collapsed"] .sidebar__footer::before { opacity: 1; }
    [data-sidebar="collapsed"] .sidebar__footer { border-top-color: transparent; }
    [data-sidebar="collapsed"] .sidebar__link { width: 40px; }
    /* Expanding: wait until the column is wide enough before the labels come back. */
    body:not([data-sidebar="collapsed"]) .sidebar__label { transition-delay: calc(var(--duration) * 0.5); }
  }

  @media (width <= 900px) {
    .sidebar { position: sticky; z-index: 10; height: auto; align-self: start; overflow: visible; border-right: 0; border-bottom: 1px solid var(--color-border); }
    .sidebar__inner { width: auto; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; align-content: flex-start; padding: var(--space-2) var(--space-3); }
    .sidebar__brand { margin: 0; }
    .sidebar__heading, .sidebar__toggle, .sidebar__footer .sidebar__label { display: none; }
    .sidebar__nav { display: flex; order: 3; width: 100%; overflow-x: auto; scrollbar-width: none; gap: 1px; margin-inline: calc(var(--space-3) * -1); padding-inline: var(--space-3); width: calc(100% + 2 * var(--space-3)); }
    .sidebar__group { flex-direction: row; flex-wrap: nowrap; }
    .sidebar__nav { scroll-snap-type: x proximity; scroll-padding-inline: var(--space-3); }
    .sidebar__group li { scroll-snap-align: start; }
    .sidebar__link--active { scroll-initial-target: nearest; } /* a new page opens the menu at the active item */
    .sidebar__group .sidebar__link { width: auto; }
    .sidebar__footer { margin: 0 0 0 auto; padding: 0; border: 0; flex-direction: row; }
    .sidebar__footer .sidebar__link { width: auto; }
  }

  /* Icons */
  .icon { flex: none; display: block; }

  /* Page header: sticky top bar */
  .page-header {
    order: -1; /* always first, also when a flash message is rendered before it */
    grid-column: full;
    display: grid;
    grid-template-columns: subgrid;
    position: sticky; top: 0; z-index: 5;
    padding-block: var(--space-4);
    min-height: 64px;
    background: color-mix(in srgb, var(--color-bg) 85%, transparent);
    backdrop-filter: saturate(1.8) blur(12px);
    -webkit-backdrop-filter: saturate(1.8) blur(12px);
    border-bottom: 1px solid var(--color-border);
  }
  /* The bar is full width, its content lines up with the content column. */
  .page-header__inner { grid-column: content; display: flex; justify-content: space-between; align-items: center; gap: var(--space-4); flex-wrap: wrap; min-width: 0; }
  .page-header__title { font-size: var(--text-lg); line-height: 1.3; }
  .page-header__description { color: var(--color-text-muted); font-size: var(--text-sm); }
  .page-header__actions { display: flex; gap: var(--space-2); }

  @media (width <= 900px) {
    .page-header { position: static; }
  }

  .section-header { display: flex; justify-content: space-between; align-items: center; gap: var(--space-3); flex-wrap: wrap; margin-top: var(--space-2); }
  .section-header__title { font-size: var(--text-md); }

  /* Card */
  .card { background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius-large); box-shadow: var(--shadow); min-width: 0; }
  .card__header { display: flex; justify-content: space-between; align-items: flex-start; gap: var(--space-3); padding: var(--space-4) var(--space-5) 0; }
  .card__title { font-size: var(--text-base); font-weight: 600; }
  .card__description { color: var(--color-text-muted); font-size: var(--text-sm); margin-top: 2px; }
  .card__body { padding: var(--space-4) var(--space-5) var(--space-5); }
  .card__body > p + p, .card__body > p + form { margin-top: var(--space-3); }
  /* A chart right below a title and subtitle gets a bit more air, so the top label doesn't touch the text. */
  .card__body > :is(.line-chart, .bar-chart, .split-bar):first-child { margin-top: var(--space-2); }
  .card__body > * + :is(.line-chart, .bar-chart) { margin-top: var(--space-2); }
  .link-more { display: inline-flex; align-items: center; gap: 4px; font-size: var(--text-sm); color: var(--color-text-muted); white-space: nowrap; font-weight: 500; }
  .link-more:hover { color: var(--color-accent); }

  /* Stats: one panel with hairline dividers */
  .stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 150px), 1fr)); gap: var(--space-4); }
  .stats--cards {
    gap: 1px;
    background: var(--color-border);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-large);
    overflow: hidden;
    box-shadow: var(--shadow);
    display: flex;
    flex-wrap: wrap;
  }
  /* Items in the last row grow to fill it, so there are no empty cells. */
  .stats--cards .stat { flex: 1 1 210px; background: var(--color-surface); padding: var(--space-4) var(--space-5); }
  /* Exactly four: two by two, or four in a row when there is room. Never three plus one. */
  .stats--cards { container-type: inline-size; }
  .stats--cards:has(> .stat:nth-child(4):last-child) > .stat { flex-basis: calc(50% - 1px); }
  @container (min-width: 820px) {
    .stats--cards:has(> .stat:nth-child(4):last-child) > .stat { flex-basis: calc(25% - 1px); }
  }
  .stat { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
  .stat__label { color: var(--color-text-muted); font-size: var(--text-sm); font-weight: 500; }
  .stat__value { font-size: var(--text-figure); font-weight: 600; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; line-height: 1.35; }
  .stat__hint { color: var(--color-text-subtle); font-size: var(--text-xs); }

  /* Money */
  .money { font-variant-numeric: tabular-nums; white-space: nowrap; }
  .money--positive { color: var(--color-positive); }
  .money--negative { color: var(--color-negative); }

  /* Buttons */
  .button {
    display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2);
    height: var(--control-height); padding: 0 var(--space-3);
    border: 1px solid var(--color-border-strong); border-radius: var(--control-radius);
    background: var(--color-surface); color: var(--color-text);
    font-size: var(--text-base); font-weight: 500; line-height: 1; cursor: pointer; white-space: nowrap;
    text-box: trim-both cap alphabetic; /* centres on the letters themselves, not on the font's line box */
    box-shadow: var(--shadow-small);
    transition: background 0.12s, border-color 0.12s;
  }
  .button:hover { background: var(--color-surface-hover); }
  .button--primary { background: var(--color-accent-fill); border-color: transparent; color: var(--color-accent-contrast); box-shadow: inset 0 1px 0 rgb(255 255 255 / 0.15), var(--shadow-small); }
  .button--primary:hover { background: var(--color-accent-fill-hover); }
  .button--danger { color: var(--color-negative); }
  .button--danger:hover { background: var(--color-negative-soft); }
  .button--danger-solid { background: var(--color-negative); border-color: transparent; color: var(--color-negative-contrast); }
  .button--danger-solid:hover { background: color-mix(in srgb, var(--color-negative) 88%, black); }
  .button--ghost { background: transparent; border-color: transparent; box-shadow: none; color: var(--color-text-muted); }
  .button--ghost:hover { background: var(--color-surface-hover); color: var(--color-text); }
  .button--large { height: 40px; padding: 0 var(--space-5); font-size: var(--text-md); }
  .button--small { height: 28px; padding: 0 var(--space-2); font-size: var(--text-sm); }
  .button--block { width: 100%; height: 36px; }

  /* Forms */
  .form { display: flex; flex-direction: column; gap: var(--space-4); }
  .card .form > .button { align-self: flex-start; }
  .field { display: flex; flex-direction: column; gap: var(--space-2); }
  .field label { font-weight: 500; font-size: var(--text-sm); color: var(--color-text-muted); }
  .form__note { font-size: var(--text-sm); color: var(--color-text-muted); }
  .form__note a { color: var(--color-text); text-decoration: underline; text-underline-offset: 2px; }
  .field__row { display: flex; justify-content: space-between; align-items: baseline; gap: var(--space-2); }
  .field__link { font-size: var(--text-sm); color: var(--color-text-muted); }
  .field__link:hover { color: var(--color-accent); }
  .field__hint { color: var(--color-text-subtle); font-size: var(--text-xs); }
  .inline-form { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2); flex: 1; min-width: 0; }
  .inline-form input[type="text"] { flex: 1 1 8rem; width: auto; min-width: 0; }
  .inline-form select { width: auto; }
  .form-errors { background: var(--color-negative-soft); color: var(--color-negative); padding: var(--space-3) var(--space-4); border-radius: var(--radius-small); font-size: var(--text-sm); }
  .form-errors ul { padding-left: var(--space-4); }

  /* Flash */
  /* Notice: the same card as a flash (surface, thin border, round icon), with an action on the right. */
  .notice { display: flex; align-items: center; gap: var(--space-3); padding: var(--space-3) var(--space-3) var(--space-3) var(--space-3); border: 1px solid var(--color-border); border-radius: var(--radius); background: var(--color-surface); box-shadow: var(--shadow-small); color: var(--color-text); font-size: var(--text-sm); }
  /* Demo banner: fixed at the bottom of the main area, in the same columns as the page, so it lines up. */
  .demo-banner { position: fixed; z-index: 5; inset: auto 0 var(--space-4) var(--sidebar-width); pointer-events: none; transition: left var(--duration) var(--ease-in-out); }
  .demo-banner > .notice { grid-column: content; pointer-events: auto; box-shadow: var(--shadow-large); }
  .app-main:has(> .demo-banner) { padding-bottom: 96px; }
  body:has(.demo-banner) .flash-messages--floating { bottom: 96px; }
  @media (width <= 900px) { .demo-banner { left: 0; } }
  .notice > .icon { flex: none; box-sizing: content-box; padding: var(--space-1); border-radius: 50%; background: var(--color-accent-soft); color: var(--color-accent); }
  .notice__text { flex: 1; }
  /* Flash: a small card with a round icon. Floating in the app, inline on the sign-in pages. */
  .flash-messages { display: flex; flex-direction: column; gap: var(--space-2); }
  .flash { display: flex; align-items: center; gap: var(--space-3); padding: var(--space-3) var(--space-4) var(--space-3) var(--space-3); border: 1px solid var(--color-border); border-radius: var(--radius); background: var(--color-surface); color: var(--color-text); font-size: var(--text-sm); font-weight: 500; }
  .flash__icon { flex: none; display: grid; place-items: center; width: 24px; height: 24px; border-radius: 50%; background: var(--color-positive-soft); color: var(--color-positive); }
  .flash--alert .flash__icon { background: var(--color-negative-soft); color: var(--color-negative); }
  .flash-messages--floating { position: fixed; z-index: 20; inset: auto var(--space-5) var(--space-5) auto; max-width: min(420px, calc(100vw - 2 * var(--space-5))); }
  .flash-messages--floating .flash { box-shadow: var(--shadow-large); animation: flash-in var(--duration) var(--ease-out) both; }
  /* A success pops in, draws its check, and leaves after five seconds (hover keeps it). An error stays. */
  .flash-messages--floating .flash--notice { animation: flash-in var(--duration) var(--ease-out) both, flash-out var(--duration) var(--ease-in-out) 5s forwards; }
  .flash-messages--floating .flash:hover { animation-play-state: paused; }
  .flash--notice .flash__icon path { stroke-dasharray: 24; stroke-dashoffset: 24; animation: draw var(--duration-slow) var(--ease-out) 150ms forwards; }
  @keyframes flash-in { from { opacity: 0; translate: 0 12px; scale: 0.96; } }
  @keyframes flash-out { to { opacity: 0; translate: 0 12px; visibility: hidden; } }
  @media (width <= 640px) { .flash-messages--floating { inset: auto var(--space-4) var(--space-4); max-width: none; } }

  /* Auth */
  .auth-card { width: 100%; max-width: 380px; background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius-large); padding: var(--space-6); box-shadow: var(--shadow-large); display: flex; flex-direction: column; gap: var(--space-4); }
  .auth-card__brand { width: fit-content; display: flex; align-items: center; gap: var(--space-2); font-weight: 600; font-size: var(--text-md); margin-bottom: var(--space-2); }
  .auth-card__title { font-size: var(--text-xl); letter-spacing: -0.02em; }
  .auth-card__links { font-size: var(--text-sm); color: var(--color-text-muted); text-align: center; }
  .auth-card__links a { color: var(--color-text); font-weight: 500; }
  .auth-card__links a:hover { color: var(--color-accent); }

  /* Badge */
  /* Investment accounts on the settings page */
  .account-list__icon { flex: none; display: grid; place-items: center; width: 36px; height: 36px; border-radius: var(--radius); background: var(--color-accent-soft); color: var(--color-accent); }
  .account-list__text { flex: 1; min-width: 0; }
  .account-list__name { font-weight: 600; }
  .account-list__meta { color: var(--color-text-subtle); font-size: var(--text-sm); }
  .account-list__actions { display: flex; gap: var(--space-2); }

  /* Choice cards: radio buttons that look like cards */
  .choice-cards { border: 0; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 180px), 1fr)); gap: var(--space-2); }
  .choice-cards__legend { margin-bottom: var(--space-2); font-weight: 500; font-size: var(--text-sm); color: var(--color-text-muted); }
  .choice-cards__option {
    display: flex; align-items: flex-start; gap: var(--space-3); padding: var(--space-3); cursor: pointer;
    border: 1px solid var(--color-border-strong); border-radius: var(--radius); background: var(--color-surface);
    transition: border-color var(--duration-fast), background var(--duration-fast), box-shadow var(--duration-fast);
  }
  .choice-cards__option > .icon { flex: none; margin-top: 2px; color: var(--color-text-subtle); }
  /* Shared by choice cards and account pills: a hidden radio, the label shows the state. */
  :is(.choice-cards__option, .account-picker__option):not(:has(:checked)):hover { border-color: var(--color-text-subtle); color: var(--color-text); }
  :is(.choice-cards__option, .account-picker__option):has(:checked) { border-color: var(--color-accent); background: var(--color-accent-soft); }
  :is(.choice-cards__option, .account-picker__option):has(:focus-visible) { outline: 2px solid var(--color-accent); outline-offset: 2px; }
  :is(.choice-cards__input, .account-picker__input) { position: absolute; opacity: 0; pointer-events: none; }
  .choice-cards__option:has(:checked) { box-shadow: 0 0 0 1px var(--color-accent); }
  .choice-cards__option:has(:checked) > .icon { color: var(--color-accent); }
  .choice-cards__text { display: flex; flex-direction: column; gap: 2px; }
  .choice-cards__text span { color: var(--color-text-muted); font-size: var(--text-sm); }

  /* Upload page: which account the files go to */
  .account-picker { border: 0; padding: 0; margin: 0; display: flex; flex-direction: column; align-items: center; gap: var(--space-2); }
  .account-picker__legend { float: left; width: 100%; margin-bottom: var(--space-2); text-align: center; font-weight: 500; font-size: var(--text-sm); color: var(--color-text-muted); }
  .account-picker__options { display: flex; flex-wrap: wrap; justify-content: center; gap: var(--space-2); }
  .account-picker__option {
    display: inline-flex; align-items: center; gap: var(--space-2); height: var(--control-height); padding: 0 var(--space-4); cursor: pointer;
    border: 1px solid var(--color-border-strong); border-radius: var(--control-radius); background: var(--color-surface); color: var(--color-text-muted); font-weight: 500;
    transition: border-color var(--duration-fast), background var(--duration-fast), color var(--duration-fast);
  }
  .account-picker__option:has(:checked) { color: var(--color-accent); }

  /* Account menu, for more than three accounts: a popover anchored to its button. */
  .account-menu__toggle { anchor-name: --account-menu; gap: 8px; }
  .account-menu {
    position-anchor: --account-menu; position-area: block-end span-inline-start; margin: var(--space-2) 0 0; inset: auto;
    min-width: 220px; max-height: 60vh; overflow: auto; padding: 4px;
    border: 1px solid var(--color-border-strong); border-radius: var(--radius); background: var(--color-surface); box-shadow: var(--shadow-large);
  }
  .account-menu__list { display: flex; flex-direction: column; }
  .account-menu__item { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); padding: var(--space-2) var(--space-3); border: 0; border-radius: var(--radius-small); background: none; color: var(--color-text); font: inherit; text-align: left; cursor: pointer; }
  .account-menu__item:not(.account-menu__item--active):hover { background: var(--color-surface-hover); }
  .account-menu__item--active { font-weight: 600; }
  .account-menu__item .icon { color: var(--color-accent); }
  /* "?" next to a number, with a popover explanation */
  .stat__label { display: block; } /* plain text, so the "?" follows the last word when the label wraps */
  .explain { flex: none; display: inline-grid; place-items: center; width: 20px; height: 20px; padding: 0; vertical-align: middle; border: 0; border-radius: 50%; background: none; color: var(--color-text-subtle); cursor: help; transition: color var(--duration-fast), background var(--duration-fast); }
  .explain:hover, .explain:focus-visible, .explain:has(+ :popover-open) { color: var(--color-accent); background: var(--color-accent-soft); }
  .explain .icon { display: block; }
  .explain__popover {
    position-area: block-end center; position-try-fallbacks: block-end span-inline-end, block-end span-inline-start, flip-block; inset: auto; margin: var(--space-2) 0;
    width: min(280px, calc(100vw - 32px)); padding: var(--space-2) var(--space-3);
    border: 1px solid var(--color-border-strong); border-radius: var(--radius); background: var(--color-surface); box-shadow: var(--shadow-large);
    color: var(--color-text-muted); font-size: var(--text-sm); font-weight: 400; line-height: 1.5; text-align: left; text-transform: none; letter-spacing: normal;
    /* Fades and slides in, and out again, without JavaScript. */
    opacity: 0; translate: 0 -4px; scale: 0.98;
    transition: opacity var(--duration-fast) var(--ease-out), translate var(--duration-fast) var(--ease-out), scale var(--duration-fast) var(--ease-out),
      display var(--duration-fast) allow-discrete, overlay var(--duration-fast) allow-discrete;
  }
  .explain__popover:popover-open { opacity: 1; translate: 0 0; scale: 1; }
  @starting-style { .explain__popover:popover-open { opacity: 0; translate: 0 -4px; scale: 0.98; } }
  .explain__more { color: var(--color-accent); white-space: nowrap; }
  .pagination { display: flex; justify-content: space-between; gap: var(--space-2); margin-top: var(--space-4); }
  .pagination > :only-child:last-child { margin-left: auto; }
  .badge { display: inline-flex; align-items: center; height: 20px; padding: 0 var(--space-2); border-radius: 999px; font-size: var(--text-xs); font-weight: 500; white-space: nowrap; background: var(--color-surface-muted); color: var(--color-text-muted); border: 1px solid var(--color-border); }
  .badge--positive { background: var(--color-positive-soft); color: var(--color-positive); border-color: transparent; }
  .badge--negative { background: var(--color-negative-soft); color: var(--color-negative); border-color: transparent; }
  .badge--warning { background: var(--color-warning-soft); color: var(--color-warning); border-color: transparent; }

  /* Segmented control */
  .segmented-nav { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 2px; min-height: var(--control-height); padding: 1px; /* with the 1px border, items sit 2px in */ background: var(--color-surface-muted); border: 1px solid var(--color-border); border-radius: var(--control-radius); }
  .segmented-nav__item { display: inline-flex; align-items: center; height: calc(var(--control-height) - 4px); padding: 0 var(--space-3); border-radius: calc(var(--control-radius) - 2px); /* 2px inside the nav, so the curves line up */ color: var(--color-text-muted); font-weight: 500; font-size: var(--text-sm); transition: color 0.12s, background 0.12s; }
  .segmented-nav__item:not(.segmented-nav__item--active):hover { color: var(--color-text); background: color-mix(in srgb, var(--color-surface) 50%, transparent); }
  .segmented-nav__item--active { background: var(--color-surface); color: var(--color-text); box-shadow: var(--shadow-small), 0 0 0 1px var(--color-border); }

  /* Filter chips */

  .filter-chips { display: flex; flex-wrap: wrap; gap: var(--space-2); }
  .filter-chip {
    display: inline-flex; align-items: center; gap: var(--space-2);
    height: 28px; padding: 0 var(--space-1) 0 var(--space-3);
    border: 1px solid var(--color-border-strong); border-radius: var(--control-radius);
    background: var(--color-surface); color: var(--color-text-muted);
    font-size: var(--text-sm); font-weight: 500; white-space: nowrap;
    box-shadow: var(--shadow-small);
    transition: background 0.12s, border-color 0.12s, color 0.12s;
  }
  .filter-chip:not(.filter-chip--active):hover { border-color: var(--color-text-subtle); color: var(--color-text); }
  .filter-chip__count {
    min-width: 20px; height: 20px; padding: 0 var(--space-1);
    display: inline-grid; place-items: center;
    border-radius: calc(var(--control-radius) - 4px); background: var(--color-surface-muted);
    color: var(--color-text-subtle); font-size: var(--text-xs); font-variant-numeric: tabular-nums;
  }
  .filter-chip--active { background: var(--color-accent-soft); border-color: color-mix(in srgb, var(--color-accent) 45%, transparent); color: var(--color-accent); }
  .filter-chip--active .filter-chip__count { background: var(--color-accent-fill); color: var(--color-accent-contrast); }
  .filter-chip--empty:not(.filter-chip--active) { opacity: 0.55; }

  /* Table */
  /* position: relative keeps hidden labels (like "Actions") inside the scroll box, so they don't widen the page. */
  .table-wrapper { position: relative; overflow-x: auto; margin: calc(var(--space-4) * -1) calc(var(--space-5) * -1) calc(var(--space-5) * -1); }
  .card__header + .card__body .table-wrapper { margin-top: 0; }
  .table { width: 100%; border-collapse: collapse; font-size: var(--text-base); }
  /* Design system page (admin) */
  .swatches { list-style: none; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: var(--space-3); }
  .swatch { display: flex; align-items: center; gap: var(--space-2); font-size: var(--text-sm); }
  .swatch__color { flex: none; width: 32px; height: 32px; border-radius: var(--radius-small); box-shadow: inset 0 0 0 1px var(--color-border); }
  .type-scale, .space-scale { list-style: none; padding: 0; display: flex; flex-direction: column; gap: var(--space-3); }
  .type-scale li, .space-scale li { display: grid; grid-template-columns: 9rem minmax(0, 1fr); align-items: baseline; gap: var(--space-3); }
  .space-scale li { align-items: center; }
  .space-scale__bar { height: 8px; border-radius: 2px; background: var(--color-accent); }
  .specimen { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-3); }
  .specimen--stack { flex-direction: column; align-items: stretch; gap: var(--space-5); }
  code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.92em; color: var(--color-text-muted); }
  .table__description { min-width: 16rem; } /* long DEGIRO texts get room; the table scrolls sideways instead */
  .table th { text-align: left; font-weight: 500; color: var(--color-text-subtle); font-size: var(--text-sm); padding: var(--space-3) var(--space-5) var(--space-2); border-bottom: 1px solid var(--color-border); white-space: nowrap; }
  .table td { padding: var(--space-2) var(--space-5); border-bottom: 1px solid var(--color-border); vertical-align: middle; }
  .table tbody tr:last-child td { border-bottom: 0; }
  .table tbody tr { transition: background 0.1s; }
  .table tbody tr:hover { background: var(--color-surface-muted); }
  .table .numeric { text-align: right; font-variant-numeric: tabular-nums; }
  .table__name { min-width: 220px; }
  /* A soft fade on the side where there is more to scroll to. It follows the scroll position
     (scroll-driven animation), so it disappears at the start and the end. */
  .scroll-fade { mask-image: linear-gradient(to right, transparent, #000 var(--fade-start), #000 calc(100% - var(--fade-end)), transparent); }
  @supports (animation-timeline: scroll()) {
    .scroll-fade { animation: scroll-fade linear both; animation-timeline: scroll(self inline); }
  }
  /* The fade grows over the first and last fifth of the scroll, so it never jumps. */
  @keyframes scroll-fade {
    0% { --fade-start: 0px; --fade-end: 16px; }
    20%, 80% { --fade-start: 16px; --fade-end: 16px; }
    100% { --fade-start: 16px; --fade-end: 0px; }
  }
  /* On a phone a segmented nav is one row you can swipe, instead of items breaking onto two lines. */
  @media (width <= 640px) {
    .segmented-nav { flex-wrap: nowrap; max-width: 100%; overflow-x: auto; scrollbar-width: none;
      mask-image: linear-gradient(to right, transparent, #000 var(--fade-start), #000 calc(100% - var(--fade-end)), transparent); }
    .segmented-nav__item { flex: none; scroll-snap-align: start; }
    .segmented-nav { scroll-snap-type: x proximity; }
    /* In a page header the account switcher gets a row of its own. */
    .page-header__actions { flex-wrap: wrap; }
    .page-header__actions > .segmented-nav, .page-header__actions > form:has(.segmented-nav) { order: 1; flex-basis: 100%; }
    @supports (animation-timeline: scroll()) {
      .segmented-nav { animation: scroll-fade linear both; animation-timeline: scroll(self inline); }
    }
  }

  /* On a phone, the columns you need least make room for value and result. */
  @media (width <= 640px) {
    .table__optional { display: none; }
    .table th, .table td { padding-inline: var(--space-3); }
    .table__name { min-width: 136px; }
  }
  .table__primary { display: block; font-weight: 500; color: var(--color-text); }
  a.table__primary:hover { color: var(--color-accent); }
  .table__secondary { display: block; color: var(--color-text-subtle); font-size: var(--text-xs); font-variant-numeric: tabular-nums; }
  .table form { display: inline; }

  /* List */
  .list { list-style: none; padding: 0; }
  .list__item { display: flex; justify-content: space-between; align-items: center; gap: var(--space-3); padding: var(--space-2) 0; border-bottom: 1px solid var(--color-border); }
  .list__item:first-child { padding-top: 0; }
  .list__item:last-child { border-bottom: 0; padding-bottom: 0; }
  .list__title { font-weight: 500; }
  .list__meta { color: var(--color-text-subtle); font-size: var(--text-xs); }

  /* Split bar: segments 2px apart, rounded ends; it reveals left to right without changing any size. */
  .split-bar { display: flex; flex-direction: column; gap: var(--space-4); }
  .split-bar__track { display: flex; gap: 2px; height: 12px; border-radius: 999px; overflow: hidden; animation: reveal-bar var(--duration-slow) var(--ease-out) both; }
  .split-bar__segment { flex: 0 0 var(--size); min-width: 2px; background: var(--color); transition: opacity var(--duration-fast); }
  .split-bar__segment:last-child { flex: 1; }
  .split-bar__track:hover .split-bar__segment:not(:hover) { opacity: 0.4; }
  .split-bar .chart-legend { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 240px), 1fr)); gap: var(--space-2) var(--space-6); }
  @keyframes reveal-bar { from { clip-path: inset(0 100% 0 0 round 999px); } to { clip-path: inset(0 0 0 0 round 999px); } }

  /* Growth: side by side on wide screens, one below the other on smaller ones. */
  .growth { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 480px), 1fr)); gap: var(--space-4); }
  .growth > turbo-frame { display: block; min-width: 0; }
  .growth > .card, .growth > turbo-frame > .card { height: 100%; }
  .growth__result { display: flex; align-items: baseline; flex-wrap: wrap; gap: var(--space-2); }
  .growth__amount { font-size: var(--text-figure-lg); font-weight: var(--weight-display); letter-spacing: -0.03em; line-height: 1.1; font-variant-numeric: tabular-nums; }
  .growth__label { color: var(--color-text-muted); }
  .growth__detail { margin-bottom: var(--space-4); color: var(--color-text-subtle); font-size: var(--text-sm); }
  .growth__form { margin-top: var(--space-4); flex: none; }
  .growth__form label { font-weight: 500; font-size: var(--text-sm); color: var(--color-text-muted); }
  .growth__form-label { flex-basis: 100%; }
  .growth__note a { color: var(--color-text-muted); text-decoration: underline; text-underline-offset: 2px; }
  .money-input { position: relative; display: inline-flex; align-items: center; }
  .money-input__unit { position: absolute; left: var(--space-3); color: var(--color-text-subtle); pointer-events: none; }
  .money-input input[type="number"] { width: 7rem; padding-left: 24px; font-variant-numeric: tabular-nums; }
  .growth__note { margin-top: var(--space-2); color: var(--color-text-subtle); font-size: var(--text-xs); }
  .stack-bar { display: flex; justify-content: flex-end; gap: 2px; height: 4px; margin-top: 4px; }
  .stack-bar__cost, .stack-bar__change { width: var(--size); border-radius: 999px; }
  .stack-bar__cost { background: var(--chart-bar); }
  .stack-bar__change { background: var(--color-positive); }
  .stack-bar__change--loss { background: repeating-linear-gradient(135deg, var(--color-negative) 0 2px, transparent 2px 4px); }
  .line-chart { display: flex; flex-direction: column; gap: var(--space-3); }
  .line-chart__frame { position: relative; display: grid; grid-template-columns: auto 1fr; grid-template-rows: var(--chart-height, 200px) 18px; column-gap: var(--space-2); }
  .line-chart__y-axis { position: relative; min-width: 44px; }
  .line-chart__y-label { position: absolute; right: 0; translate: 0 -50%; }
  .line-chart__x-axis { position: relative; grid-column: 2; }
  .line-chart__x-label { position: absolute; top: 4px; translate: -50% 0; }
  .line-chart__x-label:first-child { translate: 0 0; }
  .line-chart__y-label, .line-chart__x-label { color: var(--color-text-subtle); font-size: var(--text-xs); line-height: 1; font-variant-numeric: tabular-nums; white-space: nowrap; }
  .line-chart__plot { position: relative; min-width: 0; }
  .line-chart__svg { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }
  .line-chart__grid { stroke: var(--chart-grid); stroke-width: 1; vector-effect: non-scaling-stroke; }
  .line-chart__line { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; vector-effect: non-scaling-stroke; }
  .line-chart__line--dashed { stroke-dasharray: 5 5; }
  .line-chart__line--contributions, .line-chart__line--projected_contributions { stroke: var(--color-text-subtle); }
  .line-chart__line--value, .line-chart__line--projection { stroke: var(--chart-1); }
  .line-chart__area--value { fill: color-mix(in srgb, var(--chart-1) 14%, transparent); }
  .line-chart__band--range { fill: color-mix(in srgb, var(--chart-1) 12%, transparent); }
  .line-chart__dot, .line-chart__hover-dot { position: absolute; width: 8px; height: 8px; translate: -50% -50%; border-radius: 50%; background: var(--chart-1); box-shadow: 0 0 0 2px var(--color-surface); }
  .line-chart__hover-dot { left: var(--x); }
  /* The newest value of a dotted series gets its amount next to it. */
  .line-chart__dot-label { position: absolute; translate: 12px -50%; padding: 1px 6px; border-radius: var(--radius-small); background: var(--color-surface); color: var(--chart-1); font-size: var(--text-xs); font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; pointer-events: none; }
  .line-chart__dot-label--left { translate: calc(-100% - 10px) -50%; }
  .line-chart__hover-dot--contributions, .line-chart__hover-dot--projected_contributions { background: var(--color-text-subtle); }

  /* Hover: every date is a column; the crosshair, dots and tooltip of that column appear. */
  .line-chart__column { position: absolute; top: 0; bottom: 0; }
  .line-chart__hover { position: absolute; inset: 0; opacity: 0; pointer-events: none; }
  .line-chart__column:hover .line-chart__hover { opacity: 1; }
  .line-chart__column:hover { z-index: 1; }
  .line-chart__crosshair { position: absolute; top: 0; bottom: 0; left: var(--x); border-left: 1px solid var(--color-border-strong); }
  .line-chart__tooltip {
    position: absolute; top: 0; left: calc(var(--x) + 12px); display: flex; flex-direction: column; gap: 2px; width: max-content; max-width: 280px;
    padding: var(--space-2) var(--space-3); border: 1px solid var(--color-border-strong); border-radius: var(--radius-small); background: var(--color-surface); box-shadow: var(--shadow-large);
    color: var(--color-text-muted); font-size: var(--text-xs); font-variant-numeric: tabular-nums;
  }
  .line-chart__tooltip strong { color: var(--color-text); }
  .line-chart__tooltip > span { display: flex; align-items: center; gap: var(--space-1); }
  .line-chart__hover--left .line-chart__tooltip { left: auto; right: calc(100% - var(--x) + 12px); }

  .line-chart__legend { display: flex; flex-wrap: wrap; gap: var(--space-2) var(--space-4); color: var(--color-text-muted); font-size: var(--text-sm); }
  .line-chart__key { display: inline-flex; align-items: center; gap: var(--space-2); }
  .line-chart__swatch { flex: none; width: 16px; height: 0; border-top: 2px solid var(--chart-1); }
  .line-chart__swatch--contributions, .line-chart__swatch--projected_contributions { border-color: var(--color-text-subtle); }
  .line-chart__swatch--dashed { border-top-style: dashed; }
  .line-chart__swatch--band { height: 8px; border: 0; border-radius: 2px; background: color-mix(in srgb, var(--chart-1) 18%, transparent); }
  .chart-legend { list-style: none; padding: 0; display: flex; flex-direction: column; gap: var(--space-2); }
  .chart-legend__item { display: grid; grid-template-columns: 8px 1fr auto; align-items: center; gap: var(--space-2); font-size: var(--text-sm); }
  .chart-legend__swatch { width: 8px; height: 8px; border-radius: 2px; }
  .chart-legend__label { color: var(--color-text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .chart-legend__value { font-variant-numeric: tabular-nums; color: var(--color-text-muted); }

  /* Column chart */
  .bar-chart { display: flex; flex-direction: column; gap: var(--space-2); }
  .bar-chart__plot {
    display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 2px;
    height: 200px;
    padding-top: var(--space-5);
    border-bottom: 1px solid var(--color-border-strong);
    background: repeating-linear-gradient(to top, var(--chart-grid) 0 1px, transparent 1px 25%);
    background-origin: content-box;
    background-clip: content-box;
  }
  .bar-chart__column { display: flex; flex-direction: column; justify-content: flex-end; align-items: center; min-width: 0; height: 100%; }
  .bar-chart__bar {
    width: min(24px, 70%); height: var(--size); min-height: 2px;
    background: var(--chart-bar); border-radius: 4px 4px 0 0;
    transition: background var(--duration-fast);
    animation: grow-up var(--duration-slow) var(--ease-out) both;
  }
  /* Bars grow one after the other. Browsers without sibling-index() simply grow them together. */
  .bar-chart__column { --index: sibling-index(); }
  .bar-chart__bar { animation-delay: calc(var(--index) * 25ms); }
  .bar-chart__value {
    margin-bottom: 4px;
    font-size: var(--text-xs); font-weight: 500; color: var(--color-text); font-variant-numeric: tabular-nums;
    white-space: nowrap; opacity: 0; transform: translateY(2px); transition: opacity 0.12s, transform 0.12s;
    pointer-events: none;
  }
  .bar-chart__column--highlighted .bar-chart__bar, .bar-chart__column:hover .bar-chart__bar { background: var(--chart-bar-highlight); }
  .bar-chart__column--highlighted .bar-chart__value, .bar-chart__column:hover .bar-chart__value { opacity: 1; transform: none; }
  /* Without a chosen bar, the default highlight steps back while you hover another bar. A chosen (active) bar stays. */
  .bar-chart__plot:hover .bar-chart__column--highlighted:not(.bar-chart__column--active):not(:hover) .bar-chart__value { opacity: 0; }
  .bar-chart__plot:hover .bar-chart__column--highlighted:not(.bar-chart__column--active):not(:hover) .bar-chart__bar { background: var(--chart-bar); }
  .bar-chart__axis { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 2px; }
  .bar-chart__label { font-size: var(--text-xs); color: var(--color-text-subtle); text-align: center; white-space: nowrap; }
  /* Many columns (like 30 days): only every 7th label, so they never run into each other. */
  .bar-chart__axis:has(> :nth-child(15)) > :not(:nth-child(7n+1)) { visibility: hidden; }

  /* Allocation list */
  .allocation-list { list-style: none; padding: 0; display: flex; flex-direction: column; gap: var(--space-3); }
  .allocation-list__meta { display: flex; justify-content: space-between; gap: var(--space-3); font-size: var(--text-sm); }
  .allocation-list__label { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .allocation-list__label a:hover { color: var(--color-accent); }
  .allocation-list__value { color: var(--color-text-muted); white-space: nowrap; font-variant-numeric: tabular-nums; }
  .allocation-list__detail { display: flex; align-items: center; gap: var(--space-1); flex-wrap: wrap; margin-top: 2px; color: var(--color-text-subtle); font-size: var(--text-xs); }
  .allocation-list__track { display: block; height: 4px; margin-top: var(--space-2); background: var(--color-surface-muted); border-radius: 999px; overflow: hidden; }
  .allocation-list__fill { display: block; height: 100%; width: var(--size); background: var(--chart-1); border-radius: 999px; transform-origin: left; animation: grow-right var(--duration-slow) var(--ease-out) both; }

  /* Empty state: one look everywhere. Large for a page, compact inside a card. */
  .empty-state { display: flex; flex-direction: column; align-items: center; text-align: center; gap: var(--space-2); }
  .empty-state--large { padding: var(--space-7) var(--space-5); background: var(--color-surface); border: 1px dashed var(--color-border-strong); border-radius: var(--radius-large); }
  .empty-state--compact { padding: var(--space-5) var(--space-3); }
  .empty-state__icon { display: grid; place-items: center; width: 48px; height: 48px; margin-bottom: var(--space-1); border-radius: 14px; background: var(--color-accent-soft); color: var(--color-accent); }
  .empty-state--compact .empty-state__icon { width: 36px; height: 36px; border-radius: 10px; }
  .empty-state__title { font-size: var(--text-md); font-weight: 600; text-wrap: balance; }
  .empty-state--compact .empty-state__title { font-size: var(--text-base); font-weight: 500; color: var(--color-text-muted); }
  .empty-state__body { max-width: 440px; color: var(--color-text-muted); text-wrap: pretty; }
  .empty-state__action { display: flex; flex-direction: column; align-items: center; gap: var(--space-3); margin-top: var(--space-3); }

  /* Onboarding: a blurred preview of the page, with a card on top */
  .onboarding { position: relative; display: grid; min-height: 560px; }
  .onboarding > * { grid-area: 1 / 1; }
  /* The preview is decoration: its charts stand still, so only the card moves. */
  .onboarding__preview *, .onboarding__preview *::before { animation: none !important; transition: none !important; }
  .onboarding__preview { display: flex; flex-direction: column; gap: var(--space-4); filter: blur(3px) saturate(0.7); opacity: 0.55; pointer-events: none; user-select: none; mask: linear-gradient(to bottom, #000 40%, transparent); }
  .onboarding__card {
    align-self: start; justify-self: center; margin-top: clamp(24px, 8vh, 80px);
    width: min(520px, 100%);
    display: flex; flex-direction: column; gap: var(--space-4);
    padding: var(--space-2) var(--space-2) var(--space-5);
    background: var(--color-surface); border: 1px solid var(--color-border); border-radius: 20px; box-shadow: var(--shadow-large);
    animation: rise var(--duration-slow) var(--ease-out) both;
  }
  .onboarding__card .empty-state--large { border: 0; background: none; padding-bottom: var(--space-2); }
  .onboarding__card .onboarding-steps { margin-inline: var(--space-5); }
  .mini-steps { margin: var(--space-3) auto 0; padding-left: var(--space-5); max-width: 380px; text-align: left; display: flex; flex-direction: column; gap: var(--space-2); color: var(--color-text-muted); }
  .mini-steps strong { color: var(--color-text); font-weight: 500; }

  .skeleton-table { display: flex; flex-direction: column; }
  .skeleton-table__row { display: grid; grid-template-columns: 1.6fr 0.6fr 1fr auto; align-items: center; gap: var(--space-4); padding: 12px 0; border-bottom: 1px solid var(--color-border); }
  .skeleton-table__row:last-child { border-bottom: 0; }
  .skeleton-table__name { font-weight: 500; }
  .skeleton { display: block; height: 8px; border-radius: 999px; background: var(--color-surface-muted); }
  .skeleton--short { width: 60%; }

  /* Getting started steps */
  .onboarding-steps { list-style: none; padding: 0; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--space-2); counter-reset: none; }
  .onboarding-steps__step { display: flex; align-items: center; gap: var(--space-2); padding: var(--space-2) var(--space-3); border-radius: var(--radius); background: var(--color-surface-muted); color: var(--color-text-muted); font-size: var(--text-sm); font-weight: 500; }
  .onboarding-steps__marker { flex: none; display: grid; place-items: center; width: 24px; height: 24px; border-radius: 50%; border: 1px solid var(--color-border-strong); background: var(--color-surface); font-size: var(--text-xs); font-weight: 600; }
  .onboarding-steps__step--current { background: var(--color-accent-soft); color: var(--color-accent); }
  .onboarding-steps__step--current .onboarding-steps__marker { border-color: var(--color-accent); color: var(--color-accent); }
  .onboarding-steps__step--done { color: var(--color-text); }
  .onboarding-steps__step--done .onboarding-steps__marker { border-color: transparent; background: var(--color-positive); color: var(--color-positive-contrast); }
  @media (width <= 640px) { .onboarding-steps { grid-template-columns: 1fr; } }

  /* Upload: one big, inviting drop zone. The file input covers the whole zone. */
  .dropzone-form { display: flex; flex-direction: column; gap: var(--space-4); }
  .dropzone {
    position: relative;
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: var(--space-3);
    min-height: max(320px, 52vh);
    padding: var(--space-6);
    border: 2px dashed var(--color-border-strong); border-radius: 24px;
    background:
      radial-gradient(ellipse 60% 50% at 50% 40%, var(--color-accent-soft), transparent 70%),
      var(--color-surface);
    text-align: center; cursor: pointer;
    transition: border-color var(--duration) var(--ease-out), background-color var(--duration), padding var(--duration) var(--ease-out);
  }
  .dropzone:hover { border-color: var(--color-accent); }
  .dropzone:has(.dropzone__input:focus-visible) { outline: 2px solid var(--color-accent); outline-offset: 3px; }
  .dropzone__input { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; }
  .dropzone__icon { display: grid; place-items: center; width: 72px; height: 72px; border-radius: 22px; background: var(--color-surface); color: var(--color-accent); box-shadow: var(--shadow-large); transition: scale var(--duration) var(--ease-out); }
  .dropzone:hover .dropzone__icon { scale: 1.06; }
  .dropzone__title { font-size: clamp(22px, 3vw, 30px); font-weight: var(--weight-display); letter-spacing: -0.02em; }
  .dropzone__hint { color: var(--color-text-muted); }
  .dropzone__icon-ready, .dropzone__title--ready { display: none; }
  /* A file is chosen: the input is :valid now. */
  .dropzone:has(.dropzone__input:valid) { border-style: solid; border-color: var(--color-positive); background: radial-gradient(ellipse 60% 50% at 50% 40%, var(--color-positive-soft), transparent 70%), var(--color-surface); }
  .dropzone:has(.dropzone__input:valid) .dropzone__icon { color: var(--color-positive); }
  .dropzone:has(.dropzone__input:valid) :is(.dropzone__icon-empty, .dropzone__title--empty) { display: none; }
  .dropzone:has(.dropzone__input:valid) :is(.dropzone__icon-ready, .dropzone__title--ready) { display: block; animation: rise var(--duration) var(--ease-out); }
  /* The button sits on top of the zone (same grid cell) and only appears once a file is chosen. */
  .dropzone-stack { display: grid; }
  .dropzone-stack > * { grid-area: 1 / 1; }
  .dropzone__submit {
    z-index: 1; align-self: end; justify-self: center; margin-bottom: clamp(32px, 9vh, 72px);
    display: none; opacity: 0; translate: 0 8px;
    transition: opacity var(--duration) var(--ease-out), translate var(--duration) var(--ease-out), display var(--duration) allow-discrete;
  }
  .dropzone-stack:has(.dropzone__input:valid) .dropzone__submit { display: inline-flex; opacity: 1; translate: 0 0; }
  @starting-style {
    .dropzone-stack:has(.dropzone__input:valid) .dropzone__submit { opacity: 0; translate: 0 8px; }
  }
  .dropzone-stack:has(.dropzone__input:valid) .dropzone { padding-bottom: calc(var(--space-6) + 96px); }
  .dropzone-form__note { text-align: center; }

  .how-to { background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius-large); scroll-margin-top: 80px; }
  .how-to__summary { display: flex; align-items: center; gap: var(--space-2); padding: var(--space-4) var(--space-5); font-weight: 600; cursor: pointer; list-style: none; }
  .how-to__summary::-webkit-details-marker { display: none; }
  .how-to::details-content { block-size: 0; overflow: clip; transition: block-size var(--duration) var(--ease-in-out), content-visibility var(--duration) allow-discrete; }
  .how-to[open]::details-content { block-size: auto; }
  .how-to__body { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 300px), 1fr)); gap: var(--space-5); padding: 0 var(--space-5) var(--space-5); }

  /* Sidebar: start here */
  .sidebar__dot { width: 8px; height: 8px; margin-left: auto; border-radius: 50%; background: var(--color-accent); box-shadow: 0 0 0 3px var(--color-accent-soft); animation: pulse 2s var(--ease-in-out) infinite; }

  /* Import */
  .celebration { font-size: var(--text-md); font-weight: 600; margin-bottom: var(--space-4); }
  @keyframes grow-up { from { height: 0; } }
  @keyframes pulse { 50% { box-shadow: 0 0 0 6px transparent; } }
  @keyframes rise { from { opacity: 0; translate: 0 16px; } }
  @keyframes draw { to { stroke-dashoffset: 0; } }
  @keyframes float { 50% { transform: translateY(-6px); } }
  @keyframes flatten { to { transform: none; } }
  @keyframes fade-in-plain { from { opacity: 0; } }
  @keyframes grow-right { from { transform: scaleX(0); } }
  @keyframes reveal { from { --reveal: 0deg; } }
  .steps__title { font-size: var(--text-sm); margin-bottom: var(--space-2); }
  .steps { padding-left: var(--space-5); display: flex; flex-direction: column; gap: var(--space-2); margin-bottom: var(--space-4); color: var(--color-text-muted); }
  .steps strong { color: var(--color-text); font-weight: 500; }

  /* Dialog: native <dialog>, animated in and out with @starting-style and allow-discrete */
  .dialog {
    width: min(440px, calc(100vw - 32px));
    padding: 0;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-large);
    background: var(--color-surface);
    color: var(--color-text);
    box-shadow: var(--shadow-large);
    opacity: 0;
    translate: 0 8px;
    scale: 0.97;
    transition:
      opacity var(--duration) var(--ease-out),
      translate var(--duration) var(--ease-out),
      scale var(--duration) var(--ease-out),
      overlay var(--duration) allow-discrete,
      display var(--duration) allow-discrete;
  }
  .dialog[open] { opacity: 1; translate: 0 0; scale: 1; }
  @starting-style {
    .dialog[open] { opacity: 0; translate: 0 8px; scale: 0.97; }
  }
  .dialog::backdrop {
    background: rgb(10 10 12 / 0);
    backdrop-filter: blur(0);
    transition: background var(--duration) var(--ease-out), backdrop-filter var(--duration), overlay var(--duration) allow-discrete, display var(--duration) allow-discrete;
  }
  .dialog[open]::backdrop { background: rgb(10 10 12 / 0.35); backdrop-filter: blur(2px); }
  @starting-style {
    .dialog[open]::backdrop { background: rgb(10 10 12 / 0); backdrop-filter: blur(0); }
  }
  .dialog__body { display: flex; flex-direction: column; gap: var(--space-3); padding: var(--space-5); text-align: start; } /* a dialog can sit in a right-aligned table cell */
  .dialog__title { font-size: var(--text-md); font-weight: 600; }
  .dialog__description { color: var(--color-text-muted); }
  .dialog__actions { display: flex; justify-content: flex-end; gap: var(--space-2); padding: var(--space-3) var(--space-5); background: var(--color-surface-muted); border-top: 1px solid var(--color-border); }
  .dialog__actions form { display: contents; }

  /* Theme picker */
  .theme-picker { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--space-3); max-width: 520px; }
  .theme-picker__option {
    display: flex; flex-direction: column; gap: var(--space-2);
    padding: var(--space-2); border: 1px solid var(--color-border-strong); border-radius: var(--radius);
    background: var(--color-surface); cursor: pointer; text-align: left;
    transition: border-color 0.12s, box-shadow 0.12s;
  }
  .theme-picker__option:not(.theme-picker__option--active):hover { border-color: var(--color-text-subtle); }
  .theme-picker__option--active { border-color: var(--color-accent); box-shadow: 0 0 0 3px var(--color-accent-soft); }
  .theme-picker__label { display: flex; align-items: center; gap: var(--space-2); padding: 0 var(--space-1) var(--space-1); font-size: var(--text-sm); font-weight: 500; color: var(--color-text-muted); }
  .theme-picker__option--active .theme-picker__label { color: var(--color-text); }

  /* A small drawing of the app in each theme. Fixed colors: it must look the same in every theme. */
  .theme-picker__preview { position: relative; display: flex; flex-direction: column; gap: var(--space-2); height: 64px; padding: var(--space-3) var(--space-3) var(--space-3) 36px; border-radius: var(--radius-small); overflow: hidden; }
  .theme-picker__preview--light { background: #f8f7f4; border: 1px solid #e7e5df; }
  .theme-picker__preview--dark { background: #0d0e10; border: 1px solid #232428; }
  .theme-picker__preview--system { background: linear-gradient(105deg, #f8f7f4 50%, #0d0e10 50%); border: 1px solid #d9d6ce; }
  .theme-picker__bar { position: absolute; inset: 0 auto 0 0; width: 24px; }
  .theme-picker__line { height: 8px; border-radius: 3px; }
  .theme-picker__line--short { width: 60%; }
  .theme-picker__preview--light .theme-picker__bar { background: #f3f2ee; border-right: 1px solid #e7e5df; }
  .theme-picker__preview--light .theme-picker__line { background: #ffffff; box-shadow: 0 0 0 1px #e7e5df; }
  .theme-picker__preview--dark .theme-picker__bar { background: #0a0b0c; border-right: 1px solid #232428; }
  .theme-picker__preview--dark .theme-picker__line { background: #1a1b1f; }
  .theme-picker__preview--system .theme-picker__bar { background: #f3f2ee; border-right: 1px solid #e7e5df; }
  .theme-picker__preview--system .theme-picker__line { background: linear-gradient(105deg, #ffffff 50%, #1a1b1f 50%); }
  .theme-picker__preview .theme-picker__line--accent { width: 40%; background: #c15f3c; box-shadow: none; }


  /* ───── Marketing site ───── */
  .marketing { --page-max: 1120px; }
  /* Clip, not hidden: decoration that pokes out never makes the page scroll sideways, and sticky still works. */
  .marketing main { display: flex; flex-direction: column; gap: clamp(64px, 10vw, 120px); padding: 0 var(--space-5) var(--space-7); overflow-x: clip; }

  .site-header {
    position: sticky; top: 0; z-index: 10;
    background: color-mix(in srgb, var(--color-bg) 80%, transparent);
    backdrop-filter: saturate(1.8) blur(12px); -webkit-backdrop-filter: saturate(1.8) blur(12px);
    border-bottom: 1px solid color-mix(in srgb, var(--color-border) 70%, transparent);
  }
  .site-header__inner { max-width: var(--page-max); margin: 0 auto; padding: var(--space-3) var(--space-5); display: flex; align-items: center; gap: var(--space-5); }
  .site-header__brand { display: flex; align-items: center; gap: var(--space-2); font-weight: 600; font-size: var(--text-md); letter-spacing: -0.01em; }
  .site-header__nav { display: flex; gap: var(--space-5); margin-inline: auto; }
  .site-header__nav a { color: var(--color-text-muted); font-weight: 500; transition: color var(--duration-fast); }
  .site-header__nav a:hover { color: var(--color-text); }
  .site-header__actions { display: flex; gap: var(--space-2); }
  @media (width <= 760px) {
    .site-header__nav { display: none; }
    .site-header__actions { margin-left: auto; }
  }

  .announcement { display: inline-flex; align-items: center; gap: var(--space-2); max-width: 100%; width: fit-content; padding: 4px 12px 4px 4px; border: 1px solid var(--color-border); border-radius: 999px; background: var(--color-surface); color: var(--color-text-muted); font-size: var(--text-sm); transition: border-color var(--duration-fast) var(--ease-out), color var(--duration-fast) var(--ease-out); }
  .announcement:hover { border-color: var(--color-border-strong); color: var(--color-text); }
  .announcement__label { padding: 2px 8px; border-radius: 999px; background: var(--color-accent-soft); color: var(--color-accent); font-weight: 600; }
  .announcement__text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .announcement .icon { flex: none; transition: translate var(--duration-fast) var(--ease-out); }
  .announcement:hover .icon { translate: 2px 0; }
  .eyebrow { display: inline-flex; align-items: center; gap: var(--space-2); width: fit-content; padding: var(--space-1) var(--space-3); border-radius: 999px; background: var(--color-accent-soft); color: var(--color-accent); font-size: var(--text-sm); font-weight: 600; }

  /* Hero */
  /* minmax(0, 1fr): a long line (like the announcement) shortens itself instead of making the page wider. */
  .hero { max-width: var(--page-max); margin: 0 auto; width: 100%; padding-top: clamp(48px, 8vw, 96px); display: grid; grid-template-columns: minmax(0, 1fr); gap: clamp(40px, 6vw, 72px); }
  .hero__text { display: flex; flex-direction: column; align-items: center; text-align: center; gap: var(--space-4); width: 100%; max-width: 720px; margin: 0 auto; }
  .hero__title { font-size: clamp(40px, 7vw, 72px); line-height: 1.02; letter-spacing: -0.04em; font-weight: var(--weight-display); text-wrap: balance; }
  .hero { position: relative; }
  .hero__title em {
    font-style: normal; color: var(--color-accent);
    background: linear-gradient(100deg, var(--color-accent) 0 40%, light-dark(#f2b48f, #ffc9a6) 50%, var(--color-accent) 60% 100%) 0 0 / 250% 100% text;
    -webkit-text-fill-color: transparent; animation: shimmer 6s var(--ease-in-out) 1s infinite;
  }
  @keyframes shimmer { 0%, 30% { background-position: 100% 0; } 70%, 100% { background-position: 0 0; } }

  .hero__subtitle { font-size: clamp(16px, 2vw, 19px); line-height: 1.55; color: var(--color-text-muted); max-width: 600px; text-wrap: pretty; }
  .hero__actions { display: flex; gap: var(--space-3); flex-wrap: wrap; justify-content: center; margin-top: var(--space-2); }
  /* On phones the two buttons are equally wide: side by side when they fit, else stacked over the full width. */
  @media (width <= 760px) {
    .hero__actions { align-self: stretch; }
    .hero__actions .button { flex: 1 1 140px; }
  }
  .hero__fineprint { font-size: var(--text-sm); color: var(--color-text-subtle); }
  .hero__text > * { animation: rise var(--duration-slow) var(--ease-out) both; animation-delay: calc(var(--index) * 70ms); --index: sibling-index(); }

  /* A small, live version of the app (real components, sample data) */
  .hero__preview { position: relative; perspective: 1800px; animation: rise 900ms var(--ease-out) 250ms both; }
  .preview { position: relative; background: var(--color-bg); border: 1px solid var(--color-border-strong); border-radius: 16px; box-shadow: var(--shadow-large); overflow: hidden; transform-origin: 50% 0; }

  .preview__bar { display: flex; gap: var(--space-2); padding: var(--space-3) var(--space-4); border-bottom: 1px solid var(--color-border); background: var(--color-sidebar); }
  .preview__bar span { width: 12px; height: 12px; border-radius: 50%; background: var(--color-border-strong); }
  .preview__body { display: flex; flex-direction: column; gap: var(--space-4); padding: var(--space-5); }
  .preview__charts { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 320px), 1fr)); gap: var(--space-4); }
  .preview__charts > :first-child { grid-column: span 2; }
  @media (width <= 760px) { .preview__charts > :first-child { grid-column: auto; } }

  /* The growth line draws itself, the range fades in. */
  .preview .line-chart__line--projection, .preview .line-chart__line--value { stroke-dasharray: 1; stroke-dashoffset: 1; animation: draw 1.6s var(--ease-out) 0.9s forwards; }
  .preview .line-chart__line--projection { animation-delay: 1.6s; }
  .preview .line-chart__band, .preview .line-chart__area { animation: fade-in-plain 1s var(--ease-out) 2s both; }

  /* Floating notes on top of the screenshot */
  .hero__chip { position: absolute; z-index: 1; display: inline-flex; align-items: center; gap: var(--space-2); padding: 8px 12px; border: 1px solid var(--color-border); border-radius: 999px; background: var(--color-surface); box-shadow: var(--shadow-large); font-size: var(--text-sm); font-weight: 600; white-space: nowrap; animation: rise 600ms var(--ease-out) both, float 6s ease-in-out infinite; }
  .hero__chip .icon { color: var(--color-accent); }
  .hero__chip--result { top: 18%; left: -2%; color: var(--color-positive); animation-delay: 1.5s, 2.1s; }
  .hero__chip--dividend { bottom: 14%; right: -2%; animation-delay: 1.9s, 2.5s; animation-duration: 600ms, 7s; }
  .hero__chip--future { top: 46%; right: -3%; color: var(--color-accent); animation-delay: 2.3s, 2.9s; animation-duration: 600ms, 8s; }
  @media (width <= 760px) { .hero__chip { display: none; } }

  /* In perspective, and it lays down flat while you scroll to it (where the browser supports scroll timelines).
     Not on phones: there the preview fills the screen, and growing while you scroll feels like the page zooms. */
  @supports (animation-timeline: view()) {
    @media (width > 760px) {
      .preview { transform: rotateX(16deg) scale(0.96); animation: flatten linear both; animation-timeline: view(); animation-range: cover 20% cover 55%; } /* starts once it is well in view, so you see it tilt */
    }
  }

  /* Sections */
  .section { max-width: var(--page-max); margin: 0 auto; width: 100%; display: flex; flex-direction: column; gap: var(--space-6); scroll-margin-top: 80px; }
  .section--narrow { max-width: 760px; }
  .section__header { display: flex; flex-direction: column; align-items: center; text-align: center; gap: var(--space-3); max-width: 640px; margin: 0 auto; }
  .section__title, .cta-band__title { font-size: clamp(28px, 4vw, 40px); font-weight: var(--weight-display); line-height: 1.1; letter-spacing: -0.03em; text-wrap: balance; }
  .section__subtitle { font-size: var(--text-md); color: var(--color-text-muted); text-wrap: pretty; }

  .bento { list-style: none; padding: 0; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--space-4); }
  .bento__card {
    position: relative; display: flex; flex-direction: column; gap: var(--space-2); padding: var(--space-5); overflow: hidden;
    background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius-large); box-shadow: var(--shadow);
    transition: translate var(--duration) var(--ease-out), box-shadow var(--duration), border-color var(--duration);
  }
  .bento__card:hover { translate: 0 -3px; box-shadow: var(--shadow-large); border-color: color-mix(in srgb, var(--color-accent) 40%, var(--color-border)); }
  .bento__card--growth { grid-column: span 2; }
  .bento__big { margin-top: auto; padding-top: var(--space-4); font-size: clamp(44px, 7vw, 76px); font-weight: var(--weight-display); letter-spacing: -0.04em; line-height: 1; color: var(--color-accent); }
  .bento__caption { color: var(--color-text-muted); }
  .bento__visual { margin-top: auto; padding-top: var(--space-4); }
  .bento__visual .bar-chart__plot { height: 112px; }
  @media (width <= 900px) { .bento { grid-template-columns: minmax(0, 1fr); } .bento__card--growth { grid-column: auto; } }
  .feature__icon { display: grid; place-items: center; width: 36px; height: 36px; margin-bottom: var(--space-2); border-radius: var(--radius); background: var(--color-accent-soft); color: var(--color-accent); }
  .feature__title { font-size: var(--text-md); }
  .feature__body { color: var(--color-text-muted); }

  .steps-grid { list-style: none; padding: 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 260px), 1fr)); gap: var(--space-4); }
  .steps-grid { position: relative; }
  .step { position: relative; display: flex; flex-direction: column; gap: var(--space-2); padding: var(--space-5); }
  .step__number { display: grid; place-items: center; width: 44px; height: 44px; margin-bottom: var(--space-2); border-radius: 50%; background: var(--color-accent-fill); color: var(--color-accent-contrast); font-size: var(--text-md); font-weight: var(--weight-display); box-shadow: 0 0 0 6px var(--color-accent-soft); }
  /* The line between the steps draws itself while you scroll by. */
  @media (width > 900px) {
    .steps-grid::before {
      content: ""; position: absolute; top: calc(var(--space-5) + 21px); height: 2px; z-index: -1; background: var(--color-accent); transform-origin: left;
      /* From the centre of the first circle to the centre of the last: three equal columns with two gaps. */
      left: calc(var(--space-5) + 22px);
      right: calc((100% - 2 * var(--space-4)) / 3 - var(--space-5) - 22px);
    }
    @supports (animation-timeline: view()) {
      .steps-grid::before { animation: grow-right linear both; animation-timeline: view(); animation-range: entry 20% cover 50%; }
    }
  }
  .step__title { font-size: var(--text-md); }
  .step__body { color: var(--color-text-muted); }

  /* Always dark, for contrast: color-scheme makes every token pick its dark value. */
  .privacy-band {
    color-scheme: dark; color: var(--color-text);
    display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 380px), 1fr)); align-items: center; gap: var(--space-6); padding: clamp(24px, 5vw, 56px);
    background: var(--color-surface);
    border: 1px solid var(--color-border); border-radius: 20px; box-shadow: var(--shadow-large);
  }
  .privacy-band .section__subtitle { color: var(--color-text-muted); }
  .privacy-band .check-list .icon { color: var(--color-positive); }
  .privacy-band > div { display: flex; flex-direction: column; gap: var(--space-3); }
  .check-list { list-style: none; padding: 0; display: flex; flex-direction: column; gap: var(--space-3); font-size: var(--text-md); }
  .check-list li { display: flex; align-items: center; gap: var(--space-3); }
  .check-list .icon { flex: none; padding: var(--space-1); box-sizing: content-box; border-radius: 50%; background: var(--color-positive-soft); color: var(--color-positive); }

  /* FAQ: native <details>, one open at a time (name="faq"), height animates to auto */
  .faq { display: flex; flex-direction: column; border-top: 1px solid var(--color-border); }
  .faq__item { border-bottom: 1px solid var(--color-border); }
  .faq__question { display: flex; justify-content: space-between; align-items: center; gap: var(--space-4); padding: var(--space-4) 0; font-size: var(--text-md); font-weight: 600; cursor: pointer; list-style: none; }
  .faq__question::-webkit-details-marker { display: none; }
  .faq__question .icon { color: var(--color-text-subtle); transition: rotate var(--duration) var(--ease-out); }
  .faq__item[open] .faq__question .icon { rotate: 45deg; color: var(--color-accent); }
  .faq__item::details-content { block-size: 0; overflow: clip; transition: block-size var(--duration) var(--ease-in-out), content-visibility var(--duration) allow-discrete; }
  .faq__item[open]::details-content { block-size: auto; }
  .faq__answer { padding-bottom: var(--space-4); color: var(--color-text-muted); font-size: var(--text-md); line-height: 1.6; }

  .cta-band { position: relative; overflow: hidden; }
  .cta-band__backdrop { position: absolute; inset: -40px -20px auto; z-index: -1; padding: var(--space-5); filter: blur(7px) saturate(1.1); opacity: 0.45; pointer-events: none;
    mask-image: radial-gradient(ellipse 70% 65% at 50% 45%, transparent 20%, #000 75%); transform: rotate(-4deg) scale(1.08); animation: drift 24s var(--ease-in-out) infinite alternate; }
  @keyframes drift { from { translate: -2% 0; } to { translate: 2% -3%; } }
  .cta-band__stage { position: relative; display: grid; place-items: center; width: min(100%, 520px); height: 150px; }
  .cta-band__sprout { position: relative; display: block; width: 72px; height: 72px; border-radius: 17px; box-shadow: var(--shadow-large); }
  /* A soft ring that breathes behind the sprout. */
  .cta-band__sprout::before { content: ""; position: absolute; inset: -18px; z-index: -1; border-radius: 30px; background: radial-gradient(closest-side, var(--color-accent-soft), transparent); animation: breathe 4s var(--ease-in-out) infinite alternate; }
  @keyframes breathe { from { scale: 0.9; opacity: 0.6; } to { scale: 1.15; opacity: 1; } }
  .cta-band__chip--result { top: 6%; left: 2%; color: var(--color-positive); animation-delay: 1.2s, 1.8s; }
  .cta-band__chip--dividend { bottom: 4%; left: 10%; animation-delay: 1.5s, 2.2s; animation-duration: 600ms, 7s; }
  .cta-band__chip--future { top: 30%; right: 0; color: var(--color-accent); animation-delay: 1.8s, 2.6s; animation-duration: 600ms, 8s; }
  /* Animated logo, like a seedling coming up:
     1. the stem grows out of the ground (its path starts at the top, so a negative offset draws it upward);
     2. the light leaf unfolds from where it meets the stem, turning open and overshooting a little;
     3. the orange leaf does the same, a moment later;
     4. then the sprout sways slowly around its foot, and the orange leaf flutters on a rhythm of its own. */
  .logo--animated .logo__stem { stroke-dasharray: 1; stroke-dashoffset: -1; animation: draw 600ms var(--ease-out) 200ms forwards; }
  .logo--animated .logo__ink, .logo--animated .logo__leaf { transform-box: fill-box; scale: 0; }
  .logo--animated .logo__ink { transform-origin: 100% 85%; animation: unfold-light 600ms var(--ease-out) 700ms forwards, flutter-light 4.6s var(--ease-in-out) 1.3s infinite alternate; }
  .logo--animated .logo__leaf { transform-origin: 10% 90%; animation: unfold-orange 600ms var(--ease-out) 900ms forwards, flutter-orange 3.7s var(--ease-in-out) 1.5s infinite alternate; }
  .logo--animated .logo__sprout { transform-box: fill-box; transform-origin: 51% 100%; animation: sway 6s var(--ease-in-out) 1.5s infinite alternate both; }
  @keyframes unfold-light { 0% { scale: 0; rotate: -25deg; } 70% { scale: 1.06; rotate: 3deg; } 100% { scale: 1; rotate: 0deg; } }
  @keyframes unfold-orange { 0% { scale: 0; rotate: 30deg; } 70% { scale: 1.06; rotate: -3deg; } 100% { scale: 1; rotate: 0deg; } }
  @keyframes flutter-light { from { rotate: 0deg; } to { rotate: -3deg; } }
  @keyframes flutter-orange { from { rotate: 0deg; } to { rotate: 4deg; } }
  @keyframes sway { from { rotate: -2.5deg; } to { rotate: 2.5deg; } }
  /* In the menu and the site header the sprout only sways while you point at the logo:
     these redraw on every page, so growing there would replay on every click. */
  :is(.sidebar__brand, .site-header__brand, .site-footer__brand) .logo__sprout { transform-box: fill-box; transform-origin: 51% 100%; transition: rotate var(--duration-slow) var(--ease-out); }
  @media (hover: hover) {
    :is(.sidebar__brand, .site-header__brand):hover .logo__sprout { animation: sway 1.4s var(--ease-in-out) infinite alternate; }
  }
  .cta-band { isolation: isolate; display: flex; flex-direction: column; align-items: center; text-align: center; gap: var(--space-4); padding: clamp(40px, 7vw, 80px) var(--space-5); border-radius: 24px; background: var(--color-surface); border: 1px solid var(--color-border); box-shadow: var(--shadow); }
  .cta-band__subtitle { color: var(--color-text-muted); font-size: var(--text-md); }

  .site-footer { border-top: 1px solid var(--color-border); }
  .site-footer__inner { max-width: var(--page-max); margin: 0 auto; padding: var(--space-6) var(--space-5) var(--space-5); display: grid; grid-template-columns: minmax(0, 2fr) repeat(2, minmax(0, 1fr)); gap: var(--space-5) var(--space-6); color: var(--color-text-muted); font-size: var(--text-sm); }
  .site-footer__about { display: flex; flex-direction: column; gap: var(--space-2); max-width: 320px; }
  .site-footer__brand { display: flex; align-items: center; gap: var(--space-2); }
  .site-footer__heading { margin-bottom: var(--space-2); color: var(--color-text); font-size: var(--text-sm); font-weight: 600; }
  .site-footer__column ul { list-style: none; padding: 0; display: flex; flex-direction: column; gap: var(--space-2); }
  .site-footer__column a:hover { color: var(--color-text); }
  .site-footer__bottom { grid-column: 1 / -1; display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); padding-top: var(--space-4); border-top: 1px solid var(--color-border); color: var(--color-text-subtle); }
  @media (width <= 640px) { .site-footer__inner { grid-template-columns: repeat(2, minmax(0, 1fr)); } .site-footer__about { grid-column: 1 / -1; } }
  .language-menu__toggle { anchor-name: --language-menu; display: inline-flex; align-items: center; gap: var(--space-2); height: var(--control-height); padding: 0 var(--space-3); border: 1px solid var(--color-border); border-radius: var(--control-radius); background: none; color: var(--color-text-muted); font: inherit; cursor: pointer; }
  .language-menu__toggle:hover { color: var(--color-text); border-color: var(--color-border-strong); }
  .language-menu {
    position-anchor: --language-menu; position-area: block-start span-inline-start; inset: auto; margin: 0 0 var(--space-2);
    display: none; flex-direction: column; min-width: 160px; padding: 4px;
    border: 1px solid var(--color-border-strong); border-radius: var(--radius); background: var(--color-surface); box-shadow: var(--shadow-large);
  }
  .language-menu:popover-open { display: flex; }
  .language-menu__item { padding: var(--space-2) var(--space-3); border-radius: var(--radius-small); color: var(--color-text); }
  .language-menu__item:not(.language-menu__item--active):hover { background: var(--color-surface-hover); }
  .language-menu__item--active { font-weight: 600; }

  /* Legal pages: a calm, readable column */
  .legal { max-width: 720px; margin: 0 auto; width: 100%; padding-top: clamp(32px, 6vw, 64px); display: flex; flex-direction: column; gap: var(--space-4); font-size: var(--text-md); line-height: 1.7; }
  .legal__header { display: flex; flex-direction: column; gap: var(--space-2); margin-bottom: var(--space-3); }
  .legal h1 { font-size: clamp(32px, 5vw, 44px); letter-spacing: -0.03em; line-height: 1.1; }
  .legal h2 { margin-top: var(--space-5); font-size: var(--text-lg); }
  .legal__meta { color: var(--color-text-subtle); font-size: var(--text-sm); }
  .legal__lead { font-size: var(--text-lg); color: var(--color-text-muted); }
  .legal ul { padding-left: var(--space-5); display: flex; flex-direction: column; gap: var(--space-2); }
  .legal a { color: var(--color-accent); text-decoration: underline; text-underline-offset: 2px; }

  /* Changelog: the date on the left stays in view while you read the entry next to it. */
  .changelog { max-width: 880px; }
  .changelog__entry { display: grid; grid-template-columns: 160px minmax(0, 1fr); gap: var(--space-5); padding-top: var(--space-6); border-top: 1px solid var(--color-border); }
  .changelog__date { position: sticky; top: var(--space-6); align-self: start; color: var(--color-text-subtle); font-size: var(--text-sm); }
  .changelog__body h2 { margin-top: 0; }
  @media (width <= 640px) { .changelog__entry { grid-template-columns: minmax(0, 1fr); gap: var(--space-2); } .changelog__date { position: static; } }

  /* Sections fade in while you scroll (scroll-driven animation, no JavaScript) */
  @supports (animation-timeline: view()) {
    .reveal { animation: rise linear both; animation-timeline: view(); animation-range: entry 0% entry 40%; }
  }

  /* Two factor */
  .qr-code { width: 184px; margin: 0 auto; padding: var(--space-3); background: #fff; border: 1px solid var(--color-border); border-radius: var(--radius); }
  .qr-code svg { display: block; width: 100%; height: auto; }
  .disclosure summary { cursor: pointer; color: var(--color-text-muted); font-size: var(--text-sm); text-align: center; }
  .disclosure summary:hover { color: var(--color-text); }
  .secret { display: block; margin-top: var(--space-2); padding: var(--space-2); text-align: center; letter-spacing: 0.08em; word-break: break-all; }
  .recovery-codes { list-style: none; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: var(--space-2); margin: var(--space-4) 0; }
  .recovery-codes code { display: block; padding: var(--space-2); text-align: center; font-size: var(--text-base); }
}

@layer utilities {
  /* Keyboard users jump past the menu straight to the content. */
  .skip-link { position: absolute; left: var(--space-3); top: var(--space-3); z-index: 100; padding: 8px 12px; border-radius: var(--radius-small); background: var(--color-text); color: var(--color-bg); font-weight: 600; translate: 0 -200%; }
  .skip-link:focus-visible { translate: 0 0; }

  @media print {
    .sidebar, .page-header__actions, .site-header, .site-footer, .skip-link, .notice, [popover], .growth__form { display: none !important; }
    .page-header { position: static; backdrop-filter: none; }
    .app-shell { display: block; }
    .card, .stats--cards { box-shadow: none; break-inside: avoid; }
  }

  .muted { color: var(--color-text-muted); }
  .footnote { font-size: var(--text-xs); color: var(--color-text-subtle); line-height: 1.6; }
  .nowrap { white-space: nowrap; }
  .actions { margin-top: var(--space-4); display: flex; flex-wrap: wrap; gap: var(--space-2); }
  .honeypot { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }
  .visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
}

/* Page transitions and reduced motion, last so they win over every component. */
@layer motion {
  /*
   * Page transitions: Turbo uses the View Transitions API when <meta name="view-transition"> is set.
   * The sidebar has its own name, so it stays in place while the content cross-fades.
   */
  .sidebar { view-transition-name: sidebar; }
  /* The menu swaps at once instead of cross-fading: on a phone it can be scrolled differently on
     the old and the new page, and a cross-fade showed two words on top of each other. */
  ::view-transition-old(sidebar) { display: none; }
  ::view-transition-new(sidebar) { animation: none; }
  ::view-transition-old(root) { animation: var(--duration-fast) var(--ease-out) both fade-out; }
  ::view-transition-new(root) { animation: var(--duration) var(--ease-out) both fade-in; }
  @keyframes fade-out { to { opacity: 0; } }

  /*
   * A refresh of the same page (theme, language, collapsing the sidebar) is a Turbo "replace" visit
   * with data-turbo-visit-direction="none". No view transition there: the CSS transitions do the work.
   */
  html[data-turbo-visit-direction="none"]::view-transition-group(*),
  html[data-turbo-visit-direction="none"]::view-transition-old(*),
  html[data-turbo-visit-direction="none"]::view-transition-new(*) { animation: none; }
  @keyframes fade-in { from { opacity: 0; translate: 0 4px; } }

  /* Less motion for people who ask for it in their system settings. */
  @media (prefers-reduced-motion: reduce) {
    *, *::before, *::after, ::view-transition-group(*), ::view-transition-old(*), ::view-transition-new(*) {
      animation-duration: 1ms !important;
      animation-delay: 0ms !important;
      transition-duration: 1ms !important;
    }
    .preview { transform: none !important; animation: none !important; }
    .hero__chip { animation: none !important; }
    .logo--animated .logo__sprout, .cta-band__backdrop, .logo__sprout { animation: none !important; }
    .logo--animated .logo__ink, .logo--animated .logo__leaf { scale: 1; animation: none !important; }
  }
}
