@layer tokens, base, components, layouts;

@layer tokens {
  :root {
    /* primitives */
    --ink-900: #1a1a1a; --ink-800: #262626; --ink-700: #333333; --ink-600: #4d4d4d;
    --ink-500: #616161; --ink-400: #8c8c8c; --ink-300: #d6d3cd; --ink-200: #e6e3dd;
    --ink-150: #edeae5; --ink-100: #f3f1ed;
    --paper-100: #f7f5f2; --paper-0: #ffffff;
    --zhu-600: #ad3e32; --zhu-100: #f7e8e5;
    --green-700: #276443; --green-100: #e7f1ea;
    --amber-700: #885115; --amber-100: #f9eedd;
    --petrol-900: #0d2b30; --petrol-700: #1f6169; --petrol-100: #e2eeef;
    --texture-light: url("data:image/svg+xml,%3Csvg width='100' height='100' viewBox='0 0 100 100' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M11 18c3.866 0 7-3.134 7-7s-3.134-7-7-7-7 3.134-7 7 3.134 7 7 7zm48 25c3.866 0 7-3.134 7-7s-3.134-7-7-7-7 3.134-7 7 3.134 7 7 7zm-43-7c1.657 0 3-1.343 3-3s-1.343-3-3-3-3 1.343-3 3 1.343 3 3 3zm63 31c1.657 0 3-1.343 3-3s-1.343-3-3-3-3 1.343-3 3 1.343 3 3 3zM34 90c1.657 0 3-1.343 3-3s-1.343-3-3-3-3 1.343-3 3 1.343 3 3 3zm56-76c1.657 0 3-1.343 3-3s-1.343-3-3-3-3 1.343-3 3 1.343 3 3 3zM12 86c2.21 0 4-1.79 4-4s-1.79-4-4-4-4 1.79-4 4 1.79 4 4 4zm28-65c2.21 0 4-1.79 4-4s-1.79-4-4-4-4 1.79-4 4 1.79 4 4 4zm23-11c2.76 0 5-2.24 5-5s-2.24-5-5-5-5 2.24-5 5 2.24 5 5 5zm-6 60c2.21 0 4-1.79 4-4s-1.79-4-4-4-4 1.79-4 4 1.79 4 4 4zm29 22c2.76 0 5-2.24 5-5s-2.24-5-5-5-5 2.24-5 5 2.24 5 5 5zM32 63c2.76 0 5-2.24 5-5s-2.24-5-5-5-5 2.24-5 5 2.24 5 5 5zm57-13c2.76 0 5-2.24 5-5s-2.24-5-5-5-5 2.24-5 5 2.24 5 5 5zm-9-21c1.105 0 2-.895 2-2s-.895-2-2-2-2 .895-2 2 .895 2 2 2zM60 91c1.105 0 2-.895 2-2s-.895-2-2-2-2 .895-2 2 .895 2 2 2zM35 41c1.105 0 2-.895 2-2s-.895-2-2-2-2 .895-2 2 .895 2 2 2zM12 60c1.105 0 2-.895 2-2s-.895-2-2-2-2 .895-2 2 .895 2 2 2z' fill='%23808080' fill-opacity='0.06' fill-rule='evenodd'/%3E%3C/svg%3E");
    --texture-dark: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23ffffff' fill-opacity='0.03'%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");

    /* semantic */
    --color-canvas: var(--paper-100);
    --color-surface: var(--paper-0);
    --color-sunken: var(--ink-100);
    --color-hover: var(--ink-150);
    --color-text: var(--ink-900);
    --color-text-muted: var(--ink-500);
    --color-line: var(--ink-200);
    --color-line-strong: var(--ink-400);
    --color-brand: var(--zhu-600);
    --color-brand-soft: var(--zhu-100);
    --color-focus: var(--ink-900);
    --color-action: var(--ink-900);
    --color-action-hover: var(--ink-700);
    --color-on-action: var(--paper-0);
    --color-overlay: rgb(20 20 20 / 42%);
    --status-success: var(--green-700); --status-success-bg: var(--green-100);
    --status-progress: var(--amber-700); --status-progress-bg: var(--amber-100);
    --status-danger: var(--zhu-600); --status-danger-bg: var(--zhu-100);
    --status-neutral: var(--ink-500); --status-neutral-bg: var(--ink-150);
    --texture: var(--texture-light);
    --metric-similarity: #b3392d;
    --metric-ai: #245c9b;
    --color-mark: #ad3e32;
    --select-chevron: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23808080' stroke-width='2'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
    --control-border-hover: var(--ink-600);
    --color-on-danger: var(--paper-0);
    --toast-background: var(--ink-900);
    --toast-text: var(--paper-100);
    --on-action-danger: #f3b0a4;
    --toast-success: #9ed7b0;
    --toast-success-dark: var(--green-100);
    --toast-success-stroke: #276443;
    --font-wordmark: "Source Serif 4", "Noto Serif SC", Georgia, serif;

    --font-display: "Source Serif 4", "Noto Serif SC", "Songti SC", "Noto Serif CJK SC", serif;
    --font-ui: "Source Sans 3", -apple-system, "PingFang SC", "Noto Sans SC", "Microsoft YaHei", sans-serif;
    --font-mono: "Source Code Pro", ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
    --text-xs: 12px; --text-sm: 13px; --text-md: 14px; --text-base: 15px; --text-lg: 17px;
    --text-xl: 20px; --text-2xl: 26px; --text-3xl: 30px; --text-hero: 46px;
    --space-1: 4px; --space-2: 8px; --space-3: 12px; --space-4: 16px; --space-5: 20px;
    --space-6: 24px; --space-8: 32px; --space-10: 40px; --space-12: 48px;
    --radius-chip: 4px; --radius-control: 6px; --radius-surface: 8px;
    --shadow-segment: 0 1px 2px rgb(0 0 0 / 10%), 0 0 0 1px var(--color-line);
    --shadow-sheet: 0 1px 0 rgb(0 0 0 / 3%), 0 20px 44px -32px rgb(0 0 0 / 30%);
    --shadow-float: 0 12px 32px -12px rgb(0 0 0 / 28%), 0 0 0 1px var(--color-line);
    --ease: cubic-bezier(.2, 0, 0, 1);
    --dur-fast: 120ms; --dur: 160ms; --dur-slow: 240ms;

    /* component */
    --kv-label-width: 34%;
    --kv-label-min: 96px;
    --control-h: 44px;
    --icon-stroke: 1.6;
    --side-bg: var(--color-canvas);
    --side-w: 232px;
    color-scheme: light;
  }
  [data-theme="dark"] {
    --ink-900: #ebe9e6; --ink-800: #dddbd7; --ink-700: #cfcdc9; --ink-600: #bdbbb7;
    --ink-500: #a8a6a2; --ink-400: #7d7b78; --ink-300: #45433f; --ink-200: #353431;
    --ink-150: #2c2b29; --ink-100: #252524;
    --paper-100: #171717; --paper-0: #1f1f1f;
    --zhu-600: #ec9a88; --zhu-100: #3f2723;
    --green-700: #97d3aa; --green-100: #1e3125;
    --amber-700: #eec58d; --amber-100: #3a2f20;
    --petrol-700: #86c9ce; --petrol-100: #1b3133;
    --texture: var(--texture-dark);
    --metric-similarity: #f19b89;
    --metric-ai: #9bc5f7;
    --color-mark: #ec9a88;
    --color-on-danger: var(--paper-100);
    --on-action-danger: #8f2f24;
    --color-on-action: #171717;
    --color-overlay: rgb(0 0 0 / 60%);
    --shadow-sheet: 0 0 0 1px var(--color-line);
    --shadow-float: 0 16px 40px -12px rgb(0 0 0 / 70%), 0 0 0 1px var(--color-line);
    color-scheme: dark;
  }
  /* ---- brand theme: iThenticate (petrol, sans display, flat cool paper) ---- */
  [data-brand="ithenticate"] {
    --color-canvas: #f4f6f6;
    --texture: none;
    --color-sunken: #eef2f2;
    --color-hover: #e7eded;
    --color-line: #dde4e4;
    --color-line-strong: #86979a;
    --color-text-muted: #5a6b6d;
    --color-brand: var(--petrol-700);
    --color-brand-soft: var(--petrol-100);
    --color-focus: var(--petrol-700);
    --color-action: var(--petrol-700);
    --color-action-hover: #184f56;
    --font-display: "Source Sans 3", -apple-system, "PingFang SC", "Noto Sans SC", "Microsoft YaHei", sans-serif;
    --shadow-sheet: 0 1px 2px rgb(13 43 48 / 6%), 0 12px 32px -18px rgb(13 43 48 / 22%);
  }
  [data-brand="ithenticate"][data-theme="dark"] {
    --color-canvas: #121617;
    --color-surface: #1a2022;
    --color-sunken: #20282a;
    --color-hover: #263033;
    --color-line: #2c3639;
    --color-line-strong: #5f7174;
    --color-text-muted: #9fb0b2;
    --color-brand: #86c9ce;
    --color-focus: #86c9ce;
    --color-action: #86c9ce;
    --color-action-hover: #a3d6da;
    --color-on-action: #0d2b30;
    --shadow-sheet: 0 0 0 1px var(--color-line);
  }
  /* ---- brand theme: Open API (keeps its zinc palette and Geist type) ---- */
  [data-brand="open-api"] {
    --kv-label-width: 42%;
    --kv-label-min: 150px;
    --color-canvas: #fafafa;
    --texture: none;
    --color-surface: #ffffff;
    --color-sunken: #f4f4f5;
    --color-hover: #f1f1f3;
    --color-text: #18181b;
    --color-text-muted: #6b6b74;
    --color-line: #e4e4e7;
    --color-line-strong: #8a8a93;
    --color-brand: #18181b;
    --color-brand-soft: #f1f1f3;
    --color-focus: #18181b;
    --color-action: #18181b;
    --color-action-hover: #27272a;
    --color-on-action: #ffffff;
    --status-success: #15803d; --status-success-bg: #dcfce7;
    --color-discount-bg: var(--status-success-bg);
    --status-progress: #b45309; --status-progress-bg: #fffbeb;
    --status-danger: #b91c1c; --status-danger-bg: #fef2f2;
    --status-neutral: #52525b; --status-neutral-bg: #f4f4f5;
    --font-display: "Geist", -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
    --font-ui: "Geist", -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
    --font-mono: "JetBrains Mono", "SFMono-Regular", Consolas, monospace;
    --shadow-sheet: none;
    --side-w: 236px;
    --metric-similarity: #b91c1c;
    --metric-ai: #2563eb;
  }
  [data-brand="open-api"][data-theme="dark"] {
    --color-canvas: #09090b;
    --color-surface: #0c0c0e;
    --color-sunken: #18181b;
    --color-hover: #1d1d20;
    --color-text: #f4f4f5;
    --color-text-muted: #a1a1aa;
    --color-line: #27272a;
    --color-line-strong: #63636b;
    --color-brand: #f4f4f5;
    --color-brand-soft: #1d1d20;
    --color-focus: #f4f4f5;
    --color-action: #f4f4f5;
    --color-action-hover: #ffffff;
    --color-on-action: #09090b;
    --status-success: #4ade80; --status-success-bg: rgb(34 197 94 / 13%);
    --color-discount-bg: #183020;
    --status-progress: #fbbf24; --status-progress-bg: rgb(245 158 11 / 12%);
    --status-danger: #f87171; --status-danger-bg: rgb(239 68 68 / 12%);
    --status-neutral: #a1a1aa; --status-neutral-bg: #18181b;
    --metric-similarity: #f87171;
    --metric-ai: #60a5fa;
  }
  .console { --control-h: 36px; }
  @media (pointer: coarse) { .console { --control-h: 44px; } }
}
