/* vkt Bloom 样式
 *
 * 三条布局约定：
 *   1) **不滚动**。body 固定在一个视口内，用 dvh 而不是 vh——iOS 的 vh 会把地址栏
 *      算进去，导致底部按钮被顶到屏幕外。
 *   2) **圆圈中心固定在 40% 高度**。CSS 的 padding-bottom: 20vh 与 Garden.layout()
 *      里的 cy = h * 0.40 是同一个约定，改一处就要改另一处。
 *   3) **颜色全部来自 JS 注入的变量**（六套色板 × 深浅由 Palette.resolve 算），
 *      CSS 只负责兜底：默认值就是「暮园」方案，首帧不会闪成别的颜色。
 *      这里不做 prefers-color-scheme 双声明——因为六套方案的背景都在中深调，
 *      不存在「浅色模式下闪一屏深色」的问题。
 */
:root {
  --bg: #2A3038;
  --bg-2: #22262D;
  --text: #F1F4F0;
  --text-dim: #C2CAC3;
  --line: rgba(241, 244, 240, 0.16);
  --surface: rgba(241, 244, 240, 0.07);
  --accent: #E9C46A;
  --accent-soft: rgba(233, 196, 106, 0.16);
  --danger: #E4657A;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  color-scheme: dark;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }

html {
  height: 100%;
  background: var(--bg);
}

body {
  position: fixed;
  inset: 0;
  overflow: hidden;
  overscroll-behavior: none;
  -webkit-user-select: none;
  user-select: none;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "PingFang SC",
    "Hiragino Sans", "Microsoft YaHei", sans-serif;
  transition: background 600ms ease, color 600ms ease;
}

button { font: inherit; color: inherit; }
button:focus-visible, input:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ---------- 花园画布 ---------- */
#garden {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  z-index: 0;
}

/* ---------- 顶栏 ---------- */
#topbar {
  position: absolute;
  top: 0; left: 0; right: 0;
  z-index: 3;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: calc(10px + var(--safe-t)) 14px 10px;
  pointer-events: none;            /* 只有里面的按钮可点，不挡住花园 */
}
#topbar > * { pointer-events: auto; }

/* 标题：左对齐贴住返回箭头，右侧留给节奏 / 设置 / 菜单三个控件 */
.app-title {
  flex: 1 1 auto;
  min-width: 0;
  margin-left: 2px;
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* 壳的图标按钮（返回 / 菜单）：无底色，不与主操作（播放、节奏）抢视线 */
.nav-btn {
  width: 38px; height: 38px;
  flex: 0 0 auto;
  border: 0;
  background: transparent;
  color: var(--text);
  border-radius: 999px;
  font-size: 19px;
  line-height: 1;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  font-family: inherit;
}
.nav-btn:active { transform: scale(0.94); }

.icon-btn {
  width: 38px; height: 38px;
  flex: 0 0 auto;
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: 12px;
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
  transition: background 200ms ease, border-color 200ms ease;
}
.icon-btn:hover { border-color: var(--accent); }
.icon-btn:active { transform: scale(0.94); }

/* ---------- 桶 ---------- */
/* 桶是 DOM，画在画布之上（z-index 1 > 画布 0）：于是叶子是"消失在桶口后面"，
   而不是凭空消失 —— 这一层关系是入桶手感的一半，动了 z-index 要重新看效果。 */
/* 桶尺寸是「玩法参数」，不是纯装饰：leaves.js 用 measureBin() 把它换算成吸力圈半径
   （桶较长边 × BIN_SUCK_R）。改这里的 width/height 等于改吸附范围，要连着看手感。 */
.bin {
  position: absolute;
  right: 14px;
  bottom: calc(92px + var(--safe-b));
  z-index: 1;
  width: 104px;
  height: 124px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  pointer-events: none;             /* 别挡住扫叶子的手势 */
  border-radius: 8px 8px 20px 20px;
  background:
    radial-gradient(120% 55% at 50% -8%, rgba(255, 255, 255, 0.16), rgba(255, 255, 255, 0) 70%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.06), rgba(0, 0, 0, 0.22));
  border: 1px solid var(--line);
  overflow: hidden;
}
/* 桶口：一圈更亮的边 + 桶内的暗，做出"张开的嘴"的读感，叶子像是被吞进去 */
.bin-lip {
  position: absolute;
  top: -1px; left: -4px; right: -4px;
  height: 12px;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.28);
}
/* 吸力光晕：桶口上一圈随填充进度点亮的光环，提示"这里的叶子会被吸走" */
.bin::before {
  content: '';
  position: absolute;
  left: 50%;
  top: -14px;
  width: 120px; height: 44px;
  transform: translateX(-50%);
  border-radius: 50%;
  background: radial-gradient(closest-side, var(--accent-soft), transparent 72%);
  opacity: calc(0.35 + var(--p, 0) * 0.5);
  pointer-events: none;
}
/* 填充高度：--p 由 main.js 每帧按"这一片扫了多少"写 0..1。
   用 transform: scaleY 而不是 height —— 前者是合成层，后者每帧触发布局。 */
