:root {
  color-scheme: light;

  --color-paper: oklch(95.6% 0.0115 84.58);
  --color-paper-deep: oklch(92.4% 0.014 84.58);
  --color-paper-light: oklch(99.42% 0.0069 88.64);
  --color-ink: oklch(24.11% 0.0237 157.09);
  --color-ink-soft: oklch(34% 0.021 153);
  --color-muted: oklch(50.67% 0.0178 145.31);
  --color-rule: oklch(82% 0.014 103);
  --color-rule-strong: oklch(67% 0.018 123);
  --color-accent: oklch(69.31% 0.1679 32.43);
  --color-accent-hover: oklch(65% 0.1766 32.2);
  --color-accent-ink: var(--color-ink);
  /* Deep coral for display type: 4.48:1 on paper, where --color-accent is 2.59:1. */
  --color-accent-deep: oklch(56% 0.185 32.43);
  --color-peach: oklch(91.12% 0.0483 42.16);
  --color-focus: var(--color-ink);
  --color-overlay: oklch(24.11% 0.0237 157.09 / 0.58);
  --color-shadow: oklch(24.11% 0.0237 157.09 / 0.14);
  --color-disabled: oklch(71% 0.014 118);
  --color-phone-paper: oklch(98.6% 0.003 250);
  --color-phone-header: oklch(99.2% 0.002 250);
  --color-phone-ink: oklch(20.5% 0.012 255);
  --color-phone-muted: oklch(53% 0.01 255);
  --color-phone-rule: oklch(89.5% 0.006 250);
  --color-message-user: oklch(54% 0.205 252);
  --color-message-user-ink: oklch(99.2% 0.002 250);
  --color-message-kora: oklch(92.5% 0.006 250);
  /* Group-thread member initials. Light stops sit at L 52% so the initials
     clear 4.5:1; the ink is warm-tinted rather than pure white (gate 22). */
  --color-avatar-ink: oklch(99.5% 0.006 84);
  --color-avatar-b-light: oklch(52% 0.14 45);
  --color-avatar-b-deep: oklch(44% 0.15 35);
  --color-avatar-s-light: oklch(52% 0.13 300);
  --color-avatar-s-deep: oklch(44% 0.14 295);
  --color-avatar-j-light: oklch(52% 0.12 150);
  --color-avatar-j-deep: oklch(44% 0.12 155);
  --color-avatar-m-light: oklch(52% 0.13 230);
  --color-avatar-m-deep: oklch(44% 0.14 240);

  --font-display: "Bricolage Grotesque", "Arial Narrow", sans-serif;
  --font-body: "Geist", "Helvetica Neue", sans-serif;

  /* One step below xs on the same ~1.09 ratio the rest of the ladder uses,
     for small print set beside a large object. */
  --text-2xs: clamp(0.8rem, 0.775rem + 0.13vw, 0.89rem);
  --text-xs: clamp(0.875rem, 0.845rem + 0.15vw, 0.97rem);
  --text-sm: clamp(0.9375rem, 0.885rem + 0.26vw, 1.09rem);
  --text-base: clamp(1.0625rem, 0.99rem + 0.33vw, 1.25rem);
  --text-md: clamp(1.25rem, 1.14rem + 0.55vw, 1.56rem);
  --text-lg: clamp(1.5rem, 1.36rem + 0.7vw, 1.9rem);
  --text-xl: clamp(1.875rem, 1.68rem + 0.98vw, 2.44rem);
  --text-2xl: clamp(2.5rem, 2.2rem + 1.5vw, 3.4rem);
  --text-heading: clamp(2.125rem, 4.6vw, 3.5rem);
  --text-display-s: clamp(2.25rem, 6vw, 3.5rem);
  --text-display: clamp(2.625rem, 8vw, 4.625rem);
  --text-phone-xs: clamp(0.5rem, 1.75vw, 0.6875rem);
  --text-phone-sm: clamp(0.5625rem, 1.9vw, 0.75rem);
  --text-phone-base: clamp(0.625rem, 2vw, 0.8125rem);

  --space-3xs: 0.125rem;
  --space-2xs: 0.25rem;
  --space-xs: 0.5rem;
  --space-sm: 0.75rem;
  --space-md: 1rem;
  --space-lg: 1.5rem;
  --space-xl: 2.5rem;
  --space-2xl: 4rem;
  --space-3xl: 6rem;
  --space-4xl: 9rem;

  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-in: cubic-bezier(0.7, 0, 0.84, 0);
  --ease-in-out: cubic-bezier(0.65, 0, 0.35, 1);
  --dur-micro: 120ms;
  --dur-short: 220ms;
  --dur-long: 420ms;

  --rule-hair: 1px;
  --rule-strong: 2px;
  --radius-xs: 0.25rem;
  --radius-sm: 0.5rem;
  --radius-md: 0.75rem;
  --radius-pill: 999px;
  --radius-phone-screen: 10.5% / 5.15%;
  --radius-phone-bubble: 1.1rem;
  --radius-phone-tail: 0.35rem;

  --shadow-soft: 0 1.5rem 4rem -2.5rem var(--color-shadow);
  --control-height: 3rem;
  --tap-target: 2.75rem;
  --content-max: 76rem;
  --content-narrow: 65ch;
  --page-gutter: clamp(1rem, 4vw, 2.5rem);

  --dur-reveal: 620ms;
  --stagger: 70ms;
  /* Beat between messages in a thread. Read by motion.js too, so the CSS and
     the scene sequencer can never drift apart. */
  /* Message beat. +10% over the previous 900ms so the mock reads calmer;
     non-Latin locales get a further 10% because the glyphs render and read
     slower (see :root:not([lang="en"]) below). motion.js reads this token. */
  --msg-step: 990ms;
  --color-glass: oklch(99.42% 0.0069 88.64 / 0.72);
  --color-halo-accent: oklch(69.31% 0.1679 32.43 / 0.1);
  --blur-glass: 14px;

  --z-base: 1;
  --z-raised: 10;
  --z-dropdown: 100;
  --z-sticky: 200;
  --z-modal: 400;
  --z-toast: 500;
  --z-tooltip: 600;
}

