/* ===========================================================================
   Christmas Wonderland · UI
   色值全部来自 assets/ref/sample_palette.py 对参考图的取样：
     胶囊底 #E6E3D6 / 选中药丸 #24453C + 字 #EDE8DA / 滑杆 #A8743C / 选中按钮 #C6D7C6
   字体：衬线标题用系统衬线（Georgia / Songti），副标题用系统手写体回退链。
   ======================================================================== */

:root {
  --card: #e6e3d6;
  --card-2: #dedacb;
  --ink: #2e3a33;
  --ink-soft: #6b6f66;
  --pill: #24453c;
  --pill-ink: #ede8da;
  --caramel: #a8743c;
  --chip-on: #c6d7c6;
  --shadow: 0 10px 30px rgba(8, 16, 30, 0.22);
  --title: "Didot", "Bodoni 72", "Playfair Display", Georgia, "Times New Roman", "Songti SC", serif;
  --hand: "Snell Roundhand", "Savoye LET", "Bradley Hand", "Segoe Script", "Baskerville", Georgia, serif;
  --ui: -apple-system, "Segoe UI", "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: #16283f;
  overflow: hidden;
  font-family: var(--ui);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
}

#app { position: fixed; inset: 0; }

#stage {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
  cursor: grab;
}
#stage:active { cursor: grabbing; }

/* ---------- 标题 ---------- */
.title {
  position: absolute;
  left: clamp(18px, 3.2vw, 56px);
  top: clamp(16px, 3.4vh, 46px);
  pointer-events: none;
  z-index: 5;
}
.title h1 {
  margin: 0;
  font-family: var(--title);
  font-weight: 400;
  font-size: clamp(30px, 4.35vw, 76px);
  line-height: 0.98;
  letter-spacing: 0.004em;
  color: #f7f4ec;
  text-shadow: 0 2px 18px rgba(10, 22, 40, 0.55);
}
.title h1 .dot { letter-spacing: 0; }
.title p {
  margin: clamp(8px, 1.4vh, 18px) 0 0;
  font-family: var(--title);
  font-style: italic;
  font-size: clamp(10px, 0.86vw, 15px);
  letter-spacing: 0.01em;
  color: #e7e2d4;
  opacity: 0.92;
  text-shadow: 0 1px 12px rgba(10, 22, 40, 0.5);
}

/* ---------- 工具条 ---------- */
.toolbar {
  position: absolute;
  right: clamp(14px, 2.6vw, 48px);
  top: clamp(14px, 3vh, 40px);
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 7px 10px;
  border-radius: 999px;
  background: rgba(255, 253, 246, 0.94);
  box-shadow: var(--shadow);
  backdrop-filter: blur(8px);
  z-index: 6;
}
.tb {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 0;
  background: transparent;
  color: #3b423d;
  height: 34px;
  padding: 0 9px;
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.18s ease, color 0.18s ease;
}
.tb svg { width: 18px; height: 18px; fill: currentColor; }
.tb--wide span { font-size: 13px; letter-spacing: 0.02em; }
.tb:hover { background: rgba(36, 69, 60, 0.09); }
.tb.is-on { background: var(--pill); color: var(--pill-ink); }

/* ---------- 提示气泡 ---------- */
.toast {
  position: absolute;
  top: clamp(60px, 10.5vh, 118px);
  left: 50%;
  transform: translate(-50%, -8px);
  padding: 9px 18px;
  border-radius: 999px;
  background: rgba(20, 42, 36, 0.92);
  color: #eef3ea;
  font-size: 14px;
  letter-spacing: 0.02em;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.35s ease, transform 0.35s ease;
  z-index: 7;
}
.toast.is-on { opacity: 1; transform: translate(-50%, 0); }

/* ---------- 底部面板 ---------- */
.panel {
  position: absolute;
  left: 50%;
  bottom: clamp(14px, 2.6vh, 30px);
  transform: translateX(-50%);
  /* 【第十九轮】参考图里底部这条面板窄得多（430 → 392），这样浮岛下沿和台座剖面
     才能露在面板左右两侧，不至于被整块干掉。 */
  width: min(392px, calc(100vw - 32px));
  padding: 12px 16px 11px;
  border-radius: 24px;
  background: var(--card);
  box-shadow: var(--shadow);
  z-index: 6;
}
.row { display: flex; align-items: center; }
.row--time { justify-content: space-between; gap: 12px; }

