/* 今日作业小助手 —— 暖黄色调（呼应主题「作业鸭」）
   设计基调：暖米黄渐变背景、暖黄（鸭黄色）主色、暖珊瑚色的提醒态、
   圆润卡片、细腻阴影与留白。 */

/* 倒计时用的手写字体（crveat.ttf） */
@font-face {
  font-family: 'Caveat';
  src: url('/assets/fonts/crveat.ttf?v=mvgtlf4p') format('truetype');
  font-weight: 400 700;
  font-style: normal;
  font-display: swap;
}

:root {
  /* 背景与表面 */
  --bg-1: #fdf4e0;
  --bg-2: #fffdf7;
  --surface: #fffdf7;

  /* 文字 */
  --ink: #4a3820;
  --ink-soft: #8b7856;
  --ink-faint: #b7a684;

  /* 描边与分隔 */
  --line: #f0e4c8;

  /* 主色：友好而不刺眼的靛蓝 */
  --accent: #f4b31a;
  --accent-dark: #c98a00;
  --accent-soft: #fff4d1;

  /* 录音态：暖珊瑚 */
  --live: #f0604d;
  --live-dark: #d4483a;
  --live-soft: #ffece8;

  /* 圆角与阴影 */
  --radius: 24px;
  --radius-sm: 16px;
  --radius-pill: 999px;
  --shadow-sm: 0 2px 10px rgba(122, 92, 24, 0.06);
  --shadow: 0 12px 34px rgba(122, 92, 24, 0.1);
  --shadow-accent: 0 14px 30px rgba(244, 179, 26, 0.32);
  --shadow-live: 0 14px 30px rgba(240, 96, 77, 0.34);

  /* 让浏览器自带的输入框、滚动条、键盘附属栏按浅色画（深色见 html[data-theme="dark"]） */
  color-scheme: light;

  /* 布局 */
  --dock-h: 116px;
  /* 顶部安全区：刘海机型用 env()，安卓/微信 web-view 里 env() 常为 0，
     保底 24px 以免内容钻到状态栏下面（三菜单改版后顶部没有工具条了）。 */
  --safe-top: max(env(safe-area-inset-top, 0px), 24px);
}

* {
  box-sizing: border-box;
}

/* 整页禁掉长按选择/系统菜单（iOS 的查词、安卓的搜索/复制气泡）。
   唯独打字面板输入框里允许选择，方便家长改错字。 */
*:not(input):not(textarea) {
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
}

html,
body {
  height: 100%;
  margin: 0;
  overflow: hidden;
  overscroll-behavior: none;
  -webkit-user-select: none;
  user-select: none;
  /* 关掉长按选择/调用出系统菜单（iOS 的 Look Up、安卓的搜索/分享） */
  -webkit-touch-callout: none;
  -webkit-user-drag: none;
}

body {
  background:
    radial-gradient(120% 90% at 50% -10%, #fff9ea 0%, rgba(255, 255, 255, 0) 55%),
    linear-gradient(180deg, var(--bg-1) 0%, var(--bg-2) 100%);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "HarmonyOS Sans SC",
    "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC", system-ui, sans-serif;
  -webkit-tap-highlight-color: transparent;
  -webkit-text-size-adjust: 100%;
  touch-action: manipulation;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}

/* 页面底色兜底：给根元素也涂上页面底色（用页面**底部**那个颜色，和底部菜单/页面下沿接得上）。
   安卓浏览器会拿根元素的背景色当「窗口底色」——不写的话，键盘动画/视口抖动时
   页面边缘会闪出一圈浏览器默认的纯白。 */
html {
  background: var(--bg-2);
}

#app {
  position: relative;
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
}

/* ---------- 二级页顶栏：只有「我的」里的作业管理 / 孩子管理 / 偏好设置等页面才出现 ---------- */
.subbar {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 20;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  padding: calc(var(--safe-top) + 6px) 16px 6px;
  min-height: 50px;
  /* 磨砂底与页面顶部同色（避免顶栏下沿出现一条更亮的竖向色带/断层） */
  background: rgba(253, 246, 228, 0.82);
  backdrop-filter: blur(16px) saturate(1.5);
  -webkit-backdrop-filter: blur(16px) saturate(1.5);
}

.subbar[hidden] {
  display: none;
}

.subbar .nav-back {
  justify-self: start;
}

/* 中间标题：左右两列都是 1fr，标题始终在正中 */
.subbar-title {
  font-size: 16px;
  font-weight: 800;
  color: var(--ink);
  letter-spacing: 0.02em;
  pointer-events: none;
  white-space: nowrap;
}

/* 「我的」里的头像：紧凑一些（54px），给名字和等级留出更多呼吸空间；皇冠也戴在它上面 */
.chip-avatar {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: linear-gradient(160deg, #ffd066, var(--accent));
  color: #5f4200;
  font-size: 14px;
  font-weight: 700;
  flex: 0 0 auto;
}

/* 等级勋章：图标 + 称号（随等级变化），跟在名字下面 */
.chip-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  flex: 0 0 auto;
  min-width: 0;
  position: relative;
  overflow: hidden; /* 让扫光被裁在徽章范围内 */
  border-radius: 6px;
}

/* 还没拿到勋章时（Lv.0）整块隐藏 */
.chip-badge[hidden] {
  display: none;
}

/* 每隔约 7 秒，一道斜向高光从图标+文字上扫过（纯 CSS，真机 web-view 可用） */
.chip-badge::after {
  content: '';
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  width: 70%;
  pointer-events: none;
  background: linear-gradient(
    100deg,
    rgba(255, 255, 255, 0) 0%,
    rgba(255, 255, 255, 0.35) 42%,
    rgba(255, 255, 255, 0.9) 50%,
    rgba(255, 255, 255, 0.35) 58%,
    rgba(255, 255, 255, 0) 100%
  );
  transform: translateX(-160%) skewX(-18deg);
  animation: badge-sheen 7s ease-in-out infinite;
  will-change: transform;
}

@keyframes badge-sheen {
  0% {
    transform: translateX(-160%) skewX(-18deg);
  }
  16% {
    transform: translateX(180%) skewX(-18deg);
  }
  100% {
    transform: translateX(180%) skewX(-18deg);
  }
}

@media (prefers-reduced-motion: reduce) {
  .chip-badge::after {
    animation: none;
    opacity: 0;
  }
}

.chip-badge-icon {
  width: 15px;
  height: 20px;
  object-fit: contain;
  display: block;
  flex: 0 0 auto;
}

