/* ============================================================
   OFY SUITE — GLOBAL BASELINE
   Single global stylesheet shared by every service. Per-service
   stylesheets (ofy-suite.css, ofy-paste.css, ofy-short.css,
   ofy-transfer.css, ofy-tools.css) layer additions on top.

   Architecture:
   - @font-face for self-hosted Inter Tight + JetBrains Mono (variable).
   - Tokens in oklch() — per-service hue switched by [data-service].
   - Light/dark via [data-theme="light"]; default is dark.
   - Subtle glass surfaces (header, .glass utility) as the only
     transparency in the system. Everything else is flat.
   - Motion gated by prefers-reduced-motion.
   ============================================================ */

/* ------------------------------------------------------------
   2026-05-26 — v2 canonical refresh (operator screenshots).

   ADDED (pure additions, no existing token renamed or removed):
     --bg-4, --bg-5          new dark surface levels (v2 studio uses these)
     --text-0..4             5-level hex text scale used by .v2-app surfaces
                             (dark-mode only; --fg-0..3 remain for light-mode-aware code)
     --accent-fg             near-white text for use on filled accent backgrounds
     --status-active         green active-state indicator (same hue as --status-ok, slightly different)
     --status-redirect       amber redirect-state indicator
     --status-planned        dim text for planned/future items
     --t-1                   pre-combined transition shorthand (--d-fast + --ease-std)
     --font-sans             alias for --ff-sans (consumed by v2.css classes)
     --font-mono             alias for --ff-mono (consumed by v2.css classes)

   NOT CHANGED (risk-mitigated):
     --bg-0..3 oklch values  unchanged — light mode compatibility
     --fg-0..3 oklch values  unchanged — light mode compatibility
     --line-1..3             unchanged — alpha-based, light mode compatible
     --r-1..3                unchanged — load-bearing across 37 templates
     Accent system           unchanged — per-service hue remains dynamic
   ------------------------------------------------------------ */

