/* ========== 基础与主题变量 ========== */
* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
html { font-size: 16px; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
  min-height: 100vh;
  color: var(--text);
  background: var(--bg);
  transition: background .4s, color .4s;
}
.hidden { display: none !important; }
button { font-family: inherit; cursor: pointer; }
input, select, textarea { font-family: inherit; font-size: 1rem; }

/* ---- 汽车主题 ---- */
body.theme-car {
  --bg:
    radial-gradient(1100px 500px at 85% -10%, rgba(47,111,237,.10), transparent 60%),
    radial-gradient(900px 480px at -10% 20%, rgba(232,83,63,.10), transparent 55%),
    linear-gradient(180deg, #edf3fc 0%, #f8fafd 60%);
  --card: #ffffff;
  --text: #1f2a44;
  --muted: #7a869e;
  --primary: #e8533f;
  --primary-2: #ff7a59;
  --primary-soft: #ffe9e5;
  --accent: #2f6fed;
  --accent-soft: #e3ecff;
  --ok: #1faf5e;
  --ok-soft: #e0f6ea;
  --bad: #e0432f;
  --bad-soft: #fdeae7;
  --line: #e4e9f2;
  --field-bg: #f7f9fd;
  --shadow: 0 6px 20px rgba(31, 42, 68, .09), 0 1px 3px rgba(31, 42, 68, .06);
  --shadow-lift: 0 12px 28px rgba(31, 42, 68, .14), 0 2px 6px rgba(31, 42, 68, .07);
  --radius: 18px;
}
/* ---- 自然风景主题 ---- */
body.theme-nature {
  --bg:
    radial-gradient(1100px 500px at 85% -10%, rgba(61,155,95,.12), transparent 60%),
    radial-gradient(900px 480px at -10% 20%, rgba(240,180,60,.10), transparent 55%),
    linear-gradient(180deg, #e7f5eb 0%, #f6faf3 60%);
  --card: #ffffff;
  --text: #22402e;
  --muted: #7d9385;
  --primary: #3d9b5f;
  --primary-2: #63bd80;
  --primary-soft: #e2f4e9;
  --accent: #5b8c5a;
  --accent-soft: #e9f3e6;
  --ok: #2e9e5b;
  --ok-soft: #e2f4e9;
  --bad: #d96941;
  --bad-soft: #fbeae2;
  --line: #e0ece2;
  --field-bg: #f5faf3;
  --shadow: 0 6px 20px rgba(34, 64, 46, .09), 0 1px 3px rgba(34, 64, 46, .06);
  --shadow-lift: 0 12px 28px rgba(34, 64, 46, .14), 0 2px 6px rgba(34, 64, 46, .07);
  --radius: 18px;
}
/* ---- 星空主题（深色） ---- */
body.theme-star {
  --bg:
    radial-gradient(1100px 560px at 80% -10%, rgba(124,140,255,.22), transparent 60%),
    radial-gradient(900px 520px at 0% 30%, rgba(255,196,87,.10), transparent 55%),
    linear-gradient(180deg, #0b1026 0%, #161d3d 100%);
  --card: rgba(255, 255, 255, .07);
  --text: #eef1ff;
  --muted: #9aa3c7;
  --primary: #ffc94d;
  --primary-2: #ffe08a;
  --primary-soft: rgba(255, 201, 77, .16);
  --accent: #7ea2ff;
  --accent-soft: rgba(126, 162, 255, .18);
  --ok: #4cd68a;
  --ok-soft: rgba(76, 214, 138, .18);
  --bad: #ff7a6b;
  --bad-soft: rgba(255, 122, 107, .18);
  --line: rgba(255, 255, 255, .12);
  --field-bg: rgba(255, 255, 255, .06);
  --shadow: 0 8px 24px rgba(3, 6, 20, .45), 0 1px 3px rgba(3, 6, 20, .4);
  --shadow-lift: 0 14px 32px rgba(3, 6, 20, .55), 0 2px 8px rgba(3, 6, 20, .4);
  --radius: 18px;
}

/* 背景装饰：emoji 平铺（浅色主题）/ 星星闪烁（星空主题） */
body::before {
  content: "";
  position: fixed; inset: 0;
  pointer-events: none; z-index: 0;
  font-size: 28px; line-height: 2.2; letter-spacing: 40px;
  opacity: .05; white-space: pre-wrap; word-break: break-all;
  overflow: hidden; padding: 20px;
}
body.theme-car::before { content: "🚗 🏎️ 🚙 🚕 🚓 🛻 🚚 🏁 🚦 🔧 ⚙️ 🚗 🏎️ 🚙 🚕 🚓 🛻 🚚 🏁 🚦 🔧 ⚙️ 🚗 🏎️ 🚙 🚕 🚓 🛻 🚚 🏁 🚦 🔧 ⚙️ 🚗 🏎️ 🚙 🚕 🚓 🛻 🚚 🏁 🚦 🔧 ⚙️ 🚗 🏎️ 🚙 🚕 🚓 🛻 🚚 🏁 🚦 🔧 ⚙️ 🚗 🏎️ 🚙 🚕 🚓 🛻 🚚 🏁 🚦 🔧 ⚙️ 🚗 🏎️ 🚙 🚕 🚓 🛻 🚚 🏁 🚦 🔧 ⚙️ 🚗 🏎️ 🚙 🚕 🚓 🛻 🚚 🏁 🚦 🔧 ⚙️ 🚗 🏎️ 🚙 🚕 🚓 🛻 🚚 🏁 🚦 🔧 ⚙️ 🚗 🏎️ 🚙 🚕 🚓 🛻 🚚 🏁 🚦 🔧 ⚙️ 🚗 🏎️ 🚙 🚕 🚓 🛻 🚚 🏁 🚦 🔧 ⚙️"; }
body.theme-nature::before { content: "🌲 🌿 🍃 🌳 🌻 🌞 🌈 🏔️ 🌊 🦋 🐦 🌱 🌲 🌿 🍃 🌳 🌻 🌞 🌈 🏔️ 🌊 🦋 🐦 🌱 🌲 🌿 🍃 🌳 🌻 🌞 🌈 🏔️ 🌊 🦋 🐦 🌱 🌲 🌿 🍃 🌳 🌻 🌞 🌈 🏔️ 🌊 🦋 🐦 🌱 🌲 🌿 🍃 🌳 🌻 🌞 🌈 🏔️ 🌊 🦋 🐦 🌱 🌲 🌿 🍃 🌳 🌻 🌞 🌈 🏔️ 🌊 🦋 🐦 🌱 🌲 🌿 🍃 🌳 🌻 🌞 🌈 🏔️ 🌊 🦋 🐦 🌱 🌲 🌿 🍃 🌳 🌻 🌞 🌈 🏔️ 🌊 🦋 🐦 🌱"; }
body.theme-star::before {
  content: "⭐ ✨ 🌙 💫 🪐 ☄️ 🌟 ⭐ ✨ 🌙 💫 🪐 ☄️ 🌟 ⭐ ✨ 🌙 💫 🪐 ☄️ 🌟 ⭐ ✨ 🌙 💫 🪐 ☄️ 🌟 ⭐ ✨ 🌙 💫 🪐 ☄️ 🌟 ⭐ ✨ 🌙 💫 🪐 ☄️ 🌟 ⭐ ✨ 🌙 💫 🪐 ☄️ 🌟 ⭐ ✨ 🌙 💫 🪐 ☄️ 🌟 ⭐ ✨ 🌙 💫 🪐 ☄️ 🌟 ⭐ ✨ 🌙 💫 🪐 ☄️ 🌟 ⭐ ✨ 🌙 💫 🪐 ☄️ 🌟";
  opacity: .09;
  animation: twinkle 4s ease-in-out infinite alternate;
}
@keyframes twinkle {
  from { opacity: .05; }
  to { opacity: .14; }
}

/* ========== 通用组件 ========== */
#app, #auth { position: relative; z-index: 1; }
.btn {
  border: none; border-radius: 14px; padding: 12px 22px;
  font-size: 1rem; font-weight: 700; letter-spacing: .01em;
  transition: transform .14s, box-shadow .2s, opacity .2s;
}
.btn:active { transform: scale(.95); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary {
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-2) 100%);
  color: #fff;
  box-shadow: 0 4px 14px color-mix(in srgb, var(--primary) 40%, transparent);
}
body.theme-star .btn-primary { color: #3a2c00; }
.btn-primary:not(:disabled):hover { box-shadow: 0 6px 20px color-mix(in srgb, var(--primary) 52%, transparent); transform: translateY(-1px); }
.btn-soft { background: var(--accent-soft); color: var(--accent); }
.btn-ghost { background: transparent; color: var(--muted); border: 1.5px solid var(--line); }
.btn-block { width: 100%; }
.btn-sm { padding: 7px 12px; font-size: .88rem; border-radius: 10px; }
.icon-btn {
  border: none; background: var(--card); border-radius: 50%;
  width: 38px; height: 38px; font-size: 1.1rem;
  box-shadow: var(--shadow); display: inline-flex; align-items: center; justify-content: center;
  transition: transform .18s;
}
.icon-btn:hover { transform: rotate(-14deg) scale(1.08); }
.card {
  background: var(--card); border-radius: var(--radius);
  border: 1px solid var(--line);
  box-shadow: var(--shadow); padding: 18px;
}
body.theme-star .card,
body.theme-star .sheet-item,
body.theme-star .history-row,
body.theme-star .score-hero,
body.theme-star .auth-card {
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
}
.field { margin-bottom: 14px; }
.field label { display: block; font-size: .85rem; color: var(--muted); margin-bottom: 6px; }
.field input, .field select, .field textarea {
  width: 100%; padding: 12px 14px; border: 1.5px solid var(--line);
  border-radius: 12px; background: var(--field-bg); color: var(--text); outline: none;
  transition: border-color .2s, box-shadow .2s;
}
.field input:focus, .field textarea:focus, .field select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent);
}
body.theme-star .field select option { color: #1f2a44; }

/* ========== 登录/注册 ========== */
.auth-wrap {
  min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px;
}
.auth-card {
  width: 100%; max-width: 400px; background: var(--card);
  border: 1px solid var(--line);
  border-radius: 24px; box-shadow: var(--shadow-lift); padding: 36px 28px;
  animation: rise-in .5s cubic-bezier(.2, .9, .3, 1.2);
}
@keyframes rise-in {
  from { opacity: 0; transform: translateY(26px) scale(.97); }
  to { opacity: 1; transform: none; }
}
.auth-card.shake { animation: shake .45s; }
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-9px); }
  40% { transform: translateX(8px); }
  60% { transform: translateX(-5px); }
  80% { transform: translateX(4px); }
}
.auth-card h1 { font-size: 1.55rem; text-align: center; }
.auth-sub { text-align: center; color: var(--muted); margin: 8px 0 24px; }
.auth-err {
  background: var(--bad-soft); color: var(--bad);
  border-radius: 10px; padding: 10px 14px; font-size: .9rem; margin-bottom: 14px;
}
.auth-switch { text-align: center; margin-top: 16px; font-size: .9rem; }
.auth-switch a { color: var(--accent); text-decoration: none; }

