:root {
  --bg: #14161c;
  --surface: #1c1f27;
  --surface-2: #242832;
  --border: #2b2f3a;
  --border-hover: #3a3f4d;
  --text: #e9eaee;
  --text-dim: #9aa0ad;
  --text-faint: #6b7280;
  --sidebar-bg: #181a21;
  --accent: #5b8def;
  --accent-dim: #3f5f9e;
  --success: #4fbf9f;
  --danger: #e5636b;
  --warn: #e0a83e;
  --radius: 14px;
  --radius-sm: 9px;
  color-scheme: dark;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Inter, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

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

/* ---------- setup screen ---------- */
.setup-screen {
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.setup-card {
  width: 100%;
  max-width: 380px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px;
  text-align: center;
}
.setup-logo img { border-radius: 16px; }
.setup-card h1 { margin: 14px 0 4px; font-size: 22px; letter-spacing: -0.01em; }
.setup-card form { text-align: left; margin-top: 18px; }
.setup-card .hint {
  margin-top: 10px;
  font-size: 13px;
  color: var(--accent);
}

/* ---------- app shell ----------
   Mobile: sidebar hidden, sticky topbar + pill tabs.
   Desktop (>=900px): sidebar shown, topbar/tabs hidden. One layout, one breakpoint. */
.app { min-height: 100dvh; display: flex; }
.app-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.sidebar { display: none; }
.section-heading { display: none; }

.content {
  width: 100%;
  max-width: 640px;
  margin: 0 auto;
  padding: 16px 16px 90px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: var(--bg);
  z-index: 5;
}
.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 650;
  font-size: 17px;
  letter-spacing: -0.01em;
}
.brand img { border-radius: 6px; }

.tabs {
  display: flex;
  gap: 4px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
  position: sticky;
  top: 57px;
  background: var(--bg);
  z-index: 4;
}
.tab {
  background: none;
  border: none;
  color: var(--text-dim);
  padding: 8px 14px;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}
.tab.active { background: var(--surface-2); color: var(--text); }

.view { display: none; }
.view.active { display: block; }

/* ---------- desktop sidebar ---------- */
@media (min-width: 900px) {
  .topbar, .tabs { display: none; }

  .sidebar {
    display: block;
    width: 250px;
    min-width: 250px;
    background: var(--sidebar-bg);
    border-right: 1px solid var(--border);
    padding: 20px 14px;
    position: sticky;
    top: 0;
    height: 100dvh;
    overflow-y: auto;
  }

  .content { max-width: 760px; padding: 32px 40px 90px; }

  .section-heading {
    display: block;
    font-size: 22px;
    font-weight: 700;
    letter-spacing: -0.01em;
    margin: 0 0 20px;
  }
}

.side-brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 650;
  font-size: 18px;
  letter-spacing: -0.01em;
  padding: 0 8px;
  margin-bottom: 20px;
}
.side-logo {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 800;
  color: #fff;
}