/* ----- SELF-HOSTED FONTS (latin subset, variable) ----- */
@font-face {
  font-family: "Inter Tight";
  src: url("/static/fonts/InterTight-latin.woff2") format("woff2");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6,
                 U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F,
                 U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "JetBrains Mono";
  src: url("/static/fonts/JetBrainsMono-latin.woff2") format("woff2");
  font-weight: 100 800;
  font-style: normal;
  font-display: swap;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6,
                 U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F,
                 U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

@layer reset, tokens, components, motion, utilities, app;

/* ============================================================
   TOKENS
   ============================================================ */
@layer tokens {
  :root {
    /* Per-service brand hues */
    --hue-suite: 230;     /* electric blue */
    --hue-paste: 145;     /* signal green */
    --hue-short: 35;      /* ember orange */
    --hue-transfer: 295;  /* violet */
    --hue-tools: 195;     /* cyan */

    /* Active service (overridden via [data-service] on body) */
    --service-hue: var(--hue-suite);
    --service-chroma: 0.18;

    --accent: oklch(0.72 var(--service-chroma) var(--service-hue));
    --accent-strong: oklch(0.62 var(--service-chroma) var(--service-hue));
    --accent-soft: oklch(from var(--accent) l c h / 0.14);
    --accent-line: oklch(from var(--accent) l c h / 0.28);
    --accent-fg: #f8fbff;   /* near-white for text on filled accent backgrounds */

    /* Type — Inter Tight workhorse, JetBrains Mono for code/labels */
    --ff-sans: "Inter Tight", "Inter", system-ui, sans-serif;
    --ff-mono: "JetBrains Mono", ui-monospace, monospace;
    /* Alias names expected by v2.css (no ff- prefix) */
    --font-sans: var(--ff-sans);
    --font-mono: var(--ff-mono);

    /* Fluid type scale */
    --t-12: clamp(0.72rem, 0.70rem + 0.10vw, 0.78rem);
    --t-13: clamp(0.79rem, 0.77rem + 0.12vw, 0.85rem);
    --t-14: clamp(0.86rem, 0.84rem + 0.14vw, 0.94rem);
    --t-16: 1rem;
    --t-18: clamp(1.06rem, 1.02rem + 0.20vw, 1.18rem);
    --t-22: clamp(1.30rem, 1.22rem + 0.40vw, 1.52rem);
    --t-28: clamp(1.55rem, 1.40rem + 0.75vw, 1.95rem);
    --t-40: clamp(2.00rem, 1.70rem + 1.50vw, 2.85rem);
    --t-56: clamp(2.60rem, 2.10rem + 2.50vw, 4.00rem);

    /* Spacing */
    --s-1: 4px;  --s-2: 8px;  --s-3: 12px; --s-4: 16px;
    --s-5: 24px; --s-6: 32px; --s-8: 48px; --s-10: 64px; --s-12: 96px;

    /* Radii — modernist 2-4px */
    --r-1: 2px;
    --r-2: 4px;
    --r-3: 8px;
    --r-pill: 999px;

    /* Motion */
    --d-fast: 120ms;
    --d-med: 240ms;
    --d-slow: 420ms;
    --ease-std: cubic-bezier(0.2, 0.6, 0.2, 1);
    --t-1: var(--d-fast) var(--ease-std);   /* pre-combined shorthand (v2 pattern) */

    /* ----- Dark mode (default) ----- */
    --bg-0: oklch(0.12 0.005 250);
    --bg-1: oklch(0.16 0.005 250);
    --bg-2: oklch(0.20 0.006 250);
    --bg-3: oklch(0.25 0.007 250);
    /* v2 surface levels — dark only, used by .v2-app */
    --bg-4: #1d1f29;
    --bg-5: #262834;

    --fg-0: oklch(0.96 0.003 250);
    --fg-1: oklch(0.78 0.005 250);
    --fg-2: oklch(0.58 0.006 250);
    --fg-3: oklch(0.42 0.006 250);

    /* 5-level hex text scale (dark only) — consumed by .v2-app surfaces.
       --fg-0..3 remain the canonical light-mode-aware text tokens. */
    --text-0: #f4f5f8;
    --text-1: #c9ccd6;
    --text-2: #8a8e9c;
    --text-3: #5a5e6b;
    --text-4: #3d4049;

    --line-1: oklch(1 0 0 / 0.07);
    --line-2: oklch(1 0 0 / 0.12);
    --line-3: oklch(1 0 0 / 0.20);

    --shadow-1: 0 1px 0 oklch(1 0 0 / 0.04) inset, 0 8px 24px oklch(0 0 0 / 0.45);
    --shadow-2: 0 1px 0 oklch(1 0 0 / 0.05) inset, 0 24px 60px oklch(0 0 0 / 0.55);

    --status-ok:       oklch(0.78 0.17 145);
    --status-warn:     oklch(0.82 0.16 85);
    --status-err:      oklch(0.70 0.21 25);
    --status-info:     oklch(0.74 0.16 230);
    /* v2 semantic status variants */
    --status-active:   oklch(0.78 0.15 155);   /* green active indicator (v2 ecosystem bar) */
    --status-redirect: oklch(0.78 0.13 80);    /* amber redirect indicator */
    --status-planned:  #5a5e6b;               /* dim text for planned/future items */

    /* Glass surfaces (used by .glass utility + header) */
    --glass-bg:   oklch(from var(--bg-0) l c h / 0.78);
    --glass-blur: blur(14px) saturate(140%);

    color-scheme: dark;
  }

  /* ----- Light mode ----- */
  [data-theme="light"] {
    --bg-0: oklch(0.985 0.002 250);
    --bg-1: oklch(0.96 0.003 250);
    --bg-2: oklch(0.93 0.004 250);
    --bg-3: oklch(0.89 0.005 250);

    --fg-0: oklch(0.18 0.005 250);
    --fg-1: oklch(0.38 0.006 250);
    --fg-2: oklch(0.55 0.006 250);
    --fg-3: oklch(0.70 0.005 250);

    --line-1: oklch(0 0 0 / 0.06);
    --line-2: oklch(0 0 0 / 0.11);
    --line-3: oklch(0 0 0 / 0.18);

    --shadow-1: 0 1px 2px oklch(0 0 0 / 0.04), 0 8px 24px oklch(0 0 0 / 0.06);
    --shadow-2: 0 2px 4px oklch(0 0 0 / 0.05), 0 24px 60px oklch(0 0 0 / 0.10);

    --glass-bg: oklch(1 0 0 / 0.72);

    color-scheme: light;
  }

  /* Per-service scoping */
  [data-service="suite"]    { --service-hue: var(--hue-suite); }
  [data-service="paste"]    { --service-hue: var(--hue-paste);    --service-chroma: 0.17; }
  [data-service="short"]    { --service-hue: var(--hue-short);    --service-chroma: 0.19; }
  [data-service="transfer"] { --service-hue: var(--hue-transfer); --service-chroma: 0.20; }
  [data-service="tools"]    { --service-hue: var(--hue-tools);    --service-chroma: 0.16; }
}

/* ============================================================
   RESET
   ============================================================ */
@layer reset {
  *, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
  html { font-size: 16px; -webkit-text-size-adjust: 100%; }
  body {
    font-family: var(--ff-sans);
    font-feature-settings: "ss01", "cv11";
    font-size: var(--t-14);
    line-height: 1.5;
    color: var(--fg-0);
    background: var(--bg-0);
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
    min-height: 100vh;
  }
  img, svg { display: block; max-width: 100%; }
  button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
  input, textarea, select { font: inherit; color: inherit; }
  a { color: inherit; text-decoration: none; }
  ::selection { background: var(--accent-soft); color: var(--fg-0); }
}

/* ============================================================
   COMPONENTS
   ============================================================ */
@layer components {

  /* ----- LAYOUT PRIMITIVES ----- */
  .page { display: flex; flex-direction: column; min-height: 100vh; }
  .page__content { flex: 1; padding: var(--s-6) 0; }
  .container { max-width: 1280px; margin-inline: auto; padding: 0 var(--s-4); }

  /* ----- HEADER (subtle glass — the only ambient transparency in the baseline) ----- */
  .header {
    border-bottom: 1px solid var(--line-2);
    background: var(--glass-bg);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    position: sticky; top: 0; z-index: 50;
  }
  .header__inner {
    display: flex; align-items: center; justify-content: space-between;
    height: 56px; gap: var(--s-4);
  }
  .header__brand { display: flex; align-items: center; gap: var(--s-3); }
  .header__title {
    font-size: var(--t-14); font-weight: 600; letter-spacing: -0.01em;
    color: var(--fg-0);
  }
  .header__nav { display: flex; align-items: center; gap: var(--s-1); flex-wrap: wrap; }
  .header__link {
    height: 32px; padding: 0 10px;
    display: inline-flex; align-items: center; gap: 6px;
    font-size: var(--t-13); color: var(--fg-1);
    border-radius: var(--r-2);
    transition: color var(--d-fast), background var(--d-fast);
  }
  .header__link:hover { color: var(--fg-0); background: var(--bg-2); }
  .header__link[aria-current="page"] {
    color: var(--fg-0);
    border-bottom: 2px solid var(--accent);
    border-radius: 0;
  }

  /* ----- THEME TOGGLE (SVG moon/sun pair) ----- */
  .theme-toggle {
    height: 32px; width: 32px;
    display: inline-grid; place-items: center;
    border-radius: var(--r-2);
    color: var(--fg-1);
    transition: color var(--d-fast), background var(--d-fast);
  }
  .theme-toggle:hover { color: var(--fg-0); background: var(--bg-2); }
  .theme-toggle__sun { display: none; }
  [data-theme="light"] .theme-toggle__moon { display: none; }
  [data-theme="light"] .theme-toggle__sun { display: inline-grid; }

  /* ----- FOOTER ----- */
  .footer {
    border-top: 1px solid var(--line-1);
    background: var(--bg-0);
    padding: var(--s-5) 0;
    margin-top: var(--s-8);
  }
  .footer__inner {
    display: flex; align-items: center; justify-content: space-between;
    flex-wrap: wrap; gap: var(--s-3);
    font-size: var(--t-13); color: var(--fg-2);
  }
  .footer__links { display: flex; gap: var(--s-4); }
  .footer__link {
    color: var(--fg-2);
    transition: color var(--d-fast);
  }
  .footer__link:hover { color: var(--fg-0); }

  /* ----- FLASH MESSAGES ----- */
  .flash-container { padding: var(--s-3) 0; display: flex; flex-direction: column; gap: var(--s-2); }
  .flash {
    padding: var(--s-3) var(--s-4);
    border-radius: var(--r-2);
    border: 1px solid var(--line-2);
    background: var(--bg-1);
    font-size: var(--t-13);
    display: flex; align-items: center; gap: var(--s-2);
  }
  .flash--success, .flash--ok { color: var(--status-ok); border-color: oklch(from var(--status-ok) l c h / 0.30); background: oklch(from var(--status-ok) l c h / 0.08); }
  .flash--error,   .flash--err { color: var(--status-err); border-color: oklch(from var(--status-err) l c h / 0.30); background: oklch(from var(--status-err) l c h / 0.08); }
  .flash--warning, .flash--warn { color: var(--status-warn); border-color: oklch(from var(--status-warn) l c h / 0.30); background: oklch(from var(--status-warn) l c h / 0.08); }
  .flash--info { color: var(--status-info); border-color: oklch(from var(--status-info) l c h / 0.30); background: oklch(from var(--status-info) l c h / 0.08); }

  /* ----- LOGO — black disk, cyan ring, magenta diagonal slash, white F+Y ----- */
  .ofy-logo {
    --size: 28px;
    --ring: oklch(0.82 0.16 215);   /* cyan */
    --slash: oklch(0.62 0.22 350);  /* magenta */
    width: var(--size); height: var(--size);
    position: relative; display: inline-block;
    border-radius: 50%;
    background: oklch(0.08 0.005 250);
    flex-shrink: 0;
    box-shadow:
      0 0 0 1px oklch(from var(--ring) l c h / 0.20),
      0 0 calc(var(--size) * 0.28) oklch(from var(--ring) l c h / 0.35);
  }
  .ofy-logo::before {
    content: ""; position: absolute; inset: 0;
    border-radius: 50%;
    border: 1.5px solid var(--ring);
    box-shadow:
      0 0 6px oklch(from var(--ring) l c h / 0.55) inset,
      0 0 6px oklch(from var(--ring) l c h / 0.45);
  }
  .ofy-logo::after {
    content: ""; position: absolute;
    left: -8%; right: -8%; top: 50%;
    height: max(1.5px, calc(var(--size) * 0.03));
    background: var(--slash);
    transform: translateY(-50%) rotate(-45deg);
    transform-origin: center;
    box-shadow: 0 0 4px oklch(from var(--slash) l c h / 0.7);
  }
  .ofy-logo > .f, .ofy-logo > .y {
    position: absolute; font-family: var(--ff-sans); font-weight: 800;
    font-size: calc(var(--size) * 0.40); color: oklch(0.98 0 0);
    line-height: 1; letter-spacing: -0.02em;
    text-shadow: 0 0 4px oklch(1 0 0 / 0.35);
  }
  .ofy-logo > .f { top: 18%; left: 22%; }
  .ofy-logo > .y { bottom: 18%; right: 22%; }
  .ofy-logo--lg { --size: 40px; }
  .ofy-logo--xl { --size: 64px; }
  /* Light theme: drop the inner glow */
  [data-theme="light"] .ofy-logo > .f,
  [data-theme="light"] .ofy-logo > .y { text-shadow: none; }

  /* ----- WORDMARK ----- */
  .ofy-mark {
    display: inline-flex; align-items: center; gap: var(--s-2);
    font-family: var(--ff-sans); font-weight: 700; letter-spacing: -0.01em;
    color: var(--fg-0);
  }
  .ofy-mark__name { font-size: var(--t-14); }
  .ofy-mark__service {
    font-family: var(--ff-mono); font-size: var(--t-12);
    color: var(--accent); font-weight: 500;
    border-left: 2px solid var(--accent);
    padding-left: 6px;
    text-transform: lowercase;
  }

  /* ----- BUTTONS ----- */
  .btn {
    display: inline-flex; align-items: center; justify-content: center; gap: var(--s-2);
    height: 32px; padding: 0 var(--s-3);
    font-family: var(--ff-sans); font-size: var(--t-13); font-weight: 500;
    letter-spacing: -0.005em;
    border-radius: var(--r-2);
    border: 1px solid transparent;
    transition: background var(--d-fast) var(--ease-std),
                border-color var(--d-fast),
                color var(--d-fast),
                transform var(--d-fast);
    white-space: nowrap;
    cursor: pointer;
  }
  .btn:focus-visible {
    outline: 2px solid var(--accent); outline-offset: 2px;
  }
  .btn--primary {
    background: var(--accent); color: oklch(0.12 0 0);
    border-color: var(--accent);
  }
  .btn--primary:hover {
    background: oklch(from var(--accent) calc(l + 0.05) c h);
  }
  .btn--secondary {
    background: var(--bg-2); color: var(--fg-0);
    border-color: var(--line-2);
  }
  .btn--secondary:hover { background: var(--bg-3); border-color: var(--line-3); }
  .btn--ghost {
    background: transparent; color: var(--fg-1);
    border-color: var(--line-2);
  }
  .btn--ghost:hover { color: var(--fg-0); border-color: var(--line-3); background: var(--bg-2); }
  .btn--danger {
    background: oklch(from var(--status-err) l c h / 0.12);
    color: var(--status-err);
    border-color: oklch(from var(--status-err) l c h / 0.40);
  }
  .btn--danger:hover {
    background: oklch(from var(--status-err) l c h / 0.20);
    border-color: var(--status-err);
  }
  .btn--icon { width: 32px; padding: 0; }
  .btn--lg { height: 40px; padding: 0 var(--s-4); font-size: var(--t-14); }
  .btn--sm { height: 26px; padding: 0 var(--s-2); font-size: var(--t-12); }
  .btn--full { width: 100%; }

  /* ----- INPUTS ----- */
  .field, .form-group {
    display: flex; flex-direction: column; gap: 6px;
    margin-bottom: var(--s-3);
  }
  .field__label, .label {
    font-size: var(--t-12); font-weight: 500; color: var(--fg-1);
    font-family: var(--ff-mono); text-transform: uppercase; letter-spacing: 0.04em;
    display: block;
  }
  .input, .select, input[type="text"]:not([class]), input[type="email"]:not([class]),
  input[type="password"]:not([class]), input[type="url"]:not([class]),
  input[type="number"]:not([class]), select:not([class]), textarea:not([class]) {
    width: 100%;
    height: 32px; padding: 0 var(--s-3);
    background: var(--bg-1); color: var(--fg-0);
    border: 1px solid var(--line-2);
    border-radius: var(--r-2);
    font-size: var(--t-13);
    transition: border-color var(--d-fast), background var(--d-fast), box-shadow var(--d-fast);
  }
  .input::placeholder, textarea::placeholder { color: var(--fg-3); }
  .input:focus, .select:focus, textarea:focus,
  input[type="text"]:focus, input[type="email"]:focus,
  input[type="password"]:focus, input[type="url"]:focus,
  input[type="number"]:focus, select:focus {
    outline: none; border-color: var(--accent);
    background: var(--bg-0);
    box-shadow: 0 0 0 3px var(--accent-soft);
  }
  .input--lg { height: 40px; font-size: var(--t-14); }
  textarea, textarea.input {
    padding: var(--s-2) var(--s-3); height: auto; min-height: 120px; resize: vertical;
    line-height: 1.55; font-family: var(--ff-mono); font-size: var(--t-13);
  }

  /* ----- CARD / PANEL ----- */
  .panel {
    background: var(--bg-1);
    border: 1px solid var(--line-2);
    border-radius: var(--r-2);
  }
  .panel--glass {
    background: var(--glass-bg);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
  }
  .panel__hd {
    display: flex; align-items: center; justify-content: space-between;
    padding: var(--s-3) var(--s-4);
    border-bottom: 1px solid var(--line-1);
    min-height: 44px;
  }
  .panel__hd-title {
    font-size: var(--t-13); font-weight: 600; color: var(--fg-0);
    display: flex; align-items: center; gap: var(--s-2);
  }
  .panel__hd-meta {
    font-family: var(--ff-mono); font-size: var(--t-12); color: var(--fg-2);
  }
  .panel__bd { padding: var(--s-4); }

  /* ----- BADGES / TAGS ----- */
  .tag {
    display: inline-flex; align-items: center; gap: 4px;
    height: 20px; padding: 0 6px;
    font-family: var(--ff-mono); font-size: 11px; font-weight: 500;
    color: var(--fg-1); background: var(--bg-2);
    border: 1px solid var(--line-1);
    border-radius: var(--r-1);
    text-transform: uppercase; letter-spacing: 0.04em;
  }
  .tag--accent { color: var(--accent); background: var(--accent-soft); border-color: var(--accent-line); }
  .tag--ok    { color: var(--status-ok); background: oklch(from var(--status-ok) l c h / 0.10); border-color: oklch(from var(--status-ok) l c h / 0.25); }
  .tag--warn  { color: var(--status-warn); background: oklch(from var(--status-warn) l c h / 0.12); border-color: oklch(from var(--status-warn) l c h / 0.25); }
  .tag--err   { color: var(--status-err); background: oklch(from var(--status-err) l c h / 0.10); border-color: oklch(from var(--status-err) l c h / 0.25); }

  .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; flex-shrink: 0; }

  /* ----- KEYCAP ----- */
  .kbd {
    display: inline-grid; place-items: center;
    height: 18px; min-width: 18px; padding: 0 5px;
    font-family: var(--ff-mono); font-size: 10px; font-weight: 600; color: var(--fg-1);
    background: var(--bg-2); border: 1px solid var(--line-2);
    border-bottom-width: 2px;
    border-radius: 3px;
  }

  /* ----- SCROLLBAR ----- */
  ::-webkit-scrollbar { width: 10px; height: 10px; }
  ::-webkit-scrollbar-track { background: transparent; }
  ::-webkit-scrollbar-thumb {
    background: var(--line-2); border-radius: 999px; border: 2px solid transparent; background-clip: padding-box;
  }
  ::-webkit-scrollbar-thumb:hover { background: var(--line-3); background-clip: padding-box; border: 2px solid transparent; }

  /* ----- TYPE ----- */
  .h1 { font-size: var(--t-56); font-weight: 700; letter-spacing: -0.03em; line-height: 1.02; color: var(--fg-0); }
  .h2 { font-size: var(--t-40); font-weight: 700; letter-spacing: -0.025em; line-height: 1.05; color: var(--fg-0); }
  .h3 { font-size: var(--t-28); font-weight: 600; letter-spacing: -0.02em; line-height: 1.15; color: var(--fg-0); }
  .h4 { font-size: var(--t-22); font-weight: 600; letter-spacing: -0.015em; line-height: 1.2; color: var(--fg-0); }
  .lead { font-size: var(--t-18); color: var(--fg-1); line-height: 1.5; max-width: 60ch; }
  .micro { font-family: var(--ff-mono); font-size: var(--t-12); color: var(--fg-2); text-transform: uppercase; letter-spacing: 0.06em; }

  /* ----- DIVIDER ----- */
  .hr { height: 1px; background: var(--line-2); border: 0; }

  /* ----- STATS GRID + CARDS ----- */
  .stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: var(--s-3);
    margin-bottom: var(--s-5);
  }
  .stat-card {
    padding: var(--s-4);
    background: var(--bg-1);
    border: 1px solid var(--line-2);
    border-radius: var(--r-2);
    position: relative;
    overflow: hidden;
  }
  .stat-card::before {
    content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 2px;
    background: var(--accent);
  }
  .stat-card__label {
    font-family: var(--ff-mono);
    font-size: var(--t-12);
    color: var(--fg-2);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-bottom: var(--s-2);
    display: flex; align-items: center; gap: 6px;
  }
  .stat-card__value {
    font-size: var(--t-28);
    font-weight: 700;
    color: var(--fg-0);
    letter-spacing: -0.02em;
    line-height: 1;
    font-family: var(--ff-mono);
  }
  .stat-card__delta {
    font-size: var(--t-12);
    color: var(--accent);
    margin-top: var(--s-2);
  }

  /* ----- DATA TABLE ----- */
  .data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: var(--t-13);
  }
  .data-table th {
    text-align: left;
    padding: var(--s-3) var(--s-4);
    font-family: var(--ff-mono);
    font-size: var(--t-12);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--fg-2);
    border-bottom: 1px solid var(--line-2);
    background: var(--bg-2);
  }
  .data-table td {
    padding: var(--s-3) var(--s-4);
    border-bottom: 1px solid var(--line-1);
    color: var(--fg-1);
  }
  .data-table tr:last-child td { border-bottom: 0; }
  .data-table tr:hover td { background: var(--bg-2); }
  .data-table.compact th, .data-table.compact td { padding: var(--s-2) var(--s-3); font-size: var(--t-12); }

  /* ----- TABLE/LIST ROWS ----- */
  .row {
    display: grid; align-items: center;
    padding: var(--s-3) var(--s-4);
    border-bottom: 1px solid var(--line-1);
    font-size: var(--t-13);
    transition: background var(--d-fast);
  }
  .row:last-child { border-bottom: 0; }
  .row:hover { background: var(--bg-2); }

  /* ----- METER ----- */
  .meter { height: 4px; background: var(--bg-2); border-radius: 999px; overflow: hidden; }
  .meter > i {
    display: block; height: 100%;
    background: var(--accent);
    border-radius: 999px;
  }

  /* ----- LEGACY topbar (kept for non-base.html consumers) ----- */
  .topbar {
    display: flex; align-items: center; justify-content: space-between;
    padding: 0 var(--s-4);
    height: 48px;
    border-bottom: 1px solid var(--line-2);
    background: var(--bg-0);
  }
  .topbar__brand { display: flex; align-items: center; gap: var(--s-3); }
  .topbar__nav { display: flex; align-items: center; gap: var(--s-1); }
  .nav-link {
    height: 28px; padding: 0 10px;
    display: inline-flex; align-items: center; gap: 6px;
    font-size: var(--t-13); color: var(--fg-1);
    border-radius: var(--r-2);
  }
  .nav-link:hover { background: var(--bg-2); color: var(--fg-0); }
  .nav-link[aria-current="page"] {
    color: var(--fg-0);
    border-bottom: 2px solid var(--accent);
    border-radius: 0;
  }

  /* ----- TOAST ----- */
  .toast-container {
    position: fixed;
    top: var(--s-4); right: var(--s-4);
    z-index: 10000;
    display: flex; flex-direction: column;
    gap: var(--s-2);
    pointer-events: none;
    max-width: 380px;
    width: calc(100vw - var(--s-8));
  }
  .toast {
    pointer-events: auto;
    display: flex; align-items: flex-start; gap: var(--s-3);
    padding: var(--s-3) var(--s-4);
    background: var(--bg-1);
    border: 1px solid var(--line-2);
    border-radius: var(--r-2);
    transform: translateX(120%);
    opacity: 0;
    transition: transform var(--d-med) var(--ease-std), opacity var(--d-med);
    position: relative;
    overflow: hidden;
  }
  .toast.show { transform: translateX(0); opacity: 1; }
  .toast.hide { transform: translateX(120%); opacity: 0; }
  .toast__icon {
    flex-shrink: 0;
    width: 24px; height: 24px;
    display: grid; place-items: center;
    border-radius: var(--r-1);
    background: var(--bg-2);
  }
  .toast__content { flex: 1; min-width: 0; }
  .toast__title {
    font-weight: 600; font-size: var(--t-13);
    color: var(--fg-0); margin-bottom: 2px;
  }
  .toast__message {
    font-size: var(--t-13); color: var(--fg-1);
    word-break: break-word; line-height: 1.5;
  }
  .toast__close {
    flex-shrink: 0;
    width: 24px; height: 24px;
    display: grid; place-items: center;
    color: var(--fg-2);
    cursor: pointer;
    border-radius: var(--r-1);
    transition: color var(--d-fast), background var(--d-fast);
  }
  .toast__close:hover { color: var(--fg-0); background: var(--bg-2); }
  .toast__progress {
    position: absolute; bottom: 0; left: 0;
    height: 2px; background: currentColor; opacity: 0.7;
    transition: width linear;
  }
  .toast--success { border-color: oklch(from var(--status-ok) l c h / 0.40); }
  .toast--success .toast__icon { color: var(--status-ok); }
  .toast--success .toast__progress { background: var(--status-ok); }
  .toast--error { border-color: oklch(from var(--status-err) l c h / 0.40); }
  .toast--error .toast__icon { color: var(--status-err); }
  .toast--error .toast__progress { background: var(--status-err); }
  .toast--warning { border-color: oklch(from var(--status-warn) l c h / 0.40); }
  .toast--warning .toast__icon { color: var(--status-warn); }
  .toast--warning .toast__progress { background: var(--status-warn); }
  .toast--info { border-color: oklch(from var(--status-info) l c h / 0.40); }
  .toast--info .toast__icon { color: var(--status-info); }
  .toast--info .toast__progress { background: var(--status-info); }
}

