:root {
  --bg: #f4f6fa;
  --card: #ffffff;
  --fg: #1f2937;
  --muted: #6b7280;
  --line: #e5e7eb;
  --brand: #2563eb;
  --brand-soft: #eff6ff;
  --ok: #059669;
  --ok-soft: #ecfdf5;
  --warn: #d97706;
  --danger: #dc2626;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.04), 0 6px 20px rgba(16, 24, 40, 0.06);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB",
    "Microsoft YaHei", "Source Han Sans SC", "Noto Sans CJK SC", sans-serif;
  font-size: 16px;
  line-height: 1.6;
  -webkit-text-size-adjust: 100%;
}

.wrap {
  max-width: 720px;
  margin: 0 auto;
  padding: 16px 14px 120px;
}

/* ---------------------------------- 顶部 ---------------------------------- */

.top {
  position: sticky;
  top: 0;
  z-index: 20;
  background: rgba(244, 246, 250, 0.92);
  backdrop-filter: saturate(180%) blur(10px);
  border-bottom: 1px solid var(--line);
  padding: 10px 14px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.top .who {
  font-weight: 600;
  font-size: 16px;
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.top .who small {
  display: block;
  font-weight: 400;
  font-size: 12px;
  color: var(--muted);
}

.badge {
  font-size: 12px;
  padding: 3px 9px;
  border-radius: 999px;
  background: #f3f4f6;
  color: var(--muted);
  white-space: nowrap;
}
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.draft { background: #fffbeb; color: var(--warn); }

/* ---------------------------------- 卡片 ---------------------------------- */

.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px 16px;
  margin-bottom: 16px;
}

.card > h2 {
  margin: 0 0 4px;
  font-size: 17px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.card > h2 .num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 7px;
  background: var(--brand);
  color: #fff;
  font-size: 13px;
  flex: 0 0 auto;
}

.card .desc {
  color: var(--muted);
  font-size: 13px;
  margin: 0 0 14px;
}

.hint {
  font-size: 12.5px;
  color: var(--muted);
  background: #f9fafb;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px 10px;
  margin: 0 0 14px;
}

/* ---------------------------------- 日期行 --------------------------------- */

.day {
  border-top: 1px solid var(--line);
  padding: 10px 0;
}
.day:first-of-type { border-top: none; }

.day-head {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 40px;
}

.day-name {
  font-weight: 600;
  width: 52px;
  flex: 0 0 auto;
}

.day-sum {
  flex: 1;
  min-width: 0;
  color: var(--muted);
  font-size: 13.5px;
  font-variant-numeric: tabular-nums;
}
.day-sum.on { color: var(--brand); font-weight: 600; }

/* 开关 */
.switch {
  position: relative;
  width: 52px;
  height: 30px;
  flex: 0 0 auto;
}
.switch input {
  position: absolute;
  opacity: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  cursor: pointer;
}
.switch .slider {
  position: absolute;
  inset: 0;
  background: #d1d5db;
  border-radius: 999px;
  transition: background 0.18s;
  pointer-events: none;
}
.switch .slider::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
  transition: transform 0.18s;
}
.switch input:checked + .slider { background: var(--brand); }
.switch input:checked + .slider::after { transform: translateX(22px); }
.switch input:focus-visible + .slider { outline: 2px solid var(--brand); outline-offset: 2px; }

/* --------------------------------- 双端滑块 -------------------------------- */

.rng {
  padding: 6px 0 2px;
  user-select: none;
  -webkit-user-select: none;
}
.rng[hidden] { display: none; }

.rng-head {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 4px;
}
.rng-val {
  font-size: 15px;
  font-weight: 600;
  color: var(--brand);
  font-variant-numeric: tabular-nums;
}
.rng-tip { font-size: 12px; color: var(--muted); }

.rng-track {
  position: relative;
  height: 40px;
  margin: 0 2px;
  touch-action: pan-y;
  cursor: pointer;
}
.rng-track::before {
  content: "";
  position: absolute;
  top: 17px;
  left: 0;
  right: 0;
  height: 6px;
  border-radius: 3px;
  background: #e5e7eb;
}
.rng-fill {
  position: absolute;
  top: 17px;
  height: 6px;
  border-radius: 3px;
  background: var(--brand);
}
.rng-knob {
  position: absolute;
  top: 6px;
  width: 28px;
  height: 28px;
  margin-left: -14px;
  border-radius: 50%;
  background: #fff;
  border: 3px solid var(--brand);
  box-shadow: 0 2px 6px rgba(37, 99, 235, 0.3);
  touch-action: pan-y;
  cursor: grab;
  padding: 0;
}
.rng-knob:active { cursor: grabbing; }
.rng-knob:focus-visible { outline: 2px solid var(--brand); outline-offset: 3px; }

.rng-scale {
  display: flex;
  justify-content: space-between;
  font-size: 11.5px;
  color: #9ca3af;
  margin: 0 2px;
  font-variant-numeric: tabular-nums;
}

/* ---------------------------------- 选项组 --------------------------------- */

.opts {
  display: grid;
  gap: 10px;
}
.opts.cols { grid-template-columns: 1fr 1fr; }
.opts.cols3 { grid-template-columns: repeat(3, 1fr); }

.opt {
  position: relative;
  border: 1.5px solid var(--line);
  border-radius: 12px;
  padding: 14px 12px;
  text-align: center;
  font-size: 15px;
  background: #fff;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s, color 0.15s;
  min-height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.opt input { position: absolute; opacity: 0; pointer-events: none; }
.opt.sel {
  border-color: var(--brand);
  background: var(--brand-soft);
  color: var(--brand);
  font-weight: 600;
}
.opt:active { transform: scale(0.99); }

.parity { margin-top: 14px; }
.parity .q { font-size: 13.5px; color: var(--muted); margin-bottom: 8px; }

.none-row {
  margin-top: 14px;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 14px;
  color: var(--muted);
  border-top: 1px dashed var(--line);
  padding-top: 12px;
}
.none-row input { width: 20px; height: 20px; accent-color: var(--brand); }

/* ---------------------------------- 备注 ---------------------------------- */

.note-area {
  width: 100%;
  min-height: 88px;
  padding: 12px 14px;
  border: 1.5px solid var(--line);
  border-radius: 12px;
  font-family: inherit;
  font-size: 15px;
  line-height: 1.6;
  color: var(--fg);
  background: #fff;
  resize: vertical;
  -webkit-appearance: none;
}
.note-area::placeholder { color: #9ca3af; }
.note-area:focus { outline: none; border-color: var(--brand); }
.note-foot { text-align: right; font-size: 12px; color: var(--muted); margin-top: 6px; }
.note-item {
  border-left: 3px solid var(--brand);
  background: var(--brand-soft);
  border-radius: 0 10px 10px 0;
  padding: 9px 12px;
  margin-bottom: 8px;
  font-size: 14px;
  white-space: pre-wrap;
  word-break: break-word;
}
.note-item b { color: var(--brand); }

/* ---------------------------------- 底部栏 --------------------------------- */

.foot {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 30;
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(10px);
  border-top: 1px solid var(--line);
  padding: 10px 14px calc(10px + env(safe-area-inset-bottom));
}
.foot-inner {
  max-width: 720px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 12px;
}
.save-state {
  flex: 1;
  font-size: 12.5px;
  color: var(--muted);
  min-width: 0;
}
.save-state.err { color: var(--danger); }
.save-state.ok { color: var(--ok); }

.btn {
  border: none;
  border-radius: 12px;
  padding: 13px 22px;
  font-size: 16px;
  font-weight: 600;
  background: var(--brand);
  color: #fff;
  cursor: pointer;
  font-family: inherit;
}
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn.ghost { background: #f3f4f6; color: var(--fg); font-weight: 500; }
.btn.block { width: 100%; }
.btn.sm { padding: 9px 14px; font-size: 14px; border-radius: 10px; }

/* ---------------------------------- 其他 ---------------------------------- */

.done {
  text-align: center;
  padding: 48px 20px;
}
.done .icon { font-size: 52px; line-height: 1; }
.done h1 { font-size: 20px; margin: 16px 0 6px; }
.done p { color: var(--muted); font-size: 14px; margin: 6px 0; }

.loading, .error-box {
  text-align: center;
  color: var(--muted);
  padding: 60px 20px;
  font-size: 15px;
}
.error-box h1 { font-size: 18px; color: var(--fg); }

/* ---------------------------------- 管理端 --------------------------------- */

.admin-top {
  position: sticky;
  top: 0;
  z-index: 20;
  background: #111827;
  color: #fff;
  padding: 12px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
}
.admin-top h1 { font-size: 16px; margin: 0; flex: 1; }
.admin-wrap { max-width: 1080px; margin: 0 auto; padding: 16px 14px 60px; }

.tabs {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding: 4px 0 12px;
  -webkit-overflow-scrolling: touch;
}
.tab {
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 999px;
  padding: 7px 14px;
  font-size: 14px;
  cursor: pointer;
  white-space: nowrap;
  font-family: inherit;
  color: var(--muted);
}
.tab.active { background: var(--brand); border-color: var(--brand); color: #fff; font-weight: 600; }

table.grid {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
}
table.grid th, table.grid td {
  border-bottom: 1px solid var(--line);
  padding: 9px 8px;
  text-align: left;
  vertical-align: top;
}
table.grid th { color: var(--muted); font-weight: 600; white-space: nowrap; font-size: 12.5px; }
table.grid td.num { font-variant-numeric: tabular-nums; white-space: nowrap; }
.scroll-x { overflow-x: auto; -webkit-overflow-scrolling: touch; }

.heat {
  display: flex;
  gap: 2px;
  margin-top: 6px;
}
.heat i {
  flex: 1;
  height: 26px;
  border-radius: 3px;
  background: #eef2f7;
  font-style: normal;
  font-size: 10px;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-variant-numeric: tabular-nums;
}

.daycard { border: 1px solid var(--line); border-radius: 12px; padding: 12px; margin-bottom: 12px; }
.daycard h3 { margin: 0 0 8px; font-size: 15px; display: flex; align-items: center; gap: 8px; }
.daycard h3 .cnt { font-size: 12px; color: var(--muted); font-weight: 400; }

.bar-row { display: flex; align-items: center; gap: 8px; font-size: 13px; margin: 4px 0; }
.bar-row .nm { width: 62px; flex: 0 0 auto; color: var(--muted); }
.bar-track { position: relative; flex: 1; height: 18px; background: #f3f4f6; border-radius: 4px; overflow: hidden; }
.bar-track i { position: absolute; top: 0; bottom: 0; background: rgba(37, 99, 235, 0.55); border-radius: 4px; }
.bar-row .tm { width: 104px; flex: 0 0 auto; text-align: right; font-variant-numeric: tabular-nums; color: var(--muted); font-size: 12.5px; }

.rec { border-left: 3px solid var(--ok); background: var(--ok-soft); padding: 10px 12px; border-radius: 0 10px 10px 0; margin-bottom: 8px; font-size: 14px; }
.rec b { font-variant-numeric: tabular-nums; }

.linkrow { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.linkrow .nm { width: 70px; flex: 0 0 auto; font-size: 14px; }
.linkrow input {
  flex: 1;
  min-width: 0;
  font-size: 12.5px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 9px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  color: var(--muted);
  background: #fafafa;
}
.muted { color: var(--muted); font-size: 13px; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.login-box { max-width: 360px; margin: 12vh auto; }
input.pw {
  width: 100%;
  padding: 13px 14px;
  font-size: 16px;
  border: 1.5px solid var(--line);
  border-radius: 12px;
  font-family: inherit;
  margin-bottom: 12px;
}
input.pw:focus { outline: none; border-color: var(--brand); }

.tag { display: inline-block; font-size: 12px; padding: 1px 8px; border-radius: 999px; background: #f3f4f6; color: var(--muted); }
.tag.yes { background: var(--ok-soft); color: var(--ok); }
.tag.maybe { background: #fffbeb; color: var(--warn); }
.tag.no { background: #fef2f2; color: var(--danger); }

@media (min-width: 700px) {
  .wrap { padding-top: 24px; }
  .card { padding: 22px 22px; }
}