/* ========== 顶栏与导航 ========== */
#topbar {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px;
  background: color-mix(in srgb, var(--card) 78%, transparent);
  backdrop-filter: blur(14px) saturate(1.4); -webkit-backdrop-filter: blur(14px) saturate(1.4);
  border-bottom: 1px solid var(--line);
}
body.theme-star #topbar { background: rgba(13, 17, 38, .7); }
.brand { display: flex; align-items: center; gap: 8px; font-weight: 800; font-size: 1.08rem; }
.brand-emoji { font-size: 1.4rem; display: inline-block; animation: bob 3s ease-in-out infinite; }
@keyframes bob {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-3px); }
}
.top-actions { display: flex; align-items: center; gap: 8px; }
.user-chip {
  display: flex; align-items: center; gap: 6px;
  background: var(--card); border: 1px solid var(--line);
  border-radius: 999px; padding: 4px 6px 4px 14px;
  box-shadow: var(--shadow); font-size: .9rem; font-weight: 600;
}
#admin-switch-wrap select {
  border: 1.5px solid var(--line); border-radius: 999px; padding: 8px 12px;
  background: var(--card); color: var(--text); font-size: .85rem; max-width: 130px;
}
#tabs {
  display: flex; gap: 6px; padding: 8px;
  margin: 12px 16px 4px;
  position: sticky; top: 70px; z-index: 40;
  background: color-mix(in srgb, var(--card) 80%, transparent);
  border: 1px solid var(--line);
  border-radius: 999px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
}
body.theme-star #tabs { background: rgba(13, 17, 38, .66); }
.tab {
  flex: 1; border: none; background: transparent; padding: 9px 0;
  font-size: .93rem; font-weight: 700; color: var(--muted);
  border-radius: 999px; transition: all .22s;
}
.tab.active {
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-2) 100%);
  color: #fff;
  box-shadow: 0 3px 10px color-mix(in srgb, var(--primary) 42%, transparent);
}
body.theme-star .tab.active { color: #3a2c00; }

#view { max-width: 760px; margin: 0 auto; padding: 14px 14px 60px; }

/* ========== 今日打分页 ========== */
.score-hero {
  text-align: center; padding: 24px 18px 18px; margin-bottom: 14px;
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow);
}
.score-hero .date { color: var(--muted); font-size: .92rem; font-weight: 600; }
.score-hero .created { color: var(--muted); font-size: .8rem; margin-top: 6px; }
.score-total {
  position: relative; display: inline-block;
  font-size: 2.6rem; font-weight: 800; line-height: 1;
  font-variant-numeric: tabular-nums;
  background: linear-gradient(135deg, var(--primary) 10%, var(--primary-2) 90%);
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent; color: transparent;
  /* 轻微上移补偿，数字与“分”中线对齐后整体落在圆环中心 */
  transform: translateY(-.05em);
}
/* “分”字脱离布局流，挂在数字右侧并与其垂直中线对齐，不参与居中——保证数字本身在圆环正中心 */
.score-total small {
  position: absolute; left: calc(100% + .14em); bottom: 50%;
  transform: translateY(50%);
  font-size: 1rem; font-weight: 700; white-space: nowrap;
  -webkit-text-fill-color: var(--muted); color: var(--muted);
}
.score-hero .progress { margin-top: 4px; font-size: .85rem; color: var(--muted); font-weight: 600; }
.hero-actions { display: flex; gap: 10px; margin-top: 16px; justify-content: center; }

