/* Design tokens.
   One source of truth for color, type, spacing, radius, elevation, iconography
   and motion, shared by every surface (tool pages, directory, content
   pages, the design catalog and feature modules such as the page workspace).

   Conventions mirror the ForestMail design system: every token is prefixed
   (--pd-*), light is the default, dark follows the OS preference, and a page
   can force a theme with <html data-theme="light|dark">. Feature stylesheets
   must consume these tokens rather than hard-coded colors so both themes stay
   correct. Rendered, with the hooks contract, at /design. */
:root {
  /* Brand — teal: calm, trustworthy, distinct from red/coral PDF brands. */
  --pd-brand: #0f6b5a;
  --pd-brand-strong: #0a5043;
  --pd-brand-soft: #e2f2ec;
  --pd-brand-tint: #f1f8f5;
  --pd-brand-ink: #ffffff;              /* text on brand fills */
  --pd-accent: #c98a1b;                 /* warm amber: highlights, "new" marks */
  --pd-accent-soft: #fbf1dc;
  --pd-brand-grad: linear-gradient(135deg, #0f6b5a 0%, #14866f 55%, #23a487 100%);

  /* Neutrals */
  --pd-bg: #f5f7f6;
  --pd-surface: #ffffff;
  --pd-surface-2: #f6f9f8;
  --pd-surface-3: #edf2f0;
  --pd-line: #dfe7e4;
  --pd-line-soft: #ebf0ee;
  --pd-line-strong: #c4d1cc;

  --pd-text: #13221d;
  --pd-text-soft: #3c4f48;
  --pd-text-muted: #4a5a54;             /* 6.8:1 on --pd-bg (was #657682, 4.44:1 — failed AA); margin for 11-12px text */
  --pd-text-invert: #f3faf7;

  --pd-link: #0d6656;
  --pd-focus: #2f9c80;
  --pd-ring: 0 0 0 3px rgba(47, 156, 128, .38);

  /* Semantic status — each pair meets WCAG AA at 12px. */
  --pd-danger: #a83f25; --pd-danger-bg: #fbebe5;
  --pd-warn: #805f12;   --pd-warn-bg: #fbf3df;
  --pd-ok: #145a3a;     --pd-ok-bg: #e4f3ea;
  --pd-info: #2a6487;   --pd-info-bg: #e6f0f6;

  /* Category tones (tool icon tiles) — fg on bg >= 4.5:1. */
  --pd-tone-pages: #1a6f5e; --pd-tone-pages-bg: #e1f2ec;
  --pd-tone-convert: #2a64a0; --pd-tone-convert-bg: #e4eef8;
  --pd-tone-security: #7b5a12; --pd-tone-security-bg: #f8efd9;
  --pd-tone-visuals: #8a4a6b; --pd-tone-visuals-bg: #f6e6ee;
  --pd-tone-details: #4f5d6b; --pd-tone-details-bg: #e9edf1;
  --pd-tone-workflows: #5d4f9c; --pd-tone-workflows-bg: #ebe8f7;
  --pd-tone-scans: #3d6b2a; --pd-tone-scans-bg: #e7f1e1;

  /* Typography — system stack: no web-font request, no font-swap layout shift. */
  --pd-font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, system-ui, sans-serif;
  --pd-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --pd-fs-0: 11px; --pd-fs-1: 12.5px; --pd-fs-2: 14px; --pd-fs-3: 15.5px;
  --pd-fs-4: 18px; --pd-fs-5: 22px; --pd-fs-6: 28px; --pd-fs-7: 36px; --pd-fs-8: 48px;
  --pd-fs-hero: clamp(30px, 5.2vw, 52px);
  --pd-lh-tight: 1.15; --pd-lh: 1.6;
  --pd-fw-regular: 400; --pd-fw-medium: 550; --pd-fw-semibold: 640; --pd-fw-bold: 720;

  /* Spacing scale (4px base) */
  --pd-s-1: 4px; --pd-s-2: 8px; --pd-s-3: 12px; --pd-s-4: 16px;
  --pd-s-5: 20px; --pd-s-6: 24px; --pd-s-7: 32px; --pd-s-8: 48px; --pd-s-9: 64px; --pd-s-10: 96px;

  /* Radius */
  --pd-r-1: 8px; --pd-r-2: 11px; --pd-r-3: 15px; --pd-r-4: 20px; --pd-r-5: 28px; --pd-r-pill: 999px;

  /* Elevation — soft and layered. */
  --pd-shadow-1: 0 1px 2px rgba(15, 40, 33, .05), 0 2px 6px rgba(15, 40, 33, .05);
  --pd-shadow-2: 0 4px 14px rgba(15, 40, 33, .08), 0 10px 30px rgba(15, 40, 33, .07);
  --pd-shadow-3: 0 12px 28px rgba(15, 40, 33, .12), 0 30px 70px rgba(15, 40, 33, .16);
  --pd-shadow-brand: 0 1px 1px rgba(15, 40, 33, .2), 0 6px 16px rgba(15, 107, 90, .28);

  /* Iconography — 24px grid line icons drawn with currentColor. */
  --pd-icon-sm: 16px; --pd-icon: 20px; --pd-icon-lg: 24px; --pd-icon-xl: 40px;
  --pd-icon-stroke: 1.7;

  /* Motion — one calm easing family. Disabled under prefers-reduced-motion. */
  --pd-dur: .16s;
  --pd-dur-2: .26s;
  --pd-ease: cubic-bezier(.2, .7, .2, 1);
  --pd-ease-out: cubic-bezier(0, .6, .3, 1);

  /* Layout */
  --pd-header-h: 64px;
  --pd-header-bg: rgba(255, 255, 255, .86);
  --pd-overlay: rgba(10, 24, 20, .42);
  --pd-gutter: 16px;
  --pd-maxw: 1200px;
  --pd-maxw-text: 760px;
  --pd-maxw-workspace: 840px;

  color-scheme: light;
}

/* Dark palette — deep and desaturated, never pure black. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --pd-brand: #46c4a2;
    --pd-brand-strong: #6dd6b9;
    --pd-brand-soft: #143229;
    --pd-brand-tint: #11251f;
    --pd-brand-ink: #06130f;
    --pd-accent: #e0ad4f;
    --pd-accent-soft: #342814;
    --pd-brand-grad: linear-gradient(135deg, #1d9a7c 0%, #2fb592 55%, #52d1ae 100%);
    --pd-bg: #0c1613;
    --pd-surface: #111d19;
    --pd-surface-2: #162621;
    --pd-surface-3: #1c2f29;
    --pd-line: #263a33;
    --pd-line-soft: #1f322c;
    --pd-line-strong: #36504a;
    --pd-text: #e8f1ed;
    --pd-text-soft: #c1d3cb;
    --pd-text-muted: #98aca4;
    --pd-text-invert: #0c1613;
    --pd-link: #6dd6b9;
    --pd-focus: #46c4a2;
    --pd-ring: 0 0 0 3px rgba(70, 196, 162, .4);
    --pd-danger: #f0a089; --pd-danger-bg: #3a1e16;
    --pd-warn: #e2c37a;   --pd-warn-bg: #322914;
    --pd-ok: #74d4a4;     --pd-ok-bg: #11302a;
    --pd-info: #92c3e2;   --pd-info-bg: #13262f;
    /* Category tones */
    --pd-tone-pages: #7fd8c0; --pd-tone-pages-bg: #15342c;
    --pd-tone-convert: #94c1ef; --pd-tone-convert-bg: #16283a;
    --pd-tone-security: #e8c47a; --pd-tone-security-bg: #33290f;
    --pd-tone-visuals: #e9a9c8; --pd-tone-visuals-bg: #361d2a;
    --pd-tone-details: #b5c2cf; --pd-tone-details-bg: #222b33;
    --pd-tone-workflows: #b9aef0; --pd-tone-workflows-bg: #262043;
    --pd-tone-scans: #a9d98f; --pd-tone-scans-bg: #1d3117;
    --pd-shadow-1: 0 1px 2px rgba(0, 0, 0, .35), 0 2px 8px rgba(0, 0, 0, .3);
    --pd-shadow-2: 0 6px 18px rgba(0, 0, 0, .45), 0 14px 36px rgba(0, 0, 0, .4);
    --pd-shadow-3: 0 16px 36px rgba(0, 0, 0, .55), 0 34px 80px rgba(0, 0, 0, .6);
    --pd-shadow-brand: 0 1px 1px rgba(0, 0, 0, .4), 0 6px 16px rgba(29, 154, 124, .3);
    --pd-header-bg: rgba(17, 29, 25, .82);
    --pd-overlay: rgba(0, 0, 0, .56);
  }
}

