/* 三周正念情绪课 · 依据 design.md */

:root {
  --bg: #FDFBF7;
  --surface: #FFFFFF;
  --ink: #3D2C29;
  --ink-soft: #8A7A72;
  --primary: #E86FA4;
  --primary-deep: #D9538E;
  --accent: #F08C5A;
  --violet: #8B5FBF;
  --violet-soft: #EDE4F7;
  --leaf: #8BA84E;
  --sky: #7EC8E3;
  --flame: #E05A4E;
  --line: #EFE9E2;
  --grad-main: linear-gradient(135deg, #F08C5A 0%, #E86FA4 100%);
  --grad-badge: linear-gradient(160deg, #A98BE0, #E86FA4);
  --grad-slide: linear-gradient(90deg, #EDE4F7, #8B5FBF);
  --r-card: 24px;
  --r-photo: 20px;
  --shadow: 0 2px 12px rgba(61,44,41,.06);
  --week: var(--accent);
}

* { margin: 0; padding: 0; box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; overflow: hidden; }
body {
  font-family: 'PingFang SC', 'Noto Sans SC', -apple-system, sans-serif;
  background: #EFE9E2; color: var(--ink);
  -webkit-font-smoothing: antialiased;
  font-size: 15px; line-height: 1.7;
}
button { font-family: inherit; border: none; cursor: pointer; background: none; color: inherit; }
img { display: block; max-width: 100%; }
input, textarea { font-family: inherit; color: inherit; }

.stage {
  --phone-w: 406px; --phone-h: 860px;
  --fit: min(1, (100vw - 32px) / 406px, (100dvh - 110px) / 860px);
  height: 100%; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 8px;
  overflow: hidden; padding: 8px 16px;
}
.phone-fit { width: calc(var(--phone-w) * var(--fit)); height: calc(var(--phone-h) * var(--fit)); overflow: hidden; }
.phone {
  width: var(--phone-w); height: var(--phone-h);
  background: var(--ink); border-radius: 55px; padding: 8px;
  box-shadow: 0 24px 64px rgba(61,44,41,.28), inset 0 0 0 2px #5a4642;
  position: relative; transform: scale(var(--fit)); transform-origin: top left;
}
.phone-island {
  position: absolute; top: 18px; left: 50%; transform: translateX(-50%);
  width: 120px; height: 34px; background: #1a1210; border-radius: 20px; z-index: 100; pointer-events: none;
}
.phone-screen {
  width: 390px; height: 844px; background: var(--bg);
  border-radius: 47px; overflow: hidden; position: relative;
  display: flex; flex-direction: column;
}
.stage-hint { flex-shrink: 0; font-size: 12px; color: #B8AC9F; letter-spacing: .1em; }
.demo-bar { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; max-width: 920px; }
.demo-bar button {
  font-size: 12px; padding: 6px 12px; border-radius: 999px;
  background: #fff; border: 1px solid var(--line); color: var(--ink-soft);
}
.demo-bar button:hover { border-color: var(--violet); color: var(--violet); }
@media (max-width: 500px) {
  .stage { --fit: 1; padding: 0; gap: 0; }
  .phone-fit { width: 100vw; height: 100dvh; }
  .phone { width: 100vw; height: 100dvh; border-radius: 0; padding: 0; box-shadow: none; transform: none; }
  .phone-island, .stage-hint, .demo-bar { display: none; }
  .phone-screen { width: 100%; height: 100%; border-radius: 0; }
}

.screen { position: absolute; inset: 0; overflow-y: auto; -webkit-overflow-scrolling: touch; }
.screen[hidden] { display: none !important; }
.page { padding: 64px 18px 24px; animation: rise .4s ease-out; }
@keyframes rise { from { transform: translateY(16px); opacity: 0; } to { transform: none; opacity: 1; } }
.serif-title { font-family: 'Noto Serif SC', 'Songti SC', 'STSong', serif; font-weight: 700; font-size: 22px; line-height: 1.35; margin: 6px 0 10px; }
.day-serif { font-family: 'Noto Serif SC', 'Songti SC', serif; font-weight: 700; font-size: 14px; color: var(--violet); }
.lede { font-size: 15px; margin: 4px 0 14px; }
.nav-back { font-size: 28px; color: var(--ink-soft); line-height: 1; cursor: pointer; margin-bottom: 8px; }

.btn-primary {
  display: block; width: 100%; height: 46px; border-radius: 24px;
  background: var(--grad-main); color: #fff; font-size: 15px; font-weight: 500; margin-top: 14px;
  position: relative; z-index: 10; transition: transform .15s ease, box-shadow .15s ease;
}
.btn-primary:active { transform: scale(0.98); }
.btn-primary:disabled { background: var(--line); color: var(--ink-soft); cursor: not-allowed; }
.btn-ghost {
  display: block; width: 100%; min-height: 44px; border-radius: 22px; margin-top: 10px;
  background: #fff; border: 1px solid var(--line); font-size: 14px; padding: 10px;
}

.week-band { position: sticky; top: 0; height: 4px; background: var(--week); z-index: 5; }

.screen-welcome { padding: 0; }
.welcome-hero img { width: 100%; height: 250px; object-fit: cover; object-position: center 40%; border-radius: 0 0 28px 28px; }
.welcome-body { padding: 20px 22px 30px; }
.welcome-body .serif-title { font-size: 30px; }
.welcome-sub { font-size: 15px; margin: 8px 0 10px; }
.welcome-points { margin: 10px 0 8px; padding-left: 18px; color: var(--ink-soft); font-size: 14px; }
.welcome-note { font-size: 12px; color: var(--ink-soft); margin-top: 12px; text-align: center; }

.weekly-pill {
  display: flex; align-items: center; justify-content: space-between;
  background: var(--violet-soft); color: var(--violet); border-radius: 999px;
  padding: 8px 14px; font-size: 13px; margin-bottom: 10px; width: 100%; text-align: left;
}

.player-card {
  background: #fff; border-radius: var(--r-card); box-shadow: var(--shadow);
  padding: 14px 16px 12px; margin: 6px 0 10px;
}
.player-head { display: flex; flex-direction: column; gap: 6px; margin-bottom: 6px; }
.player-meta { display: flex; justify-content: space-between; align-items: baseline; }
.player-title { font-family: 'Noto Serif SC', 'Songti SC', serif; font-size: 16px; font-weight: 700; color: var(--ink); }
.player-dur { font-size: 12px; color: var(--ink-soft); }
.player-tools { display: flex; justify-content: space-between; align-items: center; width: 100%; gap: 6px; }
.tool-group { display: flex; gap: 4px; align-items: center; }
.chip-mini {
  font-size: 11px; padding: 3px 8px; border-radius: 999px; border: 1px solid var(--line); background: #fff; color: var(--ink-soft);
  transition: all .2s;
}
.chip-mini.on { border-color: var(--violet); background: var(--violet-soft); color: var(--violet); font-weight: 600; }
.ring-wrap { display: flex; justify-content: center; margin: 4px 0 8px; position: relative; }
.ring {
  width: 108px; height: 108px; border-radius: 50%;
  border: 2px solid var(--sky); background: rgba(237,228,247,.35);
  display: flex; align-items: center; justify-content: center;
  position: relative; transform: scale(1);
}
.ring::before {
  content: ''; position: absolute; inset: -12px; border-radius: 50%;
  background: radial-gradient(circle, rgba(139,95,191,.18) 0%, rgba(126,200,227,.10) 45%, transparent 70%);
  opacity: 0; pointer-events: none; transition: opacity .4s ease;
}
.ring.playing { animation: breathe 10s cubic-bezier(0.4, 0, 0.2, 1) infinite; }
.ring.playing::before { opacity: 1; animation: halo 10s cubic-bezier(0.4, 0, 0.2, 1) infinite; }
.ring.fast { animation-duration: 1.25s; }
.ring.fast::before { animation-duration: 1.25s; }
@keyframes breathe {
  0%, 100% { transform: scale(1); }
  40% { transform: scale(1.14); }
  65% { transform: scale(1.14); }
}
@keyframes halo {
  0%, 100% { transform: scale(0.92); opacity: 0.3; }
  40% { transform: scale(1.18); opacity: 0.85; }
  65% { transform: scale(1.18); opacity: 0.85; }
}
.play-btn {
  width: 52px; height: 52px; border-radius: 50%; background: var(--grad-main); color: #fff;
  font-size: 17px; display: flex; align-items: center; justify-content: center;
  box-shadow: 0 4px 12px rgba(232,111,164,.28); transition: transform .15s ease;
}
.play-btn:active { transform: scale(0.94); }
.script-box {
  height: 124px; overflow: hidden; position: relative; margin: 4px 0 8px;
  mask-image: linear-gradient(to bottom, transparent 0%, rgba(0,0,0,0.85) 18%, #000 50%, rgba(0,0,0,0.85) 82%, transparent 100%);
  -webkit-mask-image: linear-gradient(to bottom, transparent 0%, rgba(0,0,0,0.85) 18%, #000 50%, rgba(0,0,0,0.85) 82%, transparent 100%);
}
.script-track { position: absolute; left: 0; right: 0; top: 46px; transition: transform .35s cubic-bezier(0.2, 0.8, 0.3, 1); }
.script-line {
  font-family: 'Noto Serif SC', 'Songti SC', serif; font-size: 16px; line-height: 1.8;
  color: var(--ink-soft); text-align: center; min-height: 32px; padding: 2px 8px;
  cursor: pointer; transition: color .25s ease, transform .25s ease;
}
.script-line.cur { color: var(--ink); font-weight: 600; transform: scale(1.03); }
.prog { height: 4px; background: var(--violet-soft); border-radius: 99px; overflow: hidden; }
.prog > i { display: block; height: 100%; width: 0; background: var(--grad-main); border-radius: 99px; }
.action-card {
  background: #fff; border-radius: var(--r-card); box-shadow: var(--shadow);
  padding: 12px 14px 12px 16px; position: relative; margin-bottom: 8px;
}
.action-card::before { content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--accent); border-radius: 4px 0 0 4px; }
.action-card h3 { font-family: 'Noto Serif SC', 'Songti SC', serif; font-size: 15px; margin-bottom: 4px; }
.action-card p { font-size: 14px; line-height: 1.6; }
.griev-dot {
  display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--violet);
  margin-left: 6px; vertical-align: middle; cursor: pointer;
}
.subtract-line { font-size: 13px; color: var(--ink); margin-top: 4px; }
.subtract-line em { font-style: normal; font-weight: 600; color: var(--leaf); margin-right: 4px; }
.extra-line { font-size: 13px; color: var(--ink-soft); margin-top: 4px; }

.fold {
  background: #fff; border-radius: 16px; box-shadow: var(--shadow); margin-bottom: 8px; overflow: hidden;
}
.fold summary {
  list-style: none; cursor: pointer; padding: 10px 14px; font-size: 13px; color: var(--violet);
  display: flex; justify-content: space-between;
}
.fold summary::-webkit-details-marker { display: none; }
.fold-body { padding: 0 14px 12px; }
.quote-block { background: var(--violet-soft); border-radius: 14px; padding: 12px 14px; font-size: 14px; margin-bottom: 10px; }
.one-line { font-family: 'Noto Serif SC', 'Songti SC', serif; font-size: 18px; text-align: center; padding: 16px 8px; }

.ver-row { display: flex; gap: 8px; margin: 8px 0; }
.ver {
  flex: 1; text-align: center; background: #fff; border: 1.5px solid var(--violet); border-radius: 16px;
  padding: 10px 8px; font-size: 13px;
}
.ver.sel { background: var(--violet-soft); }
.nutri { display: flex; gap: 10px; align-items: center; font-size: 14px; }
.nutri img { width: 40px; height: 40px; object-fit: cover; border-radius: 12px; }
.plan-tag { font-size: 11px; color: var(--violet); background: var(--violet-soft); border-radius: 99px; padding: 2px 8px; }

.slider-row { display: flex; align-items: center; gap: 10px; margin: 14px 0; }
.slider-row label { font-family: 'Noto Serif SC', 'Songti SC', serif; font-size: 15px; width: 72px; flex-shrink: 0; }
.slider-row .n { font-family: 'Noto Serif SC', 'Songti SC', serif; font-size: 28px; font-weight: 700; width: 36px; text-align: right; color: var(--violet); }
input[type=range] {
  flex: 1; -webkit-appearance: none; height: 8px; border-radius: 99px;
  background: linear-gradient(to right, #8B5FBF 0%, #E86FA4 var(--pct, 50%), var(--violet-soft) var(--pct, 50%), var(--violet-soft) 100%);
  transition: background .1s ease;
}
input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none; width: 22px; height: 22px; border-radius: 50%;
  background: #fff; border: 2.5px solid var(--violet); box-shadow: 0 2px 8px rgba(139,95,191,.35);
  cursor: pointer; transition: transform .12s ease;
}
input[type=range]:active::-webkit-slider-thumb {
  transform: scale(1.15);
}
.opt { text-align: left; background: #fff; border: 1.5px solid var(--line); border-radius: 16px; padding: 12px 16px; font-size: 14px; }
.opt.sel { background: var(--violet-soft); border-color: var(--violet); }
.opt-list { display: flex; flex-direction: column; gap: 8px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.chips button { padding: 8px 12px; border-radius: 999px; border: 1px solid var(--line); background: #fff; font-size: 13px; }
.chips button.on { background: var(--violet-soft); border-color: var(--violet); }
textarea, .textin {
  width: 100%; border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; font-size: 14px; margin-top: 8px; background: #fff;
}

.week-card { background: #fff; border-radius: 20px; box-shadow: var(--shadow); padding: 12px; margin-bottom: 12px; }
.week-card.dim { opacity: .7; }
.week-head { display: flex; gap: 12px; align-items: center; width: 100%; text-align: left; }
.week-head img { width: 80px; height: 80px; object-fit: cover; border-radius: 16px; flex-shrink: 0; }
.week-meta { flex: 1; }
.week-meta .t { font-family: 'Noto Serif SC', 'Songti SC', serif; font-size: 18px; font-weight: 700; }
.week-bar { height: 6px; background: var(--line); border-radius: 99px; margin-top: 8px; overflow: hidden; }
.week-bar i { display: block; height: 100%; background: var(--week); width: 0; }
.day-row {
  display: flex; gap: 10px; align-items: center; width: 100%; text-align: left;
  padding: 10px 4px; border-top: 1px solid var(--line); font-size: 14px;
}
.dot { width: 8px; height: 8px; border-radius: 50%; border: 1.5px solid var(--line); flex-shrink: 0; }
.dot.done { background: var(--leaf); border-color: var(--leaf); }
.dot.miss { background: transparent; border-color: var(--ink-soft); }
.dots21 { display: flex; gap: 10px; margin: 8px 0 4px; }
.dots21 .g { display: flex; gap: 6px; }
.bean-num { font-family: 'Noto Serif SC', 'Songti SC', serif; font-size: 28px; font-weight: 700; color: var(--accent); }
.card { background: #fff; border-radius: var(--r-card); box-shadow: var(--shadow); padding: 16px; margin: 10px 0; }
.count3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; }
.count3 .c { background: #fff; border-radius: 16px; box-shadow: var(--shadow); padding: 12px 8px; text-align: center; }
.count3 .n { font-family: 'Noto Serif SC', 'Songti SC', serif; font-size: 24px; font-weight: 700; }
.count3 .l { font-size: 11px; color: var(--ink-soft); line-height: 1.4; margin-top: 4px; }
.count3 .n.zero { color: var(--ink-soft); }

.badge-circle {
  width: 100px; height: 100px; border-radius: 50%; margin: 8px auto;
  background: var(--grad-badge); display: flex; align-items: center; justify-content: center; font-size: 42px;
}
.badge-circle.pop { animation: flip .8s cubic-bezier(.2,.7,.3,1); }
@keyframes flip { from { transform: rotateY(0); } to { transform: rotateY(360deg); } }

.tabbar {
  position: absolute; left: 0; right: 0; bottom: 0; z-index: 20;
  display: flex; background: #fff; border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
.tabbar[hidden] { display: none; }
.tab { flex: 1; padding: 10px 0 12px; font-size: 12px; color: var(--ink-soft); display: flex; flex-direction: column; align-items: center; gap: 2px; }
.tab span { font-size: 18px; }
.tab.active { color: var(--violet); box-shadow: inset 0 2px 0 var(--violet); }

.fab-col { position: absolute; right: 12px; bottom: 74px; z-index: 25; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; }
.fab-col[hidden] { display: none !important; }
.fab {
  pointer-events: auto; width: 44px; height: 44px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 18px;
  box-shadow: 0 4px 14px rgba(61,44,41,.18); transition: transform .15s ease;
}
.fab:active { transform: scale(0.92); }
.fab-ai { background: var(--grad-main); color: #fff; font-size: 16px; }
.fab-rescue {
  background: #fff; border: 2px solid var(--sky); position: relative; font-size: 14px;
}
.fab-rescue::after {
  content: ''; position: absolute; inset: 8px; border-radius: 50%; border: 1.5px solid var(--sky);
  animation: micro 6s ease-in-out infinite;
}
@keyframes micro { 0%,100% { transform: scale(1); opacity: .7; } 50% { transform: scale(1.12); opacity: 1; } }

.overlay { position: absolute; inset: 0; z-index: 50; background: rgba(61,44,41,.4); display: flex; align-items: flex-end; justify-content: center; }
.overlay[hidden] { display: none; }
.sheet { background: var(--bg); border-radius: 24px 24px 0 0; width: 100%; max-height: 88%; overflow-y: auto; animation: rise .3s ease-out; }
.sheet-band { width: 100%; height: 96px; object-fit: cover; filter: blur(0px); }
.sheet-body { padding: 16px 20px 28px; }
.scene-grid { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; margin: 12px 0; }
.scene {
  background: #fff; border: 1px solid var(--line); border-radius: 16px; padding: 12px 8px; text-align: center; font-size: 13px;
}
.scene.locked { border-color: var(--line); }
.scene h4 { font-size: 13px; margin-bottom: 4px; }
.scene p { font-size: 11px; color: var(--ink-soft); }

.flag-modal { background: var(--ink); color: #fff; border-radius: 24px; margin: 0 20px 80px; padding: 22px 20px 20px; border-top: 4px solid var(--flame); }
.flag-modal p { white-space: pre-line; font-size: 15px; line-height: 1.8; }

.toast {
  position: absolute; left: 20px; right: 20px; bottom: 90px; z-index: 80;
  background: var(--ink); color: #fff; font-size: 13px; text-align: center;
  border-radius: 16px; padding: 12px 16px; animation: rise .22s ease-out;
}
.toast[hidden] { display: none; }

.ai-user { background: var(--violet-soft); border-radius: 14px; padding: 10px 14px; font-size: 14px; margin: 8px 0; }
.ai-bot { background: #fff; border: 1px solid var(--violet); border-radius: 14px; padding: 12px 14px; font-size: 14px; min-height: 48px; white-space: pre-line; }

.footer-note { font-size: 12px; color: var(--ink-soft); margin: 14px 0 8px; text-align: center; }
.chart { width: 100%; height: 160px; }
.bars { display: flex; flex-direction: column; gap: 8px; margin-top: 10px; }
.bar-row { display: grid; grid-template-columns: 72px 1fr 1fr; gap: 8px; align-items: center; font-size: 12px; }
.bar { height: 8px; background: var(--line); border-radius: 99px; overflow: hidden; }
.bar i { display: block; height: 100%; }
.bar.base i { background: var(--line); width: 40%; }
.bar.now i { background: var(--grad-main); }

.ripple { position: relative; }
.ripple::after {
  content: ''; position: absolute; inset: -6px; border-radius: 28px; border: 2px solid var(--primary);
  opacity: 0; pointer-events: none;
}
.ripple.ok::after { animation: pop 0.6s ease-out; }
@keyframes pop { 0% { transform: scale(.8); opacity: 1; } 100% { transform: scale(1.4); opacity: 0; } }
