/* 云栖小院 · 样式表 */
:root {
  --font-serif: "Songti SC", "STSong", "Noto Serif SC", "Source Han Serif SC", serif;
  --font-sans: "PingFang SC", "Microsoft YaHei", "Noto Sans SC", system-ui, sans-serif;
  --r-lg: 22px;
  --r-md: 14px;
}

body[data-theme="dawn"] {
  --bg: #efe9dc;
  --bg-2: #e5ddcc;
  --panel: rgba(255, 252, 245, 0.86);
  --panel-solid: #fffcf5;
  --ink: #2f332e;
  --muted: #71776d;
  --line: rgba(70, 78, 64, 0.16);
  --accent: #9b4b3a;
  --accent-deep: #7d3a2d;
  --accent-soft: #f2e0d5;
  --gold: #a8864a;
  --sky-top: #c9d8d4;
  --sky-bottom: #f4ead6;
  --orb: #f5ddb0;
  --mount-far: #a9b9a9;
  --mount-near: #80937f;
  --ground: #d9d0ba;
  --path: #ccc2a9;
  --path-line: #9f9278;
  --wall-top: #f4ecd9;
  --wall-bottom: #ded1b5;
  --pillar: #8c4b3a;
  --pillar-cap: #704034;
  --roof-top: #4f5f58;
  --roof-bottom: #35433e;
  --roof-edge: #c6a468;
  --stone: #b9ad93;
  --stone-dark: #9f937b;
  --statue: #b9975e;
  --statue-light: #d9bf8c;
  --statue-line: #8d7349;
  --leaf-1: #6e855e;
  --leaf-2: #90a57b;
  --hud: rgba(255, 253, 247, 0.66);
  --shadow: 0 18px 46px rgba(64, 58, 42, 0.12);
}

body[data-theme="dusk"] {
  --bg: #e6d9c5;
  --bg-2: #d9c8ae;
  --panel: rgba(255, 249, 238, 0.88);
  --panel-solid: #fff8ed;
  --ink: #38302a;
  --muted: #79695c;
  --line: rgba(90, 66, 48, 0.17);
  --accent: #a34f35;
  --accent-deep: #833c27;
  --accent-soft: #f3dcc7;
  --gold: #a47c3f;
  --sky-top: #d8b79c;
  --sky-bottom: #f4dcba;
  --orb: #f2b873;
  --mount-far: #a8927f;
  --mount-near: #8b7565;
  --ground: #cdb99d;
  --path: #c0aa8d;
  --path-line: #8f7b63;
  --wall-top: #f0dfc5;
  --wall-bottom: #d6c0a0;
  --pillar: #824636;
  --pillar-cap: #65392e;
  --roof-top: #4b5049;
  --roof-bottom: #323833;
  --roof-edge: #d0a45e;
  --stone: #ad9b81;
  --stone-dark: #93836b;
  --statue: #b58a50;
  --statue-light: #d9b67d;
  --statue-line: #886940;
  --leaf-1: #7d7e51;
  --leaf-2: #a39362;
  --hud: rgba(255, 247, 235, 0.68);
  --shadow: 0 18px 46px rgba(88, 62, 38, 0.16);
}

body[data-theme="night"] {
  --bg: #151c1d;
  --bg-2: #101718;
  --panel: rgba(30, 39, 40, 0.88);
  --panel-solid: #202a2b;
  --ink: #e6e9e0;
  --muted: #a3aea5;
  --line: rgba(220, 232, 216, 0.14);
  --accent: #cd8a68;
  --accent-deep: #e0a07c;
  --accent-soft: rgba(205, 138, 104, 0.16);
  --gold: #c6a56a;
  --sky-top: #162629;
  --sky-bottom: #2d3d3b;
  --orb: #d6dfc6;
  --mount-far: #2d3f3f;
  --mount-near: #223230;
  --ground: #3a3b33;
  --path: #45443a;
  --path-line: #615e4d;
  --wall-top: #3c3d34;
  --wall-bottom: #2e302a;
  --pillar: #5d3b34;
  --pillar-cap: #472c28;
  --roof-top: #2e3b39;
  --roof-bottom: #1d2726;
  --roof-edge: #b9985e;
  --stone: #4b493f;
  --stone-dark: #3a382f;
  --statue: #8f7850;
  --statue-light: #b8a272;
  --statue-line: #6d5a3b;
  --leaf-1: #405748;
  --leaf-2: #55705a;
  --hud: rgba(22, 32, 33, 0.68);
  --shadow: 0 18px 46px rgba(0, 0, 0, 0.35);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; padding: 0; }
