/* ══════════════════════════════════════════════════════════════
   518.PLUS design tokens — the ONLY place raw design values live.
   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.

   Type direction (Stripe-warm, 2026-10): Inter variable self-hosted
   for latin glyphs and DIGITS (one file, full weight axis); CJK
   rides the system stack — the hierarchy is carried by weight,
   tracking and size discipline, not by a CJK webfont.
   ══════════════════════════════════════════════════════════════ */

/* Inter variable, split by script: the browser fetches a file only
   when the page uses a code point in its unicode-range (Latin core is
   preloaded; Latin-Ext and Cyrillic load on demand). The Latin core
   also carries the arrows/math/check glyphs the copy uses. */
@font-face {
  font-family: "Inter";
  src: url("/static/fonts/Inter-latin.woff2") format("woff2-variations");
  font-weight: 100 900;
  font-style: normal;
  font-display: optional;
  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+2190-2193, U+2212, U+2215, U+2260, U+2264-2265, U+2460-2463, U+25CF, U+2713, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Inter";
  src: url("/static/fonts/Inter-latin-ext.woff2") format("woff2-variations");
  font-weight: 100 900;
  font-style: normal;
  font-display: optional;
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: "Inter";
  src: url("/static/fonts/Inter-cyrillic.woff2") format("woff2-variations");
  font-weight: 100 900;
  font-style: normal;
  font-display: optional;
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}

:root {
  color-scheme: light;

  /* ── Color: brand ──
     Strategy: --brand (#ff4d4d) 是品牌红第一表达色 (hero 标题、主按钮
     渐变亮端、品牌标签、未读角标); 暗红系只承担效果响应位 — 渐变深端
     (--brand-deep)、hover/active 加深 (--brand-deep-strong)、状态与
     档位语义色。暗色主题下 deep 已同值 #ff4d4d, 两主题表达一致。 */
  --brand: #ff4d4d;                   /* 第一表达色 (hero 标题 / 主按钮亮端 / 品牌标签) */
  --brand-600: #e5383b;
  --brand-50: #fff3f3;
  --brand-100: #ffe2e2;
  --brand-strong: #ff2442;            /* hover on accent fills */
  --brand-deep: #d92d3a;              /* 渐变深端 / hover 响应 (不再是第一表达) */
  --brand-deep-strong: #b92231;       /* hover on primary fills */
  --brand-soft: #fff1f2;
  --brand-ink: #ffffff;
  --ink-hover: #262a31;

  /* ── Color: neutral surfaces & ink ── */
  --ink: #16130f;                     /* warm near-black */
  --ink-2: #4d4a45;
  --ink-3: #6b6660;
  --ink-4: #b6b0a8;
  --line: rgba(22, 19, 15, 0.08);
  --line-2: rgba(22, 19, 15, 0.14);
  --bg: #faf9f7;                      /* warm paper */
  --card: #ffffff;
  --sunk: #f4f2ef;                    /* wells, code, chips */
  --overlay: rgba(22, 19, 15, 0.5);
  --header-bg: rgba(250, 249, 247, 0.82);
  --nav-hover-bg: rgba(11, 13, 16, 0.05);
  --home-callout-bg: #1c1813;
  --home-callout-ink: #ffffff;
  --term-scroll: rgba(0, 0, 0, 0.2);    /* 浅色主题终端回放体滚动条 */

  /* ── 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: #f4f2ef;
  --gray-200: #eae7e2;
  --gray-300: #d8d3cb;
  --gray-400: #b8b1a6;
  --gray-700: #4a443c;
  --gray-900: #1c1813;

  /* ── Typography ── */
  --font-sans: "Inter", -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);
  /* display-grade tracking: headings tighten, body stays natural */
  --tracking-tight: -0.02em;
  --tracking-tighter: -0.03em;

  --fs-xs: 12px;
  --fs-sm: 12.5px;
  --fs-base: 14px;
  --fs-md: 15px;
  --fs-lg: 17px;
  --fs-xl: 20px;

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

  /* ── Spacing (4px base) ── */
  --s1: 4px;
  --s2: 8px;
  --s3: 12px;
  --s4: 16px;
  --s5: 24px;
  --s6: 32px;
  --s8: 48px;
  /* 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;   /* 胶囊 = chip 词表专用: 状态/标签/计数徽章、进度条、
                        开关、滚动条; 品牌签名两处 (手机底栏、终端胶囊)。
                        动作面 (按钮/导航/输入/分段控件) 一律走矩形阶梯
                        (与 .btn 的 --r-sm 同语言), 不入胶囊。 */

  /* ── Shadows ── */
  --sh-1: 0 1px 2px rgba(28, 24, 19, 0.05), 0 2px 4px -1px rgba(28, 24, 19, 0.04);
  --sh-2: 0 1px 2px rgba(28, 24, 19, 0.05), 0 6px 16px -4px rgba(28, 24, 19, 0.07), 0 16px 32px -10px rgba(28, 24, 19, 0.11);
  --sh-3: 0 2px 4px rgba(28, 24, 19, 0.05), 0 10px 24px -4px rgba(28, 24, 19, 0.09), 0 32px 64px -14px rgba(28, 24, 19, 0.17);
  --sh-4: 0 2px 6px rgba(28, 24, 19, 0.06), 0 14px 32px -6px rgba(28, 24, 19, 0.11), 0 44px 88px -18px rgba(28, 24, 19, 0.24);

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

  /* ── 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;

  /* ── Operator back-office surface (samelabs.css consumers) ── */
  --sl-ok: #0f9f6e;
  --sl-err: #d64545;
  --sl-err-soft: rgba(214, 69, 69, 0.10);
  --sl-purple: #7c5cf0;
  --sl-surface: #ffffff;
  --sl-topbar: rgba(255, 255, 255, 0.92);
  --sl-line: #e8edf0;
  --sl-th-bg: #fafbfc;
  --sl-row-alt: #fbfcfd;
  --sl-row-hover: #f7f9fb;
  --sl-ink-faint: #8a97a3;
  /* 终端基线 (唯一定义): hero MCP 端点胶囊 + 首页打字机终端;
     浅色主题的 .term 重绑在 518.css 作用域完成 */
  --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; scrollbar-gutter: stable; }

