/* 「我们的时光」深色模式（Dark Mode）覆盖块
 * 严格沿用 DESIGN.md 的 token 名，仅改值不改名；
 * 根元素 document.documentElement[data-theme="dark"] 为唯一真相源。
 */

:root[data-theme="dark"] {
  color-scheme: dark;

  /* 背景 / 表面 / 边框 */
  --color-rose-50:  #241a17;
  --color-rose-100: #3a2622;
  --color-rose-200: #5a3a38;
  --color-warm-50:  #2b201c;
  --color-warm-100: #33261f;
  --color-warm-200: #3a2c26;
  --color-bg:       #20160f;
  --color-surface:  #2a1f1a;
  --color-border:   #3a2c26;

  /* 文字 */
  --color-text-primary:   #F3E9E2;
  --color-text-secondary: #C9B8AE;
  --color-warm-600: #C9B8AE;
  --color-warm-800: #E7D9D0;
  --color-warm-900: #F3E9E2;

  /* 点缀色在深色下略提亮，保持对比 */
  --color-gold:     #E0BA86;
  --color-mint:     #A9D8C9;
  --color-lavender: #D8CAE8;
  --color-sunset:   #F2B79C;

  --color-rose-400: #F58CA6;
  --color-rose-600: #EC6E8C;
}

/* 平滑切换过渡 */
html { transition: background-color var(--duration-normal), color var(--duration-normal); }
:root[data-theme="dark"] body { background: var(--color-bg); color: var(--color-text-primary); }

/* ── 白底容器在深色下改为表面色，避免残白块 ── */
:root[data-theme="dark"] .gate-card,
:root[data-theme="dark"] .login-card,
:root[data-theme="dark"] .card,
:root[data-theme="dark"] .row,
:root[data-theme="dark"] .photo-tile,
:root[data-theme="dark"] .tile,
:root[data-theme="dark"] .entry-card,
:root[data-theme="dark"] .game-card,
:root[data-theme="dark"] .more-card,
:root[data-theme="dark"] .place-card,
:root[data-theme="dark"] .lb-inner,
:root[data-theme="dark"] .msg.her .bubble,
:root[data-theme="dark"] .quiz-opt,
:root[data-theme="dark"] .who-toggle,
:root[data-theme="dark"] .nav-music,
:root[data-theme="dark"] .tabbar,
:root[data-theme="dark"] .footer,
:root[data-theme="dark"] .filter,
:root[data-theme="dark"] .nav,
:root[data-theme="dark"] .composer { background: var(--color-surface); }

:root[data-theme="dark"] .gate-card { background: rgba(42, 31, 28, 0.82); }
:root[data-theme="dark"] .nav,
:root[data-theme="dark"] .composer { background: rgba(42, 31, 28, 0.82); }

/* ── 输入框 / 下拉 / 文本域 ── */
:root[data-theme="dark"] .gate-input,
:root[data-theme="dark"] input,
:root[data-theme="dark"] select,
:root[data-theme="dark"] textarea {
  background: var(--color-warm-100);
  color: var(--color-text-primary);
  border-color: var(--color-border);
}

/* ── 地图 canvas 容器：避免深色地图上出现浅色底 ── */
:root[data-theme="dark"] .map-loading,
:root[data-theme="dark"] .place-thumb { background: var(--color-warm-100); }

/* ── 引用带 / 卡片描边微调 ── */
:root[data-theme="dark"] .quote-band { background: var(--color-rose-50); }

/* ════════════════════════════════════════════════════════════
   共享组件（与明暗无关，全站生效）：主题切换按钮 / 入口主题按钮 / 音乐附加控件
   ════════════════════════════════════════════════════════════ */
.nav-theme {
  flex: none; border: none; cursor: pointer; font-size: 1.1rem; line-height: 1;
  width: 38px; height: 38px; border-radius: var(--radius-full);
  background: var(--color-rose-50); color: var(--color-rose-600);
  display: grid; place-items: center; margin-left: var(--space-sm);
  box-shadow: 0 4px 12px rgba(244, 132, 160, 0.22);
  transition: transform var(--duration-fast), background var(--duration-fast), color var(--duration-fast);
}
.nav-theme:hover { transform: translateY(-1px); }
.nav-theme:active { transform: scale(0.94); }

.gate-theme {
  position: fixed; top: 16px; right: 16px; z-index: 5;
  width: 40px; height: 40px; border: none; cursor: pointer; font-size: 1.1rem;
  border-radius: var(--radius-full); background: rgba(255, 251, 248, 0.7); color: var(--color-rose-600);
  display: grid; place-items: center; box-shadow: var(--shadow-sm);
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
}
:root[data-theme="dark"] .gate-theme { background: rgba(42, 31, 28, 0.7); color: var(--color-rose-400); }

