/* ============================================================
   助眠电台 · 网站端样式（手机优先）
   设计取向：低亮度暖暗色、大触点、单手操作、竖屏为主，横屏/平板自动改双列
   与桌面端（frontend/css/radio.css）不共用样式表，只共用同一套视觉语汇：
   墨绿黑底 + 米白字 + 柔光
   ============================================================ */

:root {
  --bg: #0a0f0d;
  --ink: #eaf1ea;
  --ink-2: rgba(234, 241, 234, .62);
  --ink-3: rgba(234, 241, 234, .38);
  --line: rgba(150, 186, 160, .22);
  --glass: rgba(12, 18, 15, .58);
  --glass-2: rgba(16, 24, 20, .82);
  --acc: #8fd0a8;          /* 主强调：苔绿 */
  --acc-2: #d8b98a;        /* 次强调：暖沙 */
  --warn: #e08b8b;
  --r-s: 10px;
  --r-m: 16px;
  --r-l: 24px;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --tap: 46px;             /* 最小触点高度 */
}

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

html, body {
  margin: 0; height: 100%;
  background: var(--bg); color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "HarmonyOS Sans SC",
               "Microsoft YaHei", "Noto Sans CJK SC", sans-serif;
  overscroll-behavior: none;
}
body {
  display: flex; flex-direction: column;
  position: fixed; inset: 0; overflow: hidden;
  touch-action: manipulation;
}

/* ---------- 背景层 ---------- */
.bg { position: fixed; inset: 0; z-index: 0; background: var(--bg); }
.bg-layer {
  position: absolute; inset: 0;
  background-size: cover; background-position: center;
  opacity: 0; transition: none;
  filter: saturate(.85) brightness(.72);
  transform: scale(1.04);            /* 预留一点放大，避免轮播时的边缘露白 */
}
.bg-scrim {
  position: absolute; inset: 0;
  background:
    radial-gradient(120% 78% at 50% 8%, rgba(0, 0, 0, 0) 40%, rgba(6, 10, 8, .72) 100%),
    linear-gradient(180deg, rgba(6, 10, 8, .55) 0%, rgba(6, 10, 8, .18) 34%, rgba(6, 10, 8, .78) 100%);
}
.bg-canvas { position: absolute; inset: 0; width: 100%; height: 100%; opacity: .85; }

/* ---------- 顶栏 ---------- */
.topbar {
  position: relative; z-index: 3;
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(10px + var(--safe-t)) 16px 6px;
}
.brand { display: flex; align-items: center; gap: 9px; }
.brand-name { font-size: 15px; letter-spacing: 3px; color: var(--ink-2); }
.dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--ink-3); transition: background .4s, box-shadow .4s;
}
.dot.live {
  background: var(--acc);
  box-shadow: 0 0 0 4px rgba(143, 208, 168, .16), 0 0 12px rgba(143, 208, 168, .5);
  animation: breathe 4.2s ease-in-out infinite;
}
@keyframes breathe { 0%, 100% { opacity: .6; } 50% { opacity: 1; } }

.icon-btn {
  min-width: var(--tap); min-height: var(--tap);
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--glass); border: 1px solid var(--line); border-radius: 50%;
  color: var(--ink-2); cursor: pointer; padding: 0;
}
/* 顶栏右侧：定时胶囊 + 常亮 */
.top-right { display: flex; align-items: center; gap: 8px; }
.pill {
  display: inline-flex; align-items: center; gap: 6px;
  min-height: 32px; padding: 0 11px 0 9px; border-radius: 16px;
  background: rgba(216, 185, 138, .14); border: 1px solid rgba(216, 185, 138, .4);
  color: var(--acc-2); font-size: 12.5px; letter-spacing: .5px;
  font-variant-numeric: tabular-nums; cursor: pointer;
}
.pill svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; }
.pill.done { background: rgba(150, 186, 160, .12); border-color: var(--line); color: var(--ink-3); }

.icon-btn svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; }
.icon-btn[aria-pressed="true"] { color: var(--acc-2); border-color: rgba(216, 185, 138, .5); }
#sheet-close { border-radius: 12px; font-size: 16px; }

