:root {
  --bg: #f6f5f2;
  --bg-2: #efeee9;
  --surface: rgba(255, 255, 255, 0.78);
  --surface-solid: #ffffff;
  --line: rgba(20, 20, 30, 0.08);
  --line-2: rgba(20, 20, 30, 0.14);
  --text: #16161d;
  --text-2: #5d5d6a;
  --text-3: #9a9aa6;
  --accent: #5b4cf0;
  --accent-2: #8a5cf6;
  --accent-soft: rgba(91, 76, 240, 0.1);
  --danger: #e5484d;
  --warn: #e8a33c;
  --ok: #30a46c;
  --shadow: 0 1px 2px rgba(16, 16, 30, 0.04), 0 8px 24px -8px rgba(16, 16, 30, 0.12);
  --shadow-lg: 0 24px 80px -12px rgba(16, 16, 30, 0.35);
  --r: 14px;
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Inter", "Segoe UI", system-ui, sans-serif;
  --display: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Inter", "Segoe UI", system-ui, sans-serif;
  color-scheme: light;
}
/* Dark palette — applied by JS via data-mode="dark" */
:root[data-mode="dark"] {
  --bg: #0b0b0f;
  --bg-2: #111117;
  --surface: rgba(28, 28, 36, 0.72);
  --surface-solid: #18181f;
  --line: rgba(255, 255, 255, 0.07);
  --line-2: rgba(255, 255, 255, 0.13);
  --text: #f2f2f6;
  --text-2: #a4a4b2;
  --text-3: #6b6b7a;
  --accent: #8b7dff;
  --accent-2: #b48cff;
  --accent-soft: rgba(139, 125, 255, 0.14);
  --shadow: 0 1px 0 rgba(255, 255, 255, 0.03) inset, 0 8px 30px -10px rgba(0, 0, 0, 0.6);
  --shadow-lg: 0 30px 90px -10px rgba(0, 0, 0, 0.8);
  color-scheme: dark;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  font-size: 15px;
  letter-spacing: -0.01em;
}
body::before {
  content: "";
  position: fixed; inset: -20vh -10vw auto auto;
  width: 70vw; height: 70vh;
  background: radial-gradient(closest-side, var(--accent-soft), transparent 70%);
  filter: blur(40px);
  pointer-events: none; z-index: 0;
}
button { font: inherit; color: inherit; cursor: pointer; border: 0; background: none; }
input, textarea, select { font: inherit; color: inherit; }
[hidden] { display: none !important; }
.muted { color: var(--text-2); }
code { font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 0.9em; background: var(--accent-soft); padding: 1px 5px; border-radius: 5px; }

/* ---------- Brand ---------- */
.brand { display: flex; align-items: center; gap: 10px; font-family: var(--display); font-weight: 650; font-size: 17px; padding: 4px 10px 22px; }
.brand-mark {
  width: 26px; height: 26px; border-radius: 8px;
  background: linear-gradient(140deg, var(--accent), var(--accent-2));
  box-shadow: 0 4px 14px -4px var(--accent);
  position: relative;
}
.brand-mark::after {
  content: ""; position: absolute; left: 8px; top: 5px; width: 7px; height: 12px;
  border: solid #fff; border-width: 0 2.5px 2.5px 0; transform: rotate(42deg); border-radius: 1px;
}
.brand-mark.big { width: 56px; height: 56px; border-radius: 16px; margin: 0 auto 18px; }
.brand-mark.big::after { left: 19px; top: 11px; width: 14px; height: 26px; border-width: 0 5px 5px 0; }

/* ---------- Layout ---------- */
.app { position: relative; z-index: 1; display: grid; grid-template-columns: 260px 1fr; min-height: 100dvh; }
.sidebar {
  position: sticky; top: 0; height: 100dvh;
  padding: 22px 14px; display: flex; flex-direction: column;
  border-right: 1px solid var(--line);
  background: color-mix(in srgb, var(--bg-2) 60%, transparent);
  backdrop-filter: blur(20px);
}
.nav, .lists { display: flex; flex-direction: column; gap: 2px; }
.nav button, .lists button, .sidebar-foot .ghost {
  display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 9px;
  color: var(--text-2); text-align: left; font-weight: 500; transition: background .15s, color .15s;
}
.nav button:hover, .lists button:hover, .sidebar-foot .ghost:hover { background: var(--line); color: var(--text); }
.nav button.active, .lists button.active { background: var(--surface-solid); color: var(--text); box-shadow: var(--shadow); }
.nav .ico, .sidebar-foot .ico { width: 18px; text-align: center; opacity: .8; }
.nav em { margin-left: auto; font-style: normal; font-size: 12px; color: var(--text-3); font-variant-numeric: tabular-nums; }
.lists { margin-top: 22px; }
.lists .label { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--text-3); padding: 0 10px 6px; font-weight: 600; }
.lists .dot { width: 8px; height: 8px; border-radius: 50%; margin: 0 5px; }
.sidebar-foot { margin-top: auto; display: flex; flex-direction: column; gap: 10px; }
.kbd-hint { font-size: 12px; color: var(--text-3); padding: 0 10px; }
kbd { font-family: var(--font); font-size: 11px; border: 1px solid var(--line-2); border-bottom-width: 2px; border-radius: 5px; padding: 0 5px; }

