/*
 * 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.
 */
@layer tokens, base, layout, components, utilities;

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

@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 <body> 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);
    --color-accent-contrast: light-dark(#ffffff, #1a0f0b);

    --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;
    --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: "Inter", ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    --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;

    --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. */
  html { -webkit-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;
    font-feature-settings: "cv11", "ss01";
    -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"], select {
    width: 100%;
    height: 34px;
    padding: 0 var(--space-3);
    background: var(--color-surface);
    border: 1px solid var(--color-border-strong);
    border-radius: var(--radius-small);
    font-size: var(--text-base);
    transition: border-color 0.12s, box-shadow 0.12s;
  }
  input:hover, select:hover { border-color: var(--color-text-subtle); }
  input:focus, select:focus { outline: none; 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: 100vh;
    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 {
    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];
    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: 100vh;
    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 (max-width: 900px) {
    :root { --content-gutter: var(--space-4); }
    .app-shell { grid-template-columns: minmax(0, 1fr); }
  }
}

@layer components {
  /* Sidebar */
  .sidebar {
    position: sticky; top: 0;
    height: 100vh;
    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: 38px; padding-inline: 7px; 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) 10px 0; font-size: var(--text-xs); font-weight: 500; color: var(--color-text-subtle); white-space: nowrap; }
  .sidebar__group { list-style: none; padding: 0; display: flex; flex-direction: column; gap: 1px; }
  .sidebar__link {
    display: flex; align-items: center; gap: 10px;
    width: 100%; height: 30px; padding: 0 10px;
    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); }
  .sidebar__user { height: 36px; padding-left: 6px; font-size: var(--text-sm); }
  .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__tile { fill: var(--color-text); }
  .logo__mark { fill: var(--color-bg); }
  .logo__mark--accent { fill: var(--color-accent); }

  /*
   * 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); }
  .sidebar__heading::after {
    content: ""; position: absolute; left: 12px; right: auto; bottom: 8px; width: 12px; height: 1px;
    background: var(--color-border-strong); opacity: 0; transition: opacity var(--duration-fast);
  }

  @media (min-width: 901px) {
    [data-sidebar="collapsed"] { --sidebar-width: 60px; }
    [data-sidebar="collapsed"] .sidebar__label { opacity: 0; }
    [data-sidebar="collapsed"] .sidebar__heading::after { opacity: 1; }
    /* 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 (max-width: 900px) {
    .sidebar { position: sticky; z-index: 10; height: auto; overflow: visible; border-right: 0; border-bottom: 1px solid var(--color-border); }
    .sidebar__inner { width: auto; flex-direction: row; flex-wrap: wrap; align-items: center; padding: var(--space-2) var(--space-3); }
    .sidebar__brand { margin: 0; }
    .sidebar__heading, .sidebar__toggle, .sidebar__footer .sidebar__label { display: none; }
    .sidebar__group { flex-direction: row; flex-wrap: wrap; order: 3; width: 100%; overflow-x: auto; }
    .sidebar__group + .sidebar__group { width: auto; }
    .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; }
  .icon-button { display: grid; place-items: center; width: 30px; height: 30px; border: 0; border-radius: var(--radius-small); background: none; color: var(--color-text-subtle); cursor: pointer; }
  .icon-button:hover { background: var(--color-surface-hover); color: var(--color-text); }

  /* 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 (max-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); }
  .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); }
  .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: 21px; 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: 6px;
    height: 32px; padding: 0 var(--space-3);
    border: 1px solid var(--color-border-strong); border-radius: var(--radius-small);
    background: var(--color-surface); color: var(--color-text);
    font-size: var(--text-base); font-weight: 500; cursor: pointer; white-space: nowrap;
    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); 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-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: #fff; }
  .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: 42px; padding: 0 var(--space-5); font-size: var(--text-md); border-radius: var(--radius); }
  .button--small { height: 26px; 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: 6px; }
  .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); }
  .field--inline { flex-direction: row; align-items: center; gap: var(--space-2); }
  .field--inline select { width: auto; min-width: 120px; }
  .file-input { width: 100%; padding: var(--space-5); border: 1px dashed var(--color-border-strong); border-radius: var(--radius); background: var(--color-surface-muted); color: var(--color-text-muted); font-size: var(--text-sm); cursor: pointer; }
  .file-input:hover { border-color: var(--color-accent); }
  .file-input::file-selector-button { margin-right: var(--space-3); height: 28px; padding: 0 var(--space-3); border: 1px solid var(--color-border-strong); border-radius: var(--radius-small); background: var(--color-surface); color: var(--color-text); font: inherit; font-weight: 500; cursor: pointer; }
  .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 */
  .flash-messages { display: flex; flex-direction: column; gap: var(--space-2); }
  .flash { padding: var(--space-2) var(--space-3); border-radius: var(--radius-small); background: var(--color-positive-soft); color: var(--color-positive); font-size: var(--text-sm); font-weight: 500; }
  .flash--alert { background: var(--color-negative-soft); color: var(--color-negative); }

  /* 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 */
  .badge { display: inline-flex; align-items: center; height: 20px; padding: 0 7px; 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; gap: 2px; padding: 2px; background: var(--color-surface-muted); border: 1px solid var(--color-border); border-radius: 8px; }
  .segmented-nav__item { display: inline-flex; align-items: center; height: 26px; padding: 0 10px; border-radius: var(--radius-small); 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: 6px; }
  .filter-chip {
    display: inline-flex; align-items: center; gap: 6px;
    height: 28px; padding: 0 6px 0 10px;
    border: 1px solid var(--color-border-strong); border-radius: 999px;
    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: 18px; padding: 0 6px;
    display: inline-grid; place-items: center;
    border-radius: 999px; 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); color: var(--color-accent-contrast); }
  .filter-chip--empty:not(.filter-chip--active) { opacity: 0.55; }

  /* Table */
  .table-wrapper { 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); }
  .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: 10px 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; }
  .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: 10px 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); }

  /* Donut chart */
  .donut-chart { display: flex; align-items: center; gap: var(--space-6); flex-wrap: wrap; }
  .donut-chart__ring {
    position: relative; flex: none; width: 168px; aspect-ratio: 1; border-radius: 50%; display: grid; place-items: center;
    /* The ring opens clockwise: the mask grows from 0 to 360 degrees. */
    mask: conic-gradient(#000 var(--reveal), transparent 0);
    animation: reveal 900ms var(--ease-out) both;
  }
  .donut-chart__ring::before { content: ""; position: absolute; inset: 19%; border-radius: 50%; background: var(--color-surface); }
  .donut-chart__center { position: relative; display: flex; flex-direction: column; align-items: center; text-align: center; }
  .donut-chart__value { font-size: var(--text-md); font-weight: 600; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
  .donut-chart__caption { font-size: var(--text-xs); color: var(--color-text-subtle); }
  .donut-chart__legend { flex: 1; min-width: 200px; }

  .chart-legend { list-style: none; padding: 0; display: flex; flex-direction: column; gap: 6px; }
  .chart-legend__item { display: grid; grid-template-columns: 8px 1fr auto; align-items: center; gap: 10px; 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: 22px;
    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; }

  /* 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: 6px; 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: 6px; 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: 6px; 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: 22px; height: 22px; 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: #fff; }
  @media (max-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: 650; 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: 7px; height: 7px; 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); }
  .import-progress { display: flex; align-items: center; gap: var(--space-3); color: var(--color-text-muted); }
  .spinner { width: 16px; height: 16px; border: 2px solid var(--color-border-strong); border-top-color: var(--color-accent); border-radius: 50%; animation: spin 0.7s linear infinite; }
  @keyframes spin { to { transform: rotate(360deg); } }
  @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 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: 6px; 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); }
  .dialog__title { font-size: var(--text-md); }
  .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: 6px; 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: 6px; height: 64px; padding: 10px 10px 10px 34px; 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; }
  .marketing main { display: flex; flex-direction: column; gap: clamp(64px, 10vw, 120px); padding: 0 var(--space-5) var(--space-7); }

  .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 (max-width: 760px) {
    .site-header__nav { display: none; }
    .site-header__actions { margin-left: auto; }
  }

  .eyebrow { display: inline-flex; align-items: center; gap: 6px; width: fit-content; padding: 4px 10px; border-radius: 999px; background: var(--color-accent-soft); color: var(--color-accent); font-size: var(--text-sm); font-weight: 600; }

  /* Hero */
  .hero { max-width: var(--page-max); margin: 0 auto; width: 100%; padding-top: clamp(48px, 8vw, 96px); display: grid; gap: clamp(40px, 6vw, 72px); }
  .hero__text { display: flex; flex-direction: column; align-items: center; text-align: center; gap: var(--space-4); max-width: 720px; margin: 0 auto; }
  .hero__title { font-size: clamp(40px, 7vw, 72px); line-height: 1.02; letter-spacing: -0.04em; font-weight: 650; text-wrap: balance; }
  .hero__title em { font-style: normal; color: var(--color-accent); }
  .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); }
  .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; animation: rise 900ms var(--ease-out) 250ms both; }
  .hero__preview::before { content: ""; position: absolute; inset: 10% 5% -8%; z-index: -1; border-radius: 40px; background: radial-gradient(closest-side, color-mix(in srgb, var(--color-accent) 22%, transparent), transparent); filter: blur(30px); }
  .preview { background: var(--color-bg); border: 1px solid var(--color-border-strong); border-radius: 16px; box-shadow: var(--shadow-large); overflow: hidden; }
  .preview__bar { display: flex; gap: 6px; padding: 12px 14px; border-bottom: 1px solid var(--color-border); background: var(--color-sidebar); }
  .preview__bar span { width: 10px; height: 10px; 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 .bar-chart__plot { height: 160px; }

  /* 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 { font-size: clamp(28px, 4vw, 40px); 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; }

  .feature-grid { list-style: none; padding: 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 300px), 1fr)); gap: var(--space-4); }
  .feature { display: flex; flex-direction: column; gap: var(--space-2); padding: var(--space-5); 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); }
  .feature:hover { translate: 0 -2px; box-shadow: var(--shadow-large); }
  .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); }
  .step { display: flex; flex-direction: column; gap: var(--space-2); padding: var(--space-5); border-top: 2px solid var(--color-accent); }
  .step__title { font-size: var(--text-md); }
  .step__body { color: var(--color-text-muted); }

  .privacy-band { 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); }
  .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: 3px; 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 { 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: radial-gradient(ellipse 70% 90% at 50% 0%, var(--color-accent-soft), var(--color-surface) 70%); border: 1px solid var(--color-border); }
  .cta-band__title { font-size: clamp(28px, 4vw, 40px); letter-spacing: -0.03em; line-height: 1.1; text-wrap: balance; }
  .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); display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-3) var(--space-6); color: var(--color-text-muted); font-size: var(--text-sm); }
  .site-footer__brand { display: flex; align-items: center; gap: var(--space-2); font-weight: 600; color: var(--color-text); }
  .site-footer__note { flex: 1; min-width: 240px; }
  .site-footer__languages, .site-footer__links { display: flex; gap: var(--space-3); }
  .site-footer__links a:hover { color: var(--color-text); }

  /* 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: 18px; 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; }
  .legal__draft { display: flex; align-items: center; gap: var(--space-2); padding: var(--space-3) var(--space-4); border-radius: var(--radius); background: var(--color-warning-soft); color: var(--color-warning); font-size: var(--text-sm); font-weight: 500; line-height: 1.5; }
  .site-footer__languages a:hover, .site-footer__languages a[aria-current] { color: var(--color-text); }
  .site-footer__languages a[aria-current] { font-weight: 600; }

  /* 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 {
  .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; 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: 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; }
::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;
  }
}
