:root {
  --bg: #f2f3f5;
  --card: #ffffff;
  --text: #1c1c1e;
  --muted: #8a8f98;
  --line: #e6e8ec;
  --accent: #b3001b;
  --accent-soft: #fdeced;
  --ok: #1d7a4a;
  --warn: #b06a00;
  --radius: 16px;
  --safe-b: env(safe-area-inset-bottom, 0px);
}

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

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Helvetica Neue", "Segoe UI", sans-serif;
  font-size: 15px;
  line-height: 1.5;
}

body { padding-bottom: calc(72px + var(--safe-b)); }

button, input, select { font-family: inherit; font-size: inherit; color: inherit; }

/* ---------------- top bar ---------------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: rgba(242, 243, 245, 0.92);
  backdrop-filter: saturate(1.6) blur(12px);
  border-bottom: 1px solid var(--line);
  padding-top: env(safe-area-inset-top, 0px);
}
.topbar-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 18px 10px;
}
.greet { margin: 0; font-size: 17px; font-weight: 600; }
.today-line { margin: 2px 0 0; font-size: 12.5px; color: var(--muted); }
.clock-chip {
  font-variant-numeric: tabular-nums;
  font-size: 13px;
  font-weight: 600;
  color: var(--accent);
  background: var(--accent-soft);
  padding: 5px 11px;
  border-radius: 999px;
  white-space: nowrap;
}
.local-line {
  margin: 0;
  padding: 0 18px 10px;
  font-size: 12px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.field-note {
  margin: 6px 0 0;
  font-size: 12px;
  color: var(--muted);
  line-height: 1.5;
}

/* ---------------- layout ---------------- */

main { padding: 16px 16px 8px; max-width: 680px; margin: 0 auto; }
.page[hidden] { display: none; }

.section-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  letter-spacing: 0.02em;
  margin: 22px 4px 10px;
}
.section-title:first-child { margin-top: 4px; }
.section-note { margin: -6px 4px 10px; font-size: 12px; color: var(--muted); }

.card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: 0 1px 2px rgba(16, 24, 40, 0.04);
  margin-bottom: 14px;
}
.card-note { margin: 10px 0 0; font-size: 12.5px; color: var(--muted); line-height: 1.55; }
.footer-note { text-align: center; font-size: 12px; color: var(--muted); padding: 8px 0 20px; }

/* ---------------- hero ---------------- */