.main { padding: 44px clamp(18px, 6vw, 72px) 120px; max-width: 820px; width: 100%; }
.head { display: flex; align-items: flex-end; justify-content: space-between; margin-bottom: 22px; }
.eyebrow { margin: 0 0 4px; color: var(--accent); font-weight: 600; font-size: 13px; letter-spacing: .02em; }
.head h1 { margin: 0; font-family: var(--display); font-size: 34px; font-weight: 700; letter-spacing: -0.03em; }
.icon-btn { width: 38px; height: 38px; border-radius: 50%; background: var(--surface); border: 1px solid var(--line); font-size: 17px; }
.mobile-only { display: none; }

/* ---------- Capture bar ---------- */
.capture {
  position: relative; display: flex; align-items: center; flex-wrap: wrap;
  background: var(--surface); backdrop-filter: blur(20px);
  border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--shadow);
  padding: 4px 14px; margin-bottom: 26px; transition: border-color .2s, box-shadow .2s;
}
.capture:focus-within { border-color: color-mix(in srgb, var(--accent) 50%, transparent); box-shadow: 0 0 0 4px var(--accent-soft), var(--shadow); }
.capture .plus { color: var(--accent); font-size: 22px; font-weight: 300; width: 22px; }
.capture input { flex: 1; min-width: 0; border: 0; outline: 0; background: none; padding: 14px 8px; font-size: 16px; }
.capture input::placeholder, .sheet input::placeholder, textarea::placeholder { color: var(--text-3); }
.chips { display: flex; gap: 6px; flex-wrap: wrap; width: 100%; }
.chips:empty { display: none; }
.capture .chips { padding: 0 0 10px 30px; }
.chip {
  display: inline-flex; align-items: center; gap: 5px; font-size: 12px; font-weight: 550;
  padding: 3px 9px; border-radius: 99px; background: var(--accent-soft); color: var(--accent);
  animation: pop .2s ease-out;
}
.chip.list { background: color-mix(in srgb, var(--warn) 16%, transparent); color: color-mix(in srgb, var(--warn) 80%, var(--text)); }
.chip.prio { background: color-mix(in srgb, var(--danger) 14%, transparent); color: var(--danger); }
@keyframes pop { from { transform: scale(.85); opacity: 0; } }

/* ---------- Task list ---------- */
.group { margin-bottom: 26px; }
.group-h { display: flex; align-items: baseline; gap: 8px; font-size: 13px; font-weight: 650; color: var(--text-2); margin: 0 4px 8px; }
.group-h.overdue { color: var(--danger); }
.group-h small { color: var(--text-3); font-weight: 500; }
.tasks { background: var(--surface); backdrop-filter: blur(20px); border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--shadow); overflow: hidden; }
.task {
  display: flex; align-items: flex-start; gap: 12px; padding: 13px 14px;
  border-top: 1px solid var(--line); cursor: pointer; transition: background .15s;
  position: relative;
}
.task:first-child { border-top: 0; }
.task:hover { background: color-mix(in srgb, var(--line) 50%, transparent); }
.task.enter { animation: slideIn .35s cubic-bezier(.2, .9, .3, 1.2); }
.task.leaving { animation: slideOut .4s ease forwards; }
@keyframes slideIn { from { opacity: 0; transform: translateY(-8px); } }
@keyframes slideOut { to { opacity: 0; transform: translateX(16px); height: 0; padding-top: 0; padding-bottom: 0; } }