.bin-fill {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  height: 100%;
  transform-origin: 50% 100%;
  transform: scaleY(var(--p, 0));
  background: linear-gradient(180deg, var(--accent-soft), var(--accent));
  opacity: 0.55;
  transition: transform 220ms ease;
}
.bin-count {
  position: relative;
  z-index: 1;
  margin-bottom: 8px;
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  color: var(--text);
  opacity: 0.85;
}
@media (prefers-reduced-motion: reduce) {
  .bin-fill { transition: none; }
}
/* ---------- 底部 ---------- */
#dock {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  z-index: 3;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 10px 16px calc(14px + var(--safe-b));
  pointer-events: none;
}
#dock > * { pointer-events: auto; }

.stat-line, .hint-line {
  margin: 0;
  font-size: 12px;
  line-height: 1.4;
  color: var(--text-dim);
  text-align: center;
  min-height: 17px;
}

.play-btn {
  width: 58px; height: 58px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: var(--surface);
  backdrop-filter: blur(6px);
  font-size: 17px;
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: transform 160ms ease, border-color 200ms ease, background 200ms ease;
}
.play-btn:hover { border-color: var(--accent); }
.play-btn:active { transform: scale(0.94); }
.play-ico { line-height: 1; transform: translateX(1px); }

/* ---------- 抽屉 ---------- */
.backdrop {
  position: absolute;
  inset: 0;
  z-index: 8;
  background: rgba(6, 8, 11, 0.5);
  backdrop-filter: blur(2px);
}
/* 开合一律用 DOM 的 hidden 属性（与 tally / screen 的壳同一约定）。
   !important 是必须的：.sheet / .modal / .backdrop 都自带 display，
   同优先级下后写的规则会赢，hidden 就失效了。 */
[hidden] { display: none !important; }

.sheet {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  z-index: 9;
  max-height: 84vh;                 /* 兜底：不认识 dvh 的老 iOS（≤15.3）会把整条声明丢掉 */
  max-height: 84dvh;
  display: flex;
  flex-direction: column;
  background: var(--bg-2);
  border-top: 1px solid var(--line);
  border-radius: 20px 20px 0 0;
  box-shadow: 0 -18px 40px rgba(0, 0, 0, 0.38);
}
.sheet-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 14px 16px 8px;
}
.sheet-head h2 { margin: 0; font-size: 16px; font-weight: 600; }
.sheet-body {
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 4px 16px calc(22px + var(--safe-b));
}

.field { padding: 12px 0; border-top: 1px solid var(--line); }
.field:first-child { border-top: 0; }
.field-label {
  font-size: 12px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--text-dim);
  margin-bottom: 8px;
}
.field-label:empty { display: none; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: 10px;
  padding: 8px 12px;
  font-size: 13px;
  cursor: pointer;
  transition: background 180ms ease, border-color 180ms ease;
}
.chip.active {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--text);
}

.free-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 10px;
}
.step-btn {
  width: 40px; height: 40px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--surface);
  font-size: 18px;
  cursor: pointer;
}
.step-btn:active { transform: scale(0.94); }
.free-value { font-variant-numeric: tabular-nums; font-size: 14px; min-width: 74px; text-align: center; }

.switch-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 2px;
  font-size: 14px;
}
.switch-row input[type="checkbox"] {
  width: 44px; height: 26px;
  accent-color: var(--accent);
  cursor: pointer;
  flex: 0 0 auto;
}
.sw-label { color: var(--text); }

.scheme-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.scheme-name { font-size: 14px; }

.lang-row { display: flex; flex-wrap: wrap; gap: 8px; }
.lang-row .chip { padding: 6px 10px; font-size: 12px; }