/* ============================================================
   MOTION — gated by prefers-reduced-motion
   ============================================================ */
@layer motion {
  :root { --motion: 1; }
  @media (prefers-reduced-motion: reduce) {
    :root { --motion: 0; }
  }

  @media (prefers-reduced-motion: no-preference) {

    @keyframes ofy-fade-up {
      from { opacity: 0; transform: translateY(8px); }
      to   { opacity: 1; transform: none; }
    }
    @keyframes ofy-fade-in {
      from { opacity: 0; }
      to   { opacity: 1; }
    }
    @keyframes ofy-logo-pulse {
      0%, 100% { filter: hue-rotate(-12deg); }
      50%      { filter: hue-rotate(12deg); }
    }
    @keyframes ofy-logo-shimmer {
      0%   { transform: rotate(0deg); }
      100% { transform: rotate(360deg); }
    }
    @keyframes ofy-hero-sweep {
      from { background-position: -120% 0; }
      to   { background-position: 220% 0; }
    }

    /* Stagger first 6 children of the main page content */
    .page__content > * {
      animation: ofy-fade-up var(--d-slow) var(--ease-std) both;
    }
    .page__content > *:nth-child(1) { animation-delay:   0ms; }
    .page__content > *:nth-child(2) { animation-delay:  60ms; }
    .page__content > *:nth-child(3) { animation-delay: 120ms; }
    .page__content > *:nth-child(4) { animation-delay: 180ms; }
    .page__content > *:nth-child(5) { animation-delay: 240ms; }
    .page__content > *:nth-child(6) { animation-delay: 300ms; }
    .page__content > *:nth-child(n+7) { animation-delay: 360ms; }

    .panel { animation: ofy-fade-up var(--d-med) var(--ease-std) both; }
    .header { animation: ofy-fade-in var(--d-med) var(--ease-std) both; }

    .ofy-logo { isolation: isolate; }
    .ofy-logo::after {
      animation: ofy-logo-pulse 8s var(--ease-std) infinite;
      transform-origin: center;
    }
    .ofy-logo:hover::before {
      background: conic-gradient(
        from 0deg,
        transparent 0deg,
        transparent 270deg,
        oklch(from var(--ring) l c h / 0.55) 320deg,
        transparent 360deg
      );
      animation: ofy-logo-shimmer 600ms linear;
    }

    .btn:hover { transform: translateY(-1px); }
    .btn:active { transform: translateY(0); }

    .header__link { position: relative; }
    .header__link::after {
      content: ""; position: absolute;
      left: 10px; right: 10px; bottom: 4px;
      height: 1px;
      background: var(--accent);
      transform: scaleX(0);
      transform-origin: left center;
      transition: transform var(--d-fast) var(--ease-std);
    }
    .header__link:hover::after { transform: scaleX(1); }
    .header__link[aria-current="page"]::after { display: none; }

    .row { transition: background var(--d-fast), border-color var(--d-fast); }
    .row:hover { border-bottom-color: var(--line-3); }

    .panel { transition: border-color var(--d-fast); }
    .panel:hover { border-color: var(--line-3); }

    .input:focus, textarea:focus, .select:focus {
      animation: ofy-fade-in var(--d-fast) var(--ease-std);
    }

    .hero-sweep { position: relative; overflow: hidden; }
    .hero-sweep::before {
      content: ""; position: absolute;
      left: 0; top: 0; right: 0; height: 1px;
      background: linear-gradient(90deg,
        transparent 0%,
        var(--accent) 40%,
        var(--accent) 60%,
        transparent 100%);
      background-size: 50% 100%;
      background-repeat: no-repeat;
      animation: ofy-hero-sweep 1400ms var(--ease-std) 200ms 1 both;
    }

    .theme-toggle__moon, .theme-toggle__sun {
      transition: opacity var(--d-fast), transform var(--d-fast);
    }
  }
}