/* Explicit dark override, independent of OS preference. Keep in sync with the block above. */
:root[data-theme="dark"] {
  color-scheme: dark;
  --pd-brand: #46c4a2;
  --pd-brand-strong: #6dd6b9;
  --pd-brand-soft: #143229;
  --pd-brand-tint: #11251f;
  --pd-brand-ink: #06130f;
  --pd-accent: #e0ad4f;
  --pd-accent-soft: #342814;
  --pd-brand-grad: linear-gradient(135deg, #1d9a7c 0%, #2fb592 55%, #52d1ae 100%);
  --pd-bg: #0c1613;
  --pd-surface: #111d19;
  --pd-surface-2: #162621;
  --pd-surface-3: #1c2f29;
  --pd-line: #263a33;
  --pd-line-soft: #1f322c;
  --pd-line-strong: #36504a;
  --pd-text: #e8f1ed;
  --pd-text-soft: #c1d3cb;
  --pd-text-muted: #98aca4;
  --pd-text-invert: #0c1613;
  --pd-link: #6dd6b9;
  --pd-focus: #46c4a2;
  --pd-ring: 0 0 0 3px rgba(70, 196, 162, .4);
  --pd-danger: #f0a089; --pd-danger-bg: #3a1e16;
  --pd-warn: #e2c37a;   --pd-warn-bg: #322914;
  --pd-ok: #74d4a4;     --pd-ok-bg: #11302a;
  --pd-info: #92c3e2;   --pd-info-bg: #13262f;
  /* Category tones */
  --pd-tone-pages: #7fd8c0; --pd-tone-pages-bg: #15342c;
  --pd-tone-convert: #94c1ef; --pd-tone-convert-bg: #16283a;
  --pd-tone-security: #e8c47a; --pd-tone-security-bg: #33290f;
  --pd-tone-visuals: #e9a9c8; --pd-tone-visuals-bg: #361d2a;
  --pd-tone-details: #b5c2cf; --pd-tone-details-bg: #222b33;
  --pd-tone-workflows: #b9aef0; --pd-tone-workflows-bg: #262043;
  --pd-tone-scans: #a9d98f; --pd-tone-scans-bg: #1d3117;
  --pd-shadow-1: 0 1px 2px rgba(0, 0, 0, .35), 0 2px 8px rgba(0, 0, 0, .3);
  --pd-shadow-2: 0 6px 18px rgba(0, 0, 0, .45), 0 14px 36px rgba(0, 0, 0, .4);
  --pd-shadow-3: 0 16px 36px rgba(0, 0, 0, .55), 0 34px 80px rgba(0, 0, 0, .6);
  --pd-shadow-brand: 0 1px 1px rgba(0, 0, 0, .4), 0 6px 16px rgba(29, 154, 124, .3);
  --pd-header-bg: rgba(17, 29, 25, .82);
  --pd-overlay: rgba(0, 0, 0, .56);
}

/* Legacy aliases — the pre-design-system names, kept so older or concurrent
   feature CSS keeps rendering and follows the theme (the page workspace's
   --pw-*, the AI panel's --ai-* and the account/help pages read these).
   New code uses the --pd-* names above. */
:root {
  --ink: var(--pd-text);
  --muted: var(--pd-text-muted);
  --accent: var(--pd-brand);
  --accent-dark: var(--pd-brand-strong);
  --line: var(--pd-line);
  --paper: var(--pd-surface);
  --bg: var(--pd-bg);
  --soft: var(--pd-brand-soft);
  --soft-2: var(--pd-accent-soft);
  --danger: var(--pd-danger);
  --focus: var(--pd-focus);
  --radius: var(--pd-r-4);
}