.hero {
  background: linear-gradient(180deg, #ffffff 0%, #fdf6f6 100%);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 20px 18px 18px;
  box-shadow: 0 2px 10px rgba(16, 24, 40, 0.05);
}
.hero-label { margin: 0; font-size: 12.5px; color: var(--muted); font-weight: 600; }
.hero-count {
  margin: 8px 0 2px;
  font-size: 34px;
  font-weight: 700;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
  color: var(--accent);
}
.hero-sub { margin: 0; font-size: 13px; color: var(--muted); min-height: 19px; }
.hero-course { margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--line); }
.hero-course h3 { margin: 0 0 4px; font-size: 16px; font-weight: 600; }
.hero-course p { margin: 0; font-size: 13px; color: var(--muted); }
.hero.urgent { border-color: #f0c9cd; background: linear-gradient(180deg, #ffffff 0%, #fdeced 100%); }
.hero.now { background: linear-gradient(180deg, #ffffff 0%, #eaf6ef 100%); border-color: #c8e6d5; }
.hero.now .hero-count { color: var(--ok); }
.hero.free .hero-count { color: var(--muted); font-size: 26px; }

.badge {
  display: inline-block;
  font-size: 11.5px;
  font-weight: 600;
  padding: 3px 9px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  margin-bottom: 8px;
}

/* ---------------- list ---------------- */

.list { display: flex; flex-direction: column; gap: 10px; }
.item {
  background: var(--card);
  border-radius: 14px;
  padding: 13px 15px;
  display: flex;
  gap: 13px;
  align-items: flex-start;
  box-shadow: 0 1px 2px rgba(16, 24, 40, 0.04);
}
.item-time {
  min-width: 52px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  padding-top: 1px;
}
.item-body { flex: 1; min-width: 0; }
.item-body h4 { margin: 0 0 3px; font-size: 15px; font-weight: 600; }
.item-body p { margin: 0; font-size: 12.5px; color: var(--muted); }
.item.done .item-body h4 { text-decoration: line-through; color: var(--muted); }
.item.today-now { outline: 1.5px solid #c8e6d5; }

.item-right { display: flex; flex-direction: column; align-items: flex-end; gap: 8px; }
.icon-btn {
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 12.5px;
  padding: 2px 0;
  cursor: pointer;
}
.icon-btn.danger { color: #c0392b; }

.empty {
  text-align: center;
  color: var(--muted);
  font-size: 13.5px;
  padding: 22px 16px;
  background: var(--card);
  border-radius: 14px;
}

.pill {
  display: inline-block;
  font-size: 11.5px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 999px;
  background: #f0f1f4;
  color: var(--muted);
}
.pill.warn { background: #fff4e0; color: var(--warn); }
.pill.danger { background: var(--accent-soft); color: var(--accent); }
.pill.ok { background: #eaf6ef; color: var(--ok); }

/* ---------------- week grid ---------------- */

.week-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; padding-bottom: 6px; }
.week-grid {
  display: grid;
  grid-template-columns: 44px repeat(7, 104px);
  min-width: 776px;
}
.wg-head {
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  text-align: center;
  padding: 4px 0 10px;
  border-bottom: 1px solid var(--line);
}
.wg-head.is-today { color: var(--accent); }
.wg-times, .wg-day {
  position: relative;
  height: 720px; /* (20-8) 小时 × 60px */
}
.wg-times span {
  position: absolute;
  right: 8px;
  transform: translateY(-50%);
  font-size: 11px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.wg-day {
  border-left: 1px solid var(--line);
  background-image: linear-gradient(to bottom, #eef0f3 1px, transparent 1px);
  background-size: 100% 60px;
}
.wg-event {
  position: absolute;
  left: 4px;
  right: 4px;
  border-radius: 9px;
  padding: 6px 7px;
  font-size: 11px;
  line-height: 1.35;
  border-left: 3px solid var(--accent);
  background: var(--accent-soft);
  color: #7a0013;
  overflow: hidden;
  box-shadow: 0 1px 2px rgba(16, 24, 40, 0.05);
}
.wg-event b { display: block; font-size: 11.5px; }
.wg-event span { color: #9a5a63; display: block; }
.wg-event.is-live { outline: 1.5px solid #7fc79f; }

/* ---------------- forms ---------------- */

.form .field { margin-bottom: 12px; }
.field label {
  display: block;
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 5px;
  font-weight: 600;
}
.field input, .field select {
  width: 100%;
  border: 1px solid var(--line);
  background: #fbfbfc;
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 15px;
  appearance: none;
}
.field input:focus, .field select:focus { outline: 2px solid #f3c6cb; border-color: #e2a3ab; }
.field-row { display: flex; gap: 10px; flex-wrap: wrap; }
.field-row .field { flex: 1 1 110px; }
.form-note { margin: 10px 0 0; font-size: 12px; color: var(--muted); }

.primary-btn {
  width: 100%;
  border: 0;
  border-radius: 12px;
  background: var(--accent);
  color: #fff;
  font-size: 15px;
  font-weight: 600;
  padding: 12px;
  cursor: pointer;
}
.primary-btn:active { opacity: 0.85; }
.ghost-btn {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  color: var(--text);
  font-size: 14.5px;
  font-weight: 500;
  padding: 11px;
  margin-top: 9px;
  cursor: pointer;
}
.link-btn { border: 0; background: transparent; color: var(--accent); font-size: 13px; font-weight: 600; padding: 0; }

.row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 6px 0;
}
.row-label { font-size: 14.5px; }
.row-value { font-size: 13.5px; color: var(--muted); font-variant-numeric: tabular-nums; }
input[type="range"] {
  width: 100%;
  margin: 4px 0 14px;
  accent-color: var(--accent);
}

.steps { margin: 0; padding-left: 20px; font-size: 13.5px; line-height: 1.75; }
.steps li { margin-bottom: 6px; }

.lead-line { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 7px 0; border-bottom: 1px solid var(--line); }
.lead-line:last-child { border-bottom: 0; }
.lead-line span:first-child { font-size: 13.5px; }
.lead-line input { width: 76px; text-align: center; }

/* ---------------- install hint ---------------- */

.install-hint { background: #fff8e6; border-bottom: 1px solid #f0e0bb; }
.install-hint-inner { padding: 12px 18px; font-size: 13px; display: flex; flex-direction: column; gap: 4px; }
.install-hint-inner span { color: #7a6320; }

/* ---------------- tab bar ---------------- */

.tabbar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 30;
  display: flex;
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: saturate(1.6) blur(14px);
  border-top: 1px solid var(--line);
  padding: 6px 0 calc(6px + var(--safe-b));
}
.tab {
  flex: 1;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 11.5px;
  font-weight: 600;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 6px 0 2px;
  cursor: pointer;
}
.tab-dot { width: 18px; height: 3px; border-radius: 2px; background: currentColor; opacity: 0.35; }
.tab.active { color: var(--accent); }
.tab.active .tab-dot { opacity: 1; }