/* ---------- 主舞台 ---------- */
.stage {
  position: relative; z-index: 2; flex: 1;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: clamp(14px, 3vh, 30px);
  padding: 4px 18px 0;
  min-height: 0;
}

.bowl-wrap { position: relative; display: grid; place-items: center; }
.ring {
  position: absolute; width: min(74vw, 360px); height: min(74vw, 360px);
  pointer-events: none;
}
.bowl {
  position: relative; border: 0; background: none; padding: 0; cursor: pointer;
  width: min(58vw, 268px); height: auto;
  filter: drop-shadow(0 10px 26px rgba(0, 0, 0, .55));
  transition: transform .12s ease;
}
.bowl:active { transform: scale(.972); }
.bowl svg { width: 100%; height: auto; display: block; }
.bowl-body { fill: rgba(28, 42, 34, .78); stroke: rgba(196, 220, 200, .5); stroke-width: 1.4; }
.bowl-rim { fill: rgba(16, 26, 21, .6); stroke: rgba(206, 228, 210, .55); stroke-width: 1.4; }
.bowl-mallet { stroke: var(--acc-2); stroke-width: 3; stroke-linecap: round; fill: none; opacity: .8; }
.bowl-mallet-head { fill: var(--acc-2); opacity: .9; }
.bowl.hit .bowl-rim { stroke: rgba(240, 250, 244, .95); }
.bowl-hint {
  margin: 6px 0 0; font-size: 12px; letter-spacing: 2px; color: var(--ink-3);
  position: absolute; bottom: -26px;
}

/* 正在播放的音轨条目 */
.now-playing {
  list-style: none; margin: 0; padding: 0;
  width: 100%; max-width: 460px;
  display: flex; flex-direction: column; gap: 8px;
}
.np-item {
  display: grid; grid-template-columns: 1fr auto auto; align-items: center; gap: 10px;
  padding: 9px 13px; border-radius: var(--r-m);
  background: var(--glass); border: 1px solid var(--line);
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  animation: np-in .5s ease both;
}
@keyframes np-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.np-name { font-size: 14px; letter-spacing: 1px; }
.np-meta { font-size: 11px; color: var(--ink-3); }
.np-bars { display: flex; align-items: flex-end; gap: 2px; height: 18px; }
.np-bars i {
  width: 3px; background: linear-gradient(180deg, var(--acc), rgba(143, 208, 168, .25));
  border-radius: 2px; height: 20%; transition: height .35s ease-out;
}
.np-role {
  font-size: 10.5px; letter-spacing: 1px; padding: 1px 7px; border-radius: 9px;
  background: rgba(150, 186, 160, .14); color: var(--ink-3);
}
.np-item.is-main .np-role { background: rgba(216, 185, 138, .18); color: var(--acc-2); }
.np-item.is-main .np-name { color: var(--ink); }
.np-empty { text-align: center; font-size: 13px; color: var(--ink-3); letter-spacing: 2px; }

/* ---------- 底部操作坞 ---------- */
.dock {
  position: relative; z-index: 3;
  display: grid; grid-template-columns: 1.5fr 1fr 1fr; gap: 10px;
  padding: 10px 16px calc(14px + var(--safe-b));
}
.dock-btn {
  min-height: 54px; padding: 0 10px;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  background: var(--glass-2); color: var(--ink-2);
  border: 1px solid var(--line); border-radius: var(--r-l);
  font-size: 13px; letter-spacing: 1px; cursor: pointer;
}
.dock-btn svg { width: 20px; height: 20px; fill: currentColor; stroke: none; }
.dock-btn#btn-bgm svg, .dock-btn#btn-settings svg { fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; }
.dock-btn.primary {
  background: linear-gradient(180deg, rgba(143, 208, 168, .26), rgba(143, 208, 168, .12));
  border-color: rgba(143, 208, 168, .46); color: #f2fbf4;
}
.dock-btn.primary.playing {
  background: linear-gradient(180deg, rgba(216, 185, 138, .24), rgba(216, 185, 138, .1));
  border-color: rgba(216, 185, 138, .42);
}
.dock-btn.on { color: var(--acc); border-color: rgba(143, 208, 168, .45); }

