/*
 * Alca design tokens — direction: 墨 Mono.
 * A quiet, near-monochrome instrument: near-black (default) or near-white
 * fields, hairline borders, pill controls, one inverse action color.
 * The only hue is reserved for meaning: amber while Alca waits for you,
 * vermilion for the actions that always need a person (付款・寄送・刪除・發布).
 * Every surface (desktop, phone PWA) imports this file and nothing else
 * defines raw colors, sizes, radii or shadows.
 *
 * Theme: dark is the base. `data-theme="light"` (or the OS preference when
 * no data-theme is set) switches to the light set.
 */
:root {
  /* ── Typography ─────────────────────────────────────────── */
  /* Latin from the platform UI face, CJK from the platform TC face. No web fonts. */
  --font-sans:
    -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI Variable Text", "Segoe UI", "PingFang TC",
    "Noto Sans TC", "Noto Sans CJK TC", "Microsoft JhengHei", "Heiti TC", system-ui, sans-serif;
  --font-display:
    -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI Variable Display", "Segoe UI",
    "PingFang TC", "Noto Sans TC", "Noto Sans CJK TC", "Microsoft JhengHei", system-ui, sans-serif;
  --font-mono: "SF Mono", "JetBrains Mono", ui-monospace, "Cascadia Code", Menlo, Consolas, monospace;

  --text-2xs: 0.6875rem; /* 11 */
  --text-xs: 0.75rem; /* 12 */
  --text-sm: 0.875rem; /* 14 — UI labels */
  --text-md: 1rem; /* 16 — body */
  --text-lg: 1.125rem; /* 18 */
  --text-xl: 1.25rem; /* 20 */
  --text-2xl: 1.75rem; /* 28 */
  --text-3xl: 2.75rem; /* 44 — empty-state wordmark */
  --leading-tight: 1.3;
  --leading-ui: 1.5;
  --leading-body: 1.75; /* CJK reads better with generous leading */
  --tracking-cjk: 0.01em;
  --tracking-display: -0.02em;
  --weight-regular: 400;
  --weight-medium: 500;
  --weight-semibold: 600;

  /* ── Space (4px grid) ───────────────────────────────────── */
  --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;
  --space-16: 64px;

  /* ── Radius ─────────────────────────────────────────────── */
  --radius-xs: 6px;
  --radius-sm: 10px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --radius-xl: 28px;
  --radius-pill: 9999px;

  /* ── Motion ─────────────────────────────────────────────── */
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  --ease-in-out: cubic-bezier(0.65, 0, 0.35, 1);
  --dur-fast: 120ms;
  --dur-base: 180ms;
  --dur-slow: 320ms;

  /* ── Layout ─────────────────────────────────────────────── */
  --sidebar-width: 268px;
  --content-max: 768px;
  --composer-max: 800px;
  --header-height: 56px;
  --control-height: 36px;

  /* ── Phone (PWA) ────────────────────────────────────────── */
  /* Thumb-first: every tap target is at least 44pt; primary decisions are 52. */
  --touch: 44px;
  --touch-big: 52px;
  --phone-topbar: 52px;
  --phone-gutter: 16px;
  --sheet-radius: 28px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
  --ease-spring: cubic-bezier(0.32, 0.72, 0, 1);
  --dur-sheet: 420ms;

  /* ── Color: dark (base) ─────────────────────────────────── */
  color-scheme: dark;
  --c-canvas: #0a0a0a;
  --c-surface: #0a0a0a;
  --c-surface-raised: #151515;
  --c-surface-sunken: #1a1a1a;
  --c-sidebar: #0f0f0f;
  --c-composer: #151515;
  --c-hover: #1a1a1a;
  --c-active: #222222;
  --c-line: #222222;
  --c-line-strong: #343434;

  --c-ink: #fcfcfc;
  --c-ink-soft: #d6d6d6;
  --c-ink-muted: #9e9e9e;
  --c-ink-faint: #737373;

  /* Monochrome "accent": the inverse of the canvas. */
  --c-accent: #fcfcfc;
  --c-accent-strong: #ffffff;
  --c-accent-soft: #1f1f1f;
  --c-accent-ink: #0a0a0a;
  --c-inverse: #fcfcfc;
  --c-inverse-hover: #e2e2e2;
  --c-inverse-ink: #0a0a0a;

  --c-attention: #e8b25c; /* 琥珀: waiting for you */
  --c-attention-soft: #2a2114;
  --c-danger: #ff7a66; /* 朱: always-confirm classes */
  --c-danger-soft: #2c1512;
  --c-danger-line: #5a2a22;
  --c-success: #8fd19a;
  --c-success-soft: #14261a;

  --c-user-bubble: #1e1e1e;
  /* Captions drawn over a live page frame: the same in both themes. */
  --c-overlay: rgb(10 10 10 / 0.82);
  --c-overlay-ink: #fcfcfc;
  --c-attention-ink: #1a1206;
  --c-focus: #8a8a8a;
  --c-selection: rgb(255 255 255 / 0.18);
  --c-scrim: rgb(0 0 0 / 0.6);

  --shadow-xs: 0 1px 0 rgb(0 0 0 / 0.4);
  --shadow-sm: 0 1px 2px rgb(0 0 0 / 0.5);
  --shadow-md: 0 8px 24px -12px rgb(0 0 0 / 0.7);
  --shadow-lg: 0 24px 64px -24px rgb(0 0 0 / 0.85);
  --shadow-composer: 0 0 0 1px rgb(255 255 255 / 0.02), 0 12px 40px -16px rgb(0 0 0 / 0.9);
  --shadow-ring: 0 0 0 2px var(--c-canvas), 0 0 0 4px var(--c-focus);

  /* Team (P7): a bot's avatar tone. Muted on purpose — hue still means "waiting" or "always asks"
     everywhere else; a tone only tells teammates apart on their own tile. */
  --c-bot-ink-bg: #262626;
  --c-bot-ink-fg: #fcfcfc;
  --c-bot-vermilion-bg: #33231e;
  --c-bot-vermilion-fg: #e3b3a2;
  --c-bot-jade-bg: #1b2a24;
  --c-bot-jade-fg: #9ccdb6;
  --c-bot-indigo-bg: #1f2433;
  --c-bot-indigo-fg: #aeb9e3;
  --c-bot-ochre-bg: #2e2619;
  --c-bot-ochre-fg: #dcc08c;
  --c-bot-plum-bg: #2b2030;
  --c-bot-plum-fg: #cfadd8;
}