.check {
  flex: none; width: 22px; height: 22px; margin-top: 1px; border-radius: 50%;
  border: 1.6px solid var(--line-2); position: relative; transition: all .2s;
}
.check:hover { border-color: var(--accent); background: var(--accent-soft); }
.task[data-p="3"] .check { border-color: var(--danger); }
.task[data-p="2"] .check { border-color: var(--warn); }
.task[data-p="1"] .check { border-color: var(--accent); }
.task.done .check, .check.checking {
  background: linear-gradient(140deg, var(--accent), var(--accent-2)); border-color: transparent;
}
.task.done .check::after, .check.checking::after {
  content: ""; position: absolute; left: 7px; top: 3.5px; width: 5px; height: 10px;
  border: solid #fff; border-width: 0 2px 2px 0; transform: rotate(42deg);
  animation: pop .25s ease-out;
}
.task-body { flex: 1; min-width: 0; }
.task-title { line-height: 1.4; word-wrap: break-word; }
.task.done .task-title { color: var(--text-3); text-decoration: line-through; text-decoration-color: var(--line-2); }
.task-meta { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 3px; font-size: 12.5px; color: var(--text-3); }
.task-meta .due.overdue { color: var(--danger); }
.task-meta .due.soon { color: var(--accent); }
.task-meta .tag::before { content: "#"; opacity: .6; }
.task-meta .bell { display: inline-flex; align-items: center; opacity: .75; }
.task-meta .bell svg { width: 12px; height: 12px; }

.empty { text-align: center; padding: 70px 20px; color: var(--text-3); }
.empty .big { font-size: 40px; margin-bottom: 10px; opacity: .8; }
.empty h3 { color: var(--text-2); margin: 0 0 4px; font-weight: 600; }

