/* 心域-心灵引导助眠 · iOS PWA 样式（复刻安卓端紫罗兰视觉） */
:root {
  --bg-top: #f6f2ff;
  --bg-bottom: #e8dffb;
  --accent: #7c5ce0;
  --accent-light: #f1ebff;
  --text-primary: #3a3355;
  --text-secondary: #8a82a8;
  --card: #ffffff;
  --danger: #d9534f;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

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

html, body {
  margin: 0; padding: 0; height: 100%;
  background: var(--bg-top);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Heiti SC", "Microsoft YaHei", sans-serif;
  color: var(--text-primary);
  background: linear-gradient(180deg, var(--bg-top) 0%, var(--bg-bottom) 100%);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
  font-size: 16px;
  line-height: 1.5;
  overscroll-behavior-y: none;
}

#app {
  max-width: 720px;
  margin: 0 auto;
  padding: calc(20px + var(--safe-top)) 18px calc(28px + var(--safe-bottom));
}

h1 { font-size: 26px; margin: 4px 0; text-align: center; letter-spacing: .5px; }
.subtitle { text-align: center; color: var(--text-secondary); font-size: 14px; margin-bottom: 18px; }

/* ---------- 卡片 ---------- */
.card {
  background: var(--card);
  border-radius: 18px;
  padding: 18px;
  margin-bottom: 12px;
  box-shadow: 0 2px 10px rgba(124, 92, 224, .06);
}
.card.tap { cursor: pointer; transition: transform .12s ease; }
.card.tap:active { transform: scale(.985); }
.card-row { display: flex; align-items: center; }
.card-txt { flex: 1; min-width: 0; padding-left: 14px; }
.card-title { font-size: 18px; font-weight: 600; }
.card-desc { font-size: 13px; color: var(--text-secondary); margin-top: 4px; }
.card-arrow { font-size: 24px; color: var(--text-secondary); padding-left: 8px; }