/*
 * Reversible visual study. The default page keeps Kora's warm palette; this
 * layer is enabled only by /?theme=apple and never persists across visits.
 */
html[data-theme="apple"] {
  --color-paper: oklch(98.7% 0.003 250);
  --color-paper-deep: oklch(95.7% 0.005 250);
  --color-paper-light: oklch(100% 0 0);
  --color-ink: oklch(20.5% 0.012 255);
  --color-ink-soft: oklch(35.5% 0.012 255);
  --color-muted: oklch(47.5% 0.01 255);
  --color-rule: oklch(89.5% 0.006 250);
  --color-rule-strong: oklch(78% 0.008 250);
  --color-accent: oklch(54% 0.19 255);
  --color-accent-hover: oklch(49% 0.19 255);
  --color-accent-ink: oklch(100% 0 0);
  --color-accent-deep: oklch(49% 0.19 255);
  --color-peach: oklch(94.8% 0.012 250);
  --color-focus: oklch(54% 0.19 255);
  --color-overlay: oklch(20.5% 0.012 255 / 0.52);
  --color-shadow: oklch(20.5% 0.012 255 / 0.15);
  --color-disabled: oklch(82% 0.006 250);
  --color-dark-muted: oklch(84% 0.008 250);
  --color-dark-rule: oklch(62% 0.01 250);
  --color-private-surface: oklch(92% 0.013 250);

  --font-display: "Geist", "Helvetica Neue", sans-serif;
  --font-wordmark: "Bricolage Grotesque", "Arial Narrow", sans-serif;

  --text-heading: clamp(2.25rem, 4.7vw, 4rem);
  --text-display: clamp(2.75rem, 6.9vw, 5.75rem);

  --radius-xs: 0.5rem;
  --radius-sm: 0.875rem;
  --radius-md: 1.75rem;
  --radius-bubble: 1.25rem;
  --shadow-soft: 0 2rem 5rem -3rem var(--color-shadow);
  --content-max: 80rem;
}