/* ---------- Sheets ---------- */
.sheet-backdrop {
  position: fixed; inset: 0; z-index: 50; display: grid; place-items: center;
  background: rgba(8, 8, 14, 0.38); backdrop-filter: blur(6px);
  animation: fade .2s ease;
}
@keyframes fade { from { opacity: 0; } }
.sheet {
  width: min(560px, calc(100vw - 32px)); max-height: 88dvh; overflow: auto;
  background: var(--surface-solid); border: 1px solid var(--line); border-radius: 20px; box-shadow: var(--shadow-lg);
  padding: 22px; animation: rise .28s cubic-bezier(.2, .9, .3, 1.1);
}
@keyframes rise { from { transform: translateY(20px) scale(.98); opacity: 0; } }
.grabber { display: none; width: 38px; height: 5px; border-radius: 9px; background: var(--line-2); margin: -8px auto 14px; }
.sheet h2 { margin: 0 0 16px; font-family: var(--display); font-size: 22px; letter-spacing: -0.02em; }
.sheet h3 { margin: 0 0 4px; font-size: 15px; }
.sheet input, .sheet textarea, .sheet select {
  width: 100%; border: 1px solid var(--line); background: var(--bg); border-radius: 10px; padding: 10px 12px; outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.sheet input:focus, .sheet textarea:focus, .sheet select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.sheet textarea { resize: vertical; margin: 10px 0 14px; }
.detail-title { font-size: 19px !important; font-weight: 600; border: 0 !important; background: none !important; padding: 4px 2px !important; box-shadow: none !important; }
.field-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.field-grid label { display: flex; flex-direction: column; gap: 6px; font-size: 12px; font-weight: 600; color: var(--text-2); }
.detail-actions, .row { display: flex; gap: 8px; align-items: center; margin-top: 18px; flex-wrap: wrap; }
.row.end { justify-content: flex-end; }
.spacer { flex: 1; }
.quick input { font-size: 18px; border: 0 !important; background: none !important; box-shadow: none !important; padding: 6px 2px !important; }
.quick .chips { margin: 4px 0 12px; }
.quick-row { display: flex; gap: 10px; align-items: center; }
.pills { flex: 1; min-width: 0; display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; -webkit-mask-image: linear-gradient(90deg, #000 85%, transparent); mask-image: linear-gradient(90deg, #000 85%, transparent); }
.pills::-webkit-scrollbar { display: none; }
.quick-row .btn { flex: none; }
.pill { flex: none; padding: 7px 12px; border-radius: 99px; border: 1px solid var(--line-2); font-size: 13px; color: var(--text-2); white-space: nowrap; }
.pill:active { background: var(--accent-soft); }
.card { border: 1px solid var(--line); border-radius: 14px; padding: 16px; margin-bottom: 12px; background: var(--bg); }
.card p { margin: 4px 0 0; font-size: 13.5px; line-height: 1.5; }
.card .row { margin-top: 12px; }
.ios-hint { margin-top: 12px; font-size: 13px; line-height: 1.5; padding: 10px 12px; border-radius: 10px; background: var(--accent-soft); }
.copy-row { display: flex; gap: 8px; margin-top: 10px; }
.copy-row input { font-family: ui-monospace, Menlo, monospace; font-size: 12px; }
.seg { display: inline-flex; padding: 3px; background: var(--line); border-radius: 10px; margin-top: 8px; }
.seg button { padding: 6px 14px; border-radius: 8px; font-size: 13px; color: var(--text-2); }
.seg button.active { background: var(--surface-solid); color: var(--text); box-shadow: var(--shadow); }

/* ---------- Buttons ---------- */
.btn { padding: 9px 16px; border-radius: 10px; font-weight: 600; font-size: 14px; background: var(--line); transition: transform .1s, filter .15s, background .15s; }
.btn:active { transform: scale(.97); }
.btn.primary { background: linear-gradient(140deg, var(--accent), var(--accent-2)); color: #fff; box-shadow: 0 6px 18px -8px var(--accent); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.ghost { background: transparent; border: 1px solid var(--line-2); }
.btn.danger { color: var(--danger); }
.btn.sm { padding: 7px 14px; font-size: 13px; }
.btn:disabled { opacity: .5; cursor: default; }

/* ---------- Login ---------- */
.login { position: relative; z-index: 1; min-height: 100dvh; display: grid; place-items: center; padding: 20px; }
.login-card { width: min(360px, 100%); text-align: center; display: flex; flex-direction: column; gap: 12px; }
.login-card h1 { margin: 0; font-family: var(--display); letter-spacing: -0.03em; }
.login-card p { margin: 0 0 8px; }
.login-card input { border: 1px solid var(--line-2); background: var(--surface); border-radius: 12px; padding: 13px 14px; outline: none; font-size: 16px; text-align: center; }
.login-card input:focus { border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
.login-card .btn { padding: 13px; }
.error { color: var(--danger); font-size: 13px; min-height: 1em; }

/* ---------- Toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%); z-index: 80;
  background: var(--text); color: var(--bg); padding: 11px 16px; border-radius: 12px; font-size: 14px; font-weight: 500;
  box-shadow: var(--shadow-lg); display: flex; gap: 14px; align-items: center; animation: rise .25s ease;
  max-width: calc(100vw - 32px);
}
.toast button { color: var(--accent-2); font-weight: 650; }

/* ---------- Tab bar (mobile) ---------- */
.tabbar { display: none; }

@media (max-width: 760px) {
  body { font-size: 16px; }
  .app { grid-template-columns: 1fr; }
  .sidebar { display: none; }
  .mobile-only { display: grid; place-items: center; }
  .main { padding: calc(env(safe-area-inset-top) + 18px) 16px calc(env(safe-area-inset-bottom) + 110px); }
  .head h1 { font-size: 32px; }
  .capture { display: none; }
  .task { padding: 14px; }
  .tabbar {
    display: flex; position: fixed; z-index: 40; left: 12px; right: 12px; bottom: calc(env(safe-area-inset-bottom) + 10px);
    background: color-mix(in srgb, var(--surface-solid) 82%, transparent); backdrop-filter: blur(24px) saturate(1.6);
    -webkit-backdrop-filter: blur(24px) saturate(1.6);
    border: 1px solid var(--line); border-radius: 22px; box-shadow: var(--shadow-lg); padding: 6px; align-items: center;
  }
  .tabbar button { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 1px; font-size: 10.5px; font-weight: 600; color: var(--text-3); padding: 6px 0; }
  .tabbar button span { font-size: 18px; line-height: 1.2; }
  .tabbar button.active { color: var(--accent); }
  .tabbar .fab {
    flex: none; width: 52px; height: 52px; border-radius: 17px; margin: 0 4px; font-size: 28px; font-weight: 300; color: #fff;
    background: linear-gradient(140deg, var(--accent), var(--accent-2)); box-shadow: 0 10px 24px -8px var(--accent);
  }
  .sheet-backdrop { place-items: end center; }
  .sheet {
    width: 100%; border-radius: 22px 22px 0 0; border-bottom: 0;
    padding: 20px 18px calc(env(safe-area-inset-bottom) + 18px);
    animation: up .3s cubic-bezier(.2, .9, .3, 1);
  }
  @keyframes up { from { transform: translateY(100%); } }
  .grabber { display: block; }
  .field-grid { grid-template-columns: 1fr; }
  .toast { bottom: calc(env(safe-area-inset-bottom) + 96px); }
}