/* 音乐控件：绝对定位下拉面板，避免撑乱导航栏 */
.nav-music { position: relative; }
.music-panel {
  display: none; position: absolute; top: calc(100% + 8px); right: 0; z-index: 300;
  align-items: center; gap: 8px; flex-wrap: wrap; width: max-content; max-width: 88vw;
  padding: 8px 12px; border-radius: var(--radius-lg);
  background: #fff; border: 1px solid var(--color-rose-100);
  box-shadow: 0 8px 24px rgba(244, 132, 160, 0.18);
}
.nav-music.vol-open .music-panel { display: flex; }
.music-prev, .music-next {
  flex: none; border: none; cursor: pointer; width: 30px; height: 30px; border-radius: var(--radius-full);
  background: var(--color-rose-50); color: var(--color-rose-600); display: grid; place-items: center;
  font-size: 0.85rem; transition: transform var(--duration-fast);
}
.music-prev:hover, .music-next:hover { transform: translateY(-1px); }
.music-bar { width: 110px; accent-color: var(--color-rose-500); cursor: pointer; }
.music-time { font-size: 0.7rem; color: var(--color-warm-600); min-width: 34px; text-align: center; }
.music-sep { width: 1px; height: 20px; background: var(--color-rose-100); margin: 0 2px; }

/* 常驻音量/控制按钮：点击展开下拉面板（音量随时可调） */
.music-vol {
  flex: none; border: none; cursor: pointer; background: none; padding: 2px 4px;
  font-size: 1rem; line-height: 1; color: var(--color-rose-500);
  transition: transform var(--duration-fast);
}
.music-vol:hover { transform: translateY(-1px); }
.music-vol-bar { width: 80px; accent-color: var(--color-rose-500); cursor: pointer; }
:root[data-theme="dark"] .music-panel {
  background: var(--color-surface); border-color: #4a2f33;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
}
:root[data-theme="dark"] .music-sep { background: #4a2f33; }

/* 手机端（≤879）控件宽窄与主题按钮靠右：保持既有移动端形态不变 */
@media (max-width: 879px) {
  .nav-theme { margin-left: auto; }
  .music-bar { width: 80px; }
  .music-vol-bar { width: 60px; }
}

/* ══ 首页故事长卷（P1-O）+ 回忆彩蛋（P1-E） ══ */
.extras-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: var(--space-md); }
.extra-card { display: flex; gap: var(--space-sm); background: var(--color-warm-50); border-radius: var(--radius-lg); padding: var(--space-md); box-shadow: var(--shadow-sm); }
.extra-ico { font-size: 1.6rem; }
.extra-title { font-family: var(--font-display); font-weight: 600; font-size: 1.1rem; }
.extra-text { color: var(--color-warm-600); font-size: 0.9rem; margin-top: 2px; }
.extra-go { display: inline-block; margin-top: 6px; color: var(--color-rose-400); font-weight: 700; font-size: 0.85rem; }

.story-feed { display: flex; flex-direction: column; gap: var(--space-md); }
.story-empty { text-align: center; color: var(--color-warm-600); padding: var(--space-xl) 0; font-family: var(--font-quote); font-size: 1.05rem; }
.story-card { display: flex; gap: var(--space-sm); background: var(--color-warm-50); border-radius: var(--radius-lg); padding: var(--space-md); box-shadow: var(--shadow-sm); animation: storyIn .4s var(--ease-out); }
@keyframes storyIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
.story-card .sc-ico { font-size: 1.5rem; flex: none; }
.story-card .sc-body { min-width: 0; flex: 1; }
.story-card .sc-date { font-size: 0.72rem; color: var(--color-rose-600); font-weight: 700; }
.story-card .sc-title { font-family: var(--font-display); font-weight: 600; font-size: 1.02rem; margin: 2px 0; }
.story-card .sc-text { color: var(--color-warm-800); font-size: 0.9rem; line-height: 1.6; word-break: break-word; }
.story-card .sc-img { width: 72px; height: 72px; object-fit: cover; border-radius: var(--radius-md); flex: none; }
:root[data-theme="dark"] .extra-card,
:root[data-theme="dark"] .story-card { background: var(--color-surface); }

