/* vkt Breath 样式：画布铺满 + 统一壳（顶栏 / 抽屉 / 菜单 / 内容页）。
   深色是主场景（睡前、暗房间），浅色只作为跟随系统的备选。 */

:root {
  --bg: #0B171B;
  --surface: #132226;
  --surface-2: #1A2C30;
  --text: #E9F2F1;
  --muted: #9DB0AF;
  --line: rgba(255, 255, 255, 0.10);
  --accent: #7BE0D1;
  --accent-ink: #05201C;
  --shadow: 0 18px 48px rgba(0, 0, 0, 0.45);
}

body.theme-light {
  --bg: #F2F0EB;
  --surface: #FFFFFF;
  --surface-2: #F6F4EF;
  --text: #1B2423;
  --muted: #6B7A78;
  --line: rgba(0, 0, 0, 0.10);
  --accent: #1F8F84;
  --accent-ink: #F2FFFC;
  --shadow: 0 18px 48px rgba(30, 40, 38, 0.16);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans", "Noto Sans", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
  -webkit-tap-highlight-color: transparent;
}

[hidden], .hidden { display: none !important; }

/* ---------- 画布 ---------- */

#breathCanvas {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
  z-index: 0;
}

#breathCanvas:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -8px;
}

.canvas-fallback {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 32px;
  text-align: center;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.7;
  z-index: 1;
}

/* ---------- 顶栏 ---------- */

#topbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: calc(env(safe-area-inset-top, 0px) + 10px) 12px 10px;
  z-index: 10;
  pointer-events: none;   /* 只有按钮可点，标题/计时区不挡住画布 */
}

#topbar > button { pointer-events: auto; }

.app-title {
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.04em;
}

.mini {
  font-size: 12px;
  color: var(--muted);
  opacity: 0.85;
  white-space: nowrap;
}

.pill {
  margin-left: auto;
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 3px 9px;
  min-width: 0;
}

.nav-btn, .icon-btn {
  appearance: none;
  border: 1px solid var(--line);
  background: rgba(19, 34, 38, 0.55);
  color: var(--text);
  width: 38px;
  height: 38px;
  border-radius: 12px;
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(10px);
}

body.theme-light .nav-btn,
body.theme-light .icon-btn { background: rgba(255, 255, 255, 0.65); }

.nav-btn:active, .icon-btn:active { transform: scale(0.96); }

/* ---------- 阶段词 ---------- */

.phase-text {
  position: fixed;
  left: 0;
  right: 0;
  top: calc(46% + 24vmin);
  margin: 0;
  text-align: center;
  font-size: 15px;
  letter-spacing: 0.18em;
  color: var(--muted);
  text-transform: none;
  transition: opacity 0.25s ease;
  z-index: 5;
  pointer-events: none;
}

.phase-text.paused { opacity: 0.75; }

/* ---------- 角落圆钮 ---------- */

#corner {
  position: fixed;
  right: 16px;
  bottom: calc(env(safe-area-inset-bottom, 0px) + 18px);
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 12;
}

.round-btn {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: rgba(19, 34, 38, 0.55);
  color: var(--text);
  font-size: 17px;
  cursor: pointer;
  backdrop-filter: blur(10px);
}

body.theme-light .round-btn { background: rgba(255, 255, 255, 0.7); }
.round-btn[aria-pressed="false"] { opacity: 0.55; }

/* ---------- 遮罩与抽屉 ---------- */

.backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.46);
  z-index: 20;
}

.sheet {
  position: fixed;
  left: 50%;
  bottom: 0;
  transform: translateX(-50%);
  width: min(560px, 100%);
  max-height: 86vh;
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--line);
  border-bottom: 0;
  border-radius: 20px 20px 0 0;
  box-shadow: var(--shadow);
  padding: 0 20px calc(env(safe-area-inset-bottom, 0px) + 20px);
  z-index: 21;
  animation: rise 0.22s ease both;
}

@keyframes rise {
  from { transform: translate(-50%, 18px); opacity: 0; }
  to { transform: translate(-50%, 0); opacity: 1; }
}

.sheet-head {
  position: sticky;
  top: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 0 10px;
  background: var(--surface);
  z-index: 1;
}

