:root {
  --bg: #fbfbf8;
  --surface: #ffffff;
  --text: #1b1c1e;
  --muted: #6b6f76;
  --accent: #3478f6;
  --line: #ececea;
  --danger: #e5484d;
  --flag: #f5a623;
  --done: #34c759;
  --radius: 14px;
  --gap: 16px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #16181d; --surface: #20232a; --text: #f3f4f6; --muted: #9aa0a6;
    --line: #2c2f37; --accent: #4f8dff;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg); color: var(--text);
  font: 16px/1.45 -apple-system, BlinkMacSystemFont, "SF Pro Text", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}
#app { max-width: 720px; margin: 0 auto; min-height: 100%; padding-bottom: calc(72px + var(--safe-bottom)); }

header.topbar {
  position: sticky; top: 0; z-index: 5; background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(180%) blur(14px);
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 20px 8px; gap: 12px;
}
header.topbar h1 { font-size: 26px; font-weight: 700; margin: 0; letter-spacing: -0.02em; }

.group-title { color: var(--muted); font-size: 13px; font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.04em; padding: 18px 20px 6px; }

.task-row {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 12px 20px; background: var(--bg); position: relative;
  border-bottom: 1px solid var(--line); touch-action: pan-y;
}
.task-row .circle {
  flex: none; width: 24px; height: 24px; border-radius: 50%;
  border: 2px solid color-mix(in srgb, var(--muted) 55%, transparent);
  margin-top: 1px; display: grid; place-items: center; cursor: pointer;
  transition: background .15s, border-color .15s;
}
.task-row.done .circle { background: var(--done); border-color: var(--done); }
.task-row.done .circle::after { content: "✓"; color: #fff; font-size: 14px; }
.task-row.done .title { color: var(--muted); text-decoration: line-through; }
.task-row .body { flex: 1; min-width: 0; }
.task-row .title { font-size: 16px; }
.task-row .meta { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 4px; color: var(--muted); font-size: 13px; }
.task-row .progress { font-size: 12px; color: var(--muted); }
.chip { display: inline-flex; align-items: center; gap: 4px; padding: 2px 9px; border-radius: 999px;
  font-size: 12px; background: color-mix(in srgb, var(--accent) 12%, transparent); color: var(--accent); }
.chip.flag { background: color-mix(in srgb, var(--flag) 18%, transparent); color: var(--flag); }
.chip.high { background: color-mix(in srgb, var(--danger) 14%, transparent); color: var(--danger); }

.swipe-actions { position: absolute; right: 0; top: 0; bottom: 0; display: flex; }
.swipe-actions button { border: 0; color: #fff; font-size: 13px; padding: 0 16px; }
.swipe-actions .resched { background: var(--accent); }
.swipe-actions .flag { background: var(--flag); }
.swipe-actions .del { background: var(--danger); }

nav.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 6;
  display: flex; background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: blur(14px); border-top: 1px solid var(--line);
  padding-bottom: var(--safe-bottom);
}
nav.tabbar button { flex: 1; border: 0; background: none; color: var(--muted);
  font-size: 11px; padding: 8px 0 10px; display: grid; gap: 2px; justify-items: center; }
nav.tabbar button .ico { font-size: 20px; }
nav.tabbar button.active { color: var(--accent); }

.fab { position: fixed; right: 20px; bottom: calc(78px + var(--safe-bottom)); z-index: 7;
  width: 56px; height: 56px; border-radius: 50%; border: 0; background: var(--accent); color: #fff;
  font-size: 30px; box-shadow: 0 6px 18px rgba(52,120,246,.4); }

.sheet-backdrop { position: fixed; inset: 0; z-index: 10; background: rgba(0,0,0,.35); display: grid; align-items: end; }
.sheet { background: var(--surface); border-radius: 20px 20px 0 0; padding: 20px;
  max-height: 86vh; overflow: auto; }
.sheet input, .sheet textarea, .sheet select {
  width: 100%; font: inherit; padding: 12px 14px; border: 1px solid var(--line);
  border-radius: var(--radius); background: var(--bg); color: var(--text); margin: 6px 0; }
.sheet .chips { display: flex; gap: 8px; flex-wrap: wrap; margin: 10px 0; }
.btn-primary { width: 100%; border: 0; background: var(--accent); color: #fff; font-weight: 600;
  padding: 14px; border-radius: var(--radius); font-size: 16px; margin-top: 10px; }

.toast { position: fixed; left: 50%; bottom: calc(90px + var(--safe-bottom)); transform: translateX(-50%);
  z-index: 20; background: #1b1c1e; color: #fff; padding: 12px 18px; border-radius: 12px;
  display: flex; gap: 14px; align-items: center; box-shadow: 0 8px 24px rgba(0,0,0,.3); }
.toast button { background: none; border: 0; color: var(--accent); font-weight: 600; }

.breadcrumb { color: var(--accent); font-size: 14px; padding: 8px 20px 0; }
.detail-field { padding: 12px 20px; border-bottom: 1px solid var(--line); }
.detail-field label { display: block; color: var(--muted); font-size: 12px; margin-bottom: 4px; }
.client-list .client { padding: 16px 20px; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; }
.empty { text-align: center; color: var(--muted); padding: 64px 20px; }
