:root {
  --bg: #f4f5f8;
  --surface: #ffffff;
  --surface-2: #f0f1f5;
  --text: #14161c;
  --muted: #6b7180;
  --faint: #9aa0ad;
  --border: #e6e8ee;
  --accent: #4f46e5;
  --accent-soft: #eceeff;
  --on-accent: #ffffff;
  --green: #16a34a;
  --green-soft: #dcfce7;
  --amber: #c2610c;
  --amber-soft: #ffedd5;
  --red: #dc2626;
  --red-soft: #fee2e2;
  --blue: #2563eb;
  --blue-soft: #dbeafe;
  --shadow: 0 1px 2px rgba(16, 20, 40, .05), 0 6px 20px rgba(16, 20, 40, .05);
  --radius: 16px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  --cunused-bg: #f7e3e7; /* 确认未使用：低饱和度浅粉，不是警告红 */
  --cunused-fg: #9a4a5a;
  --toast-bg: #1f2330;
  --toast-fg: #ffffff;
  --toast-border: transparent;
  --toast-action: #b4b8ff;
  --toast-action-bg: rgba(255, 255, 255, .12);
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e1016;
    --surface: #181b23;
    --surface-2: #222631;
    --text: #eceef3;
    --muted: #9aa0ad;
    --faint: #6b7180;
    --border: #2a2e3a;
    --accent: #8b87ff;
    --accent-soft: #25264a;
    --on-accent: #0e1016;
    --cunused-bg: #3a252b;
    --cunused-fg: #e0a7b3;
    --toast-bg: #2a2f3c;
    --toast-fg: #eceef3;
    --toast-border: #3a4050;
    --toast-action: #a9a6ff;
    --toast-action-bg: rgba(139, 135, 255, .16);
    --green: #4ade80;
    --green-soft: #143222;
    --amber: #fbbf24;      /* UI-06：深色模式改成偏黄（色相 43°），和红色 #f87171 明显区分；不增加新颜色 */
    --amber-soft: #3a2e12;
    --red: #f87171;
    --red-soft: #3b1a1a;
    --blue: #60a5fa;
    --blue-soft: #172a46;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Segoe UI", "Microsoft YaHei", sans-serif;
  min-height: 100vh;
  overscroll-behavior-y: none;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
h1, h2, h3, p { margin: 0; }
small { font-size: 12px; }
.muted { color: var(--muted); }

/* ---------- header ---------- */
.top {
  position: sticky; top: 0; z-index: 10;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(180%) blur(16px);
  -webkit-backdrop-filter: saturate(180%) blur(16px);
  padding: calc(var(--safe-t) + 14px) 16px 10px;
  max-width: 680px; margin: 0 auto;
}
.top-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.top h1 { font-size: 26px; font-weight: 750; letter-spacing: -.02em; }
.chips { display: flex; gap: 8px; margin-top: 10px; overflow-x: auto; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; flex: none;
  border: 1px solid var(--border); background: var(--surface);
  border-radius: 999px; padding: 6px 14px; font-size: 14px; font-weight: 550;
}
.chip i { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.chip.on { background: var(--text); color: var(--bg); border-color: var(--text); }

.icon-btn {
  width: 36px; height: 36px; border-radius: 50%; border: 0;
  background: var(--accent-soft); color: var(--accent);
  font-size: 22px; line-height: 1; display: grid; place-items: center; flex: none;
}

/* ---------- main ---------- */
.main {
  max-width: 680px; margin: 0 auto;
  padding: 6px 16px calc(96px + var(--safe-b));
}
.sec {
  display: flex; align-items: baseline; justify-content: space-between; gap: 8px;
  font-size: 13px; font-weight: 650; color: var(--muted); text-transform: uppercase; letter-spacing: .02em;
  margin: 22px 4px 8px;
}
.sec span { font-weight: 500; text-transform: none; letter-spacing: 0; }
.sec .link { font-size: 13px; }

.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 6px; }
.stat {
  background: var(--surface); border-radius: var(--radius); padding: 12px; box-shadow: var(--shadow);
  min-width: 0;
}
.stat .label { font-size: 12px; color: var(--muted); }
.stat .val { font-size: 20px; font-weight: 750; letter-spacing: -.02em; margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stat .val.warn { color: var(--amber); }
.stat .sub { font-size: 11px; color: var(--faint); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.list { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.item {
  display: flex; align-items: center; gap: 12px; width: 100%;
  padding: 12px 14px; border: 0; background: transparent; text-align: left;
}
.item + .item { border-top: 1px solid var(--border); }
.item:active { background: var(--surface-2); }
.ico {
  width: 40px; height: 40px; border-radius: 12px; flex: none;
  display: grid; place-items: center; font-size: 20px;
  background: color-mix(in srgb, var(--c, var(--accent)) 14%, var(--surface));
}
.item-main { flex: 1; min-width: 0; }
.item-title { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item-sub { font-size: 12.5px; color: var(--muted); display: flex; align-items: center; gap: 5px; white-space: nowrap; overflow: hidden; }
.item-sub .dot, .dot { width: 7px; height: 7px; border-radius: 50%; flex: none; display: inline-block; }
.bar { height: 5px; border-radius: 3px; background: var(--surface-2); margin-top: 7px; overflow: hidden; }
.bar > span { display: block; height: 100%; background: var(--accent); border-radius: 3px; }
.bar.full > span { background: var(--green); }
.item-side { text-align: right; flex: none; }
.amt { font-weight: 700; font-variant-numeric: tabular-nums; }
.amt small { color: var(--faint); font-weight: 500; }
.due { font-size: 12px; font-weight: 600; margin-top: 3px; color: var(--muted); }
.pill { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 12px; font-weight: 650; }
.pill.amber { background: var(--amber-soft); color: var(--amber); }
.pill.red { background: var(--red-soft); color: var(--red); }
.pill.green { background: var(--green-soft); color: var(--green); }
.pill.gray { background: var(--surface-2); color: var(--muted); }

.toggle-row {
  display: flex; align-items: center; justify-content: space-between; width: 100%;
  border: 0; background: transparent; padding: 0; margin: 22px 4px 8px;
  font-size: 13px; font-weight: 650; color: var(--muted);
}

.empty { text-align: center; padding: 56px 24px; }
.empty .big { font-size: 44px; }
.empty h2 { font-size: 18px; margin-top: 12px; }
.empty p { color: var(--muted); margin: 6px 0 18px; }

/* ---------- buttons & forms ---------- */
.btn {
  border: 0; border-radius: 12px; padding: 11px 16px; font-weight: 600;
  background: var(--surface-2); color: var(--text);
}
.btn.primary { background: var(--accent); color: var(--on-accent); }
.btn.danger { background: var(--red-soft); color: var(--red); }
.btn.block { width: 100%; }
.btn:disabled { opacity: .5; }
.btn:active { transform: scale(.98); }
.link { border: 0; background: none; color: var(--accent); font-weight: 600; padding: 6px 4px; }
.link.danger { color: var(--red); }
.btns { display: flex; gap: 10px; margin-top: 14px; }
.btns .btn { flex: 1; }

.field { display: block; margin-top: 14px; }
.field > span { display: block; font-size: 13px; color: var(--muted); font-weight: 600; margin-bottom: 6px; }
.field > span small { font-weight: 400; color: var(--faint); }
.field input:not([type=checkbox]):not([type=radio]), .field select, .field textarea, .input {
  width: 100%; border: 1px solid var(--border); background: var(--surface-2);
  border-radius: 12px; padding: 11px 12px; font-size: 16px; outline: none; appearance: none; -webkit-appearance: none;
  min-height: 46px;
}
.field select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%23888' stroke-width='1.8' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 14px center; padding-right: 36px;
}
.field textarea { min-height: 70px; resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--accent); }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.row2 .field { margin-top: 14px; min-width: 0; }
.row2 input { min-width: 0; }
/* 表单复选框行（F5：以前和一键勾选按钮共用 .check，被压成 34px 的圆） */
.check-row { display: flex; align-items: flex-start; gap: 10px; margin-top: 16px; font-weight: 600; line-height: 1.35; }
.check-row input { flex: none; width: 20px; height: 20px; margin: 1px 0 0; accent-color: var(--accent); }
.check-row > span { flex: 1; min-width: 0; }
.check-row small { display: block; margin-top: 2px; font-weight: 400; font-size: 12.5px; color: var(--muted); }

/* 日期输入（F4）：文本框 + 日历按钮（透明的原生日期控件盖在按钮上）+ 完整日期预览 */
.date-wrap { display: block; min-width: 0; }
.date-in { position: relative; display: block; }
.date-in > input.input[data-date] { padding-right: 52px; font-variant-numeric: tabular-nums; }
.date-btn {
  position: absolute; right: 4px; top: 50%; transform: translateY(-50%);
  width: 42px; height: 38px; border-radius: 10px; display: grid; place-items: center; color: var(--muted);
}
.date-btn svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; }
.date-btn input.date-native {
  position: absolute !important; inset: 0 !important; width: 100% !important; height: 100% !important;
  min-height: 0 !important; padding: 0 !important; margin: 0 !important; border: 0 !important;
  opacity: 0 !important; background: none !important; font-size: 16px; cursor: pointer;
}
.date-preview { display: block; margin-top: 5px; font-size: 12.5px; font-weight: 500; color: var(--muted); font-variant-numeric: tabular-nums; }
.date-preview:empty { display: none; }
.date-preview.err { color: var(--red); }
.hint { font-size: 12.5px; color: var(--faint); margin-top: 6px; }

.seg { display: flex; background: var(--surface-2); border-radius: 12px; padding: 3px; gap: 3px; }
.seg label { flex: 1; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg label span {
  display: flex; align-items: center; justify-content: center; gap: 6px;
  padding: 8px 6px; border-radius: 9px; font-weight: 600; font-size: 14px; color: var(--muted);
}
.seg input:checked + span { background: var(--surface); color: var(--text); box-shadow: 0 1px 3px rgba(0, 0, 0, .1); }

.preset-list { display: flex; flex-direction: column; gap: 6px; max-height: 300px; overflow-y: auto; padding: 2px; }
.preset { display: block; }
.preset input { position: absolute; opacity: 0; pointer-events: none; }
.preset > div {
  display: flex; align-items: center; gap: 10px; padding: 9px 10px;
  border: 1.5px solid var(--border); border-radius: 12px; background: var(--surface);
}
.preset input:checked + div { border-color: var(--accent); background: var(--accent-soft); }
.preset b { font-weight: 600; display: block; }
.preset small { color: var(--muted); }
.mini-cc { width: 34px; height: 22px; border-radius: 4px; flex: none; background: var(--c); box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .15); }

.swatches { display: flex; gap: 10px; flex-wrap: wrap; }
.swatches label { position: relative; }
.swatches input { position: absolute; opacity: 0; pointer-events: none; }
.swatches span { display: block; width: 30px; height: 30px; border-radius: 50%; background: var(--c); border: 3px solid var(--surface); box-shadow: 0 0 0 1.5px var(--border); }
.swatches input:checked + span { box-shadow: 0 0 0 2.5px var(--text); }

/* ---------- cards tab ---------- */
.panel { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.panel + .panel { margin-top: 10px; }
.card-head { display: flex; align-items: center; gap: 12px; width: 100%; padding: 12px 14px; border: 0; background: transparent; text-align: left; }
.cc {
  width: 58px; height: 38px; border-radius: 6px; flex: none; position: relative; overflow: hidden;
  background: linear-gradient(135deg, var(--c), color-mix(in srgb, var(--c) 55%, #000));
  color: rgba(255, 255, 255, .92); font-size: 8.5px; font-weight: 700; padding: 4px 5px; letter-spacing: .02em;
}
.cc::after { content: ""; position: absolute; left: 6px; bottom: 7px; width: 10px; height: 7px; border-radius: 2px; background: rgba(255, 220, 140, .85); }
.chev { color: var(--faint); transition: transform .2s; flex: none; }
.open .chev { transform: rotate(90deg); }
.card-body { border-top: 1px solid var(--border); padding: 4px 14px 12px; }
.b-row { display: flex; align-items: center; gap: 10px; padding: 9px 0; }
.b-row + .b-row { border-top: 1px solid var(--border); }
.b-row.off { opacity: .5; }
.b-row .ico { width: 32px; height: 32px; font-size: 16px; border-radius: 9px; }
.card-actions { display: flex; gap: 8px; margin-top: 8px; }
.card-actions .btn { flex: 1; padding: 9px; font-size: 14px; }
.add-dashed {
  display: block; width: 100%; margin-top: 10px; padding: 12px; border-radius: var(--radius);
  border: 1.5px dashed var(--border); background: transparent; color: var(--muted); font-weight: 600;
}

/* ---------- history ---------- */
.year-nav { display: flex; align-items: center; justify-content: center; gap: 18px; margin-top: 4px; }
.year-nav b { font-size: 18px; min-width: 64px; text-align: center; }
.year-nav button { width: 36px; height: 36px; border-radius: 50%; border: 0; background: var(--surface); box-shadow: var(--shadow); font-size: 18px; }
.mstats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; margin-top: 14px; }
.mstat { background: var(--surface); border-radius: var(--radius); padding: 12px 14px; box-shadow: var(--shadow); }
.mstat .name { display: flex; align-items: center; gap: 6px; font-weight: 650; }
.mstat .big { font-size: 22px; font-weight: 750; margin-top: 4px; letter-spacing: -.02em; }
.mstat .big small { font-size: 13px; color: var(--faint); font-weight: 500; }
.mstat .miss { font-size: 12.5px; color: var(--red); margin-top: 2px; }
.mstat .miss.zero { color: var(--green); }
.h-card { padding: 12px 14px; }
.h-card + .h-card { border-top: 1px solid var(--border); }
.h-card-title { display: flex; align-items: center; gap: 8px; font-weight: 700; margin-bottom: 6px; }
.h-row { padding: 6px 0; }
.h-row-top { display: flex; justify-content: space-between; font-size: 13.5px; gap: 8px; }
.h-row-top span:last-child { color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.cells { display: grid; grid-template-columns: repeat(var(--n), 1fr); gap: 4px; margin-top: 5px; }
.cell {
  border: 0; border-radius: 6px; padding: 5px 0; font-size: 11px; font-weight: 650;
  background: var(--surface-2); color: var(--faint); min-width: 0;
}
.cell.full { background: var(--green-soft); color: var(--green); }
.cell.partial { background: var(--amber-soft); color: var(--amber); }
.cell.missed { background: var(--red-soft); color: var(--red); }
.cell.current { box-shadow: inset 0 0 0 1.5px var(--accent); color: var(--accent); }
.cell.na { opacity: .45; }
.legend { display: flex; flex-wrap: wrap; gap: 12px; font-size: 12px; color: var(--muted); margin: 12px 4px 0; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 4px; vertical-align: -1px; }

/* ---------- settings ---------- */
.s-row { display: flex; align-items: center; gap: 10px; padding: 10px 14px; }
.s-row + .s-row { border-top: 1px solid var(--border); }
.s-row .input { min-height: 40px; padding: 8px 10px; }
.s-row > .grow { flex: 1; min-width: 0; }
.s-row select.input { width: auto; padding-right: 12px; }
.color-dot { width: 28px; height: 28px; border-radius: 50%; border: 0; background: var(--c); flex: none; }
.s-btn { display: flex; align-items: center; justify-content: space-between; width: 100%; padding: 13px 14px; border: 0; background: transparent; text-align: left; font-weight: 550; }
.s-btn + .s-btn, .s-row + .s-btn, .s-btn + .s-row { border-top: 1px solid var(--border); }
.s-btn.danger { color: var(--red); }
.s-btn span:last-child { color: var(--faint); }
.note { font-size: 13px; color: var(--muted); padding: 10px 4px 0; }

/* ---------- tab bar ---------- */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  display: flex; justify-content: center;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: saturate(180%) blur(16px);
  -webkit-backdrop-filter: saturate(180%) blur(16px);
  border-top: 1px solid var(--border);
  padding: 6px 8px calc(6px + var(--safe-b));
}
.tabbar button {
  flex: 1; max-width: 140px; border: 0; background: transparent; color: var(--faint);
  display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 4px 0;
  font-size: 11px; font-weight: 600; position: relative;
}
.tabbar svg { width: 25px; height: 25px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.tabbar button.active { color: var(--accent); }
.tabbar .badge {
  position: absolute; top: 0; left: calc(50% + 6px); min-width: 17px; height: 17px; padding: 0 5px;
  border-radius: 9px; background: var(--red); color: #fff; font-size: 10.5px; line-height: 17px; text-align: center;
}

/* ---------- sheet ---------- */
.sheet { position: fixed; inset: 0; z-index: 50; }
.sheet-backdrop { position: absolute; inset: 0; background: rgba(0, 0, 0, .38); opacity: 0; transition: opacity .22s; }
.sheet-panel {
  position: absolute; left: 0; right: 0; bottom: 0; margin: 0 auto; max-width: 560px;
  max-height: 92vh; max-height: 92dvh; overflow-y: auto; overscroll-behavior: contain;
  background: var(--surface); border-radius: 22px 22px 0 0;
  padding: 0 18px calc(20px + var(--safe-b));
  transform: translateY(100%); transition: transform .28s cubic-bezier(.2, .8, .2, 1);
}
.sheet.open .sheet-backdrop { opacity: 1; }
.sheet.open .sheet-panel { transform: none; }
.sheet-head {
  position: sticky; top: 0; z-index: 1; background: var(--surface);
  display: flex; align-items: center; justify-content: space-between; padding: 16px 0 6px;
}
.sheet-head h3 { font-size: 18px; font-weight: 700; }
.sheet-head .icon-btn { background: var(--surface-2); color: var(--muted); font-size: 20px; width: 32px; height: 32px; }
@media (min-width: 600px) {
  .sheet-panel { bottom: auto; top: 50%; border-radius: 22px; transform: translateY(-46%) scale(.97); opacity: 0; transition: transform .22s, opacity .22s; max-height: 86vh; }
  .sheet.open .sheet-panel { transform: translateY(-50%); opacity: 1; }
}

.log-head { display: flex; align-items: center; gap: 12px; margin-top: 4px; }
.log-head .ico { width: 46px; height: 46px; font-size: 24px; }
.log-title { font-size: 17px; font-weight: 700; }
.b-note { font-size: 13px; color: var(--muted); background: var(--surface-2); border-radius: 10px; padding: 8px 10px; margin-top: 12px; white-space: pre-line; overflow-wrap: anywhere; }
.pnav { display: flex; align-items: center; gap: 10px; margin-top: 16px; }
.pnav button { width: 38px; height: 38px; border-radius: 50%; border: 0; background: var(--surface-2); font-size: 18px; flex: none; }
.pnav > div { flex: 1; text-align: center; }
.pnav b { display: block; font-size: 16px; }
.pnav span { font-size: 12.5px; color: var(--muted); }
.prog { margin-top: 14px; }
.prog-top { display: flex; justify-content: space-between; align-items: baseline; }
.prog-top b { font-size: 24px; letter-spacing: -.02em; }
.prog-top span { color: var(--muted); font-size: 13px; }
.prog .bar { height: 8px; border-radius: 4px; }
.entries { list-style: none; margin: 14px 0 0; padding: 0; }
.entries li { display: flex; align-items: center; gap: 10px; padding: 9px 0; border-top: 1px solid var(--border); }
.entries li > div { flex: 1; min-width: 0; }
.entries li b { font-variant-numeric: tabular-nums; }
.entries li span { color: var(--muted); font-size: 13px; margin-left: 6px; }
.entries li p { font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.done-banner { margin-top: 16px; padding: 12px; border-radius: 12px; background: var(--green-soft); color: var(--green); font-weight: 650; text-align: center; }

/* 提示（F1）：顶部浮动提示；整个提示不拦截点击，只有「撤销」按钮可以点。
   外层 .toast 占满安全区内的宽度，只负责定位和居中；内层 .toast-pill 随内容变宽，最宽不超过外层，长文字自动换行。
   （不用 width: fit-content：iOS Safari 对绝对定位元素按 max-content 计算，长文字会超出屏幕。） */
.toast {
  position: fixed; z-index: 80; top: calc(var(--safe-t) + 8px);
  left: calc(env(safe-area-inset-left, 0px) + 12px); right: calc(env(safe-area-inset-right, 0px) + 12px);
  display: flex; justify-content: center;
  transform: translateY(-10px); opacity: 0; pointer-events: none;
  transition: transform .2s, opacity .2s;
}
.toast.show { transform: none; opacity: 1; }
.toast-pill {
  display: flex; align-items: center; gap: 10px; max-width: min(100%, 480px); min-height: 40px;
  background: var(--toast-bg); color: var(--toast-fg); border: 1px solid var(--toast-border);
  padding: 4px 4px 4px 16px; border-radius: 20px; font-weight: 600; font-size: 14px; line-height: 1.35;
  box-shadow: 0 6px 20px rgba(0, 0, 0, .18);
}
.toast #toast-msg { flex: 1 1 auto; min-width: 0; white-space: normal; overflow-wrap: anywhere; padding: 6px 12px 6px 0; }
.toast button {
  flex: none; border: 0; min-height: 34px; padding: 0 14px; border-radius: 999px;
  background: var(--toast-action-bg); color: var(--toast-action); font-weight: 700; font-size: 14px;
  pointer-events: none;
}
.toast.show button { pointer-events: auto; }

/* ================= Phase 1 additions ================= */
.stat .val.info { color: var(--blue); }
.pill.blue { background: var(--blue-soft); color: var(--blue); }
.bar.has-pending > span { background: var(--blue); }
.blue { color: var(--blue); }
.red { color: var(--red); }
.green { color: var(--green); }
.strike { text-decoration: line-through; opacity: .6; }

/* 列表行（div 形式，右侧带一键勾选按钮） */
div.item { cursor: pointer; }
.check-btn {
  flex: none; width: 34px; height: 34px; border-radius: 50%; margin-left: 2px;
  border: 2px solid var(--border); background: var(--surface); display: grid; place-items: center; padding: 0;
}
.check-btn svg { width: 18px; height: 18px; fill: none; stroke: var(--faint); stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
.check-btn:active { background: var(--green-soft); border-color: var(--green); }
.check-btn:active svg { stroke: var(--green); }
.item-tags { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 3px; }
.item-tags span { font-size: 11px; color: var(--muted); background: var(--surface-2); border-radius: 6px; padding: 1px 6px; }
.b-row { cursor: pointer; }
.sub-sec { font-size: 12.5px; font-weight: 650; color: var(--muted); margin: 18px 0 6px; }
.panel.closed .cc { filter: grayscale(.7); opacity: .7; }

/* 年度 */
.mline { display: flex; justify-content: space-between; font-size: 12.5px; color: var(--muted); margin-top: 3px; }
.mline b { font-weight: 650; color: var(--text); }
.mline b.blue { color: var(--blue); } .mline b.red { color: var(--red); } .mline b.green { color: var(--green); }
.h-card-title { flex-wrap: wrap; }
.h-card-title small { margin-left: auto; font-weight: 500; color: var(--muted); font-size: 12px; }
.h-card-title em, .h-row-top em { font-style: normal; font-size: 11px; color: var(--muted); background: var(--surface-2); padding: 1px 6px; border-radius: 6px; }
.cell { position: relative; }
.cell.pending { background: var(--blue-soft); color: var(--blue); }
.cell.future { background: transparent; box-shadow: inset 0 0 0 1px var(--border); }
.cell.na { opacity: .4; }
.cell .pdot { position: absolute; top: 2px; right: 2px; width: 5px; height: 5px; border-radius: 50%; background: var(--blue); }
.legend .lg { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 4px; vertical-align: -1px; background: var(--surface-2); }
.legend .lg.full { background: var(--green-soft); } .legend .lg.pending { background: var(--blue-soft); }
.legend .lg.partial { background: var(--amber-soft); } .legend .lg.missed { background: var(--red-soft); }
.legend .lg.unused { box-shadow: inset 0 0 0 1.5px var(--accent); background: transparent; } .legend .lg.na { opacity: .4; }

/* 详情弹窗 */
.breakdown { display: flex; justify-content: space-between; gap: 8px; margin-top: 8px; font-size: 12.5px; color: var(--muted); }
.breakdown b { color: var(--text); font-weight: 650; }
.notice { margin-top: 12px; padding: 10px 12px; border-radius: 12px; background: var(--surface-2); color: var(--muted); font-size: 13px; }
.notice.warn { background: var(--amber-soft); color: var(--amber); }
.inline-form { margin-top: 12px; }
.inline-form summary { color: var(--accent); font-weight: 600; font-size: 14px; cursor: pointer; list-style: none; }
.inline-form summary::-webkit-details-marker { display: none; }
.inline-form summary::before { content: '＋ '; }
.inline-form[open] summary::before { content: '－ '; }
.row-form { display: flex; align-items: flex-start; gap: 8px; margin-top: 8px; }
.row-form .date-wrap { flex: 1; }
.row-form .input { flex: 1; min-height: 42px; }
.row-form .btn { flex: none; }
.entries li[data-action] { cursor: pointer; }
.entries .chev-s { color: var(--faint); margin-left: 2px; }
.entries .pill { flex: none; }
.entries.rules li, .entries.timeline li { cursor: default; }
.entries.rules p, .entries.timeline p { white-space: normal; }
.cert-li { align-items: flex-start !important; }
.li-actions { display: flex; flex-wrap: wrap; gap: 4px 10px; margin-top: 2px; }
.li-actions .link { padding: 2px 0; font-size: 13px; }
.link.back { padding-left: 0; margin-top: 4px; }
.rec-head { display: flex; align-items: center; gap: 10px; margin-top: 6px; }
.rec-head b { font-size: 26px; letter-spacing: -.02em; }
.card-box { margin-top: 12px; padding: 4px 12px 12px; border-radius: 14px; background: var(--surface-2); }
.card-box .field input { background: var(--surface); }
.seg.disabled { opacity: .55; }
.ov-wrap { display: flex; flex-direction: column; gap: 6px; }
.ov-row { display: grid; grid-template-columns: 1fr 1fr auto; gap: 8px; align-items: center; }
.ov-row .input { min-height: 40px; padding: 8px 10px; }
.ov-wrap > .link { align-self: flex-start; padding-left: 0; }


[hidden] { display: none !important; }

/* ================= Phase 2：登录、更新提示、保存状态 ================= */
body.auth-mode .tabbar, body.auth-mode .top { display: none; }
.auth { max-width: 380px; margin: 0 auto; padding: calc(var(--safe-t) + 48px) 4px 24px; }
.auth-head { text-align: center; }
.auth-head img { border-radius: 18px; box-shadow: var(--shadow); }
.auth-head h1 { font-size: 26px; font-weight: 750; margin-top: 14px; }
.auth-form { margin-top: 18px; }
.auth-form .notice { margin-bottom: 4px; }
.hint.center { text-align: center; margin-top: 18px; }
.s-details { margin: 0; padding: 12px 14px; border-top: 1px solid var(--border); }
.s-details form { margin-top: 4px; }
/* Phase 3B-2：提醒预览 */
.rem-day { align-items: flex-start; }
.rem-off .grow { font-size: 13.5px; color: var(--amber); }
.rem-date { font-size: 12.5px; color: var(--muted); }
.rem-title { font-weight: 650; margin-top: 2px; }
.rem-body { font-size: 13.5px; color: var(--text); line-height: 1.5; }

/* Phase 3B-1：推送提醒的设备列表 */
.dev-row { align-items: flex-start; }
.dev-meta { font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.dev-meta.dev-paused { color: var(--amber); } /* 3B-3：登录已过期、暂停接收自动提醒的设备 */

/* Phase 3A：旧地址迁移提示。放在主内容顶部、随内容滚动，不浮在任何按钮上方 */
.site-move {
  margin: 4px 0 12px; padding: 10px 12px; border-radius: 12px;
  background: var(--amber-soft); border: 1px solid color-mix(in srgb, var(--amber) 30%, transparent);
  font-size: 13.5px; line-height: 1.5;
}
.site-move b { display: block; color: var(--amber); font-weight: 650; }
.site-move p { color: var(--text); }
.site-move a { color: var(--accent); font-weight: 650; overflow-wrap: anywhere; }
body.auth-mode .site-move { max-width: 380px; margin: calc(var(--safe-t) + 16px) auto 0; }
body.auth-mode .site-move + .auth { padding-top: 28px; }
.update-banner {
  position: fixed; left: 50%; top: calc(var(--safe-t) + 10px); transform: translateX(-50%); z-index: 90;
  border: 0; border-radius: 999px; padding: 10px 18px; background: var(--accent); color: var(--on-accent);
  font-weight: 650; box-shadow: var(--shadow);
}
body.saving .tabbar::before {
  content: ''; position: absolute; top: -2px; left: 0; height: 2px; width: 40%;
  background: var(--accent); animation: saving 1s linear infinite;
}
@keyframes saving { from { left: -40%; } to { left: 100%; } }

/* ================= Batch C：卡片页使用状态、可选的规则核对 ================= */
.b-row .item-main { min-width: 0; }
.b-status { margin-top: 3px; font-size: 12.5px; font-weight: 600; color: var(--muted); }
.b-status.green { color: var(--green); } .b-status.blue { color: var(--blue); } .b-status.amber { color: var(--amber); }
/* 本年度周期：月度 12 个小圆点，季度/半年用短条；每个点有 18px 的点击区域，点开查看那一期 */
.pstrip { display: flex; gap: 0; margin: 3px 0 0 -5px; }
/* 月度：始终一行；每格最宽 18px，窄屏自动缩小，不换行、不拥挤 */
.pstrip.dense { display: grid; grid-template-columns: repeat(var(--n), minmax(0, 18px)); }
.pstrip.dense .ps { width: 100%; }
.ps { width: 18px; height: 18px; padding: 0; border: 0; background: none; display: grid; place-items: center; }
.ps i { position: relative; display: block; width: 8px; height: 8px; border-radius: 50%; background: var(--border); }
.pstrip:not(.dense) .ps { width: 34px; }
.pstrip:not(.dense) .ps i { width: 26px; height: 6px; border-radius: 3px; }
.ps.full i { background: var(--green); }
.ps.pending i { background: var(--blue); }
.ps.partial i { background: var(--amber); }
.ps.unused i { background: transparent; box-shadow: inset 0 0 0 1.5px var(--faint); }
.ps.missed i { background: var(--faint); opacity: .45; } /* 已结束未用完：中性灰，不强调（§1.4） */
.ps.future i { background: transparent; box-shadow: inset 0 0 0 1px var(--border); }
.ps.na i { opacity: .35; }
.ps.current i { outline: 1.5px solid var(--accent); outline-offset: 1.5px; }
.ps i b { position: absolute; top: -2px; right: -2px; width: 4px; height: 4px; border-radius: 50%; background: var(--blue); }
.verify-line { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 12px; padding-top: 10px; border-top: 1px solid var(--border); font-size: 12.5px; color: var(--muted); }
.verify-line .link { flex: none; font-size: 13px; padding: 4px 0; }
.vlist { list-style: none; margin: 12px 0 0; padding: 0; }
.vlist li { display: grid; grid-template-columns: 5.5em 1fr; gap: 10px; padding: 9px 0; border-top: 1px solid var(--border); font-size: 14px; }
.vlist li b { font-weight: 600; color: var(--muted); font-size: 13px; }
.vlist li span { min-width: 0; overflow-wrap: anywhere; white-space: pre-line; }
.cc.sm { width: 46px; height: 30px; }
a.btn { display: flex; align-items: center; justify-content: center; text-decoration: none; color: inherit; }
/* 不适用的周期（开卡前、卡种生效前、福利结束后）：置灰并加删除线，不能记录 */
.ps.void i { background: transparent; box-shadow: none; opacity: .5; }
.ps.void i::after { content: ""; position: absolute; left: -1px; right: -1px; top: 50%; height: 1.5px; margin-top: -.75px; background: var(--faint); transform: rotate(-35deg); }
.pstrip:not(.dense) .ps.void i::after { transform: none; }
.cell.void { background: transparent; color: var(--faint); text-decoration: line-through; opacity: .55; box-shadow: inset 0 0 0 1px var(--border); }
.legend .lg.void { background: transparent; box-shadow: inset 0 0 0 1px var(--border); position: relative; }
.legend .lg.void::after { content: ""; position: absolute; left: 0; right: 0; top: 50%; height: 1px; background: var(--faint); transform: rotate(-35deg); }

/* ================= Batch C2：无记录 ≠ 未使用；不强调未使用（§1.4） ================= */
/* 无记录：中性浅灰（不是红色）；确认未使用：中性灰加一条短横线 */
.ps.norecord i { background: var(--faint); opacity: .35; }
.ps.cunused i { background: transparent; box-shadow: inset 0 0 0 1px var(--faint); opacity: .8; }
.ps.cunused i::after { content: ""; position: absolute; left: 1.5px; right: 1.5px; top: 50%; height: 1.5px; margin-top: -.75px; background: var(--faint); }
.ps.missed i { background: var(--faint); opacity: .5; } /* 只用于免费券过期 */
.cell.norecord { background: var(--surface-2); color: var(--faint); }
.cell.cunused { background: transparent; color: var(--faint); box-shadow: inset 0 0 0 1px var(--border); }
.cell.missed { background: var(--surface-2); color: var(--muted); }
.legend .lg.norecord { background: var(--surface-2); }
.legend .lg.cunused { background: transparent; box-shadow: inset 0 0 0 1px var(--faint); }

/* ================= Batch C2 验收修正：可点击 vs 不可点击，确认未使用用浅粉 ================= */
/* 所有可以点开的格子：文字清楚可读（不再用很淡的灰），按下有反馈 */
button.cell { color: var(--muted); cursor: pointer; }
button.cell:active { filter: brightness(.94); }
.cell.norecord { background: var(--surface-2); color: var(--muted); }
.cell.na { opacity: 1; background: transparent; color: var(--muted); box-shadow: none; outline: 1px dashed color-mix(in srgb, var(--faint) 55%, transparent); outline-offset: -1px; }
.cell.future { color: var(--muted); }
.cell.cunused { background: var(--cunused-bg); color: var(--cunused-fg); box-shadow: none; }
/* 不适用、没有历史记录：只显示，不能点 */
span.cell.void { display: block; text-align: center; background: transparent; box-shadow: none; color: var(--faint); opacity: .5; text-decoration: line-through; cursor: default; }
.ps.cunused i { background: var(--cunused-fg); opacity: .55; box-shadow: none; }
.ps.cunused i::after { content: none; }
span.ps { cursor: default; }
.legend .lg.cunused { background: var(--cunused-bg); box-shadow: inset 0 0 0 1px var(--cunused-fg); }
.legend .lg.na { opacity: 1; background: transparent; outline: 1px dashed var(--border); outline-offset: -1px; }
.legend .lg.norecord { background: var(--surface-2); box-shadow: inset 0 0 0 1px var(--border); }

/* Batch D：卡片里的「已隐藏」折叠行（比页面级的折叠行更紧凑） */
.card-body .toggle-row.sub { margin: 8px 0 0; padding: 9px 2px; background: none; box-shadow: none; border-top: 1px solid var(--border); border-radius: 0; font-size: 13px; }
/* 隐藏的福利：可以点开、可以恢复，所以只轻微减淡，不做成禁用的样子 */
.b-row.is-hidden .item-main, .b-row.is-hidden .ico { opacity: .75; }

/* ================= Batch D 验收修正 ================= */
/* 主动选择「本期不使用」：中性色，只用实线边框区分（空底 + 边框），不加额外符号；和「确认未使用」的浅粉分开。周期结束后仍保持 */
.cell.skipped { background: transparent; color: var(--muted); box-shadow: inset 0 0 0 1px var(--faint); }
.cell.skipped.current { box-shadow: inset 0 0 0 1.5px var(--accent); }
.ps.skipped i { background: transparent; box-shadow: inset 0 0 0 1.5px var(--muted); }
.ps.skipped i::after { content: ""; position: absolute; left: 2px; right: 2px; top: 50%; height: 1.5px; margin-top: -.75px; background: var(--muted); }
.pstrip:not(.dense) .ps.skipped i::after { left: 8px; right: 8px; }
.legend .lg.skipped { background: transparent; box-shadow: inset 0 0 0 1px var(--faint); }
/* 已隐藏福利（年度页底部折叠区）：没有使用的周期用中性样式，没有当前周期强调框；可以点开查看 */
.cell.idle { background: var(--surface-2); color: var(--muted); box-shadow: none; }
.h-card.quiet .h-row-top span:first-child { color: var(--muted); }

/* 年度页折叠区（本期不使用）里的「撤销」 */
.link.sm { font-size: 12.5px; padding: 0 0 0 10px; }

/* ================= Batch E-2：固定订阅自动记录 ================= */
.plan-box .sub-sec { margin-top: 10px; }
.plan-line { font-size: 14px; margin: 2px 0 6px; }
.plan-preview { font-size: 13px; line-height: 1.5; }
.plan-preview:empty { display: none; }
.plan-preview b { display: block; margin-bottom: 2px; font-weight: 650; color: var(--text); }
.entries .auto-tag { font-style: normal; font-size: 11px; font-weight: 600; color: var(--muted); background: var(--surface-2); border-radius: 6px; padding: 1px 6px; margin-left: 6px; }
.pv-row { padding: 6px 0; border-top: 1px solid var(--border); }
.pv-row:first-of-type { border-top: 0; }
.pv-dup { color: var(--amber); font-size: 12.5px; margin-top: 2px; }
.pv-skip { margin-top: 6px; font-weight: 500; font-size: 13px; }
.pv-muted { color: var(--muted); font-size: 12.5px; }
.pv-hint { color: var(--muted); font-size: 12px; margin: 2px 0 4px; font-weight: 500; }
.pv-next { margin-top: 6px; }
.pv-skip .pv-dup { display: block; color: var(--amber); }

/* ================= 收尾 F1 ================= */
/* 年度页折叠分组：福利名称为主标题，「卡名 · 成员名」为次要信息 */
.h-row-meta { font-size: 12px; color: var(--muted); margin-top: 1px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* 全部记录 */
.entries.all-records li p { white-space: normal; }

/* F2-C 免费券：手上的券和下一张券的发放状态放在同一组；到期日期完整显示，空间不够时换行，不截断 */
.cert-lines { margin-top: 4px; display: flex; flex-direction: column; gap: 3px; }
.cert-line { display: flex; flex-wrap: wrap; align-items: center; gap: 2px 8px; font-size: 12.5px; color: var(--muted); white-space: normal; }
.cert-line b { color: var(--text); font-variant-numeric: tabular-nums; }
.cert-line .link.sm { padding: 0; }
.cert-line.next.amber { color: var(--amber); } .cert-line.next.green { color: var(--green); }
.b-status.cert-b { margin-top: 2px; }
.cert-box .cert-lines { margin: 6px 0; }
.cert-li span { display: inline-block; }
.entries li p.wrap { white-space: normal; }
/* F2-B 多年周期 */
.my-box .pill { white-space: normal; text-align: right; }
.my-row { cursor: pointer; }
.cert-li { flex-wrap: wrap; }
.cert-li .cert-edit { flex-basis: 100%; margin-top: 2px; }
/* F3 最近删除 */
.trash-li { align-items: center !important; gap: 10px; }
.trash-li .btn.sm { flex: none; padding: 6px 14px; min-height: 0; }

/* F4 从预设选择 */
.preset-entry { margin-bottom: 14px; padding-bottom: 12px; border-bottom: 1px solid var(--border); }
.preset-entry .btn { width: 100%; }
.pk-list li { flex-wrap: wrap; align-items: flex-start; }
.pk-list .check-row { margin-top: 0; flex: 1 1 100%; }
.pk-list .pk-notes { white-space: normal; }
.pk-list li > .btn.sm { margin-left: 30px; padding: 5px 12px; min-height: 0; font-size: 13px; }
.pk-list li > div + .btn.sm { margin-left: 0; flex: none; }
.pre-box { margin-top: 4px; padding: 10px 12px; border-radius: 12px; background: var(--surface-2); color: var(--muted); font-size: 13px; white-space: pre-wrap; overflow-wrap: anywhere; }
.wrap-any { overflow-wrap: anywhere; }

/* ================= UI/UX 集中优化 UI-A ================= */
/* UI-01：可以点进详情的福利名称后面加浅色「›」，和右侧「编辑」区分 */
.chev-s { color: var(--faint); margin-left: 4px; font-weight: 400; }
.h-row-top.tap { cursor: pointer; }
/* UI-02：详情顶部的「编辑」 */
.log-head .log-main { flex: 1; min-width: 0; }
.log-head .head-edit { flex: none; align-self: flex-start; margin-top: 2px; padding: 6px 14px; min-height: 0; }
/* UI-03：长表单的保存按钮吸在弹出层底部。只属于所在的表单（滚过这个表单后回到原位，不遮挡下面的其他操作）；
   留出 iPhone 底部安全区；正在输入（键盘弹出）时取消吸底，避免挡住输入框。撤销提示在屏幕顶部，不会和它重叠。 */
.sheet .btns.sticky-save {
  /* 吸附位置要扣掉弹出层自己的底部内边距（20px + 安全区），否则按钮下面会露出一条滚动的内容 */
  position: sticky; bottom: calc(-20px - var(--safe-b)); z-index: 2;
  margin: 14px -18px 0; padding: 10px 18px calc(10px + var(--safe-b));
  background: var(--surface); border-top: 1px solid var(--border);
}
.sheet form:has(:is(input:not([type=checkbox]):not([type=radio]), textarea, select):focus) .btns.sticky-save {
  position: static; border-top-color: transparent; padding-bottom: 10px;
}
/* UI-05：文本框按内容调整高度（JS 设置 height），超过半屏时框内滚动 */
.sheet .field textarea { overflow-y: auto; }

/* UI-08：预计发放三选一，只显示选中方式的输入 */
.issue-field .issue-days, .issue-field .issue-date { display: none; margin-top: 8px; }
.issue-field:has(input[name=issueMode][value=days]:checked) .issue-days,
.issue-field:has(input[name=issueMode][value=date]:checked) .issue-date { display: block; }
.seg input:disabled + span { opacity: .4; }
