/* vkt Shatter 样式：极简（设计稿 5.3）。画布铺满全屏，UI 全部浮层。
   深浅主题走 CSS 变量（canvas 是内容，不随主题变）。 */

:root {
  --bg: #10131A;
  --fg: #E8EDF4;
  --fg-dim: rgba(232, 237, 244, 0.62);
  --chip-bg: rgba(255, 255, 255, 0.08);
  --chip-fg: #DDE5EF;
  --chip-active-bg: rgba(150, 200, 255, 0.22);
  --sheet-bg: rgba(24, 28, 36, 0.96);
  --card-bg: rgba(30, 34, 44, 0.97);
  --line: rgba(255, 255, 255, 0.09);
  --accent: #9CC8FF;

  /* 「压在画布上的浮层」专用色（顶栏 / 工具坞 / 提示 / toast）。
     画布背板 6 套主题**全是深色**（见 js/themes.js）+ 统一暗角，且 canvas 不随
     CSS 深浅主题变 —— 所以这几件浮层必须永远「浅字压深底」。
     它们**刻意不参与 body.theme-light 的覆盖**：浅色主题要把 --fg 变近黑
     （抽屉 / 卡片那种不透明白底才需要），直接拿去画浮层就成了「深字压深画布」，
     左上角返回键会整个消失（2026-10-05 踩过）。 */
  --chrome-fg: #E8EDF4;
  --chrome-fg-dim: rgba(232, 237, 244, 0.62);
  --chrome-chip: rgba(10, 12, 18, 0.55);
  --chrome-btn: rgba(16, 19, 26, 0.82);
  --chrome-line: rgba(255, 255, 255, 0.09);
}

/* 浅色主题（body.theme-light，由 main.applyThemeClass 挂载；auto 按系统解析） */
body.theme-light {
  --bg: #E9EEF5;
  --fg: #1D2430;
  --fg-dim: rgba(29, 36, 48, 0.62);
  --chip-bg: rgba(20, 30, 45, 0.07);
  --chip-fg: #2A3342;
  --chip-active-bg: rgba(70, 130, 210, 0.18);
  --sheet-bg: rgba(246, 249, 253, 0.97);
  --card-bg: rgba(250, 252, 255, 0.98);
  --line: rgba(20, 30, 45, 0.12);
  --accent: #3E7CC4;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--fg);
  font: 15px/1.45 -apple-system, "PingFang SC", "Segoe UI", Roboto, sans-serif;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  overscroll-behavior: none;
}

#glassCanvas {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;          /* 手势全归画布，页面不滚 */
}

/* ---------------- 顶栏 ---------------- */

#topbar {
  position: fixed;
  top: 0; left: 0; right: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: calc(10px + env(safe-area-inset-top)) 14px 10px;
  pointer-events: none;
  background: linear-gradient(rgba(8, 10, 16, 0.55), rgba(8, 10, 16, 0));
}

.brand { font-weight: 700; letter-spacing: 0.02em; }

.mini {
  font-size: 12px;
  color: var(--chrome-fg-dim);
  max-width: 88px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.pill {
  margin-left: auto;
  font-size: 12px;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--chrome-chip);
  border: 1px solid var(--chrome-line);
  color: var(--chrome-fg);
  white-space: nowrap;
}

.icon-btn {
  pointer-events: auto;
  border: none;
  background: var(--chrome-chip);
  color: var(--chrome-fg);
  width: 34px;
  height: 34px;
  border-radius: 50%;
  font-size: 17px;
  line-height: 1;
  cursor: pointer;
}

/* ---------------- 提示与工具坞 ---------------- */

.hint {
  position: fixed;
  left: 0; right: 0;
  bottom: calc(86px + env(safe-area-inset-bottom));
  text-align: center;
  font-size: 13px;
  color: var(--chrome-fg-dim);
  pointer-events: none;
  animation: hintFade 9s ease forwards;
}

@keyframes hintFade {
  0%, 55% { opacity: 1; }
  100% { opacity: 0; }
}

/* 首敲即收起：提示不该压在正在敲的玻璃上（main 加 class）。
   animation:none 是必须的——动画会盖过普通声明，不清掉则 opacity:0 不生效。 */
.hint.gone {
  animation: none;
  opacity: 0;
}

@media (prefers-reduced-motion: reduce) {
  .hint { animation: none; }
}

#dock {
  position: fixed;
  right: 14px;
  bottom: calc(16px + env(safe-area-inset-bottom));
  display: flex;
  gap: 10px;
  align-items: center;
}

.tool-btn {
  border: 1px solid var(--chrome-line);
  background: var(--chrome-btn);
  color: var(--chrome-fg);
  padding: 10px 16px;
  border-radius: 999px;
  font-size: 14px;
  cursor: pointer;
  /* 刻意不用 backdrop-filter：画布每帧都在变，模糊层会让合成器每帧重做一次
     背景读取+模糊（低端安卓上很贵）。改用略高不透明度的底色，观感几乎一样。 */
}

.tool-btn.icon-only { width: 44px; padding: 0; text-align: center; font-size: 17px; }
.tool-btn.icon-only.muted { opacity: 0.45; }

/* ---------------- 设置抽屉 ---------------- */

.backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  z-index: 8;
}

.sheet {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 9;
  max-height: 84vh;            /* 老 iOS 不认 dvh 的兜底行 */
  max-height: 84dvh;
  overflow-y: auto;
  background: var(--sheet-bg);
  border-radius: 18px 18px 0 0;
  padding: 6px 18px calc(18px + env(safe-area-inset-bottom));
  transform: translateY(0);
  transition: transform 0.24s ease;
}

@media (prefers-reduced-motion: reduce) {
  .sheet { transition: none; }
}

.sheet-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 0;
}

.sheet-head h2 { margin: 0; font-size: 17px; }

.field { padding: 10px 0; border-top: 1px solid var(--line); }
.field-label { font-size: 13px; color: var(--fg-dim); margin-bottom: 8px; }

.switch-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.sw-label { font-size: 15px; }
.switch-row input { width: 22px; height: 22px; accent-color: var(--accent); }

.chips { display: flex; gap: 8px; flex-wrap: wrap; }

.chip {
  border: 1px solid var(--line);
  background: var(--chip-bg);
  color: var(--chip-fg);
  padding: 7px 14px;
  border-radius: 999px;
  font-size: 13px;
  cursor: pointer;
}

.chip.active {
  background: var(--chip-active-bg);
  border-color: var(--accent);
  color: #fff;
}

.lang-row { display: flex; gap: 8px; flex-wrap: wrap; }
.lang-chip { min-width: 64px; text-align: center; }

.stat-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.stat {
  background: var(--chip-bg);
  border-radius: 12px;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.stat b { font-size: 20px; }
.stat span { font-size: 12px; color: var(--fg-dim); }

.note { font-size: 12px; color: var(--fg-dim); margin: 10px 0 0; }

/* ---------------- 配额卡片 / toast ---------------- */

.modal {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.5);
  padding: 24px;
}

.modal-card {
  background: var(--card-bg);
  border-radius: 16px;
  padding: 22px;
  max-width: 340px;
  width: 100%;
  text-align: center;
}

.modal-card h3 { margin: 0 0 8px; font-size: 17px; }
.modal-card p { margin: 6px 0; font-size: 14px; color: var(--fg-dim); }
.rest-count { font-size: 22px !important; color: var(--fg) !important; font-variant-numeric: tabular-nums; }

.modal-actions {
  display: flex;
  gap: 10px;
  margin-top: 16px;
}

.btn {
  flex: 1;
  border-radius: 12px;
  padding: 11px 0;
  font-size: 14px;
  cursor: pointer;
  border: none;
}

.btn.ghost { background: var(--chip-bg); color: var(--fg); border: 1px solid var(--line); }
.btn.primary { background: var(--accent); color: #10203A; font-weight: 600; }

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(120px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  background: rgba(18, 22, 30, 0.92);
  color: var(--chrome-fg);
  font-size: 13px;
  padding: 9px 16px;
  border-radius: 999px;
  border: 1px solid var(--chrome-line);
  z-index: 11;
  pointer-events: none;
  white-space: nowrap;
}

/* ================= 统一壳 =================
 * 与 pop / tally / bloom / screen 同一套：顶栏「← 标题 [形状] [配额] ⚙ ☰」
 * + 折叠菜单 + 内容页（说明）+ 登录抽屉 + 确认弹窗（设置抽屉本作已有）。
 * 样式逐条对齐 bloom 的壳段，颜色换成本作的变量（--fg / --fg-dim /
 * --chip-bg / --line / --sheet-bg / --card-bg / --accent）。
 * 开合沿用本作既有的 .hidden class。
 */

/* 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(--chrome-fg);
  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(--chrome-fg);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ---------- 折叠菜单：底部抽屉 ---------- */
.menu-list {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 9;
  display: flex;
  flex-direction: column;
  padding: 10px 10px calc(12px + env(safe-area-inset-bottom));
  background: var(--sheet-bg);
  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(--fg);
  font-family: inherit;
  font-size: 15px;
  text-align: left;
  cursor: pointer;
}
.menu-item:active { background: var(--chip-bg); }
.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(--bg);
}
.page-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: calc(12px + env(safe-area-inset-top)) 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 + env(safe-area-inset-bottom));
}
.page-placeholder { margin: 0; font-size: 14px; color: var(--fg-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(--fg-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(--fg-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; }

/* ---------- 登录 / 个人信息抽屉 ---------- */
.sheet-body { padding: 0 18px calc(18px + env(safe-area-inset-bottom)); }

.input {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--chip-bg);
  color: var(--fg);
  font-family: inherit;
  font-size: 15px;
  -webkit-appearance: none;
  appearance: none;
}
.input::placeholder { color: var(--fg-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: #E4657A;                 /* 本作没有 --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(--fg-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(--fg-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(--chip-bg);
  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(--fg-dim); word-break: break-all; }
.user-line { margin: 6px 0; font-size: 14px; color: var(--fg-dim); }

/* 确认弹窗里的危险按钮：与 .btn.ghost 同尺寸，只把字染红 */
.btn.danger { background: var(--chip-bg); color: #E4657A; border: 1px solid var(--line); }

.hidden { display: none !important; }