/* ── Color: light ───────────────────────────────────────────── */
:root[data-theme="light"] {
  color-scheme: light;
  --c-canvas: #fdfdfd;
  --c-surface: #fdfdfd;
  --c-surface-raised: #ffffff;
  --c-surface-sunken: #f3f3f3;
  --c-sidebar: #f9f9f9;
  --c-composer: #f8f8f8;
  --c-hover: #f0f0f0;
  --c-active: #e9e9e9;
  --c-line: #e8e8e8;
  --c-line-strong: #d4d4d4;
  --c-ink: #0d0d0d;
  --c-ink-soft: #3a3a3a;
  --c-ink-muted: #6b6b6b;
  --c-ink-faint: #949494;
  --c-accent: #0d0d0d;
  --c-accent-strong: #000000;
  --c-accent-soft: #efefef;
  --c-accent-ink: #ffffff;
  --c-inverse: #0d0d0d;
  --c-inverse-hover: #2b2b2b;
  --c-inverse-ink: #ffffff;
  --c-attention: #a86a12;
  --c-attention-soft: #fbf1e0;
  --c-danger: #c2381f;
  --c-danger-soft: #fdecea;
  --c-danger-line: #f1c4bb;
  --c-success: #2f7a3e;
  --c-success-soft: #e6f3e8;
  --c-user-bubble: #f1f1f1;
  --c-focus: #8a8a8a;
  --c-selection: rgb(0 0 0 / 0.12);
  --c-scrim: rgb(0 0 0 / 0.28);
  --shadow-xs: 0 1px 0 rgb(0 0 0 / 0.03);
  --shadow-sm: 0 1px 2px rgb(0 0 0 / 0.05);
  --shadow-md: 0 8px 24px -14px rgb(0 0 0 / 0.18);
  --shadow-lg: 0 24px 56px -24px rgb(0 0 0 / 0.22);
  --shadow-composer: 0 1px 2px rgb(0 0 0 / 0.03), 0 10px 30px -18px rgb(0 0 0 / 0.18);

  --c-bot-ink-bg: #161616;
  --c-bot-ink-fg: #ffffff;
  --c-bot-vermilion-bg: #f6e6e0;
  --c-bot-vermilion-fg: #87412c;
  --c-bot-jade-bg: #e2f0ea;
  --c-bot-jade-fg: #2c6550;
  --c-bot-indigo-bg: #e6e9f6;
  --c-bot-indigo-fg: #3c4a85;
  --c-bot-ochre-bg: #f5ecda;
  --c-bot-ochre-fg: #765a1f;
  --c-bot-plum-bg: #f1e6f4;
  --c-bot-plum-fg: #6a3f78;
}

