/*
 * 木易星球（muyischool.cn）V4 三层设计 Token（严格遵循 DESIGN.md）
 * Primitive -> Semantic -> Component
 * 气质：浅色工作室冷石膏（Cool Studio Alabaster）× 深色电影暗房（Cinema Darkroom Teal）× 小狐狸暖琥珀
 */

:root {
  /* === Layer 1: Primitive Palette === */
  --stone-0: #FFFFFF;
  --stone-50: #F6F7F9;
  --stone-100: #ECEEF2;
  --stone-150: #E3E6EC;
  --stone-200: #D7DCE4;
  --stone-500: #5E6878;
  --stone-700: #394250;
  --stone-900: #151922;
  --stone-950: #0F141A;

  --teal-400: #299DA7;
  --teal-500: #1E828B;
  --teal-600: #156A72;
  --teal-700: #0F535A;
  --teal-800: #0B4046;

  --amber-400: #E5813E;
  --amber-600: #C45814;

  --emerald-500: #34B77C;
  --emerald-600: #178254;
  --rose-500: #E85B5F;
  --rose-600: #C8373B;

  /* === Layer 2: Semantic Tokens (Light: Cool Studio Alabaster) === */
  --bg-canvas: var(--stone-50);
  --bg-sidebar: var(--stone-100);
  --bg-surface: var(--stone-0);
  --bg-surface-muted: #EFF1F5;
  --bg-surface-hover: #F4F6F9;
  --bg-darkroom: #0D1419;
  --bg-darkroom-elev: #141E25;

  --ink-primary: var(--stone-950);
  --ink-secondary: var(--stone-700);
  --ink-muted: var(--stone-500);
  --ink-on-accent: #FFFFFF;

  --border-subtle: rgba(15, 20, 26, 0.085);
  --border-strong: rgba(15, 20, 26, 0.16);
  --img-outline: rgba(15, 20, 26, 0.09);

  --accent-solid: var(--teal-700);
  --accent-hover: var(--teal-800);
  --accent-soft: rgba(15, 83, 90, 0.09);
  --accent-border: rgba(15, 83, 90, 0.24);
  --accent-warm: var(--amber-600);
  --accent-warm-soft: rgba(196, 88, 20, 0.10);

  --status-success: var(--emerald-600);
  --status-success-soft: rgba(23, 130, 84, 0.11);
  --status-danger: var(--rose-600);

  --selection-bg: rgba(15, 83, 90, 0.18);
  --selection-ink: var(--stone-950);

  /* === Layer 3: Component & Geometry Tokens === */
  --sidebar-w: 240px;
  --mobile-topbar-h: 56px;
  --mobile-tabbar-h: 62px;

  /* Concentric Radii: outer = inner + padding */
  --r-inner: 6px;
  --r-mid: 10px;
  --r-card: 14px;
  --r-outer: 16px;
  --r-pill: 999px;

  /* Typography */
  --font-sans: "PingFang SC", -apple-system, BlinkMacSystemFont, "SF Pro Display", "Noto Sans SC", "Helvetica Neue", sans-serif;
  --font-mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Monaco, Consolas, monospace;

  /* Tactile Motion Curves */
  --ease-ui: cubic-bezier(0.2, 0, 0, 1);
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  --dur-press: 150ms;
  --dur-fast: 180ms;
  --dur-base: 260ms;
  --dur-slide: 280ms;
  --dur-expand: 300ms;

  /* Restrained Studio Elevation */
  --shadow-card: 0 1px 2px rgba(15, 20, 26, 0.04);
  --shadow-hover: 0 10px 26px rgba(15, 20, 26, 0.07), 0 2px 6px rgba(15, 20, 26, 0.04);
  --shadow-drawer: -14px 0 42px rgba(15, 20, 26, 0.14);
  --shadow-modal: 0 24px 64px rgba(15, 20, 26, 0.24);
}

[data-theme="dark"] {
  --bg-canvas: #0B0D11;
  --bg-sidebar: #101319;
  --bg-surface: #151922;
  --bg-surface-muted: #1B202C;
  --bg-surface-hover: #1E2432;
  --bg-darkroom: #080B0F;
  --bg-darkroom-elev: #111820;

  --ink-primary: #F2F4F8;
  --ink-secondary: #A7B0BE;
  --ink-muted: #7D8798;
  --ink-on-accent: #071315;

  --border-subtle: rgba(242, 244, 248, 0.09);
  --border-strong: rgba(242, 244, 248, 0.18);
  --img-outline: rgba(242, 244, 248, 0.11);

  --accent-solid: var(--teal-400);
  --accent-hover: #38B2BD;
  --accent-soft: rgba(41, 157, 167, 0.16);
  --accent-border: rgba(41, 157, 167, 0.34);
  --accent-warm: var(--amber-400);
  --accent-warm-soft: rgba(229, 129, 62, 0.16);

  --status-success: var(--emerald-500);
  --status-success-soft: rgba(52, 183, 124, 0.16);
  --status-danger: var(--rose-500);

  --selection-bg: rgba(41, 157, 167, 0.28);
  --selection-ink: #F2F4F8;

  --shadow-card: 0 1px 2px rgba(0, 0, 0, 0.28);
  --shadow-hover: 0 14px 32px rgba(0, 0, 0, 0.42);
  --shadow-drawer: -14px 0 48px rgba(0, 0, 0, 0.52);
  --shadow-modal: 0 28px 72px rgba(0, 0, 0, 0.62);
}

/* Zero-smear instant theme switch helper */
.no-theme-transitions *,
.no-theme-transitions *::before,
.no-theme-transitions *::after {
  transition: none !important;
}

/* Base Reset & Browser Native Surfaces */
*, *::before, *::after {
  box-sizing: border-box;
}

html {
  font-size: 16px;
  scroll-padding-block-start: 72px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: clip;
  background: var(--bg-canvas);
}

body {
  margin: 0;
  min-height: 100dvh;
  background: var(--bg-canvas);
  color: var(--ink-primary);
  font-family: var(--font-sans);
  line-height: 1.65;
  overflow-x: clip;
  caret-color: var(--accent-solid);
}

::selection {
  background: var(--selection-bg);
  color: var(--selection-ink);
}

/* Slim Custom Scrollbars */
::-webkit-scrollbar {
  width: 7px;
  height: 7px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border-radius: 999px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--ink-muted);
}

img {
  display: block;
  max-width: 100%;
}

a {
  color: inherit;
  text-decoration: none;
  text-underline-offset: 4px;
}

button, input {
  font: inherit;
  color: inherit;
}

button {
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
  touch-action: manipulation;
}

button:focus-visible,
a:focus-visible,
input:focus-visible {
  outline: 2px solid var(--accent-solid);
  outline-offset: 2px;
}

h1, h2, h3, h4, p, ul, ol, figure, pre {
  margin: 0;
}

h1, h2, h3 {
  text-wrap: balance;
}

p {
  text-wrap: pretty;
}

[hidden] {
  display: none !important;
}

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