.seg {
  display: flex;
  align-items: center;
  gap: 2px;
  background: transparent;
}
.seg-btn {
  border: 0;
  background: transparent;
  font-family: var(--ui);
  font-size: 13.5px;
  color: var(--ink-soft);
  padding: 6px 12px;
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.2s ease, color 0.2s ease;
  white-space: nowrap;
}
.seg-btn:hover { color: var(--ink); }
.seg-btn.is-on { background: var(--pill); color: var(--pill-ink); }

.clock {
  font-variant-numeric: tabular-nums;
  font-size: 14px;
  color: var(--ink);
  letter-spacing: 0.02em;
  min-width: 46px;
  text-align: right;
}

.slider-wrap { padding: 14px 2px 12px; }
.slider-track {
  position: relative;
  height: 5px;
  border-radius: 999px;
  background: linear-gradient(90deg, #cbd2c4 0%, var(--caramel) 48%, #6d4a2a 100%);
  cursor: pointer;
}
.slider-fill {
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, rgba(36, 69, 60, 0.0), var(--caramel));
  opacity: 0.55;
  pointer-events: none;
}
.slider-knob {
  position: absolute;
  top: 50%;
  left: 100%;
  width: 17px;
  height: 17px;
  margin: -8.5px 0 0 -8.5px;
  border-radius: 50%;
  background: #fdfaf1;
  border: 3px solid var(--caramel);
  box-shadow: 0 2px 6px rgba(40, 30, 16, 0.28);
  cursor: grab;
  transition: box-shadow 0.2s ease;
}
.slider-knob:focus-visible { outline: 2px solid var(--pill); outline-offset: 3px; }