/* Any unsized inline svg must not blow up to the 300×150 default.
   Carve-out: a geometry class (e.g. the menu-icon single source .mi in
   518.css) defines its own size and must not be forced back to 20px. */
svg:not([width]):not([height]):not(.mi) { 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(--ink-3); 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 { width: 100%; max-width: var(--wrap); margin: 0 auto; padding: 0 var(--gut); }
@media (max-width: 767px) {
  :root { --gut: 16px; }
}

/* ── Dark mode: system preference + explicit override ──────── */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;

    /* ── Color: brand ── */
    --brand: #ff5c5c;
    --brand-600: #ff4d4d;
    --brand-50: rgba(255, 77, 77, 0.12);
    --brand-100: rgba(255, 77, 77, 0.22);
    --brand-strong: #ff334b;
    --brand-deep: #ff4d4d;
    --brand-deep-strong: #ff6666;
    --brand-soft: rgba(255, 77, 77, 0.08);
    --ink-hover: #34302a;

    /* ── Color: neutral surfaces & ink ── */
    --ink: #f5f2eb;
    --ink-2: #c2bcb2;
    --ink-3: #8c857b;
    --ink-4: #544f47;
    --line: rgba(245, 242, 235, 0.1);
    --line-2: rgba(245, 242, 235, 0.16);
    --bg: #141210;
    --card: #1c1a17;
    --sunk: #24211d;
    --overlay: rgba(0, 0, 0, 0.72);
    --header-bg: rgba(20, 18, 16, 0.78);
    --nav-hover-bg: rgba(245, 242, 235, 0.08);
    --home-callout-bg: #1e1b18;
    --home-callout-ink: #f5f2eb;

    /* ── Color: semantic ── */
    --ok: #22c55e;
    --ok-50: rgba(34, 197, 94, 0.12);
    --ok-700: #4ade80;
    --warn: #fbbf24;
    --warn-50: rgba(251, 191, 36, 0.12);
    --danger: #ef4444;
    --danger-strong: #f87171;
    --danger-50: rgba(239, 68, 68, 0.12);
    --info: #3b82f6;
    --info-50: rgba(59, 130, 246, 0.12);

    /* ── Color: gray ramp in dark mode ── */
    --gray-100: #24211d;
    --gray-200: #2c2925;
    --gray-300: #38342f;
    --gray-400: #544f47;
    --gray-700: #b6b0a8;
    --gray-900: #f5f2eb;

    /* ── Terminal colors in dark mode ── */
    --term-bg: #111317;
    --term-ink: #c9ced6;
    --term-dim: #717782;
    --term-warm: #ff8a7a;
    --term-ok: #7ee2a8;
    --term-scroll: rgba(255, 255, 255, 0.22);

    /* ── Elevation shadows in dark mode ── */
    --sh-1: 0 1px 2px rgba(0, 0, 0, 0.35);
    --sh-2: 0 4px 12px rgba(0, 0, 0, 0.45);
    --sh-3: 0 12px 32px rgba(0, 0, 0, 0.6);

    /* ── Operator surfaces ── */
    --sl-surface: #1c1a17;
    --sl-topbar: rgba(28, 26, 23, 0.92);
    --sl-line: rgba(245, 242, 235, 0.1);
    --sl-th-bg: #24211d;
    --sl-row-alt: #1e1b18;
    --sl-row-hover: #272420;
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;

  /* ── Color: brand ── */
  --brand: #ff5c5c;
  --brand-600: #ff4d4d;
  --brand-50: rgba(255, 77, 77, 0.12);
  --brand-100: rgba(255, 77, 77, 0.22);
  --brand-strong: #ff334b;
  --brand-deep: #ff4d4d;
  --brand-deep-strong: #ff6666;
  --brand-soft: rgba(255, 77, 77, 0.08);
  --ink-hover: #34302a;

  /* ── Color: neutral surfaces & ink ── */
  --ink: #f5f2eb;
  --ink-2: #c2bcb2;
  --ink-3: #8c857b;
  --ink-4: #544f47;
  --line: rgba(245, 242, 235, 0.1);
  --line-2: rgba(245, 242, 235, 0.16);
  --bg: #141210;
  --card: #1c1a17;
  --sunk: #24211d;
  --overlay: rgba(0, 0, 0, 0.72);
  --header-bg: rgba(20, 18, 16, 0.78);
  --nav-hover-bg: rgba(245, 242, 235, 0.08);
  --home-callout-bg: #1e1b18;
  --home-callout-ink: #f5f2eb;

  /* ── Color: semantic ── */
  --ok: #22c55e;
  --ok-50: rgba(34, 197, 94, 0.12);
  --ok-700: #4ade80;
  --warn: #fbbf24;
  --warn-50: rgba(251, 191, 36, 0.12);
  --danger: #ef4444;
  --danger-strong: #f87171;
  --danger-50: rgba(239, 68, 68, 0.12);
  --info: #3b82f6;
  --info-50: rgba(59, 130, 246, 0.12);

  /* ── Color: gray ramp in dark mode ── */
  --gray-100: #24211d;
  --gray-200: #2c2925;
  --gray-300: #38342f;
  --gray-400: #544f47;
  --gray-700: #b6b0a8;
  --gray-900: #f5f2eb;

  /* ── Terminal colors in dark mode ── */
  --term-bg: #111317;
  --term-ink: #c9ced6;
  --term-dim: #717782;
  --term-warm: #ff8a7a;
  --term-ok: #7ee2a8;
  --term-scroll: rgba(255, 255, 255, 0.22);

  /* ── Elevation shadows in dark mode ── */
  --sh-1: 0 1px 2px rgba(0, 0, 0, 0.35);
  --sh-2: 0 4px 12px rgba(0, 0, 0, 0.45);
  --sh-3: 0 12px 32px rgba(0, 0, 0, 0.6);

  /* ── Operator surfaces ── */
  --sl-surface: #1c1a17;
  --sl-topbar: rgba(28, 26, 23, 0.92);
  --sl-line: rgba(245, 242, 235, 0.1);
  --sl-th-bg: #24211d;
  --sl-row-alt: #1e1b18;
  --sl-row-hover: #272420;
}

/* ── Utilities (logical properties only — RTL safe) ────────── */
.stack { display: flex; flex-direction: column; }
.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); }
.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;
}
