:root {
  --bg: #f4f2ee;
  --bg2: #ffffff;
  --bg3: #ece7dc;
  --line: #e2dccf;
  --text: #2f2a22;
  --text-dim: #857e72;
  --text-faint: #aca596;
  --accent: #a8843f;
  --ok: #6f9d5a;
  --warn: #c79a55;
  --bad: #c2655f;
  --radius: 12px;
  --font: "PingFang SC", "Microsoft YaHei", "Noto Sans CJK SC", system-ui, sans-serif;
  --tabbar-h: 62px;
}

/* ---- 深色模式 ---- */
:root[data-theme="dark"] {
  --bg: #1b1813;
  --bg2: #242018;
  --bg3: #302a20;
  --line: #3b3428;
  --text: #ece5d6;
  --text-dim: #b3aa97;
  --text-faint: #7e7563;
  --accent: #c9a35e;
  --ok: #8db77a;
  --warn: #d0a560;
  --bad: #d67f77;
  color-scheme: dark;
}
:root[data-theme="dark"] body { background: radial-gradient(1200px 600px at 50% -10%, #2b2519 0%, var(--bg) 60%); }
:root[data-theme="dark"] .warn-banner { background: linear-gradient(120deg, #372c1c, #3a2a17); border-color: #584526; color: #e0c07c; }
:root[data-theme="dark"] .warn-banner.strong { background: linear-gradient(120deg, #392321, #462726); border-color: #6b3b36; color: #e59a92; }
:root[data-theme="dark"] .quote-box { background: linear-gradient(135deg, #33291a, #3a2b16); border-color: #584526; color: #e0c07c; }
:root[data-theme="dark"] .visualize-box { background: linear-gradient(135deg, #2e2619, #3a2b16); }
:root[data-theme="dark"] .praise-card { background: linear-gradient(120deg, #33291a, #3a2b16); border-color: #584526; color: #e0c07c; }
:root[data-theme="dark"] .badge-item.on { border-color: #584526; background: linear-gradient(135deg, #33291a, #3a2b16); }
:root[data-theme="dark"] #topbar { background: rgba(36, 32, 24, 0.86); }
:root[data-theme="dark"] #tabbar { background: rgba(36, 32, 24, 0.92); }
:root[data-theme="dark"] .today-hero { background: linear-gradient(135deg, #2c2416, #3a2b16); border-color: #584526; }
:root[data-theme="dark"] .hero-pct::after { background: var(--bg2); }
:root[data-theme="dark"] .hero-pct { background: conic-gradient(var(--accent) calc(var(--pct,50) * 1%), #3b3428 0); }
:root[data-theme="dark"] .next-milestone { background: var(--bg2); border-color: #584526; }
:root[data-theme="dark"] .chip, :root[data-theme="dark"] .lp-btn { box-shadow: 0 6px 24px rgba(0,0,0,0.35); }

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }

button { touch-action: manipulation; }

html, body { height: 100%; }

body {
  background: radial-gradient(1200px 600px at 50% -10%, #ece5d5 0%, var(--bg) 60%);
  color: var(--text);
  font-family: var(--font);
  line-height: 1.6;
}

main {
  padding-bottom: calc(var(--tabbar-h) - 20px);
}

a { color: var(--accent); text-decoration: none; }

.hidden { display: none !important; }

/* ---- banners ---- */
.warn-banner {
  background: linear-gradient(120deg, #f3e7d2, #f0dfc0);
  border: 1px solid #e0c896;
  border-radius: var(--radius);
  padding: 12px 16px;
  color: var(--accent);
  font-weight: 600;
  letter-spacing: 1px;
  margin-bottom: 14px;
}
.warn-banner.strong {
  background: linear-gradient(120deg, #f8e3e0, #f5d6d1);
  border-color: #e2b6b0;
  color: var(--bad);
}

/* ---- 吸引力法则 ---- */
.quote-box {
  background: linear-gradient(135deg, #f6efdf, #f0e2c0);
  border: 1px solid #e6d5ae;
  border-radius: 10px;
  padding: 14px 16px;
  font-size: 15px;
  color: var(--accent);
  letter-spacing: 1px;
  margin-bottom: 12px;
}
.affirmations { display: flex; flex-direction: column; gap: 8px; }
.affirm-line {
  background: var(--bg3);
  border-radius: 8px;
  padding: 9px 12px;
  font-size: 14px;
  color: var(--text);
  border-left: 3px solid var(--accent);
}
.visualize-box {
  display: flex; justify-content: center; align-items: center;
  background: linear-gradient(135deg, #efe7d4, #e3d3b0);
  border-radius: 12px;
  padding: 26px 12px;
  margin: 14px 0;
}
.visualize-display {
  font-size: 26px;
  font-weight: 700;
  letter-spacing: 2px;
  color: var(--accent);
}
.intention-card { border-left: 4px solid var(--accent); }
.intention-card .p-tip { color: var(--text); font-weight: 500; margin-top: 6px; }
.intention-card .p-standard { color: var(--text-dim); font-size: 13px; margin-top: 6px; }

/* ---- 激励：徽章 / 夸赞 / 倒计时 / 誓言 ---- */
.praise-card {
  background: linear-gradient(120deg, #f6efdf, #f0e2c0);
  border: 1px solid #e6d5ae;
  color: var(--accent);
  font-weight: 600;
  letter-spacing: 1px;
  text-align: center;
}
.next-milestone {
  background: var(--bg2);
  border: 1px dashed var(--accent);
  border-radius: var(--radius);
  padding: 12px 16px;
  color: var(--text-dim);
  font-size: 14px;
  margin-bottom: 14px;
  text-align: center;
}
.next-milestone b { color: var(--accent); font-size: 17px; }
.next-milestone.done { border-color: var(--ok); color: var(--ok); }
.badges { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.badge-item {
  text-align: center;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px 4px;
  opacity: 0.45;
  filter: grayscale(1);
}
.badge-item.on { opacity: 1; filter: none; border-color: #e0c896; background: linear-gradient(135deg, #f6efdf, #f0e2c0); }
.badge-ico {
  width: 38px; height: 38px; margin: 0 auto 6px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg3); color: var(--text-dim);
  font-size: 14px; font-weight: 700;
}
.badge-item.on .badge-ico { background: var(--accent); color: #1a1206; }
.badge-name { font-size: 12px; color: var(--text-dim); }
.vow-item {
  background: var(--bg3);
  border-radius: 10px;
  padding: 10px 12px;
  margin-bottom: 8px;
  font-size: 14px;
}
.badge-milestone { color: var(--accent); border-color: var(--accent); }
.vow-live { color: var(--accent); border-color: var(--accent); }
.vow-ok { color: var(--ok); border-color: var(--ok); }
.vow-bad { color: var(--bad); border-color: var(--bad); }

/* ---- topbar ---- */
#topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 18px;
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.brand { font-size: 18px; letter-spacing: 4px; color: var(--accent); font-weight: 600; }
#back-btn {
  background: none; border: none; cursor: pointer;
  font-size: 28px; line-height: 1; color: var(--text-dim);
  padding: 0 4px; margin-right: -6px;
}
#back-btn:hover { color: var(--accent); }
#theme-btn {
  background: none; border: none; cursor: pointer;
  font-size: 17px; color: var(--text-dim); padding: 4px 8px;
}
#theme-btn:hover { color: var(--accent); }
.userchip { color: var(--text-dim); font-size: 13px; white-space: nowrap; }

/* ---- 底部 Tab 栏 ---- */
#tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
  display: flex; align-items: stretch;
  max-width: 620px; margin: 0 auto;
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(14px) saturate(1.3);
  border-top: 1px solid var(--line);
  box-shadow: 0 -6px 24px rgba(60, 45, 20, 0.06);
  padding-bottom: env(safe-area-inset-bottom);
}
#tabbar button {
  flex: 1; background: none; border: none; position: relative;
  padding: 9px 4px 10px;
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  color: var(--text-faint); font-family: var(--font); cursor: pointer;
}
#tabbar .tb-ico { font-size: 21px; line-height: 1; transition: transform .18s ease; }
#tabbar .tb-label { font-size: 11px; letter-spacing: 1px; transition: color .18s ease; }
#tabbar button.active { color: var(--accent); }
#tabbar button.active .tb-ico { transform: translateY(-1px) scale(1.1); }
#tabbar button.active::before {
  content: ""; position: absolute; top: 0; left: 50%; transform: translateX(-50%);
  width: 36px; height: 3px; border-radius: 0 0 4px 4px; background: var(--accent);
}

/* ---- 底部主操作（保存今日打卡） ---- */
.save-float {
  position: fixed; left: 0; right: 0;
  bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom) - 6px);
  z-index: 30;
  max-width: 620px; margin: 0 auto;
  padding: 10px 14px;
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(14px) saturate(1.3);
  border-top: 1px solid var(--line);
  box-shadow: 0 -6px 24px rgba(60, 45, 20, 0.06);
}
.save-float:empty { display: none; }
.save-float-btn {
  pointer-events: auto; width: 100%;
  min-height: 50px; font-size: 16px; letter-spacing: 3px; font-weight: 700;
  border-radius: 999px;
  box-shadow: 0 6px 18px rgba(168, 132, 63, 0.3);
  animation: floatIn .4s ease both;
}
#save-float .save-float-btn {
  min-height: 50px; font-size: 16px; border-radius: 999px; letter-spacing: 3px;
}
@keyframes floatIn { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }

/* ---- 计划切换 chips ---- */
.plan-chips { display: flex; gap: 8px; overflow-x: auto; padding: 2px 2px 6px; -webkit-overflow-scrolling: touch; scrollbar-width: none; }
.plan-chips::-webkit-scrollbar { display: none; }
.plan-chip {
  flex-shrink: 0; background: var(--bg2); border: 1px solid var(--line); color: var(--text-dim);
  border-radius: 999px; padding: 7px 14px; font-size: 13px; font-family: var(--font); cursor: pointer;
  transition: all .18s ease; touch-action: manipulation;
}
.plan-chip.active { background: var(--accent); border-color: var(--accent); color: #1a1206; font-weight: 600; }
.cat-tags { margin-bottom: 12px; }
.coach-banner {
  width: 100%; display: flex; align-items: center; justify-content: space-between; gap: 10px;
  font-family: var(--font); font-size: 14px; color: var(--text); text-align: left;
  cursor: pointer; transition: all .18s ease;
}
.coach-banner:hover { border-color: var(--accent); }
.coach-banner .coach-banner-go { color: var(--accent); font-weight: 600; white-space: nowrap; }

/* ---- 折叠分区 ---- */
details.sec-details summary {
  list-style: none; cursor: pointer; user-select: none;
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  font-size: 15px; font-weight: 600; color: var(--text);
}
details.sec-details summary::-webkit-details-marker { display: none; }
details.sec-details summary::after { content: "⌄"; color: var(--accent); font-size: 20px; line-height: 1; transition: transform .22s ease; }
details.sec-details[open] summary::after { transform: rotate(180deg); }
.sec-title { display: flex; align-items: center; gap: 8px; }
.sec-hint { color: var(--text-faint); font-size: 12px; font-weight: 400; white-space: nowrap; }
.sec-body { margin-top: 14px; }
.sec-inline { margin-top: 14px; border-top: 1px dashed var(--line); padding-top: 6px; }

/* ---- layout ---- */
.view { max-width: 1180px; margin: 0 auto; padding: 16px 14px 40px; }
#view-admin { max-width: 1280px; }
#view-today { padding-bottom: calc(var(--tabbar-h) + 11px); }
#app-view > section:not(.hidden) { animation: viewIn .32s ease both; }
@keyframes viewIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
.card {
  background: var(--bg2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 22px;
  margin-bottom: 18px;
  transition: box-shadow .22s ease, border-color .22s ease, transform .22s ease;
}
@media (hover: hover) {
  .card:hover { box-shadow: 0 10px 28px rgba(60, 45, 20, 0.09); }
  .btn:active { transform: scale(0.96); }
}
.card h2 { font-size: 16px; color: var(--accent); margin-bottom: 14px; letter-spacing: 2px; font-weight: 600; }
.card h3 { font-size: 14px; color: var(--text); margin: 14px 0 8px; }

/* ---- 今日页 hero ---- */
.today-hero {
  position: relative; overflow: hidden;
  border: 1px solid #e4d3ac;
  background: linear-gradient(135deg, #fbf6ea, #f2e6c8);
}
.today-hero::after {
  content: "☯"; position: absolute; right: -18px; bottom: -34px;
  font-size: 120px; opacity: 0.06; color: var(--accent);
}
.hero-name { font-size: 20px; font-weight: 700; letter-spacing: 2px; color: var(--accent); }
.hero-title { font-size: 13px; color: var(--text-dim); margin-top: 2px; }
.hero-day { font-size: 15px; margin-top: 8px; color: var(--text); }
.hero-day b { font-size: 26px; color: var(--accent); font-weight: 800; }
.hero-stage { font-size: 13px; color: var(--text); margin-top: 12px; background: rgba(168, 132, 63, 0.10); border-radius: 8px; padding: 6px 10px; }
.hero-pct {
  width: 76px; height: 76px; border-radius: 50%; flex-shrink: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  background: conic-gradient(var(--accent) calc(var(--pct, 50) * 1%), #e6dcc4 0);
  position: relative;
}
.hero-pct::after { content: ""; position: absolute; inset: 6px; border-radius: 50%; background: var(--bg2); }
.hero-pct span { position: relative; font-size: 22px; font-weight: 800; color: var(--accent); line-height: 1.1; }
.hero-pct em { position: relative; font-style: normal; font-size: 11px; color: var(--text-dim); }
.hero-standard { margin-top: 8px; }

.bar { height: 8px; border-radius: 999px; background: var(--bg3); overflow: hidden; margin-top: 12px; }
.bar-fill { display: block; height: 100%; border-radius: 999px; background: linear-gradient(90deg, var(--accent), #c9a35e); transition: width .5s ease; }
.bar-fill.ok { background: linear-gradient(90deg, var(--ok), #8db77a); }
.bar-sm { height: 6px; margin-top: 10px; }
.task-progress { color: var(--ok); font-size: 13px; font-weight: 600; }

/* ---- 折叠仪式卡 ---- */
.ritual-card summary {
  list-style: none; cursor: pointer; user-select: none;
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  font-size: 15px; font-weight: 600; color: var(--text);
}
.ritual-card summary::-webkit-details-marker { display: none; }
.ritual-card summary::after { content: "⌄"; color: var(--accent); font-size: 20px; line-height: 1; transition: transform .22s ease; }
.ritual-card[open] summary::after { transform: rotate(180deg); }
.ritual-badge { background: var(--bg3); color: var(--text-dim); border-radius: 999px; padding: 2px 10px; font-size: 11px; font-weight: 500; white-space: nowrap; }
.ritual-body { margin-top: 14px; }

/* ---- 任务完成动效 ---- */
.chk.task-done label { color: var(--text-faint); text-decoration: line-through; }
.chk.task-done { animation: taskPop .4s ease; }
@keyframes taskPop {
  0% { background: rgba(111, 157, 90, 0.28); }
  100% { background: transparent; }
}

details.card summary { cursor: pointer; font-size: 14px; color: var(--text); user-select: none; }
details.card summary::-webkit-details-marker { color: var(--accent); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
@media (max-width: 720px) { .grid2 { grid-template-columns: 1fr; } }

.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.spread { justify-content: space-between; }
.muted { color: var(--text-dim); font-size: 13px; }
.faint { color: var(--text-faint); font-size: 12px; }

/* ---- forms ---- */
input, textarea, select {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 14px;
  font-family: var(--font);
  outline: none;
}
input:focus, textarea:focus, select:focus { border-color: var(--accent); }
textarea { resize: vertical; min-height: 70px; }
label { font-size: 13px; color: var(--text-dim); display: block; margin: 12px 0 6px; }
.btn {
  background: var(--bg3);
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: 8px;
  padding: 9px 18px;
  font-size: 14px;
  cursor: pointer;
  font-family: var(--font);
}
.btn:hover { border-color: var(--accent); color: var(--accent); }
.btn.primary { background: var(--accent); color: #1a1206; border-color: var(--accent); font-weight: 600; }
.btn.primary:hover { filter: brightness(1.1); color: #1a1206; }
.btn.danger { border-color: var(--bad); color: var(--bad); }
.btn.small { padding: 4px 10px; font-size: 12px; }
a.btn { display: inline-block; }
.plan-select { padding: 6px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--bg2); color: var(--text); font-family: var(--font); font-size: 13px; width: auto; min-width: 200px; max-width: 100%; }
.tag { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 12px; background: var(--bg3); color: var(--text-dim); white-space: nowrap; }
.tag.ok { background: rgba(111, 157, 90, 0.16); color: var(--ok); }
.faint.small { font-size: 11px; }

/* ---- auth ---- */
#auth-view { max-width: 420px; padding-top: 80px; }
.auth-tabs { display: flex; margin-bottom: 20px; border-bottom: 1px solid var(--line); }
.auth-tabs button {
  flex: 1; background: none; border: none; color: var(--text-dim);
  padding: 10px; font-size: 15px; cursor: pointer; border-bottom: 2px solid transparent; font-family: var(--font);
}
.auth-tabs button.active { color: var(--accent); border-bottom-color: var(--accent); }
.err { color: var(--bad); font-size: 13px; margin-top: 10px; min-height: 18px; }
.welcome { text-align: center; margin-bottom: 24px; color: var(--text-dim); font-size: 14px; letter-spacing: 2px; }

/* ---- today: timer ---- */
.timer-box { text-align: center; padding: 12px 0 4px; }
.timer-display { font-size: 52px; font-weight: 300; letter-spacing: 3px; color: var(--accent); font-variant-numeric: tabular-nums; }
.presets { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; margin: 16px 0; }
.presets button.active { border-color: var(--accent); color: var(--accent); }
.timer-controls { display: flex; gap: 12px; justify-content: center; }

/* ---- practice sound ---- */
.sound-row { display: flex; align-items: center; gap: 10px; justify-content: center; margin-top: 14px; }
.sound-btns { display: flex; gap: 6px; flex-wrap: wrap; }
.sound-btn.active { border-color: var(--accent); color: var(--accent); }

/* ---- checklist ---- */
.chk { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px dashed var(--line); font-size: 14px; }
.chk:last-child { border-bottom: none; }
.chk input { width: auto; }
.chk .tag { margin-left: auto; font-size: 12px; color: var(--text-faint); }
.chk.bad-hit { color: var(--bad); }

/* ---- stars ---- */
.stars { display: flex; gap: 6px; }
.stars button { background: none; border: none; font-size: 22px; color: var(--text-faint); cursor: pointer; padding: 0 2px; }
.stars button.on { color: var(--accent); }
.stars-label { margin-left: 12px; font-size: 12px; color: var(--text-dim); }

/* ---- progress ring ---- */
.ring-wrap { text-align: center; }
.ring-svg { transform: rotate(-90deg); }
.ring-text { font-size: 13px; fill: var(--text-dim); }
.ring-num { font-size: 30px; font-weight: 600; fill: var(--accent); }
.stats-row { display: flex; justify-content: space-around; text-align: center; margin-top: 16px; }
.stat-num { font-size: 22px; color: var(--accent); font-weight: 600; }
.stat-label { font-size: 12px; color: var(--text-dim); margin-top: 2px; }

/* ---- heatmap ---- */
.heatmap { display: grid; grid-template-columns: repeat(10, 1fr); gap: 4px; }
.hm-cell { aspect-ratio: 1; border-radius: 3px; background: var(--bg3); position: relative; }
.hm-cell[data-min="0"] { background: var(--bg3); }
.hm-cell.today { outline: 1px solid var(--accent); }

/* ---- leaderboard / feed / circles ---- */
.list-item {
  display: flex; align-items: center; gap: 14px;
  padding: 12px 14px; border-bottom: 1px solid var(--line);
}
.list-item:last-child { border-bottom: none; }
.rank { width: 28px; height: 28px; border-radius: 50%; background: var(--bg3); color: var(--accent);
  display: flex; align-items: center; justify-content: center; font-size: 13px; flex-shrink: 0; }
.rank.top { background: var(--accent); color: #1a1206; font-weight: 700; }
.name { font-weight: 500; }
.detail { margin-left: auto; color: var(--text-dim); font-size: 13px; white-space: nowrap; }
.avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--bg3); border: 1px solid var(--line);
  display: flex; align-items: center; justify-content: center; color: var(--accent); font-size: 15px; flex-shrink: 0; }

.tabs { display: flex; gap: 8px; margin-bottom: 16px; flex-wrap: wrap; }

.feed-item { padding: 14px; border-bottom: 1px solid var(--line); }
.feed-item .msg { font-size: 15px; }
.feed-item .time { color: var(--text-faint); font-size: 12px; margin-top: 4px; }

.circle-row { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-bottom: 1px solid var(--line); cursor: pointer; }
.circle-row:hover { background: var(--bg3); }
.circle-row:last-child { border-bottom: none; }
.circle-name { font-weight: 500; }
.circle-count { margin-left: auto; color: var(--text-dim); font-size: 13px; }
.circle-mine { color: var(--ok); font-size: 12px; border: 1px solid var(--ok); border-radius: 6px; padding: 1px 6px; }

/* ---- phase banner ---- */
.phase {
  border-left: 3px solid var(--accent);
  background: var(--bg3);
  border-radius: 0 var(--radius) var(--radius) 0;
  padding: 12px 16px;
  margin-bottom: 18px;
}
.phase .p-name { color: var(--accent); font-weight: 600; letter-spacing: 1px; }
.phase .p-tip { font-size: 13px; color: var(--text-dim); margin-top: 4px; }
.phase .p-standard { font-size: 12px; color: var(--text-faint); margin-top: 4px; }

/* ---- toast ---- */
.toast {
  position: fixed; top: 70px; left: 50%; transform: translateX(-50%);
  background: var(--bg2); border: 1px solid var(--accent); color: var(--text);
  padding: 10px 20px; border-radius: 10px; z-index: 50; font-size: 14px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.14);
  animation: toastIn .28s ease both;
}
@keyframes toastIn { from { opacity: 0; transform: translate(-50%, -8px); } to { opacity: 1; transform: translate(-50%, 0); } }

/* ---- admin ---- */
.table-wrap { overflow-x: auto; }
.admin-table { width: 100%; table-layout: fixed; border-collapse: collapse; font-size: 13px; }
.admin-table th, .admin-table td { text-align: left; padding: 5px 7px; border-bottom: 1px solid var(--line); white-space: nowrap; overflow-wrap: anywhere; }
.admin-table th { color: var(--text-dim); font-weight: 500; }
.admin-table tr:hover td { background: var(--bg3); }
.admin-table th:nth-child(1) { width: 7%; }
.admin-table th:nth-child(2) { width: 20%; }
.admin-table th:nth-child(3) { width: 12%; }
.admin-table th:nth-child(4), .admin-table th:nth-child(5), .admin-table th:nth-child(6) { width: 7%; }
.admin-table th:nth-child(7) { width: 12%; }
.admin-table th:nth-child(8) { width: 11%; }
.admin-table th:nth-child(9) { width: 17%; }
.admin-actions { display: flex; gap: 6px; flex-wrap: nowrap; }
.admin-table td.admin-actions-cell { white-space: nowrap; }
.admin-actions .btn { flex-shrink: 0; margin: 2px 0; }
.admin-table .num { text-align: right; }
.users-table th, .users-table td { white-space: nowrap; }
.users-table th:nth-child(1) { width: 6%; }
.users-table th:nth-child(2) { width: 16%; }
.users-table th:nth-child(3) { width: 11%; }
.users-table th:nth-child(4), .users-table th:nth-child(5), .users-table th:nth-child(6) { width: 6%; }
.users-table th:nth-child(7) { width: 11%; }
.users-table th:nth-child(8) { width: 12%; }
.users-table th:nth-child(9) { width: 26%; }
.badge { display: inline-block; font-size: 11px; border: 1px solid var(--line); color: var(--text-dim); border-radius: 6px; padding: 1px 6px; margin-right: 4px; }
.badge-admin { color: var(--accent); border-color: var(--accent); }
.badge-ban { color: var(--bad); border-color: var(--bad); }
.muted.small { font-size: 12px; }

/* ================= mobile (<= 720px) ================= */
@media (max-width: 720px) {
  body { line-height: 1.6; }

  #topbar { padding: 8px 12px; gap: 8px; }
  .brand { font-size: 15px; letter-spacing: 2px; }
  .userchip { display: none; }

  #back-btn { font-size: 26px; }
  #theme-btn { font-size: 16px; }

  .view { padding: 14px 12px 8px; }
  .card { padding: 16px; margin-bottom: 12px; border-radius: 14px; }
  .grid2 { gap: 12px; }
  .row { gap: 8px; }

  input, textarea, select { padding: 12px; font-size: 15px; }
  label { font-size: 14px; }

  .btn { padding: 11px 16px; font-size: 15px; min-height: 42px; }
  .btn.small { padding: 8px 13px; font-size: 13px; min-height: 36px; }

  .plan-select { min-width: 0; width: 100%; }

  #auth-view { padding-top: 32px; }

  .timer-display { font-size: 44px; }
  .ring-svg { width: 120px; height: 120px; }
  .stat-num { font-size: 18px; }
  .stat-label { font-size: 12px; }

  .heatmap { gap: 3px; }
  .chk { gap: 8px; padding: 10px 0; }
  .stars button { font-size: 26px; }
  .stars .star-label { font-size: 13px; }

  .list-item { padding: 11px 8px; gap: 10px; }
  .circle-row { padding: 11px 8px; }
  .feed-item { padding: 12px 8px; }
  .rank { width: 26px; height: 26px; font-size: 12px; }

  .phase { padding: 10px 12px; margin-bottom: 14px; }

  .today-hero { padding: 18px 16px; }
  .hero-pct { width: 66px; height: 66px; }
  .hero-pct span { font-size: 19px; }

  .save-float { padding: 8px 12px; }

  .tabs { gap: 6px; margin-bottom: 12px; }

  .toast { top: 58px; width: calc(100% - 32px); text-align: center; }

  .table-wrap { margin: 0 -4px; }
  .admin-table { font-size: 12px; }
  .admin-table th, .admin-table td { padding: 5px 6px; white-space: normal; overflow-wrap: anywhere; }
  .admin-table td.admin-actions-cell .admin-actions { flex-direction: column; align-items: flex-start; gap: 5px; }
  .admin-table td.admin-actions-cell .admin-actions .btn { width: 100%; text-align: center; }
  .users-table th, .users-table td { white-space: nowrap; }

  .muted.small { font-size: 11px; }
}

/* ================= coach ================= */
.badge-gold { color: #a8843f; border-color: #a8843f; background: rgba(168, 132, 63, 0.12); }
.badge-ok { color: var(--ok); border-color: var(--ok); }

.coach-promo {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-left: 4px solid var(--accent);
}
.coach-promo h2 { margin-bottom: 6px; }

.coach-card { padding: 11px 16px; }
.coach-card h2 { font-size: 1rem; margin-bottom: 0; }
.coach-card .muted { font-size: 12px; line-height: 1.4; }
.coach-card .tag { padding: 1px 6px; font-size: 11px; }
.coach-card p { font-size: 13px; margin: 2px 0 5px; line-height: 1.45; }
.coach-card .row.spread { margin-top: 0; }
.coach-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px; align-items: stretch; }
@media (max-width: 900px) { .coach-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 560px) { .coach-grid { grid-template-columns: 1fr; } }
.coach-tags { margin-bottom: 4px; }
.coach-price { color: var(--accent); font-weight: 700; }

.coach-me { border-left: 4px solid var(--accent); }

.coach-student {
  display: flex; align-items: center; justify-content: space-between;
  gap: 10px;
  padding: 12px 0;
  border-top: 1px solid var(--line);
}
.coach-student:first-of-type { border-top: none; }

.chat-box {
  max-height: 46vh;
  overflow-y: auto;
  background: var(--bg2);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px;
  margin-bottom: 12px;
}
.chat-line { margin-bottom: 10px; display: flex; flex-direction: column; }
.chat-line.from-coach { align-items: flex-start; }
.chat-line.from-student { align-items: flex-end; }
.chat-bubble {
  max-width: 82%;
  padding: 9px 12px;
  border-radius: 12px;
  font-size: 14px;
  line-height: 1.55;
  background: var(--bg3);
  border: 1px solid var(--line);
}
.chat-line.from-coach .chat-bubble { border-left: 3px solid var(--accent); }
.chat-line.from-student .chat-bubble { border-right: 3px solid var(--ok); background: rgba(111, 157, 90, 0.12); }

/* ================= 自建领域 ================= */
.cat-title { margin: 18px 0 10px; color: var(--accent); letter-spacing: 2px; font-size: 14px; font-weight: 600; }
.de-row { padding: 12px 0; border-bottom: 1px dashed var(--line); }
.de-row:last-child { border-bottom: none; }

/* ================= 通用弹出层（面板居中） ================= */
.ag-overlay { position: fixed; inset: 0; z-index: 999; background: rgba(20,16,10,.55); display: flex; align-items: center; justify-content: center; padding: 20px; }
.ag-overlay.ag-scroll { align-items: flex-start; overflow-y: auto; }
.ag-overlay.ag-scroll .ag-box { margin: auto; }
.ag-box { background: var(--bg2); border-radius: 16px; max-width: 640px; width: 100%; max-height: 82vh; display: flex; flex-direction: column; overflow: hidden; box-shadow: 0 20px 60px rgba(0,0,0,.3); }
.ag-head { padding: 16px 22px; border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; font-size: 16px; font-weight: 700; color: var(--text); }
.ag-close { background: none; border: none; font-size: 22px; line-height: 1; cursor: pointer; color: var(--text-dim); padding: 4px 8px; }
.ag-body { padding: 6px 22px 22px; overflow-y: auto; font-size: 14px; line-height: 1.9; color: var(--text); }
.ag-body h3 { font-size: 15px; margin: 18px 0 8px; }
.ag-body p { margin: 0 0 10px; }
.ag-agree { padding: 14px 22px; border-top: 1px solid var(--line); display: flex; gap: 10px; align-items: center; }
.ag-agree .btn { flex: 1; }

/* ================= 领域视频弹出层 ================= */
.ag-overlay .video-box { max-width: 860px; }
.ag-overlay .video-frame { padding: 10px 14px 14px; }
.ag-overlay .video-frame iframe,
.ag-overlay .video-frame video { width: 100%; aspect-ratio: 16 / 9; border: none; border-radius: 10px; background: #000; max-height: 70vh; }

@media (max-width: 720px) {
  .coach-promo { flex-direction: column; align-items: flex-start; }
  .coach-promo .btn { width: 100%; }
  .coach-student { flex-direction: column; align-items: flex-start; }
  .coach-student .row { width: 100%; flex-wrap: wrap; }
}