/* ---------- 设置面板（底部抽屉） ---------- */
.sheet-mask {
  position: fixed; inset: 0; z-index: 8;
  background: rgba(4, 7, 6, .58);
  backdrop-filter: blur(2px); -webkit-backdrop-filter: blur(2px);
  opacity: 0; transition: opacity .25s;
}
.sheet-mask.show { opacity: 1; }
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 9;
  max-height: 82vh; display: flex; flex-direction: column;
  background: rgba(11, 17, 14, .96);
  border-top: 1px solid var(--line);
  border-radius: var(--r-l) var(--r-l) 0 0;
  transform: translateY(100%); transition: transform .3s cubic-bezier(.22, .8, .26, 1);
  padding-bottom: var(--safe-b);
}
.sheet.show { transform: none; }
.sheet-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 18px 8px;
}
.sheet-head h2 { margin: 0; font-size: 16px; font-weight: 500; letter-spacing: 3px; }
.tabs { display: flex; gap: 4px; padding: 0 12px; border-bottom: 1px solid var(--line); }
.tab {
  flex: 1; min-height: var(--tap); padding: 8px 4px;
  background: none; border: 0; border-bottom: 2px solid transparent;
  color: var(--ink-3); font-size: 14px; letter-spacing: 2px; cursor: pointer;
}
.tab.active { color: var(--ink); border-bottom-color: var(--acc); }
.sheet-body { overflow-y: auto; -webkit-overflow-scrolling: touch; padding: 8px 18px 22px; }
.tab-pane { display: none; flex-direction: column; gap: 4px; }
.tab-pane.active { display: flex; }

.field {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  min-height: 52px; padding: 8px 0; border-bottom: 1px solid rgba(150, 186, 160, .1);
}
.field.col { flex-direction: column; align-items: stretch; gap: 8px; }
.lbl { font-size: 14px; color: var(--ink-2); letter-spacing: 1px; }
.tip { margin: 6px 0 0; font-size: 11.5px; line-height: 1.7; color: var(--ink-3); }
.tip.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 11px; }

.slider { display: flex; align-items: center; gap: 10px; flex: 1; max-width: 240px; }
.slider b { font-size: 12px; font-weight: 400; color: var(--ink-3); width: 30px; text-align: right; }
input[type="range"] {
  -webkit-appearance: none; appearance: none; flex: 1; height: 26px; background: none;
}
input[type="range"]::-webkit-slider-runnable-track {
  height: 3px; border-radius: 2px; background: rgba(150, 186, 160, .3);
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; width: 20px; height: 20px; margin-top: -8.5px;
  border-radius: 50%; background: var(--acc); border: 0;
  box-shadow: 0 0 0 4px rgba(143, 208, 168, .14);
}
input[type="range"]::-moz-range-track { height: 3px; border-radius: 2px; background: rgba(150, 186, 160, .3); }
input[type="range"]::-moz-range-thumb { width: 20px; height: 20px; border: 0; border-radius: 50%; background: var(--acc); }

.switch { position: relative; width: 50px; height: 28px; flex: none; }
.switch input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.switch i {
  position: absolute; inset: 0; border-radius: 14px;
  background: rgba(150, 186, 160, .18); transition: background .25s; pointer-events: none;
}
.switch i::after {
  content: ""; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px;
  border-radius: 50%; background: var(--ink-2); transition: transform .25s, background .25s;
}
.switch input:checked + i { background: rgba(143, 208, 168, .38); }
.switch input:checked + i::after { transform: translateX(22px); background: var(--acc); }