.stat-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 12px;
}
.stat-cell {
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: 12px;
  padding: 10px 12px;
}
.stat-cell .v {
  display: block;
  font-size: 20px;
  font-weight: 300;
  font-variant-numeric: tabular-nums;
}
.stat-cell .k {
  display: block;
  font-size: 11px;
  color: var(--text-dim);
  margin-top: 2px;
}

.btn {
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: 12px;
  padding: 11px 14px;
  font-size: 14px;
  cursor: pointer;
  transition: background 180ms ease, border-color 180ms ease;
}
.btn.ghost:hover { border-color: var(--accent); }
.btn.primary {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--text);
}
.btn.danger { border-color: var(--danger); color: var(--danger); }
.btn.danger-text { color: var(--danger); }
.note {
  margin: 8px 0 0;
  font-size: 12px;
  line-height: 1.5;
  color: var(--text-dim);
}

/* ---------- 弹窗 ---------- */
.modal {
  position: absolute;
  inset: 0;
  z-index: 10;
  display: grid;
  place-items: center;
  padding: 22px;
  background: rgba(6, 8, 11, 0.55);
}
.modal-card {
  width: 100%;
  max-width: 340px;
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 20px;
  box-shadow: 0 20px 48px rgba(0, 0, 0, 0.42);
}
.modal-card h3 { margin: 0 0 8px; font-size: 16px; font-weight: 600; }
.modal-card p { margin: 0; font-size: 13px; line-height: 1.6; color: var(--text-dim); }
.rest-count {
  margin-top: 10px !important;
  font-size: 26px !important;
  font-weight: 300;
  font-variant-numeric: tabular-nums;
  color: var(--text) !important;
}
.modal-actions {
  display: flex;
  gap: 10px;
  margin-top: 18px;
}
.modal-actions .btn { flex: 1 1 0; }

/* ---------- toast ---------- */
.toast {
  position: absolute;
  left: 50%;
  bottom: calc(96px + var(--safe-b));
  transform: translateX(-50%);
  z-index: 12;
  max-width: 84vw;
  padding: 10px 16px;
  border-radius: 999px;
  background: rgba(12, 15, 19, 0.92);
  border: 1px solid var(--line);
  color: var(--text);
  font-size: 13px;
  text-align: center;
  pointer-events: none;
}

/* ---------- 极矮 / 横屏 ---------- */
@media (max-height: 480px) {
  .app-title { display: none; }
  .bin { width: 82px; height: 96px; bottom: calc(78px + var(--safe-b)); }
  .play-btn { width: 46px; height: 46px; }
  .stat-line, .hint-line { font-size: 11px; }
}

/* ---------- 折叠菜单：底部抽屉（结构与动效对齐设置抽屉） ---------- */
.menu-list {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  z-index: 9;
  display: flex;
  flex-direction: column;
  padding: 10px 10px calc(12px + var(--safe-b));
  background: var(--bg-2);
  border-top: 1px solid var(--line);
  border-radius: 20px 20px 0 0;
  box-shadow: 0 -18px 40px rgba(0, 0, 0, 0.38);
}
.menu-item {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 14px 12px;
  border: 0;
  border-radius: 12px;
  background: transparent;
  color: var(--text);
  font-size: 15px;
  font-family: inherit;
  text-align: left;
  cursor: pointer;
}
.menu-item:active { background: var(--surface); }
.menu-ico { flex: 0 0 auto; width: 24px; font-size: 17px; text-align: center; }
.menu-txt { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; }

/* ---------- 占位页：菜单里的次级页面 ---------- */
.page-view {
  position: absolute;
  inset: 0;
  z-index: 11;
  display: flex;
  flex-direction: column;
  background: var(--bg);
}
.page-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: calc(12px + var(--safe-t)) 14px 10px;
  border-bottom: 1px solid var(--line);
}
.page-title { font-size: 16px; font-weight: 700; }
.page-body {
  flex: 1 1 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow-y: auto;
  padding: 18px 16px calc(22px + var(--safe-b));
}
.page-placeholder { margin: 0; font-size: 14px; color: var(--text-dim); text-align: center; }

/* ---------- 内容页（「说明」：下半部分是联系作者 / 隐私政策） ----------
   占位页是一句居中的话；内容页是长文，必须顶对齐 —— 长文居中会让第一行跑到
   屏幕中间、下面还藏着一半。 */
.page-view.doc .page-body {
  align-items: flex-start;
  justify-content: flex-start;
}

