:root {
  /* Palette: Obsidian Cinema & Antique Champagne Gold (Default Dark Theme) */
  --bg-root: #080b12;
  --bg-sidebar: #0c101b;
  --bg-surface: #111624;
  --bg-surface-elevated: #161c2e;
  --bg-glass: rgba(15, 20, 34, 0.78);
  --bg-glass-subtle: rgba(255, 255, 255, 0.025);
  --bg-nav: rgba(8, 11, 18, 0.86);
  --bg-reader-bar: rgba(8, 11, 18, 0.92);
  --bg-card-grad: linear-gradient(180deg, rgba(17, 23, 38, 0.85) 0%, rgba(12, 16, 28, 0.94) 100%);
  --bg-card-soft: rgba(16, 21, 35, 0.78);
  --bg-card-hover: rgba(22, 28, 46, 0.9);
  --bg-dialogue: linear-gradient(180deg, rgba(15, 21, 35, 0.88) 0%, rgba(11, 15, 26, 0.95) 100%);
  --bg-popover: rgba(14, 19, 32, 0.97);
  --bg-drawer: #0d121f;
  --bg-input: rgba(255, 255, 255, 0.045);
  --bg-body-glow:
    radial-gradient(ellipse 85% 42% at 50% -12%, rgba(44, 68, 114, 0.2), transparent 68%),
    radial-gradient(ellipse 48% 36% at 88% 88%, rgba(196, 150, 74, 0.065), transparent 60%);
  --bg-overflow-fade: linear-gradient(180deg, rgba(11, 15, 26, 0) 0%, rgba(11, 15, 26, 0.96) 72%);

  /* Hairline Borders */
  --border-subtle: rgba(255, 255, 255, 0.07);
  --border-medium: rgba(255, 255, 255, 0.13);
  --border-gold: rgba(224, 184, 108, 0.36);
  --border-gold-soft: rgba(224, 184, 108, 0.18);

  /* Surface Controls (2026 Segmented & Switch Tokens) */
  --bg-segment: rgba(255, 255, 255, 0.045);
  --bg-segment-active: rgba(226, 186, 109, 0.18);
  --bg-switch-off: rgba(255, 255, 255, 0.14);
  --switch-knob: #f7f4ec;

  /* Typography Colors */
  --text-primary: #f4efe6;
  --text-secondary: #aeb7ca;
  --text-muted: #7c879e;
  --text-pinyin: #a5b9d6;
  --text-prose-zh: #f8f4ec;
  --text-prose-vi: #d5dce9;

  /* Accent Colors (Restrained Luxury) */
  --gold-primary: #e5be70;
  --gold-soft: #caa158;
  --gold-glow: rgba(229, 190, 112, 0.16);
  --cyan-time: #6ad3e8;
  --cyan-soft: rgba(106, 211, 232, 0.14);
  --crimson-alert: #d96b76;
  --emerald-safe: #6bc49c;

  /* Typography Families (2026 Editorial Fraunces + Be Vietnam Pro + Noto SC) */
  --font-ui: 'Be Vietnam Pro', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-display: 'Fraunces', 'Be Vietnam Pro', Georgia, serif;
  --font-zh: 'Noto Sans SC', 'PingFang SC', 'Microsoft YaHei', sans-serif;
  --font-zh-serif: 'Noto Serif SC', 'Songti SC', serif;

  /* Layout Metrics */
  --sidebar-width: 262px;
  --radius-xs: 8px;
  --radius-sm: 10px;
  --radius-md: 14px;
  --radius-lg: 18px;
  --radius-xl: 22px;
  --radius-pill: 999px;

  /* Transitions */
  --ease-cinema: cubic-bezier(0.22, 1, 0.36, 1);
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* ==========================================================================
   WARM SEPIA READING THEME (Giấy ấm — bảo vệ mắt khi đọc lâu)
   ========================================================================== */
html[data-theme='sepia'] {
  --bg-root: #f3ece0;
  --bg-sidebar: #ece3d2;
  --bg-surface: #faf5eb;
  --bg-surface-elevated: #fffdf8;
  --bg-glass: rgba(246, 239, 226, 0.92);
  --bg-glass-subtle: rgba(74, 53, 28, 0.05);
  --bg-nav: rgba(243, 236, 224, 0.92);
  --bg-reader-bar: rgba(243, 236, 224, 0.95);
  --bg-card-grad: linear-gradient(180deg, #fbf7ee 0%, #f4ecdd 100%);
  --bg-card-soft: #faf5eb;
  --bg-card-hover: #fffbf2;
  --bg-dialogue: linear-gradient(180deg, #fcf8ef 0%, #f5edde 100%);
  --bg-popover: rgba(253, 249, 241, 0.98);
  --bg-drawer: #f6efe2;
  --bg-input: rgba(74, 53, 28, 0.07);
  --bg-segment: rgba(74, 53, 28, 0.075);
  --bg-segment-active: rgba(156, 107, 30, 0.16);
  --bg-switch-off: rgba(74, 53, 28, 0.22);
  --switch-knob: #fffdf8;
  --bg-body-glow:
    radial-gradient(ellipse 85% 42% at 50% -12%, rgba(196, 150, 74, 0.14), transparent 68%),
    radial-gradient(ellipse 48% 36% at 88% 88%, rgba(164, 118, 52, 0.08), transparent 60%);
  --bg-overflow-fade: linear-gradient(180deg, rgba(245, 237, 222, 0) 0%, rgba(245, 237, 222, 0.98) 72%);

  --border-subtle: rgba(82, 58, 29, 0.14);
  --border-medium: rgba(82, 58, 29, 0.24);
  --border-gold: rgba(148, 99, 22, 0.48);
  --border-gold-soft: rgba(148, 99, 22, 0.28);

  --text-primary: #241b12;
  --text-secondary: #4e3f2f;
  --text-muted: #6e5c48;
  --text-pinyin: #584634;
  --text-prose-zh: #1b130b;
  --text-prose-vi: #3c2f21;

  --gold-primary: #936217;
  --gold-soft: #7c5213;
  --gold-glow: rgba(147, 98, 23, 0.13);
  --cyan-time: #1b6b82;
  --emerald-safe: #1f704c;
}

/* ==========================================================================
   CRISP LIGHT READING THEME (Sáng — đọc rõ ngoài trời ban ngày)
   ========================================================================== */
html[data-theme='light'] {
  --bg-root: #f4f6f9;
  --bg-sidebar: #eef1f6;
  --bg-surface: #ffffff;
  --bg-surface-elevated: #ffffff;
  --bg-glass: rgba(255, 255, 255, 0.92);
  --bg-glass-subtle: rgba(15, 23, 42, 0.045);
  --bg-nav: rgba(255, 255, 255, 0.92);
  --bg-reader-bar: rgba(255, 255, 255, 0.95);
  --bg-card-grad: linear-gradient(180deg, #ffffff 0%, #f8fafc 100%);
  --bg-card-soft: #ffffff;
  --bg-card-hover: #f8fafc;
  --bg-dialogue: linear-gradient(180deg, #ffffff 0%, #f8fafc 100%);
  --bg-popover: rgba(255, 255, 255, 0.98);
  --bg-drawer: #ffffff;
  --bg-input: rgba(15, 23, 42, 0.065);
  --bg-segment: rgba(15, 23, 42, 0.06);
  --bg-segment-active: rgba(158, 108, 24, 0.14);
  --bg-switch-off: rgba(15, 23, 42, 0.2);
  --switch-knob: #ffffff;
  --bg-body-glow:
    radial-gradient(ellipse 85% 42% at 50% -12%, rgba(99, 132, 196, 0.1), transparent 68%),
    radial-gradient(ellipse 48% 36% at 88% 88%, rgba(196, 150, 74, 0.06), transparent 60%);
  --bg-overflow-fade: linear-gradient(180deg, rgba(248, 250, 252, 0) 0%, rgba(248, 250, 252, 0.98) 72%);

  --border-subtle: rgba(15, 23, 42, 0.11);
  --border-medium: rgba(15, 23, 42, 0.2);
  --border-gold: rgba(158, 108, 24, 0.46);
  --border-gold-soft: rgba(158, 108, 24, 0.26);

  --text-primary: #111827;
  --text-secondary: #3f4b5e;
  --text-muted: #5a677c;
  --text-pinyin: #39557d;
  --text-prose-zh: #0b1220;
  --text-prose-vi: #273449;

  --gold-primary: #9c6a16;
  --gold-soft: #815711;
  --gold-glow: rgba(156, 106, 22, 0.12);
  --cyan-time: #0d6d89;
  --emerald-safe: #197049;
}

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  min-height: 100%;
  background: var(--bg-root);
  color: var(--text-primary);
  font-family: var(--font-ui);
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: clip;
  transition: background-color 0.25s ease, color 0.25s ease;
}

button {
  font-family: inherit;
  color: inherit;
  background: none;
  border: none;
  cursor: pointer;
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
[tabindex]:focus-visible {
  outline: 2px solid var(--gold-primary);
  outline-offset: 2px;
}

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

/* Custom minimal scrollbar */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: var(--border-medium);
  border-radius: 99px;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--border-gold);
}
