/* vkt Ripple 样式
 *
 * 布局约定：
 *   1) **不滚动**。body 固定视口，画布铺满，touch-action: none 防浏览器手势抢事件。
 *   2) **画布是唯一主视觉**。画布外（页框/角落小钮/提示）用深水色，UI 全部半透明压在画布上。
 *   3) 池底颜色不进 CSS——水盆颜色全在 JS 的程序化池底里（js/pool.js），这里只管 chrome。
 *   4) **压画布的浮层（顶栏/角落小钮/提示/toast）永远浅字压深底**，不跟 body.theme-light 走：
 *      池底六套恒为中低明度（见 js/pool.js），浅色主题的 --text 近黑只服务面板，
 *      直接拿去画浮层就是「深字压深水」，整片糊掉（sand 踩过，照抄 flow 的钉法）。
 */
:root {
  --page: #0F1D26;
  --page-2: #0B1620;
  --text: #EAF2F6;
  --text-dim: #A8BCC6;
  --line: rgba(234, 242, 246, 0.16);
  --surface: rgba(234, 242, 246, 0.07);
  --accent: #79C2D9;
  --accent-soft: rgba(121, 194, 217, 0.16);
  --danger: #E4657A;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  color-scheme: dark;
}

body.theme-light {
  --page: #E7EDF0;
  --page-2: #DCE4E8;
  --text: #1E262C;
  --text-dim: #55636B;
  --line: rgba(30, 38, 44, 0.2);
  --surface: rgba(30, 38, 44, 0.06);
  color-scheme: light;
}

/* 压在画布上的浮层（顶栏 / 角落小钮 / 提示 / toast）把变量钉回深色套 —— 它们
   **刻意不参与** body.theme-light：池底六套恒为中低明度（js/pool.js），画布本身
   也不随系统深浅变，所以这几件浮层只能永远「浅字压深底」。
   钉在容器上而不是逐条改 color/border：变量按继承生效，往后往里加新控件也不会漏。 */
#topbar, #corner, #hint, .toast {
  --text: #EAF2F6;
  --text-dim: #A8BCC6;
  --line: rgba(234, 242, 246, 0.16);
  --surface: rgba(234, 242, 246, 0.07);
  --page: #0F1D26;            /* .round-btn.active 选中环的间隔圈 */
  /* 光钉变量不够：按钮没写 color，靠 button { color: inherit } 从 body 一路继承 ——
     浅色主题下这条继承链不经过任何变量，只能在这里截断。 */
  color: var(--text);
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;      /* 长按画布不弹 iOS 呼出菜单 */
}
html, body { margin: 0; padding: 0; }

html { height: 100%; background: var(--page-2); }

body {
  position: fixed;
  inset: 0;
  overflow: hidden;
  overscroll-behavior: none;
  -webkit-user-select: none;
  user-select: none;
  background: var(--page);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "PingFang SC",
    "Hiragino Sans", "Microsoft YaHei", sans-serif;
}

button { font: inherit; color: inherit; }
button:focus-visible, input:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ---------- 画布 ---------- */
#rippleCanvas {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;          /* 手指是水面，浏览器手势全让路 */
  cursor: crosshair;
}

/* 2D 上下文不可用时的降级文案：居中一句话，压在深水底色上（浅字压深底，同浮层口径） */
.canvas-fallback {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: grid;
  place-items: center;
  padding: 24px;
  pointer-events: none;
}
.canvas-fallback p {
  margin: 0;
  max-width: 320px;
  padding: 12px 18px;
  border-radius: 999px;
  background: rgba(8, 16, 22, 0.92);
  border: 1px solid var(--line);
  color: var(--text);
  font-size: 13px;
  text-align: center;
}

/* ---------- 顶栏 ---------- */
#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; }

.mini {
  font-size: 11px;
  color: var(--text-dim);
  opacity: 0.75;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 18vw;
}

.pill {
  margin-left: auto;
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: 999px;
  padding: 5px 11px;
  color: var(--text);
  white-space: nowrap;
}

.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: border-color 200ms ease;
}
.icon-btn:hover { border-color: var(--accent); }
.icon-btn:active { transform: scale(0.94); }

/* ---------- 右下角两个小钮（雨 / 音效）----------
 * 设计稿 5.3：极简，无底部工具栏。「泼一把」不做按钮——它是个动作（双指按住）。 */
#corner {
  position: absolute;
  right: 14px;
  bottom: calc(16px + var(--safe-b));
  z-index: 3;
  display: flex;
  gap: 10px;
  pointer-events: none;
}
#corner > * { pointer-events: auto; }

.round-btn {
  width: 42px; height: 42px;
  padding: 0;
  border: 1px solid var(--line);
  background: var(--surface);
  backdrop-filter: blur(6px);
  border-radius: 999px;
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  transition: border-color 200ms ease, transform 160ms ease, background 200ms ease;
}
.round-btn:hover { border-color: var(--accent); }
.round-btn:active { transform: scale(0.92); }
.round-btn.active {
  border-color: var(--accent);
  background: var(--accent-soft);
}

/* 划动时整组沉下去：transform 走合成层，不重排 */
#corner, #hint { transition: transform 320ms ease, opacity 320ms ease; }
body.drawing #corner,
body.drawing #hint {
  transform: translateY(calc(100% + 24px));
  opacity: 0;
  pointer-events: none;
}
body.drawing #corner > * { pointer-events: none; }