.doc-block { width: 100%; max-width: 520px; margin: 0 auto; }

.doc-p { font-size: 14px; line-height: 1.6; margin: 0 0 12px; }

.doc-list {
  margin: 0; padding-left: 20px;
  font-size: 14px; line-height: 1.6;
  display: grid; gap: 8px;
}
.doc-list li { list-style: disc; }

/* 分节标题：把「怎么玩」和「联系作者 / 隐私政策」分开。
   不画上边框 —— 它上面那条 .doc-note 已经有 border-top，再画一条就是双线。 */
.doc-h { font-size: 14px; font-weight: 600; margin: 24px 0 10px; }

.doc-note {
  font-size: 13px; line-height: 1.55; color: var(--text-dim);
  margin: 16px 0 0; padding-top: 12px;
  border-top: 1px solid var(--line);
}

.doc-row {
  display: flex; align-items: baseline; gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}
.doc-k { flex: 0 0 auto; font-size: 13px; color: var(--text-dim); }

.doc-link {
  flex: 1 1 auto; min-width: 0;
  font-size: 14px;
  color: var(--accent);
  text-decoration: none;
  /* 邮箱 / 长 URL 不许把行撑破 */
  overflow-wrap: anywhere;
}
.doc-link:active { opacity: .7; }

/* ---------- 登录 / 个人信息抽屉 ---------- */
.input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  color: var(--text);
  padding: 12px 14px;
  font-size: 15px;
  font-family: inherit;
  -webkit-appearance: none;
  appearance: none;
}
.input::placeholder { color: var(--text-dim); }
.input:focus { outline: none; border-color: var(--accent); }

.code-row { display: flex; gap: 8px; margin-top: 10px; }
/* 验证码那一行：输入框占满剩余宽度、按钮按内容宽度。
   反过来写会把输入框挤成一个小方块（tally 踩过）。 */
.code-row .code-input { flex: 1 1 auto; min-width: 0; }
.code-row .btn { flex: 0 0 auto; white-space: nowrap; }

/* Turnstile 用 interaction-only：平时完全隐形、高度 0，
   只有 Cloudflare 真要用户点一下时才现形 —— 所以没内容时不留空白 */
.turnstile-box:not(:empty) { margin-top: 12px; }

.form-msg {
  min-height: 18px;
  margin: 10px 0 2px;
  font-size: 13px;
  color: var(--danger);
  word-break: break-word;
}
.form-msg.ok { color: #6FBF8B; }

/* 人机校验未就绪是「状态」，不是「用户做错了什么」——比错误红字弱一档 */
.form-hint {
  margin: 8px 0 0;
  font-size: 12px;
  line-height: 1.5;
  color: var(--text-dim);
  word-break: break-word;
}

.or-row { display: flex; align-items: center; gap: 12px; margin: 14px 0; }
.or-line { flex: 1; height: 1px; background: var(--line); }
.or-txt { font-size: 12px; color: var(--text-dim); }

/* Google 官方按钮：白底描边 + 四色 G，深浅主题都不变（品牌规范） */
.btn.google {
  width: 100%;
  background: #fff;
  color: #1f1f1f;
  border: 1px solid #dadce0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}
.g-ico { width: 18px; height: 18px; flex: 0 0 auto; }

#authLoginArea .btn { margin-top: 10px; }
#authLoginArea .code-row .btn,
#authLoginArea .btn.google { margin-top: 0; }

/* ---------- 资料顶部的头像 + 昵称 ---------- */
.profile-head { display: flex; align-items: center; gap: 12px; margin: 4px 0 14px; }
.profile-id { flex: 1; min-width: 0; }
.avatar {
  flex: 0 0 auto;
  width: 46px; height: 46px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  overflow: hidden;
  background: var(--surface);
  font-size: 20px; font-weight: 700;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }
.user-nick { margin: 0; font-size: 16px; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-email { margin: 2px 0 0; font-size: 13px; color: var(--text-dim); word-break: break-all; }
.user-line { margin: 6px 0; font-size: 14px; color: var(--text-dim); }
#authUserArea .btn { width: 100%; margin-top: 14px; }

/* ---------- 减弱动效 ---------- */
@media (prefers-reduced-motion: reduce) {
  body { transition: none; }
  .play-btn, .btn, .chip, .icon-btn { transition: none !important; }
  .play-btn, .btn, .chip, .icon-btn { transition: none !important; }
}
