/* ============================================================
   胎教故事集 · 主题
   默认深色（夜间友好），可切浅色
   ============================================================ */

:root {
  /* 基础节奏 */
  --radius-sm: 8px;
  --radius: 14px;
  --radius-lg: 22px;
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.06);
  --shadow: 0 6px 24px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 12px 40px rgba(0, 0, 0, 0.12);

  /* 字体栈：移动优先，避开中文系统字体差异 */
  --font-body: -apple-system, BlinkMacSystemFont, "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", "Helvetica Neue", Helvetica,
    Arial, sans-serif;
  --font-serif: "Noto Serif SC", "Source Han Serif SC", "Songti SC",
    "STSong", serif;

  /* 动画曲线 */
  --ease: cubic-bezier(0.4, 0, 0.2, 1);
}

/* ---------- 深色主题（默认） ---------- */
:root,
[data-theme="dark"] {
  --bg: #1a1622;
  --bg-elevated: #25202f;
  --bg-card: #2c2538;
  --bg-overlay: rgba(26, 22, 34, 0.85);

  --text: #f0e8f5;
  --text-soft: #c5b8d4;
  --text-mute: #8b7d9c;

  --border: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.16);

  --accent: #f5b8c8; /* 樱粉 */
  --accent-soft: rgba(245, 184, 200, 0.14);
  --accent-strong: #ffc7d6;

  --secondary: #b8d8f0; /* 月蓝 */
  --secondary-soft: rgba(184, 216, 240, 0.14);

  --warm: #ffd9a8; /* 暖橙 */

  --category-nature: #a8d8b8;
  --category-life: #f5b8c8;
  --category-poetry: #c8b8f0;
}

/* ---------- 浅色主题 ---------- */
[data-theme="light"] {
  --bg: #faf7f5;
  --bg-elevated: #fff;
  --bg-card: #fff;
  --bg-overlay: rgba(250, 247, 245, 0.85);

  --text: #2a2433;
  --text-soft: #5a5168;
  --text-mute: #8b8499;

  --border: rgba(0, 0, 0, 0.06);
  --border-strong: rgba(0, 0, 0, 0.12);

  --accent: #e88aa4;
  --accent-soft: rgba(232, 138, 164, 0.12);
  --accent-strong: #d96f8e;

  --secondary: #7ab0d4;
  --secondary-soft: rgba(122, 176, 212, 0.12);

  --warm: #e8a868;

  --category-nature: #6aaa86;
  --category-life: #d96f8e;
  --category-poetry: #8b7dc8;
}

/* 跟随系统（用户未手动切换时） */
@media (prefers-color-scheme: light) {
  :root:not([data-theme]) {
    color-scheme: light;
    --bg: #faf7f5;
    --bg-elevated: #fff;
    --bg-card: #fff;
    --bg-overlay: rgba(250, 247, 245, 0.85);
    --text: #2a2433;
    --text-soft: #5a5168;
    --text-mute: #8b8499;
    --border: rgba(0, 0, 0, 0.06);
    --border-strong: rgba(0, 0, 0, 0.12);
    --accent: #e88aa4;
    --accent-soft: rgba(232, 138, 164, 0.12);
    --accent-strong: #d96f8e;
    --secondary: #7ab0d4;
    --secondary-soft: rgba(122, 176, 212, 0.12);
    --warm: #e8a868;
    --category-nature: #6aaa86;
    --category-life: #d96f8e;
    --category-poetry: #8b7dc8;
  }
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) {
    color-scheme: dark;
  }
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  transition: background 0.3s var(--ease), color 0.3s var(--ease);
}

body {
  min-height: 100vh;
  min-height: 100dvh;
  /* 防止橡皮筋滚动露出底色不一致 */
  overscroll-behavior-y: contain;
}

a {
  color: inherit;
  text-decoration: none;
}

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

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

/* iOS 安全区 */
@supports (padding: max(0px)) {
  .safe-bottom {
    padding-bottom: max(16px, env(safe-area-inset-bottom));
  }
  .safe-top {
    padding-top: max(12px, env(safe-area-inset-top));
  }
}