html { min-height: 100%; background: #efe9dc; }
body {
  min-height: 100vh;
  background: radial-gradient(1200px 700px at 50% -10%, var(--bg) 0%, var(--bg-2) 100%);
  color: var(--ink);
  font-family: var(--font-sans);
  -webkit-font-smoothing: antialiased;
  display: flex;
  flex-direction: column;
  transition: background 0.6s ease, color 0.4s ease;
}
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
.svg-sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
svg use { fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }

/* 顶栏 */
.topbar {
  height: 78px;
  flex: 0 0 78px;
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 0 28px;
  max-width: 1640px;
  width: 100%;
  margin: 0 auto;
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand-seal {
  width: 42px; height: 42px; display: grid; place-items: center;
  border-radius: 10px; background: var(--accent); color: #fff8ec;
  font-family: var(--font-serif); font-size: 23px; line-height: 1;
  box-shadow: 0 6px 16px rgba(155, 75, 58, 0.25);
}
.brand-text h1 { margin: 0; font-family: var(--font-serif); font-size: 21px; letter-spacing: 3px; font-weight: 600; }
.brand-text p { margin: 2px 0 0; font-size: 11px; color: var(--muted); letter-spacing: 2px; }
.visitor-pill {
  margin-left: auto; display: flex; align-items: center; gap: 8px;
  padding: 7px 14px; border: 1px solid var(--line); border-radius: 999px;
  background: var(--panel); font-size: 12px; color: var(--muted);
}
.visitor-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
.top-actions { display: flex; gap: 8px; }
.icon-btn {
  width: 38px; height: 38px; display: grid; place-items: center;
  border: 1px solid var(--line); border-radius: 11px; background: var(--panel);
  color: var(--ink); transition: transform 0.18s, background 0.18s;
}
.icon-btn:hover { transform: translateY(-2px); background: var(--accent-soft); }
.icon-btn svg { width: 19px; height: 19px; }
.icon-btn.small { width: 30px; height: 30px; border-radius: 9px; }
.icon-btn.small svg { width: 16px; height: 16px; }
.icon-btn.muted { color: var(--muted); }

/* 主布局 */
.layout {
  flex: 1; width: 100%; max-width: 1640px; margin: 0 auto;
  padding: 0 28px 8px; display: grid; grid-template-columns: minmax(0, 1fr) 388px; gap: 22px;
  align-items: start;
}
.stage-column { min-width: 0; }
.stage {
  position: relative; width: 100%; aspect-ratio: 12 / 7; min-height: 420px;
  border-radius: var(--r-lg); overflow: hidden; box-shadow: var(--shadow);
  border: 1px solid var(--line); background: var(--sky-bottom);
}
#scene { width: 100%; height: 100%; display: block; }
#fxCanvas { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.stage-hud { position: absolute; top: 16px; left: 16px; display: flex; gap: 8px; flex-wrap: wrap; }
.hud-chip {
  padding: 6px 12px; border-radius: 999px; background: var(--hud);
  border: 1px solid rgba(255, 255, 255, 0.3); backdrop-filter: blur(8px);
  font-size: 11px; letter-spacing: 0.5px; color: var(--ink);
}
.stage-caption {
  position: absolute; left: 50%; bottom: 16px; transform: translateX(-50%);
  padding: 7px 18px; border-radius: 999px; background: var(--hud);
  border: 1px solid rgba(255, 255, 255, 0.3); backdrop-filter: blur(8px);
  font-family: var(--font-serif); font-size: 13px; letter-spacing: 1px;
  color: var(--ink); white-space: nowrap; max-width: 92%; overflow: hidden; text-overflow: ellipsis;
}
.cloud-a { animation: drift 46s linear infinite alternate; }
.cloud-b { animation: drift 62s linear infinite alternate-reverse; }
.cloud-c { animation: drift 78s linear infinite alternate; }
@keyframes drift { from { transform: translateX(-40px); } to { transform: translateX(90px); } }
.lantern { transform-box: fill-box; transform-origin: top center; animation: sway 6s ease-in-out infinite alternate; }
#lanternRight { animation-delay: -2.7s; }
@keyframes sway { from { transform: rotate(-2.5deg); } to { transform: rotate(2.5deg); } }
.avatar { transform-box: fill-box; transform-origin: center bottom; transition: transform 0.5s ease; }
.avatar.bowing { transform: scaleY(0.62) translateY(6px); }
.bell.ringing #bellWaves { animation: waves 1.3s ease-out; }
@keyframes waves { 0% { opacity: 0.9; transform: scale(0.85); } 100% { opacity: 0; transform: scale(1.35); } }
#bellWaves { transform-box: fill-box; transform-origin: center; }

/* 念珠浮层 */
.bead-panel {
  position: absolute; right: 16px; top: 16px; bottom: 16px; width: 330px; z-index: 6;
  border-radius: 18px; padding: 16px; background: var(--panel); backdrop-filter: blur(18px);
  border: 1px solid var(--line); box-shadow: var(--shadow);
  display: flex; flex-direction: column; align-items: center;
  animation: rise 0.25s ease;
}
@keyframes rise { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }
.bead-head { width: 100%; display: flex; align-items: flex-start; justify-content: space-between; }
.bead-head strong { display: block; font-family: var(--font-serif); font-size: 17px; letter-spacing: 2px; }
.bead-head span { font-size: 12px; color: var(--muted); }
#mala { width: 100%; max-width: 300px; flex: 1; min-height: 0; }
#mala circle { cursor: pointer; transition: r 0.15s, fill 0.15s; }
#mala circle:hover { stroke-width: 2.5; }
.bead-tip { margin: 0; font-size: 11px; color: var(--muted); }

/* 动作栏 */
.dock { display: flex; gap: 10px; margin-top: 14px; }
.dock-btn {
  flex: 1 1 0; min-width: 0; height: 68px; border-radius: var(--r-md);
  border: 1px solid var(--line); background: var(--panel); color: var(--ink);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 5px;
  position: relative; transition: transform 0.16s, background 0.2s, box-shadow 0.2s;
}
.dock-btn:hover { transform: translateY(-3px); box-shadow: 0 10px 22px rgba(60, 50, 36, 0.1); }
.dock-btn:active { transform: translateY(0) scale(0.96); }
.dock-btn svg { width: 23px; height: 23px; }
.dock-btn span { font-size: 12px; letter-spacing: 1px; }
.dock-btn em {
  position: absolute; top: 6px; right: 8px; font-style: normal; font-size: 10px;
  min-width: 18px; padding: 1px 5px; border-radius: 999px;
  background: var(--accent-soft); color: var(--accent-deep); text-align: center;
}
.dock-btn.primary { background: var(--accent); color: #fff9ee; border-color: transparent; }
.dock-btn.primary em { background: rgba(255, 255, 255, 0.2); color: #fff9ee; }
.dock-btn.tapped { animation: tap 0.32s ease; }
@keyframes tap { 50% { transform: scale(0.93); background: var(--accent-soft); } }
.dock-hint { margin: 9px 2px 0; font-size: 11px; color: var(--muted); text-align: center; }

/* 侧栏 */
.side {
  position: sticky; top: 14px; height: calc(100vh - 108px); min-height: 560px;
  display: flex; flex-direction: column; overflow: hidden;
  border-radius: var(--r-lg); border: 1px solid var(--line);
  background: var(--panel); box-shadow: var(--shadow); backdrop-filter: blur(14px);
}
.tabs { display: flex; flex: 0 0 auto; border-bottom: 1px solid var(--line); }
.tab {
  flex: 1; padding: 15px 0 13px; border: none; background: transparent; color: var(--muted);
  font-size: 13px; letter-spacing: 2px; border-bottom: 2px solid transparent; transition: color 0.2s;
}
.tab:hover { color: var(--ink); }
.tab.active { color: var(--accent); border-bottom-color: var(--accent); font-weight: 600; }
.panel { display: none; flex: 1; overflow-y: auto; padding: 20px 20px 26px; }
.panel.active { display: block; }
.panel h2 { margin: 0 0 6px; font-family: var(--font-serif); font-size: 20px; letter-spacing: 2px; font-weight: 600; }
.panel h3 { margin: 0 0 10px; font-size: 13px; font-weight: 600; letter-spacing: 1px; color: var(--muted); }
.panel-sub { margin: 0 0 18px; font-size: 12px; line-height: 1.7; color: var(--muted); }
.panel-sub b { font-weight: 600; color: var(--accent-deep); }
.divider { height: 1px; background: var(--line); margin: 20px 0; }

.timer-presets { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.timer-presets button, .theme-choices button {
  padding: 8px 0; border-radius: 10px; border: 1px solid var(--line);
  background: transparent; color: var(--muted); font-size: 12px; transition: all 0.18s;
}
.timer-presets button.on, .theme-choices button.on {
  background: var(--accent-soft); color: var(--accent-deep); border-color: transparent; font-weight: 600;
}
.breath-ring { position: relative; width: 240px; height: 240px; margin: 18px auto 6px; }
.breath-ring svg { width: 100%; height: 100%; }
.ring-bg { fill: none; stroke: var(--line); stroke-width: 10; }
.ring-glow { fill: none; stroke: var(--accent); stroke-width: 22; opacity: 0.07; transition: r 4s ease-in-out; }
.ring-glow.expand { r: 100; }
.ring-progress {
  fill: none; stroke: var(--accent); stroke-width: 10; stroke-linecap: round;
  stroke-dasharray: 628.32; stroke-dashoffset: 628.32;
  transform: rotate(-90deg); transform-origin: 120px 120px; transition: stroke-dashoffset 0.4s linear;
}
.breath-center { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; }
.breath-center strong { font-family: var(--font-serif); font-size: 38px; font-weight: 500; letter-spacing: 1px; }
.breath-center span { font-size: 12px; color: var(--muted); letter-spacing: 3px; }
.timer-actions { display: flex; gap: 8px; justify-content: center; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 18px; border-radius: 11px; border: 1px solid var(--line);
  background: transparent; color: var(--ink); font-size: 13px; transition: all 0.18s;
}
.btn:hover { transform: translateY(-1px); }
.btn svg { width: 17px; height: 17px; }
.btn.primary { background: var(--accent); color: #fff9ee; border-color: transparent; }
.btn.ghost { padding: 10px 12px; color: var(--muted); }
.sound-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.sound-chip {
  display: flex; flex-direction: column; align-items: center; gap: 5px; padding: 12px 0;
  border: 1px solid var(--line); border-radius: 11px; background: transparent; font-size: 12px; color: var(--muted);
}
.sound-chip svg { width: 17px; height: 17px; }
.sound-chip.on { background: var(--accent-soft); color: var(--accent-deep); border-color: transparent; }
.range-row { display: flex; align-items: center; gap: 12px; margin-top: 16px; font-size: 12px; color: var(--muted); }
.range-row input { flex: 1; accent-color: var(--accent); }

/* 禅语对话 */
.chat-shell { display: flex; flex-direction: column; height: calc(100% - 128px); min-height: 380px; }
.chat-log { flex: 1; overflow-y: auto; padding-right: 4px; display: flex; flex-direction: column; gap: 10px; }
.bubble { max-width: 88%; padding: 10px 13px; border-radius: 14px; font-size: 13px; line-height: 1.75; white-space: pre-wrap; word-break: break-word; }
.bubble.bot { align-self: flex-start; background: var(--accent-soft); color: var(--ink); border-bottom-left-radius: 4px; }
.bubble.me { align-self: flex-end; background: var(--accent); color: #fff9ee; border-bottom-right-radius: 4px; }
.bubble.typing { opacity: 0.6; }
.quick-prompts { display: flex; flex-wrap: wrap; gap: 6px; margin: 12px 0 8px; }
.quick-prompts button { padding: 6px 10px; border-radius: 999px; border: 1px solid var(--line); background: transparent; font-size: 11px; color: var(--muted); }
.quick-prompts button:hover { color: var(--accent); border-color: var(--accent); }
.chat-form { display: flex; gap: 8px; }
.chat-form input { flex: 1; min-width: 0; padding: 11px 13px; border-radius: 11px; border: 1px solid var(--line); background: var(--panel-solid); font-size: 13px; outline: none; }
.chat-form input:focus { border-color: var(--accent); }
.chat-form button { width: 42px; border: none; border-radius: 11px; background: var(--accent); color: #fff9ee; display: grid; place-items: center; }
.chat-form button svg { width: 18px; height: 18px; }

/* 心愿笺 */
#wishInput { width: 100%; height: 110px; resize: none; padding: 13px; border-radius: 12px; border: 1px solid var(--line); background: var(--panel-solid); font-family: var(--font-serif); font-size: 14px; line-height: 1.7; outline: none; }
#wishInput:focus { border-color: var(--accent); }
.wish-actions { display: flex; align-items: center; justify-content: space-between; margin: 10px 0 18px; }
.wish-actions span { font-size: 11px; color: var(--muted); }
.wish-list { display: flex; flex-direction: column; gap: 10px; }
.wish-note { padding: 12px 14px; border-radius: 12px; background: var(--accent-soft); position: relative; font-family: var(--font-serif); font-size: 13px; line-height: 1.7; }
.wish-note time { display: block; margin-top: 6px; font-family: var(--font-sans); font-size: 10px; color: var(--muted); }
.wish-note button { position: absolute; right: 8px; bottom: 8px; border: none; background: transparent; color: var(--muted); padding: 2px; }
.wish-note button svg { width: 14px; height: 14px; }
.empty-hint { font-size: 12px; color: var(--muted); text-align: center; padding: 24px 0; }

/* 记录 */
.stat-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-bottom: 22px; }
.stat { padding: 14px; border-radius: 12px; border: 1px solid var(--line); background: var(--panel-solid); }
.stat strong { display: block; font-family: var(--font-serif); font-size: 26px; font-weight: 500; color: var(--accent-deep); }
.stat span { font-size: 11px; color: var(--muted); }
.week-chart { height: 130px; display: flex; align-items: flex-end; gap: 8px; padding: 10px 0 0; border-bottom: 1px solid var(--line); }
.week-bar { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px; justify-content: flex-end; height: 100%; }
.week-bar i { width: 100%; max-width: 26px; min-height: 3px; border-radius: 6px 6px 2px 2px; background: var(--accent); opacity: 0.75; display: block; }
.week-bar span { font-size: 10px; color: var(--muted); }
.record-note { font-size: 11px; line-height: 1.7; color: var(--muted); margin-top: 18px; }

/* 页脚 */
.site-footer {
  max-width: 1640px; width: 100%; margin: 0 auto; padding: 6px 28px 16px;
  display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  font-size: 11px; color: var(--muted);
}

/* 设置弹层 */
.modal { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 20px; background: rgba(24, 26, 22, 0.42); backdrop-filter: blur(4px); }
.modal-card { width: min(520px, 100%); max-height: 90vh; display: flex; flex-direction: column; border-radius: 20px; background: var(--panel-solid); box-shadow: 0 30px 80px rgba(0, 0, 0, 0.28); overflow: hidden; animation: rise 0.22s ease; }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 18px 20px; border-bottom: 1px solid var(--line); }
.modal-head h2 { margin: 0; font-family: var(--font-serif); font-size: 19px; letter-spacing: 2px; }
.modal-body { padding: 20px; overflow-y: auto; }
.modal-body h3 { margin: 0 0 10px; font-size: 13px; letter-spacing: 1px; color: var(--muted); }
.theme-choices { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 16px; }
.check-row { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--muted); }
.check-row input { accent-color: var(--accent); }
.form-note { font-size: 11px; line-height: 1.7; color: var(--muted); margin: 0 0 14px; }
.field { display: block; margin-bottom: 12px; }
.field span { display: block; font-size: 11px; color: var(--muted); margin-bottom: 5px; }
.field input { width: 100%; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--panel-solid); font-size: 12px; outline: none; }
.field input:focus { border-color: var(--accent); }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; }
.about-block p { font-size: 11px; line-height: 1.8; color: var(--muted); margin: 0; }

.toast {
  position: fixed; left: 50%; bottom: 26px; transform: translate(-50%, 14px);
  padding: 10px 18px; border-radius: 999px; background: var(--ink); color: var(--panel-solid);
  font-size: 12px; opacity: 0; pointer-events: none; transition: opacity 0.25s, transform 0.25s; z-index: 80;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

::-webkit-scrollbar { width: 7px; height: 7px; }
::-webkit-scrollbar-thumb { background: var(--line); border-radius: 99px; }
::-webkit-scrollbar-track { background: transparent; }

body.reduce-motion *, body.reduce-motion *::before, body.reduce-motion *::after {
  animation-duration: 0.001ms !important; animation-iteration-count: 1 !important; transition-duration: 0.001ms !important;
}

@media (max-width: 1120px) {
  .layout { grid-template-columns: minmax(0, 1fr); }
  .side { position: static; height: 620px; min-height: 0; min-width: 0; }
  .stage { min-height: 360px; }
}
@media (max-width: 640px) {
  .topbar { height: 64px; flex-basis: 64px; padding: 0 14px; gap: 10px; }
  .brand-seal { width: 36px; height: 36px; font-size: 20px; }
  .brand-text h1 { font-size: 17px; letter-spacing: 2px; }
  .brand-text p { font-size: 9px; letter-spacing: 1px; }
  .visitor-pill { display: none; }
  .icon-btn { width: 34px; height: 34px; }
  .layout { padding: 0 12px 8px; gap: 14px; }
  .stage { aspect-ratio: 4 / 3; min-height: 300px; border-radius: 16px; }
  .stage-caption { font-size: 11px; bottom: 10px; }
  .stage-hud { top: 10px; left: 10px; }
  .hud-chip { font-size: 10px; padding: 5px 9px; }
  .dock { gap: 4px; margin-top: 10px; }
  .dock-btn { height: 58px; border-radius: 10px; padding: 2px; flex: 1 1 0; min-width: 0; }
  .dock-btn svg { width: 19px; height: 19px; }
  .dock-btn span { font-size: 9px; letter-spacing: 0; white-space: nowrap; }
  .dock-btn em { top: 4px; right: 5px; font-size: 9px; min-width: 15px; }
  .dock-hint { font-size: 10px; }
  .side { height: 600px; border-radius: 16px; }
  .panel { padding: 18px 16px 24px; }
  .bead-panel { right: 8px; top: 8px; bottom: 8px; width: min(280px, calc(100% - 16px)); }
  .site-footer { padding: 4px 14px 14px; font-size: 10px; }
}
