/* tokens.css — Develop design tokens (v3).
 *
 * v3 is a NEW, additive version. /v2 is FROZEN (bug-fix only) and untouched;
 * channels migrate to /v3 opt-in by re-pointing their <link>s. Three explicit
 * tiers (the lint-enforced rule):
 *   COMPONENT (--c-*)  -> reference only SEMANTIC
 *   SEMANTIC  (role)   -> reference only PRIMITIVE
 *   PRIMITIVE (--p-*)  -> raw values (INTERNAL; consumers MUST NOT reference)
 *
 * Warm is the v3 baseline: cream canvas, clay actions, rounded shapes and
 * system typography. Both .dark and [data-theme="dark"] select the dark
 * palette. Opt-in skins, including the former baseline (neutral), are
 * assembled from skins/skins.json. */

:root {
  /* :root paints the LIGHT palette, so pin the UA's native controls (scrollbars,
     select popups, date pickers, autofill) to light here; `.dark`/[data-theme=
     "dark"] flip it to dark below. `light dark` was wrong: it let the UA render
     native controls dark per the OS on a forced-LIGHT page (the "dark date input
     on a light page" tell). Dark mode is always driven by the explicit class. */
  color-scheme: light;

  /* ============================================================
     TIER 1 — PRIMITIVE  (--p-*, internal; never referenced by consumers)
     ============================================================ */

  /* Warm neutral ramp: cream canvas, warm graphite ink. */
  --p-gray-0: oklch(0.995 0.003 95);           /* card */
  --p-gray-1: oklch(0.984 0.005 95);       /* canvas */
  --p-gray-2: oklch(0.972 0.006 92);       /* panel */
  /* 凹陷面(表格列头 / alert / .code)与卡片的
     亮度落差约 0.045(1 − 0.955),保留层次而不让整页发灰。 */
  --p-gray-3: oklch(0.955 0.008 92);       /* sunken */
  --p-gray-4: oklch(0.935 0.009 92);        /* hover */
  --p-gray-5: oklch(0.905 0.01 92);        /* border */
  --p-gray-6: oklch(0.885 0.01 92);        /* strong border */
  --p-gray-7: oklch(0.82 0.012 90);        /* stronger border */
  --p-gray-8: oklch(0.69 0.012 85);        /* placeholder */
  --p-gray-9: oklch(0.51 0.01 75);       /* muted — 达标线按**卡片**底色算 */
  --p-gray-10: oklch(0.44 0.01 70);       /* secondary text */
  --p-gray-11: oklch(0.37 0.008 65);       /* strong text */
  --p-gray-12: oklch(0.205 0.005 60);       /* ink */

  /* Status hues — oklch (perceptually even color-mix tints).
     --p-red carries the SAME lightness contract as --p-accent: .btn-danger-solid
     / .tag-solid-danger put near-white --danger-foreground on it as 11–12px
     TEXT, so it must clear AA 4.5:1, not the 3:1 UI floor. 0.58 L only reached
     4.34:1; 0.55 L reaches 4.92:1. Hue/chroma untouched (27 / 0.21, still inside
     sRGB — max chroma at 0.55 L is 0.225), so the red stays the same red, just
     one step deeper — and it now separates from the WARM skin's clay accent
     (oklch(0.58 0.145 40)) by LIGHTNESS too, not only by chroma. */
  --p-green: oklch(0.63 0.17 149);
  --p-amber: oklch(0.75 0.15 75);
  --p-red:   oklch(0.55 0.21 27);
  --p-blue:  oklch(0.55 0.2 256);

  /* Clay action accent. White text on the solid fill must clear 4.5:1. */
  --p-accent:      oklch(0.580 0.145 40);
  --p-accent-deep: oklch(0.52 0.14 40);

  /* Decorative gradient stops: clay, coral and fig. */
  --p-brand-1: oklch(0.62 0.15 40);
  --p-brand-2: oklch(0.60 0.13 15);
  --p-brand-3: oklch(0.58 0.12 355);

  /* ============================================================
     TIER 2 — SEMANTIC  (role tokens; the consumer/contract surface)
     ============================================================ */

  /* Surface ladder (bg -> raised card -> overlay/popover -> sunken well). */
  --background:       var(--p-gray-1);
  --surface:          var(--p-gray-1);
  --surface-raised:   var(--p-gray-0);
  --surface-overlay:  var(--p-gray-0);
  --surface-sunken:   var(--p-gray-3);
  --surface-head:     var(--surface-sunken);
  /* Warm surfaces are authored into the neutral ramp. */
  --card:             var(--p-gray-0);
  --popover:          var(--p-gray-0);
  --secondary:        var(--p-gray-3);
  --muted:            var(--p-gray-4);
  --accent:           var(--p-gray-3);

  /* Text. */
  --foreground:           var(--p-gray-12);
  --card-foreground:      var(--p-gray-12);
  --popover-foreground:   var(--p-gray-12);
  --secondary-foreground: var(--p-gray-11);
  --accent-foreground:    var(--p-gray-12);
  --muted-foreground:     var(--p-gray-9);
  --foreground-subtle:    var(--p-gray-10);
  /* Placeholder copy is still secondary, but must clear normal-text contrast
     on both raised and sunken fields; gray-8 was only a disabled-ink step. */
  --placeholder:          var(--p-gray-9);

  /* Lines. */
  --border:        var(--p-gray-5);
  --border-strong: var(--p-gray-7);
  --border-hover:  var(--p-gray-7);
  --input:         var(--border);
  --ring:          var(--p-gray-10);
  --border-focus:  var(--ring);

  /* Primary = the brand ACTION color (v3: solid clay; a skin re-points it via
     --p-accent). v2's neutral near-black primary is retired — the CTA, checked
     controls, current-page pill and solid tag all speak the accent voice. */
  --primary:            var(--p-accent);
  --primary-foreground: #fff;

  /* Intent recipes — five names each, tints derived via color-mix so a filled
     chip always has a guaranteed-contrast on-color.
     `--*-text` is the INK step, the exact counterpart of --ui-accent-text: the
     bare `--success` / `--danger` are FILL tones, tuned so a near-white
     `-foreground` can sit ON them, which is the same constraint upside-down as
     "readable when painted on a light canvas". Using the fill tone as ink is
     what shipped .btn-danger at 3.74:1 and .metric-delta.is-up at 3.14:1. The
     mix ratio is not taste — it is whatever the hue's own lightness demands;
     65% is the step that carries BOTH families (green is the light one: at 78%,
     the accent's ratio, green ink on its own 12% tint is still 3.77:1).
     2026-07-28 起 warning/info 也各有墨水档(--warning-text / --info-text):
     琥珀更亮,所以混得更狠(55%),蓝按 65%,两者都在十个上下文里过了 AA。 */
  --success: var(--p-green);
  /* Dark ink, like --warning-foreground and like this very token in the .dark
     block below — green is a LIGHT hue: near-white on it was 2.96:1 (the worst
     on-color in the system), dark ink is 4.91:1. Deepening --p-green instead is
     not available: oklch(L 0.17 149) leaves sRGB below 0.63 L, so every step
     down would be silently channel-clipped, i.e. a chroma change in disguise. */
  --success-foreground: var(--p-gray-12);
  --success-bg: color-mix(in oklab, var(--p-green) 12%, var(--surface));
  --success-border: color-mix(in oklab, var(--p-green) 35%, transparent);
  --success-text: color-mix(in oklab, var(--p-green) 60%, var(--foreground));

  --warning: var(--p-amber);
  --warning-foreground: var(--p-gray-12);
  --warning-bg: color-mix(in oklab, var(--p-amber) 14%, var(--surface));
  --warning-border: color-mix(in oklab, var(--p-amber) 38%, transparent);
  /* 墨水档:压在同族底纹上的文字色。success / danger 一直有,warning / info 却缺席,
     于是组件只能拿填充调(--warning / --info)当文字色压在自己 12-14% 的底纹上 ——
     那是这套体系里最常见的一处低对比。琥珀比红绿更亮,所以混得更狠一点。 */
  --warning-text: color-mix(in oklab, var(--p-amber) 46%, var(--foreground));

  --danger: var(--p-red);
  /* 实底徽标/按钮上的**近白墨**。故意写成字面值,不再引用 `--p-gray-1`(画布)——
     它引用画布时,任何一次「把页面底色调深一点」都会顺带把这层白墨调暗,而白墨
     的亮度是 AA 契约的一半:2026-08-09 把纸感梯子整体压深 0.02 时,`.tag-solid-info`
     当场从 4.5 掉到 4.26,而改的人根本没碰过 info 这一族。底色与 on-color 是两件事。 */
  --danger-foreground: oklch(0.968 0.008 95);
  --danger-bg: color-mix(in oklab, var(--p-red) 12%, var(--surface));
  --danger-border: color-mix(in oklab, var(--p-red) 35%, transparent);
  --danger-text: color-mix(in oklab, var(--p-red) 65%, var(--foreground));
  --destructive: var(--p-red);            /* v1-compat alias */

  --info: var(--p-blue);
  --info-foreground: oklch(0.968 0.008 95);
  --info-bg: color-mix(in oklab, var(--p-blue) 12%, var(--surface));
  --info-border: color-mix(in oklab, var(--p-blue) 35%, transparent);
  --info-text: color-mix(in oklab, var(--p-blue) 65%, var(--foreground));

  /* State layers — overlays composited on a surface for hover/press/select. */
  --state-hover:    color-mix(in oklab, var(--foreground) 5%, transparent);
  --state-pressed:  color-mix(in oklab, var(--foreground) 9%, transparent);
  --state-selected: color-mix(in oklab, var(--foreground) 7%, transparent);
  --state-disabled-opacity: 0.5;
  --surface-hover:  var(--accent);

  /* Brand gradient. */
  --brand-gradient: linear-gradient(95deg,
    var(--p-brand-1) 0%, var(--p-brand-2) 50%, var(--p-brand-3) 100%);
  --brand-gradient-fg: oklch(0.99 0 0);
  /* Brand as a SOLID accent + soft tints — for active rails, selected nav,
     accent underlines. Semantic tier so components never touch --p-brand-*. */
  --brand: var(--p-brand-2);
  --brand-soft: color-mix(in oklab, var(--p-brand-2) 10%, transparent);
  --brand-soft-hover: color-mix(in oklab, var(--p-brand-2) 16%, transparent);
  --brand-text: color-mix(in oklab, var(--p-brand-2) 72%, var(--foreground));

  /* Interactive accent (品牌蓝) — the UI's action/selection color: solid CTA fill,
     switch/checkbox checked, calendar selected day, active tab, selected item,
     active tool. DISTINCT from the decorative --brand* (hero art / opt-in brand
     chips), which stays blue→purple. Soft/text adapt per theme via color-mix. */
  --ui-accent:            var(--p-accent);
  --ui-accent-hover:      var(--p-accent-deep);
  --ui-accent-fg:         #fff;
  --ui-accent-soft:       color-mix(in oklab, var(--p-accent) 13%, transparent);
  --ui-accent-soft-hover: color-mix(in oklab, var(--p-accent) 20%, transparent);
  --ui-accent-text:       color-mix(in oklab, var(--p-accent) 78%, var(--foreground));

  /* Solid action button (primary CTA) — brand-blue; aliases the interactive accent.
     The gradient is a token so hover/selected can RE-ASSERT it (the base .btn:hover
     uses `background:` shorthand which would otherwise wipe the image → white flash).
     On no-color-mix engines the token is invalid → background-image unsets → flat. */
  --btn-solid-bg:       var(--ui-accent);
  --btn-solid-bg-hover: var(--ui-accent-hover);
  --btn-solid-fg:       var(--ui-accent-fg);
  --btn-solid-gradient: linear-gradient(180deg, color-mix(in oklab, var(--btn-solid-bg) 88%, #fff), var(--btn-solid-bg-hover));

  /* Default/outline buttons — NEUTRAL (the reference consoles' discipline:
     surface buttons carry no hue; ONLY the primary CTA and selected states
     do). The old blue tonal wash on every default button is what made whole
     screens read "blue". */
  --btn-outline-bg:           var(--surface-raised);
  --btn-outline-bg-hover:     color-mix(in oklab, var(--foreground) 5%, var(--surface-raised));
  --btn-outline-fg:           var(--foreground);
  --btn-outline-border:       var(--border);
  --btn-outline-border-hover: var(--border-strong);
  /* Tonal wash — now reserved for SELECTED/pressed states (accent family). */
  --btn-tonal-bg:           color-mix(in oklab, var(--p-accent) 13%, var(--surface));
  --btn-tonal-bg-hover:     color-mix(in oklab, var(--p-accent) 20%, var(--surface));
  --btn-tonal-selected-bg:  color-mix(in oklab, var(--p-accent) 14%, var(--surface));
  --btn-tonal-fg:           color-mix(in oklab, var(--p-accent) 72%, var(--foreground));
  --btn-tonal-border:       color-mix(in oklab, var(--p-accent) 40%, var(--border));
  --btn-tonal-border-hover: color-mix(in oklab, var(--p-accent) 55%, var(--border));

  /* Categorical chart colours: clay, olive, sky, fig, cactus and moss. */
  --chart-1: oklch(0.685 0.142 38);
  --chart-2: oklch(0.59 0.082 130);
  --chart-3: oklch(0.67 0.075 248);
  --chart-4: oklch(0.7 0.115 0);
  --chart-5: oklch(0.65 0.06 175);
  --chart-6: oklch(0.52 0.09 150);  /* moss — sixth slot */
  --sidebar: var(--p-gray-2);
  --sidebar-foreground: var(--p-gray-11);
  --sidebar-primary: var(--p-gray-12);
  --sidebar-primary-foreground: var(--p-gray-1);
  --sidebar-accent: color-mix(in oklab, var(--p-gray-12) 6%, transparent);
  --sidebar-accent-foreground: var(--p-gray-12);
  --sidebar-border: var(--p-gray-5);
  --sidebar-ring: var(--ring);

  /* Fonts + type scale (raw ladder kept for direct use). */
  /* Platform type system = the OS-native stacks (operator rule 2026-07-10):
     users download NO font files, text renders in each OS's own face with
     zero FOUT. The old var(--font-geist*) indirection is removed on purpose —
     it let Next.js channels inject downloaded webfonts and drift from the
     non-Next channels; nothing may reintroduce a webfont or @font-face. */
  --font-sans-rounded: ui-rounded, "PingFang SC", "HarmonyOS Sans SC", "MiSans",
    "Microsoft YaHei UI", "Microsoft YaHei", "Noto Sans CJK SC",
    "Noto Sans SC", "Source Han Sans SC", "WenQuanYi Micro Hei",
    "Hiragino Sans GB", system-ui, sans-serif;
  --font-sans: var(--font-sans-rounded);
  --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas,
    "Liberation Mono", "PingFang SC", "HarmonyOS Sans SC", "MiSans",
    "Microsoft YaHei UI", "Microsoft YaHei", "Noto Sans CJK SC", "Noto Sans SC",
    "Source Han Sans SC", "WenQuanYi Micro Hei", "Hiragino Sans GB", monospace;
  --text-xs: 0.75rem; --text-sm: 0.875rem; --text-base: 1rem; --text-lg: 1.125rem;
  --text-xl: 1.25rem; --text-2xl: 1.5rem; --text-3xl: 1.875rem; --text-4xl: 2.25rem;

  /* Type ROLES — compact 12px base. Reference roles, not raw steps. */
  --text-micro:   0.6875rem;  /* 11px */
  --text-caption: 0.75rem;    /* 12px */
  --text-body:    0.75rem;    /* 12px — canonical base */
  --text-menu:    0.8125rem;  /* 13px — sidebar/menu item text. The platform
                                 standard for left-nav rows (matches AI对话 and
                                 AI短剧); body copy stays on the 12px base. */
  --text-title:   0.875rem;   /* 14px */
  --text-heading: 1rem;       /* 16px */
  --text-subheading: 1.125rem; /* 18px — h2 / sub-section */
  --text-display: 1.375rem;   /* 22px */
  /* Marketing poster scale — fluid hero/section type for landing pages, beyond
     --text-display (UI cap). Use via .text-poster-{sm,md,lg}. */
  --text-poster-sm: clamp(1.75rem, 1.2rem + 2.6vw, 2.5rem);   /* ~28→40px */
  --text-poster-md: clamp(2.25rem, 1.3rem + 4.5vw, 4rem);     /* ~36→64px */
  --text-poster-lg: clamp(2.75rem, 1.4rem + 6.5vw, 5.5rem);   /* ~44→88px */

  --weight-normal: 400; --weight-medium: 500; --weight-semibold: 600; --weight-bold: 700;
  --tracking-tight: -0.01em; --tracking-normal: 0; --tracking-wide: 0.02em;
  --leading-tight: 1.2; --leading-snug: 1.35; --leading-normal: 1.6;
  --leading-heading: var(--leading-tight); --leading-body: 1.5;

  /* 标准栏宽 —— 侧栏 / 工作台侧窗格 / 编辑工作区的目录列共用这一档。
     同一个共享面板在不同页面里必须一样宽,否则同一个组件会因为列宽不同排出不同的
     列数,看着就是两个东西。system.css 里曾经有 5 处写着同样的 13rem/17rem 字面量,
     注释还说「它是一个 token 而不是每页一个数」—— 那句话现在才是真的。
     2026-08-27 由 17rem 加宽到 22rem:资产栏的分类档要在一行里放得下且不横滚,
     横滑会把后面几档藏起来(「声音」就这么丢过一次)。 */
  --rail-w-min: 13rem;
  --rail-w: 22rem;

  /* Spacing (4px unit). */
  --sp-px: 1px; --sp-0_5: 2px;
  --sp-1: 4px; --sp-2: 8px; --sp-3: 12px; --sp-4: 16px; --sp-5: 20px; --sp-6: 24px;
  --sp-7: 28px; --sp-8: 32px; --sp-9: 36px; --sp-10: 40px; --sp-11: 44px; --sp-12: 48px;

  /* Shape ladder shared by controls and surfaces. The neutral skin keeps the former ladder. */
  --radius: 8px;                             /* buttons and inputs */
  --radius-sm: 6px;
  --radius-md: var(--radius);
  --radius-lg: 10px;
  --radius-xl: 14px;
  --radius-2xl: 18px;                         /* hero panels / dashboards */
  /* Soft-card shape — the rounder family for settings dialogs and the relation board
     (<dev-dialog look="card">, <dev-link-board>, <dev-check-list>, <dev-change-bar>).
     These dedicated roles also serve the neutral skin. */
  --radius-soft-sm: 8px;                     /* chips, icon tiles, small tags */
  --radius-soft: 10px;                       /* fields, buttons, list rows */
  --radius-soft-lg: 12px;                    /* cards, grouped rows */
  --radius-soft-xl: 14px;                    /* target cards */
  --radius-soft-2xl: 18px;                   /* the card-look dialog */
  --radius-full: 9999px;

  /* Elevation ladder (each gets a dark counterpart below). */
  --elevation-0: none;
  --elevation-1: 0 1px 2px color-mix(in oklab, var(--p-gray-12) 5%, transparent);
  --elevation-2: 0 4px 12px oklch(0 0 0 / 0.06), 0 1px 4px oklch(0 0 0 / 0.04);
  --elevation-3: 0 12px 24px oklch(0 0 0 / 0.08), 0 4px 8px oklch(0 0 0 / 0.05);
  --elevation-4: 0 20px 48px oklch(0 0 0 / 0.1), 0 8px 16px oklch(0 0 0 / 0.06);
  /* 遮罩:模态压住页面时那层暗。以前每个模态各写各的(对话框 rgba(15,23,42,.5)、
     抽屉与命令面板 oklch(0.2 0 0/.42)),同一套界面里深浅不一。收成一个令牌,
     暗色下要更重一些 —— 暗底上太淡的遮罩压不住下面的内容。 */
  --scrim: oklch(0.2 0 0 / 0.42);
  /* 压在图片上的字(封面格 .cover-tile):底图的亮暗不随主题变,所以这层暗与字色两种主题一样 ——
     从下往上由深到浅,反白字在任何底图上都读得出。 */
  --media-scrim: linear-gradient(to top, oklch(0.12 0 0 / 0.86), oklch(0.12 0 0 / 0.52));
  --on-media-foreground: oklch(0.98 0 0);
  /* 浮层的高度上限。缺了它,长列表会直接顶出视口 —— 底部那几项永远点不到,
     消费方只能往共享组件上写内联 style 兜底(xapi-tool 的控制台就在这么干)。 */
  --c-popover-max-h: min(60vh, 25rem);
  --shadow-card: var(--elevation-1);     /* v1-compat names */
  --shadow-float: var(--elevation-3);
  --shadow-inset: inset 0 1px 1px oklch(0 0 0 / 0.04);

  /* Skin contract — SHAPE + TYPE axes (the colour axis is the --p-* ramp).
     A skin (styles/v3/skins/<id>.css) may re-point exactly the tokens listed in
     skins/_template.css; the values here are the warm baseline, i.e. what a page
     with no data-skin renders. Recipes read the poster tokens WITH a fallback
     (`var(--poster-frame, 3px solid var(--foreground))`) so a rolling deploy that
     serves a new system.css next to an old tokens.css still draws the frame. */
  --poster-frame: 3px solid var(--foreground);        /* .poster-grid / .poster-split outline */
  --poster-shadow: 8px 8px 0 var(--foreground);       /* hard offset shadow */
  --poster-shadow-sm: 6px 6px 0 var(--foreground);    /* same, narrow screens */
  --poster-rule: var(--foreground);                   /* 1px lines between poster cells */
  --poster-radius: 0;                                 /* frame corner; the recipe clips content to it */
  --poster-ink: var(--foreground);                    /* inverted cell / split-poster dark side */
  --poster-weight: var(--weight-bold);                /* poster-scale titles + .stat-value */
  --poster-tracking: var(--tracking-tight);
  --poster-wrap: wrap;
  --poster-title-tracking: -0.02em;                   /* .poster-cell-title */
  /* Display face for headings. `initial` = guaranteed-invalid, so the recipes'
     `var(--font-display, inherit)` fall back to the inherited face (Warm keeps
     headings in the body face); a skin sets a real stack. */
  --font-display: initial;
  --display-weight: var(--weight-semibold);           /* h1–h6, .text-display/title/heading/subheading */

  /* An unset component value uses the usual role at the element so local
     role overrides, including high contrast, still take effect. */
  --c-table-head-background: initial;
  --c-table-head-weight: initial;
  --c-table-cell-block-padding: initial;
  --c-tab-indicator-color: initial;

  /* Motion. */
  --duration-fast: 120ms; --duration-normal: 180ms; --duration-slow: 280ms;
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-smooth: cubic-bezier(0.4, 0, 0.2, 1);
  /* --ease-standard 是 --ease-smooth 的别名:全仓 8 处在用它,却从来没有定义过 ——
     没有回退的 var() 引用不存在的令牌,浏览器把整条声明丢掉,那些动效其实一直没生效。 */
  --ease-standard: var(--ease-smooth);
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);

  /* Z-index ladder (gaps of 10). */
  /* 局部层叠:同一个卡片/表格内部的前后关系,不参与全局层级。
     它们存在的意义是「不要再写裸数字」—— 层级是体系,不是谁的数字大。 */
  --z-raised: 1; --z-raised-2: 2;
  --z-base: 0; --z-dropdown: 1000; --z-sticky: 1010; --z-overlay: 1020;
  --z-modal: 1030; --z-popover: 1040; --z-toast: 1050; --z-tooltip: 1060;

  /* Icon sizes (aligned to type). */
  --icon-sm: 14px; --icon-md: 16px; --icon-lg: 20px; --icon-xl: 24px;

  /* Breakpoint reference constants. NOTE: custom properties CANNOT drive
     @media/@container conditions — these document the vocabulary; the literals
     30rem/48rem/64rem are used in @container rules. */
  --bp-sm: 30rem; --bp-md: 48rem; --bp-lg: 64rem;

  /* Focus ring recipe (ONE look, used by every control via :focus-visible). */
  /* 焦点走 outline 通道,不再走 box-shadow。两个原因,都是实测出来的:
     一、旧的三种环都是「颜色 × 百分比混透明」,真正画出来的对比度只有 1.60-2.77,
         WCAG 2.2 对非文本界面的下限是 3:1 —— 一个都没达标。实色就没有这个问题。
     二、环画在 box-shadow 上,而 `.btn:active` 与 `.btn-ghost:hover` 都写了
         `box-shadow: none` 且权重更高 —— 键盘聚焦的淡按钮一被鼠标碰到,环就消失了。
         outline 与 box-shadow 不是同一个属性,碰不到。
     --focus-ring* 这三个 box-shadow 变量保留给还没迁移的消费方,新代码不要再用。 */
  --focus-outline: 2px solid var(--ring);
  --focus-outline-brand: 2px solid var(--ui-accent);
  --focus-outline-danger: 2px solid var(--danger);
  --focus-outline-offset: 2px;

  --focus-ring: 0 0 0 2px var(--background), 0 0 0 4px color-mix(in oklab, var(--ring) 55%, transparent);
  --focus-ring-danger: 0 0 0 2px var(--background), 0 0 0 4px color-mix(in oklab, var(--danger) 50%, transparent);
  /* Text-entry controls focus with the BRAND accent (inputs/textarea/select) — the focus
     moment is where a form reads as intentional vs generic. A thin accent ring only; the
     resting look stays neutral (blue-purple is otherwise reserved for buttons/titles). */
  --focus-ring-brand: 0 0 0 2px var(--background), 0 0 0 4px color-mix(in oklab, var(--ui-accent) 42%, transparent);

  /* ============================================================
     TIER 3 — COMPONENT  (--c-*, override hooks; default to semantics)
     ============================================================ */
  --control-h: 2rem;                 /* 32px default buttons, inputs and selects */
  --control-h-sm: 1.625rem;          /* 26px */
  --control-h-xs: var(--sp-5);       /* 20px — compact inline actions */
  --control-h-lg: 2.5rem;            /* 40px */
  /* 28px —— **密集浮层**(.pop-body / .picker-detail)里的控件档。它一直存在,
     只是以裸 `1.75rem` 的形式散在五处、没有名字,于是同一行里标签 28px 和
     分段控件容器 30px 差 2px(2026-08-15 实测)。给它名字,这一档才对得齐。 */
  --control-h-dense: 1.75rem;        /* 28px */
  --c-btn-h: var(--control-h);
  /* 顶栏那排图标控件(主题 / 皮肤 / 语言 / 通知 / 头像)比正文按钮大一档:它们是
     全站常驻的 chrome,点击目标要更稳。以前这个尺寸是四个组件里各写一遍的 `36px`
     字面量 —— 改一次要改四处,而且没人知道它和 --control-h 是什么关系。 */
  --c-chrome-btn-h: 2.25rem;         /* 36px */
  --c-btn-px: var(--sp-3);
  --c-btn-radius: var(--radius);
  --c-input-h: var(--control-h);
  --c-input-bg: var(--surface-raised);
  --c-input-border: var(--border);
  /* Native <select> caret, tokenised so it re-colours per theme (a hardcoded gray SVG
     disappeared against the dark surface). Overridden with a lighter stroke in dark mode. */
  --c-select-caret: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2371717a' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  --c-card-radius: var(--radius-xl);
  --c-card-pad: var(--sp-4);
  /* Cards get a soft ambient float (not just a hairline) so surfaces read as
     layered, not flat — the premium tell. Kept low-opacity + tight so nested
     cards don't pile up. Dark override below. */
  --c-card-shadow: 0 1px 2px color-mix(in oklab, var(--p-gray-12) 4%, transparent),
    0 8px 24px -12px color-mix(in oklab, var(--p-gray-12) 10%, transparent);
  /* 标签是**盒子**不是圆点,跟着基准走(2026-09-17 由 --radius-full 改过来:
     一个全圆的标签挨着一个 8px 的 .code 与一个 99px 的状态点,三种形状同排)。 */
  --c-tag-radius: var(--radius);
  /* 主对话框 —— 全平台那一个「说点什么」的盒子(AI对话定稿的形状)。
     它比卡片更圆、更沉:一块 30% 的 muted 玻璃,不投影 —— 页面已经在它背后了。 */
  --c-composer-radius: var(--radius-2xl);
  /* 30% 的 --border 兑水 —— 和 AI对话 那个盒子逐像素同一块玻璃(那边是 input/30,
     两个 token 在本皮肤下同值)。比 --muted 再淡一档,正文才浮得出来。 */
  --c-composer-bg: color-mix(in oklab, var(--border) 30%, transparent);
  --c-composer-min-h: 6rem;          /* 96px —— 三行,写一段分镜不用先撑开 */
  --c-composer-max-h: 12rem;         /* 192px —— 再长就滚,不许顶穿页面 */
  /* 跟基准走(operator 2026-08-29:「主对话框的文字大小要小一点,变成和全局标准
     文字一样大小」)。此前它比基准大一档,于是同一屏上正文有两种大小。 */
  --c-composer-font: var(--text-body);
  --c-composer-send-size: 2rem;      /* 32px —— 工具条上唯一一个实心圆,和 AI对话 同尺寸 */
}

/* Keep explicit rounded typography available on the neutral skin too. */
html[data-font="rounded"] {
  --font-sans: var(--font-sans-rounded);
}
/* 手机(≤ 30rem):主对话框起步两行、最多八行,打字时照样按内容长高。三行起步的盒子连同上下的工具条,
   在 844px 高的屏上把对话区压到三百来像素(2026-09-25 AI短剧 390 验收)。 */
@media (max-width: 30rem) {
  :root {
    --c-composer-min-h: 3rem;        /* 48px —— 两行 */
    --c-composer-max-h: 8rem;        /* 128px */
  }
}

/* Dark theme uses the same warm palette and shape, tuned for dark surfaces. */
.dark,
[data-theme="dark"] {
  color-scheme: dark;
  --surface-head: var(--surface-sunken);
  --p-gray-0: oklch(0.235 0.006 60);  /* raised card (above bg) */
  --p-gray-1: oklch(0.205 0.005 60);  /* app bg */
  --p-gray-2: oklch(0.22 0.006 60);
  --p-gray-3: oklch(0.27 0.007 60);
  --p-gray-4: oklch(0.175 0.005 60);  /* muted (recessed) */
  --p-gray-5: oklch(0.31 0.008 60);
  --p-gray-6: oklch(0.28 0.007 60);
  --p-gray-7: oklch(0.39 0.008 60);
  --p-gray-8: oklch(0.46 0.008 65);
  --p-gray-9: oklch(0.638 0.008 70);   /* 暗色下次要文字压在**卡片**上实测 4.18-4.41,低于 4.5 —— 亮色早就按卡片底色调过,暗色没有。 */
  --p-gray-10: oklch(0.71 0.008 75);
  --p-gray-11: oklch(0.76 0.008 80);
  --p-gray-12: oklch(0.94 0.005 90);
  /* gray-9 clears AA on light fields, but dark raised fields need the next
     text step (about 5.8:1 on the darkest supported sunken surface). */
  --placeholder: var(--p-gray-10);

  --p-green: oklch(0.7 0.16 150);
  --p-amber: oklch(0.8 0.14 78);
  --p-red:   oklch(0.7 0.18 25);
  --p-blue:  oklch(0.68 0.16 254);

  /* Stay deep enough for AA on the solid action. */
  --p-accent:      oklch(0.575 0.13 42);
  --p-accent-deep: oklch(0.50 0.13 42);

  --p-brand-1: oklch(0.70 0.14 40);
  --p-brand-2: oklch(0.68 0.12 15);
  --p-brand-3: oklch(0.66 0.11 355);

  /* Data-viz categorical ramp, dark — the SAME hues as the light block,
     re-stepped for the dark surface (see light block). */
  --chart-1: oklch(0.72 0.13 40);
  --chart-2: oklch(0.68 0.09 130);
  --chart-3: oklch(0.72 0.08 248);
  --chart-4: oklch(0.74 0.11 0);
  --chart-5: oklch(0.70 0.06 175);
  --chart-6: oklch(0.64 0.09 150);  /* moss  */

  --primary-foreground: #fff;
  --border: var(--p-gray-6);   /* keep dark border one step below (light uses gray-5) */
  /* Surface bridge, dark — same discipline as light: warm surfaces are
     authored into the ramp, no accent mix. */
  --card:   var(--p-gray-0);
  --accent: var(--p-gray-3);
  --sidebar: var(--p-gray-2);
  /* lighter caret so the <select> arrow stays legible on the dark surface */
  --c-select-caret: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23a1a1aa' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");

  /* Tonal buttons — louder brand-blue mix on dark so the wash survives the dark surface. */
  --btn-tonal-bg:           color-mix(in oklab, var(--p-accent) 24%, var(--p-gray-3));
  --btn-tonal-bg-hover:     color-mix(in oklab, var(--p-accent) 34%, var(--p-gray-3));
  --btn-tonal-selected-bg:  color-mix(in oklab, var(--p-accent) 30%, var(--p-gray-3));
  --btn-tonal-fg:           color-mix(in oklab, var(--p-accent) 50%, var(--p-gray-12));
  --btn-tonal-border:       color-mix(in oklab, var(--p-accent) 40%, var(--border));
  --btn-tonal-border-hover: color-mix(in oklab, var(--p-accent) 55%, var(--border));
  --success-foreground: oklch(0.16 0 0);
  --danger-foreground: oklch(0.16 0 0);
  --info-foreground: oklch(0.16 0 0);
  /* 琥珀在暗色下更亮,压白字只有 1.59:1 —— success/danger/info 都在这儿钉过深墨,
     唯独 warning 漏了(:root 的 var(--p-gray-12) 在暗色下翻成近白)。 */
  --warning-foreground: oklch(0.16 0 0);

  --elevation-1: inset 0 1px 0 color-mix(in oklab, var(--p-gray-12) 4%, transparent),
    0 1px 2px color-mix(in oklab, var(--p-gray-4) 25%, transparent);
  --elevation-2: 0 4px 12px oklch(0 0 0 / 0.4), 0 1px 4px oklch(0 0 0 / 0.25);
  --elevation-3: 0 12px 28px oklch(0 0 0 / 0.45), 0 4px 10px oklch(0 0 0 / 0.3);
  --elevation-4: 0 20px 48px oklch(0 0 0 / 0.55), 0 8px 16px oklch(0 0 0 / 0.35);
  --shadow-inset: inset 0 1px 1px oklch(0 0 0 / 0.2);
  /* On dark, a top inset highlight + a deeper ambient shadow reads as a raised
     surface (a flat shadow alone is invisible on a dark page). */
  --c-card-shadow: inset 0 1px 0 color-mix(in oklab, var(--p-gray-12) 4%, transparent),
    0 8px 24px -12px color-mix(in oklab, var(--p-gray-4) 65%, transparent);
  --scrim: oklch(0.12 0 0 / 0.62);
}

/* ============================================================
   SKINS — [data-skin="<id>"] on <html>, composable with the dark axis
   (.dark / [data-theme="dark"] on the SAME element). A skin overrides
   PRIMITIVES (like dark does) — plus, where a canvas swap demands it,
   the surface-bridge semantics — so every component recipe retints
   automatically. The `skin` apex cookie mirrors the attribute; lib's
   bundle applies it at load. The root baseline also serves explicit warm;
   paper is a legacy alias of neutral.
   The blocks are NOT written here: one file per skin under styles/v3/skins/,
   listed in skins/skins.json, spliced in at the marker below at build time
   (build.mjs; tests use tests/_v3-tokens.mjs). The marker keeps the skin blocks
   where they always were — after the dark baseline, before high-contrast and
   the legacy-engine fallbacks, so cascade order is unchanged.
   ============================================================ */

/* skin: default — the v2 neutral+blue console palette (opt-in; paper is the baseline).
   One skin = this one file (light block + dark block). The contract is
   skins/_template.css; the manifest entry is skins/skins.json. */
[data-skin="default"] {
  --surface-head: var(--surface-sunken);
  --p-gray-0: oklch(1 0 0);
  --p-gray-1: oklch(0.985 0 0);
  --p-gray-2: oklch(0.972 0 0);
  --p-gray-3: oklch(0.965 0 0);
  --p-gray-4: oklch(0.94 0 0);
  --p-gray-5: oklch(0.922 0 0);
  --p-gray-6: oklch(0.9 0 0);
  --p-gray-7: oklch(0.83 0 0);
  --p-gray-8: oklch(0.7 0 0);
  --p-gray-9: oklch(0.52 0 0);
  --p-gray-10: oklch(0.45 0 0);
  --p-gray-11: oklch(0.38 0 0);
  --p-gray-12: oklch(0.12 0 0);

  /* 0.585 L only carried white at 4.24:1 (see :root — 4.5 is the floor). */
  --p-accent:      oklch(0.565 0.16 256);
  --p-accent-deep: oklch(0.50 0.16 256);

  --p-brand-1: oklch(0.54 0.23 266);
  --p-brand-2: oklch(0.52 0.26 296);
  --p-brand-3: oklch(0.55 0.27 324);

  --chart-1: #2a78d6;  /* blue   */
  --chart-2: #1baf7a;  /* aqua   */
  --chart-3: #eda100;  /* yellow */
  --chart-4: #008300;  /* green  */
  --chart-5: #4a3aa7;  /* violet */
  --chart-6: #e34948;  /* red    */

  --card:    color-mix(in oklab, var(--p-accent) 2%, var(--p-gray-0));
  --accent:  color-mix(in oklab, var(--p-accent) 8%, var(--p-gray-2));
  --sidebar: color-mix(in oklab, var(--p-accent) 2%, var(--p-gray-2));
}
.dark[data-skin="default"],
[data-theme="dark"][data-skin="default"] {
  --surface-head: var(--surface-sunken);
  --p-gray-0: oklch(0.225 0 0);
  --p-gray-1: oklch(0.195 0 0);
  --p-gray-2: oklch(0.21 0 0);
  --p-gray-3: oklch(0.26 0 0);
  --p-gray-4: oklch(0.165 0 0);
  --p-gray-5: oklch(0.3 0 0);
  --p-gray-6: oklch(0.27 0 0);
  --p-gray-7: oklch(0.38 0 0);
  --p-gray-8: oklch(0.45 0 0);
  --p-gray-9: oklch(0.635 0 0);   /* 暗色下次要文字压在**卡片**上实测 4.18-4.41,低于 4.5 —— 亮色早就按卡片底色调过,暗色没有。 */
  --p-gray-10: oklch(0.7 0 0);
  --p-gray-11: oklch(0.75 0 0);
  --p-gray-12: oklch(0.94 0 0);

  --p-accent:      oklch(0.565 0.16 256);
  --p-accent-deep: oklch(0.50 0.16 256);

  --p-brand-1: oklch(0.64 0.21 266);
  --p-brand-2: oklch(0.62 0.25 296);
  --p-brand-3: oklch(0.65 0.26 324);

  --chart-1: #3987e5;  /* blue   */
  --chart-2: #199e70;  /* aqua   */
  --chart-3: #c98500;  /* yellow */
  --chart-4: #008300;  /* green  */
  --chart-5: #9085e9;  /* violet */
  --chart-6: #e66767;  /* red    */

  --card:    color-mix(in oklab, var(--p-accent) 4%, var(--p-gray-0));
  --accent:  color-mix(in oklab, var(--p-accent) 12%, var(--p-gray-3));
  --sidebar: color-mix(in oklab, var(--p-accent) 3%, var(--p-gray-2));
}

/* skin: forest — neutral canvas + deep emerald actions/selection.
   One skin = this one file (light block + dark block). The contract is
   skins/_template.css; the manifest entry is skins/skins.json. */
[data-skin="forest"] {
  --surface-head: var(--surface-sunken);
  --p-gray-0: oklch(1 0 0);
  --p-gray-1: oklch(0.985 0 0);
  --p-gray-2: oklch(0.972 0 0);
  --p-gray-3: oklch(0.965 0 0);
  --p-gray-4: oklch(0.94 0 0);
  --p-gray-5: oklch(0.922 0 0);
  --p-gray-6: oklch(0.9 0 0);
  --p-gray-7: oklch(0.83 0 0);
  --p-gray-8: oklch(0.7 0 0);
  --p-gray-9: oklch(0.52 0 0);
  --p-gray-10: oklch(0.45 0 0);
  --p-gray-11: oklch(0.38 0 0);
  --p-gray-12: oklch(0.12 0 0);

  /* 0.585 L only carried white at 4.24:1 (see :root — 4.5 is the floor). */
  --p-accent:      oklch(0.50 0.12 155);
  --p-accent-deep: oklch(0.43 0.12 155);

  --p-brand-1: oklch(0.54 0.23 266);
  --p-brand-2: oklch(0.52 0.26 296);
  --p-brand-3: oklch(0.55 0.27 324);

  --chart-1: #2a78d6;  /* blue   */
  --chart-2: #1baf7a;  /* aqua   */
  --chart-3: #eda100;  /* yellow */
  --chart-4: #008300;  /* green  */
  --chart-5: #4a3aa7;  /* violet */
  --chart-6: #e34948;  /* red    */

  --card:    color-mix(in oklab, var(--p-accent) 2%, var(--p-gray-0));
  --accent:  color-mix(in oklab, var(--p-accent) 8%, var(--p-gray-2));
  --sidebar: color-mix(in oklab, var(--p-accent) 2%, var(--p-gray-2));
}
.dark[data-skin="forest"],
[data-theme="dark"][data-skin="forest"] {
  --surface-head: var(--surface-sunken);
  --p-gray-0: oklch(0.225 0 0);
  --p-gray-1: oklch(0.195 0 0);
  --p-gray-2: oklch(0.21 0 0);
  --p-gray-3: oklch(0.26 0 0);
  --p-gray-4: oklch(0.165 0 0);
  --p-gray-5: oklch(0.3 0 0);
  --p-gray-6: oklch(0.27 0 0);
  --p-gray-7: oklch(0.38 0 0);
  --p-gray-8: oklch(0.45 0 0);
  --p-gray-9: oklch(0.635 0 0);   /* 暗色下次要文字压在**卡片**上实测 4.18-4.41,低于 4.5 —— 亮色早就按卡片底色调过,暗色没有。 */
  --p-gray-10: oklch(0.7 0 0);
  --p-gray-11: oklch(0.75 0 0);
  --p-gray-12: oklch(0.94 0 0);

  --p-accent:      oklch(0.550 0.12 155);
  --p-accent-deep: oklch(0.48 0.12 155);

  --p-brand-1: oklch(0.64 0.21 266);
  --p-brand-2: oklch(0.62 0.25 296);
  --p-brand-3: oklch(0.65 0.26 324);

  --chart-1: #3987e5;  /* blue   */
  --chart-2: #199e70;  /* aqua   */
  --chart-3: #c98500;  /* yellow */
  --chart-4: #008300;  /* green  */
  --chart-5: #9085e9;  /* violet */
  --chart-6: #e66767;  /* red    */

  --card:    color-mix(in oklab, var(--p-accent) 4%, var(--p-gray-0));
  --accent:  color-mix(in oklab, var(--p-accent) 12%, var(--p-gray-3));
  --sidebar: color-mix(in oklab, var(--p-accent) 3%, var(--p-gray-2));
}

/* skin: violet — neutral canvas + violet actions/selection.
   One skin = this one file (light block + dark block). The contract is
   skins/_template.css; the manifest entry is skins/skins.json. */
[data-skin="violet"] {
  --surface-head: var(--surface-sunken);
  --p-gray-0: oklch(1 0 0);
  --p-gray-1: oklch(0.985 0 0);
  --p-gray-2: oklch(0.972 0 0);
  --p-gray-3: oklch(0.965 0 0);
  --p-gray-4: oklch(0.94 0 0);
  --p-gray-5: oklch(0.922 0 0);
  --p-gray-6: oklch(0.9 0 0);
  --p-gray-7: oklch(0.83 0 0);
  --p-gray-8: oklch(0.7 0 0);
  --p-gray-9: oklch(0.52 0 0);
  --p-gray-10: oklch(0.45 0 0);
  --p-gray-11: oklch(0.38 0 0);
  --p-gray-12: oklch(0.12 0 0);

  /* 0.585 L only carried white at 4.24:1 (see :root — 4.5 is the floor). */
  --p-accent:      oklch(0.51 0.19 296);
  --p-accent-deep: oklch(0.44 0.19 296);

  --p-brand-1: oklch(0.54 0.23 266);
  --p-brand-2: oklch(0.52 0.26 296);
  --p-brand-3: oklch(0.55 0.27 324);

  --chart-1: #2a78d6;  /* blue   */
  --chart-2: #1baf7a;  /* aqua   */
  --chart-3: #eda100;  /* yellow */
  --chart-4: #008300;  /* green  */
  --chart-5: #4a3aa7;  /* violet */
  --chart-6: #e34948;  /* red    */

  --card:    color-mix(in oklab, var(--p-accent) 2%, var(--p-gray-0));
  --accent:  color-mix(in oklab, var(--p-accent) 8%, var(--p-gray-2));
  --sidebar: color-mix(in oklab, var(--p-accent) 2%, var(--p-gray-2));
}
.dark[data-skin="violet"],
[data-theme="dark"][data-skin="violet"] {
  --surface-head: var(--surface-sunken);
  --p-gray-0: oklch(0.225 0 0);
  --p-gray-1: oklch(0.195 0 0);
  --p-gray-2: oklch(0.21 0 0);
  --p-gray-3: oklch(0.26 0 0);
  --p-gray-4: oklch(0.165 0 0);
  --p-gray-5: oklch(0.3 0 0);
  --p-gray-6: oklch(0.27 0 0);
  --p-gray-7: oklch(0.38 0 0);
  --p-gray-8: oklch(0.45 0 0);
  --p-gray-9: oklch(0.635 0 0);   /* 暗色下次要文字压在**卡片**上实测 4.18-4.41,低于 4.5 —— 亮色早就按卡片底色调过,暗色没有。 */
  --p-gray-10: oklch(0.7 0 0);
  --p-gray-11: oklch(0.75 0 0);
  --p-gray-12: oklch(0.94 0 0);

  --p-accent:      oklch(0.580 0.17 296);
  --p-accent-deep: oklch(0.52 0.17 296);

  --p-brand-1: oklch(0.64 0.21 266);
  --p-brand-2: oklch(0.62 0.25 296);
  --p-brand-3: oklch(0.65 0.26 324);

  --chart-1: #3987e5;  /* blue   */
  --chart-2: #199e70;  /* aqua   */
  --chart-3: #c98500;  /* yellow */
  --chart-4: #008300;  /* green  */
  --chart-5: #9085e9;  /* violet */
  --chart-6: #e66767;  /* red    */

  --card:    color-mix(in oklab, var(--p-accent) 4%, var(--p-gray-0));
  --accent:  color-mix(in oklab, var(--p-accent) 12%, var(--p-gray-3));
  --sidebar: color-mix(in oklab, var(--p-accent) 3%, var(--p-gray-2));
}

/* skin: neutral — the previous v3 baseline: gray canvas, amber actions and compact corners. */
[data-skin="neutral"],
[data-skin="paper"] {
  --p-gray-0: oklch(1 0 0);
  --p-gray-1: oklch(0.968 0 0);
  --p-gray-2: oklch(0.985 0 0);
  --p-gray-3: oklch(0.955 0 0);
  --p-gray-4: oklch(0.94 0 0);
  --p-gray-5: oklch(0.91 0 0);
  --p-gray-6: oklch(0.87 0 0);
  --p-gray-7: oklch(0.80 0 0);
  --p-gray-8: oklch(0.70 0 0);
  --p-gray-9: oklch(0.495 0 0);
  --p-gray-10: oklch(0.50 0 0);
  --p-gray-11: oklch(0.42 0 0);
  --p-gray-12: oklch(0.25 0 0);
  --p-accent: oklch(0.565 0.115 70);
  --p-accent-deep: oklch(0.52 0.11 68);
  --p-brand-1: oklch(0.62 0.12 70);
  --p-brand-2: oklch(0.58 0.08 185);
  --p-brand-3: oklch(0.60 0.09 255);
  --surface-head: oklch(0.978 0 0);
  --chart-1: oklch(0.66 0.12 70);
  --chart-2: oklch(0.58 0.08 185);
  --chart-3: oklch(0.60 0.09 255);
  --chart-4: oklch(0.58 0.11 310);
  --chart-5: oklch(0.55 0.12 25);
  --radius: 3px;
  --radius-sm: 2px;
  --radius-lg: 4px;
  --radius-xl: 4px;
  --radius-2xl: 6px;
  --elevation-1: 0 1px 2px oklch(0 0 0 / 0.05), 0 1px 1px oklch(0 0 0 / 0.03);
  --c-card-shadow: 0 1px 2px oklch(0 0 0 / 0.04), 0 5px 18px -6px oklch(0 0 0 / 0.09);
  --font-sans: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto,
    "PingFang SC", "Microsoft YaHei", "Hiragino Sans GB", sans-serif;
}
.dark[data-skin="neutral"],
[data-theme="dark"][data-skin="neutral"],
.dark[data-skin="paper"],
[data-theme="dark"][data-skin="paper"] {
  --surface-head: var(--surface-sunken);
  --p-gray-0: oklch(0.235 0.008 75);
  --p-gray-1: oklch(0.205 0.007 75);
  --p-gray-2: oklch(0.22 0.008 75);
  --p-gray-3: oklch(0.27 0.009 75);
  --p-gray-4: oklch(0.175 0.006 75);
  --p-gray-5: oklch(0.31 0.010 75);
  --p-gray-6: oklch(0.28 0.009 75);
  --p-gray-7: oklch(0.39 0.010 75);
  --p-gray-8: oklch(0.46 0.010 78);
  --p-gray-9: oklch(0.638 0.012 82);
  --p-gray-10: oklch(0.71 0.012 85);
  --p-gray-11: oklch(0.76 0.012 88);
  --p-gray-12: oklch(0.94 0.006 92);
  --p-accent: oklch(0.565 0.115 72);
  --p-accent-deep: oklch(0.53 0.11 70);
  --p-brand-1: oklch(0.72 0.12 70);
  --p-brand-2: oklch(0.66 0.08 185);
  --p-brand-3: oklch(0.68 0.09 255);
  --chart-1: oklch(0.74 0.12 70);
  --chart-2: oklch(0.68 0.08 185);
  --chart-3: oklch(0.70 0.09 255);
  --chart-4: oklch(0.68 0.10 310);
  --chart-5: oklch(0.66 0.11 25);
  --elevation-1: inset 0 1px 0 oklch(1 0 0 / 0.04), 0 1px 2px oklch(0 0 0 / 0.25);
  --c-card-shadow: inset 0 1px 0 oklch(1 0 0 / 0.04), 0 2px 10px oklch(0 0 0 / 0.36);
}

/* skin: editorial — warm-paper editorial (ai-seq.com's look): paper canvas, near-black
   warm ink, wine accent, serif display face, hairline layering instead of shadows.
   One skin = this one file (light block + dark block); contract = skins/_template.css;
   manifest entry = skins/skins.json. Hex in the comments is the design value. */
[data-skin="editorial"] {
  --surface-head: var(--surface-sunken);
  --c-table-head-background: transparent;
  --c-tab-indicator-color: var(--ui-accent);

  /* colour — warm ramp. 0 card (near-white) · 1 canvas #faf9f5 · 3 sunken/tag #f0eee6 ·
     4 hover #e8e6dc · 5 hairline over paper · 6 border #dedbd0 · 9 muted (>= 4.5 on card AND
     canvas, never #8b857d) · 10 secondary ink #55504a · 12 ink #1f1d1a. */
  --p-gray-0: oklch(0.997 0.003 85);
  --p-gray-1: oklch(0.982 0.005 95);
  --p-gray-2: oklch(0.964 0.008 91);
  --p-gray-3: oklch(0.948 0.011 95);
  --p-gray-4: oklch(0.924 0.014 97);
  --p-gray-5: oklch(0.912 0.014 97);
  --p-gray-6: oklch(0.891 0.015 94);
  --p-gray-7: oklch(0.835 0.020 94);
  --p-gray-8: oklch(0.720 0.017 86);
  --p-gray-9: oklch(0.506 0.016 78);
  --p-gray-10: oklch(0.434 0.012 73);
  --p-gray-11: oklch(0.340 0.009 68);
  --p-gray-12: oklch(0.232 0.006 78);

  /* wine #7a2e3a (hover #68242f) — white on it is 9.2:1 */
  --p-accent:      oklch(0.413 0.106 13);
  --p-accent-deep: oklch(0.366 0.098 14);
  --p-green: oklch(0.621 0.069 170);   /* teal-green #5a9480 */
  /* status hues greyed toward the paper: ochre / brick / mist blue (tags and alerts stay quiet) */
  --p-amber: oklch(0.70 0.10 75);
  --p-red:   oklch(0.50 0.15 27);
  --p-blue:  oklch(0.50 0.06 250);

  --p-brand-1: oklch(0.48 0.11 13);
  --p-brand-2: oklch(0.58 0.07 170);
  --p-brand-3: oklch(0.55 0.04 250);

  /* wine / teal-green / warm taupe / ink grey / ochre / mist blue */
  --chart-1: oklch(0.413 0.106 13);
  --chart-2: oklch(0.639 0.065 172);
  --chart-3: oklch(0.603 0.023 72);
  --chart-4: oklch(0.350 0.008 75);
  --chart-5: oklch(0.628 0.102 70);
  --chart-6: oklch(0.597 0.044 249);

  /* surfaces: white content panels, warm-grey sidebar, one step darker hover/selected */
  --card:    var(--p-gray-0);
  --accent:  var(--p-gray-4);
  --sidebar: var(--p-gray-3);

  /* shape — 4px base, almost no elevation (layers come from hairlines) */
  --radius: 4px;
  --radius-sm: 2px;
  --radius-md: var(--radius);
  --radius-lg: 4px;
  --radius-xl: 5px;
  --radius-2xl: 6px;
  --elevation-1: none;
  --elevation-2: 0 1px 2px oklch(0 0 0 / 0.04);
  --elevation-3: 0 4px 12px oklch(0 0 0 / 0.06);
  --elevation-4: 0 8px 24px oklch(0 0 0 / 0.08);
  --c-card-shadow: none;
  --c-table-cell-block-padding: var(--sp-2);
  --poster-frame: 1px solid var(--border);
  --poster-shadow: none;
  --poster-shadow-sm: none;
  --poster-rule: var(--border);
  --poster-radius: 4px;
  --poster-ink: var(--p-accent);       /* the inverted face is the wine block, not black */

  /* type — standard system body and serif display */
  --font-sans: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto,
    "PingFang SC", "Microsoft YaHei", "Hiragino Sans GB", sans-serif;
  --font-display: Georgia, "Songti SC", "Noto Serif SC", "Source Han Serif SC", serif;
  --display-weight: 600;
  --c-table-head-weight: var(--weight-semibold);
  --poster-weight: 400;
  --poster-tracking: -0.015em;
  --poster-title-tracking: -0.015em;
  --poster-wrap: balance;
}
.dark[data-skin="editorial"],
[data-theme="dark"][data-skin="editorial"] {
  --surface-head: var(--surface-sunken);

  --p-gray-0: oklch(0.235 0.006 70);
  --p-gray-1: oklch(0.205 0.005 70);
  --p-gray-2: oklch(0.22 0.006 70);
  --p-gray-3: oklch(0.27 0.007 70);
  --p-gray-4: oklch(0.175 0.005 70);
  --p-gray-5: oklch(0.31 0.008 70);
  --p-gray-6: oklch(0.28 0.007 70);
  --p-gray-7: oklch(0.39 0.008 70);
  --p-gray-8: oklch(0.46 0.008 72);
  --p-gray-9: oklch(0.66 0.010 78);
  --p-gray-10: oklch(0.72 0.010 82);
  --p-gray-11: oklch(0.77 0.008 85);
  --p-gray-12: oklch(0.94 0.005 90);

  /* wine lifted so the focus ring / outline still reads on the near-black card (>= 3:1)
     while white text on it stays >= 4.5 — the narrow window is L 0.545-0.565 */
  --p-accent:      oklch(0.555 0.125 13);
  --p-accent-deep: oklch(0.50 0.12 14);
  --p-green: oklch(0.719 0.080 169);
  --p-amber: oklch(0.76 0.10 78);
  --p-red:   oklch(0.60 0.15 27);
  --p-blue:  oklch(0.66 0.06 250);

  --p-brand-1: oklch(0.62 0.11 12);
  --p-brand-2: oklch(0.70 0.07 170);
  --p-brand-3: oklch(0.70 0.04 250);

  --chart-1: oklch(0.625 0.110 10);
  --chart-2: oklch(0.743 0.068 171);
  --chart-3: oklch(0.727 0.026 77);
  --chart-4: oklch(0.822 0.015 85);
  --chart-5: oklch(0.739 0.101 75);
  --chart-6: oklch(0.720 0.041 244);

  --card:    var(--p-gray-0);
  --accent:  oklch(0.25 0.007 70);   /* a hair above the card: wine text on this wash stays >= 4.5 */
  --sidebar: var(--p-gray-2);

  --elevation-1: none;
  --elevation-2: 0 1px 2px oklch(0 0 0 / 0.3);
  --elevation-3: 0 6px 16px oklch(0 0 0 / 0.4);
  --elevation-4: 0 12px 32px oklch(0 0 0 / 0.5);
  --c-card-shadow: none;
  --poster-ink: var(--foreground);
}

/* ---- High-contrast — manual [data-contrast=high] OR OS prefers-contrast.
   Its own mapping (heavier lines + AAA text), not a filter. ---- */
[data-contrast="high"] {
  --surface-head: var(--surface-sunken);
  --border: var(--p-gray-12);
  --border-strong: var(--p-gray-12);
  --muted-foreground: var(--p-gray-12);
  --foreground-subtle: var(--p-gray-12);
  --placeholder: var(--p-gray-11);
  --ring: var(--p-gray-12);
}
@media (prefers-contrast: more) {
  :root {
    --surface-head: var(--surface-sunken);
    --border: var(--p-gray-12);
    --border-strong: var(--p-gray-12);
    --muted-foreground: var(--p-gray-12);
    --foreground-subtle: var(--p-gray-12);
    --placeholder: var(--p-gray-11);
    --ring: var(--p-gray-12);
  }
}

/* ============================================================
   FALLBACKS — a NO-BUILD system has no compiler to down-level color, so it must
   render on engines without oklch()/color-mix() (older Safari, in-app WebViews).
   Default values above stay oklch/color-mix (modern path, untouched); these
   blocks only fire where the feature is ABSENT.
   ============================================================ */
@supports not (color: oklch(0 0 0)) {
  :root {
    --p-gray-0: #fefdfb; --p-gray-1: #fbfaf6; --p-gray-2: #f7f6f1;
    --p-gray-3: #f2f0ea; --p-gray-4: #ebe9e3; --p-gray-5: #e2e0d8;
    --p-gray-6: #dbd9d2; --p-gray-7: #c7c4bc; --p-gray-8: #9f9b93;
    --p-gray-9: #696560; --p-gray-10: #56524d; --p-gray-11: #433f3b;
    --p-gray-12: #191715;
    --p-green: #16a34a; --p-amber: #d97706; --p-red: #d01d21; --p-blue: #2563eb;
    --p-accent: #bf5630; --p-accent-deep: #a94620;
    --p-brand-1: #cf6139; --p-brand-2: #c15c67; --p-brand-3: #b0597e;
    --shadow-inset: inset 0 1px 1px rgba(0,0,0,0.04);
    --brand-gradient-fg: #ffffff;
    --chart-1: #e37756; --chart-2: #6d8752; --chart-3: #709ac2; --chart-4: #d87f9b; --chart-5: #679c8d; --chart-6: #3f774d;
  }
  .dark, [data-theme="dark"] {
    --p-gray-0: #201d1b; --p-gray-1: #191715; --p-gray-2: #1d1a18;
    --p-gray-3: #292623; --p-gray-4: #12100e; --p-gray-5: #332f2c;
    --p-gray-6: #2c2825; --p-gray-7: #484441; --p-gray-8: #5b5753;
    --p-gray-9: #8f8b86; --p-gray-10: #a4a19c; --p-gray-11: #b4b1ab;
    --p-gray-12: #ecebe7;
    --p-green: #22c55e; --p-amber: #fbbf24; --p-red: #f87171; --p-blue: #60a5fa;
    --p-accent: #b75b35; --p-accent-deep: #9e441d;
    --p-brand-1: #e67d58; --p-brand-2: #d87880; --p-brand-3: #c77596;
    --shadow-inset: inset 0 1px 1px rgba(0,0,0,0.2);
    --chart-1: #e98664; --chart-2: #86a468; --chart-3: #7ca9d5; --chart-4: #e48da8; --chart-5: #76ab9c; --chart-6: #639c6f;
  }
}
@supports not (color: color-mix(in oklab, red, blue)) {
  :root {
    --card: #fefdfb; --accent: #f2f0ea; --sidebar: #f7f6f1;
    --elevation-1: 0 1px 2px rgba(25,23,21,0.05);
    --c-card-shadow: 0 1px 2px rgba(25,23,21,0.04), 0 8px 24px -12px rgba(25,23,21,0.1);
    --btn-outline-bg-hover: #f1f0ee;
    --success-bg: #eaf4e9; --success-border: #a9d8b0; --success-text: #30753d;
    --warning-bg: #faf0dc; --warning-border: #eecd93; --warning-text: #7a5312;
    --danger-bg:  #f9e8e4; --danger-border:  #efafa6; --danger-text: #942e26;
    --info-bg:    #e9eff7; --info-border:    #accaee; --info-text: #2b5192;
    --state-hover: rgba(43,40,34,0.05); --state-pressed: rgba(43,40,34,0.09);
    --state-selected: rgba(43,40,34,0.07);
    --btn-tonal-bg: #f5e5dc; --btn-tonal-bg-hover: #f2d9ce; --btn-tonal-selected-bg: #f5e3da;
    --btn-tonal-fg: #8d442a; --btn-tonal-border: #d9aa96; --btn-tonal-border-hover: #d3967d;
    --ui-accent-soft: rgba(191,86,48,0.13); --ui-accent-soft-hover: rgba(191,86,48,0.2); --ui-accent-text: #97482c;
    --focus-ring: 0 0 0 2px var(--background), 0 0 0 4px rgba(86,82,77,0.55);
    --focus-ring-danger: 0 0 0 2px var(--background), 0 0 0 4px rgba(220,38,38,0.5);
    --focus-ring-brand: 0 0 0 2px var(--background), 0 0 0 4px rgba(191,86,48,0.42);
  }
  .dark, [data-theme="dark"] {
    --card: #201d1b; --accent: #292623; --sidebar: #1d1a18;
    --elevation-1: inset 0 1px 0 rgba(236,235,232,0.04), 0 1px 2px rgba(17,15,14,0.25);
    --c-card-shadow: inset 0 1px 0 rgba(236,235,232,0.04), 0 8px 24px -12px rgba(17,15,14,0.65);
    --btn-outline-bg-hover: #282523;
    --success-bg: #17251a; --success-border: #2c5840; --success-text: #83d691;
    --warning-bg: #2a2213; --warning-border: #5a4a28; --warning-text: #f2c46b;
    --danger-bg:  #2a1817; --danger-border:  #5a3434; --danger-text: #fba09b;
    --info-bg:    #17223a; --info-border:    #2c4470; --info-text: #96b8f2;
    --state-hover: rgba(255,255,255,0.06); --state-pressed: rgba(255,255,255,0.1);
    --state-selected: rgba(255,255,255,0.08);
    --btn-tonal-bg: #493329; --btn-tonal-bg-hover: #57392b; --btn-tonal-selected-bg: #51362a;
    --btn-tonal-fg: #d5a38e; --btn-tonal-border: #613d2e; --btn-tonal-border-hover: #764530;
    --ui-accent-soft: rgba(183,91,53,0.16); --ui-accent-soft-hover: rgba(183,91,53,0.24); --ui-accent-text: #c57b5d;
    --focus-ring: 0 0 0 2px var(--background), 0 0 0 4px rgba(164,161,156,0.5);
    --focus-ring-danger: 0 0 0 2px var(--background), 0 0 0 4px rgba(248,113,113,0.5);
    --focus-ring-brand: 0 0 0 2px var(--background), 0 0 0 4px rgba(183,91,53,0.45);
  }
}