/* ---------- 首访提示 ---------- */
.hint {
  position: absolute;
  left: 50%;
  bottom: calc(28px + var(--safe-b));
  transform: translateX(-50%);
  z-index: 3;
  margin: 0;
  max-width: 84vw;
  padding: 9px 16px;
  border-radius: 999px;
  background: rgba(8, 16, 22, 0.72);
  border: 1px solid var(--line);
  color: var(--text);
  font-size: 13px;
  text-align: center;
  pointer-events: none;
}

/* ---------- 抽屉 ---------- */
.backdrop {
  position: absolute;
  inset: 0;
  z-index: 8;
  background: rgba(4, 10, 14, 0.5);
  backdrop-filter: blur(2px);
}
.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(--page-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;
}

.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: border-color 180ms ease;
}
.chip.active {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--text);
}

.lang-row { display: flex; flex-wrap: wrap; gap: 8px; }
.lang-row .chip { padding: 6px 10px; font-size: 12px; }

.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;
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(3, 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;
  width: 100%;
  transition: border-color 180ms ease;
}
.btn.ghost:hover { border-color: var(--accent); }
.btn.primary {
  border-color: var(--accent);
  background: var(--accent-soft);
}
.note {
  margin: 8px 0 0;
  font-size: 12px;
  line-height: 1.5;
  color: var(--text-dim);
}
/* 抽屉里的「当前水盆」——窄屏顶栏藏了那个 mini，这条得留出下边距 */
#poolNote { margin: 8px 0 14px; }

/* ---------- 弹窗 ---------- */
.modal {
  position: absolute;
  inset: 0;
  z-index: 10;
  display: grid;
  place-items: center;
  padding: 22px;
  background: rgba(4, 10, 14, 0.55);
}
.modal-card {
  width: 100%;
  max-width: 340px;
  background: var(--page-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(120px + var(--safe-b));
  transform: translateX(-50%);
  z-index: 12;
  max-width: 84vw;
  padding: 10px 16px;
  border-radius: 999px;
  background: rgba(8, 16, 22, 0.92);
  border: 1px solid var(--line);
  color: var(--text);
  font-size: 13px;
  text-align: center;
  pointer-events: none;
}

/* ---------- 统一壳：顶栏按钮 / 折叠菜单 / 内容页 / 登录 ---------- */

/* hidden 属性也必须能关掉元素：.sheet / .modal / .menu-item 都自带 display，
   同优先级下后写的规则会赢，属性隐藏会静默失效（菜单里「个人信息」那一格就靠它）。 */
[hidden] { display: none !important; }

.nav-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  width: 34px; height: 34px;
  padding: 0;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--text);
  font-family: inherit;
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  pointer-events: auto;
}
.nav-btn:active { transform: scale(0.94); }

.app-title {
  flex: 0 1 auto;
  min-width: 0;
  margin-left: 2px;
  max-width: 40vw;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* 窄屏顶栏只留必要件：← 标题 配额 ⚙ ☰。水盆名收进设置抽屉
   （renderPoolRow 会同时写顶栏那个 mini 和抽屉里的 #poolNote）——
   挤在 390px 上必然溢出，而配额那条文案又不该被截断。 */
@media (max-width: 560px) {
  #topbar .mini { display: none; }
}

/* ---------- 折叠菜单：底部抽屉 ---------- */
.menu-list {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 9;
  display: flex;
  flex-direction: column;
  padding: 10px 10px calc(12px + var(--safe-b));
  background: var(--page-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-family: inherit;
  font-size: 15px;
  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: fixed;
  inset: 0;
  z-index: 11;
  display: flex;
  flex-direction: column;
  background: var(--page);
}
.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-head-pad { flex: 0 0 auto; width: 38px; }
.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 {
  display: grid; gap: 8px;
  margin: 0; padding-left: 20px;
  font-size: 14px; line-height: 1.6;
}
.doc-list li { list-style: disc; }
.doc-h { margin: 24px 0 10px; font-size: 14px; font-weight: 600; }
.doc-note {
  margin: 16px 0 0;
  padding-top: 12px;
  border-top: 1px solid var(--line);
  font-size: 13px; line-height: 1.55;
  color: var(--text-dim);
}
.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;
  overflow-wrap: anywhere;        /* 邮箱 / 长 URL 不许把行撑破 */
}
.doc-link:active { opacity: .7; }

/* ---------- 登录 / 个人信息抽屉 ---------- */
.input {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  color: var(--text);
  font-family: inherit;
  font-size: 15px;
  -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; }
.code-row .code-input { flex: 1 1 auto; min-width: 0; }
.code-row .btn { flex: 0 0 auto; padding: 11px 14px; 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 {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  background: #fff;
  color: #1f1f1f;
  border: 1px solid #dadce0;
}
.g-ico { flex: 0 0 auto; width: 18px; height: 18px; }

#authLoginArea .btn { width: 100%; 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 {
  display: flex; align-items: center; justify-content: center;
  flex: 0 0 auto;
  width: 46px; height: 46px;
  border-radius: 50%;
  overflow: hidden;
  background: var(--surface);
  font-size: 20px; font-weight: 700;
}
.avatar img { display: block; width: 100%; height: 100%; object-fit: cover; }
.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); }

/* 确认弹窗里的危险按钮：与 .btn.ghost 同尺寸，只把字染红 */
.btn.danger { background: var(--surface); color: var(--danger); border: 1px solid var(--line); }

/* ---------- 减弱动效：只关装饰过渡，水波照常 ---------- */
@media (prefers-reduced-motion: reduce) {
  #corner, #hint, .round-btn { transition: none !important; }
}