/* 进度环 */
.hero-ring { position: relative; width: 148px; height: 148px; margin: 10px auto 2px; }
.hero-ring svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.hero-ring .ring-bg { fill: none; stroke: var(--line); stroke-width: 9; }
.hero-ring .ring-fg {
  fill: none; stroke: url(#ringGrad); stroke-width: 9; stroke-linecap: round;
  stroke-dasharray: 326.7; stroke-dashoffset: 326.7;
  transition: stroke-dashoffset .6s cubic-bezier(.3, .8, .4, 1);
}
.hero-ring-inner {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
}
.score-total.bump { animation: bump .4s cubic-bezier(.3, 1.4, .5, 1); }
@keyframes bump {
  0% { transform: translateY(-.05em) scale(1); }
  40% { transform: translateY(-.05em) scale(1.18); }
  100% { transform: translateY(-.05em) scale(1); }
}

.sheet-item {
  position: relative;
  background: var(--card); border-radius: var(--radius);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  padding: 14px 14px 14px 18px; margin-bottom: 12px;
  user-select: none; -webkit-user-select: none; -webkit-user-drag: none;
  transition: transform .18s, box-shadow .18s;
  overflow: hidden;
}
/* 左侧主题色条 */
.sheet-item::before {
  content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 5px;
  background: linear-gradient(180deg, var(--accent), color-mix(in srgb, var(--accent) 55%, transparent));
  border-radius: 5px 0 0 5px; opacity: .8;
}
.sheet-item.st-pass::before { background: linear-gradient(180deg, var(--ok), color-mix(in srgb, var(--ok) 55%, transparent)); }
.sheet-item.st-fail::before { background: linear-gradient(180deg, var(--bad), color-mix(in srgb, var(--bad) 55%, transparent)); }
@media (hover: hover) {
  .sheet-item:hover { transform: translateY(-2px); box-shadow: var(--shadow-lift); }
}
.dragging, .dragging * { user-select: none !important; -webkit-user-select: none !important; }
.item-head { display: flex; align-items: center; gap: 10px; }
.item-title { flex: 1; font-weight: 700; font-size: 1.02rem; }
.score-badge {
  font-size: .8rem; font-weight: 800; padding: 4px 10px; border-radius: 999px;
  background: var(--accent-soft); color: var(--accent); white-space: nowrap;
}
.state-btn {
  width: 48px; height: 48px; border-radius: 50%; border: 2.5px solid var(--line);
  background: var(--field-bg); font-size: 1.3rem; font-weight: 800;
  display: inline-flex; align-items: center; justify-content: center;
  transition: all .18s; color: transparent; flex-shrink: 0;
}
.state-btn.on-pass { background: linear-gradient(135deg, var(--ok), color-mix(in srgb, var(--ok) 75%, #fff)); border-color: var(--ok); color: #fff; box-shadow: 0 4px 12px color-mix(in srgb, var(--ok) 45%, transparent); }
.state-btn.on-fail { background: linear-gradient(135deg, var(--bad), color-mix(in srgb, var(--bad) 75%, #fff)); border-color: var(--bad); color: #fff; box-shadow: 0 4px 12px color-mix(in srgb, var(--bad) 45%, transparent); }
.state-btn.pop, .item-state.pop, .sub-check.pop { animation: pop .38s cubic-bezier(.3, 1.6, .5, 1); }
@keyframes pop {
  0% { transform: scale(.7); }
  55% { transform: scale(1.22); }
  100% { transform: scale(1); }
}
.item-state {
  width: 48px; height: 48px; border-radius: 50%; flex-shrink: 0;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 1.4rem; font-weight: 800; border: 2.5px solid var(--line); color: var(--line);
}
.item-state.on-pass { background: var(--ok-soft); border-color: var(--ok); color: var(--ok); }
.item-state.on-fail { background: var(--bad-soft); border-color: var(--bad); color: var(--bad); }

.sub-list { margin-top: 10px; padding-top: 4px; border-top: 1px dashed var(--line); }
.sub-row {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 2px; font-size: .95rem;
}
.sub-check {
  width: 32px; height: 32px; border-radius: 50%; border: 2px solid var(--line);
  background: var(--field-bg); flex-shrink: 0; font-size: .95rem;
  display: inline-flex; align-items: center; justify-content: center; color: transparent;
  transition: all .18s;
}
.sub-check.on { background: linear-gradient(135deg, var(--ok), color-mix(in srgb, var(--ok) 75%, #fff)); border-color: var(--ok); color: #fff; box-shadow: 0 3px 9px color-mix(in srgb, var(--ok) 40%, transparent); }
.sub-title.done { color: var(--muted); text-decoration: line-through; text-decoration-color: color-mix(in srgb, var(--muted) 55%, transparent); }

.empty-tip { text-align: center; color: var(--muted); padding: 40px 20px; }

/* 撒花彩蛋 */
.confetti-layer { position: fixed; inset: 0; pointer-events: none; z-index: 300; overflow: hidden; }
.confetti-piece {
  position: absolute; top: -6vh;
  animation: confetti-fall linear forwards;
}
@keyframes confetti-fall {
  0% { transform: translateY(-6vh) rotate(0deg); opacity: 1; }
  85% { opacity: 1; }
  100% { transform: translateY(108vh) rotate(720deg); opacity: 0; }
}

/* 模板编辑模式 */
.edit-panel { margin-top: 6px; }
.tpl-item {
  display: flex; align-items: center; gap: 8px; padding: 10px 4px;
  border-bottom: 1px dashed var(--line);
}
.tpl-item:last-child { border-bottom: none; }
.drag-handle { cursor: grab; color: var(--muted); font-size: 1.15rem; touch-action: none; user-select: none; padding: 8px 4px; }
.dragging { opacity: .4; }
.tpl-title { flex: 1; }
.tpl-title small { display: block; color: var(--muted); font-weight: 400; font-size: .78rem; }
.tpl-score { width: 64px !important; padding: 7px 8px !important; text-align: center; }
.tpl-edit-row { display: flex; gap: 6px; margin-top: 8px; }
.tpl-edit-row input { flex: 1; }
.tpl-edit-row input[type="number"], .tpl-edit-row input[type="text"], .tpl-edit-row input:not([type]) {
  padding: 9px 12px; border: 1.5px solid var(--line); border-radius: 10px;
  background: var(--field-bg); color: var(--text); outline: none;
}
.mini-btn {
  border: none; border-radius: 9px; padding: 8px 12px; font-size: .85rem; font-weight: 600;
  background: var(--accent-soft); color: var(--accent); white-space: nowrap;
  transition: transform .14s;
}
.mini-btn:active { transform: scale(.93); }
.mini-btn.danger { background: var(--bad-soft); color: var(--bad); }
.mini-icon {
  border: none; background: transparent; font-size: .95rem;
  padding: 6px; border-radius: 8px; color: var(--muted); flex-shrink: 0;
  line-height: 1; transition: background .15s, transform .15s;
}
.mini-icon:active { background: var(--accent-soft); transform: scale(.9); }
.item-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* 弹窗面板 */
.modal-overlay {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(15, 23, 42, .45);
  display: flex; align-items: flex-end; justify-content: center;
  animation: fade-in .22s;
}
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
.modal-card {
  background: var(--card); width: 100%; max-width: 460px;
  border: 1px solid var(--line);
  border-radius: 22px 22px 0 0; padding: 22px;
  max-height: 86vh; overflow-y: auto;
  box-shadow: 0 -8px 40px rgba(0, 0, 0, .22);
  animation: sheet-up .32s cubic-bezier(.2, .9, .3, 1.1);
}
@keyframes sheet-up {
  from { transform: translateY(48px); opacity: .4; }
  to { transform: none; opacity: 1; }
}
body.theme-star .modal-card { background: #1a2142; backdrop-filter: none; }
.modal-card h3 { margin-bottom: 14px; font-size: 1.1rem; }
@media (min-width: 720px) {
  .modal-overlay { align-items: center; padding: 20px; }
  .modal-card { border-radius: 22px; }
}
/* 桌面端拖动 affordance */
@media (hover: hover) {
  .sheet-item { cursor: grab; }
  .sheet-item:active { cursor: grabbing; }
  .sheet-item button, .sheet-item input { cursor: pointer; }
}

/* ========== 奋斗宣言 ========== */
.declaration { margin-top: 6px; }
.declaration h3 { display: flex; align-items: center; gap: 8px; font-size: 1.05rem; margin-bottom: 12px; }
.decl-photo { max-width: 100%; border-radius: 12px; margin: 10px 0; display: block; }
.decl-audio { width: 100%; margin: 8px 0; }
.decl-existing { background: var(--accent-soft); border-radius: 12px; padding: 12px 14px; margin-bottom: 14px; font-size: .92rem; }
.decl-existing .decl-text { white-space: pre-wrap; margin-bottom: 6px; }
.decl-existing .decl-time { color: var(--muted); font-size: .78rem; }
.recorder { display: flex; align-items: center; gap: 10px; margin: 10px 0; }
.rec-btn { width: 52px; height: 52px; border-radius: 50%; border: none; font-size: 1.3rem; background: linear-gradient(135deg, var(--bad), color-mix(in srgb, var(--bad) 72%, #fff)); color: #fff; box-shadow: 0 4px 12px color-mix(in srgb, var(--bad) 40%, transparent); }
.rec-btn.recording { animation: pulse 1.1s infinite; }
.rec-time { font-variant-numeric: tabular-nums; color: var(--muted); }
@keyframes pulse { 0%,100% { transform: scale(1); } 50% { transform: scale(1.12); } }
.audio-preview { margin: 8px 0; display: flex; align-items: center; gap: 8px; }
.photo-preview { position: relative; display: inline-block; margin: 8px 0; }
.photo-preview img { max-width: 160px; border-radius: 12px; display: block; }
.photo-preview .rm {
  position: absolute; top: -8px; right: -8px; width: 26px; height: 26px;
  border-radius: 50%; border: none; background: var(--bad); color: #fff;
}

/* ========== 历史页 ========== */
.month-bar { display: flex; gap: 8px; align-items: center; margin-bottom: 14px; }
.month-bar input[type="month"] { flex: 1; padding: 10px 12px; border: 1.5px solid var(--line); border-radius: 12px; background: var(--field-bg); color: var(--text); }
.history-row {
  position: relative;
  display: flex; align-items: center; gap: 12px;
  background: var(--card); border: 1px solid var(--line);
  border-radius: 16px; box-shadow: var(--shadow);
  padding: 14px 16px; margin-bottom: 10px; cursor: pointer;
  transition: transform .16s, box-shadow .16s;
}
.history-row:hover { transform: translateX(4px); box-shadow: var(--shadow-lift); }
.history-row .h-date { font-weight: 700; flex: 1; }
.history-row .h-date small { display: block; font-weight: 400; color: var(--muted); font-size: .78rem; margin-top: 2px; }
.history-row .h-score {
  font-size: 1.15rem; font-weight: 800; font-variant-numeric: tabular-nums;
  min-width: 58px; text-align: center; padding: 5px 10px; border-radius: 999px;
}
.history-row .h-score.pos { color: var(--ok); background: var(--ok-soft); }
.history-row .h-score.neg { color: var(--bad); background: var(--bad-soft); }
.history-row .h-badge { font-size: .75rem; padding: 3px 8px; border-radius: 999px; background: var(--primary-soft); color: var(--primary); }

/* ========== 统计页 ========== */
.stat-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 14px; }
.stat-card {
  padding: 16px; position: relative; overflow: hidden;
  transition: transform .16s, box-shadow .16s;
}
.stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-lift); }
.stat-card::after {
  content: ""; position: absolute; right: -30px; top: -30px; width: 100px; height: 100px;
  border-radius: 50%; background: var(--accent-soft); opacity: .5; pointer-events: none;
}
.stat-card .s-label { font-size: .82rem; color: var(--muted); margin-bottom: 6px; font-weight: 600; }
.stat-card .s-value { font-size: 1.7rem; font-weight: 800; font-variant-numeric: tabular-nums; }
.stat-card .s-sub { font-size: .78rem; color: var(--muted); margin-top: 4px; }
.stat-card.wide { grid-column: 1 / -1; }
.chart-card { margin-bottom: 14px; }
.chart-card h3 { font-size: .98rem; margin-bottom: 8px; }
.chart-box { width: 100%; height: 260px; }

/* ========== 管理页 ========== */
.admin-table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.admin-table th, .admin-table td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--line); }
.admin-table th { color: var(--muted); font-weight: 600; font-size: .82rem; }
.admin-table tr:last-child td { border-bottom: none; }
.admin-table tbody tr:nth-child(even), .admin-table tr:nth-child(even) td { background: color-mix(in srgb, var(--accent-soft) 40%, transparent); }
.invite-code {
  font-family: ui-monospace, monospace; font-weight: 700; letter-spacing: 1px;
  background: var(--accent-soft); padding: 3px 8px; border-radius: 6px;
}
.tag { font-size: .75rem; padding: 2px 8px; border-radius: 999px; background: var(--ok-soft); color: var(--ok); }
.tag.off { background: var(--bad-soft); color: var(--bad); }

/* ========== 桌面端适配 ========== */
@media (min-width: 720px) {
  html { font-size: 17px; }
  #view { padding-top: 20px; }
  #tabs { max-width: 560px; margin-left: auto; margin-right: auto; }
  .score-total { font-size: 3rem; }
  .sheet-item { padding: 18px 18px 18px 22px; }
  .stat-grid { grid-template-columns: repeat(3, 1fr); }
  .stat-card.wide { grid-column: auto; }
  .chart-box { height: 320px; }
}
@media (max-width: 400px) {
  .brand-text { display: none; }
  #admin-switch-wrap select { max-width: 96px; }
}

/* ========== 手机端打分项卡片 ========== */
@media (max-width: 719px) {
  .item-head { flex-wrap: wrap; row-gap: 10px; align-items: center; }
  /* 标题独占一行完整显示，不再省略 */
  .item-head .item-title {
    order: -1; flex: 1 0 100%;
    white-space: normal; overflow: visible; text-overflow: unset;
    font-size: 1.08rem; line-height: 1.45; padding-right: 4px;
  }
  /* 第二行：分数徽章在左，打勾/编辑/删除靠右 */
  .item-head .score-badge { order: 1; }
  .item-head .drag-handle { order: 2; padding: 4px 4px; }
  .item-head .state-btn, .item-head .item-state { order: 3; margin-left: auto; width: 44px; height: 44px; }
  .item-head .mini-icon { order: 4; font-size: 1.05rem; padding: 8px; }
  /* 子项行更紧凑一些 */
  .sub-row { padding: 8px 2px; }
}

/* 尊重系统减少动效偏好 */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

/* 明日准备：操作按钮靠右 */
.prep-row .item-head .mini-icon:first-of-type { margin-left: auto; }

/* ========== 紧凑布局优化 ========== */
.sheet-item { padding: 10px 12px; margin-bottom: 8px; }
.item-head { gap: 8px; }
.state-btn { width: 40px; height: 40px; font-size: 1.1rem; }
.item-state { width: 40px; height: 40px; font-size: 1.2rem; }
.sub-list { margin-top: 6px; padding-top: 2px; }
.sub-row { padding: 6px 2px; }
.sub-check { width: 26px; height: 26px; font-size: .88rem; }
@media (max-width: 719px) {
  .sheet-item { padding: 10px 12px; }
  .item-head { row-gap: 8px; }
  .item-head .state-btn, .item-head .item-state { width: 36px; height: 36px; }
}