/*
 * Dark scheme. Same anchor hues, only lightness and chroma move (color.md).
 * Paper sits at L 17%, ink at 94%, raised surfaces are lighter, not darker.
 * The accent gains lightness and loses a little chroma so it holds on dark
 * paper; its button ink flips to a dark warm tone so text on coral stays
 * readable. The phone mock follows iOS dark: near-black screen, grey
 * bubbles, the same blue for the user's side.
 */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="apple"]):not([data-theme="light"]) {
    color-scheme: dark;

    --color-paper: oklch(17% 0.012 84.58);
    --color-paper-deep: oklch(21.5% 0.014 84.58);
    --color-paper-light: oklch(23.5% 0.013 84.58);
    --color-ink: oklch(94% 0.008 84);
    --color-ink-soft: oklch(84% 0.01 84);
    --color-muted: oklch(70% 0.012 84);
    --color-rule: oklch(32% 0.014 84);
    --color-rule-strong: oklch(46% 0.016 84);
    --color-accent: oklch(72% 0.15 32.43);
    --color-accent-hover: oklch(76% 0.15 32.43);
    --color-accent-ink: oklch(17% 0.02 32);
    /* Display coral on dark paper: 8.9:1. */
    --color-accent-deep: oklch(78% 0.14 32.43);
    --color-peach: oklch(31% 0.05 42);
    --color-focus: var(--color-ink);
    --color-overlay: oklch(8% 0.01 84 / 0.72);
    --color-shadow: oklch(6% 0.01 84 / 0.5);
    --color-disabled: oklch(46% 0.012 84);
    --color-phone-paper: oklch(12% 0.006 250);
    --color-phone-header: oklch(16% 0.007 250);
    --color-phone-ink: oklch(96% 0.003 250);
    --color-phone-muted: oklch(66% 0.01 255);
    --color-phone-rule: oklch(28% 0.008 250);
    --color-message-user: oklch(58% 0.19 252);
    --color-message-user-ink: oklch(99.2% 0.002 250);
    --color-message-kora: oklch(30% 0.008 250);
    --color-avatar-ink: oklch(99.5% 0.006 84);
    --color-glass: oklch(17% 0.012 84.58 / 0.74);
    --color-halo-accent: oklch(72% 0.15 32.43 / 0.14);
    --shadow-soft: 0 1.5rem 4rem -2.5rem var(--color-shadow);
  }
}

/* The same scheme, chosen rather than inherited. Duplicated because a
   selector inside a media query cannot be shared with one outside it;
   both lists must be edited together. */
:root[data-theme="dark"] {
  color-scheme: dark;

  --color-paper: oklch(17% 0.012 84.58);
  --color-paper-deep: oklch(21.5% 0.014 84.58);
  --color-paper-light: oklch(23.5% 0.013 84.58);
  --color-ink: oklch(94% 0.008 84);
  --color-ink-soft: oklch(84% 0.01 84);
  --color-muted: oklch(70% 0.012 84);
  --color-rule: oklch(32% 0.014 84);
  --color-rule-strong: oklch(46% 0.016 84);
  --color-accent: oklch(72% 0.15 32.43);
  --color-accent-hover: oklch(76% 0.15 32.43);
  --color-accent-ink: oklch(17% 0.02 32);
  /* Display coral on dark paper: 8.9:1. */
  --color-accent-deep: oklch(78% 0.14 32.43);
  --color-peach: oklch(31% 0.05 42);
  --color-focus: var(--color-ink);
  --color-overlay: oklch(8% 0.01 84 / 0.72);
  --color-shadow: oklch(6% 0.01 84 / 0.5);
  --color-disabled: oklch(46% 0.012 84);
  --color-phone-paper: oklch(12% 0.006 250);
  --color-phone-header: oklch(16% 0.007 250);
  --color-phone-ink: oklch(96% 0.003 250);
  --color-phone-muted: oklch(66% 0.01 255);
  --color-phone-rule: oklch(28% 0.008 250);
  --color-message-user: oklch(58% 0.19 252);
  --color-message-user-ink: oklch(99.2% 0.002 250);
  --color-message-kora: oklch(30% 0.008 250);
  --color-avatar-ink: oklch(99.5% 0.006 84);
  --color-glass: oklch(17% 0.012 84.58 / 0.74);
  --color-halo-accent: oklch(72% 0.15 32.43 / 0.14);
  --shadow-soft: 0 1.5rem 4rem -2.5rem var(--color-shadow);
}
