:root {
  --bg: #0b0f1a;
  --card: #141a2a;
  --card2: #1b2338;
  --border: #232c44;
  --text: #e8ecf6;
  --muted: #8b94ad;
  --accent: #6d7ff5;
  --accent2: #38bdf8;
  --green: #34d399;
  --amber: #fbbf24;
  --red: #f87171;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html { -webkit-text-size-adjust: 100%; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  min-height: 100vh;
}

.hidden { display: none !important; }
.muted { color: var(--muted); font-size: 12px; }
.fg-text { color: var(--text); }

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

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 14px 16px;
  margin-bottom: 12px;
}

h3 { font-size: 14px; margin-bottom: 12px; }

button {
  font-family: inherit;
  cursor: pointer;
  border: none;
  background: none;
  color: var(--text);
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  background: rgba(11, 15, 26, 0.9);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}

.brand {
  font-weight: 700;
  font-size: 15px;
  background: linear-gradient(90deg, var(--accent), var(--accent2));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  white-space: nowrap;
}

.tabs { display: flex; gap: 4px; flex: 1; justify-content: center; }

.tab {
  padding: 6px 16px;
  border-radius: 999px;
  font-size: 13px;
  color: var(--muted);
}

.tab.active { background: var(--card2); color: var(--text); }

.link-btn { font-size: 12px; color: var(--muted); white-space: nowrap; }

.datebar {
  display: flex;
  align-items: center;
  gap: 10px;
}

.nav-btn {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: var(--card2);
  border: 1px solid var(--border);
  font-size: 18px;
  line-height: 1;
  flex-shrink: 0;
}

.nav-btn:disabled { opacity: 0.3; cursor: default; }

.datebox { flex: 1; text-align: center; }
#dateLabel { font-size: 16px; font-weight: 600; }

.mini-btn {
  font-size: 12px;
  padding: 6px 12px;
  border-radius: 999px;
  background: var(--card2);
  border: 1px solid var(--border);
}

.progress-info {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}

.pct { font-size: 20px; font-weight: 700; color: var(--accent2); }

.bar {
  height: 10px;
  border-radius: 999px;
  background: var(--card2);
  overflow: hidden;
}

#barFill {
  height: 100%;
  width: 0%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--accent), var(--accent2));
  transition: width 0.3s;
}

.alldone {
  margin-top: 10px;
  font-size: 13px;
  color: var(--green);
  font-weight: 600;
}

.task { border-left: 3px solid var(--cat, var(--accent)); }

.task.done { opacity: 0.72; }

.task-head {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.cat-badge {
  font-size: 11px;
  padding: 2px 9px;
  border-radius: 999px;
  color: var(--cat);
  background: color-mix(in srgb, var(--cat) 16%, transparent);
  white-space: nowrap;
}

.task-name { font-size: 14px; font-weight: 600; }

.task-meta { font-size: 12px; color: var(--muted); margin-left: auto; white-space: nowrap; }

.task-tip { margin: 6px 0 4px; line-height: 1.5; }

.units { margin-top: 6px; }

.unit {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 8px;
  border-radius: 9px;
  cursor: pointer;
  font-size: 13px;
}

.unit:hover { background: var(--card2); }

.checkbox {
  width: 19px;
  height: 19px;
  border-radius: 6px;
  border: 2px solid var(--muted);
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  color: #04281c;
  transition: all 0.15s;
}

.checkbox.on {
  background: var(--green);
  border-color: var(--green);
}

.checkbox.on::after { content: "✓"; font-weight: 700; }

.task.single { cursor: pointer; }
.task.single:hover { background: var(--card2); }

.note-card label { font-size: 13px; font-weight: 600; display: block; margin-bottom: 8px; }

textarea, input[type="password"] {
  width: 100%;
  background: var(--card2);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  padding: 10px 12px;
  font-size: 14px;
  font-family: inherit;
  outline: none;
}

textarea:focus, input[type="password"]:focus { border-color: var(--accent); }

.skip-note { line-height: 1.7; padding: 4px 6px; }

.stat-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}

@media (min-width: 640px) {
  .stat-grid { grid-template-columns: repeat(4, 1fr); }
}

.stat { text-align: center; padding: 16px 10px; margin-bottom: 0; }