/* ============================================================
   UTILITIES
   ============================================================ */
@layer utilities {
  .stack { display: flex; flex-direction: column; }
  .row-flex { display: flex; align-items: center; }
  .grid { display: grid; }
  .gap-1 { gap: var(--s-1); } .gap-2 { gap: var(--s-2); } .gap-3 { gap: var(--s-3); }
  .gap-4 { gap: var(--s-4); } .gap-5 { gap: var(--s-5); } .gap-6 { gap: var(--s-6); }
  .grow { flex: 1; }
  .mono { font-family: var(--ff-mono); }
  .muted { color: var(--fg-2); }
  .dim { color: var(--fg-1); }
  .right { margin-left: auto; }
  .center { margin-inline: auto; }
  .nowrap { white-space: nowrap; }
  .truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .hidden { display: none !important; }
  .sr-only {
    position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
    overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0;
  }
  .text-center { text-align: center; }
  .text-right { text-align: right; }
  .text-muted { color: var(--fg-2); }

  .mt-1 { margin-top: var(--s-1); } .mt-2 { margin-top: var(--s-2); } .mt-3 { margin-top: var(--s-3); }
  .mt-4 { margin-top: var(--s-4); } .mt-5 { margin-top: var(--s-5); } .mt-6 { margin-top: var(--s-6); }
  .mb-1 { margin-bottom: var(--s-1); } .mb-2 { margin-bottom: var(--s-2); } .mb-3 { margin-bottom: var(--s-3); }
  .mb-4 { margin-bottom: var(--s-4); } .mb-5 { margin-bottom: var(--s-5); } .mb-6 { margin-bottom: var(--s-6); }

  /* Opt-in glass surface */
  .glass {
    background: var(--glass-bg);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
  }
}