/* ═══════════════════════════════════════════════════════════════════
   全站入口登录门（ENTRANCE GATE）— 抽自 index.html，所有页面共享
   Entrance.showGate() 动态注入 .gate 遮罩 DOM，各页零重复 CSS。
   设计令牌沿用 DESIGN.md，样式与旧入口页结构/动画一致。
   ═══════════════════════════════════════════════════════════════════ */
.gate {
  position: fixed;
  inset: 0;
  z-index: 9998;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--space-md);
  background:
    radial-gradient(60% 50% at 20% 15%, rgba(255,194,209,0.55) 0%, rgba(255,240,243,0) 60%),
    radial-gradient(55% 50% at 85% 80%, rgba(244,132,160,0.35) 0%, rgba(255,240,243,0) 60%),
    radial-gradient(40% 40% at 50% 50%, rgba(196,181,216,0.25) 0%, rgba(255,240,243,0) 70%),
    linear-gradient(160deg, rgba(255,240,243,0.97) 0%, rgba(255,251,248,0.97) 100%);
}

.gate-card {
  width: 100%;
  max-width: 440px;
  background: rgba(255,251,248,0.78);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-radius: var(--radius-xl);
  padding: var(--space-2xl) var(--space-xl);
  box-shadow: var(--shadow-lg);
  text-align: center;
  animation: cardIn 0.9s var(--ease-out) both;
}