.icon-box {
  width: 52px; height: 52px; flex: 0 0 52px;
  display: flex; align-items: center; justify-content: center;
  background: var(--accent-light); color: var(--accent);
  border-radius: 26px; font-size: 22px;
}
.icon-box.round { border-radius: 24px; background: var(--accent); color: #fff; width: 46px; height: 46px; flex-basis: 46px; font-size: 19px; font-weight: 600; }

.lock-tag {
  display: inline-block; font-size: 11px; color: var(--accent);
  background: var(--accent-light); border-radius: 8px;
  padding: 1px 7px; margin-left: 6px; vertical-align: 2px;
}
.free-tag { color: #2e9e6b; background: #e6f7ef; }

/* ---------- 按钮 ---------- */
.btn {
  border: none; border-radius: 36px; font-size: 15px;
  padding: 11px 18px; background: var(--accent-light); color: var(--accent);
  border: 1px solid transparent; cursor: pointer; font-family: inherit;
}
.btn.primary { background: var(--accent); color: #fff; }
.btn.ghost { background: transparent; border: 1px solid var(--accent); color: var(--accent); }
.btn.block { display: block; width: 100%; padding: 15px; font-size: 17px; font-weight: 600; }
.btn.small { font-size: 13px; padding: 6px 14px; }
.btn:disabled { opacity: .5; }
.btn-row { display: flex; gap: 10px; margin-top: 14px; }
.btn-row .btn { flex: 1; }

/* ---------- 返回栏 ---------- */
.topbar { display: flex; align-items: center; margin-bottom: 12px; gap: 10px; }
.topbar .btn { flex: 0 0 auto; }

/* ---------- chip 选择组 ---------- */
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.chip {
  border: 1px solid var(--accent); color: var(--text-primary);
  background: var(--accent-light); border-radius: 36px;
  padding: 6px 15px; font-size: 13.5px; cursor: pointer; font-family: inherit;
}
.chip.on { background: var(--accent); color: #fff; }
.chip:disabled { opacity: .45; }

.switch {
  border: none; border-radius: 36px; padding: 5px 16px;
  font-size: 13px; cursor: pointer; font-family: inherit;
  background: var(--accent); color: #fff;
}
.switch.off { background: var(--accent-light); color: var(--text-secondary); }

.group-title { font-size: 15px; font-weight: 600; margin-bottom: 2px; }

/* ---------- 滑块 ---------- */
.slider-row { display: flex; align-items: center; gap: 12px; margin-top: 12px; }
.slider-row label { flex: 0 0 62px; font-size: 14px; color: var(--text-secondary); }
.slider-row .val { flex: 0 0 46px; text-align: right; font-size: 13px; color: var(--text-secondary); }
input[type=range] {
  -webkit-appearance: none; flex: 1; height: 4px; border-radius: 2px;
  background: #ded5f7; outline: none; margin: 0;
}
input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none; width: 22px; height: 22px; border-radius: 50%;
  background: var(--accent); box-shadow: 0 1px 4px rgba(0,0,0,.2);
}

/* ---------- 播放页 ---------- */
.player { text-align: center; }
.player-theme { font-size: 15px; color: var(--text-secondary); }
.player-text {
  font-size: 22px; line-height: 1.7; font-weight: 500;
  min-height: 160px; display: flex; align-items: center; justify-content: center;
  padding: 22px 8px; transition: opacity .45s ease;
}
.player-text.fade { opacity: .25; }
.progress-wrap { height: 4px; background: #ded5f7; border-radius: 2px; overflow: hidden; margin: 4px 0 6px; }
.progress-bar { height: 100%; width: 0; background: var(--accent); transition: width .4s linear; }
.player-meta { font-size: 13px; color: var(--text-secondary); margin-bottom: 10px; }

.pad { display: flex; gap: 10px; margin: 8px 0 16px; }
.pad .btn { flex: 1; }

.breath {
  width: 96px; height: 96px; margin: 6px auto 14px;
  border-radius: 50%; background: radial-gradient(circle, #cbb8f5 0%, #7c5ce0 100%);
  transition: transform 4s ease-in-out, opacity 4s ease-in-out;
  opacity: .85;
}
.breath.in { transform: scale(1.25); opacity: 1; }
.breath.out { transform: scale(.85); opacity: .6; }

/* ---------- 弹窗 ---------- */
.mask {
  position: fixed; inset: 0; background: rgba(40, 32, 70, .5);
  display: flex; align-items: center; justify-content: center;
  padding: 22px; z-index: 50;
}
.dialog {
  background: #fff; border-radius: 20px; padding: 22px;
  width: 100%; max-width: 420px; max-height: 82vh; overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
.dialog h3 { margin: 0 0 10px; font-size: 19px; text-align: center; }
.dialog p { font-size: 14px; color: var(--text-secondary); margin: 8px 0; }
.dialog .code-box {
  background: var(--accent-light); border-radius: 12px; padding: 12px;
  text-align: center; font-family: ui-monospace, Menlo, monospace;
  font-size: 17px; letter-spacing: 1px; color: var(--accent); word-break: break-all;
}
.dialog input[type=text] {
  width: 100%; padding: 12px; border-radius: 12px; font-size: 16px;
  border: 1px solid #ddd3f5; margin-top: 10px; font-family: inherit;
  text-align: center; letter-spacing: 1px; color: var(--text-primary);
}
.dialog .tip { font-size: 12.5px; color: var(--text-secondary); margin-top: 8px; line-height: 1.6; }
.dialog .err { color: var(--danger); font-size: 13px; min-height: 18px; margin-top: 6px; text-align: center; }
.scroll-text { font-size: 14px; line-height: 1.75; color: var(--text-primary); }
.scroll-text h4 { font-size: 15px; margin: 16px 0 6px; }
.scroll-text p { margin: 6px 0; color: var(--text-primary); }

/* ---------- toast ---------- */
#toast {
  position: fixed; left: 50%; bottom: calc(40px + var(--safe-bottom));
  transform: translateX(-50%) translateY(20px);
  background: rgba(58, 51, 85, .94); color: #fff;
  padding: 10px 20px; border-radius: 24px; font-size: 14px;
  opacity: 0; pointer-events: none; transition: all .25s ease; z-index: 99;
  max-width: 82vw; text-align: center;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------- 首次加载 ---------- */
#boot {
  position: fixed; inset: 0; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 16px;
  background: linear-gradient(180deg, var(--bg-top) 0%, var(--bg-bottom) 100%);
  z-index: 80; transition: opacity .35s ease;
}
#boot.hide { opacity: 0; pointer-events: none; }
#boot .logo { width: 82px; height: 82px; border-radius: 20px; }
#boot .bt { font-size: 19px; font-weight: 600; letter-spacing: 1px; }
#boot .bs { font-size: 13px; color: var(--text-secondary); }

.badge { display: inline-block; background: #e6f7ef; color: #2e9e6b; border-radius: 8px; padding: 2px 8px; font-size: 12px; }
.list-plain { font-size: 14px; line-height: 1.9; color: var(--text-primary); }
.muted { color: var(--text-secondary); font-size: 13px; }