/* ============================================================
   SKELETON LOADERS
   Pure-CSS shimmer for placeholder UI during loads. Match the
   real content's bounding box to avoid CLS on reveal. Reduced-
   motion users see a static placeholder, no sweep.
   ============================================================ */
@layer components {
  .skel {
    --skel-base: var(--bg-2);
    --skel-shine: var(--bg-3);
    background: linear-gradient(100deg,
      var(--skel-base) 40%,
      var(--skel-shine) 50%,
      var(--skel-base) 60%) no-repeat;
    background-size: 200% 100%;
    background-position-x: 150%;
    animation: ofy-skel-sweep 1.4s ease-in-out infinite;
    border-radius: var(--r-2);
    pointer-events: none;
    user-select: none;
    display: block;
  }
  /* Inline variants so cards can compose without bespoke CSS */
  .skel--chip   { height: 1.25rem;  width: 60%; }
  .skel--line   { height: 0.875rem; width: 100%; margin-block: var(--s-1); }
  .skel--short  { width: 72%; }
  .skel--pill   { height: 1.1rem;   width: 4rem; border-radius: var(--r-pill); }
  .skel--block  { width: 100%; min-height: 80px; }
  .skel--circle { aspect-ratio: 1; border-radius: 50%; }

  /* Skeleton tool-card mirroring the real .tool-card shape — title
     chip + two desc lines + status pill — so swap-in doesn't shift. */
  .skel-tool-card {
    background: var(--bg-1);
    border: 1px solid var(--line-1);
    border-radius: var(--r-3);
    padding: var(--s-4);
    display: flex;
    flex-direction: column;
    gap: var(--s-2);
  }
  .skel-tool-card__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--s-2);
  }

  /* Skeleton category chip for the landing categories grid */
  .skel-chip {
    height: 2rem;
    width: 8rem;
    border-radius: var(--r-pill);
    background: linear-gradient(100deg,
      var(--bg-2) 40%, var(--bg-3) 50%, var(--bg-2) 60%) no-repeat;
    background-size: 200% 100%;
    background-position-x: 150%;
    animation: ofy-skel-sweep 1.4s ease-in-out infinite;
    display: inline-block;
  }

  /* Full-page skeleton replacement for the tool-loading spinner */
  .skel-tool-page {
    max-width: 1400px;
    margin: 0 auto;
    padding: var(--s-5);
    display: flex;
    flex-direction: column;
    gap: var(--s-4);
  }
  .skel-tool-page__hd { display: flex; align-items: center; gap: var(--s-3); }
  .skel-tool-page__body {
    background: var(--bg-1);
    border: 1px solid var(--line-1);
    border-radius: var(--r-3);
    padding: var(--s-5);
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--s-4);
    min-height: 320px;
  }
  @media (max-width: 900px) {
    .skel-tool-page__body { grid-template-columns: 1fr; }
  }
}