.sheet-head h2 { margin: 0; font-size: 17px; }

.field { padding: 14px 0; border-top: 1px solid var(--line); }
.field:first-child { border-top: 0; }

.field-label {
  font-size: 12px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 10px;
}

.switch-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  cursor: pointer;
}

.sw-label { font-size: 15px; }

.switch-row input[type="checkbox"] {
  width: 20px;
  height: 20px;
  accent-color: var(--accent);
  flex: 0 0 auto;
}

.note {
  margin: 8px 0 0;
  font-size: 12.5px;
  line-height: 1.6;
  color: var(--muted);
}

/* ---------- 选项芯片 ---------- */

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.lang-row { display: flex; flex-wrap: wrap; gap: 8px; }

.chip {
  appearance: none;
  font: inherit;
  font-size: 13px;
  padding: 8px 13px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}

.chip.active {
  background: var(--accent);
  border-color: transparent;
  color: var(--accent-ink);
  font-weight: 600;
}

/* ---------- 统计 ---------- */

.stat-grid { display: grid; gap: 8px; }

.stat-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
}

.stat-k { font-size: 13px; color: var(--muted); }
.stat-v { font-size: 14px; font-variant-numeric: tabular-nums; }

/* ---------- 按钮 ---------- */

.btn {
  appearance: none;
  font: inherit;
  width: 100%;
  padding: 13px 16px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--text);
  cursor: pointer;
}

.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: transparent; font-weight: 600; }
.btn.ghost { background: transparent; }

/* ---------- 菜单 ---------- */

.menu-list {
  position: fixed;
  left: 50%;
  bottom: calc(env(safe-area-inset-bottom, 0px) + 12px);
  transform: translateX(-50%);
  width: min(420px, calc(100% - 24px));
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: var(--shadow);
  padding: 8px;
  z-index: 22;
  animation: rise 0.18s ease both;
}

.menu-item {
  appearance: none;
  font: inherit;
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 13px 14px;
  border: 0;
  border-radius: 12px;
  background: transparent;
  color: var(--text);
  text-align: left;
  cursor: pointer;
}

.menu-item:active { background: var(--surface-2); }
.menu-ico { width: 22px; text-align: center; }
.menu-txt { font-size: 15px; }

/* ---------- 内容页 ---------- */

.page-view {
  position: fixed;
  inset: 0;
  background: var(--bg);
  z-index: 30;
  display: flex;
  flex-direction: column;
}

.page-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: calc(env(safe-area-inset-top, 0px) + 12px) 14px 12px;
  border-bottom: 1px solid var(--line);
}

.page-head-pad { width: 38px; }
.page-title { flex: 1; font-size: 16px; }

.page-body {
  overflow-y: auto;
  padding: 20px 20px calc(env(safe-area-inset-bottom, 0px) + 40px);
}

.doc-block { max-width: 620px; margin: 0 auto; }
.doc-p { margin: 0 0 14px; font-size: 14.5px; line-height: 1.75; color: var(--text); }
.doc-list { margin: 0 0 14px; padding-left: 20px; }
.doc-list li { margin-bottom: 10px; font-size: 14.5px; line-height: 1.7; }
.doc-note { margin: 0 0 14px; font-size: 13px; color: var(--muted); }
.doc-h { margin: 26px 0 10px; font-size: 15px; }
.doc-row { display: flex; gap: 10px; margin: 6px 0 12px; font-size: 14px; }
.doc-k { color: var(--muted); min-width: 64px; }
.doc-link { color: var(--accent); text-decoration: none; word-break: break-all; }
.page-placeholder { color: var(--muted); text-align: center; padding-top: 30vh; }

/* ---------- Toast ---------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(env(safe-area-inset-bottom, 0px) + 84px);
  transform: translateX(-50%);
  background: var(--surface);
  border: 1px solid var(--line);
  color: var(--text);
  font-size: 13px;
  padding: 10px 16px;
  border-radius: 999px;
  box-shadow: var(--shadow);
  z-index: 40;
  max-width: 86vw;
  text-align: center;
}

/* ---------- 动效降级 ---------- */

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}