@media (prefers-color-scheme: light) {
  :root:not([data-theme]) {
    color-scheme: light;
    --c-canvas: #fdfdfd;
    --c-surface: #fdfdfd;
    --c-surface-raised: #ffffff;
    --c-surface-sunken: #f3f3f3;
    --c-sidebar: #f9f9f9;
    --c-composer: #f8f8f8;
    --c-hover: #f0f0f0;
    --c-active: #e9e9e9;
    --c-line: #e8e8e8;
    --c-line-strong: #d4d4d4;
    --c-ink: #0d0d0d;
    --c-ink-soft: #3a3a3a;
    --c-ink-muted: #6b6b6b;
    --c-ink-faint: #949494;
    --c-accent: #0d0d0d;
    --c-accent-strong: #000000;
    --c-accent-soft: #efefef;
    --c-accent-ink: #ffffff;
    --c-inverse: #0d0d0d;
    --c-inverse-hover: #2b2b2b;
    --c-inverse-ink: #ffffff;
    --c-attention: #a86a12;
    --c-attention-soft: #fbf1e0;
    --c-danger: #c2381f;
    --c-danger-soft: #fdecea;
    --c-danger-line: #f1c4bb;
    --c-success: #2f7a3e;
    --c-success-soft: #e6f3e8;
    --c-user-bubble: #f1f1f1;
    --c-focus: #8a8a8a;
    --c-selection: rgb(0 0 0 / 0.12);
    --c-scrim: rgb(0 0 0 / 0.28);
    --shadow-xs: 0 1px 0 rgb(0 0 0 / 0.03);
    --shadow-sm: 0 1px 2px rgb(0 0 0 / 0.05);
    --shadow-md: 0 8px 24px -14px rgb(0 0 0 / 0.18);
    --shadow-lg: 0 24px 56px -24px rgb(0 0 0 / 0.22);
    --shadow-composer: 0 1px 2px rgb(0 0 0 / 0.03), 0 10px 30px -18px rgb(0 0 0 / 0.18);

    --c-bot-ink-bg: #161616;
    --c-bot-ink-fg: #ffffff;
    --c-bot-vermilion-bg: #f6e6e0;
    --c-bot-vermilion-fg: #87412c;
    --c-bot-jade-bg: #e2f0ea;
    --c-bot-jade-fg: #2c6550;
    --c-bot-indigo-bg: #e6e9f6;
    --c-bot-indigo-fg: #3c4a85;
    --c-bot-ochre-bg: #f5ecda;
    --c-bot-ochre-fg: #765a1f;
    --c-bot-plum-bg: #f1e6f4;
    --c-bot-plum-fg: #6a3f78;
  }
}

@media (prefers-reduced-motion: reduce) {
  :root {
    --dur-fast: 0ms;
    --dur-base: 0ms;
    --dur-slow: 0ms;
    --dur-sheet: 0ms;
  }
}
