/* ══════════════════════════════════════════════════════════════
   518.PLUS design tokens — the ONLY place raw design values live
   (values per the approved v2 prototype :root).
   components.css consumes tokens; page CSS consumes both.
   Guarded by tools/guard_css_tokens.py: no :root anywhere else,
   every variable reference must resolve here, no raw hex outside
   this file.
   ══════════════════════════════════════════════════════════════ */

:root {
  color-scheme: light;

  /* ── Color: brand ── */
  --brand: #ff4d4d;
  --brand-600: #e5383b;
  --brand-50: #fff3f3;
  --brand-100: #ffe2e2;
  --brand-strong: #ff2442;            /* hover on brand fills */
  --brand-deep: #e63b3b;
  --brand-soft: #fff1f2;              /* legacy soft name, same role */
  --brand-ink: #ffffff;               /* text on brand fills */
  --ink-hover: #262a31;               /* hover on ink (dark) fills */

  /* ── Color: neutral surfaces & ink ── */
  --ink: #0b0d10;
  --ink-2: #454b54;
  --ink-3: #5f6670;
  --ink-4: #b4b9c1;
  --line: rgba(11, 13, 16, 0.08);
  --line-2: rgba(11, 13, 16, 0.14);
  --bg: #fbfbfc;
  --card: #ffffff;
  --sunk: #f4f5f7;                    /* wells, code, chips */
  --overlay: rgba(11, 13, 16, 0.5);

  /* ── Color: semantic ── */
  --ok: #12a150;
  --ok-50: #eafbf1;
  --ok-700: #0a7d3d;              /* text-grade green (4.5+ on ok-50) */
  --warn: #f59e0b;
  --warn-50: #fffbeb;
  --danger: #dc2626;
  --danger-strong: #b91c1c;
  --danger-50: #fef2f2;
  --info: #2563eb;
  --info-50: #eff6ff;

  /* ── Color: raw ramp (rare, direct use) ── */
  --gray-100: #f2f4f5;
  --gray-200: #e8ecee;
  --gray-300: #d4dcdf;
  --gray-400: #b3bfc4;
  --gray-700: #38444c;
  --gray-900: #0f1419;

  /* ── Typography ── */
  --font-sans: -apple-system, BlinkMacSystemFont, "PingFang SC",
    "Noto Sans SC", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --font: var(--font-sans);

  --fs-xs: 12px;
  --fs-sm: 12.5px;
  --fs-base: 14px;
  --fs-md: 15px;
  --fs-lg: 17px;
  --fs-xl: 20px;
  --fs-2xl: clamp(26px, 4.5vw, 36px);

  --lh-tight: 1.25;
  --lh-base: 1.55;
  --lh-loose: 1.65;

  /* ── Spacing (4px base) ── */
  --s0: 2px;
  --s1: 4px;
  --s2: 8px;
  --s3: 12px;
  --s4: 16px;
  --s5: 24px;
  --s6: 32px;
  --s8: 48px;
  --s10: 64px;
  /* form rhythm: one gap between fields AND between the last field and
     the submit row — every form (auth/account/publish/keys/withdraw) */
  --form-gap: var(--s4);

  /* ── Radius ── */
  --r-xs: 6px;
  --r-sm: 10px;
  --r: 14px;
  --r-lg: 20px;
  --r-xl: 28px;
  --r-full: 999px;

  /* ── Shadows ── */
  --sh-1: 0 1px 2px rgba(11, 13, 16, 0.04), 0 1px 1px rgba(11, 13, 16, 0.03);
  --sh-2: 0 1px 2px rgba(11, 13, 16, 0.04), 0 8px 24px -8px rgba(11, 13, 16, 0.10);
  --sh-3: 0 2px 4px rgba(11, 13, 16, 0.04), 0 24px 48px -16px rgba(11, 13, 16, 0.18);
  --sh-4: 0 2px 4px rgba(11, 13, 16, 0.04), 0 32px 64px -20px rgba(11, 13, 16, 0.24);

  /* ── Borders ── */
  --border-w: 1px;
  --border-w-strong: 1.5px;

  /* ── Z-index ── */
  --z-dropdown: 30;
  --z-modal: 50;
  --z-toast: 60;

  /* ── Motion ── */
  --ease: 0.2s ease;
  --ease-in: 0.15s ease;

  /* ── Layout: two content widths + page gutter ──
     wrap = regular sections; narrow  = tool main column / result page  */
  --wrap: 1120px;
  --gut: 24px;
  --container-read: 780px;
  --container-work: 1120px;

  /* ── Operator back-office surface (samelabs.css consumers) ── */
  --sl-ok: #0f9f6e;
  --sl-ok-soft: rgba(15, 159, 110, 0.10);
  --sl-warn: #b7791f;
  --sl-warn-soft: rgba(183, 121, 31, 0.10);
  --sl-err: #d64545;
  --sl-err-soft: rgba(214, 69, 69, 0.10);
  --sl-purple: #7c5cf0;
  --sl-purple-soft: rgba(124, 92, 240, 0.10);
  --sl-surface: #ffffff;
  --sl-line: #e8edf0;
  --sl-th-bg: #fafbfc;
  --sl-row-alt: #fbfcfd;
  --sl-row-hover: #f7f9fb;
  --sl-ink-faint: #8a97a3;
  /* dark developer panel + terminal */
  --term-bg: #15181d;
  --term-ink: #c9ced6;
  --term-dim: #6b7280;
  --term-warm: #ff8a7a;
  --term-ok: #7ee2a8;
  --sl-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  --sl-ease: 0.15s ease;

  /* Breakpoints (media queries only; documented here):
     desktop ≥ 1024px   tablet 768–1023px   phone ≤ 767px (390 ref)  */
}

