:root {
  --bg: #0f1419;
  --bg-elev: #171e26;
  --bg-card: #1c2530;
  --bg-card-hover: #243041;
  --line: rgba(255, 255, 255, 0.08);
  --text: #eef3f8;
  --muted: #8b9aab;
  --accent: #34d399;
  --accent-dim: rgba(52, 211, 153, 0.18);
  --accent-ink: #052e1c;
  --warn: #f5b942;
  --danger: #ff4d4f;
  --high: #ff8a7a;
  --med: #f5b942;
  --low: #7aa2ff;
  --done: #34d399;
  --shadow: 0 12px 40px rgba(0, 0, 0, 0.45);
  --radius: 18px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  --font: "Noto Sans SC", "Source Han Sans SC", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Segoe UI", system-ui, sans-serif;
}

[data-theme="light"] {
  --bg: #f4f1ea;
  --bg-elev: #fffdf8;
  --bg-card: #ffffff;
  --bg-card-hover: #f7f3eb;
  --line: rgba(20, 30, 40, 0.08);
  --text: #1a2430;
  --muted: #6b7a8c;
  --accent: #22c55e;
  --accent-dim: rgba(34, 197, 94, 0.16);
  --accent-ink: #ffffff;
  --danger: #e11d48;
  --shadow: 0 10px 30px rgba(40, 50, 60, 0.1);
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.45;
  letter-spacing: 0.02em;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
body {
  background-image:
    radial-gradient(1200px 600px at 10% -10%, rgba(52, 211, 153, 0.08), transparent 55%),
    radial-gradient(900px 500px at 100% 0%, rgba(122, 162, 255, 0.05), transparent 50%);
}
button, input, select, textarea {
  font: inherit;
  color: inherit;
}
button { cursor: pointer; border: none; background: none; }
#app {
  --app-max: 430px;
  max-width: var(--app-max);
  width: 100%;
  margin: 0 auto;
  min-height: 100dvh;
  padding: calc(16px + var(--safe-t)) 16px calc(150px + var(--safe-b));
  position: relative;
}

.topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 18px;
}
.brand-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 8px;
  line-height: 1;
}
.brand-logo {
  width: 34px;
  height: 34px;
  border-radius: 0;
  object-fit: contain;
  flex-shrink: 0;
  display: block;
  align-self: center;
  background: transparent;
  box-shadow: none;
  border: none;
}
.brand {
  margin: 0;
  color: var(--text);
  font-size: 21px;
  font-weight: 750;
  letter-spacing: 0.06em;
  line-height: 1;
  display: flex;
  align-items: center;
  height: 34px;
}
@media (min-width: 768px) {
  .brand { font-size: 24px; height: 36px; }
  .brand-logo { width: 36px; height: 36px; }
}
.eyebrow {
  margin: 0 0 6px;
  color: var(--muted);
  font-size: 13px;
  letter-spacing: 0.02em;
}
.user-inline {
  margin-left: 0.35em;
  color: var(--text);
  font-weight: 650;
}
.user-inline::before {
  content: "·";
  margin-right: 0.35em;
  color: var(--muted);
  font-weight: 500;
}
.topbar h1,
.view-title {
  margin: 0;
  font-size: 20px;
  font-weight: 650;
  letter-spacing: -0.01em;
  color: var(--text);
  max-width: 18em;
}
.view-title.is-quote {
  font-size: 15px;
  font-weight: 500;
  line-height: 1.55;
  color: var(--muted);
  letter-spacing: 0.01em;
  max-width: 22em;
}
.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}
.account-menu {
  position: relative;
}
.account-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  min-width: 140px;
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow);
  padding: 6px;
  z-index: 40;
}
.account-item {
  display: block;
  width: 100%;
  text-align: left;
  padding: 10px 12px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}
.account-item:hover,
.account-item:focus-visible {
  background: var(--bg-card-hover);
}
.account-item.danger {
  color: var(--danger);
}
.field-hint {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}
.sync-pill {
  font-size: 11px;
  font-weight: 650;
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--bg-elev);
  color: var(--muted);
  white-space: nowrap;
}
.sync-pill.online {
  color: var(--accent);
  background: var(--accent-dim);
  border-color: transparent;
}
.sync-pill.offline { color: var(--warn); }
.sync-pill.syncing { color: var(--low); }
.icon-btn {
  width: 44px;
  height: 44px;
  border-radius: 14px;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  font-size: 18px;
  color: var(--muted);
}