.stepper { display: flex; align-items: center; gap: 8px; }
.stepper button {
  width: var(--tap); height: var(--tap); border-radius: var(--r-s);
  background: var(--glass-2); border: 1px solid var(--line); color: var(--ink); font-size: 18px;
}
.stepper span { font-size: 14px; min-width: 62px; text-align: center; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chips button {
  min-height: 38px; padding: 0 14px; border-radius: 19px;
  background: var(--glass-2); border: 1px solid var(--line);
  color: var(--ink-2); font-size: 13px; cursor: pointer;
}
.chips button.active { color: #f4fbf6; border-color: var(--acc); background: rgba(143, 208, 168, .16); }

select {
  width: 100%; min-height: var(--tap); padding: 0 12px;
  background: #101a15; color: var(--ink);
  border: 1px solid var(--line); border-radius: var(--r-s); font-size: 14px;
}

.track-list { display: flex; flex-direction: column; gap: 2px; }
.track-row {
  display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 4px 10px;
  padding: 10px 0; border-bottom: 1px solid rgba(150, 186, 160, .1);
}
.track-row .t-name { font-size: 14px; color: var(--ink-2); }
.track-row.live .t-name { color: var(--acc); }
.track-row .t-sub { font-size: 11px; color: var(--ink-3); grid-column: 1 / -1; }
.track-row .t-slider { grid-column: 1 / 2; display: flex; align-items: center; gap: 8px; }
.track-row .t-slider b { font-size: 11px; font-weight: 400; color: var(--ink-3); width: 26px; }

.btn-row { display: flex; flex-wrap: wrap; gap: 8px; padding: 10px 0; }
.ghost {
  min-height: var(--tap); padding: 0 16px; border-radius: var(--r-s);
  background: var(--glass-2); border: 1px solid var(--line); color: var(--ink-2); font-size: 13px;
}
.ghost.danger { color: var(--warn); border-color: rgba(224, 139, 139, .35); }

/* ---------- 解锁层 / 轻提示 ---------- */
.unlock {
  position: fixed; inset: 0; z-index: 20;
  display: grid; place-items: center;
  background: radial-gradient(90% 60% at 50% 45%, rgba(18, 28, 22, .92), rgba(6, 10, 8, .98));
  transition: opacity .6s ease;
}
.unlock.gone { opacity: 0; pointer-events: none; }
.unlock-inner { text-align: center; padding: 0 28px; }
.unlock-mark { font-size: 46px; color: var(--acc); opacity: .8; animation: breathe 3.4s ease-in-out infinite; }
.unlock h1 { margin: 14px 0 8px; font-size: 21px; font-weight: 500; letter-spacing: 8px; }
.unlock p { margin: 0; font-size: 13px; color: var(--ink-3); letter-spacing: 2px; }

.toast {
  position: fixed; left: 50%; bottom: calc(96px + var(--safe-b)); transform: translateX(-50%);
  z-index: 30; max-width: 84vw;
  padding: 10px 16px; border-radius: 18px;
  background: rgba(10, 16, 13, .92); border: 1px solid var(--line);
  color: var(--ink-2); font-size: 13px; line-height: 1.6;
}
.toast.err { color: var(--warn); border-color: rgba(224, 139, 139, .4); }

/* ---------- 横屏 / 平板 / 桌面 ---------- */
@media (orientation: landscape), (min-width: 780px) {
  body { flex-direction: row; flex-wrap: wrap; }
  .topbar { position: absolute; top: 0; left: 0; right: 0; }
  .stage { flex: 1 1 55%; order: 2; padding: 0 4vw; }
  .bowl { width: min(38vh, 240px); }
  .ring { width: min(48vh, 320px); height: min(48vh, 320px); }
  .now-playing { max-width: 380px; }
  .dock {
    flex: 1 1 100%; order: 3; grid-template-columns: repeat(3, 1fr);
    max-width: 420px; right: 0; bottom: 0; position: fixed;
    padding: 10px 22px calc(16px + var(--safe-b));
  }
  .sheet {
    position: fixed; top: 0; bottom: 0; left: auto; right: 0; width: min(440px, 92vw);
    max-height: none; border-radius: var(--r-l) 0 0 var(--r-l);
    border-left: 1px solid var(--line); border-top: 0;
    transform: translateX(100%);
  }
  .sheet.show { transform: none; }
}
@media (min-width: 780px) {
  .dock { max-width: none; left: 0; padding-left: max(24px, 6vw); padding-right: max(24px, 6vw); }
  .dock-btn { max-width: 320px; }
}

/* 减少动效偏好 */
@media (prefers-reduced-motion: reduce) {
  .dot.live, .unlock-mark { animation: none; }
  .np-item { animation: none; }
}