/* ── Reset ─────────────────────────────────────────────────── */
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { -webkit-text-size-adjust: 100%; overscroll-behavior: none; }

/* Any unsized inline svg must not blow up to the 300×150 default */
svg:not([width]):not([height]) { width: 20px; height: 20px; }

body {
  margin: 0;
  font-family: var(--font);
  font-size: var(--fs-md);
  line-height: var(--lh-base);
  background: var(--bg);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  touch-action: manipulation;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  padding-top: env(safe-area-inset-top);
}

:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }

a { color: var(--brand); text-decoration: none; }
h1, h2 { letter-spacing: -0.02em; margin: 0; }
h3, p, dl, dd { margin: 0; }
pre { margin: 0; font-family: var(--font-mono); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: 0.01ms !important; animation-duration: 0.01ms !important; }
}

/* ── Layout containers ─────────────────────────────────────── */
.wrap { max-width: var(--wrap); margin: 0 auto; padding: 0 var(--gut); }
.container-read { width: min(var(--container-read), 100% - var(--s6)); margin-inline: auto; }
.container-work { width: min(var(--container-work), 100% - var(--s6)); margin-inline: auto; }
@media (max-width: 767px) {
  :root { --gut: 16px; }
  .container-read, .container-work { width: min(100% - var(--s4), var(--container-read)); }
}

/* ── Utilities (logical properties only — RTL safe) ────────── */
.stack { display: flex; flex-direction: column; }
.stack-3 > * + * { margin-block-start: var(--s3); }
.stack-4 > * + * { margin-block-start: var(--s4); }
.stack-5 > * + * { margin-block-start: var(--s5); }
.row { display: flex; align-items: center; gap: var(--s2); }
.row-wrap { flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
.muted { color: var(--ink-2); }
.tertiary { color: var(--ink-3); }
.nowrap { white-space: nowrap; }
.hidden { display: none !important; }
.visually-hidden {
  position: absolute !important; width: 1px; height: 1px;
  margin: -1px; padding: 0; border: 0; clip: rect(0 0 0 0);
  overflow: hidden; white-space: nowrap;
}