.row--tabs { gap: 8px; }
.chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  border: 0;
  border-radius: 999px;
  padding: 7px 14px;
  font-family: var(--ui);
  font-size: 13.5px;
  color: #5f6459;
  background: rgba(255, 255, 255, 0.55);
  cursor: pointer;
  transition: background 0.2s ease, color 0.2s ease, opacity 0.2s ease;
}
.chip.is-on { background: var(--chip-on); color: #24382f; }
.chip:hover:not([disabled]) { background: rgba(198, 215, 198, 0.8); }
.chip[disabled] { opacity: 0.42; cursor: not-allowed; }
.ico {
  width: 14px; height: 14px;
  display: inline-block;
  background: currentColor;
  -webkit-mask-repeat: no-repeat;
  mask-repeat: no-repeat;
  -webkit-mask-size: contain;
  mask-size: contain;
}
.ico-snow {
  -webkit-mask-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'><path d='M12 2v20M4 6l16 12M20 6L4 18' stroke='black' stroke-width='2' fill='none' stroke-linecap='round'/></svg>");
  mask-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'><path d='M12 2v20M4 6l16 12M20 6L4 18' stroke='black' stroke-width='2' fill='none' stroke-linecap='round'/></svg>");
}
.ico-spark {
  -webkit-mask-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'><path d='M12 2l2.2 6.4L21 11l-6.8 2.6L12 20l-2.2-6.4L3 11l6.8-2.6z' fill='black'/></svg>");
  mask-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'><path d='M12 2l2.2 6.4L21 11l-6.8 2.6L12 20l-2.2-6.4L3 11l6.8-2.6z' fill='black'/></svg>");
}
/* 【第六十一轮】面板补齐参考图的四个按钮：音乐（音符）、环境音（声波） */
.ico-note {
  -webkit-mask-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'><path d='M9 18V5l11-2v13' stroke='black' stroke-width='2' fill='none' stroke-linecap='round' stroke-linejoin='round'/><circle cx='6.5' cy='18' r='2.6' fill='black'/><circle cx='17.5' cy='16' r='2.6' fill='black'/></svg>");
  mask-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'><path d='M9 18V5l11-2v13' stroke='black' stroke-width='2' fill='none' stroke-linecap='round' stroke-linejoin='round'/><circle cx='6.5' cy='18' r='2.6' fill='black'/><circle cx='17.5' cy='16' r='2.6' fill='black'/></svg>");
}
.ico-wave {
  -webkit-mask-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'><path d='M3 12h2M7 8v8M11 5v14M15 8v8M19 10v4M22 12h-1' stroke='black' stroke-width='2' fill='none' stroke-linecap='round'/></svg>");
  mask-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'><path d='M3 12h2M7 8v8M11 5v14M15 8v8M19 10v4M22 12h-1' stroke='black' stroke-width='2' fill='none' stroke-linecap='round'/></svg>");
}

/* ---------- 左下提示 ---------- */
.hint {
  position: absolute;
  left: clamp(18px, 3.2vw, 56px);
  bottom: clamp(14px, 2.6vh, 30px);
  margin: 0;
  font-size: 12px;
  letter-spacing: 0.03em;
  /* 【第一百九十一轮】这行字会同时压到"深蓝夜空"和"白色雪地"两种背景上：
     浅字在白雪上消失、深字在夜空里消失，纯换颜色解决不了。
     改成浅字 + 三层叠加投影——最里面的 0 0 2px 紧贴字形，
     相当于给字描一圈深色轮廓，白底上把笔画勾出来；
     在深色夜空上这层描边几乎不可见，不破坏夜景。
     外面两层负责大范围的托底与柔和过渡。 */
  color: rgba(244, 248, 252, 0.9);
  text-shadow:
    0 0 2px rgba(8, 16, 28, 0.92),
    0 1px 6px rgba(6, 14, 26, 0.7),
    0 2px 14px rgba(6, 14, 26, 0.5);
  pointer-events: none;
  z-index: 5;
}

/* ---------- 载入 ---------- */
.loading {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 18px;
  background: radial-gradient(120% 90% at 50% 35%, #31506f 0%, #12253c 62%, #0b1728 100%);
  color: #dfe7ef;
  font-size: 14px;
  letter-spacing: 0.16em;
  z-index: 20;
  transition: opacity 0.7s ease;
}
.loading.is-off { opacity: 0; pointer-events: none; }

/* 【第一百四十三轮】启动进度条：构建那几秒里让用户看到「在动」 */
.loading__text {
  margin: 0;
  font-size: 14px;
  letter-spacing: 0.16em;
  opacity: 0.9;
  transition: opacity 0.25s ease;
}
.loading__bar {
  width: 168px;
  height: 2px;
  border-radius: 2px;
  background: rgba(223, 231, 239, 0.16);
  overflow: hidden;
}
.loading__fill {
  display: block;
  width: 0%;
  height: 100%;
  border-radius: 2px;
  background: linear-gradient(90deg, #bfd6f2 0%, #ffd8a8 100%);
  transition: width 0.32s cubic-bezier(0.22, 0.61, 0.36, 1);
  box-shadow: 0 0 8px rgba(255, 216, 168, 0.45);
}

/* ---------- 沉浸模式 ---------- */
body.is-immersive .title,
body.is-immersive .toolbar,
body.is-immersive .panel,
body.is-immersive .hint { opacity: 0; pointer-events: none; transition: opacity 0.35s ease; }

/* ---------- 窄屏 ---------- */
@media (max-width: 720px) {
  /* 【第一百九十五轮·竖屏撞版】390px 宽 + 8.2vw 下 "Wonderland." 撑到约 224px,
     而右上工具条只有 5 个 30px 按钮 ≈ 200px 宽, 两者在 390px 画布上必然交叠
     (实测 _qa/pub_iPhone13.png 里句号压在了工具条圆角上)。
     唯一稳的办法是让标题和工具条各占一行 —— 标题下移让出工具条高度,
     字号不用缩, "Christmas / Wonderland." 的两行结构保持不变。 */
  .title {
    top: calc(clamp(16px, 3.4vh, 46px) + 46px);
  }
  .title h1 { font-size: clamp(26px, 8.2vw, 40px); }
  .title p { font-size: 12px; }
  .toolbar { padding: 5px 7px; gap: 0; }
  .tb { height: 30px; padding: 0 7px; }
  .tb--wide span { display: none; }
  .panel { width: calc(100vw - 24px); padding: 12px 14px 10px; border-radius: 20px; }
  .seg-btn { font-size: 12.5px; padding: 5px 9px; }
  /* 【第六十六轮】四个胶囊按钮在 390px 宽的屏幕上被挤到每个只有 ~70px，
     文字折行成"音/乐""环/境/音"两行。收紧内边距 + 禁止换行。 */
  .row--tabs { gap: 5px; }
  .chip { padding: 6px 9px; font-size: 12px; white-space: nowrap; }
  .chip .ico { width: 12px; height: 12px; }
  .hint { display: none; }
  .toast { font-size: 12.5px; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition-duration: 0.01ms !important; }
}