.side-nav-list { margin-top: 20px; display: flex; flex-direction: column; gap: 2px; }
.side-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  width: 100%;
  background: none;
  border: none;
  color: var(--text-dim);
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  text-align: left;
}
.side-nav:hover { background: #1f232d; }
.side-nav.active { background: var(--surface-2); color: var(--text); }

.side-badge {
  background: var(--danger);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  border-radius: 999px;
  padding: 1px 7px;
}

.side-section-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-faint);
  margin: 26px 0 6px;
  padding: 0 12px;
}
.side-project {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  background: none;
  border: none;
  color: var(--text-dim);
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}
.side-project:hover { background: #1f232d; }
.side-project.active { background: var(--surface-2); color: var(--text); }
.side-project .dot { width: 8px; height: 8px; min-width: 8px; }
.side-project .pname { text-align: left; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.side-project .count { font-size: 12px; color: var(--text-faint); }

/* ---------- buttons ---------- */
.btn-primary, .btn-secondary {
  border: none;
  border-radius: var(--radius-sm);
  padding: 10px 16px;
  font-size: 14px;
  font-weight: 650;
  cursor: pointer;
}
.btn-primary { background: var(--accent); color: white; }
.btn-primary:active { background: var(--accent-dim); }
.btn-secondary { background: var(--surface-2); color: var(--text); }
.btn-primary.full { width: 100%; margin-top: 4px; }

.link-btn {
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  padding: 4px 6px;
}
.link-btn.danger { color: var(--danger); }

/* ---------- forms ---------- */
.field-label {
  display: block;
  font-size: 12px;
  font-weight: 650;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-dim);
  margin: 12px 0 6px;
}
input[type="text"], input[type="url"], input[type="password"],
input[type="datetime-local"], input[type="time"], select, textarea {
  width: 100%;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font-size: 15px;
  font-family: inherit;
}
textarea { resize: vertical; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

.preset-row { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
.preset-row button {
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text-dim);
  border-radius: 999px;
  padding: 6px 10px;
  font-size: 12px;
  cursor: pointer;
}

.inline-form { display: flex; flex-direction: column; gap: 8px; margin-bottom: 16px; }

/* ---------- cards / sections ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 16px;
}
.section-title {
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-dim);
  margin: 22px 0 8px;
}
.section-title:first-child { margin-top: 0; }

.today-summary { display: flex; gap: 12px; margin-bottom: 4px; }
.summary-card {
  flex: 1;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  text-align: center;
}
.summary-card .num { font-size: 32px; font-weight: 700; letter-spacing: -0.02em; }
.summary-card .num.danger { color: var(--danger); }
.summary-card .num.accent { color: var(--accent); }
.summary-card .label { font-size: 12px; color: var(--text-dim); margin-top: 2px; }

/* ---------- task list ---------- */
.task-list { list-style: none; margin: 0 0 8px; padding: 0; }
.task-row {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 3px solid var(--pcolor, var(--accent));
  border-radius: 10px;
  padding: 13px 14px;
  margin-bottom: 8px;
}
/* Keep the project stripe when the rest of the border lightens on hover. */
.task-row:hover {
  border-color: var(--border-hover);
  border-left-color: var(--pcolor, var(--accent));
}
.task-row.done { opacity: 0.5; }
.task-row.done .task-title { text-decoration: line-through; }

.check {
  width: 24px;
  height: 24px;
  min-width: 24px;
  border-radius: 50%;
  border: 2px solid var(--text-dim);
  background: none;
  cursor: pointer;
  transition: transform 0.15s ease;
}
.task-row.done .check { background: var(--success); border-color: var(--success); }
.check:active { transform: scale(0.85); }

.task-main { flex: 1; min-width: 0; }
.task-title { font-size: 15px; font-weight: 600; }
.task-meta { display: flex; gap: 6px; align-items: center; margin-top: 4px; flex-wrap: wrap; }

.chip {
  font-size: 11px;
  font-weight: 650;
  color: var(--pcolor, var(--accent));
  background: color-mix(in srgb, var(--pcolor, var(--accent)) 18%, transparent);
  padding: 2px 8px;
  border-radius: 999px;
}
.due { font-size: 12px; color: var(--text-dim); }
/* Overdue reads as a badge, not just red text — it should survive a glance. */
.due.overdue {
  font-size: 11px;
  font-weight: 700;
  color: var(--danger);
  background: color-mix(in srgb, var(--danger) 15%, transparent);
  padding: 2px 8px;
  border-radius: 999px;
}
.prio-high {
  font-size: 11px;
  font-weight: 700;
  color: var(--warn);
  background: color-mix(in srgb, var(--warn) 15%, transparent);
  padding: 2px 8px;
  border-radius: 999px;
}

.edit-btn {
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  padding: 4px 6px;
}

.empty { color: var(--text-dim); font-size: 14px; padding: 10px 2px; list-style: none; }

/* ---------- projects ---------- */
.project-pills { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 12px; margin-bottom: 6px; }
.pill {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-dim);
  padding: 7px 14px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
  border-left: 3px solid var(--pcolor, var(--border));
}
.pill.active { background: var(--surface-2); color: var(--text); }

.project-manage-list { list-style: none; margin: 0 0 14px; padding: 0; }
.project-manage-list li { display: flex; align-items: center; gap: 8px; padding: 8px 0; border-bottom: 1px solid var(--border); }
.project-manage-list li:last-child { border-bottom: none; }
.dot { width: 10px; height: 10px; border-radius: 50%; background: var(--pcolor); }
.pname { flex: 1; font-size: 14px; }

.swatches { display: flex; gap: 8px; margin: 4px 0; }
.swatch {
  width: 26px; height: 26px; border-radius: 50%;
  background: var(--c);
  border: 2px solid transparent;
  cursor: pointer;
}
.swatch.selected { border-color: var(--text); }

.kv { display: flex; justify-content: space-between; gap: 10px; font-size: 13px; padding: 6px 0; }
.kv span:first-child { color: var(--text-dim); }
.kv span:last-child { word-break: break-all; text-align: right; }
.btn-row { display: flex; gap: 8px; margin-top: 12px; flex-wrap: wrap; }

/* ---------- notes ---------- */
.note-list { list-style: none; margin: 0; padding: 0; }
.note-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px;
  margin-bottom: 10px;
}
.note-body { font-size: 14px; margin: 6px 0; white-space: pre-wrap; }
.note-footer { display: flex; justify-content: space-between; align-items: center; }
.note-date { font-size: 12px; color: var(--text-dim); }

/* ---------- modal ---------- */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 20;
}
.modal {
  width: 100%;
  max-width: 480px;
  max-height: 92dvh;
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-bottom: none;
  border-radius: 20px 20px 0 0;
  padding: 20px;
}
@media (min-width: 640px) {
  .modal-backdrop { align-items: center; }
  .modal { border-radius: var(--radius); border-bottom: 1px solid var(--border); }
}
.modal h3 { margin: 0 0 4px; font-size: 18px; }
.modal-actions { display: flex; align-items: center; gap: 8px; margin-top: 18px; }
.spacer { flex: 1; }

/* ---------- smart-capture suggestion ---------- */
.suggestion {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--surface-2);
  border: 1px solid var(--accent-dim);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  font-size: 13px;
  color: var(--text-dim);
  margin-top: 10px;
}
.suggestion span { flex: 1; }
.btn-suggest {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 7px;
  padding: 6px 10px;
  font-size: 12px;
  font-weight: 650;
  cursor: pointer;
  white-space: nowrap;
}

/* ---------- quick add ---------- */
.quick-add { display: flex; gap: 8px; margin-bottom: 18px; }
.quick-add input { flex: 1; min-width: 0; }

/* ---------- floating capture button ---------- */
.fab {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  border: none;
  font-size: 26px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 6px 18px rgba(91, 141, 239, 0.5);
  z-index: 26;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.15s ease;
}
.fab.open { transform: rotate(45deg); }

/* Full-screen catcher so a tap anywhere closes the menu. */
.fab-backdrop { position: fixed; inset: 0; z-index: 24; }

.fab-actions {
  position: fixed;
  bottom: 88px;
  right: 24px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 25;
}
.fab-action {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 999px;
  padding: 12px 18px;
  font-size: 14px;
  font-weight: 650;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.35);
  white-space: nowrap;
}

/* ---------- toast ---------- */
.toast {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 10px 18px;
  border-radius: 999px;
  font-size: 13px;
  z-index: 30;
  max-width: 90vw;
}

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