@keyframes cardIn {
  from { opacity: 0; transform: translateY(18px) scale(0.98); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

.gate-mark {
  width: 72px;
  height: 72px;
  margin: 0 auto var(--space-md);
  border-radius: var(--radius-full);
  background: linear-gradient(135deg, var(--color-rose-400), var(--color-rose-600));
  display: grid;
  place-items: center;
  box-shadow: 0 8px 24px rgba(244,132,160,0.4);
  animation: floaty 4s ease-in-out infinite;
}
.gate-mark svg { width: 38px; height: 38px; }
@keyframes floaty {
  0%,100% { transform: translateY(0); }
  50%     { transform: translateY(-6px); }
}

.gate-title {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 2.25rem;
  line-height: 1.2;
  background: linear-gradient(120deg, var(--color-rose-600), var(--color-rose-400) 60%, var(--color-gold));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  color: transparent;
  margin-bottom: var(--space-2xs);
}
.gate-sub {
  font-family: var(--font-quote);
  font-size: 1.125rem;
  color: var(--color-warm-600);
  margin-bottom: var(--space-lg);
}

.gate-field { position: relative; margin-bottom: var(--space-sm); }
.gate-input {
  width: 100%;
  height: 52px;
  padding: 0 20px;
  font-family: var(--font-body);
  font-size: 1rem;
  color: var(--color-warm-900);
  background: #FFFFFF;
  border: 1.5px solid var(--color-warm-200);
  border-radius: var(--radius-lg);
  text-align: center;
  letter-spacing: 0.12em;
  transition: border-color var(--duration-fast), box-shadow var(--duration-fast);
}
.gate-input::placeholder { color: var(--color-warm-600); letter-spacing: 0; }
.gate-input:focus {
  outline: none;
  border-color: var(--color-rose-400);
  box-shadow: 0 0 0 4px rgba(244,132,160,0.15);
}
.gate-input.error {
  border-color: var(--color-error);
  box-shadow: 0 0 0 4px rgba(232,131,122,0.15);
  animation: shake 0.4s var(--ease-out);
}
@keyframes shake {
  0%,100% { transform: translateX(0); }
  20%,60% { transform: translateX(-8px); }
  40%,80% { transform: translateX(8px); }
}

.gate-btn {
  width: 100%;
  height: 52px;
  margin-top: var(--space-2xs);
  border: none;
  border-radius: var(--radius-full);
  background: linear-gradient(135deg, var(--color-rose-400), var(--color-rose-600));
  color: #FFFFFF;
  font-family: var(--font-body);
  font-weight: 700;
  font-size: 1.0625rem;
  cursor: pointer;
  transition: transform var(--duration-fast), box-shadow var(--duration-fast);
  box-shadow: 0 6px 18px rgba(244,132,160,0.35);
}
.gate-btn:hover { transform: translateY(-2px); box-shadow: 0 10px 26px rgba(224,87,122,0.4); }
.gate-btn:active { transform: translateY(0); }
.gate-btn:disabled { opacity: 0.7; cursor: default; transform: none; }

.gate-hint {
  margin-top: var(--space-md);
  font-size: 0.8125rem;
  color: var(--color-warm-600);
  line-height: 1.6;
}
.gate-hint b { color: var(--color-rose-600); font-weight: 700; }

.gate-msg {
  min-height: 18px;
  margin-top: var(--space-xs);
  font-size: 0.875rem;
  color: var(--color-error);
  opacity: 0;
  transition: opacity var(--duration-fast);
}
.gate-msg.show { opacity: 1; }

.gate-foot {
  position: relative;
  z-index: 2;
  margin-top: var(--space-lg);
  font-size: 0.8125rem;
  color: var(--color-warm-600);
  font-family: var(--font-quote);
}

/* 进入后的淡出 */
.gate.leaving { animation: gateOut 0.7s var(--ease-out) forwards; }
@keyframes gateOut {
  to { opacity: 0; transform: scale(1.04); }
}

/* ══ 无障碍焦点态：键盘聚焦显示可见焦点环（全站统一，原仅入口页内联） ══ */
a:focus-visible,
button:focus-visible,
[tabindex]:focus-visible,
.filter:focus-visible,
.tile:focus-visible,
.lb-btn:focus-visible,
.send-btn:focus-visible,
.music-btn:focus-visible,
textarea:focus-visible,
.place-card:focus-visible,
.quiz-opt:focus-visible,
.dpad button:focus-visible,
.who-toggle button:focus-visible,
.reset:focus-visible,
.gate-btn:focus-visible,
.btn:focus-visible,
.play-card:focus-visible {
  outline: 2px solid var(--color-rose-400);
  outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.001ms !important; }
}

/* ══ 全站导航搜索框（theme.js 注入；内容页共用，入口页/后台不注入） ══ */
.nav-search {
  display: flex; align-items: center; gap: 4px;
  background: var(--color-rose-50); border: 1px solid var(--color-rose-100);
  border-radius: var(--radius-full); padding: 4px 4px 4px 14px; margin-left: 10px;
  transition: border-color var(--duration-fast), box-shadow var(--duration-fast);
}
.nav-search:focus-within { border-color: var(--color-rose-400); box-shadow: 0 0 0 4px rgba(244,132,160,0.15); }
.nav-search-input {
  border: none; outline: none; background: transparent; font-family: var(--font-body); font-size: 0.9rem;
  color: var(--color-warm-900); width: 104px; min-width: 0; transition: width var(--duration-fast);
}
.nav-search-input::placeholder { color: var(--color-warm-600); }
.nav-search-input:focus { width: 148px; }
.nav-search-btn {
  flex: none; width: 32px; height: 32px; border: none; cursor: pointer; border-radius: var(--radius-full);
  background: linear-gradient(135deg,var(--color-rose-400),var(--color-rose-600)); color: #fff; font-size: 0.95rem;
  display: grid; place-items: center; transition: transform var(--duration-fast);
}
.nav-search-btn:active { transform: scale(0.92); }
:root[data-theme="dark"] .nav-search { background: var(--color-surface); border-color: #4a2f33; }

/* ════════════════════════════════════════════════════════════
   统一导航（nav.js 生成）· 规范样式收口
   1) 组件样式单点收口：各内容页 <style> 中曾各自复制一份导航组件
      样式，只引入 theme.css 的页面（pet / lottery / tools）因此缺少
      音乐控件外观 ——「同一套导航两种长相」。此处用 .nav / #siteNav
      提升选择器优先级，页面副本无法再覆盖；取值与原副本一致，
      既有页面视觉不变。
   2) 抗溢出约束：导航项增至 8 项后内容宽度逼近容器上限（实测
      1022px / 可用 1120px），flex 收缩会把中文标签压成逐字竖排。
      故为标签加 white-space:nowrap，并收紧间距留出宽度余量。
   3) 断点收口：8 项导航在视口 <1024px 时无法与 logo、搜索框、音乐
      控件并存，故桌面导航下探至 1024px，以下统一用底部 Tab Bar
      （原断点 879px，会在 880–1023px 区间产生拥挤折行）。
   ═══════════════════════════════════════════════════════════ */
.nav {
  position: sticky; top: 0; z-index: 200;
  background: rgba(255,251,248,0.82);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--color-warm-200);
  transition: background var(--duration-normal);
}
.nav.scrolled { background: rgba(255,251,248,0.95); }
.nav .nav-inner {
  max-width: var(--container-max);
  margin: 0 auto;
  height: 64px;
  padding: 0 var(--space-md);
  display: flex; align-items: center; gap: var(--space-sm);
}
.nav .nav-logo {
  font-family: var(--font-display); font-weight: 700; font-size: 1.25rem;
  color: var(--color-warm-900); display: flex; align-items: center; gap: 6px;
  white-space: nowrap; text-decoration: none;
}
.nav .nav-logo .bloom { color: var(--color-rose-400); }
.nav .nav-links { align-items: center; gap: 10px; margin-left: auto; }
.nav .nav-links a {
  position: relative; font-weight: 600; font-size: 0.95rem; color: var(--color-warm-600);
  padding: 8px 4px; transition: color var(--duration-fast); text-decoration: none;
  white-space: nowrap;              /* 关键：禁止标签内部折行 */
}
.nav .nav-links a:hover { color: var(--color-rose-400); }
.nav .nav-links a.active { color: var(--color-rose-400); }
.nav .nav-links a.active::after {
  content: ''; position: absolute; left: 50%; bottom: 0; transform: translateX(-50%);
  width: 5px; height: 5px; border-radius: var(--radius-full);
  background: var(--color-rose-400);
}
/* 退出按钮（K3） */
.nav .nav-logout {
  margin-left: 10px; color: var(--color-warm-600); font-weight: 600; font-size: 0.9rem;
  padding: 8px 14px; border-radius: var(--radius-full); border: 1px solid var(--color-rose-100);
  background: var(--color-rose-50); transition: all var(--duration-fast); white-space: nowrap;
  text-decoration: none; cursor: pointer;
}
.nav .nav-logout:hover { color: var(--color-rose-600); border-color: var(--color-rose-400); }

/* ── 音乐控件（原仅存在于各页内联副本，此处收口为单点真源）── */
.nav .nav-music {
  position: relative; display: flex; align-items: center; gap: 10px;
  background: var(--color-rose-50); border: 1px solid var(--color-rose-100);
  border-radius: var(--radius-full); padding: 6px 14px 6px 6px; margin-left: 10px;
}
.nav .music-btn {
  width: 38px; height: 38px; flex: none; border: none; cursor: pointer; border-radius: var(--radius-full);
  background: linear-gradient(135deg,var(--color-rose-400),var(--color-rose-600)); color: #fff;
  display: grid; place-items: center; box-shadow: 0 4px 12px rgba(244,132,160,0.35);
  transition: transform var(--duration-fast);
}
.nav .music-btn:active { transform: scale(0.94); }
.nav .music-disc { font-size: 1.1rem; line-height: 1; display: inline-block; }
.nav .music-disc.spin { animation: spin 3s linear infinite; }
.nav .music-meta { display: none; flex-direction: column; line-height: 1.2; }
.nav .music-title { font-weight: 700; font-size: 0.8rem; color: var(--color-warm-900); }
.nav .music-sub { font-size: 0.7rem; color: var(--color-warm-600); }
.nav .music-eq { display: none; gap: 3px; align-items: flex-end; height: 16px; }
.nav .music-eq i { width: 3px; background: var(--color-rose-400); border-radius: 2px; height: 6px; }
.nav .nav-music.playing .music-eq { display: flex; }
.nav .nav-music.playing .music-eq i { animation: eq 0.9s ease-in-out infinite; }
.nav .nav-music.playing .music-eq i:nth-child(2) { animation-delay: 0.2s; }
.nav .nav-music.playing .music-eq i:nth-child(3) { animation-delay: 0.4s; }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes eq { 0%, 100% { height: 5px; } 50% { height: 15px; } }

/* 移动端底部 Tab Bar */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 200;
  display: none;
  background: #FFFFFF;
  border-top: 1px solid var(--color-warm-200);
  padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
}
.tabbar a {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px;
  color: var(--color-warm-600); font-size: 0.68rem; font-weight: 600; padding: 4px 0;
  text-decoration: none;
}
.tabbar a svg { width: 22px; height: 22px; }
.tabbar a.active { color: var(--color-rose-400); }
.tabbar a.tab-logout { color: var(--color-warm-500); }
.tabbar a.tab-logout svg { width: 20px; height: 20px; }

/* ── 断点：≥1024 用桌面导航（含导航项）；≤1023 用底部 Tab Bar ──
   用 #siteNav / .nav 前缀提高优先级，避免被各页内联副本覆盖。 */
@media (min-width: 1024px) {
  .nav .nav-links { display: flex; }
  #siteNav .tabbar { display: none; }
}
@media (max-width: 1023px) {
  #siteNav .nav-links { display: none; }
  #siteNav .tabbar { display: flex; }
  .nav .nav-music { margin-left: auto; padding: 5px 10px 5px 5px; }
  .nav .nav-search { margin-left: 0; }
  .nav .nav-search-input { width: 92px; }
  .nav .nav-search-input:focus { width: 116px; }
  /* 固定底栏约 68px，给页面留出滚动余量（含安全区） */
  html body { padding-bottom: 96px; }
}