.chip-badge-name {
  font-size: 12px;
  font-weight: 700;
  color: var(--accent-dark);
  letter-spacing: 0.02em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* 升级换勋章：旧的弹性缩小消失 → 新的弹性放大弹出（点「收下勋章」时播） */
.chip-badge.is-badge-out {
  animation: badge-shrink-out 0.3s cubic-bezier(0.55, 0, 0.85, 0.35) both;
  transform-origin: center;
  will-change: transform;
}

@keyframes badge-shrink-out {
  0% {
    transform: scale(1);
    opacity: 1;
  }
  100% {
    transform: scale(0.2);
    opacity: 0;
  }
}

.chip-badge.is-badge-in {
  animation: badge-pop-in 0.6s cubic-bezier(0.22, 1.6, 0.44, 1) both;
  transform-origin: center;
  will-change: transform;
}

@keyframes badge-pop-in {
  0% {
    transform: scale(0.2);
    opacity: 0;
  }
  60% {
    transform: scale(1.18);
    opacity: 1;
  }
  100% {
    transform: scale(1);
    opacity: 1;
  }
}

@media (prefers-reduced-motion: reduce) {
  .chip-badge.is-badge-out,
  .chip-badge.is-badge-in {
    animation: none;
  }
}

/* 头像图片：填满圆形容器并裁成圆形（首页卡和「我的」头像共用） */
.avatar-img {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
  display: block;
}

/* 带图片时隐藏容器本身的渐变底/首字，让图片铺满 */
.chip-avatar:has(.avatar-img),
.student-avatar:has(.avatar-img) {
  background: #fbeecb;
  overflow: hidden;
}

/* 会员皇冠：戴在左上角小孩头像顶上。**只有开通过会员才戴** —— 会员有效=金冠，
   会员已过期=浅灰冠；从没开通过（含免费次数用完）不戴（syncMemberCrown 挂 .member-crown）。
   头像带图时容器 overflow:hidden 会裁掉皇冠，所以戴冠时放开裁剪（圆角由 img 自己保证）。 */
.chip-avatar.has-crown {
  overflow: visible;
}

.member-crown {
  position: absolute;
  top: -8px;
  left: 50%;
  transform: translateX(-50%);
  display: inline-flex;
  font-size: 15px;
  line-height: 1;
  pointer-events: none;
  animation: crown-drop 0.3s cubic-bezier(0.22, 1.4, 0.44, 1) both;
}

.member-crown svg {
  display: block;
}

.member-crown.is-gold {
  color: #f5b020;
  filter: drop-shadow(0 1px 1px rgba(96, 64, 8, 0.55));
}

.member-crown.is-gray {
  color: #b3ab9c;
  filter: drop-shadow(0 1px 1px rgba(80, 74, 62, 0.35));
  opacity: 0.9;
}

@keyframes crown-drop {
  0% {
    transform: translateX(-50%) translateY(-7px) scale(0.45);
    opacity: 0;
  }
  100% {
    transform: translateX(-50%) translateY(0) scale(1);
    opacity: 1;
  }
}

.chip {
  appearance: none;
  border: 1px solid rgba(255, 252, 243, 0.9);
  background: rgba(255, 252, 243, 0.75);
  color: var(--ink-soft);
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.01em;
  padding: 8px 15px;
  border-radius: var(--radius-pill);
  box-shadow: var(--shadow-sm);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  cursor: pointer;
  transition: transform 0.12s ease, background 0.15s ease, color 0.15s ease;
}

.chip:active {
  transform: scale(0.96);
  background: #fffdf7;
  color: var(--ink);
}

.chip-primary {
  background: var(--accent);
  border-color: transparent;
  color: #5f4200;
  box-shadow: var(--shadow-accent);
}

.chip-primary:active {
  background: var(--accent-dark);
  color: #5f4200;
}

.chip[hidden] {
  display: none;
}

/* ---------- 中间舞台 ---------- */
.stage {
  position: relative;
  overflow: hidden;
  flex: 1;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  /* 底部原来越靠 .dock 页脚那行撑出的安全距离；按钮收进计时卡后，这里自己留出
     iPhone 底部横条的安全区，免得卡片最后一行压在 Home 指示条下面 */
  padding: 0 20px calc(env(safe-area-inset-bottom, 0px) + 4px);
  /* 面板自己只纵向滚动；底部场景缩略图条需要横向滑动，所以这里不锁横向 */
  touch-action: auto;
}

.panel {
  width: 100%;
  max-width: 760px;
  max-height: 100%;
  overflow: auto;
  text-align: center;
  animation: rise 0.26s cubic-bezier(0.22, 0.61, 0.36, 1);
  -webkit-overflow-scrolling: touch;
  /* 移动端全屏应用：隐藏滚动条（科目列表等长了也不显示） */
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.panel::-webkit-scrollbar {
  display: none;
  width: 0;
  height: 0;
}

.panel[hidden] {
  display: none;
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(12px) scale(0.99);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

/* ---------- 下拉刷新指示器：内容区顶部下拉触发（自定义手势） ---------- */
.ptr {
  position: absolute;
  left: 0;
  right: 0;
  top: calc(var(--safe-top, 24px) + 8px);
  display: flex;
  align-items: center;
  justify-content: center;
  height: 48px;
  pointer-events: none;
  z-index: 16;
  opacity: 0;
  transform: translateY(-56px);
  transition: opacity 0.18s ease;
}

/* 胶囊：磨砂底 + 细描边 + 柔光，随下拉一起探出头 */
.ptr-cap {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 16px;
  background: rgba(255, 253, 247, 0.94);
  border: 1px solid var(--line);
  border-radius: var(--radius-pill);
  box-shadow: 0 8px 22px rgba(122, 92, 24, 0.14), 0 1px 0 rgba(255, 255, 255, 0.7) inset;
  backdrop-filter: blur(12px) saturate(1.4);
  -webkit-backdrop-filter: blur(12px) saturate(1.4);
  transform: scale(0.92);
  transition: transform 0.24s cubic-bezier(0.34, 1.56, 0.64, 1), border-color 0.18s ease,
    box-shadow 0.18s ease;
}

/* 刷新图标（标准「转一圈」图标） */
.ptr-icon {
  width: 17px;
  height: 17px;
  flex: none;
  color: var(--accent-dark);
  transform: scale(0.9);
  transition: transform 0.24s cubic-bezier(0.34, 1.56, 0.64, 1), color 0.18s ease;
}

.ptr-text {
  color: var(--ink-soft);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.02em;
  white-space: nowrap;
}

/* 拉过阈值：整体亮起，图标放大一点，示意可以松手 */
.ptr.is-ready .ptr-cap {
  transform: scale(1);
  border-color: rgba(244, 179, 26, 0.55);
  box-shadow: 0 10px 26px rgba(244, 179, 26, 0.28), 0 1px 0 rgba(255, 255, 255, 0.7) inset;
}

.ptr.is-ready .ptr-text {
  color: var(--accent-dark);
}

.ptr.is-ready .ptr-icon {
  transform: scale(1.05);
}

/* 刷新中：图标旋转 */
.ptr.is-spinning .ptr-cap {
  transform: scale(1);
}

.ptr.is-spinning .ptr-icon {
  color: var(--accent);
  animation: ptr-icon-spin 0.9s linear infinite;
}

@keyframes ptr-icon-spin {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}

/* 收起：整体向上滑回（不是直接消失） */
.ptr.is-hiding {
  transition: opacity 0.26s ease, transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

@media (prefers-reduced-motion: reduce) {
  .ptr-icon {
    animation: none !important;
  }
  .ptr.is-hiding {
    transition: opacity 0.2s ease;
  }
}

/* ---------- 首页：选孩子 ---------- */
.home-title {
  font-size: clamp(24px, 6.8vw, 34px);
  font-weight: 700;
  letter-spacing: 0.005em;
  margin: 0 0 8px;
  color: var(--ink);
}

.home-sub {
  font-size: clamp(14px, 4vw, 18px);
  color: var(--ink-soft);
  margin: 0 0 26px;
}

.students {
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-width: 420px;
  margin: 0 auto;
}

.student-card {
  appearance: none;
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  text-align: left;
  padding: 16px 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  font: inherit;
  color: var(--ink);
  cursor: pointer;
  transition: transform 0.12s ease, box-shadow 0.15s ease, border-color 0.15s ease;
}

.student-card:active {
  transform: scale(0.985);
  border-color: var(--accent);
  box-shadow: var(--shadow);
}

.student-avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: linear-gradient(160deg, #ffd066, var(--accent));
  color: #5f4200;
  font-size: 22px;
  font-weight: 700;
  flex: 0 0 auto;
}

.student-nm {
  font-size: clamp(18px, 5vw, 22px);
  font-weight: 700;
  flex: 1;
}

.student-gr {
  font-size: clamp(13px, 3.6vw, 15px);
  font-weight: 600;
  color: var(--accent-dark);
  background: var(--accent-soft);
  border-radius: var(--radius-pill);
  padding: 5px 12px;
}

.student-gr:empty {
  display: none;
}

.add-student {
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-width: 420px;
  margin: 16px auto 0;
}

.add-input {
  width: 100%;
  font: inherit;
  font-size: 16px;
  padding: 13px 15px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  -webkit-user-select: text;
  user-select: text;
}

.add-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(244, 179, 26, 0.16);
}

.add-submit {
  padding: 14px;
  font-size: 16px;
}

.add-student[hidden] {
  display: none;
}

.home-link {
  border: none;
  background: none;
  color: var(--accent-dark);
  font: inherit;
  font-size: 15px;
  font-weight: 600;
  padding: 10px;
  margin-top: 6px;
  cursor: pointer;
}

.home-link[hidden] {
  display: none;
}

/* ---------- 计时卡右下角：「开始专注 / 继续专注 / 结束」按钮组 ----------
   不再固定占页面底部，而是和「喂小鱼」同一行、贴在计时卡右下角；
   随作业页一起滚动，也不再挡作业列表。 */
.dock {
  position: relative;
  flex: 0 0 auto;
  margin-left: auto;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 6px; /* 「继续专注」+ 小「结束」并排时的间距（见 updateStartButton） */
}

/* .dock 自带 display:flex 会盖掉浏览器默认的 [hidden]{display:none}，这里显式补上 */
.dock[hidden] {
  display: none;
}

/* 计时卡里的「开始专注 / 继续专注 / 结束」按钮：比原来底部大按钮收小一号，
   好和左边的「喂小鱼」并在一行里 */
.start-btn {
  appearance: none;
  padding: 8px 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  border: none;
  border-radius: 999px;
  background: linear-gradient(160deg, #f7c64a 0%, #eaa100 100%);
  color: #5f4200;
  font: inherit;
  font-size: clamp(12.5px, 3.5vw, 14px);
  font-weight: 700;
  letter-spacing: 0.04em;
  white-space: nowrap;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(224, 154, 10, 0.24);
  transition: transform 0.12s ease, background 0.15s ease;
}

.start-btn:active {
  transform: scale(0.97);
  background: #cf9000;
}

.start-btn[hidden] {
  display: none;
}

/* 专注/休息中：大按钮变「结束」——换红色，并把播放小三角收起来（见 updateStartButton 的 is-stop） */
.start-btn.is-stop {
  background: linear-gradient(160deg, #ff8a7a 0%, #e0513f 100%);
  color: #ffffff;
  box-shadow: 0 4px 12px rgba(224, 81, 63, 0.24);
}

.start-btn.is-stop:active {
  background: #c8402f;
}

.start-btn.is-stop .start-btn-icon {
  display: none;
}

/* 「等待继续」时并排的小「结束」：次要按钮（浅底），不跟大按钮抢眼 */
.start-btn-quiet {
  padding: 8px 10px;
  background: var(--live-soft);
  color: var(--live-dark);
  box-shadow: none;
}

.start-btn-quiet:active {
  background: #f9d9d3;
}

.start-btn-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1em;
  line-height: 1;
}

.start-btn-icon svg {
  display: block;
  width: 14px;
  height: 14px;
}

/* ---------- 轻提示：统一放在「底部偏上」，深色底更醒目 ---------- */
.toast {
  position: fixed;
  left: 50%;
  top: auto;
  bottom: calc(env(safe-area-inset-bottom, 0px) + 14vh);
  transform: translateX(-50%);
  background: rgba(74, 56, 32, 0.94);
  color: #fff7e6;
  border: 1px solid rgba(255, 255, 255, 0.12);
  padding: 12px 22px;
  border-radius: var(--radius-pill);
  font-size: 15px;
  font-weight: 700;
  line-height: 1.5;
  max-width: 86vw;
  text-align: center;
  box-shadow: 0 12px 30px rgba(60, 42, 16, 0.34);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  /* 盖在弹层（70~120）之上：取名浮窗里「先写个名字吧」这类提示不能被遮罩压暗 */
  z-index: 130;
  /* 自带 keyframes：动画里也保持 translateX(-50%) 水平居中，避免先偏再跳 */
  animation: toastIn 0.22s cubic-bezier(0.22, 0.61, 0.36, 1);
}

@keyframes toastIn {
  from {
    opacity: 0;
    transform: translateX(-50%) translateY(10px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateX(-50%) translateY(0) scale(1);
  }
}

/* 文字折行时的提示：换成卡片式排版，行距更舒展、左对齐，不再挤成一颗胶囊 */
.toast.is-long {
  width: max-content;
  max-width: min(340px, 88vw);
  padding: 14px 18px;
  border-radius: 16px;
  line-height: 1.62;
  letter-spacing: 0.01em;
  text-align: left;
}

.toast[hidden] {
  display: none;
}

/* ---------- 登录前置遮罩 ---------- */
.login-gate {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background:
    radial-gradient(120% 90% at 50% -10%, #fff9ea 0%, rgba(255, 255, 255, 0) 55%),
    rgba(245, 246, 249, 0.97);
  backdrop-filter: blur(6px);
}

.login-gate[hidden] {
  display: none;
}

.login-gate-card {
  width: 100%;
  max-width: 360px;
  text-align: center;
  padding: 34px 26px 30px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  animation: rise 0.26s cubic-bezier(0.22, 0.61, 0.36, 1);
}

/* 圆形鸭子头像：和引导页的鸭子同款 */
.login-gate-duck {
  width: 96px;
  height: 96px;
  margin: 0 auto 18px;
  border-radius: 50%;
  background-image: url('/assets/images/scene/default.jpg?v=mvgtlf4p');
  background-size: cover;
  background-position: center;
  border: 5px solid #fff;
  box-shadow: var(--shadow);
}

.login-gate-title {
  margin: 0 0 10px;
  font-size: clamp(19px, 5.4vw, 22px);
  font-weight: 700;
  line-height: 1.4;
  color: var(--ink);
}

.login-gate-desc {
  margin: 0;
  font-size: 14px;
  line-height: 1.7;
  color: var(--ink-soft);
}

.login-gate-desc strong {
  color: var(--accent-dark);
}

.login-gate-hint {
  margin: 16px 0 0;
  padding-top: 14px;
  border-top: 1px solid var(--line);
  font-size: 13px;
  color: var(--ink-faint);
}

/* 登录遮罩上的动作区（登录失败/过期时才出现：重试 + 可选「先随便逛逛」） */
.login-gate-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
  margin-top: 18px;
}

.login-gate-actions[hidden] {
  display: none;
}

.login-gate-skip {
  font-size: 13px;
  color: var(--ink-faint);
}

/* ---------- 「我的」等级行：Lv 徽章 + 称号 + 会员有效期（整行点进勋章页） ---------- */
.menu-level-go {
  margin-left: auto;
  flex: 0 0 auto;
  font-size: 12px;
  font-weight: 700;
  color: var(--accent-dark);
  white-space: nowrap;
}

.menu-level-num {
  flex: 0 0 auto;
  min-width: 44px;
  padding: 7px 10px;
  text-align: center;
  border-radius: 12px;
  background: linear-gradient(135deg, #f7c64a, #e0a000);
  color: #5f4200;
  font-size: 15px;
  font-weight: 800;
  letter-spacing: 0.02em;
  box-shadow: 0 3px 10px rgba(224, 154, 10, 0.3);
}

/* 初始档（还没拿到任何勋章）：灰色 Lv.0，弱化到不抢眼 */
.menu-level-num.is-zero {
  background: #eee7d8;
  color: var(--ink-faint);
  box-shadow: none;
}

/* 称号下面不再重复显示会员有效期：统一只在「会员中心」右侧显示一次。 */

/* ---------- 今日作业面板 ---------- */
.panel-homework {
  display: flex;
  flex-direction: column;
  text-align: left;
  /* 顶部没有工具条了：只留状态栏安全区 + 一点呼吸位 */
  padding: calc(var(--safe-top) + 14px) 2px 0;
  max-height: 100%;
  /* 整页自己滚（滚动条已由 .panel 统一隐藏） */
  overflow-y: auto;
  overflow-x: hidden;
  touch-action: pan-y;
  -webkit-overflow-scrolling: touch;
}

/* 科目分区：四个科目从上到下依次排列 */
.hw-sec {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px 14px;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: 8px;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.hw-sec.is-editing {
  border-color: #dfe3ee;
  background: #fffdf7;
}

/* 编辑模式下：作业行左侧的单选框（打勾）不显示，避免和编辑/删除混淆 */
.hw-sec.is-editing .hw-check {
  display: none;
}

.hw-sec-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.hw-sec-name {
  font-size: clamp(14px, 3.9vw, 16px);
  font-weight: 700;
  color: var(--ink-soft);
  display: inline-flex;
  align-items: baseline;
  gap: 1px;
}

.hw-sec-right {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.hw-sec-count {
  font-size: 11px;
  font-weight: 700;
  color: var(--ink-faint);
  font-variant-numeric: tabular-nums;
}

/* 铅笔编辑钮：右上角小小的，不抢眼 */
.hw-edit {
  appearance: none;
  flex: 0 0 auto;
  width: 28px;
  height: 28px;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: transparent;
  color: var(--ink-faint);
  font-size: 16px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background 0.14s ease, color 0.14s ease, transform 0.12s ease;
}

.hw-edit:active {
  transform: scale(0.9);
}

/* 编辑中：铅笔变成绿勾（点它结束编辑） */
.hw-edit.is-on {
  background: #fff4d1;
  color: #cf9000;
}

/* 条目列表 */
.hw-list {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  gap: 18px;
  /* 底部留白：最后一张卡片不贴着屏幕底 */
  padding: 2px 2px 18px;
}

/* ---- 每个孩子一块：头像+名字，下面跟他的各科分区 ---- */
.hw-child {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.hw-child-head {
  display: flex;
  align-items: center;
  gap: 12px;
  /* 上下都和内容隔开一点，标题不挤着卡片 */
  margin: 14px 0 4px;
}

/* 标题两边的渐变横线：从透明渐入到暖黄，收在文字两侧 */
.hw-child-head::before,
.hw-child-head::after {
  content: '';
  flex: 1 1 0;
  height: 2px;
  border-radius: 2px;
}

.hw-child-head::before {
  background: linear-gradient(to right, rgba(244, 179, 26, 0), var(--line));
}

.hw-child-head::after {
  background: linear-gradient(to left, rgba(244, 179, 26, 0), var(--line));
}

.hw-child-name {
  flex: 0 0 auto;
  font-size: clamp(15px, 4.2vw, 17px);
  font-weight: 800;
  color: var(--ink);
  letter-spacing: 0.01em;
  white-space: nowrap;
}

.hw-sec-group {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.hw-sec-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.hw-empty {
  text-align: center;
  color: var(--ink-faint);
  font-size: clamp(13px, 3.6vw, 15px);
  padding: 18px 10px;
  line-height: 1.6;
}

.hw-row {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 40px;
  padding: 6px 8px 6px 8px;
  border-radius: 12px;
  transition: background 0.15s ease;
}

.hw-row:active {
  background: #faf3e4;
}

/* ---- 拖动排序：长按提起后，被拖的项浮起来、其余项平滑让位 ---- */
.hw-row.is-dragging,
.hw-sec.is-dragging {
  z-index: 50;
  box-shadow: 0 16px 34px rgba(122, 92, 24, 0.24);
  opacity: 0.97;
  transition: none;
  will-change: transform;
}

.hw-row.is-dragging {
  background: #fff4d1;
  border-radius: 12px;
}

.hw-sec.is-dragging {
  border-color: var(--accent);
}

/* 让位的空位：虚线框，告诉孩子会落在哪 */
.sort-placeholder {
  border: 2px dashed #e3cf95;
  border-radius: 12px;
  background: rgba(244, 179, 26, 0.06);
  box-sizing: border-box;
}

/* 拖动中：整页进入"搬动"状态，禁止长按选中/滚动 */
body.is-sorting {
  cursor: grabbing;
}

body.is-sorting .hw-row,
body.is-sorting .hw-sec {
  touch-action: none;
}

/* 打勾按钮：未完成是空心绿圈，完成是实心绿色圆 + 白勾 */
.hw-check {
  appearance: none;
  flex: 0 0 auto;
  width: 26px;
  height: 26px;
  border: 2px solid #f2d68a;
  border-radius: 50%;
  background: #fffdf7;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: transparent;
  font-size: 15px;
  transition: transform 0.12s ease, background 0.15s ease, border-color 0.15s ease,
    box-shadow 0.15s ease, color 0.15s ease;
}

.hw-check svg {
  display: block;
}

.hw-check:active {
  transform: scale(0.88);
}

.hw-row.is-done .hw-check {
  background: linear-gradient(160deg, #f7c64a 0%, #eaa100 100%);
  border-color: #eaa100;
  color: #5f4200;
  box-shadow: 0 3px 10px rgba(224, 154, 10, 0.36);
  animation: checkPop 0.28s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes checkPop {
  0% { transform: scale(0.6); }
  60% { transform: scale(1.14); }
  100% { transform: scale(1); }
}

.hw-text {
  flex: 1 1 auto;
  min-width: 0;
  font-size: clamp(14px, 3.9vw, 16px);
  font-weight: 500;
  color: var(--ink);
  line-height: 1.45;
  word-break: break-word;
}

/* 编辑模式：作业文字可点改 → 给个可点的提示（虚线下划线 + 手型），点其它地方不影响外观 */
.hw-text.is-editable {
  cursor: text;
  border-bottom: 1px dashed #dcc899;
  padding-bottom: 1px;
}

/* 就地编辑的输入框：跟文字同宽同字号，融进这一行 */
.hw-text-input {
  flex: 1 1 auto;
  min-width: 0;
  font: inherit;
  font-size: clamp(14px, 3.9vw, 16px);
  font-weight: 500;
  color: var(--ink);
  line-height: 1.45;
  padding: 3px 8px;
  border: 1px solid #f0c65a;
  border-radius: 8px;
  background: #fffdf7;
  box-shadow: 0 0 0 3px rgba(224, 154, 10, 0.14);
  -webkit-user-select: text;
  user-select: text;
}

.hw-text-input:focus {
  outline: none;
}

.hw-row.is-done .hw-text {
  color: var(--ink-faint);
  text-decoration: line-through;
  text-decoration-color: #cbbf9e;
}

.hw-del {
  appearance: none;
  flex: 0 0 auto;
  width: 26px;
  height: 26px;
  border: none;
  border-radius: 50%;
  background: transparent;
  color: var(--ink-faint);
  font-size: 19px;
  line-height: 1;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.hw-del:active {
  background: var(--live-soft);
  color: var(--live-dark);
}

/* 每科的添加行（只在编辑模式） */
.hw-add {
  display: flex;
  gap: 8px;
  padding-top: 2px;
}

.hw-input {
  flex: 1 1 auto;
  min-width: 0;
  font: inherit;
  font-size: 15px;
  padding: 9px 12px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: #fffdf7;
  color: var(--ink);
  -webkit-user-select: text;
  user-select: text;
}

.hw-input:focus {
  outline: none;
  border-color: #f0c65a;
  box-shadow: 0 0 0 3px rgba(224, 154, 10, 0.14);
}

/* 占位提示文字：浅一点，别太抢眼 */
.hw-input::placeholder {
  color: #c4b48f;
  opacity: 1;
}

.hw-add-btn {
  flex: 0 0 auto;
  appearance: none;
  border: none;
  background: #ffe09a;
  color: #5f4200;
  font: inherit;
  font-size: 13px;
  padding: 0 15px;
  border-radius: 10px;
  cursor: pointer;
  transition: transform 0.12s ease, background 0.15s ease;
}

.hw-add-btn:active {
  transform: scale(0.96);
  background: #cf9000;
}

/* ---------- 番茄钟卡片（方形 + 作业蛙动画）：作业面板顶部 ---------- */
.hw-timer {
  position: relative;
  align-self: stretch;
  flex: 0 0 auto; /* 别被下面的作业列表挤压，保持自身高度 */
  display: flex;
  flex-direction: column;
  margin: 0 2px 14px;
  padding: 12px;
  border-radius: 20px;
  background: rgba(255, 252, 244, 0.96);
  border: 1px solid var(--line);
  box-shadow: 0 8px 26px rgba(122, 92, 24, 0.09);
  overflow: hidden;
  /* ★ 这里**刻意不用** backdrop-filter：底色本来就 96% 不透明，模糊看不出来，
     但它会把这整张卡提升成「合成层 + 背景根（backdrop root）」，再叠加
     overflow:hidden + border-radius 的滚动内容层之后，微信 Android web-view
     偶发只剩卡片底色、场景图和底部按钮那一片不重绘（手动刷新才恢复，见
     public/app.js 的 kickCardRepaint）。去掉它 = 少一层合成层，肉眼无差别。 */
  animation: hwTimerIn 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.hw-timer[hidden] {
  display: none;
}

@keyframes hwTimerIn {
  from {
    opacity: 0;
    transform: translateY(-12px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

/* 休息态：暖橙背景 + 边框 */
.hw-timer.is-break {
  background: rgba(255, 249, 240, 0.97);
  border-color: #f6d9a8;
}

/* 暂停态：不再给整卡罩一层暗色（保持卡片本身颜色不变） */

/* 方形舞台：鸭子铺满整块，倒计时浮在它上方 */
.hw-stage {
  position: relative;
  flex: 0 0 auto;
  aspect-ratio: 1 / 1;
  width: 100%;
  border-radius: 16px;
  overflow: hidden;
  background: radial-gradient(120% 100% at 50% 0%, #fff3d0 0%, #fffaf0 100%);
}

/* 小鸭子图片铺满整个方块（cover：填满不留白，居中，略微裁边） */
.hw-duck {
  position: absolute;
  inset: 0;
  background-image: url('/assets/images/scene/default.jpg?v=mvgtlf4p');
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  pointer-events: none;
}

/* 视频场景层：铺满方块（cover），静音循环播放。层次在小鸭子(3)与小鱼(2)之下、背景之上。 */
.hw-duck video.hw-scene-video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  z-index: 1;
  pointer-events: none;
}

/* 视频被自动播放策略挡住（必须点一下才播，微信 iOS 那种）时，动画框**正中**给一颗播放按钮：
   用户一眼就知道要去点它；点了就播，播起来由 playing 事件自己收掉。
   用户定稿：**半透明黑底**，不要阴影/发光；图标只要「圆角播放三角」，不要再套白圆环
   （2026-10-20 用户要求去掉那圈白框，见 app.js 里的 SVG）。
   挂在 #hwStage 上（不是 .hw-duck —— 那是 aria-hidden + pointer-events:none 的纯背景层）。
   ★ 不写 backdrop-filter / box-shadow / 外圈光环：压在视频合成层上既容易不重绘，也不是用户要的效果。 */
.hw-scene-play {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  z-index: 5;
  display: grid;
  place-items: center;
  width: calc(50px * var(--stage-scale, 1));
  height: calc(50px * var(--stage-scale, 1));
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.55);
  color: #fff;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  transition: transform 0.16s ease;
}

/* 图标本体（只剩播放三角）：viewBox 保持原图范围，这里只控制大小 + 居中，不用 margin 硬挪。
   30px 是三角连带的留白盒；三角本体约占 12px，正好落在 50px 圆底中间。 */
.hw-scene-play svg {
  display: block;
  width: calc(30px * var(--stage-scale, 1));
  height: calc(30px * var(--stage-scale, 1));
  margin: 0;
  pointer-events: none;
}

@media (hover: hover) and (pointer: fine) {
  .hw-scene-play:hover {
    transform: translate(-50%, -50%) scale(1.05);
  }
}

.hw-scene-play:active {
  transform: translate(-50%, -50%) scale(0.93);
}

.hw-scene-play:focus-visible {
  outline: 2px solid rgba(255, 255, 255, 0.9);
  outline-offset: 3px;
}

.hw-scene-play[hidden] {
  display: none;
}

@media (prefers-reduced-motion: reduce) {
  .hw-scene-play {
    transition: none;
  }
}

/* 走动的小鸭子（精灵图逐帧动画 + transform 位移）——只在计时卡下半区活动 */
.hw-stage .duck-sprite {
  z-index: 3;
}
/* 投喂的食物（小鱼）——**一条鱼一个元素**：飞行中挂在 body 上 fixed（z-index 40，在鸭子之上，
   从画面外飞进来要看得见）；落地后成为「鸭子指定的那条」时挂回卡里、降到鸭子之下(z-index 2)。
   没被吃到的小鱼落地后停一会儿自己淡出（下面的 opacity 过渡），不再在空中被新抛的鱼顶掉。 */
.duck-food {
  z-index: 40;
  filter: drop-shadow(0 2px 4px rgba(122, 92, 24, 0.28));
  transition: opacity 0.6s ease; /* 与 duck.js 的 fishFadeMs(600) 保持一致：配角鱼落地后淡出 */
}
.hw-stage .duck-food {
  z-index: 2;
}

/* 飞行影子：画在宠物「逻辑落点」的正下方，随离地高度变小变淡 —— 「离地感」几乎全靠它。
   层次：.duck-sprite 是 3、落地的 .duck-food 是 2 → 影子放 1，落在食物与宠物之下。
   只有飞行中才显示（控制器按 state.z 写入 width/height/opacity/transform）；
   地面物种、站着不动时 state.z = 0，控制器把 opacity 置 0，完全不可见、零影响。 */
.pet-shadow {
  position: absolute;
  left: 0;
  top: 0;
  z-index: 1;
  border-radius: 50%;
  background: radial-gradient(closest-side, rgba(60, 45, 20, 0.5), rgba(60, 45, 20, 0) 100%);
  pointer-events: none;
  opacity: 0;
  will-change: transform, opacity;
}

/* 倒计时浮在动画画面正中间，层次在**背景与宠物之间**：
   背景图/视频(1) < 倒计时(2) < 宠物(3)，所以宠物走到倒计时前面时会盖住数字，
   不再出现「倒计时整块压在宠物身上」的观感。玩法控件（体力/音乐）仍在宠物之上。 */
.hw-clock-wrap {
  position: absolute;
  top: 50%;
  left: 0;
  right: 0;
  transform: translateY(-50%);
  z-index: 2;
  padding: 0 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
  pointer-events: none;
}

/* 后台为这个场景设过倒计时位置/大小（--scene-clock-x/y 是中心点百分比，--scene-clock-scale 是倍率）：
   改成绝对定位，把倒计时中心对到那个点，并按倍率缩放。未设 → 保持上面的默认居中。 */
.hw-clock-wrap.is-positioned {
  top: var(--scene-clock-y, 50%);
  left: var(--scene-clock-x, 50%);
  right: auto;
  transform: translate(-50%, -50%);
  white-space: nowrap;
}

/* 状态提示（专注中 / 休息中）：浮在倒计时**正上方**，阶段开始时出现 3 秒后消失。
   黑色半透明底 + 白字，压在图片/视频场景上都看得清；绝对定位不占布局，显隐不会顶动倒计时。 */
.hw-timer-label {
  position: absolute;
  left: 50%;
  bottom: calc(100% + 6px);
  transform: translateX(-50%);
  z-index: 6;
  /* 字号/内边距跟着动画框等比缩放（--stage-scale 由 syncStageScale 写入）；
     避免平板下框变大、而这块标签仍用固定 12px 显得过小。 */
  font-size: calc(12px * var(--stage-scale, 1));
  font-weight: 700;
  letter-spacing: 0.04em;
  color: #fff;
  white-space: nowrap;
  pointer-events: none;
  padding: calc(3px * var(--stage-scale, 1)) calc(11px * var(--stage-scale, 1));
  border-radius: 999px;
  /* 黑色半透明底：同样**不加 backdrop-filter**（见 .hw-timer 的说明，web-view 合成层容易不重绘）。 */
  background: rgba(18, 18, 20, 0.72);
  border: 1px solid rgba(255, 255, 255, 0.16);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.22);
  animation: hwLabelIn 0.18s ease-out;
}

.hw-timer-label[hidden] {
  display: none;
}

@keyframes hwLabelIn {
  from { opacity: 0; transform: translate(-50%, 4px); }
  to { opacity: 1; transform: translate(-50%, 0); }
}

/* 右上角背景音乐按钮：圆形半透明黑底 + 白图标；点一下在下方展开竖条音量。
   图标**不旋转**（旧版播放时自转，已按需求去掉）。
   原来右上角的「专注中」标签挪到倒计时上方后，这里就空出来给它了。 */
.hw-music {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 7;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: calc(34px * var(--stage-scale, 1));
  height: calc(34px * var(--stage-scale, 1));
  padding: 0;
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 50%;
  background: rgba(18, 18, 20, 0.46);
  color: #fff;
  font-size: calc(17px * var(--stage-scale, 1));
  line-height: 1;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  transition: background-color 0.15s ease, transform 0.12s ease;
}

.hw-music:active {
  background: rgba(18, 18, 20, 0.72);
  transform: scale(0.94);
}

/* 音量面板展开时按钮保持按下的深色，指回「现在调的就是它」 */
.hw-music.is-open {
  background: rgba(18, 18, 20, 0.72);
}

.hw-music:focus-visible {
  outline: 2px solid #fff;
  outline-offset: 2px;
}

/* 作者样式里的 display 会盖掉浏览器默认的 [hidden]{display:none}，这里补一条 */
.hw-music[hidden] {
  display: none;
}

.hw-music .hw-music-off {
  display: none;
}

.hw-music.is-muted {
  color: rgba(255, 255, 255, 0.62);
  background: rgba(18, 18, 20, 0.3);
}

.hw-music.is-muted .hw-music-on {
  display: none;
}

.hw-music.is-muted .hw-music-off {
  display: block;
}

/* 竖条音量面板：挂在音乐按钮正下方，深色半透明底 + 白色滑杆。
   初始值由 JS 从「后台场景音量」写入，用户拖过之后记住自己的选择。 */
.hw-volume {
  position: absolute;
  top: calc(10px + 34px * var(--stage-scale, 1) + 8px);
  right: 10px;
  z-index: 8;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: calc(5px * var(--stage-scale, 1));
  width: calc(46px * var(--stage-scale, 1));
  padding: calc(8px * var(--stage-scale, 1)) 0 calc(7px * var(--stage-scale, 1));
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: calc(16px * var(--stage-scale, 1));
  background: rgba(18, 18, 20, 0.68);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.26);
  color: #fff;
  pointer-events: auto;
  animation: hwVolumeIn 0.16s ease-out;
}

.hw-volume[hidden] {
  display: none;
}

.hw-volume-value {
  font-size: calc(11px * var(--stage-scale, 1));
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  line-height: 1;
  color: rgba(255, 255, 255, 0.92);
}

/* 竖条滑杆：用「横条旋转 -90°」实现，比 writing-mode/私有垂直样式在各家 web-view 里更稳。
   旋转后：左端(min) 朝下、右端(max) 朝上 —— 往上拖 = 音量变大。 */
.hw-volume-slider {
  display: flex;
  align-items: center;
  justify-content: center;
  width: calc(24px * var(--stage-scale, 1));
  height: calc(92px * var(--stage-scale, 1));
  overflow: visible;
}

.hw-volume-range {
  width: calc(88px * var(--stage-scale, 1));
  height: calc(24px * var(--stage-scale, 1));
  margin: 0;
  padding: 0;
  transform: rotate(-90deg);
  transform-origin: 50% 50%;
  accent-color: #ffd76a;
  cursor: pointer;
  touch-action: none;
}

@keyframes hwVolumeIn {
  from { opacity: 0; transform: translateY(-4px) scale(0.96); }
  to { opacity: 1; transform: none; }
}

@media (prefers-reduced-motion: reduce) {
  .hw-volume {
    animation: none;
  }
}

/* 小鸭子体力血条：固定在动画区左上角。文字 + 轨道横向排列、整行垂直居中，
   与右上角音乐按钮（top:10px）同一水平线。文字颜色走场景设置（--scene-label-color，
   空=默认色）—— 状态提示改成黑底白字后，这个颜色设置只作用于体力文字。指针穿透，不挡投喂。 */
.hw-health {
  position: absolute;
  top: 10px;
  left: 10px;
  z-index: 6;
  display: flex;
  align-items: center;
  gap: 5px;
  pointer-events: none;
}
/* 「体力：」标签：与状态提示同字号/字重/字距/竖直 padding，只是不带胶囊底。
   盒高与音乐按钮同一水平线（top 都是 10px）。 */
.hw-health-label {
  /* 与 .hw-timer-label 同样跟动画框等比缩放，两者始终等高等大。 */
  font-size: calc(12px * var(--stage-scale, 1));
  font-weight: 700;
  letter-spacing: 0.04em;
  padding: calc(3px * var(--stage-scale, 1)) 0;
  color: var(--scene-label-color, var(--ink-faint));
  white-space: nowrap;
}
/* 血条轨道：圆角胶囊 + 磨砂白底，与状态标签同一质感；整行垂直居中所以自动对齐文字中线 */
.hw-health-track {
  width: calc(74px * var(--stage-scale, 1));
  max-width: 32vw;
  height: calc(9px * var(--stage-scale, 1));
  border-radius: 999px;
  /* 同 .hw-timer-label：不加 backdrop-filter（合成层里的背景根 + 压在场景图上
     是 web-view 偶发不重绘的高危组合），底色 .72 → .82 补回可读性。 */
  background: rgba(255, 253, 247, 0.82);
  box-shadow: inset 0 0 0 1px rgba(74, 56, 32, 0.16), 0 1px 3px rgba(74, 56, 32, 0.12);
  overflow: hidden;
}
/* 血条填充：顶部一道高光让颜色更立体，随体力增减平滑过渡 */
.hw-health-fill {
  height: 100%;
  width: 100%;
  border-radius: 999px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.42) 0%, rgba(255, 255, 255, 0) 55%),
    #57bd5a; /* 默认绿：体力充足 */
  box-shadow: 0 0 6px rgba(87, 189, 90, 0.35);
  transition: width 0.45s ease, background-color 0.45s ease, box-shadow 0.45s ease;
}
/* 体力 ≤50：偏低（黄） */
.hw-health.is-low .hw-health-fill {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.42) 0%, rgba(255, 255, 255, 0) 55%),
    #edb23a;
  box-shadow: 0 0 6px rgba(237, 178, 58, 0.4);
}
/* 体力 <20：告急（红），轻轻脉动提示该喂鱼了 */
.hw-health.is-crit .hw-health-fill {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.42) 0%, rgba(255, 255, 255, 0) 55%),
    #e4573d;
  box-shadow: 0 0 6px rgba(228, 87, 61, 0.45);
  animation: hwHealthPulse 1.1s ease-in-out infinite;
}
@keyframes hwHealthPulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.55; }
}
@media (prefers-reduced-motion: reduce) {
  .hw-health.is-crit .hw-health-fill { animation: none; }
  .hw-health-fill { transition: none; }
}

.hw-timer-clock {
  /* 倒计时字体：场景设的字体（--scene-clock-font，由 applySceneFont 写入），
     未设/找不到时回内置手写体 Caveat。 */
  font-family: var(--scene-clock-font, 'Caveat'), 'Caveat', sans-serif;
  /* 字号跟着**动画框**等比缩放（--stage-scale = 框宽 / 参考框宽，由 syncStageScale 写入）：
     参考框宽 316px（≈390 手机），scale=1 时字号 62.4px 与原手机一致；
     平板/桌面框更大 → 字号同比放大，不再被 vw/上限卡住而显得过小。
     （旧写法 clamp(40px,16vw,66px) 跟随视口宽度，平板下框变大而字被 66px 封顶 → 比例失衡。） */
  font-size: calc(62.4px * var(--stage-scale, 1));
  line-height: 1.05;
  font-weight: 700;
  color: var(--scene-clock-color, var(--ink));
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.02em;
}

/* 后台设过缩放 → 按倍率缩放倒计时（transform 不占布局，居中/定位都不受影响）。 */
.hw-timer-clock.is-scaled {
  transform: scale(var(--scene-clock-scale, 1));
}

.hw-timer.is-break .hw-timer-clock {
  color: var(--scene-clock-color, #b9791f);
}

/* 未开始（空闲）时也显示倒计时：整段专注时长（默认 25:00），只是不倒数。
   [hidden] 仍保留：别的地方临时藏起来时照样生效。 */
.hw-timer-clock[hidden] {
  display: none;
}

/* 动画框下方一行：左边「喂小鱼」，右下角「开始专注 / 继续专注 / 结束」（见 .dock）。
   两个按钮挤不下一行时（超窄屏）自动换行，开始/结束仍在右侧。 */
.hw-timer-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}

/* 底部左侧：投喂按钮（蚯蚓） */
.hw-feed {
  appearance: none;
  flex: 0 0 auto;
  border: 1px solid var(--line);
  background: #fffdf7;
  color: var(--accent-dark);
  font: inherit;
  font-size: 13px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 7px 12px;
  border-radius: var(--radius-pill);
  box-shadow: 0 1px 3px rgba(122, 92, 24, 0.08);
  cursor: pointer;
}

.hw-feed:active {
  transform: translateY(1px);
}

/* 没小鱼了：置灰，但**仍可点**（点了提示「专注学习，可以获得小鱼哦~」） */
.hw-feed:disabled,
.hw-feed.is-empty {
  color: var(--ink-faint);
  background: #f6f1e6;
  border-color: var(--line);
  box-shadow: none;
  cursor: pointer;
  opacity: 0.72;
}

/* 专注中：置灰但**可点**（点了弹「专注中，休息时再喂哦」）；样式与没鱼接近，
   但不设 disabled，保留点击热区好给提示 */
.hw-feed.is-locked {
  color: var(--ink-faint);
  background: #f6f1e6;
  border-color: var(--line);
  box-shadow: none;
  opacity: 0.72;
}

.hw-feed.is-locked .hw-feed-fish {
  filter: grayscale(1);
  opacity: 0.5;
}

.hw-feed.is-locked .hw-feed-count,
.hw-feed.is-locked .hw-feed-num {
  color: var(--ink-faint);
}

.hw-feed.is-empty .hw-feed-fish {
  filter: grayscale(1);
  opacity: 0.5;
}

.hw-feed-count {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.01em;
  color: var(--accent-dark);
  white-space: nowrap;
}

/* 只让数字动：数字单独一个内联块，弹一下不带着文字一起抖 */
.hw-feed-num {
  display: inline-block;
  font-size: 14px;
  font-weight: 900;
  color: #cf9000;
  min-width: 1em;
  text-align: center;
}

.hw-feed.is-empty .hw-feed-count {
  color: var(--ink-faint);
}

.hw-feed.is-empty .hw-feed-num {
  color: var(--ink-faint);
}

.hw-feed-worm {
  display: inline-flex;
  align-items: center;
  color: #e07d97;
  font-size: 18px;
  line-height: 1;
}

/* 按钮上的小鱼：缩小显示（原始 47×22 太大） */
.hw-feed-fish {
  display: block;
  width: 20px;
  height: auto;
}

/* ---- 专注到点奖励：金光四射的胜利背景 + 一排小鱼 + 「收下」---- */
.hw-reward {
  position: absolute;
  inset: 0;
  z-index: 6;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: calc(20px * var(--stage-scale, 1)) calc(16px * var(--stage-scale, 1));
  overflow: hidden;
  background: radial-gradient(
    circle at 50% 44%,
    rgba(255, 240, 196, 0.98) 0%,
    rgba(255, 216, 116, 0.95) 42%,
    rgba(244, 179, 26, 0.92) 100%
  );
}

.hw-reward[hidden] {
  display: none;
}

/* 放射光束：绕中心缓慢旋转的重复锥形渐变（黄白相间的胜利光芒） */
.hw-reward-rays {
  position: absolute;
  left: 50%;
  top: 44%;
  width: 240%;
  height: 240%;
  transform: translate(-50%, -50%);
  background: repeating-conic-gradient(
    from 0deg at 50% 50%,
    rgba(255, 255, 255, 0.92) 0deg 3.2deg,
    rgba(255, 255, 255, 0) 3.2deg 13deg
  );
  -webkit-mask-image: radial-gradient(circle at 50% 50%, #000 6%, rgba(0, 0, 0, 0.55) 44%, transparent 72%);
  mask-image: radial-gradient(circle at 50% 50%, #000 6%, rgba(0, 0, 0, 0.55) 44%, transparent 72%);
  animation: reward-rays-spin 18s linear infinite;
  pointer-events: none;
}

@keyframes reward-rays-spin {
  from {
    transform: translate(-50%, -50%) rotate(0deg);
  }
  to {
    transform: translate(-50%, -50%) rotate(360deg);
  }
}

/* 弹框顶部标题：说明这笔小鱼来自哪（专注到点奖励 / 获得勋章奖励） */
.hw-reward-title {
  position: relative;
  z-index: 1;
  margin: 0 0 calc(10px * var(--stage-scale, 1));
  padding: 0 calc(6px * var(--stage-scale, 1));
  font-size: calc(17px * var(--stage-scale, 1));
  font-weight: 800;
  letter-spacing: 0.04em;
  text-align: center;
  color: #8a5c00;
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.6);
}

.hw-reward-title[hidden] {
  display: none;
}

/* 一排小鱼：够多就自动换行 */
.hw-reward-fish {
  position: relative;
  z-index: 1;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: calc(5px * var(--stage-scale, 1));
  max-width: 94%;
  margin-bottom: calc(44px * var(--stage-scale, 1));
}

.hw-reward-fish-img {
  width: calc(44px * var(--stage-scale, 1));
  height: auto;
  filter: drop-shadow(0 4px 5px rgba(122, 92, 24, 0.32));
  animation: fish-pop 0.46s cubic-bezier(0.22, 1.5, 0.44, 1) both;
}

/* 每条依次弹起 */
.hw-reward-fish-img:nth-child(1) { animation-delay: 0s; }
.hw-reward-fish-img:nth-child(2) { animation-delay: 0.07s; }
.hw-reward-fish-img:nth-child(3) { animation-delay: 0.14s; }
.hw-reward-fish-img:nth-child(4) { animation-delay: 0.21s; }
.hw-reward-fish-img:nth-child(5) { animation-delay: 0.28s; }
.hw-reward-fish-img:nth-child(6) { animation-delay: 0.35s; }
.hw-reward-fish-img:nth-child(n+7) { animation-delay: 0.42s; }

@keyframes fish-pop {
  0% {
    transform: translateY(14px) scale(0.3);
    opacity: 0;
  }
  100% {
    transform: translateY(0) scale(1);
    opacity: 1;
  }
}

/* 「收下」按钮：钉在底部中间 */
.hw-reward-take {
  position: absolute;
  z-index: 1;
  left: 50%;
  bottom: calc(22px * var(--stage-scale, 1));
  transform: translateX(-50%);
  appearance: none;
  border: none;
  font: inherit;
  font-size: calc(18px * var(--stage-scale, 1));
  font-weight: 800;
  color: #fff;
  padding: calc(14px * var(--stage-scale, 1)) calc(52px * var(--stage-scale, 1));
  border-radius: var(--radius-pill);
  background: linear-gradient(160deg, #ff9f1a, #e5761a);
  box-shadow: 0 8px 20px rgba(196, 116, 6, 0.45);
  cursor: pointer;
  animation: reward-take-in 0.3s cubic-bezier(0.22, 0.61, 0.36, 1) 0.12s both;
}

@keyframes reward-take-in {
  from {
    transform: translateX(-50%) translateY(24px);
    opacity: 0.4;
  }
  to {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
  }
}

.hw-reward-take:active {
  transform: translateX(-50%) translateY(1px);
}

/* ---- 升级获得勋章：动画框里金光 + 大勋章 + 奖励小鱼 ---- */
.hw-medal {
  position: absolute;
  inset: 0;
  z-index: 7;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: calc(18px * var(--stage-scale, 1)) calc(16px * var(--stage-scale, 1)) calc(70px * var(--stage-scale, 1));
  overflow: hidden;
  background: radial-gradient(
    circle at 50% 42%,
    rgba(255, 244, 208, 0.98) 0%,
    rgba(255, 220, 130, 0.96) 44%,
    rgba(244, 179, 26, 0.94) 100%
  );
}

.hw-medal[hidden] {
  display: none;
}

.hw-medal-cap {
  position: relative;
  z-index: 1;
  margin: 0 0 calc(4px * var(--stage-scale, 1));
  font-size: calc(15px * var(--stage-scale, 1));
  font-weight: 700;
  letter-spacing: 0.08em;
  color: #8a5c00;
}

.hw-medal-icon {
  position: relative;
  z-index: 1;
  width: 34%;
  max-width: calc(128px * var(--stage-scale, 1));
  height: auto;
  filter: drop-shadow(0 8px 14px rgba(150, 100, 10, 0.42));
  animation: medal-pop 0.62s cubic-bezier(0.22, 1.5, 0.44, 1) both;
}

.hw-medal-name {
  position: relative;
  z-index: 1;
  margin: calc(8px * var(--stage-scale, 1)) 0 0;
  font-size: calc(22px * var(--stage-scale, 1));
  font-weight: 800;
  letter-spacing: 0.04em;
  color: #fff;
  text-shadow: 0 2px 6px rgba(150, 96, 6, 0.65), 0 1px 0 rgba(255, 220, 130, 0.7);
}

.hw-medal-fish {
  position: relative;
  z-index: 1;
  margin: calc(8px * var(--stage-scale, 1)) 0 0;
  padding: calc(5px * var(--stage-scale, 1)) calc(14px * var(--stage-scale, 1));
  border-radius: var(--radius-pill);
  background: rgba(255, 255, 255, 0.72);
  font-size: calc(15px * var(--stage-scale, 1));
  font-weight: 700;
  color: #b06500;
}

/* 盖过「收下」按钮的入场动画，让勋章先弹出来再点 */
.hw-medal .hw-reward-take {
  z-index: 2;
}

@keyframes medal-pop {
  0% {
    transform: scale(0.2) rotate(-24deg);
    opacity: 0;
  }
  60% {
    transform: scale(1.08) rotate(5deg);
    opacity: 1;
  }
  100% {
    transform: scale(1) rotate(0deg);
    opacity: 1;
  }
}

/* 点「收下勋章」：整块勋章庆祝框弹性缩小消失（带一点回弹） */
.hw-medal.is-leaving {
  animation: medal-leave 0.46s cubic-bezier(0.5, -0.35, 0.7, 0.25) both;
  pointer-events: none;
  transform-origin: center;
}

@keyframes medal-leave {
  0% {
    transform: scale(1);
    opacity: 1;
  }
  35% {
    transform: scale(1.06);
    opacity: 1;
  }
  100% {
    transform: scale(0.05);
    opacity: 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  .hw-medal.is-leaving {
    animation: none;
  }
}

/* ---------- 勋章页：12 个等级勋章网格（已获得=彩色，未获得=灰色） ---------- */
.medal-head {
  margin: 0 0 14px;
}

.medal-sub {
  margin: 0;
  font-size: 13px;
  color: var(--ink-soft);
}

.medal-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}

.medal-cell {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  padding: 12px 6px;
  border-radius: 16px;
  border: 1px solid var(--line);
  background: #fffdf7;
  text-align: center;
}

.medal-icon {
  width: 60px;
  height: 60px;
  object-fit: contain;
  display: block;
}

.medal-name {
  font-size: 13px;
  font-weight: 700;
  color: var(--ink);
  letter-spacing: 0.02em;
}

.medal-req {
  font-size: 11px;
  color: var(--ink-faint);
}

/* 未获得：整格灰掉（灰度 + 压暗 + 降透明） */
.medal-cell.is-locked {
  background: #f6f1e4;
}

.medal-cell.is-locked .medal-icon {
  filter: grayscale(1) opacity(0.42) brightness(1.05);
}

.medal-cell.is-locked .medal-name {
  color: var(--ink-faint);
}

/* 已获得：金边 + 微微发光 */
.medal-cell.is-earned {
  border-color: #f0c34a;
  background: linear-gradient(180deg, #fffdf4, #fff4d6);
  box-shadow: 0 4px 12px rgba(224, 154, 10, 0.18);
}

/* 刚升级获得的：弹一下吸引注意（只亮一次） */
.medal-cell.is-just {
  animation: medal-pop 0.62s cubic-bezier(0.22, 1.5, 0.44, 1) both;
}

/* 收下时飞向投喂按钮的小鱼（挂在 body 上 fixed，走贝塞尔弧线） */
.fly-fish {
  position: fixed;
  left: 0;
  top: 0;
  z-index: 90;
  width: 44px;
  height: auto;
  pointer-events: none;
  filter: drop-shadow(0 3px 4px rgba(122, 92, 24, 0.35));
  will-change: transform, opacity;
}

/* 数字蹭蹭涨时轻微弹一下（只作用于数字块） */
@keyframes feed-count-bump {
  0% {
    transform: scale(1);
  }
  45% {
    transform: scale(1.35);
  }
  100% {
    transform: scale(1);
  }
}

.hw-feed-num.is-bump {
  animation: feed-count-bump 0.2s ease-out;
}

/* ---------- 每个孩子全部完成后的「完成表单」（挂在名字下方，代替可编辑列表） ---------- */
.hw-sum-child {
  flex: 0 0 auto;
  padding: 16px 18px 18px;
  background: var(--surface);
  border: 1px solid #f3e3b8;
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  background-image: linear-gradient(180deg, #fff6d9 0%, #fffdf7 42%);
}

.hw-summary-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin: 0 0 10px;
}

.hw-summary-title {
  margin: 0;
  font-size: clamp(16px, 4.4vw, 18px);
  font-weight: 800;
  color: var(--ink);
}

/* 标题里的小图标（完成勾），跟文字同一行、跟着字号缩放 */
.hw-summary-icon {
  display: inline-flex;
  margin-right: 6px;
  font-size: 1.05em;
  color: #ff9200;
  vertical-align: -0.1em;
}

.hw-summary-icon svg {
  display: block;
}

/* 作业清单：同科目合并成一行，像表格一样（科目 | 该科的若干条作业） */
.hw-done-table {
  display: flex;
  flex-direction: column;
}

.hw-done-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 8px 2px;
  font-size: clamp(13.5px, 3.9vw, 15px);
  border-bottom: 1px solid #f7edd6;
}

.hw-done-row:last-child {
  border-bottom: none;
}

.hw-done-subj {
  flex: 0 0 auto;
  min-width: 3em;
  padding-top: 2px;
  font-weight: 700;
  color: var(--ink);
}

/* 一个科目下的多条作业：竖着排，逐条带删除横线 */
.hw-done-cell {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

/* 完成的作业：文字加删除横线（一眼看出已写完） */
.hw-done-text {
  min-width: 0;
  color: var(--ink-faint);
  text-decoration: line-through;
  text-decoration-color: #cbbf9e;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.hw-sum-time {
  margin: 12px 0 2px;
  font-size: 13px;
  font-weight: 800;
  color: #cf9000;
  font-variant-numeric: tabular-nums;
}

/* ---------- 完成条：一个孩子一条，两条就上下叠；滚到下面就吸顶在作业页上方 ----------
   分享入口从完成卡底部挪到这里：不弹层、不参与小鱼/勋章排队，滚多远都看得见。
   外层 .hw-done-bars 负责 sticky；每条 .hw-done-bar 各自带「晒一晒」和右上角 ×。 */
.hw-done-bars {
  position: sticky;
  /* 面板顶部有 safe-top + 14px 的内边距；sticky 的 top 是相对内容盒算的，
     减掉这段才能真吸到顶，不然会停在 38px、上方漏一条内容。 */
  top: calc(-1 * (var(--safe-top) + 14px));
  z-index: 8;
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 0 2px 14px;
}

.hw-done-bars[hidden] {
  display: none;
}

.hw-done-bar {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  /* 右边留出 42px 给右上角的 ×，分享按钮不会和它叠在一起 */
  padding: 10px 42px 10px 12px;
  border-radius: 16px;
  background: linear-gradient(135deg, #fffdf7 0%, #fff3d0 100%);
  border: 1px solid #f0d9a8;
  box-shadow: 0 6px 18px rgba(160, 120, 20, 0.12);
  text-align: left;
}

.hw-done-bar.is-in {
  animation: hwDoneBarIn 0.24s cubic-bezier(0.22, 0.61, 0.36, 1);
}

@keyframes hwDoneBarIn {
  from {
    opacity: 0;
    transform: translateY(-6px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.hw-done-bar-check {
  flex: 0 0 auto;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(180deg, #ffd45e, #f4b31a);
  color: #fff;
  font-size: 19px;
  font-weight: 900;
  line-height: 1;
  box-shadow: 0 3px 8px rgba(244, 179, 26, 0.35);
}

.hw-done-bar-text {
  flex: 1 1 120px;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.hw-done-bar-title,
.hw-done-bar-sub {
  margin: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.hw-done-bar-title {
  font-size: 15px;
  font-weight: 800;
  color: var(--ink);
}

.hw-done-bar-sub {
  font-size: 11px;
  font-weight: 600;
  color: #a8873a;
  font-variant-numeric: tabular-nums;
}

.hw-done-bar-actions {
  flex: 0 0 auto;
  margin-left: auto;
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 6px;
}

.hw-done-bar-btn {
  appearance: none;
  flex: 0 0 auto;
  max-width: 7.5em;
  height: 38px;
  padding: 0 14px;
  border: 0;
  border-radius: var(--radius-pill);
  background: linear-gradient(180deg, #ffd45e 0%, #f4b31a 100%);
  color: #5b4a1f;
  font: inherit;
  font-size: 13px;
  font-weight: 800;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  cursor: pointer;
  box-shadow: 0 4px 10px rgba(244, 179, 26, 0.3);
  transition: transform 0.12s ease, filter 0.12s ease;
}

.hw-done-bar-btn:active {
  transform: translateY(1px) scale(0.98);
  filter: brightness(0.97);
}

.hw-done-bar-btn:disabled {
  opacity: 0.65;
  cursor: default;
}

.hw-done-bar-btn:focus-visible {
  outline: 2px solid #cf9000;
  outline-offset: 2px;
}

/* 右上角 ×：浮在条的右上角（红圈位置），只收起这一条；小、淡，不抢「晒一晒」 */
.hw-done-bar-close {
  appearance: none;
  position: absolute;
  top: 4px;
  right: 8px;
  width: 28px;
  height: 28px;
  padding: 0;
  border: 1px solid rgba(160, 120, 20, 0.22);
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.55);
  color: #a8873a;
  font: inherit;
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.12s ease, background 0.12s ease;
}

.hw-done-bar-close:active {
  transform: scale(0.9);
  background: #fff3d0;
}

.hw-done-bar-close:focus-visible {
  outline: 2px solid #cf9000;
  outline-offset: 2px;
}

@media (max-width: 340px) {
  .hw-done-bars {
    gap: 6px;
  }
  .hw-done-bar {
    gap: 8px;
    padding: 9px 38px 9px 10px;
  }
  .hw-done-bar-btn {
    height: 36px;
    padding: 0 11px;
  }
  .hw-done-bar-close {
    top: 3px;
    right: 6px;
    width: 26px;
    height: 26px;
    font-size: 17px;
  }
}

/* ---------- 上传作业菜单：底部弹出「拍作业 / 复制粘贴作业 / 相册上传作业」 ---------- */
.hw-rewrite {
  appearance: none;
  flex: 0 0 auto;
  padding: 6px 16px;
  font: inherit;
  font-size: 13px;
  font-weight: 800;
  color: #7a5a10;
  background: #ffe9a3;
  border: 1px solid #f3d574;
  border-radius: var(--radius-pill);
  cursor: pointer;
}

.hw-rewrite:active {
  background: #ffdf85;
}

/* ---------- 上传作业菜单：底部弹出「拍作业 / 复制粘贴作业 / 相册上传作业」 ---------- */
.up-menu {
  position: fixed;
  inset: 0;
  z-index: 64;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  background: rgba(122, 92, 24, 0.34);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
  animation: hwEstFade 0.18s ease;
}

.up-menu[hidden] {
  display: none;
}

.up-menu-card {
  width: 100%;
  max-width: 460px;
  background: #fffdf7;
  border-radius: 22px 22px 0 0;
  padding: 18px 18px calc(env(safe-area-inset-bottom) + 16px);
  box-shadow: var(--shadow);
  animation: hwEstUp 0.22s cubic-bezier(0.22, 0.61, 0.36, 1);
}

.up-menu-title {
  margin: 0 0 12px;
  font-size: 16px;
  font-weight: 800;
  color: var(--ink);
  text-align: center;
}

/* 标题下的副标题：非会员显示「（可试用 N 次）」 */
.up-menu-sub {
  margin: -6px 0 12px;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-soft);
  text-align: center;
}

.up-menu-sub[hidden] {
  display: none;
}

/* .up-menu-item 自带 display:flex，会盖掉浏览器默认的 [hidden]{display:none}。
   审核期「分享作业」入口靠 hidden 隐藏，这里必须显式补一条（审核通过后 hidden 去掉即恢复）。 */
.up-menu-item[hidden] {
  display: none;
}

.up-menu-item {
  appearance: none;
  width: 100%;
  display: flex;
  align-items: center;
  gap: 12px;
  text-align: left;
  font: inherit;
  font-size: 16px;
  font-weight: 600;
  color: var(--ink);
  padding: 15px 14px;
  margin-bottom: 8px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fffdf7;
  cursor: pointer;
  transition: background 0.12s ease, border-color 0.12s ease;
}

.up-menu-item:active {
  background: var(--accent-soft);
  border-color: var(--accent);
}

/* 右侧锁标识：默认隐藏；试用次数用完后显示（父级 is-locked） */
.up-menu-lock {
  display: none;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  font-size: 18px;
  color: var(--ink-faint);
}

.up-menu-item.is-locked .up-menu-lock {
  display: inline-flex;
}

/* 试用结束 / 未开通：按钮置灰但仍可点（点了弹开通引导） */
.up-menu-item.is-locked {
  color: var(--ink-faint);
  background: #f6f1e6;
  border-color: var(--line);
}

.up-menu-item.is-locked .up-menu-ico {
  background: #ece4d3;
  color: var(--ink-faint);
}

.up-menu-item.is-locked:active {
  background: #f0e9da;
  border-color: var(--line);
}

.up-menu-ico {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  flex: 0 0 auto;
  border-radius: 10px;
  background: var(--accent-soft);
  color: var(--accent-dark);
  font-size: 20px;
}

.up-menu-text {
  flex: 1 1 auto;
}

.up-menu-actions {
  display: flex;
  margin-top: 6px;
}

.up-menu-actions .chip {
  flex: 1 1 auto;
  text-align: center;
  justify-content: center;
}

/* ---------- 上传前选「这份作业是谁的」 ---------- */
.up-pick {
  position: fixed;
  inset: 0;
  z-index: 64;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  background: rgba(122, 92, 24, 0.34);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
  animation: hwEstFade 0.18s ease;
}

.up-pick[hidden] {
  display: none;
}

.up-pick-card {
  width: 100%;
  max-width: 460px;
  background: #fffdf7;
  border-radius: 22px 22px 0 0;
  padding: 18px 18px calc(env(safe-area-inset-bottom) + 16px);
  box-shadow: var(--shadow);
  animation: hwEstUp 0.22s cubic-bezier(0.22, 0.61, 0.36, 1);
}

.up-pick-title {
  margin: 0 0 12px;
  font-size: 16px;
  font-weight: 800;
  color: var(--ink);
  text-align: center;
}

.up-pick-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.up-pick-item {
  appearance: none;
  width: 100%;
  display: flex;
  align-items: center;
  gap: 12px;
  text-align: left;
  font: inherit;
  font-size: 17px;
  font-weight: 700;
  color: var(--ink);
  padding: 13px 16px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fffdf7;
  cursor: pointer;
  transition: background 0.12s ease, border-color 0.12s ease;
}

.up-pick-item:active {
  background: var(--accent-soft);
  border-color: var(--accent);
}

.up-pick-avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: linear-gradient(160deg, #ffd066, var(--accent));
  color: #5f4200;
  font-size: 18px;
  font-weight: 700;
  overflow: hidden;
  flex: 0 0 auto;
}

.up-pick-avatar:has(.avatar-img) {
  background: #fbeecb;
}

.up-pick-name {
  flex: 1 1 auto;
}

/* 分享作业时：这个孩子还没录入作业，右侧标一句（点了会提示） */
.up-pick-hint {
  flex: 0 0 auto;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-faint);
}

/* ---------- 分享作业：勾选要分享出去的作业项（卡片样式同作业列表） ---------- */
.hw-share-out-card {
  display: flex;
  flex-direction: column;
  max-height: 82vh;
}

.hw-share-out-title {
  margin: 0 0 6px;
  font-size: 17px;
  font-weight: 800;
  color: var(--ink);
  text-align: center;
}

.hw-share-out-sub {
  margin: 0 0 12px;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-soft);
  text-align: center;
}

.hw-share-out-list {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 2px 2px 4px;
}

/* 整行可点（不是只有小圈可点）；没勾的淡下去 + 划线 */
.hw-share-out .hw-row {
  cursor: pointer;
}

/* 这一行是 <button>（整行可点）：清掉浏览器给按钮的默认浅色底/边框/字体，
   让它和作业列表里的 .hw-row 长得一模一样。深色模式下不重置就会是「白底 + 浅色字」。 */
.hw-share-out .hw-row {
  appearance: none;
  -webkit-appearance: none;
  width: 100%;
  margin: 0;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  text-align: left;
}

.hw-share-out .hw-row.is-off {
  opacity: 0.45;
}

.hw-share-out .hw-row.is-off .hw-text {
  text-decoration: line-through;
}

/* 勾上了：复用作业列表「已完成」那套实心金圈 */
.hw-share-out .hw-row.is-on .hw-check {
  background: linear-gradient(160deg, #f7c64a 0%, #eaa100 100%);
  border-color: #eaa100;
  color: #5f4200;
  box-shadow: 0 3px 10px rgba(224, 154, 10, 0.36);
}

/* ---------- 好友分享来的作业：勾选要录入的（默认全选） ---------- */
.hw-share-in-card {
  display: flex;
  flex-direction: column;
  max-height: 82vh;
}

.hw-share-in-title {
  margin: 0 0 6px;
  font-size: 17px;
  font-weight: 800;
  color: var(--ink);
  text-align: center;
}

.hw-share-in-sub {
  margin: 0 0 12px;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-soft);
  text-align: center;
}

/* 接收方有两个孩子时：录给谁（默认第一个） */
.hw-share-in-kids {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}

.hw-share-in-kids[hidden] {
  display: none;
}

.hw-share-in-kids .chip {
  flex: 1 1 auto;
  text-align: center;
  justify-content: center;
}

.hw-share-in-kids .chip.is-on {
  color: #7a5a10;
  background: #ffe9a3;
  border-color: #f3d574;
}

.hw-share-in-list {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.hw-share-in-item {
  appearance: none;
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  text-align: left;
  font: inherit;
  font-size: 15px;
  font-weight: 600;
  color: var(--ink);
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fffdf7;
  cursor: pointer;
  transition: opacity 0.12s ease, background 0.12s ease, border-color 0.12s ease;
}

.hw-share-in-item.is-off {
  opacity: 0.5;
}

.hw-share-in-item.is-off .hw-share-in-text {
  text-decoration: line-through;
}

/* 勾选圈：选中 = 实心金圆 + 白勾 */
.hw-share-in-box {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 2px solid #e3d4a8;
  background: #fff;
  color: #fff;
  font-size: 13px;
  font-weight: 900;
  line-height: 1;
}

.hw-share-in-item:not(.is-off) .hw-share-in-box {
  border-color: var(--accent);
  background: linear-gradient(160deg, #ffd066, var(--accent));
}

.hw-share-in-subject {
  flex: 0 0 auto;
  padding: 3px 8px;
  border-radius: 8px;
  background: #ffd85e;
  color: #7a5a10;
  font-size: 12px;
  font-weight: 800;
}

.hw-share-in-text {
  flex: 1 1 auto;
  word-break: break-all;
}

.up-pick-actions {
  display: flex;
  margin-top: 12px;
}

.up-pick-actions .chip {
  flex: 1 1 auto;
  text-align: center;
  justify-content: center;
}

/* ---------- 复制粘贴作业弹层 ---------- */
.hw-paste {
  position: fixed;
  inset: 0;
  z-index: 64;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  background: rgba(122, 92, 24, 0.34);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
  animation: hwEstFade 0.18s ease;
}

.hw-paste[hidden] {
  display: none;
}

.hw-paste-card {
  width: 100%;
  max-width: 460px;
  background: #fffdf7;
  border-radius: 22px 22px 0 0;
  padding: 18px 18px calc(env(safe-area-inset-bottom) + 16px);
  box-shadow: var(--shadow);
  animation: hwEstUp 0.22s cubic-bezier(0.22, 0.61, 0.36, 1);
}

.hw-paste-title {
  margin: 0;
  font-size: 16px;
  font-weight: 800;
  color: var(--ink);
}

.hw-paste-sub {
  margin: 4px 0 12px;
  font-size: 13px;
  line-height: 1.5;
  color: var(--ink-soft);
}

.hw-paste-input {
  width: 100%;
  font: inherit;
  font-size: 15px;
  line-height: 1.5;
  padding: 12px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: #fffdf7;
  color: var(--ink);
  resize: none;
  -webkit-user-select: text;
  user-select: text;
}

.hw-paste-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.hw-paste-img {
  display: block;
  max-width: 100%;
  max-height: 40vh;
  margin: 10px auto 0;
  border-radius: 12px;
  border: 1px solid var(--line);
}

.hw-paste-img[hidden] {
  display: none;
}

.hw-paste-actions {
  display: flex;
  gap: 8px;
  margin-top: 14px;
}

.hw-paste-actions .chip {
  flex: 1 1 auto;
  text-align: center;
  justify-content: center;
}

.hw-paste-actions .chip-primary {
  flex: 1.6;
}

/* ---------- 弹层通用进出场动画（与底部弹层共用） ---------- */
@keyframes hwEstFade {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes hwEstUp {
  from {
    transform: translateY(24px);
    opacity: 0.6;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

/* ---------- 拍照识别结果预览：确认后再写入 ---------- */
.hw-preview {
  position: fixed;
  inset: 0;
  z-index: 65;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  background: rgba(122, 92, 24, 0.34);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
  animation: hwEstFade 0.18s ease;
}

.hw-preview[hidden] {
  display: none;
}

.hw-preview-card {
  width: 100%;
  max-width: 560px;
  max-height: 86vh;
  display: flex;
  flex-direction: column;
  background: #fffdf7;
  border-radius: 22px 22px 0 0;
  padding: 18px 18px calc(env(safe-area-inset-bottom) + 16px);
  box-shadow: var(--shadow);
  animation: hwEstUp 0.22s cubic-bezier(0.22, 0.61, 0.36, 1);
}

.hw-preview-title {
  margin: 0;
  font-size: 16px;
  font-weight: 800;
  color: var(--ink);
}

.hw-preview-count {
  margin: 3px 0 12px;
  font-size: 13px;
  color: var(--ink-faint);
}

.hw-preview-hint {
  margin: 10px 0 2px;
  font-size: 12px;
  line-height: 1.4;
  color: var(--ink-faint);
  text-align: center;
}

.hw-preview-list {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding-bottom: 4px;
}

.hwp-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.hwp-group-head {
  margin: 0;
  font-size: 15px;
  font-weight: 800;
  color: var(--ink);
}

.hwp-item {
  display: flex;
  align-items: center;
  gap: 8px;
}

.hwp-no {
  flex: 0 0 auto;
  min-width: 1.4em;
  font-size: 14px;
  font-weight: 700;
  color: var(--ink-faint);
  text-align: right;
}

.hwp-text {
  flex: 1 1 auto;
  min-width: 0;
  font: inherit;
  font-size: 15px;
  padding: 8px 11px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: #fffdf7;
  color: var(--ink);
  -webkit-user-select: text;
  user-select: text;
}

.hwp-text:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.hwp-del {
  flex: 0 0 auto;
  appearance: none;
  width: 26px;
  height: 26px;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: transparent;
  color: var(--ink-faint);
  font-size: 19px;
  line-height: 1;
  cursor: pointer;
}

.hwp-del:active {
  background: var(--live-soft);
  color: var(--live-dark);
}

.hw-preview-actions {
  display: flex;
  gap: 8px;
  margin-top: 14px;
}

.hw-preview-actions .chip {
  flex: 1 1 auto;
  text-align: center;
  justify-content: center;
}

.hw-preview-actions .chip-primary {
  flex: 1.6;
}

.hw-preview-actions .chip[disabled] {
  opacity: 0.5;
  pointer-events: none;
}

/* ---------- 今日作业分享图弹层 ---------- */
.hw-sum-share {
  display: block;
  width: 100%;
  margin-top: 12px;
  padding: 10px 14px;
  appearance: none;
  font: inherit;
  font-size: 14px;
  font-weight: 800;
  color: #7a5a10;
  background: #ffe9a3;
  border: 1px solid #f3d574;
  border-radius: var(--radius-pill);
  cursor: pointer;
}

.hw-sum-share:active {
  background: #ffdf85;
}

.hw-poster {
  position: fixed;
  inset: 0;
  z-index: 72;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(78, 58, 12, 0.55);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  animation: hwEstFade 0.18s ease;
}

.hw-poster[hidden] {
  display: none;
}

.hw-poster-card {
  width: 100%;
  max-width: 440px;
  max-height: 92vh;
  display: flex;
  flex-direction: column;
  background: #fffdf7;
  border-radius: 22px;
  padding: 16px 16px calc(env(safe-area-inset-bottom) + 14px);
  box-shadow: var(--shadow);
  animation: hwEstUp 0.22s cubic-bezier(0.22, 0.61, 0.36, 1);
}

.hw-poster-title {
  margin: 0 0 10px;
  font-size: 16px;
  font-weight: 800;
  color: var(--ink);
  text-align: center;
}

.hw-poster-imgwrap {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  display: flex;
  justify-content: center;
  border-radius: 14px;
  background: #fff6dd;
}

.hw-poster-img {
  display: block;
  width: 100%;
  max-width: 340px;
  height: auto;
  border-radius: 14px;
}

.hw-poster-hint {
  margin: 10px 0 0;
  font-size: 12.5px;
  color: var(--ink-faint);
  text-align: center;
}

.hw-poster-actions {
  display: flex;
  gap: 8px;
  margin-top: 12px;
}

.hw-poster-actions .chip {
  flex: 1 1 auto;
  text-align: center;
  justify-content: center;
}

.hw-poster-actions .chip-primary {
  flex: 1.5;
}

/* ---------- 结束写作业：确认弹窗 ---------- */
.hw-confirm {
  position: fixed;
  inset: 0;
  z-index: 70;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(122, 92, 24, 0.34);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
  animation: hwEstFade 0.18s ease;
}

.hw-confirm[hidden] {
  display: none;
}

.hw-confirm-card {
  width: 100%;
  max-width: 340px;
  background: #fffdf7;
  border-radius: var(--radius);
  padding: 22px 20px 18px;
  box-shadow: var(--shadow);
  text-align: center;
  animation: hwEstUp 0.22s cubic-bezier(0.22, 0.61, 0.36, 1);
}

.hw-confirm-title {
  margin: 0 0 18px;
  font-size: 17px;
  font-weight: 800;
  color: var(--ink);
}

/* 确认框里的补充说明（如「重写」弹窗）。负上边距抵消标题的下间距 */
.hw-confirm-desc {
  margin: -10px 0 18px;
  font-size: 13.5px;
  line-height: 1.5;
  color: var(--ink-faint);
}

.hw-confirm-actions {
  display: flex;
  gap: 10px;
}

.hw-confirm-actions .chip {
  flex: 1 1 auto;
  text-align: center;
  justify-content: center;
  padding: 11px 0;
}

/* 三个按钮（保留/清空/取消）：字小一点、允许换行，避免挤爆 */
.hw-confirm-actions-3 .chip {
  padding: 11px 4px;
  font-size: 14px;
}

/* ---------- 新用户取名浮窗（进倒计时主页面后弹，可点「一会再说」） ---------- */
.name-modal .hw-confirm-title {
  margin-bottom: 8px;
}

/* 说明文字贴住输入框：改掉 hw-confirm-desc 为「标题下」设计的负上边距 */
.name-modal .hw-confirm-desc {
  margin: 0 0 14px;
}

.name-modal .add-input {
  margin: 0 0 16px;
  text-align: center;
}

.chip.chip-danger {
  background: var(--live);
  border: 1px solid transparent;
  color: #fff;
  box-shadow: var(--shadow-live);
}

.chip.chip-danger:active {
  background: var(--live-dark);
  color: #fff;
}

/* ---------- 识别/分析中：全屏遮罩 + 居中转圈动画 ---------- */
.analyzing {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(122, 92, 24, 0.4);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  animation: hwEstFade 0.18s ease;
}

.analyzing[hidden] {
  display: none;
}

.analyzing-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  padding: 26px 30px;
  background: rgba(255, 252, 244, 0.96);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  animation: hwEstUp 0.22s cubic-bezier(0.22, 0.61, 0.36, 1);
}

.analyzing-spinner {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 4px solid var(--accent-soft);
  border-top-color: var(--accent);
  animation: anaSpin 0.8s linear infinite;
}

@keyframes anaSpin {
  to {
    transform: rotate(360deg);
  }
}

.analyzing-text {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
  color: var(--ink);
}

/* ---------- 作业分析试用到期 / 未开通：引导开通 ---------- */
.pay-gate {
  position: fixed;
  inset: 0;
  z-index: 82;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(122, 92, 24, 0.42);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  animation: hwEstFade 0.18s ease;
}

.pay-gate[hidden] {
  display: none;
}

.pay-gate-card {
  width: 100%;
  max-width: 360px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 26px 22px 20px;
  background: #fffdf7;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  animation: hwEstUp 0.22s cubic-bezier(0.22, 0.61, 0.36, 1);
}

.pay-gate-duck {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background-image: url('/assets/images/scene/default.jpg?v=mvgtlf4p');
  background-size: cover;
  background-position: center;
  border: 4px solid #fff;
  box-shadow: 0 6px 16px rgba(122, 92, 24, 0.16);
  margin-bottom: 14px;
}

.pay-gate-title {
  margin: 0 0 8px;
  font-size: 17px;
  font-weight: 800;
  color: var(--ink);
}

.pay-gate-desc {
  margin: 0 0 12px;
  font-size: 14px;
  line-height: 1.6;
  color: var(--ink-soft);
}

.pay-gate-hint {
  margin: 0 0 18px;
  font-size: 12.5px;
  color: var(--ink-faint);
}

.pay-gate-actions {
  display: flex;
  width: 100%;
  gap: 10px;
}

.pay-gate-actions .chip {
  flex: 1 1 auto;
  text-align: center;
  justify-content: center;
  padding: 11px 0;
}

/* ---- 会员支付弹层（底部弹出的收银台）---- */
.pay-sheet {
  position: fixed;
  inset: 0;
  z-index: 90;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  background: rgba(122, 92, 24, 0.42);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  animation: hwEstFade 0.18s ease;
}

.pay-sheet[hidden] {
  display: none;
}

.pay-sheet-card {
  position: relative;
  width: 100%;
  max-width: 480px;
  max-height: 92vh;
  overflow-y: auto;
  padding: 22px 20px calc(20px + env(safe-area-inset-bottom, 0px));
  background: #fffdf7;
  border-radius: 20px 20px 0 0;
  box-shadow: 0 -8px 30px rgba(122, 92, 24, 0.22);
  animation: paySheetUp 0.26s cubic-bezier(0.22, 0.61, 0.36, 1);
}

@keyframes paySheetUp {
  from {
    transform: translateY(24px);
    opacity: 0.4;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

.pay-sheet-close {
  position: absolute;
  top: 12px;
  right: 14px;
  width: 30px;
  height: 30px;
  border: 0;
  border-radius: 50%;
  background: rgba(122, 92, 24, 0.08);
  color: var(--ink-soft);
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
}

.pay-sheet-head {
  text-align: center;
  padding: 4px 0 12px;
}

.pay-sheet-badge {
  display: inline-block;
  padding: 2px 12px;
  border-radius: 999px;
  background: linear-gradient(135deg, #f6c453, #e0a622);
  color: #fff;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.08em;
  margin-bottom: 8px;
}

.pay-sheet-title {
  margin: 0;
  font-size: 19px;
  font-weight: 800;
  color: var(--ink);
}

.pay-sheet-sub {
  margin: 4px 0 0;
  font-size: 13px;
  color: var(--ink-soft);
}

.pay-sheet-perks {
  list-style: none;
  margin: 6px 0 16px;
  padding: 12px 14px;
  background: #fdf6e3;
  border-radius: 14px;
}

.pay-sheet-perks li {
  position: relative;
  padding-left: 22px;
  font-size: 13.5px;
  line-height: 2;
  color: var(--ink);
}

.pay-sheet-perks li::before {
  content: '✓';
  position: absolute;
  left: 0;
  color: #e0a622;
  font-weight: 800;
}

.pay-sheet-perks b {
  color: #c8871a;
}

.pay-sheet-plans {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 16px;
}

.pay-plan {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border: 2px solid #eee3c9;
  border-radius: 14px;
  background: #fff;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}

.pay-plan.is-active {
  border-color: #e0a622;
  background: #fffaf0;
}

.pay-plan-name {
  font-size: 15px;
  font-weight: 700;
  color: var(--ink);
}

.pay-plan-days {
  display: block;
  margin-top: 2px;
  font-size: 12px;
  color: var(--ink-faint);
}

.pay-plan-price {
  font-size: 20px;
  font-weight: 800;
  color: #c8871a;
}

.pay-plan-price .unit {
  font-size: 13px;
  font-weight: 600;
}

.pay-plan-tag {
  position: absolute;
  top: -9px;
  right: 12px;
  padding: 1px 8px;
  border-radius: 999px;
  background: #ff6b57;
  color: #fff;
  font-size: 11px;
  font-weight: 700;
}

.pay-sheet-actions {
  text-align: center;
}

.pay-sheet-actions .chip {
  width: 100%;
  padding: 13px 0;
  font-size: 16px;
}

.pay-sheet-note {
  margin: 10px 0 0;
  font-size: 11.5px;
  color: var(--ink-faint);
}

/* 「《会员服务说明》」链接（支付弹层底部） */
.pay-terms-link {
  margin-left: 4px;
  padding: 0;
  border: 0;
  background: none;
  font: inherit;
  font-size: 11.5px;
  color: var(--accent-dark);
  text-decoration: underline;
  cursor: pointer;
}

/* ---- 会员服务说明弹层（居中卡片）---- */
.terms {
  position: fixed;
  inset: 0;
  z-index: 120;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 22px;
  background: rgba(122, 92, 24, 0.42);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  animation: hwEstFade 0.18s ease;
}

.terms[hidden] {
  display: none;
}

.terms-card {
  position: relative;
  width: 100%;
  max-width: 460px;
  max-height: 84vh;
  overflow-y: auto;
  padding: 22px 20px 18px;
  background: #fffdf7;
  border-radius: 18px;
  box-shadow: var(--shadow);
}

.terms-close {
  position: absolute;
  top: 12px;
  right: 14px;
  width: 30px;
  height: 30px;
  border: 0;
  border-radius: 50%;
  background: rgba(122, 92, 24, 0.08);
  color: var(--ink-soft);
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
}

.terms-title {
  margin: 0 0 12px;
  font-size: 17px;
  font-weight: 800;
  color: var(--ink);
}

.terms-body {
  font-size: 12.5px;
  line-height: 1.75;
  color: var(--ink-soft);
}

.terms-body p {
  margin: 0 0 10px;
}

.terms-body b {
  color: var(--ink);
}

.terms-ok {
  margin-top: 10px;
  width: 100%;
}


@media (min-width: 820px) {
  :root {
    --dock-h: 124px;
  }
  .stage {
    padding: 0 40px 12px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .panel,
  .toast {
    animation: none;
  }
}

/* ================================================================== 科目编辑（管理页用） */

.subj-editor {
  width: 100%;
  text-align: left;
}

.subj-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.subj-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 8px 7px 10px;
  background: #fffdf7;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-sm);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.subj-item:focus-within {
  border-color: var(--accent);
  background: #fffdf7;
  box-shadow: 0 0 0 3px rgba(244, 179, 26, 0.14);
}

.subj-handle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 36px;
  flex: 0 0 auto;
  color: #c2cadb;
  cursor: grab;
  touch-action: none;
}

.subj-handle:active {
  color: var(--accent-dark);
}

.subj-handle svg {
  display: block;
  width: 17px;
  height: 17px;
}

.subj-input {
  flex: 1 1 auto;
  min-width: 0;
  font: inherit;
  font-size: 16px;
  font-weight: 600;
  color: var(--ink);
  background: transparent;
  border: none;
  padding: 7px 0;
  -webkit-user-select: text;
  user-select: text;
}

.subj-input:focus {
  outline: none;
}

.subj-input::placeholder {
  color: var(--ink-faint);
  font-weight: 500;
}

.subj-btn {
  appearance: none;
  flex: 0 0 auto;
  width: 34px;
  height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: #fffdf7;
  color: var(--ink-soft);
  font-size: 18px;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  transition: transform 0.12s ease, background 0.15s ease, color 0.15s ease,
    border-color 0.15s ease;
}

.subj-btn:active {
  transform: scale(0.9);
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent-dark);
}

.subj-btn.subj-del {
  color: var(--ink-faint);
}

.subj-btn.subj-del:active {
  background: var(--live-soft);
  border-color: var(--live);
  color: var(--live-dark);
}

.subj-add {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 12px;
  padding: 6px 6px 6px 14px;
  border: 1.5px dashed #e7dcc2;
  border-radius: var(--radius-sm);
  background: rgba(255, 252, 243, 0.6);
  transition: border-color 0.15s ease;
}

.subj-add:focus-within {
  border-color: var(--accent);
  border-style: solid;
}

.subj-add .subj-input {
  font-weight: 500;
}

.subj-add-btn {
  flex: 0 0 auto;
}

/* ================================================================== 科目管理页 */

.panel-manage {
  width: 100%;
  max-width: 460px;
  align-self: flex-start;
  margin: 0 auto;
  /* 子页面顶栏（返回 + 标题）约 50px，再留 12px 呼吸位 */
  padding: calc(var(--safe-top) + 62px) 2px 24px;
  text-align: left;
  animation: none;
  transform: translateX(100%);
  transition: transform 0.26s cubic-bezier(0.22, 0.61, 0.36, 1);
}

.panel-manage.is-in {
  transform: translateX(0);
}

.manage-head {
  margin: 0 0 16px;
}

/* 返回：一枚轻量的小胶囊按钮，带箭头（现在放在顶部栏左上角） */
.nav-back {
  appearance: none;
  display: inline-flex;
  align-items: center;
  gap: 3px;
  border: 1px solid var(--line);
  background: #fffdf7;
  font: inherit;
  font-size: 15px;
  font-weight: 600;
  color: #000;
  cursor: pointer;
  padding: 8px 16px 8px 11px;
  margin: 0;
  border-radius: var(--radius-pill);
  box-shadow: var(--shadow-sm);
  transition: transform 0.12s ease, background 0.15s ease;
}

.nav-back svg {
  display: block;
  width: 20px;
  height: 20px;
}

.nav-back:active {
  transform: scale(0.95);
  background: var(--accent-soft);
}

/* .nav-back 是 display:inline-flex，会盖掉浏览器默认的 [hidden]{display:none}，
   必须显式补一条，否则 hidden 后按钮仍会显示在作业页顶部 */
.nav-back[hidden] {
  display: none;
}

.manage-sub {
  font-size: 14px;
  line-height: 1.6;
  color: var(--ink-soft);
  margin: 6px 0 0;
}

/* 有两个孩子时，科目管理页顶部先选是谁的科目 */
.child-tabs {
  display: flex;
  gap: 8px;
  margin-top: 12px;
}

.child-tabs[hidden] {
  display: none;
}

.child-tab {
  appearance: none;
  font: inherit;
  font-size: 14px;
  font-weight: 700;
  color: var(--ink-soft);
  padding: 8px 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius-pill);
  background: #fffdf7;
  cursor: pointer;
  transition: background 0.12s ease, color 0.12s ease, border-color 0.12s ease;
}

.child-tab.is-on {
  background: var(--accent);
  border-color: var(--accent);
  color: #5f4200;
}

/* ================================================================== 孩子管理页 */

.child-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.child-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-sm);
}

.child-avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: linear-gradient(160deg, #ffd066, var(--accent));
  color: #5f4200;
  font-size: 20px;
  font-weight: 700;
  overflow: hidden;
  flex: 0 0 auto;
}

.child-avatar:has(.avatar-img) {
  background: #fbeecb;
}

.child-name-input {
  flex: 1 1 auto;
  min-width: 0;
  font: inherit;
  font-size: 16px;
  font-weight: 700;
  color: var(--ink);
  padding: 8px 10px;
  border: 1px solid transparent;
  border-radius: 10px;
  background: transparent;
  -webkit-user-select: text;
  user-select: text;
}

.child-name-input:focus {
  outline: none;
  border-color: var(--accent);
  background: #fffdf7;
  box-shadow: 0 0 0 3px rgba(244, 179, 26, 0.14);
}

.child-btn {
  appearance: none;
  flex: 0 0 auto;
  font: inherit;
  font-size: 13px;
  font-weight: 700;
  color: var(--ink-soft);
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-pill);
  background: #fffdf7;
  cursor: pointer;
  transition: transform 0.12s ease, background 0.15s ease, color 0.15s ease,
    border-color 0.15s ease;
}

.child-btn:active {
  transform: scale(0.94);
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent-dark);
}

.child-btn.child-del.is-danger {
  background: var(--live);
  border-color: var(--live);
  color: #fff;
}

.child-add-btn {
  width: 100%;
  margin-top: 14px;
  padding: 14px;
  font-size: 16px;
  text-align: center;
}

.child-add-btn[disabled] {
  opacity: 0.5;
  pointer-events: none;
}

/* ---------- 偏好设置页（时长选择 + 开关列表） ---------- */
.pref-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.pref-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 18px;
  background: #fffdf7;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-sm);
}

/* 可点击的行（倒计时/休息时长）：整行都是热区 */
.pref-row-btn {
  appearance: none;
  width: 100%;
  font: inherit;
  text-align: left;
  cursor: pointer;
  transition: background 0.15s ease, transform 0.1s ease;
}

.pref-row-btn:active {
  background: #f8efd6;
  transform: scale(0.99);
}

.pref-text {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}

.pref-name {
  font-size: 16px;
  font-weight: 700;
  color: var(--ink);
}

.pref-desc {
  font-size: 13px;
  line-height: 1.45;
  color: var(--ink-soft);
}

/* 右侧当前值 + 箭头（提示可点开选择） */
.pref-value {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 15px;
  font-weight: 800;
  color: var(--accent-dark);
  white-space: nowrap;
}

.pref-row-btn .pref-value::after {
  content: '›';
  font-size: 20px;
  line-height: 1;
  color: var(--ink-faint);
}

/* ---------- 偏好设置：时长选项底部弹层 ---------- */
.pref-pick {
  position: fixed;
  inset: 0;
  z-index: 72;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  background: rgba(122, 92, 24, 0.34);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
  animation: hwEstFade 0.18s ease;
}

.pref-pick[hidden] {
  display: none;
}

.pref-pick-card {
  width: 100%;
  max-width: 460px;
  max-height: 78vh;
  overflow-y: auto;
  background: #fffdf7;
  border-radius: 22px 22px 0 0;
  padding: 20px 18px calc(env(safe-area-inset-bottom) + 16px);
  box-shadow: var(--shadow);
  animation: hwEstUp 0.22s cubic-bezier(0.22, 0.61, 0.36, 1);
}

.pref-pick-title {
  margin: 0 0 4px;
  font-size: 17px;
  font-weight: 800;
  color: var(--ink);
  text-align: center;
}

.pref-pick-sub {
  margin: 0 0 16px;
  font-size: 13px;
  line-height: 1.5;
  color: var(--ink-soft);
  text-align: center;
}

.pref-chips {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 10px;
  margin-bottom: 18px;
}

.pref-chip {
  appearance: none;
  font: inherit;
  font-size: 15px;
  font-weight: 700;
  color: var(--ink);
  padding: 12px 0;
  background: #fffdf7;
  border: 1.5px solid var(--line);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.pref-chip:active {
  transform: scale(0.96);
}

.pref-chip.is-on {
  background: var(--accent);
  border-color: var(--accent);
  color: #4a3820;
  box-shadow: var(--shadow-accent);
}

.pref-pick-actions {
  display: flex;
}

.pref-pick-actions .chip {
  flex: 1 1 auto;
  text-align: center;
  justify-content: center;
  padding: 11px 0;
}

/* 开关：关=灰底、开=主色底；滑块平移 */
.switch {
  appearance: none;
  flex: 0 0 auto;
  position: relative;
  width: 52px;
  height: 30px;
  border: none;
  border-radius: var(--radius-pill);
  background: #e7dcc2;
  cursor: pointer;
  padding: 0;
  transition: background 0.18s ease;
}

.switch[aria-checked='true'] {
  background: var(--accent);
}

.switch-knob {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: #fffdf7;
  box-shadow: 0 1px 4px rgba(122, 92, 24, 0.28);
  transition: transform 0.18s ease;
}

.switch[aria-checked='true'] .switch-knob {
  transform: translateX(22px);
}

/* ---------- 场景设置页（场景网格：挑计时卡动画框的背景） ---------- */
.scene-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.scene-cell {
  position: relative;
  appearance: none;
  padding: 0;
  border: 2px solid var(--line);
  border-radius: var(--radius-sm);
  background: #fffdf7;
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  cursor: pointer;
  aspect-ratio: 1 / 1;
  transition: border-color 0.15s ease, transform 0.12s ease, box-shadow 0.15s ease;
}

.scene-cell:active {
  transform: scale(0.98);
}

/* 选中的场景：主色描边 + 右上角对勾 */
.scene-cell.is-selected {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(244, 179, 26, 0.18), var(--shadow-sm);
}

.scene-thumb {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  pointer-events: none;
  -webkit-user-drag: none;
}

/* 场景名：底部一条半透明渐变，白字压在图上 */
.scene-cell-name {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 16px 6px 6px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.01em;
  color: #fff;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  background: linear-gradient(180deg, rgba(0, 0, 0, 0), rgba(0, 0, 0, 0.46));
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.5);
}

.scene-check {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 26px;
  height: 26px;
  display: none;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: radial-gradient(circle at 32% 28%, #ffd66b, var(--accent));
  color: #fff;
  font-size: 15px;
  line-height: 1;
  border: 2px solid rgba(255, 255, 255, 0.92);
  box-shadow: 0 3px 8px rgba(122, 92, 24, 0.35), 0 0 0 1px rgba(122, 92, 24, 0.12);
  transform-origin: top right;
}

.scene-check svg {
  display: block;
}

.scene-cell.is-selected .scene-check {
  display: inline-flex;
  animation: scene-check-pop 0.24s cubic-bezier(0.22, 1.4, 0.44, 1) both;
}

@keyframes scene-check-pop {
  0% {
    transform: scale(0.4);
    opacity: 0;
  }
  100% {
    transform: scale(1);
    opacity: 1;
  }
}

/* 付费场景 + 会员不可用：加锁、变灰、不可点 */
.scene-cell.is-locked {
  cursor: pointer;
}

.scene-cell.is-locked .scene-thumb {
  filter: grayscale(0.7) brightness(0.82);
}

.scene-lock {
  position: absolute;
  inset: 0;
  background: rgba(28, 39, 64, 0.16);
}

/* 锁做成右上角一个小徽标：白色圆底 + 深色锁 */
.scene-lock svg {
  position: absolute;
  top: 5px;
  right: 5px;
  width: 11px;
  height: 11px;
  padding: 4px;
  box-sizing: content-box;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.92);
  color: #6b5a36;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.25);
}

.scene-actions {
  display: flex;
  margin-top: 18px;
}

.scene-confirm {
  flex: 1 1 auto;
  text-align: center;
  justify-content: center;
  padding: 13px 0;
  font-size: 16px;
}

.scene-confirm[disabled] {
  opacity: 0.45;
  pointer-events: none;
}

/* ---------- 倒计时画面下方：场景速选条（点画面浮出，不写名称） ---------- */
.scene-dock {
  position: absolute;
  left: 50%;
  bottom: 10px;
  z-index: 25;
  width: min(calc(100% - 20px), 520px);
  padding: 14px 10px 10px;
  border-radius: 20px;
  border: 1px solid rgba(140, 108, 42, 0.14);
  background: linear-gradient(180deg, rgba(255, 253, 247, 0.98), rgba(255, 246, 226, 0.96));
  box-shadow: 0 16px 40px rgba(90, 66, 18, 0.18), 0 2px 8px rgba(90, 66, 18, 0.06),
    inset 0 1px 0 rgba(255, 255, 255, 0.78);
  opacity: 0;
  transform: translate(-50%, 16px) scale(0.985);
  transition: opacity 0.18s ease, transform 0.24s cubic-bezier(0.22, 0.61, 0.36, 1);
}

.scene-dock.is-open {
  opacity: 1;
  transform: translate(-50%, 0) scale(1);
}

.scene-dock[hidden] {
  display: none;
}

/* 顶部小把手：一眼看出这是一层可以收起的浮层 */
.scene-dock::before {
  content: '';
  position: absolute;
  top: 5px;
  left: 50%;
  width: 30px;
  height: 3px;
  border-radius: 999px;
  background: rgba(122, 92, 24, 0.18);
  transform: translateX(-50%);
}

.scene-dock-strip {
  display: flex;
  gap: 8px;
  padding: 3px 1px;
  overflow-x: auto;
  overflow-y: hidden;
  scroll-snap-type: x proximity;
  scroll-padding-left: 0;
  overscroll-behavior-x: contain;
  touch-action: pan-x;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}

.scene-dock-strip::-webkit-scrollbar {
  display: none;
  width: 0;
  height: 0;
}

/* 还能往哪边滑：那一侧用 12px 淡出代替硬切的半张图 */
.scene-dock-strip.is-scroll-left {
  -webkit-mask-image: linear-gradient(90deg, transparent 0, #000 12px, #000 100%);
  mask-image: linear-gradient(90deg, transparent 0, #000 12px, #000 100%);
}

.scene-dock-strip.is-scroll-right {
  -webkit-mask-image: linear-gradient(90deg, #000 0, #000 calc(100% - 12px), transparent 100%);
  mask-image: linear-gradient(90deg, #000 0, #000 calc(100% - 12px), transparent 100%);
}

.scene-dock-strip.is-scroll-left.is-scroll-right {
  -webkit-mask-image: linear-gradient(
    90deg,
    transparent 0,
    #000 12px,
    #000 calc(100% - 12px),
    transparent 100%
  );
  mask-image: linear-gradient(
    90deg,
    transparent 0,
    #000 12px,
    #000 calc(100% - 12px),
    transparent 100%
  );
}

/* 一屏正好露出 4 张 + 半张：半张就是「还能往左滑」的提示 */
.scene-dock-item {
  position: relative;
  flex: 0 0 calc((100% - 32px) / 4.5);
  aspect-ratio: 4 / 3;
  padding: 0;
  border: 2px solid transparent;
  border-radius: 12px;
  background: #efe3c8;
  box-shadow: 0 2px 6px rgba(90, 66, 18, 0.08);
  overflow: hidden;
  cursor: pointer;
  scroll-snap-align: start;
  transition: transform 0.16s ease, border-color 0.18s ease, box-shadow 0.18s ease;
}

.scene-dock-item:active {
  transform: scale(0.94);
}

.scene-dock-item.is-selected {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(244, 179, 26, 0.22), 0 5px 12px rgba(224, 154, 10, 0.22);
}

.scene-dock-thumb {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  pointer-events: none;
  -webkit-user-drag: none;
}

.scene-dock-check {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 17px;
  height: 17px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  border: 1.5px solid rgba(255, 255, 255, 0.92);
  background: var(--accent);
  color: #fff;
  font-size: 10px;
  line-height: 1;
  box-shadow: 0 2px 6px rgba(122, 92, 24, 0.32);
  animation: scene-check-pop 0.24s cubic-bezier(0.22, 1.4, 0.44, 1) both;
}

.scene-dock-check svg {
  display: block;
}

.scene-dock-lock {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(28, 30, 38, 0.28);
  color: #fff;
  font-size: 15px;
}

.scene-dock-item.is-locked .scene-dock-thumb {
  filter: saturate(0.8) brightness(0.86);
}

html[data-theme="dark"] .scene-dock {
  border-color: rgba(84, 84, 94, 0.8);
  background: linear-gradient(180deg, rgba(38, 38, 44, 0.98), rgba(28, 28, 33, 0.97));
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.45), 0 2px 8px rgba(0, 0, 0, 0.24),
    inset 0 1px 0 rgba(255, 255, 255, 0.06);
}

html[data-theme="dark"] .scene-dock::before {
  background: rgba(255, 255, 255, 0.18);
}

html[data-theme="dark"] .scene-dock-item {
  background: #2a2a30;
}

html[data-theme="dark"] .scene-dock-check {
  border-color: rgba(28, 28, 33, 0.9);
}

/* ---------- 领养宠物页（宠物网格：默认小鸭子，其它花专注积分领养） ---------- */
.pet-head {
  margin: 0 0 14px;
}

/* 可用专注积分：一个金色小药丸，进页面第一眼就看余额 */
.pet-balance {
  display: inline-flex;
  align-items: baseline;
  gap: 4px;
  padding: 6px 14px;
  border-radius: 999px;
  border: 1px solid #f0c34a;
  background: linear-gradient(180deg, #fffdf4, #fff4d6);
  box-shadow: 0 2px 8px rgba(224, 154, 10, 0.16);
}

.pet-balance-label {
  font-size: 12px;
  color: #8a6a17;
}

.pet-balance-num {
  font-size: 19px;
  font-weight: 800;
  line-height: 1;
  color: #b8801a;
  letter-spacing: 0.01em;
}

.pet-balance-unit {
  font-size: 12px;
  color: #8a6a17;
}

.pet-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-top: 14px;
}

/* 底部「确认保存」：点它才真正换上并滑回倒计时页（与场景页的「确认使用」同一套观感） */
.pet-actions {
  display: flex;
  margin-top: 18px;
  padding-bottom: 8px;
}

.pet-confirm {
  flex: 1 1 auto;
  text-align: center;
  justify-content: center;
  padding: 13px 0;
  font-size: 16px;
}

.pet-confirm[disabled] {
  opacity: 0.45;
  pointer-events: none;
}

.pet-cell {
  position: relative;
  appearance: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 18px 8px 14px;
  border: 2px solid var(--line);
  border-radius: var(--radius-sm);
  background: #fffdf7;
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  font: inherit;
  color: inherit;
  text-align: center;
  transition: border-color 0.15s ease, transform 0.12s ease, box-shadow 0.15s ease;
}

.pet-cell:active {
  transform: scale(0.98);
}

/* 头像：精灵图里 idle 的第 1 格（按网格放大后只露左上角）——未领养也保持原色，不调灰 */
.pet-thumb {
  display: block;
  width: 76px;
  height: 76px;
  background-repeat: no-repeat;
  background-position: 0 0;
  pointer-events: none;
}

.pet-name {
  font-size: 14px;
  font-weight: 700;
  color: var(--ink);
  letter-spacing: 0.02em;
}

/* 名字下方那行：领养这只宠物要花的专注积分（浅灰小字，不抢名字；免费/已领养的不显示这行） */
.pet-price {
  font-size: 12px;
  font-weight: 600;
  line-height: 1.2;
  color: var(--ink-faint);
  letter-spacing: 0.02em;
}

/* 正在用的那只：金边 + 微光（右下角用下面那个金色对勾，不再另画一个绿勾） */
.pet-cell.is-active {
  border-color: #f0c34a;
  background: linear-gradient(180deg, #fffdf4, #fff4d6);
  box-shadow: 0 4px 12px rgba(224, 154, 10, 0.18);
}

/* 选中标记：右下角一个金色对勾（**只有「选中待确认」的那只打**；当前宠物靠金边+微光表示，不打勾） */
.pet-draft-check {
  position: absolute;
  right: 6px;
  bottom: 6px;
  width: 22px;
  height: 22px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: radial-gradient(circle at 32% 28%, #ffd66b, var(--accent));
  color: #fff;
  font-size: 14px;
  line-height: 1;
  border: 2px solid rgba(255, 255, 255, 0.92);
  box-shadow: 0 3px 8px rgba(122, 92, 24, 0.35), 0 0 0 1px rgba(122, 92, 24, 0.12);
  pointer-events: none;
  transform-origin: bottom right;
  animation: scene-check-pop 0.24s cubic-bezier(0.22, 1.4, 0.44, 1) both;
}

.pet-draft-check svg {
  display: block;
}

/* 可换的（已领养、不是当前）：主色描边（点一下选中，再点底部「确认保存」换上） */
.pet-cell.is-owned:not(.is-active) {
  border-color: rgba(244, 179, 26, 0.5);
}

/* 选中的（还没点「确认保存」）：主色描边 + 光环，一眼看出「要存的是这只」。
   写成 :not(.is-active) 是为了压过上面「已领养可换上」那条（已领养+选中也要吃这层更强的描边） */
.pet-cell.is-draft:not(.is-active) {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(244, 179, 26, 0.24), 0 4px 12px rgba(224, 154, 10, 0.18);
}

/* 还没领养、积分也不够：整格略压暗（点了只提示去专注写作业赚积分，仍然看得清是哪只宠物） */
.pet-cell.is-poor {
  cursor: pointer;
  opacity: 0.94;
}

.pet-lock svg {
  position: absolute;
  top: 5px;
  right: 5px;
  width: 11px;
  height: 11px;
  padding: 4px;
  box-sizing: content-box;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.92);
  color: #6b5a36;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.25);
}

/* ==================================================================
   外观设置：浅色（默认）/ 深色
   ================================================================== */

/* ---------- 偏好设置里的「浅色 / 深色」分段开关 ---------- */
.theme-seg {
  flex: 0 0 auto;
  display: inline-flex;
  gap: 2px;
  padding: 3px;
  background: #f4ead3;
  border: 1px solid var(--line);
  border-radius: var(--radius-pill);
}

.theme-opt {
  appearance: none;
  border: none;
  background: transparent;
  color: var(--ink-soft);
  font: inherit;
  font-size: 13px;
  font-weight: 700;
  padding: 7px 13px;
  border-radius: var(--radius-pill);
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s ease, color 0.15s ease, box-shadow 0.15s ease, transform 0.1s ease;
}

.theme-opt.is-on {
  background: #fffdf7;
  color: var(--ink);
  box-shadow: 0 1px 4px rgba(122, 92, 24, 0.14);
}

.theme-opt:active {
  transform: scale(0.96);
}

/* ================================================================== 底部三个菜单 */
.tabbar {
  position: relative;
  z-index: 30;
  flex: 0 0 auto;
  display: flex;
  align-items: stretch;
  justify-content: center;
  gap: 4px;
  padding: 5px 12px calc(env(safe-area-inset-bottom, 0px) + 5px);
  background: linear-gradient(180deg, rgba(255, 253, 246, 0.97), rgba(255, 248, 232, 0.94));
  border-top: 1px solid rgba(140, 108, 42, 0.12);
  box-shadow: 0 -6px 20px rgba(122, 92, 24, 0.055);
  backdrop-filter: blur(18px) saturate(1.5);
  -webkit-backdrop-filter: blur(18px) saturate(1.5);
}

/* 键盘弹出时（body.kb-open，见 app.js 的「键盘」一节）：底部菜单直接让位。
   安卓 Chrome 会把布局视口压到键盘上沿，普通流里的菜单就会被顶到键盘上方，
   既挡住正在录的那一科，下面还会留一条空白；收起后键盘一走菜单就回来，
   选中态不变（syncTabbar 的 class 一直挂着）。 */
body.kb-open .tabbar {
  display: none;
}

.tab {
  appearance: none;
  flex: 1 1 0;
  max-width: 160px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 2px 4px;
  border: none;
  border-radius: 14px;
  background: none;
  font: inherit;
  color: var(--ink-faint);
  cursor: pointer;
  transition: color 0.18s ease, background 0.18s ease, transform 0.1s ease;
}

.tab:active {
  transform: scale(0.96);
}

.tab-ico {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 24px;
  border-radius: 9px;
  transition: background 0.18s ease, color 0.18s ease, box-shadow 0.18s ease, transform 0.18s ease;
}

.tab-ico svg {
  display: block;
  width: 21px;
  height: 21px;
}

.tab-label {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.04em;
  line-height: 1;
  transition: color 0.18s ease;
}

.tab.is-on {
  color: var(--accent-dark);
}

.tab.is-on .tab-label {
  font-weight: 700;
}

.tab.is-on .tab-ico {
  background: var(--accent-soft);
  box-shadow: inset 0 0 0 1px rgba(244, 179, 26, 0.14);
  transform: translateY(-1px);
}

/* 中间的「作业上传」是个弹菜单的动作：图标常驻暖黄圆底，打开菜单时再亮一圈 */
.tab-upload .tab-ico {
  width: 32px;
  color: #5f4200;
  background: linear-gradient(160deg, #ffd877, var(--accent));
  box-shadow: 0 3px 10px rgba(224, 154, 10, 0.28), inset 0 1px 0 rgba(255, 255, 255, 0.42);
}

.tab-upload.is-on .tab-ico {
  background: linear-gradient(160deg, #ffd877, var(--accent));
  box-shadow: 0 0 0 3px var(--accent-soft), 0 6px 14px rgba(224, 154, 10, 0.38),
    inset 0 1px 0 rgba(255, 255, 255, 0.42);
}

/* ================================================================== 我的（个人中心） */
.panel-me {
  max-width: 560px;
  text-align: left;
  padding: calc(var(--safe-top) + 14px) 2px 24px;
}

.me-card {
  position: relative;
  padding: 18px 18px 14px;
  background: linear-gradient(165deg, #fffdf7 0%, #fff7e2 100%);
  border: 1px solid var(--line);
  border-radius: 22px;
  box-shadow: var(--shadow-sm);
}

.me-top {
  display: flex;
  align-items: center;
  gap: 12px;
}

.me-avatar {
  width: 54px;
  height: 54px;
  font-size: 22px;
  border: 2.5px solid #fffdf7;
  box-shadow: 0 5px 14px rgba(122, 92, 24, 0.15);
}

.me-id {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 7px;
  min-width: 0;
  flex: 1 1 auto;
}

.me-name {
  max-width: 100%;
  font-size: 21px;
  font-weight: 800;
  color: var(--ink);
  letter-spacing: 0.02em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.me-id .chip-badge-name {
  font-size: 12px;
}

.me-level {
  appearance: none;
  width: 100%;
  margin-top: 14px;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border: 1px solid rgba(244, 179, 26, 0.35);
  border-radius: 16px;
  background: var(--accent-soft);
  font: inherit;
  color: var(--ink);
  text-align: left;
  cursor: pointer;
  transition: transform 0.12s ease;
}

.me-level:active {
  transform: scale(0.985);
}

.me-level-main {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  min-width: 0;
  flex: 1 1 auto;
}

.me-level-title {
  max-width: 100%;
  font-size: 14px;
  font-weight: 800;
  color: var(--ink);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.me-cap {
  margin: 18px 6px 8px;
  font-size: 12px;
  font-weight: 700;
  color: var(--ink-faint);
  letter-spacing: 0.06em;
}

.me-list {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 20px;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

.me-row {
  appearance: none;
  width: 100%;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  border: none;
  border-bottom: 1px solid var(--line);
  background: none;
  font: inherit;
  font-size: 15px;
  font-weight: 600;
  color: var(--ink);
  text-align: left;
  cursor: pointer;
  transition: background 0.12s ease;
}

.me-row:last-child {
  border-bottom: none;
}

.me-row:active {
  background: var(--accent-soft);
}

.me-row[hidden] {
  display: none;
}

/* 右侧箭头用伪元素：按钮的 textContent 仍然只有项目名（测试/读屏都干净） */
.me-row::after {
  content: '›';
  flex: 0 0 auto;
  font-size: 18px;
  font-weight: 700;
  line-height: 1;
  color: var(--ink-faint);
}

.me-row-ico {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  flex: 0 0 auto;
  color: var(--accent-dark);
}

.me-row-ico svg {
  display: block;
  width: 22px;
  height: 22px;
}

.me-row-label {
  flex: 1 1 auto;
  min-width: 0;
}

.me-row-value {
  flex: 0 0 auto;
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-faint);
}

.me-foot {
  margin: 18px 0 4px;
  text-align: center;
  font-size: 12px;
  color: var(--ink-faint);
  letter-spacing: 0.02em;
}

/* ---------- 深色外观 ----------
   配色：深灰偏黑（不是纯黑），保留暖黄主色作点缀；小鸭子场景图保持原样，
   所以压在场景图上的倒计时 / 体力条 / 状态标签仍用原来的浅色半透明底。
   作用范围：整个前台页面（主页 + 管理/孩子/偏好/场景/勋章/领养 + 弹层）。
   ★ 后台 /admin 有自己的一套样式，不跟随这里。 */
html[data-theme="dark"] {
  /* 深色下浏览器自带的控件、键盘附属栏也跟着深色走，别再闪白 */
  color-scheme: dark;
  --bg-1: #131315;
  --bg-2: #1a1a1e;
  --surface: #222227;
  --ink: #efe9dd;
  --ink-soft: #b8afa0;
  --ink-faint: #8a8275;
  --line: #35353c;
  --accent-dark: #f2c451; /* 深色底上金色文字要亮一点才看得清 */
  --accent-soft: #3a2f1a;
  --live-soft: #3c2622;
  --shadow-sm: 0 2px 10px rgba(0, 0, 0, 0.32);
  --shadow: 0 12px 34px rgba(0, 0, 0, 0.46);
  --shadow-accent: 0 10px 24px rgba(244, 179, 26, 0.18);
}

/* 页面底色：深灰偏黑 + 顶部一点暖光（覆盖 body 原来的暖黄渐变） */
html[data-theme="dark"] body {
  background:
    radial-gradient(120% 90% at 50% -10%, rgba(244, 179, 26, 0.07) 0%, rgba(0, 0, 0, 0) 55%),
    linear-gradient(180deg, var(--bg-1) 0%, var(--bg-2) 100%);
  color: var(--ink);
}

/* 二级页顶栏 / 底部菜单：深色磨砂，和页面同色系 */
html[data-theme="dark"] .subbar {
  background: rgba(19, 19, 22, 0.78);
}
html[data-theme="dark"] .tabbar {
  background: linear-gradient(180deg, rgba(25, 25, 30, 0.97), rgba(19, 19, 23, 0.96));
  border-top-color: var(--line);
  box-shadow: 0 -6px 20px rgba(0, 0, 0, 0.28);
}

/* 胶囊（主色按钮保持暖黄，不参与） */
html[data-theme="dark"] .chip:not(.chip-primary):not(.chip-danger):not(.is-on) {
  background: rgba(38, 38, 44, 0.82);
  border-color: rgba(72, 72, 82, 0.9);
  color: var(--ink-soft);
}
html[data-theme="dark"] .chip:not(.chip-primary):not(.chip-danger):not(.is-on):active {
  background: #303039;
  color: var(--ink);
}

/* 下拉刷新胶囊 */
html[data-theme="dark"] .ptr-cap {
  background: rgba(30, 30, 35, 0.94);
  border-color: var(--line);
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.42), 0 1px 0 rgba(255, 255, 255, 0.04) inset;
}

html[data-theme="dark"] .menu-level-num.is-zero {
  background: #303036;
}

/* 作业卡片 */
html[data-theme="dark"] .hw-sec {
  background: linear-gradient(180deg, #232329 0%, #1f1f24 100%);
  border-color: var(--line);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.035) inset, 0 6px 18px rgba(0, 0, 0, 0.22);
}
html[data-theme="dark"] .hw-sec.is-editing {
  background: #26262c;
  border-color: #41414a;
}
/* 分享作业勾选页：这一行是整行可点的 <button>，清掉默认浅底（见下方 .hw-share-out .hw-row） */
html[data-theme="dark"] .hw-share-out .hw-row:active {
  background: rgba(255, 255, 255, 0.06);
}
html[data-theme="dark"] .hw-row:active {
  background: rgba(255, 255, 255, 0.05);
}
html[data-theme="dark"] .hw-row.is-dragging {
  background: #302b20;
  box-shadow: 0 16px 34px rgba(0, 0, 0, 0.55);
}
html[data-theme="dark"] .sort-placeholder {
  border-color: #5b4d31;
  background: rgba(244, 179, 26, 0.06);
}
html[data-theme="dark"] .hw-edit.is-on {
  background: #3a3020;
  color: #f2c451;
}

/* 打勾圈 / 输入框 / 添加按钮 */
html[data-theme="dark"] .hw-row:not(.is-done):not(.is-on) .hw-check {
  border-color: #5b513c;
  background: #1c1c20;
}
html[data-theme="dark"] .hw-text.is-editable {
  border-bottom-color: #5a5240;
}
html[data-theme="dark"] .hw-text-input,
html[data-theme="dark"] .hw-input {
  background: #1b1b1f;
  border-color: #6b5a32;
  color: var(--ink);
}
html[data-theme="dark"] .hw-input:focus {
  border-color: var(--accent);
}
html[data-theme="dark"] .hw-input::placeholder {
  color: #6f685a;
}
html[data-theme="dark"] .hw-add-btn {
  background: #f0c24e;
  color: #241800;
}
html[data-theme="dark"] .hw-add-btn:active {
  background: #d9a92f;
}
html[data-theme="dark"] .hw-row.is-done .hw-text {
  text-decoration-color: #6a6355;
}

/* 番茄钟卡片：深色相框 + 原来的场景图（图上标签保持浅底，见上方说明） */
html[data-theme="dark"] .hw-timer {
  background: rgba(31, 31, 36, 0.96);
  border-color: var(--line);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.38);
}
html[data-theme="dark"] .hw-timer.is-break {
  background: rgba(37, 33, 28, 0.97);
  border-color: #4c3f2c;
}
/* 倒计时/体力文字压在**场景图**上，而场景图仍是亮的：不能跟着页面把文字变浅，
   否则浅色天空上会出现看不见的浅色数字。场景自己配过颜色时（--scene-*）继续优先用它。
   （「专注中/休息中」提示是固定黑底白字，不参与深色外观。） */
html[data-theme="dark"] .hw-timer-clock {
  color: var(--scene-clock-color, #4a3820);
}
html[data-theme="dark"] .hw-timer.is-break .hw-timer-clock {
  color: var(--scene-clock-color, #b9791f);
}
html[data-theme="dark"] .hw-health-label {
  color: var(--scene-label-color, #8b7856);
}
html[data-theme="dark"] .hw-feed {
  background: #26262c;
  border-color: var(--line);
  color: var(--accent-dark);
}
html[data-theme="dark"] .hw-feed:disabled,
html[data-theme="dark"] .hw-feed.is-empty,
html[data-theme="dark"] .hw-feed.is-locked {
  background: #222226;
}

/* 主页面上的各类弹层：底部菜单 / 选孩子 / 分享 / 粘贴 / 识别预览 / 海报 / 确认 */
html[data-theme="dark"] .up-menu,
html[data-theme="dark"] .up-pick,
html[data-theme="dark"] .hw-paste,
html[data-theme="dark"] .hw-preview,
html[data-theme="dark"] .hw-confirm,
html[data-theme="dark"] .analyzing,
html[data-theme="dark"] .hw-poster {
  background: rgba(0, 0, 0, 0.55);
}
html[data-theme="dark"] .up-menu-card,
html[data-theme="dark"] .up-pick-card,
html[data-theme="dark"] .hw-paste-card,
html[data-theme="dark"] .hw-preview-card,
html[data-theme="dark"] .hw-confirm-card,
html[data-theme="dark"] .analyzing-card,
html[data-theme="dark"] .hw-poster-card {
  background: #232329;
  border: 1px solid var(--line);
}
/* 分享作业勾选页：弹层底比科目卡片（.hw-sec #232329）再暗一档，卡片才不会糊成一片 */
html[data-theme="dark"] .hw-share-out .hw-share-out-card {
  background: #1a1a1f;
}
html[data-theme="dark"] .up-menu-item,
html[data-theme="dark"] .up-pick-item,
html[data-theme="dark"] .hw-share-in-item {
  background: #26262c;
  border-color: var(--line);
  color: var(--ink);
}
html[data-theme="dark"] .up-menu-item:active,
html[data-theme="dark"] .up-pick-item:active {
  background: var(--accent-soft);
}
html[data-theme="dark"] .up-menu-item.is-locked {
  background: #222226;
  border-color: var(--line);
}
html[data-theme="dark"] .up-menu-item.is-locked .up-menu-ico {
  background: #2d2d33;
}
html[data-theme="dark"] .hw-paste-input,
html[data-theme="dark"] .hwp-text {
  background: #1b1b1f;
  border-color: var(--line);
  color: var(--ink);
}
html[data-theme="dark"] .hw-share-in-box {
  background: #1b1b1f;
  border-color: #5b513c;
}
html[data-theme="dark"] .hw-poster-imgwrap {
  background: #1b1b1f;
}
html[data-theme="dark"] .hw-confirm-desc,
html[data-theme="dark"] .hw-preview-hint,
html[data-theme="dark"] .hw-poster-hint {
  color: var(--ink-faint);
}

/* 轻提示：浅色页上是深底；深色页上改成比卡片亮一档的灰，避免糊在背景里 */
html[data-theme="dark"] .toast {
  background: rgba(58, 58, 66, 0.96);
  border-color: rgba(255, 255, 255, 0.12);
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.5);
}

/* ===== 深色：外观设置控件 ===== */
html[data-theme="dark"] .theme-seg {
  background: #2b2b31;
  border-color: var(--line);
}
html[data-theme="dark"] .theme-opt {
  color: var(--ink-soft);
}
html[data-theme="dark"] .theme-opt.is-on {
  background: #3a3a42;
  color: var(--ink);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.35);
}

/* ===== 深色：管理页 / 孩子页 / 偏好设置 ===== */
html[data-theme="dark"] .nav-back {
  background: #24242a;
  border-color: var(--line);
  color: var(--ink);
}
html[data-theme="dark"] .nav-back:active {
  background: var(--accent-soft);
}
html[data-theme="dark"] .subj-item {
  background: #232329;
  border-color: var(--line);
}
html[data-theme="dark"] .subj-item:focus-within {
  background: #26262c;
}
html[data-theme="dark"] .subj-handle {
  color: #6d6d78;
}
html[data-theme="dark"] .subj-btn {
  background: #26262c;
  border-color: var(--line);
  color: var(--ink-soft);
}
html[data-theme="dark"] .subj-add {
  background: rgba(35, 35, 41, 0.6);
  border-color: #44444d;
}
html[data-theme="dark"] .child-tab {
  background: #24242a;
  border-color: var(--line);
}
html[data-theme="dark"] .child-tab.is-on {
  background: var(--accent);
  border-color: var(--accent);
  color: #5f4200;
}
html[data-theme="dark"] .child-name-input:focus {
  background: #1f1f24;
}
html[data-theme="dark"] .child-btn {
  background: #26262c;
  border-color: var(--line);
}
html[data-theme="dark"] .pref-row {
  background: #232329;
  border-color: var(--line);
}
html[data-theme="dark"] .pref-row-btn:active {
  background: #2c2c33;
}
html[data-theme="dark"] .pref-pick {
  background: rgba(0, 0, 0, 0.55);
}
html[data-theme="dark"] .pref-pick-card {
  background: #232329;
}
html[data-theme="dark"] .pref-chip {
  background: #26262c;
  border-color: var(--line);
  color: var(--ink);
}
html[data-theme="dark"] .pref-chip.is-on {
  background: var(--accent);
  border-color: var(--accent);
  color: #4a3820;
}
html[data-theme="dark"] .switch {
  background: #45454f;
}
html[data-theme="dark"] .switch[aria-checked='true'] {
  background: var(--accent);
}
html[data-theme="dark"] .switch-knob {
  background: #f1ecdf;
}

/* ===== 深色：场景 / 勋章 / 宠物 ===== */
html[data-theme="dark"] .scene-cell {
  background: #232329;
  border-color: var(--line);
}
html[data-theme="dark"] .scene-cell.is-selected {
  border-color: var(--accent);
}
html[data-theme="dark"] .medal-cell {
  background: #232329;
  border-color: var(--line);
}
html[data-theme="dark"] .medal-cell.is-locked {
  background: #1e1e23;
}
html[data-theme="dark"] .medal-cell.is-earned {
  background: linear-gradient(180deg, #2e2a1d, #272318);
  border-color: #7a6122;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}
html[data-theme="dark"] .pet-balance {
  background: linear-gradient(180deg, #2e2a1d, #282317);
  border-color: #6b5620;
  box-shadow: none;
}
html[data-theme="dark"] .pet-balance-label,
html[data-theme="dark"] .pet-balance-unit {
  color: #d8b75a;
}
html[data-theme="dark"] .pet-balance-num {
  color: #f2c451;
}
html[data-theme="dark"] .pet-cell {
  background: #232329;
  border-color: var(--line);
}
html[data-theme="dark"] .pet-cell.is-active {
  background: linear-gradient(180deg, #2e2a1d, #282317);
  border-color: #7a6122;
}
html[data-theme="dark"] .pet-cell.is-owned:not(.is-active) {
  border-color: rgba(244, 179, 26, 0.42);
}
html[data-theme="dark"] .pet-cell.is-draft:not(.is-active) {
  border-color: var(--accent);
}

/* ===== 深色：全部写完后的完成表单 ===== */
html[data-theme="dark"] .hw-sum-child {
  border-color: #4a3f27;
  background-image: linear-gradient(180deg, #2a2619 0%, #222227 42%);
}
html[data-theme="dark"] .hw-done-row {
  border-bottom-color: #303036;
}
html[data-theme="dark"] .hw-done-text {
  text-decoration-color: #6a6355;
}
html[data-theme="dark"] .hw-sum-time {
  color: var(--accent-dark);
}
html[data-theme="dark"] .hw-done-bar {
  background: linear-gradient(135deg, #2a2619 0%, #232329 100%);
  border-color: #4a3f27;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.28);
}
html[data-theme="dark"] .hw-done-bar-sub {
  color: #c9a96a;
}
html[data-theme="dark"] .hw-done-bar-close {
  background: rgba(255, 255, 255, 0.06);
  border-color: #4a3f27;
  color: #c9a96a;
}

/* 禁用的主色按钮：深色下别再是「暗掉的黄」（会变成脏橄榄色），改成中性灰 */
html[data-theme="dark"] .chip-primary:disabled,
html[data-theme="dark"] .chip-primary[disabled] {
  background: #34343b;
  border-color: #3f3f47;
  color: var(--ink-faint);
  box-shadow: none;
  opacity: 1;
}

/* ===== 深色：登录 / 会员支付 / 会员说明 ===== */
html[data-theme="dark"] .login-gate {
  background:
    radial-gradient(120% 90% at 50% -10%, rgba(244, 179, 26, 0.06) 0%, rgba(0, 0, 0, 0) 55%),
    rgba(19, 19, 22, 0.97);
}
html[data-theme="dark"] .login-gate-card {
  background: #232329;
  border-color: var(--line);
}
html[data-theme="dark"] .login-gate-duck {
  border-color: #3a3a41;
}
html[data-theme="dark"] .pay-gate,
html[data-theme="dark"] .pay-sheet,
html[data-theme="dark"] .terms {
  background: rgba(0, 0, 0, 0.55);
}
html[data-theme="dark"] .pay-gate-card,
html[data-theme="dark"] .pay-sheet-card,
html[data-theme="dark"] .terms-card {
  background: #232329;
  border: 1px solid var(--line);
}
html[data-theme="dark"] .pay-sheet-card {
  box-shadow: 0 -8px 30px rgba(0, 0, 0, 0.5);
}
html[data-theme="dark"] .pay-gate-duck {
  border-color: #3a3a41;
}
html[data-theme="dark"] .pay-sheet-close,
html[data-theme="dark"] .terms-close {
  background: rgba(255, 255, 255, 0.08);
  color: var(--ink-soft);
}
html[data-theme="dark"] .pay-sheet-perks {
  background: #2a2a30;
}
html[data-theme="dark"] .pay-sheet-perks b,
html[data-theme="dark"] .pay-plan-price {
  color: var(--accent-dark);
}
html[data-theme="dark"] .pay-plan {
  background: #26262c;
  border-color: var(--line);
}
html[data-theme="dark"] .pay-plan.is-active {
  background: #2f2a1d;
  border-color: #7a6122;
}

/* ===== 深色：「我的」个人中心 ===== */
html[data-theme="dark"] .me-card {
  background: linear-gradient(165deg, #24242a 0%, #252117 100%);
  border-color: var(--line);
}
html[data-theme="dark"] .me-avatar {
  border-color: #24242a;
}
html[data-theme="dark"] .me-level {
  background: #2d2719;
  border-color: #4a3d20;
}
html[data-theme="dark"] .me-level-title {
  color: var(--ink);
}
