:root {
  --bg: #F4F1EC;
  --surface: #FFFFFF;
  --surface-2: #FAF8F5;
  --ink: #1C1B19;
  --muted: #7A746C;
  --line: #E6E1D8;
  --live: #E24B3A;
  --soon: #E89B2C;
  --done: #2F9E44;
  --blue: #2F6FED;
  --violet: #7C5CFF;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(28,27,25,.04);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --font: -apple-system, BlinkMacSystemFont, "PingFang SC", "Noto Sans SC", "Microsoft YaHei", sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}
* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; }
body {
  font-family: var(--font);
  color: var(--ink);
  background: #ddd8d0;
  line-height: 1.45;
  font-size: 15px;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { border: none; background: none; cursor: pointer; }
input, select, textarea {
  width: 100%;
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: 10px;
  padding: 10px 12px;
  outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--blue); }
textarea { resize: vertical; min-height: 72px; }
.phone-shell {
  max-width: 430px;
  margin: 0 auto;
  min-height: 100%;
  background: var(--bg);
  position: relative;
  box-shadow: 0 12px 40px rgba(0,0,0,.12);
}
@media (min-width: 480px) {
  body { padding: 24px 0 40px; }
  .phone-shell {
    min-height: 860px;
    height: 860px;
    border-radius: 28px;
    overflow: hidden;
    border: 1px solid rgba(0,0,0,.06);
  }
}
.app { height: 100%; display: flex; flex-direction: column; position: relative; }
.topbar { padding: 14px 16px 10px; background: var(--bg); flex-shrink: 0; }
.topbar-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.topbar h1 { font-size: 20px; font-weight: 600; letter-spacing: -0.02em; }
.topbar .date-line { color: var(--muted); font-size: 13px; margin-top: 2px; }
.icon-btn {
  width: 36px; height: 36px; border-radius: 12px;
  background: var(--surface); border: 1px solid var(--line);
  display: grid; place-items: center; color: var(--muted); flex-shrink: 0;
}
.content {
  flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch;
  padding: 8px 16px 96px;
}
.tabbar {
  position: absolute; left: 0; right: 0; bottom: 0;
  display: grid; grid-template-columns: repeat(4, 1fr);
  background: rgba(255,255,255,.94); backdrop-filter: blur(12px);
  border-top: 1px solid var(--line);
  padding: 8px 8px calc(8px + var(--safe-b));
  z-index: 20;
}
.tab {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 6px 0; color: var(--muted); font-size: 11px; border-radius: 12px;
}
.tab.active { color: var(--ink); }
.tab.active .tab-icon { color: var(--blue); }
.tab-icon { width: 22px; height: 22px; }
.section { margin-top: 18px; }
.section-head {
  display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px;
}
.section-head h2 { font-size: 15px; font-weight: 600; }
.section-head .hint { font-size: 12px; color: var(--muted); }
.card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow);
}
.hero {
  margin-top: 8px; padding: 16px;
  background: linear-gradient(160deg, #1C1B19 0%, #2A2622 55%, #3A1F1A 100%);
  color: #fff; border-radius: 18px; border: none; position: relative; overflow: hidden;
}
.hero::after {
  content: ""; position: absolute; right: -30px; top: -30px;
  width: 120px; height: 120px; border-radius: 50%;
  background: radial-gradient(circle, rgba(226,75,58,.35), transparent 70%);
  pointer-events: none;
}
.hero-label { font-size: 12px; opacity: .72; letter-spacing: .04em; }
.hero-title { margin-top: 8px; font-size: 17px; font-weight: 600; }
.hero-meta { margin-top: 4px; font-size: 13px; opacity: .78; }
.hero-count {
  margin-top: 14px; font-family: var(--mono); font-size: 40px; font-weight: 600;
  letter-spacing: -0.03em; line-height: 1;
}
.hero-status {
  margin-top: 8px; display: inline-flex; align-items: center; gap: 6px;
  font-size: 12px; padding: 4px 8px; border-radius: 999px; background: rgba(255,255,255,.1);
}
.hero-next {
  margin-top: 12px; padding-top: 10px; border-top: 1px dashed rgba(255,255,255,.18);
  font-size: 12px; color: rgba(255,255,255,.72); line-height: 1.4;
}
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; flex-shrink: 0; }
.dot.pulse { animation: pulse 1.6s ease-in-out infinite; }
@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: .45; transform: scale(.85); }
}
.badge {
  display: inline-flex; align-items: center; gap: 5px; font-size: 11px;
  padding: 3px 8px; border-radius: 999px; font-weight: 500; white-space: nowrap;
}
.badge.live { background: rgba(226,75,58,.1); color: var(--live); }
.badge.soon { background: rgba(232,155,44,.14); color: #B87410; }
.badge.upcoming { background: rgba(47,111,237,.1); color: var(--blue); }
.badge.ended { background: rgba(122,116,108,.1); color: var(--muted); }
.badge.done { background: rgba(47,158,68,.1); color: var(--done); }
.badge.cat { background: var(--surface-2); color: var(--muted); border: 1px solid var(--line); }
.badge.prio-high { background: rgba(226,75,58,.1); color: var(--live); }
.badge.prio-low { background: rgba(122,116,108,.08); color: var(--muted); }
.list { display: flex; flex-direction: column; gap: 8px; }
.stream-item, .task-item, .metric-card {
  display: flex; align-items: flex-start; gap: 12px; padding: 12px 14px;
}
.stream-item { cursor: pointer; }
.task-item { cursor: default; }
.stream-item:active { background: var(--surface-2); }
.time-col {
  width: 48px; flex-shrink: 0; font-family: var(--mono); font-size: 13px;
  color: var(--muted); padding-top: 2px;
}
.time-col strong { display: block; color: var(--ink); font-weight: 600; font-size: 14px; }
.item-main { flex: 1; min-width: 0; }
.item-title {
  font-weight: 600; font-size: 14px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
}
.item-title span.name {
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.item-sub {
  margin-top: 3px; font-size: 12px; color: var(--muted);
  display: flex; flex-wrap: wrap; gap: 6px 10px;
}
.item-actions { display: flex; flex-direction: column; gap: 4px; align-items: flex-end; }
.mini-btn { font-size: 12px; color: var(--muted); padding: 4px 6px; border-radius: 8px; }
.mini-btn.danger { color: var(--live); }
.task-check {
  width: 22px; height: 22px; border-radius: 50%; border: 1.5px solid var(--line);
  display: grid; place-items: center; flex-shrink: 0; margin-top: 1px; background: var(--surface);
}
.task-check.checked { background: var(--done); border-color: var(--done); color: #fff; }
.task-item.done .item-title { text-decoration: line-through; color: var(--muted); font-weight: 500; }
.task-item.overdue { border-color: rgba(226,75,58,.35); }
.empty {
  padding: 22px 16px; text-align: center; color: var(--muted); font-size: 13px;
  border: 1px dashed var(--line); border-radius: var(--radius); background: var(--surface-2);
}
.date-strip {
  display: flex; gap: 8px; overflow-x: auto; padding: 4px 0 8px; scrollbar-width: none;
}
.date-strip::-webkit-scrollbar { display: none; }
.date-chip {
  min-width: 52px; padding: 8px 6px; border-radius: 12px; background: var(--surface);
  border: 1px solid var(--line); text-align: center; flex-shrink: 0;
}
.date-chip .dow { font-size: 11px; color: var(--muted); }
.date-chip .dom { font-family: var(--mono); font-size: 16px; font-weight: 600; margin-top: 2px; }
.date-chip.active { background: var(--ink); border-color: var(--ink); color: #fff; }
.date-chip.active .dow { color: rgba(255,255,255,.7); }
.chips {
  display: flex; gap: 8px; overflow-x: auto; padding: 2px 0 10px; scrollbar-width: none;
}
.chips::-webkit-scrollbar { display: none; }
.chip {
  padding: 6px 12px; border-radius: 999px; background: var(--surface);
  border: 1px solid var(--line); font-size: 12px; color: var(--muted); white-space: nowrap; flex-shrink: 0;
}
.chip.active {
  background: rgba(47,111,237,.1); border-color: rgba(47,111,237,.25); color: var(--blue); font-weight: 500;
}
.fab {
  position: absolute; right: 18px; bottom: calc(78px + var(--safe-b));
  width: 52px; height: 52px; border-radius: 18px; background: var(--ink); color: #fff;
  display: grid; place-items: center; box-shadow: 0 8px 20px rgba(28,27,25,.25);
  z-index: 15; font-size: 26px; line-height: 1;
}
.panel { padding: 14px; }
.field { margin-bottom: 12px; }
.field label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 6px; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.field-row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; }
.btn-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 4px; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 11px 14px; border-radius: 12px; font-weight: 500; font-size: 14px;
  border: 1px solid var(--line); background: var(--surface); text-decoration: none; color: inherit;
}
.btn.primary { background: var(--ink); color: #fff; border-color: var(--ink); }
.btn.blue { background: var(--blue); color: #fff; border-color: var(--blue); }
.btn.block { width: 100%; }
.btn.danger { color: var(--live); border-color: rgba(226,75,58,.3); background: rgba(226,75,58,.06); }
.quick-add { display: flex; gap: 8px; margin-top: 8px; }
.quick-add input { flex: 1; }
.quick-add .btn { flex-shrink: 0; padding-inline: 14px; }
.anchor-row { display: flex; align-items: center; gap: 10px; padding: 10px 12px; }
.anchor-row + .anchor-row { border-top: 1px solid var(--line); }
.color-swatch { width: 14px; height: 14px; border-radius: 50%; flex-shrink: 0; }
.anchor-name { flex: 1; font-weight: 500; font-size: 14px; }
.setting-row {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px;
}
.setting-row + .setting-row { border-top: 1px solid var(--line); }
.setting-label { font-weight: 500; font-size: 14px; }
.setting-desc { font-size: 12px; color: var(--muted); margin-top: 2px; }
.switch {
  width: 46px; height: 28px; border-radius: 999px; background: var(--line);
  position: relative; flex-shrink: 0; transition: background .15s ease;
}
.switch.on { background: var(--done); }
.switch::after {
  content: ""; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px;
  border-radius: 50%; background: #fff; transition: transform .15s ease;
  box-shadow: 0 1px 3px rgba(0,0,0,.15);
}
.switch.on::after { transform: translateX(18px); }
.seg {
  display: inline-flex; background: var(--surface-2); border: 1px solid var(--line);
  border-radius: 10px; overflow: hidden;
}
.seg button { padding: 6px 10px; font-size: 12px; color: var(--muted); }
.seg button.active { background: var(--surface); color: var(--ink); font-weight: 600; }
.modal-mask {
  position: absolute; inset: 0; background: rgba(28,27,25,.4); z-index: 40;
  display: none; align-items: flex-end;
}
.modal-mask.show { display: flex; }
.sheet {
  width: 100%; background: var(--bg); border-radius: 20px 20px 0 0;
  padding: 16px 16px calc(16px + var(--safe-b)); max-height: 88%; overflow-y: auto;
}
.sheet-handle { width: 36px; height: 4px; border-radius: 999px; background: var(--line); margin: 0 auto 12px; }
.sheet h3 { font-size: 16px; font-weight: 600; margin-bottom: 12px; }
.toast {
  position: absolute; left: 50%; bottom: calc(88px + var(--safe-b));
  transform: translateX(-50%) translateY(12px);
  background: rgba(28,27,25,.92); color: #fff; font-size: 13px; padding: 8px 14px;
  border-radius: 999px; opacity: 0; pointer-events: none;
  transition: opacity .2s ease, transform .2s ease; z-index: 50; white-space: nowrap;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.progress-row {
  display: grid; grid-template-columns: 1fr auto; gap: 8px; align-items: center; margin-top: 10px;
}
.progress { height: 6px; background: rgba(255,255,255,.12); border-radius: 999px; overflow: hidden; }
.progress > i { display: block; height: 100%; background: var(--live); border-radius: 999px; }
.note-box { margin-top: 10px; font-size: 12px; color: var(--muted); line-height: 1.5; }
.color-grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 8px; }
.color-opt { aspect-ratio: 1; border-radius: 50%; border: 2px solid transparent; }
.color-opt.active { border-color: var(--ink); box-shadow: inset 0 0 0 2px #fff; }
.stack-gap > * + * { margin-top: 8px; }
/* analytics */
.metrics {
  display: grid; grid-template-columns: 1fr 1fr; gap: 8px;
}
.metric {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 12px 14px; box-shadow: var(--shadow);
}
.metric .k { font-size: 12px; color: var(--muted); }
.metric .v { margin-top: 6px; font-family: var(--mono); font-size: 26px; font-weight: 600; letter-spacing: -0.03em; }
.metric .s { margin-top: 4px; font-size: 11px; color: var(--muted); }
.metric .v.good { color: var(--done); }
.metric .v.warn { color: var(--soon); }
.metric .v.bad { color: var(--live); }
.chart-card { padding: 14px; }
.chart-title { font-size: 13px; font-weight: 600; margin-bottom: 10px; }
.bars { display: flex; align-items: flex-end; gap: 6px; height: 96px; }
.bar-col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 4px; min-width: 0; }
.bar-stack { width: 100%; height: 72px; display: flex; flex-direction: column; justify-content: flex-end; gap: 2px; }
.bar { width: 100%; border-radius: 4px 4px 2px 2px; min-height: 2px; }
.bar.done { background: var(--done); }
.bar.total { background: rgba(47,111,237,.25); }
.bar-col .lab { font-size: 10px; color: var(--muted); }
.legend { display: flex; gap: 12px; margin-top: 8px; font-size: 11px; color: var(--muted); }
.legend i { display: inline-block; width: 8px; height: 8px; border-radius: 2px; margin-right: 4px; }
.rank-row { display: grid; grid-template-columns: 56px 1fr 36px; gap: 8px; align-items: center; padding: 8px 0; }
.rank-row + .rank-row { border-top: 1px dashed var(--line); }
.rank-bar { height: 8px; background: var(--surface-2); border-radius: 999px; overflow: hidden; }
.rank-bar i { display: block; height: 100%; background: var(--blue); }
.rank-name { font-size: 13px; font-weight: 500; }
.rank-val { font-family: var(--mono); font-size: 12px; color: var(--muted); text-align: right; }
.cat-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.cat-cell {
  border: 1px solid var(--line); border-radius: 12px; padding: 10px; text-align: center; background: var(--surface-2);
}
.cat-cell .n { font-family: var(--mono); font-weight: 600; font-size: 18px; }
.cat-cell .t { font-size: 11px; color: var(--muted); margin-top: 2px; }