@keyframes ofy-skel-sweep {
  0%   { background-position-x: 150%; }
  100% { background-position-x: -50%; }
}

@media (prefers-reduced-motion: reduce) {
  .skel, .skel-chip { animation-duration: 0.001ms; }
}

/* ============================================================
   TOOLTIP — shared singleton driven by OFY.tooltip (ofy.js)
   Reads `data-tooltip="..."`. WCAG 2.2 SC 1.4.13 compliant
   (dismissible via Escape, persists on hover, hides on blur).
   Anchored via JS for browser-portability; the singleton sits
   in <body> so it escapes overflow/scroll clipping naturally.
   ============================================================ */
@layer components {
  .ofy-tooltip {
    position: fixed;
    top: -9999px;
    left: 0;
    z-index: 10000;
    background: var(--bg-3);
    color: var(--fg-0);
    font-family: var(--ff-sans);
    font-size: var(--t-12);
    font-weight: 500;
    padding: 6px 10px;
    border-radius: var(--r-2);
    border: 1px solid var(--line-2);
    box-shadow: var(--shadow-1);
    max-width: 280px;
    white-space: normal;
    line-height: 1.35;
    pointer-events: none;
    opacity: 0;
    transform: translateY(2px);
    transition: opacity var(--d-fast), transform var(--d-fast);
  }
  .ofy-tooltip.show {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ============================================================
   VIEW TRANSITIONS — default crossfade for OFY.transition().
   Studios that want a custom transition can override the
   ::view-transition-old/new pseudo-elements per route name.
   ============================================================ */
::view-transition-old(root),
::view-transition-new(root) {
  animation-duration: var(--d-med);
  animation-timing-function: var(--ease-std);
}
@media (prefers-reduced-motion: reduce) {
  ::view-transition-old(root),
  ::view-transition-new(root) {
    animation-duration: 0.001ms;
  }
}