.tabs {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 3px;
  padding: 5px;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: 16px;
  margin-bottom: 14px;
}
.tab {
  height: 40px;
  border-radius: 12px;
  color: var(--muted);
  font-weight: 600;
  font-size: 11px;
  padding: 0 1px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.tab.active {
  background: var(--accent-dim);
  color: var(--accent);
}
.tab.tab-today {
  color: #d97706;
  font-weight: 700;
  letter-spacing: 0.01em;
}
[data-theme="light"] .tab.tab-today {
  color: #c2410c;
}
.tab.tab-today:not(.active) {
  background: rgba(245, 185, 66, 0.12);
  box-shadow: inset 0 0 0 1px rgba(245, 185, 66, 0.35);
}
.tab.tab-today.active {
  background: rgba(245, 185, 66, 0.28);
  color: #b45309;
  box-shadow: inset 0 0 0 1px rgba(217, 119, 6, 0.45);
}
[data-theme="light"] .tab.tab-today.active {
  background: rgba(251, 146, 60, 0.28);
  color: #9a3412;
}

.filters { margin-bottom: 12px; }
.chip-row {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 8px;
  scrollbar-width: none;
}
.chip-row::-webkit-scrollbar { display: none; }
.chip {
  flex: 0 0 auto;
  height: 34px;
  padding: 0 14px;
  border-radius: 999px;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  color: var(--muted);
  font-size: 13px;
  font-weight: 500;
}
.chip.active {
  border-color: transparent;
  background: var(--accent);
  color: var(--accent-ink);
}

.stats {
  display: flex;
  gap: 10px;
  margin-bottom: 14px;
  color: var(--muted);
  font-size: 13px;
  flex-wrap: wrap;
}
.stats strong { color: var(--text); font-weight: 650; }

.task-board,
.task-done-board {
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.task-col {
  min-width: 0;
}
.task-col-h {
  margin: 0 0 10px;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 8px;
}
.task-col-h::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex: 0 0 auto;
  background: currentColor;
}
.task-col-work .task-col-h { color: #a5b4fc; }
.task-col-life .task-col-h { color: #6ee7b7; }
[data-theme="light"] .task-col-work .task-col-h { color: #4f46e5; }
[data-theme="light"] .task-col-life .task-col-h { color: #059669; }
.task-col-empty {
  margin: 0;
  padding: 14px 12px;
  border-radius: 14px;
  border: 1px dashed var(--line);
  color: var(--muted);
  font-size: 13px;
  text-align: center;
}
.task-done-section {
  margin-top: 8px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}
.task-done-section[hidden] { display: none !important; }
.task-done-title {
  margin: 0 0 12px;
  font-size: 13px;
  font-weight: 650;
  letter-spacing: 0.04em;
  color: var(--muted);
}
.task-board[hidden] { display: none !important; }

.task-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.task-card {
  display: grid;
  grid-template-columns: 36px 1fr;
  gap: 8px;
  padding: 10px 11px;
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: calc(var(--radius) - 2px);
  box-shadow: var(--shadow);
  transition: background 0.15s ease, transform 0.15s ease, border-color 0.15s ease;
}
.task-card:active { transform: scale(0.985); background: var(--bg-card-hover); }
.task-card.done-card { opacity: 0.72; }

/* Left color bar: 工作 indigo / 生活 green (dual → work via cardTintClass) */
.task-card.card-work,
.task-card.card-life {
  background: var(--bg-card);
  border-color: var(--line);
  position: relative;
  overflow: hidden;
}
.task-card.card-work::before,
.task-card.card-life::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 4px;
  border-radius: calc(var(--radius) - 2px) 0 0 calc(var(--radius) - 2px);
  pointer-events: none;
}
.task-card.card-work::before { background: #818cf8; }
.task-card.card-life::before { background: #34d399; }
[data-theme="light"] .task-card.card-work::before { background: #6366f1; }
[data-theme="light"] .task-card.card-life::before { background: #22c55e; }
.task-card.card-work:active,
.task-card.card-life:active {
  background: var(--bg-card-hover);
}

.check {
  width: 36px;
  height: 36px;
  border-radius: 11px;
  border: 2px solid color-mix(in srgb, var(--muted) 70%, var(--text));
  background: rgba(255,255,255,0.04);
  display: grid;
  place-items: center;
  color: color-mix(in srgb, var(--muted) 85%, transparent);
  font-size: 16px;
  font-weight: 700;
  flex-shrink: 0;
  opacity: 1;
}
[data-theme="light"] .check {
  border-color: rgba(15, 23, 42, 0.35);
  background: #fff;
  color: rgba(100, 116, 139, 0.85);
}
.check.on {
  background: var(--accent);
  border-color: transparent;
  color: var(--accent-ink);
  opacity: 1;
}
.task-main { min-width: 0; }
.task-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 4px;
}
.task-title {
  margin: 0;
  font-size: 15px;
  font-weight: 650;
  line-height: 1.28;
  word-break: break-word;
}
.task-card.done-card .task-title {
  text-decoration: line-through;
  color: var(--muted);
}
.prio {
  flex: 0 0 auto;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  padding: 4px 8px;
  border-radius: 999px;
}
.prio.high { background: rgba(255, 138, 122, 0.18); color: var(--high); }
.prio.med { background: rgba(245, 185, 66, 0.18); color: var(--med); }
.prio.low { background: rgba(122, 162, 255, 0.18); color: var(--low); }

.task-top-right {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 0 0 auto;
}
.card-delete {
  width: 30px;
  height: 30px;
  border-radius: 10px;
  border: 1.5px solid rgba(255, 77, 79, 0.55);
  background: rgba(255, 77, 79, 0.22);
  color: #ff6b6b;
  display: grid;
  place-items: center;
  font-size: 14px;
  line-height: 1;
  flex-shrink: 0;
  box-shadow: 0 0 0 1px rgba(255, 77, 79, 0.15);
}
.card-delete svg {
  width: 15px;
  height: 15px;
  display: block;
  fill: currentColor;
}
.card-delete:active {
  transform: scale(0.94);
  background: rgba(255, 77, 79, 0.35);
  color: #ff8a8a;
}
[data-theme="light"] .card-delete {
  border-color: rgba(225, 29, 72, 0.45);
  background: rgba(225, 29, 72, 0.12);
  color: #e11d48;
  box-shadow: none;
}

.meta {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-bottom: 6px;
  align-items: center;
}
.tag {
  font-size: 11px;
  color: var(--muted);
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 2px 7px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.due-ico {
  width: 11px;
  height: 11px;
  display: block;
  flex-shrink: 0;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}
[data-theme="light"] .tag { background: rgba(0,0,0,0.03); }
.tag.status-doing { color: var(--accent); border-color: transparent; background: var(--accent-dim); }
.tag.status-done { color: var(--done); }
.tag.due-soon { color: var(--warn); }
.tag.due-late { color: var(--danger); }
.tag.cat {
  border-color: transparent;
}
.tag.cat.cat-work {
  color: #a5b4fc;
  background: rgba(165, 180, 252, 0.16);
}
.tag.cat.cat-life {
  color: var(--accent);
  background: var(--accent-dim);
}
.tag.cat.cat-muted {
  color: var(--muted);
  background: rgba(255,255,255,0.04);
}
[data-theme="light"] .tag.cat.cat-work {
  color: #6366f1;
  background: rgba(99, 102, 241, 0.1);
}
[data-theme="light"] .tag.cat.cat-life {
  color: var(--accent);
  background: var(--accent-dim);
}
[data-theme="light"] .tag.cat.cat-muted {
  background: rgba(0,0,0,0.03);
}
.chip.chip-work.active {
  background: #818cf8;
  color: #eef2ff;
}
.chip.chip-life.active {
  background: var(--accent);
  color: var(--accent-ink);
}

.progress-nodes {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-top: 10px;
}
.progress-node {
  padding: 8px 0;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--bg-elev);
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
}
.progress-node:hover,
.progress-node:focus-visible {
  border-color: var(--accent);
  color: var(--text);
}
.progress-node.active {
  border-color: transparent;
  background: var(--accent-dim);
  color: var(--accent);
}
.progress {
  height: 4px;
  border-radius: 999px;
  background: rgba(255,255,255,0.06);
  overflow: hidden;
  margin-top: 0;
}
[data-theme="light"] .progress { background: rgba(0,0,0,0.06); }
.progress > i {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent), #6ee7b7);
  width: 0%;
}

.empty {
  text-align: center;
  padding: 56px 20px;
  color: var(--muted);
}
.empty.hidden, .hidden { display: none !important; }
.empty-icon {
  width: 56px;
  height: 56px;
  margin: 0 auto 14px;
  border-radius: 18px;
  display: grid;
  place-items: center;
  background: var(--accent-dim);
  color: var(--accent);
  font-size: 22px;
}
.empty-title { margin: 0 0 6px; color: var(--text); font-size: 17px; font-weight: 650; }
.empty-sub { margin: 0; font-size: 14px; line-height: 1.5; }

.fab-dock {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: calc(78px + var(--safe-b));
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: center;
  gap: 14px;
  z-index: 20;
}
.fab {
  position: static;
  width: 56px;
  height: 56px;
  border-radius: 20px;
  background: var(--accent);
  color: var(--accent-ink);
  font-size: 30px;
  font-weight: 400;
  line-height: 1;
  box-shadow: 0 14px 30px rgba(52, 211, 153, 0.42);
  display: grid;
  place-items: center;
  flex: 0 0 auto;
}
.fab:active { transform: scale(0.96); }
.fab.hidden { display: none !important; }

@media (min-width: 768px) {
  .fab-dock {
    left: auto;
    right: max(18px, calc(50% - (var(--app-max) / 2) + 18px));
    transform: none;
  }
}

.voice-actions .btn { flex: 1; }

.overlay {
  position: fixed;
  inset: 0;
  background: rgba(4, 8, 12, 0.55);
  backdrop-filter: blur(4px);
  z-index: 30;
}
.sheet {
  position: fixed;
  left: 50%;
  bottom: 0;
  transform: translateX(-50%);
  width: min(100%, var(--app-max, 430px));
  max-height: min(92dvh, 820px);
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-bottom: none;
  border-radius: 24px 24px 0 0;
  z-index: 40;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow);
  padding-bottom: 0;
  overflow: hidden;
}
.sheet-handle {
  width: 42px;
  height: 4px;
  border-radius: 999px;
  background: var(--line);
  margin: 10px auto 0;
}
.sheet-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px 8px;
}
.sheet-header h2 {
  margin: 0;
  font-size: 18px;
  font-weight: 700;
}
.text-btn {
  color: var(--muted);
  font-size: 15px;
  font-weight: 600;
  padding: 8px 4px;
}
.sheet-form {
  display: flex;
  flex-direction: column;
  min-height: 0;
  flex: 1;
}
.sheet-body {
  padding: 8px 18px 12px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-height: 0;
  flex: 1;
}
.sheet-footer {
  flex-shrink: 0;
  padding: 10px 18px calc(12px + var(--safe-b));
  border-top: 1px solid var(--line);
  background: var(--bg-elev);
}
.field {
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-size: 13px;
  color: var(--muted);
  font-weight: 600;
}
.field em {
  font-style: normal;
  color: var(--accent);
  float: right;
}
.field em.hint {
  color: var(--muted);
  font-weight: 500;
  font-size: 12px;
}
.field input,
.field select,
.field textarea {
  width: 100%;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: var(--bg-card);
  padding: 14px 14px;
  font-size: 16px;
  color: var(--text);
  outline: none;
}
.field textarea { resize: vertical; min-height: 84px; }
.field input:focus,
.field select:focus,
.field textarea:focus {
  border-color: rgba(52, 211, 153, 0.6);
  box-shadow: 0 0 0 3px var(--accent-dim);
}
.field input[type="range"] {
  padding: 0;
  height: 28px;
  accent-color: var(--accent);
  border: none;
  background: transparent;
  box-shadow: none;
}
.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.sheet-actions {
  display: flex;
  gap: 10px;
  align-items: center;
}
.sheet-actions .btn.danger {
  min-width: 96px;
  flex: 0 0 auto;
}
.btn {
  height: 50px;
  border-radius: 16px;
  font-weight: 700;
  font-size: 15px;
  padding: 0 18px;
}
.btn.grow { flex: 1; }
.btn.primary {
  background: var(--accent);
  color: var(--accent-ink);
}
.btn.danger {
  color: #fff;
  background: rgba(255, 77, 79, 0.95);
  border: 1px solid rgba(255, 120, 120, 0.4);
}
.btn.danger:active { filter: brightness(0.95); }
.btn:active { transform: scale(0.98); }
[data-theme="light"] .btn.danger {
  background: #e11d48;
  border-color: transparent;
}

/* Category picker */
.cat-picker {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.cat-group {
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 10px 12px;
}
.cat-group-title {
  font-size: 12px;
  font-weight: 700;
  color: var(--text);
  margin: 0 0 8px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.cat-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.cat-chip {
  height: 32px;
  padding: 0 12px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(255,255,255,0.03);
  color: var(--muted);
  font-size: 13px;
  font-weight: 550;
}
.cat-chip.on {
  background: var(--accent);
  color: var(--accent-ink);
  border-color: transparent;
}
.cat-chip.parent-chip.on {
  background: var(--accent-dim);
  color: var(--accent);
  border-color: transparent;
}
.cat-group.cat-work .cat-chip.parent-chip.on {
  background: rgba(165, 180, 252, 0.16);
  color: #a5b4fc;
}
.cat-group.cat-life .cat-chip.parent-chip.on {
  background: var(--accent-dim);
  color: var(--accent);
}
.cat-group.cat-work .cat-chip.on {
  background: #818cf8;
  color: #eef2ff;
}
.cat-group.cat-life .cat-chip.on {
  background: var(--accent);
  color: var(--accent-ink);
}
.cat-chip-wrap {
  display: inline-flex;
  align-items: center;
  gap: 0;
  position: relative;
}
.cat-chip-wrap .cat-chip {
  padding-right: 28px;
}
.cat-x {
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  width: 18px;
  height: 18px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  line-height: 1;
  color: var(--muted);
  background: transparent;
  padding: 0;
}
.cat-x:hover,
.cat-x:focus-visible {
  color: var(--danger);
  background: rgba(255, 77, 79, 0.12);
}
.cat-empty {
  font-size: 12px;
  color: var(--muted);
  padding: 4px 2px;
}
.cat-add-row {
  display: flex;
  gap: 8px;
  margin-top: 10px;
  align-items: center;
}
.cat-add-input {
  flex: 1;
  min-width: 0;
  height: 34px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--bg-elev);
  padding: 0 10px;
  font-size: 13px;
}
.cat-add-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-dim);
}
.cat-add-btn {
  height: 34px;
  padding: 0 12px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--bg-elev);
  color: var(--text);
  font-size: 13px;
  font-weight: 650;
  white-space: nowrap;
}
.cat-add-btn:hover,
.cat-add-btn:focus-visible {
  background: var(--accent-dim);
  color: var(--accent);
  border-color: transparent;
}

/* Stats view */
.stats-wrap { margin-top: 2px; }
.stats-period {
  margin: 0 0 12px;
  color: var(--muted);
  font-size: 13px;
}
.stats-summary {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 18px;
}
.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px 10px;
  text-align: center;
}
.stat-card .n {
  display: block;
  font-size: 20px;
  font-weight: 750;
  color: var(--text);
  letter-spacing: -0.02em;
}
.stat-card .l {
  display: block;
  margin-top: 4px;
  font-size: 11px;
  color: var(--muted);
}
.stats-section { margin-bottom: 18px; }
.stats-h {
  margin: 0 0 10px;
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
}
.rank-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.rank-item {
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px 14px;
}
.rank-item.rank-compact {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
}
.rank-item.rank-empty {
  justify-content: center;
}
.rank-idx {
  flex: 0 0 auto;
  width: 22px;
  height: 22px;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 750;
  color: var(--muted);
  background: rgba(255,255,255,0.06);
}
[data-theme="light"] .rank-idx { background: rgba(0,0,0,0.05); }
.rank-item.cat-work .rank-idx {
  color: #a5b4fc;
  background: rgba(129, 140, 248, 0.16);
}
.rank-item.cat-life .rank-idx {
  color: var(--accent);
  background: color-mix(in srgb, var(--accent) 16%, transparent);
}
[data-theme="light"] .rank-item.cat-work .rank-idx {
  color: #6366f1;
  background: rgba(99, 102, 241, 0.12);
}
.rank-main {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.rank-name {
  font-size: 14px;
  font-weight: 650;
  color: var(--text);
  min-width: 0;
  word-break: break-word;
}
.rank-name.cat-work,
.rank-item.cat-work .rank-name {
  color: #a5b4fc;
}
.rank-name.cat-life,
.rank-item.cat-life .rank-name {
  color: var(--accent);
}
[data-theme="light"] .rank-name.cat-work,
[data-theme="light"] .rank-item.cat-work .rank-name {
  color: #6366f1;
}
.rank-item.cat-work .rank-pct {
  color: #a5b4fc;
}
.rank-item.cat-life .rank-pct {
  color: var(--accent);
}
[data-theme="light"] .rank-item.cat-work .rank-pct {
  color: #6366f1;
}
.rank-pct {
  font-size: 16px;
  font-weight: 750;
  color: var(--accent);
  flex: 0 0 auto;
  letter-spacing: -0.02em;
}
.rank-meta {
  font-size: 12px;
  color: var(--muted);
}
.rank-item.rank-with-bar {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 12px 14px;
}
.rank-top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
}
.rank-item.rank-with-bar .rank-pct {
  font-size: 15px;
}
.rank-item.rank-with-bar .share-bar {
  height: 8px;
  margin-top: 2px;
}
.rank-thin-bar {
  height: 3px;
  border-radius: 999px;
  background: rgba(255,255,255,0.06);
  overflow: hidden;
  margin-top: 4px;
}
[data-theme="light"] .rank-thin-bar { background: rgba(0,0,0,0.06); }
.rank-thin-bar > i {
  display: block;
  height: 100%;
  border-radius: inherit;
}
.rank-thin-bar.cat-work > i { background: #818cf8; }
.rank-thin-bar.cat-life > i { background: var(--accent); }
.leaf-rank-split {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
}
.leaf-col {
  min-width: 0;
}
.leaf-col-title {
  margin: 0 0 8px;
  font-size: 12px;
  font-weight: 650;
  color: var(--muted);
}
.leaf-col-title.cat-work { color: #a5b4fc; }
.leaf-col-title.cat-life { color: var(--accent); }
[data-theme="light"] .leaf-col-title.cat-work { color: #6366f1; }
.leaf-empty {
  padding: 12px 14px;
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: 14px;
  text-align: center;
}
@media (min-width: 560px) {
  .leaf-rank-split {
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    align-items: start;
  }
}

.stats-panel {
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.stats-panel-empty {
  color: var(--muted);
  font-size: 13px;
  text-align: center;
  padding: 8px 0;
}
.share-block-title {
  margin: 0 0 8px;
  font-size: 12px;
  font-weight: 650;
  color: var(--muted);
}
.wl-grid {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 10px;
  /* Fixed stack height so flex-grow makes card heights ∝ volume share on mobile. */
  height: min(72vw, 440px);
  min-height: 340px;
}
.wl-card {
  border-radius: 14px;
  border: 1px solid var(--line);
  padding: 14px 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  background: rgba(255,255,255,0.03);
  min-width: 0;
  width: 100%;
  box-sizing: border-box;
  /* Mobile stack: height follows --wl-share (raw %); floor keeps tiny side readable. */
  flex: var(--wl-share, 50) 1 0;
  min-height: 120px;
  overflow: hidden;
}
@media (min-width: 560px) {
  .wl-grid {
    flex-direction: row;
    height: auto;
    min-height: 220px;
  }
  .wl-card {
    width: auto;
    /* Desktop: width ∝ share with floor via --wl-grow; height from grid. */
    flex: var(--wl-grow, 50) 1 0;
    min-height: 0;
    overflow: visible;
  }
}
[data-theme="light"] .wl-card { background: rgba(0,0,0,0.02); }
.wl-card.cat-work {
  border-color: rgba(129, 140, 248, 0.35);
  background: rgba(129, 140, 248, 0.10);
}
.wl-card.cat-life {
  border-color: color-mix(in srgb, var(--accent) 35%, transparent);
  background: color-mix(in srgb, var(--accent) 10%, transparent);
}
[data-theme="light"] .wl-card.cat-work {
  border-color: rgba(99, 102, 241, 0.28);
  background: rgba(99, 102, 241, 0.08);
}
[data-theme="light"] .wl-card.cat-life {
  border-color: color-mix(in srgb, var(--accent) 30%, transparent);
  background: color-mix(in srgb, var(--accent) 08%, transparent);
}
.wl-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
}
.wl-label {
  font-size: 12px;
  font-weight: 650;
  color: var(--muted);
}
.wl-card.cat-work .wl-label { color: #a5b4fc; }
.wl-card.cat-life .wl-label { color: var(--accent); }
[data-theme="light"] .wl-card.cat-work .wl-label { color: #6366f1; }
.wl-count {
  font-size: 28px;
  font-weight: 750;
  letter-spacing: -0.03em;
  color: var(--text);
  line-height: 1.1;
}
.wl-rate {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
  flex: 0 0 auto;
}
.wl-card.cat-work .wl-rate { color: #a5b4fc; }
.wl-card.cat-life .wl-rate { color: var(--accent); }
[data-theme="light"] .wl-card.cat-work .wl-rate { color: #6366f1; }
.wl-meta {
  font-size: 12px;
  color: var(--muted);
  margin-top: 2px;
}
.tm-root {
  flex: 1 1 auto;
  /* Let parent card height drive area on mobile so volume share is visible. */
  min-height: 0;
  margin-top: 6px;
  display: flex;
  border-radius: 10px;
  overflow: hidden;
}
@media (min-width: 560px) {
  .tm-root { min-height: 128px; }
}
.tm-node {
  display: flex;
  width: 100%;
  height: 100%;
  min-width: 0;
  min-height: 0;
  gap: 2px;
}
.tm-branch {
  display: flex;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
}
.tm-cell {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: flex-end;
  gap: 2px;
  padding: 7px 8px;
  min-width: 44px;
  min-height: 44px;
  overflow: hidden;
  box-sizing: border-box;
  color: #e0e7ff;
  background: color-mix(in srgb, #818cf8 var(--tm-fill, 40%), transparent);
}
.wl-card.cat-life .tm-cell {
  color: color-mix(in srgb, var(--accent) 22%, white);
  background: color-mix(in srgb, var(--accent) var(--tm-fill, 40%), transparent);
}
[data-theme="light"] .tm-cell {
  color: #312e81;
  background: color-mix(in srgb, #6366f1 var(--tm-fill, 36%), transparent);
}
[data-theme="light"] .wl-card.cat-life .tm-cell {
  color: color-mix(in srgb, var(--accent) 55%, black);
  background: color-mix(in srgb, var(--accent) var(--tm-fill, 36%), transparent);
}
.tm-name {
  font-size: 12px;
  font-weight: 650;
  line-height: 1.2;
  max-width: 100%;
  overflow: visible;
  white-space: normal;
  overflow-wrap: anywhere;
  word-break: break-word;
}
.tm-pct {
  font-size: 13px;
  font-weight: 750;
  letter-spacing: -0.02em;
  line-height: 1.1;
}
@media (min-width: 560px) {
  .tm-name { font-size: 11px; }
  .tm-pct { font-size: 12px; }
  .tm-cell {
    min-width: 0;
    min-height: 0;
    padding: 6px 7px;
  }
}
.share-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 10px;
}
.share-row:last-child { margin-bottom: 0; }
.share-top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
}
.share-label {
  font-size: 13px;
  font-weight: 650;
  color: var(--text);
  min-width: 0;
}
.share-label.cat-work { color: #a5b4fc; }
.share-label.cat-life { color: var(--accent); }
[data-theme="light"] .share-label.cat-work { color: #6366f1; }
.share-nums {
  font-size: 12px;
  color: var(--muted);
  flex: 0 0 auto;
  white-space: nowrap;
}
.share-bar {
  height: 8px;
  border-radius: 999px;
  background: rgba(255,255,255,0.06);
  overflow: hidden;
}
[data-theme="light"] .share-bar { background: rgba(0,0,0,0.06); }
.share-bar > i {
  display: block;
  height: 100%;
  border-radius: inherit;
}
.share-bar.cat-work > i { background: #818cf8; }
.share-bar.cat-life > i { background: var(--accent); }
.share-bar.status-todo > i { background: #94a3b8; }
.share-bar.status-doing > i { background: var(--accent); }
.share-bar.status-done > i { background: var(--done); }
.share-label.status-todo { color: #94a3b8; }
.share-label.status-doing { color: var(--accent); }
.share-label.status-done { color: var(--done); }

.seg-bar {
  display: flex;
  height: 10px;
  border-radius: 999px;
  overflow: hidden;
  background: rgba(255,255,255,0.06);
  margin-bottom: 10px;
}
[data-theme="light"] .seg-bar { background: rgba(0,0,0,0.06); }
.seg-bar > i {
  display: block;
  height: 100%;
  min-width: 0;
}
.seg-bar > i.todo { background: #94a3b8; }
.seg-bar > i.doing { background: var(--accent); }
.seg-bar > i.done { background: var(--done); }
.seg-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 14px;
  font-size: 12px;
  color: var(--muted);
}
.seg-legend span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.seg-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex: 0 0 auto;
}
.seg-dot.todo { background: #94a3b8; }
.seg-dot.doing { background: var(--accent); }
.seg-dot.done { background: var(--done); }

.ontime-hero {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
}
.ontime-pct {
  font-size: 28px;
  font-weight: 750;
  letter-spacing: -0.03em;
  color: var(--accent);
  line-height: 1;
}
.ontime-pct.is-empty { color: var(--muted); }
.ontime-sub {
  margin: 8px 0 0;
  font-size: 13px;
  color: var(--text);
}
.ontime-hint {
  margin: 6px 0 0;
  font-size: 11px;
  color: var(--muted);
}
.ontime-side {
  text-align: right;
  flex: 0 0 auto;
}
.ontime-late-n {
  display: block;
  font-size: 18px;
  font-weight: 750;
  color: var(--danger);
  line-height: 1.1;
}
.ontime-late-l {
  display: block;
  margin-top: 4px;
  font-size: 11px;
  color: var(--muted);
}

@media (min-width: 480px) {
  #app { padding-top: 28px; }
  .task-board,
  .task-done-board {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    align-items: start;
  }
}

@media (min-width: 768px) {
  :root {
    --radius: 20px;
  }
  #app {
    --app-max: 760px;
    padding: calc(28px + var(--safe-t)) 28px calc(160px + var(--safe-b));
  }
  .topbar h1 { font-size: 32px; }
  .task-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
  }
  .task-done-section {
    margin-top: 18px;
    padding-top: 18px;
  }
  .task-board,
  .task-done-board {
    gap: 16px;
  }
  .task-card:active { transform: none; }
  .task-card:hover { background: var(--bg-card-hover); }
  .task-card.card-work:hover {
    background: color-mix(in srgb, #818cf8 24%, var(--bg-card));
  }
  .task-card.card-life:hover {
    background: color-mix(in srgb, #34d399 22%, var(--bg-card));
  }
  [data-theme="light"] .task-card.card-work:hover {
    background: color-mix(in srgb, #6366f1 15%, #ffffff);
  }
  [data-theme="light"] .task-card.card-life:hover {
    background: color-mix(in srgb, #34d399 16%, #ffffff);
  }
  .stats-summary { gap: 12px; }
  .sheet {
    bottom: auto;
    top: 50%;
    transform: translate(-50%, -50%);
    width: min(560px, calc(100% - 48px));
    max-height: min(88dvh, 760px);
    border-radius: 22px;
    border-bottom: 1px solid var(--line);
  }
  .sheet-handle { display: none; }
  .sheet-footer { padding-bottom: 16px; border-radius: 0 0 22px 22px; }
}

@media (min-width: 1100px) {
  #app {
    --app-max: 960px;
    padding-left: 36px;
    padding-right: 36px;
  }
  .task-board {
    gap: 18px;
  }
  .list-wrap {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--line);
    border-radius: 22px;
    padding: 16px;
  }
  [data-theme="light"] .list-wrap {
    background: rgba(255, 255, 255, 0.55);
  }
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
.gate {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 28px 18px;
  background: var(--bg);
  background-image:
    radial-gradient(1100px 560px at 18% -12%, rgba(52, 211, 153, 0.1), transparent 58%),
    radial-gradient(900px 480px at 92% 8%, rgba(122, 162, 255, 0.07), transparent 52%),
    radial-gradient(700px 420px at 50% 110%, rgba(52, 211, 153, 0.04), transparent 60%);
}
.gate[hidden] { display: none !important; }
.gate-card {
  width: min(100%, 400px);
  background: linear-gradient(180deg, rgba(255,255,255,0.03), transparent 40%), var(--bg-card);
  border: 1px solid var(--line);
  border-radius: 28px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.45), 0 0 0 1px rgba(52, 211, 153, 0.08);
  padding: 36px 28px 26px;
  text-align: center;
  backdrop-filter: blur(8px);
}
[data-theme="light"] .gate-card {
  background: linear-gradient(180deg, #ffffff, #fffdf8);
  box-shadow: 0 20px 50px rgba(40, 50, 60, 0.12), 0 0 0 1px rgba(34, 197, 94, 0.08);
}
.gate-logo-wrap {
  width: 88px;
  height: 88px;
  margin: 0 auto 18px;
  display: grid;
  place-items: center;
  background: transparent;
  box-shadow: none;
  border-radius: 0;
}
.gate-logo {
  width: 88px;
  height: 88px;
  border-radius: 24px;
  object-fit: cover;
  display: block;
  box-shadow: none;
}
.gate-title {
  margin: 0 0 8px;
  font-size: 1.6rem;
  font-weight: 750;
  letter-spacing: 0.06em;
  color: var(--text);
}
.gate-sub {
  margin: 0 0 22px;
  color: var(--muted);
  font-size: 0.95rem;
  line-height: 1.5;
}
.gate-form {
  text-align: left;
}
.gate-field {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 14px;
}
.gate-label {
  font-size: 13px;
  font-weight: 650;
  color: var(--muted);
  letter-spacing: 0.02em;
}
.gate-field input {
  width: 100%;
  padding: 15px 16px;
  border-radius: 16px;
  border: 1px solid var(--line);
  background: var(--bg-elev);
  outline: none;
  font-size: 16px;
  letter-spacing: 0.02em;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.gate-field input[type="password"] {
  letter-spacing: 0.08em;
}
.gate-field input:focus {
  border-color: rgba(52, 211, 153, 0.7);
  box-shadow: 0 0 0 4px var(--accent-dim);
}
.gate-error {
  margin: -4px 0 12px;
  color: var(--danger);
  font-size: 0.9rem;
  font-weight: 600;
}
.gate-btn {
  width: 100%;
  margin-top: 2px;
  height: 52px;
  border-radius: 16px;
  font-size: 16px;
  letter-spacing: 0.04em;
}
.gate-foot {
  margin: 18px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
  opacity: 0.9;
}
@media (min-width: 768px) {
  .gate-card {
    width: min(100%, 420px);
    padding: 40px 32px 28px;
  }
}
#app[hidden], #app.app-locked[hidden] { display: none !important; }