.stat-num {
  font-size: 26px;
  font-weight: 700;
  background: linear-gradient(90deg, var(--accent), var(--accent2));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.stat-label { font-size: 11px; color: var(--muted); margin-top: 4px; }

#viewStats .stat-grid { margin-bottom: 12px; }

.bars {
  display: flex;
  align-items: flex-end;
  gap: 6px;
  height: 130px;
}

.barcol {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  height: 100%;
}

.barfill-wrap { flex: 1; width: 100%; display: flex; align-items: flex-end; }

.barfill {
  width: 100%;
  border-radius: 4px 4px 0 0;
  background: linear-gradient(180deg, var(--accent2), var(--accent));
  min-height: 2px;
}

.barfill.zero { background: var(--card2); }

.barlabel { font-size: 10px; color: var(--muted); }

.hm-wrap { overflow-x: auto; padding-bottom: 4px; }

#heatmap {
  display: grid;
  grid-template-rows: repeat(7, 13px);
  grid-auto-flow: column;
  grid-auto-columns: 13px;
  gap: 3px;
  width: max-content;
}

.hm-cell {
  width: 13px;
  height: 13px;
  border-radius: 3px;
  background: var(--card2);
  cursor: pointer;
}

.hm-cell.future { background: transparent; cursor: default; }
.hm-cell.l1 { background: rgba(109, 127, 245, 0.35); }
.hm-cell.l2 { background: rgba(109, 127, 245, 0.7); }
.hm-cell.l3 { background: var(--accent2); }

.hm-legend { display: flex; align-items: center; gap: 4px; margin-top: 8px; justify-content: flex-end; }
.hm-legend .hm-cell { cursor: default; }

.cat-row { margin-bottom: 12px; }
.cat-row-head { display: flex; justify-content: space-between; font-size: 13px; margin-bottom: 5px; }
.cat-bar { height: 8px; border-radius: 999px; background: var(--card2); overflow: hidden; }
.cat-fill { height: 100%; border-radius: 999px; }

.tt-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 0;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}

.tt-row:last-child { border-bottom: none; }
.tt-name { width: 130px; flex-shrink: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tt-cat { width: 40px; flex-shrink: 0; font-size: 11px; }
.tt-bar { flex: 1; height: 7px; border-radius: 999px; background: var(--card2); overflow: hidden; }
.tt-fill { height: 100%; border-radius: 999px; background: var(--accent); }
.tt-num { width: 72px; text-align: right; color: var(--muted); font-size: 12px; flex-shrink: 0; }

.cal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
#calTitle { font-size: 15px; font-weight: 600; }

.cal-week {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
  text-align: center;
  font-size: 11px;
  color: var(--muted);
  margin-bottom: 6px;
}

.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
}

.cal-cell {
  aspect-ratio: 1;
  border-radius: 9px;
  background: var(--card2);
  border: 1px solid transparent;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  cursor: pointer;
  color: var(--text);
}

.cal-cell.empty { background: transparent; cursor: default; }
.cal-cell.today { border-color: var(--accent2); }
.cal-cell.l1 { background: rgba(109, 127, 245, 0.35); }
.cal-cell.l2 { background: rgba(109, 127, 245, 0.7); }
.cal-cell.l3 { background: var(--accent2); color: #06121f; font-weight: 700; }

.cal-tip { margin-top: 8px; text-align: center; }

.auth {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.auth-card { width: 100%; max-width: 340px; padding: 28px 24px; text-align: center; }

.auth-logo {
  width: 56px;
  height: 56px;
  border-radius: 16px;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 16px;
  margin: 0 auto 14px;
}

.auth-card h1 { font-size: 18px; margin-bottom: 6px; }
.auth-card p { margin-bottom: 16px; }
.auth-card input { margin-bottom: 10px; text-align: center; }

.btn-primary {
  width: 100%;
  padding: 11px;
  border-radius: 10px;
  background: linear-gradient(90deg, var(--accent), var(--accent2));
  font-size: 14px;
  font-weight: 600;
  color: #fff;
}

.auth-err { color: var(--red); font-size: 13px; margin-top: 10px; min-height: 16px; }

#toast {
  position: fixed;
  left: 50%;
  bottom: 30px;
  transform: translateX(-50%) translateY(20px);
  background: var(--card2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 10px 18px;
  border-radius: 999px;
  font-size: 13px;
  opacity: 0;
  pointer-events: none;
  transition: all 0.25s;
  z-index: 50;
  max-width: 90vw;
}

#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
