/* ── Reset & Variables ──────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

/* ── QA Environment Banner ───────────────────────────────────────────────── */
.qa-banner {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 8px 20px;
  background: #92400e;
  border-bottom: 2px solid #f59e0b;
  color: #fef3c7;
  font-size: 13px;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}
.qa-banner-icon  { font-size: 15px; }
.qa-banner-text  { flex: 1; text-align: center; }
.qa-banner-link  {
  color: #fde68a;
  text-decoration: underline;
  white-space: nowrap;
  font-size: 12px;
}
.qa-banner-link:hover { color: #fff; }

/* Push app content down when QA banner is visible */
body:has(#qa-banner[style*="flex"]) .app {
  padding-top: 38px;
}

/* ── Design tokens ──────────────────────────────────────────────────────────
   Light palette lives on bare :root. Dark overrides the same names twice:
   once behind prefers-color-scheme (guarded so an explicit data-theme="light"
   still wins), and once behind [data-theme="dark"] so the in-app toggle wins
   in both directions. Every component below reads only these names — never
   a literal color — so both themes and the system default stay correct. */
:root {
  --bg:          #F7F7F8;
  --surface:     #FFFFFF;
  --surface-2:   #FBFBFC;
  --raise:       #F1F1F3;
  --hover:       #F4F4F6;
  --text:        #1B1B1F;
  --text-2:      #65656F;
  --text-3:      #9A9AA4;
  --border:      #E8E8EC;
  --border-2:    #DEDEE3;

  --accent:      #3355E8;
  --accent-h:    #2444C7;
  --accent-d:    #1A35A0;
  --accent-bg:   rgba(51,85,232,.07);

  --work:        #3355E8;
  --personal:    #0B8A72;
  --life:        #BE730C;

  --ok:          #12855A;
  --ok-bg:       rgba(18,133,90,.08);
  --warn:        #B0700B;
  --warn-bg:     rgba(176,112,11,.08);
  --bad:         #C13B31;
  --bad-bg:      rgba(193,59,49,.07);
  --info:        var(--accent);

  --shadow:      0 12px 40px -8px rgba(15,15,20,.24);
  --shadow-sm:   0 2px 10px rgba(15,15,20,.08);

  /* legacy aliases — every selector below was written against these names
     before the token rewrite; keeping them means the whole file didn't need
     a mechanical find/replace across ~2000 lines of otherwise-unrelated CSS */
  --bg2: var(--surface);
  --bg3: var(--raise);
  --bg4: var(--hover);
  --success: var(--ok);
  --warning: var(--warn);
  --danger:  var(--bad);

  --sidebar-w:  236px;
  --radius:     9px;
  --radius-sm:  6px;

  --font-sans: 'Instrument Sans', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, 'SF Mono', Menlo, monospace;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg:          #111114;
    --surface:     #18181C;
    --surface-2:   #1C1C21;
    --raise:       #22222A;
    --hover:       #202027;
    --text:        #ECECF0;
    --text-2:      #95959F;
    --text-3:      #5E5E69;
    --border:      #26262E;
    --border-2:    #31313A;

    --accent:      #6C86FF;
    --accent-h:    #8AA0FF;
    --accent-d:    #4D63D9;
    --accent-bg:   rgba(108,134,255,.1);

    --work:        #6C86FF;
    --personal:    #2BB89C;
    --life:        #DE9B34;

    --ok:          #35BC85;
    --ok-bg:       rgba(53,188,133,.11);
    --warn:        #DBA13C;
    --warn-bg:     rgba(219,161,60,.11);
    --bad:         #E8695E;
    --bad-bg:      rgba(232,105,94,.1);

    --shadow:      0 12px 40px -8px rgba(0,0,0,.5);
    --shadow-sm:   0 2px 10px rgba(0,0,0,.35);
  }
}
:root[data-theme="dark"] {
  --bg:          #111114;
  --surface:     #18181C;
  --surface-2:   #1C1C21;
  --raise:       #22222A;
  --hover:       #202027;
  --text:        #ECECF0;
  --text-2:      #95959F;
  --text-3:      #5E5E69;
  --border:      #26262E;
  --border-2:    #31313A;

  --accent:      #6C86FF;
  --accent-h:    #8AA0FF;
  --accent-d:    #4D63D9;
  --accent-bg:   rgba(108,134,255,.1);

  --work:        #6C86FF;
  --personal:    #2BB89C;
  --life:        #DE9B34;

  --ok:          #35BC85;
  --ok-bg:       rgba(53,188,133,.11);
  --warn:        #DBA13C;
  --warn-bg:     rgba(219,161,60,.11);
  --bad:         #E8695E;
  --bad-bg:      rgba(232,105,94,.1);

  --shadow:      0 12px 40px -8px rgba(0,0,0,.5);
  --shadow-sm:   0 2px 10px rgba(0,0,0,.35);
}

html, body { height: 100%; font-family: var(--font-sans); }
body {
  background: var(--bg);
  color: var(--text);
  overflow: hidden;
  font-size: 14px;
  line-height: 1.5;
  letter-spacing: -0.005em;
  -webkit-font-smoothing: antialiased;
}
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
button { font-family: inherit; letter-spacing: inherit; }

/* ── Layout ─────────────────────────────────────────────────────────────── */
.app { display: flex; height: 100vh; overflow: hidden; }

/* ── Sidebar ─────────────────────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  min-width: var(--sidebar-w);
  background: var(--bg);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  transition: width 0.2s ease, min-width 0.2s ease;
  overflow: hidden;
  z-index: 10;
  /* Extend the sidebar's background under the iOS status bar/notch (PWA
     standalone mode) instead of letting nav content render beneath it. */
  padding-top: env(safe-area-inset-top);
}
.sidebar.collapsed { width: 0; min-width: 0; border: none; }

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 16px 16px 12px;
  font-size: 14.5px;
  font-weight: 600;
  letter-spacing: -0.02em;
  white-space: nowrap;
}
.logo-icon {
  width: 22px; height: 22px;
  border-radius: 5px;
  background: #FFFFFF;
  border: 1px solid #DEDEE3;
  color: #1B1B1F;
  font-size: 12px;
  display: inline-flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.logo-text { color: var(--text); }

.sidebar-scroll { flex: 1; overflow-y: auto; padding: 2px 8px 8px; }

.sidebar-section-title {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--text-3);
  padding: 16px 8px 5px;
  white-space: nowrap;
}
.sidebar-group-dot { width: 5px; height: 5px; border-radius: 50%; flex-shrink: 0; }

.sidebar-nav { display: flex; flex-direction: column; padding: 0 0 2px; }

.nav-item {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 6px 8px;
  border-radius: var(--radius-sm);
  color: var(--text-2);
  text-decoration: none;
  font-size: 13.5px;
  font-weight: 450;
  cursor: pointer;
  transition: background 0.11s, color 0.11s;
  white-space: nowrap;
  user-select: none;
}
.nav-item:hover { background: var(--hover); color: var(--text); }
.nav-item.active { background: var(--raise); color: var(--text); font-weight: 600; }
.nav-icon { font-size: 13.5px; width: 16px; text-align: center; flex-shrink: 0; opacity: 0.75; }
.nav-item.active .nav-icon { opacity: 1; }

.sidebar-footer { margin-top: auto; padding: 8px; border-top: 1px solid var(--border); }

/* ── User Chip ───────────────────────────────────────────────────────────── */
.user-chip {
  display: flex; align-items: center; gap: 9px;
  padding: 6px 8px; border-radius: var(--radius-sm);
  overflow: hidden; white-space: nowrap;
  cursor: pointer; transition: background 0.12s;
}
.user-chip:hover { background: var(--hover); }
.user-avatar {
  width: 26px; height: 26px; border-radius: 50%;
  background: var(--accent); color: #fff;
  font-size: 11px; font-weight: 600;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
  overflow: hidden;
}
.user-name  { font-size: 13px; font-weight: 500; color: var(--text); line-height: 1.25; }
.user-email { font-size: 11px; color: var(--text-3); overflow: hidden; text-overflow: ellipsis; }
.user-info  { overflow: hidden; }

/* ── Theme Toggle ────────────────────────────────────────────────────────── */
.theme-toggle { margin: 8px 0; }
.theme-toggle .scope-toggle { width: 100%; }
.theme-toggle .scope-btn { flex: 1; text-align: center; padding: 5px 6px; font-size: 15px; }

/* ── Logout Button ───────────────────────────────────────────────────────── */
.btn-logout {
  width: 100%; background: none; border: 1px solid var(--border);
  border-radius: var(--radius-sm); color: var(--text-3);
  font-size: 13px; padding: 7px; cursor: pointer; margin-top: 8px;
  transition: color 0.15s, background 0.15s, border-color 0.15s; font-family: inherit;
}
.btn-logout:hover { color: var(--bad); border-color: var(--bad); background: var(--bad-bg); }

/* ── Main ────────────────────────────────────────────────────────────────── */
.main { flex: 1; display: flex; flex-direction: column; overflow: hidden; min-width: 0; background: var(--surface); }

/* ── Topbar ──────────────────────────────────────────────────────────────── */
.topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  /* Same status-bar inset as .sidebar — keeps the topbar's own background
     seamless behind the notch instead of letting controls collide with it. */
  padding: calc(12px + env(safe-area-inset-top)) 24px 12px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  min-height: 56px;
  flex-shrink: 0;
}
.topbar-search {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 6px 12px;
  flex: 1;
  max-width: 340px;
}
.search-icon { color: var(--text-3); font-size: 16px; }
.topbar-search input {
  background: none;
  border: none;
  outline: none;
  color: var(--text);
  font-size: 14px;
  width: 100%;
  font-family: inherit;
}
.topbar-search input::placeholder { color: var(--text-3); }

.topbar-filters { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.topbar-filters select {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-2);
  font-size: 13px;
  padding: 6px 10px;
  outline: none;
  cursor: pointer;
}
.topbar-filters select:focus { border-color: var(--accent); }

.topbar-right { margin-left: auto; display: flex; gap: 8px; align-items: center; }

/* ── Buttons ─────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 32px;
  padding: 0 14px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  font-size: 13.5px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.11s, border-color 0.11s, color 0.11s, filter 0.11s;
  white-space: nowrap;
  font-family: inherit;
}
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { filter: brightness(1.08); }
.btn-ghost { background: transparent; color: var(--text-2); border-color: var(--border-2); }
.btn-ghost:hover { background: var(--hover); color: var(--text); }
.btn-danger { background: var(--bad); color: #fff; }
.btn-danger:hover { filter: brightness(1.1); }
.btn-sm { height: 26px; padding: 0 10px; font-size: 12.5px; border-radius: 5px; }
.btn-icon {
  background: none;
  border: none;
  color: var(--text-3);
  font-size: 16px;
  cursor: pointer;
  padding: 6px;
  border-radius: var(--radius-sm);
  line-height: 1;
  transition: color 0.15s, background 0.15s;
}
.btn-icon:hover { color: var(--text); background: var(--hover); }

/* ── Views ───────────────────────────────────────────────────────────────── */
.view { flex: 1; overflow-y: auto; padding: 26px 28px; }

.view-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 22px;
  gap: 16px;
  flex-wrap: wrap;
}
.view-title { font-size: 22px; font-weight: 600; letter-spacing: -0.02em; }
.view-subtitle { color: var(--text-3); font-size: 13px; margin-top: 4px; }
.view-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.today-date { color: var(--text-3); font-size: 13px; text-align: right; }

.count-label { color: var(--text-3); font-size: 13px; }

/* ── Stats Grid ──────────────────────────────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 12px;
  margin-bottom: 24px;
}
@media (max-width: 1100px) { .stats-grid { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 700px) { .stats-grid { grid-template-columns: repeat(2, 1fr); } }

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 15px 14px;
  text-align: center;
  transition: border-color 0.15s;
}
.stat-card:hover { border-color: var(--border-2); }
.stat-card.success { border-color: color-mix(in srgb, var(--ok) 30%, var(--border)); }
.stat-card.info    { border-color: color-mix(in srgb, var(--info) 30%, var(--border)); }
.stat-card.warning { border-color: color-mix(in srgb, var(--warn) 30%, var(--border)); }
.stat-card.danger  { border-color: color-mix(in srgb, var(--bad) 30%, var(--border)); }
.stat-card.critical{ border-color: color-mix(in srgb, var(--bad) 50%, var(--border)); background: var(--bad-bg); }

.stat-value { font-size: 26px; font-weight: 600; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.stat-card.success .stat-value { color: var(--ok); }
.stat-card.info    .stat-value { color: var(--info); }
.stat-card.warning .stat-value { color: var(--warn); }
.stat-card.danger  .stat-value { color: var(--bad); }
.stat-card.critical .stat-value { color: var(--bad); }
.stat-label { font-size: 11px; color: var(--text-3); margin-top: 4px; font-weight: 500; text-transform: uppercase; letter-spacing: 0.05em; }

/* ── Dashboard Body ──────────────────────────────────────────────────────── */
.dashboard-body { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
@media (max-width: 900px) { .dashboard-body { grid-template-columns: 1fr; } }

.dash-col { display: flex; flex-direction: column; gap: 14px; }

.dash-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.dash-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px 9px;
  border-bottom: 1px solid var(--border);
}
.dash-card-header h3 { font-size: 13.5px; font-weight: 600; color: var(--text-2); letter-spacing: -0.01em; }
.badge-count {
  background: var(--raise);
  color: var(--text-3);
  font-size: 11px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 20px;
}

/* ── Task List Items (in dash cards) ─────────────────────────────────────── */
.task-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 16px;
  border-bottom: 1px solid var(--border);
  transition: background 0.12s;
  cursor: pointer;
}
.task-item:last-child { border-bottom: none; }
.task-item:hover { background: var(--hover); }

.task-item-dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  flex-shrink: 0;
}
.task-item-name {
  flex: 1;
  font-size: 13px;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.task-item-meta { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }
.task-item-date { font-size: 11px; color: var(--text-3); }
.task-item-done { text-decoration: line-through; color: var(--text-3); }

/* ── Focus Card ─────────────────────────────────────────────────────────── */
.focus-task {
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.focus-task-name { font-size: 15.5px; font-weight: 600; color: var(--text); letter-spacing: -0.01em; }
.focus-task-detail { font-size: 12.5px; color: var(--text-3); }
.focus-task-meta { display: flex; gap: 8px; flex-wrap: wrap; }
.focus-task-actions { display: flex; gap: 8px; margin-top: 4px; }

/* ── Table View ──────────────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }

.tasks-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
}
.tasks-table th {
  background: var(--surface-2);
  color: var(--text-3);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 11px 14px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  user-select: none;
}
.tasks-table th.sortable { cursor: pointer; }
.tasks-table th.sortable:hover { color: var(--text-2); background: var(--hover); }
.tasks-table th.sort-asc .sort-arrow::after { content: ' ↑'; }
.tasks-table th.sort-desc .sort-arrow::after { content: ' ↓'; }

.tasks-table td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
  color: var(--text-2);
}
.tasks-table tr:last-child td { border-bottom: none; }
.tasks-table tr:hover td { background: var(--hover); }
.tasks-table tr.done-row td { opacity: 0.55; }

.td-task { max-width: 240px; }
.td-task-name {
  font-weight: 500;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.clickable-row { cursor: pointer; }
.tasks-table tbody .clickable-row:hover td,
.projects-table tbody .clickable-row:hover td { background: var(--hover); }
.td-task-detail {
  font-size: 11.5px;
  color: var(--text-3);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 220px;
}
.td-actions { display: flex; gap: 4px; align-items: center; }

/* ── Drag-to-reorder ───────────────────────────────────────────────────── */
.td-drag {
  width: 28px;
  min-width: 28px;
  padding: 0 6px !important;
  text-align: center;
}
.drag-handle {
  display: inline-block;
  color: var(--text-3);
  font-size: 14px;
  opacity: 0;
  cursor: grab;
  line-height: 1;
  transition: opacity 0.1s;
}
.tasks-table tr:hover .drag-handle { opacity: 0.5; }
.tasks-table tr.dragging { opacity: 0.35; }
.tasks-table tr.drag-over-top td    { border-top: 2px solid var(--accent) !important; }
.tasks-table tr.drag-over-bottom td { border-bottom: 2px solid var(--accent) !important; }

.status-select {
  background: var(--raise);
  border: 1px solid var(--border);
  color: var(--text-2);
  font-size: 12px;
  border-radius: 4px;
  padding: 3px 6px;
  cursor: pointer;
  outline: none;
  font-family: inherit;
}
.status-select:focus { border-color: var(--accent); }

/* ── Badges ──────────────────────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 500;
  white-space: nowrap;
}
.badge-priority-critical { background: var(--bad-bg);  color: var(--bad); }
.badge-priority-high     { background: var(--warn-bg); color: var(--warn); }
.badge-priority-medium   { background: var(--accent-bg); color: var(--accent); }
.badge-priority-low      { background: var(--ok-bg);   color: var(--ok); }

.badge-status-todo        { background: var(--raise);    color: var(--text-2); }
.badge-status-in-progress { background: var(--accent-bg); color: var(--accent); }
.badge-status-done        { background: var(--ok-bg);    color: var(--ok); }
.badge-status-blocked     { background: var(--bad-bg);   color: var(--bad); }
.badge-status-deferred    { background: var(--warn-bg);  color: var(--warn); }

.cat-dot {
  display: inline-block;
  width: 8px; height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

/* ── Manage Grids ────────────────────────────────────────────────────────── */
.manage-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; }
.manage-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.manage-card-name {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13.5px;
  font-weight: 500;
  color: var(--text);
}
.color-dot { width: 12px; height: 12px; border-radius: 50%; flex-shrink: 0; }

/* ── Modal ───────────────────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(15,15,20,0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  backdrop-filter: blur(2px);
  animation: fade-in 0.15s ease;
}
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }

.modal {
  background: var(--surface);
  border: 1px solid var(--border-2);
  border-radius: 14px;
  width: 800px;
  max-width: 96vw;
  max-height: 92vh;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow);
  animation: slide-up 0.18s ease;
}
.modal-sm { width: 380px; max-width: 95vw; }

/* Two-column modal body layout */
.modal-cols {
  display: flex;
  gap: 20px;
  align-items: flex-start;
}
.modal-col-main {
  flex: 1.5;
  min-width: 0;
}
.modal-col-side {
  flex: 1;
  min-width: 180px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
/* On narrow viewports stack the two columns vertically */
@media (max-width: 640px) {
  .modal-cols { flex-direction: column; }
  .modal-col-side { min-width: 0; }
}
@keyframes slide-up { from { transform: translateY(20px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 22px 14px;
  border-bottom: 1px solid var(--border);
}
.modal-header h2 { font-size: 16.5px; font-weight: 600; letter-spacing: -0.01em; }
.modal-body { padding: 18px 22px; overflow-y: auto; flex: 1; }
.modal-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 22px;
  border-top: 1px solid var(--border);
}

/* ── Forms ───────────────────────────────────────────────────────────────── */
.form-row { display: flex; gap: 14px; margin-bottom: 15px; }
.form-group { display: flex; flex-direction: column; gap: 6px; flex: 1; }
.form-group.full { flex: none; width: 100%; }
.form-group label { font-size: 11px; font-weight: 600; color: var(--text-3); text-transform: uppercase; letter-spacing: 0.05em; }

.form-group input,
.form-group select,
.form-group textarea {
  background: var(--surface-2);
  border: 1px solid var(--border-2);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 14px;
  padding: 9px 12px;
  outline: none;
  transition: border-color 0.15s;
  font-family: inherit;
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus { border-color: var(--accent); }
.form-group input::placeholder,
.form-group textarea::placeholder { color: var(--text-3); }
.form-group textarea { resize: vertical; min-height: 70px; }

.required-star  { color: var(--bad);    margin-left: 2px; }
.label-optional { color: var(--text-3); font-weight: 400; font-size: 12px; }

.field-hint {
  font-size: 11px;
  color: var(--text-3);
  margin-top: 2px;
}
.field-hint a { color: var(--accent); text-decoration: none; }
.field-hint a:hover { text-decoration: underline; }

/* ── Quill Rich Text Editor — themed via the same tokens ─────────────────── */
.ql-toolbar.ql-snow {
  background: var(--surface-2);
  border: 1px solid var(--border-2) !important;
  border-bottom: 1px solid var(--border) !important;
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
  padding: 6px 8px;
}
.ql-container.ql-snow {
  background: var(--surface-2);
  border: 1px solid var(--border-2) !important;
  border-top: none !important;
  border-radius: 0 0 var(--radius-sm) var(--radius-sm);
  font-family: inherit;
  font-size: 14px;
}
.ql-container.ql-snow:focus-within {
  border-color: var(--accent) !important;
}
.ql-editor {
  min-height: 200px;
  max-height: 340px;
  color: var(--text);
  line-height: 1.6;
}
.ql-editor.ql-blank::before {
  color: var(--text-3);
  font-style: normal;
}
/* Toolbar icons */
.ql-snow .ql-stroke           { stroke: var(--text-2) !important; }
.ql-snow .ql-fill             { fill:   var(--text-2) !important; }
.ql-snow .ql-picker            { color:  var(--text-2) !important; }
.ql-snow.ql-toolbar button:hover .ql-stroke,
.ql-snow.ql-toolbar button.ql-active .ql-stroke { stroke: var(--accent) !important; }
.ql-snow.ql-toolbar button:hover .ql-fill,
.ql-snow.ql-toolbar button.ql-active .ql-fill   { fill:   var(--accent) !important; }
.ql-snow.ql-toolbar button:hover,
.ql-snow.ql-toolbar button.ql-active            { color:  var(--accent) !important; }
/* Dropdown picker options */
.ql-snow .ql-picker-options {
  background: var(--surface-2);
  border-color: var(--border-2) !important;
  border-radius: var(--radius-sm);
}
/* Code blocks */
.ql-editor pre.ql-syntax {
  background: var(--bg);
  color: var(--info);
  border-radius: var(--radius-sm);
  font-size: 12px;
  padding: 10px 14px;
  font-family: var(--font-mono);
}
/* Lists */
.ql-editor ul, .ql-editor ol { padding-left: 1.5em; }
/* Links */
.ql-editor a { color: var(--accent); }

/* ── Rendered rich-text in task views ───────────────────────────────────── */
/* Used when displaying Quill HTML in the focus card & detail panels */
.ql-rendered {
  font-size: 13px;
  color: var(--text-2);
  line-height: 1.6;
}
.ql-rendered p            { margin: 0 0 4px; }
.ql-rendered strong       { color: var(--text); }
.ql-rendered ul,
.ql-rendered ol           { padding-left: 1.4em; margin: 4px 0; }
.ql-rendered pre          { background: var(--bg); color: var(--info); border-radius: 4px; padding: 6px 10px; font-size: 12px; margin: 4px 0; font-family: var(--font-mono); }
.ql-rendered code         { background: var(--bg); color: var(--info); padding: 1px 5px; border-radius: 3px; font-size: 12px; font-family: var(--font-mono); }
.ql-rendered a            { color: var(--accent); }

/* ── Timeline View ───────────────────────────────────────────────────────── */
.tl-toolbar {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 10px 0 18px;
  flex-wrap: wrap;
}

/* Navigation buttons */
.tl-nav-group { display: flex; gap: 6px; }

/* Info message (e.g. "X tasks have no dates") */
.tl-info-msg {
  font-size: 12px;
  color: var(--text-3);
  background: var(--raise);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 5px 10px;
}

/* The div vis-timeline renders into */
.tl-container {
  border-radius: var(--radius);
  overflow-x: auto;
  min-height: 420px;
}

/* ── vis-timeline theme overrides ─────────────────────────────────────────── */
.vis-timeline {
  border: 1px solid var(--border-2) !important;
  background: var(--surface) !important;
  font-family: inherit !important;
  font-size: 13px;
  border-radius: var(--radius);
}
.vis-panel { border-color: var(--border) !important; }
.vis-panel.vis-center,
.vis-panel.vis-left,
.vis-panel.vis-right,
.vis-panel.vis-top,
.vis-panel.vis-bottom { border-color: var(--border-2) !important; }
.vis-labelset .vis-label {
  background: var(--surface-2) !important;
  border-bottom: 1px solid var(--border) !important;
  border-right:  1px solid var(--border-2) !important;
  color: var(--text-2) !important;
}
.vis-labelset .vis-label:nth-child(even) { background: var(--surface) !important; }
/* Applied via the group's own className field (vis-timeline strips
   class/style attributes embedded inside a content HTML string, so
   this can't be set through `content` — see timeline.js). */
.vis-label.tl-group-project .vis-inner {
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.vis-panel.vis-center .vis-content { background: var(--surface) !important; }
.vis-time-axis .vis-text            { color: var(--text-3) !important; }
.vis-time-axis .vis-text.vis-major  { color: var(--text-2) !important; font-weight: 600; }
.vis-time-axis .vis-grid.vis-minor  { border-color: var(--border) !important; }
.vis-time-axis .vis-grid.vis-major  { border-color: var(--border-2) !important; }
.vis-current-time { background: var(--accent) !important; width: 2px !important; opacity: 0.8; }
.vis-item {
  border-radius: 4px !important;
  font-size: 12px !important;
  font-family: inherit !important;
  border-width: 1px !important;
  cursor: pointer !important;
  padding: 2px 6px !important;
}
.vis-item .vis-item-content { padding: 0 !important; }

/* Project bars carry their own project color via inline style; open-ended
   projects (no end date set) render dashed to read as "still ongoing". */
.vis-item.tl-project-ongoing { border-style: dashed !important; }
.vis-item.vis-selected { box-shadow: 0 0 0 2px var(--accent) !important; z-index: 2; }
.vis-tooltip {
  background: var(--surface) !important;
  border: 1px solid var(--border-2) !important;
  color: var(--text) !important;
  border-radius: var(--radius-sm) !important;
  padding: 8px 12px !important;
  font-size: 12px !important;
  font-family: inherit !important;
  line-height: 1.5;
  box-shadow: var(--shadow-sm) !important;
}

/* ── Quick Add Bar ───────────────────────────────────────────────────────── */
.quick-add-bar {
  position: fixed;
  /* Keep clear of the iOS home-indicator area in standalone PWA mode, and of
     the mobile bottom nav where present. */
  bottom: calc(24px + env(safe-area-inset-bottom));
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--surface);
  border: 1px solid var(--border-2);
  border-radius: 40px;
  padding: 10px 14px 10px 20px;
  box-shadow: var(--shadow);
  z-index: 500;
  width: 500px;
  max-width: 90vw;
  animation: slide-up 0.18s ease;
}
.quick-add-bar input {
  flex: 1;
  background: none;
  border: none;
  outline: none;
  color: var(--text);
  font-size: 14px;
  font-family: inherit;
}
.quick-add-bar input::placeholder { color: var(--text-3); }

/* ── Empty States ────────────────────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 56px 20px;
  color: var(--text-3);
}
.empty-icon { font-size: 44px; margin-bottom: 14px; }
.empty-state h3 { font-size: 17px; font-weight: 600; color: var(--text-2); margin-bottom: 8px; }
.empty-state p { font-size: 13.5px; margin-bottom: 18px; }
.empty-state-sm { padding: 18px 18px; font-size: 13px; color: var(--text-3); }

/* ── Scrollbar ───────────────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-2); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-3); }

/* ── Utility ─────────────────────────────────────────────────────────────── */
.overdue-date { color: var(--bad) !important; font-weight: 600; }
.text-muted { color: var(--text-3); }
.flex-center { display: flex; align-items: center; gap: 6px; }
.text-sm  { font-size: 12px; }
.text-xs  { font-size: 11px; }
.text-danger { color: var(--bad); }
.btn-icon--danger { color: var(--bad); }
.btn-icon--danger:hover { color: var(--bad); filter: brightness(1.15); }

/* Dashboard focus-card badges */
.badge-cat  { background: var(--raise); color: var(--text-3); }
.badge-proj { background: var(--accent-bg); color: var(--info); }
.badge-date { background: transparent; color: var(--text-3); }
.badge-overdue { background: transparent; color: var(--bad); }

/* ── Loading Overlay ─────────────────────────────────────────────────────── */
.loading-overlay {
  position: absolute; inset: 0; background: var(--bg);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  z-index: 999; gap: 16px;
}
.loading-spinner {
  position: relative;
  width: 64px; height: 64px;
}
/* The rotating comet-trail ring lives on ::before so the T mark below
   (a real child element) can sit still at the center, not spin with it. */
.loading-spinner::before {
  content: "";
  position: absolute; inset: 0;
  border-radius: 50%;
  background: conic-gradient(from 0deg, transparent, var(--accent));
  -webkit-mask: radial-gradient(farthest-side, transparent calc(100% - 4px), #000 calc(100% - 4px));
          mask: radial-gradient(farthest-side, transparent calc(100% - 4px), #000 calc(100% - 4px));
  animation: spin 1.1s linear infinite;
}
.loading-spinner-mark {
  position: absolute; inset: 16px;
  border-radius: 7px;
  background: #FFFFFF;
  border: 1px solid #DEDEE3;
  color: #1B1B1F;
  font-size: 18px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
}
@keyframes spin { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }

/* ── Toast ───────────────────────────────────────────────────────────────── */
.toast {
  position: fixed;
  bottom: calc(28px + env(safe-area-inset-bottom));
  right: calc(28px + env(safe-area-inset-right));
  background: var(--surface); border: 1px solid var(--border-2);
  border-radius: var(--radius-sm); padding: 11px 18px;
  font-size: 13.5px; color: var(--text); box-shadow: var(--shadow);
  z-index: 2000; animation: slide-up 0.2s ease;
}
.toast-success { border-color: color-mix(in srgb, var(--ok) 40%, var(--border-2)); color: var(--ok); }
.toast-error   { border-color: color-mix(in srgb, var(--bad) 40%, var(--border-2)); color: var(--bad); }

/* ── Scope Toggle (segmented control — task context, habits sub-view,
     theme) ─────────────────────────────────────────────────────────────── */
.scope-toggle {
  display: flex;
  background: var(--raise);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 2px;
  gap: 2px;
}
.scope-btn {
  background: transparent;
  border: none;
  border-radius: 4px;
  color: var(--text-3);
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  padding: 5px 14px;
  transition: background 0.15s, color 0.15s;
  white-space: nowrap;
  font-family: inherit;
}
.scope-btn:hover  { color: var(--text); background: var(--hover); }
.scope-btn.active { background: var(--accent); color: #fff; }

/* ── view-actions flex helpers ───────────────────────────────────────────── */
.view-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

/* ── Category Add Panel ──────────────────────────────────────────────────── */
.cat-add-panel {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  background: var(--surface);
  border: 1px solid var(--border-2);
  border-radius: var(--radius);
  padding: 14px 18px;
  margin-bottom: 18px;
  animation: slide-up 0.15s ease;
}
.cat-add-panel input[type="text"] {
  background: var(--surface-2);
  border: 1px solid var(--border-2);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 14px;
  padding: 8px 12px;
  outline: none;
  flex: 1;
  min-width: 160px;
  font-family: inherit;
}
.cat-add-panel input[type="text"]:focus { border-color: var(--accent); }
.cat-color-wrap { display: flex; align-items: center; gap: 8px; }
.cat-color-label { font-size: 12px; color: var(--text-3); white-space: nowrap; }
.cat-add-panel input[type="color"] {
  width: 36px; height: 36px;
  border: 1px solid var(--border-2);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  cursor: pointer;
  padding: 2px;
}
.cat-error { font-size: 12px; color: var(--bad); margin-left: 4px; }

/* ── Multiselect Dropdown ────────────────────────────────────────────────── */
.ms-wrap {
  position: relative;
  display: inline-block;
}
.ms-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-2);
  font-size: 13px;
  padding: 6px 10px;
  outline: none;
  cursor: pointer;
  white-space: nowrap;
  transition: border-color 0.15s, color 0.15s;
  font-family: inherit;
}
.ms-btn:hover       { border-color: var(--border-2); color: var(--text); }
.ms-btn.ms-active   { border-color: var(--accent); color: var(--accent); background: var(--accent-bg); }
.ms-caret           { font-size: 10px; color: var(--text-3); }
.ms-panel {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  min-width: 180px;
  background: var(--surface);
  border: 1px solid var(--border-2);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
  z-index: 500;
  padding: 6px 0;
  animation: slide-up 0.12s ease;
}
.ms-opt {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 14px;
  font-size: 13px;
  color: var(--text-2);
  cursor: pointer;
  user-select: none;
  transition: background 0.1s;
}
.ms-opt:hover { background: var(--hover); color: var(--text); }
.ms-opt input[type="checkbox"] {
  accent-color: var(--accent);
  width: 14px;
  height: 14px;
  flex-shrink: 0;
  cursor: pointer;
}

/* ── Filter bar "Clear all" button ──────────────────────────────────────── */
.filter-clear-all-btn {
  color: var(--bad);
  border-color: transparent;
  white-space: nowrap;
  align-self: center;
}
.filter-clear-all-btn:hover {
  background: var(--bad-bg);
  border-color: var(--bad);
  color: var(--bad);
}

/* ── Mobile filter toggle button badge ───────────────────────────────────── */
#mobile-filter-btn { position: relative; }
.mobile-filter-badge {
  position: absolute; top: 2px; right: 2px;
  min-width: 16px; height: 16px;
  background: var(--accent); color: #fff;
  border-radius: 8px; font-size: 9px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  padding: 0 3px; pointer-events: none;
}

/* ── Projects list (table view) ──────────────────────────────────────────── */
.proj-filter-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 0 16px;
  flex-wrap: wrap;
}
.proj-done-notice {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--warn);
  background: var(--warn-bg);
  border: 1px solid color-mix(in srgb, var(--warn) 35%, transparent);
  border-radius: 20px;
  padding: 4px 12px;
}
.proj-done-icon { font-size: 13px; }
.link-btn {
  background: none;
  border: none;
  color: var(--warn);
  text-decoration: underline;
  cursor: pointer;
  font-size: inherit;
  padding: 0;
  font-family: inherit;
}
.link-btn:hover { color: var(--text); }

/* Projects table (inside #projects-table-wrap) */
.projects-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
}
.projects-table th {
  background: var(--surface-2);
  color: var(--text-3);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 11px 14px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  user-select: none;
}
.projects-table th.sortable { cursor: pointer; }
.projects-table th.sortable:hover { color: var(--text-2); background: var(--hover); }
.projects-table th.sort-asc  .sort-arrow::after { content: ' ↑'; }
.projects-table th.sort-desc .sort-arrow::after { content: ' ↓'; }
.projects-table td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
  color: var(--text-2);
}
.projects-table tr:last-child td { border-bottom: none; }
.projects-table tr:hover td { background: var(--hover); }
.projects-table tr.proj-done-row td { opacity: 0.55; }

.proj-status-badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 500;
  white-space: nowrap;
}
.proj-status-not-started { background: var(--raise);    color: var(--text-2); }
.proj-status-in-progress { background: var(--accent-bg); color: var(--accent); }
.proj-status-done        { background: var(--ok-bg);    color: var(--ok); }

.proj-priority-badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 500;
  white-space: nowrap;
}
.proj-priority-high   { background: var(--warn-bg); color: var(--warn); }
.proj-priority-medium { background: var(--accent-bg); color: var(--accent); }
.proj-priority-low    { background: var(--ok-bg);   color: var(--ok); }

/* ── Form helpers for modal ──────────────────────────────────────────────── */
.form-row.two-col   { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-row.three-col { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 14px; }
.field-hint-inline { font-size: 11px; color: var(--text-3); font-weight: 400; text-transform: none; letter-spacing: 0; }

/* ── Task modal enhancements ─────────────────────────────────────────────── */
@keyframes taskModalScaleIn {
  from { opacity: 0; transform: scale(0.97) translateY(-8px); }
  to   { opacity: 1; transform: scale(1)    translateY(0);     }
}
.modal-task { animation: taskModalScaleIn 0.18s ease; }

.modal-header-left { display: flex; align-items: center; gap: 10px; }
.modal-task-icon { font-size: 17px; }

.f-task-input { font-size: 15.5px !important; font-weight: 500; padding: 10px 12px !important; }

.char-count { font-size: 11px; color: var(--text-3); float: right; margin-top: 3px; }

.attachments-area {
  margin-top: 14px;
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 20px;
  text-align: center;
  color: var(--text-3);
  background: var(--surface-2);
  font-size: 13px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}
.attachments-icon { font-size: 22px; margin-bottom: 4px; }
.attachments-text { color: var(--text-2); font-weight: 500; }
.attachments-hint { font-size: 11px; color: var(--text-3); }

/* Labels / tags chip input */
.labels-wrap {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  padding: 4px 8px;
  min-height: 36px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px;
}
.labels-input {
  border: none !important;
  background: transparent !important;
  color: var(--text-2);
  font-size: 13px;
  outline: none;
  min-width: 120px;
  flex: 1;
  padding: 2px 0 !important;
  font-family: inherit;
}
.label-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: var(--accent-bg);
  color: var(--accent);
  border-radius: 4px;
  padding: 2px 7px;
  font-size: 12px;
  font-weight: 500;
}
.label-chip-remove {
  background: none;
  border: none;
  color: var(--accent);
  cursor: pointer;
  font-size: 13px;
  padding: 0;
  line-height: 1;
  opacity: 0.7;
}
.label-chip-remove:hover { opacity: 1; }

.modal-shortcut-hint { font-size: 11px; color: var(--text-3); white-space: nowrap; }
.modal-footer-actions { display: flex; gap: 10px; }

/* ── Notification Bell ───────────────────────────────────────────────────── */
.notif-wrap { position: relative; display: inline-flex; }

.notif-bell {
  position: relative;
  font-size: 17px;
  width: 34px;
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.notif-badge {
  position: absolute;
  top: 2px;
  right: 2px;
  min-width: 18px;
  height: 18px;
  background: var(--bad);
  color: #fff;
  border-radius: 9px;
  font-size: 10px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
  border: 2px solid var(--surface);
  pointer-events: none;
}

.notif-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  width: 320px;
  max-height: 440px;
  background: var(--surface);
  border: 1px solid var(--border-2);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  z-index: 700;
  flex-direction: column;
  overflow: hidden;
}

.notif-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.notif-title { font-size: 13.5px; font-weight: 600; color: var(--text); }

.notif-list { overflow-y: auto; flex: 1; }
.notif-empty { padding: 24px 16px; text-align: center; color: var(--text-3); font-size: 13px; }

.notif-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background 0.12s;
}
.notif-item:last-child { border-bottom: none; }
.notif-item:hover { background: var(--hover); }
.notif-item.notif-read { opacity: 0.6; }

.notif-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--border-2);
  flex-shrink: 0;
  margin-top: 5px;
}
.notif-dot.unread { background: var(--accent); }

.notif-content { flex: 1; min-width: 0; }
.notif-message { font-size: 13px; color: var(--text); line-height: 1.45; }
.notif-time    { font-size: 11px; color: var(--text-3); margin-top: 3px; }

/* ── Mobile Sidebar Overlay ──────────────────────────────────────────────── */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  z-index: 199;
  cursor: pointer;
}
.sidebar-overlay.active { display: block; }

/* ── Mobile Bottom Navigation ─────────────────────────────────────────────
   Hidden on desktop; replaces the sidebar as the primary nav surface below
   860px. Only ever shows shipped surfaces — "More" reopens the full
   sidebar as a slide-in panel rather than duplicating every item here. ── */
.bottom-nav { display: none; }

/* Matches the sidebar's own mobile breakpoint (768px, used throughout this
   file) — the bottom nav only makes sense once the sidebar goes off-canvas,
   never alongside it. */
@media (max-width: 768px) {
  .bottom-nav {
    display: block;
    position: fixed;
    bottom: 0; left: 0; right: 0;
    background: var(--surface);
    border-top: 1px solid var(--border);
    z-index: 60;
    padding-bottom: env(safe-area-inset-bottom);
  }
  .bottom-nav-row { display: grid; grid-template-columns: repeat(5, 1fr); }
  .bn-item {
    display: flex; flex-direction: column; align-items: center; gap: 2px;
    padding: 8px 2px 9px;
    cursor: pointer; color: var(--text-3);
    transition: color 0.11s;
    text-decoration: none;
    background: none; border: none; font-family: inherit;
  }
  .bn-item.active { color: var(--accent); }
  .bn-glyph { font-size: 17px; line-height: 1; }
  .bn-label { font-size: 9.5px; font-weight: 500; }
  .bn-item.mid .bn-glyph {
    width: 28px; height: 28px; border-radius: 8px;
    background: var(--accent); color: #fff;
    display: grid; place-items: center; font-size: 17px; margin-bottom: 1px;
  }
  .bn-item.mid { color: var(--text-3); }

  /* Clear the bottom nav's own height (~58px) plus its safe-area padding —
     otherwise the quick-add bar opened from "+ Add" sits on top of it. */
  .quick-add-bar { bottom: calc(82px + env(safe-area-inset-bottom)); }
}

/* ── Responsive: stack dashboard sections on narrow viewports ────────────── */
@media (max-width: 768px) {
  .modal-shortcut-hint { display: none; }
}

/* ── Mobile Responsive Layout ────────────────────────────────────────────── */
@media (max-width: 768px) {
  /* Allow the body to scroll naturally on mobile */
  body { overflow-y: auto; }

  .app {
    height: auto;
    min-height: 100dvh;
    overflow: visible;
  }

  /* Sidebar becomes a fixed overlay that slides in from the left */
  .sidebar {
    position: fixed !important;
    top: 0;
    left: 0;
    height: 100vh;
    z-index: 200;
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    /* Override the desktop width:0 collapse */
    width: var(--sidebar-w) !important;
    min-width: var(--sidebar-w) !important;
    border-right: 1px solid var(--border) !important;
    overflow-y: auto;
  }
  /* Desktop .collapsed class must not hide the sidebar on mobile — transform handles it */
  .sidebar.collapsed {
    width: var(--sidebar-w) !important;
    min-width: var(--sidebar-w) !important;
  }
  .sidebar.mobile-open {
    transform: translateX(0);
    box-shadow: var(--shadow);
  }

  /* Main content fills the full viewport width */
  .main {
    width: 100%;
    overflow: visible;
    height: auto;
  }

  /* Views scroll as part of the normal page flow; leave room for the
     bottom nav + the fixed quick-add bar sitting above it */
  .view {
    overflow-x: clip;   /* clip horizontal overflow without creating a scroll context */
    overflow-y: visible;
    height: auto;
    padding: 16px 14px 130px;
    max-width: 100%;
  }

  /* Topbar tighter on mobile */
  .topbar {
    padding: calc(10px + env(safe-area-inset-top)) 14px 10px;
    gap: 8px;
    min-height: 52px;
    position: sticky;
    top: 0;
    z-index: 100;
  }
  .topbar-right { gap: 6px; }
  #btn-add-task { padding: 0 12px; font-size: 13px; }

  /* View header stacks vertically */
  .view-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
    margin-bottom: 16px;
  }
  .view-title { font-size: 19px; }
  .view-actions { flex-wrap: wrap; gap: 8px; }

  /* Stats grid: 2 columns */
  .stats-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; margin-bottom: 20px; }
  .stat-value { font-size: 23px; }

  /* Dashboard columns stack */
  .dashboard-body { grid-template-columns: 1fr; gap: 14px; }
  .dash-col { min-width: 0; }

  /* Tasks table scrolls horizontally */
  .table-wrap { -webkit-overflow-scrolling: touch; }
  .tasks-table { min-width: 680px; }

  /* Manage grid single column */
  .manage-grid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); }

  /* Notification dropdown: position fixed against viewport so it can't overflow left */
  .notif-dropdown {
    position: fixed;
    top: 52px;    /* mobile topbar min-height */
    right: 14px;  /* matches topbar side padding */
    left: auto;
    width: min(320px, calc(100dvw - 28px));
  }

  /* Mobile filter panel drops below the sticky topbar */
  /* Note: topbar must keep overflow:visible (default) so absolute child can escape */
  #filter-wrap {
    position: absolute;
    top: 100%;
    left: 0; right: 0;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: 10px 14px;
    gap: 8px;
    flex-wrap: wrap;
    z-index: 99;
    box-shadow: var(--shadow-sm);
  }
  #filter-wrap .filter-clear-all-btn { margin-left: auto; }

  /* Timeline toolbar wraps */
  .tl-toolbar { gap: 8px; }
  .tl-nav-group { flex-wrap: wrap; gap: 4px; }

  /* Scope toggle smaller text */
  .scope-btn { padding: 4px 10px; font-size: 12px; }

  /* Filter bar wraps cleanly */
  .topbar-filters { flex-wrap: wrap; gap: 6px; }
  .topbar-search  { max-width: 100%; }
}

/* Modal: slide up from bottom as a sheet on small phones */
@media (max-width: 540px) {
  .modal-overlay { align-items: flex-end; padding: 0; }
  .modal {
    width: 100% !important;
    max-width: 100% !important;
    max-height: 92vh !important;
    border-radius: 18px 18px 0 0;
  }
  .modal-sm {
    width: 100% !important;
    max-width: 100% !important;
  }
  /* Inline category add panel stacks */
  .cat-add-panel { flex-direction: column; align-items: flex-start; }
  /* Two-column form rows stack on small phones */
  .form-row.two-col   { grid-template-columns: 1fr; }
  .form-row.three-col { grid-template-columns: 1fr; }
}

/* Minimum touch target size across all interactive elements */
@media (max-width: 768px) {
  .btn, .btn-icon, .nav-item, .scope-btn, .ms-btn, .auth-tab {
    min-height: 40px;
  }
  .nav-item { padding: 11px 10px; font-size: 15px; }
}

/* Extra-small phones (≤480px) */
@media (max-width: 480px) {
  .stat-value { font-size: 20px; }
  .stat-card { padding: 13px 10px; }
  .task-item { padding: 9px 12px; }
  .dash-card-header { padding: 11px 14px 7px; }
  .view-title { font-size: 18px; }
}

/* ── Done tasks toggle button ─────────────────────────────────────────────── */
.tasks-done-toggle {
  font-size: 12px;
  opacity: 0.65;
  transition: opacity 0.15s;
  padding: 3px 10px;
}
.tasks-done-toggle:hover { opacity: 1; }

/* ── Collapsible section groups (used by the Habits "Archived" section) ──── */
.section-group {
  margin-bottom: 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--surface);
}
.section-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 16px;
  background: var(--surface-2);
  cursor: pointer;
  user-select: none;
  transition: background 0.15s;
  flex-wrap: nowrap;
}
.section-header:hover { background: var(--hover); }
.section-caret { font-size: 10px; color: var(--text-3); flex-shrink: 0; width: 10px; }
.section-title { font-size: 13px; font-weight: 600; color: var(--text); white-space: nowrap; }
.section-subtitle { font-size: 11px; color: var(--text-3); white-space: nowrap; }
.section-count {
  margin-left: auto;
  font-size: 11px;
  font-weight: 600;
  background: var(--hover);
  color: var(--text-3);
  padding: 2px 8px;
  border-radius: 20px;
  white-space: nowrap;
  flex-shrink: 0;
}
.section-table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.section-body .tasks-table { border-radius: 0; }

@media (max-width: 768px) {
  .section-header { gap: 7px; padding: 10px 12px; }
  .section-title  { font-size: 12px; }
  .section-subtitle { display: none; }
  .section-table-wrap .tasks-table { min-width: 680px; }
}

/* ════════════════════════════════════════════════════════════════════════
   HABITS
   ════════════════════════════════════════════════════════════════════════ */

/* ── Today: progress ring header ─────────────────────────────────────────── */
.habit-today-header {
  display: flex;
  align-items: center;
  gap: 18px;
  margin-bottom: 20px;
  padding: 15px 17px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.progress-ring {
  width: 68px; height: 68px;
  border-radius: 50%;
  background: conic-gradient(var(--accent) calc(var(--pct, 0) * 1%), var(--raise) 0);
  display: grid; place-items: center;
  flex-shrink: 0;
  transition: background 0.4s ease;
}
.progress-ring-inner {
  width: 53px; height: 53px;
  border-radius: 50%;
  background: var(--surface);
  display: grid; place-items: center;
  font-weight: 700; font-size: 14px; color: var(--text);
  font-variant-numeric: tabular-nums;
}
.habit-today-title { font-size: 15px; font-weight: 600; color: var(--text); letter-spacing: -0.01em; }
.habit-today-sub   { font-size: 12.5px; color: var(--text-3); margin-top: 3px; }

/* ── Today: habit cards ──────────────────────────────────────────────────── */
.habit-list { display: flex; flex-direction: column; gap: 10px; }
.habit-card {
  display: flex; align-items: center; gap: 14px;
  padding: 12px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  transition: border-color 0.15s;
}
.habit-card:hover { border-color: var(--border-2); }
.habit-card.habit-done { opacity: 0.72; }
.habit-check {
  width: 40px; height: 40px; flex-shrink: 0;
  border-radius: 50%;
  border: 2px solid var(--habit-color, var(--accent));
  background: transparent;
  color: var(--habit-color, var(--accent));
  font-size: 16px; font-weight: 700;
  cursor: pointer; display: grid; place-items: center;
  transition: transform 0.12s, background 0.12s;
}
.habit-check:hover { transform: scale(1.08); }
.habit-check.checked { background: var(--habit-color, var(--accent)); color: #fff; animation: habit-pop 0.28s ease; }
@keyframes habit-pop { 0% { transform: scale(1); } 40% { transform: scale(1.25); } 100% { transform: scale(1); } }
.habit-card-body { flex: 1; min-width: 0; }
.habit-card-name { font-weight: 600; color: var(--text); font-size: 14px; }
.habit-card-cue  { font-size: 12px; color: var(--text-3); margin-top: 2px; font-style: italic;
                   overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.habit-progress {
  margin-top: 7px; height: 5px; border-radius: 4px;
  background: var(--raise); overflow: hidden;
}
.habit-progress-bar { height: 100%; border-radius: 4px; transition: width 0.25s ease; }
.habit-progress-label { font-size: 11px; color: var(--text-3); margin-top: 3px; }
.habit-streak { font-size: 13.5px; font-weight: 600; color: var(--text-2); white-space: nowrap; flex-shrink: 0; font-variant-numeric: tabular-nums; }
.habit-streak-zero { color: var(--text-3); font-weight: 400; }

/* ── Empty state with starter habits ─────────────────────────────────────── */
.habit-empty { text-align: center; padding: 48px 20px; }
.habit-empty-icon { font-size: 42px; margin-bottom: 8px; }
.habit-empty h3 { font-size: 17px; margin-bottom: 6px; }
.habit-empty p  { color: var(--text-3); margin-bottom: 20px; }
.starter-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 10px; max-width: 460px; margin: 0 auto 20px;
}
.starter-btn {
  display: flex; align-items: center; gap: 8px; justify-content: center;
  padding: 12px 14px;
  background: var(--surface); border: 1px solid var(--border-2); border-radius: var(--radius);
  color: var(--text-2); font-size: 14px; cursor: pointer; transition: all 0.15s;
}
.starter-btn:hover { border-color: var(--accent); color: var(--text); background: var(--hover); }
.starter-icon { font-size: 18px; }

/* ── All habits: rows + drag ─────────────────────────────────────────────── */
.habit-all-list { display: flex; flex-direction: column; gap: 8px; }
.habit-row {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 14px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
}
.habit-row.dragging { opacity: 0.4; }
.habit-row.drag-over-top    { border-top: 2px solid var(--accent); }
.habit-row.drag-over-bottom { border-bottom: 2px solid var(--accent); }
.habit-row-handle { color: var(--text-3); cursor: grab; opacity: 0.4; font-size: 15px; flex-shrink: 0; }
.habit-row:hover .habit-row-handle { opacity: 0.8; }
.habit-row-icon {
  width: 34px; height: 34px; border-radius: 9px; flex-shrink: 0;
  display: grid; place-items: center; font-size: 17px;
}
.habit-row-body { flex: 1; min-width: 0; }
.habit-row-name { font-weight: 600; color: var(--text); font-size: 14px; }
.habit-row-meta { font-size: 12px; color: var(--text-3); margin-top: 2px;
                  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.habit-row-cue  { font-style: italic; }
.habit-row-streak, .habit-row-best { font-size: 13px; font-weight: 600; color: var(--text-2); white-space: nowrap; flex-shrink: 0; font-variant-numeric: tabular-nums; }
.habit-row-best  { color: var(--text-3); }
.habit-row-actions { display: flex; gap: 4px; flex-shrink: 0; }
.habit-dates { font-size: 12px; color: var(--text-3); margin-top: 2px; white-space: nowrap; }
.habit-deadline-passed { color: var(--bad); }
.habit-archived { margin-top: 22px; }
.habit-section-title { font-size: 11px; font-weight: 600; color: var(--text-3);
                       text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 8px; }
.habit-row-archived { opacity: 0.6; }

/* ── Stats: metrics, heatmap, badges ─────────────────────────────────────── */
.habit-stats-section .section-body { padding: 14px 14px 0; }
.habit-stats-card { margin-bottom: 16px; }
.habit-stats-streak { font-size: 13.5px; font-weight: 600; color: var(--text-2); }
.habit-stats-body { padding: 16px 18px; }
.habit-metrics { display: flex; gap: 10px; margin-bottom: 16px; flex-wrap: wrap; }
.habit-metric {
  flex: 1; min-width: 64px; text-align: center;
  background: var(--raise); border-radius: var(--radius-sm); padding: 10px 6px;
}
.habit-metric-val { font-size: 19px; font-weight: 600; color: var(--text); font-variant-numeric: tabular-nums; }
.habit-metric-lbl { font-size: 11px; color: var(--text-3); margin-top: 2px; }

/* GitHub-style contribution graph: day labels + month labels + intensity shades */
.habit-stats-body { --hm-empty: var(--raise); }
.habit-heatmap { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 4px; -webkit-overflow-scrolling: touch; }
.hm-days {
  display: flex; flex-direction: column; gap: 3px;
  padding-top: 15px;                 /* clears the month-label row so day labels align to rows */
  font-size: 9px; color: var(--text-3); flex-shrink: 0;
  font-family: var(--font-mono);
}
.hm-days span { height: 13px; line-height: 13px; }
.hm-grid-wrap { display: flex; flex-direction: column; gap: 3px; }
.hm-months { display: flex; gap: 3px; height: 12px; }
.hm-month  { width: 13px; font-size: 9px; color: var(--text-3); white-space: nowrap; flex-shrink: 0; font-family: var(--font-mono); }
.hm-grid   { display: flex; gap: 3px; }
.hm-col    { display: flex; flex-direction: column; gap: 3px; }
.hm-cell   { width: 13px; height: 13px; border-radius: 3px; background: var(--hm-empty); flex-shrink: 0; }
.hm-empty  { background: var(--hm-empty); }
.hm-missed { background: var(--hm-empty); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--bad) 25%, transparent); }
.hm-future { background: transparent; }

.hm-legend { display: flex; align-items: center; gap: 3px; margin-top: 12px; }
.hm-legend-lbl { font-size: 10px; color: var(--text-3); margin: 0 4px; }
.hm-legend .hm-cell { width: 11px; height: 11px; }

.habit-badges { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }
.badge-chip {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 5px 10px; border-radius: 20px;
  background: var(--accent-bg); color: var(--accent);
  font-size: 12px; font-weight: 600;
}
.badge-chip.badge-locked { background: var(--raise); color: var(--text-3); }

/* ── Habit modal: weekday picker ─────────────────────────────────────────── */
.hf-icon-input { text-align: center; font-size: 20px; }
.weekday-picker { display: flex; gap: 6px; flex-wrap: wrap; }
.weekday-btn {
  width: 38px; height: 38px; border-radius: 50%;
  border: 1px solid var(--border-2); background: var(--surface-2);
  color: var(--text-3); font-size: 13px; font-weight: 600; cursor: pointer;
  transition: all 0.12s;
}
.weekday-btn.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.weekday-presets { display: flex; gap: 14px; margin-top: 8px; }

/* ── Habits: mobile ──────────────────────────────────────────────────────── */
@media (max-width: 768px) {
  .habit-today-header { gap: 14px; padding: 14px; }
  .progress-ring { width: 58px; height: 58px; }
  .progress-ring-inner { width: 44px; height: 44px; font-size: 12.5px; }
  .habit-check { width: 44px; height: 44px; }   /* comfortable touch target */
  .habit-row-best { display: none; }             /* drop secondary stat to save width */
  .habit-row-handle { display: none; }           /* drag handle is desktop-only */
  .starter-grid { grid-template-columns: 1fr; }
  .weekday-btn { width: 40px; height: 40px; }    /* touch target */
}

/* ═══════════════════════════════════════════════════════════════════════════
   Phase 1 — The Daily Loop (Today, Daily Log, Impact, Inbox, Quick Capture)
   ═══════════════════════════════════════════════════════════════════════════ */

/* ── Shared small bits ──────────────────────────────────────────────────── */
.dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; margin-right: 2px; }
.sec-title { font-size: 12px; font-weight: 600; color: var(--text-2); text-transform: uppercase; letter-spacing: 0.04em; }
.kbd {
  display: inline-block; font-family: var(--font-mono); font-size: 10.5px;
  background: var(--raise); color: var(--text-3); border: 1px solid var(--border-2);
  border-radius: 4px; padding: 1px 5px; line-height: 1.5;
}
.nav-badge {
  margin-left: auto; background: var(--accent); color: #fff;
  font-size: 10.5px; font-weight: 700; padding: 1px 6px; border-radius: 20px;
}

/* ── Today: attention band ─────────────────────────────────────────────── */
.tdy-att {
  display: flex; align-items: center; gap: 10px;
  background: var(--warn-bg); border: 1px solid color-mix(in srgb, var(--warn) 35%, var(--border));
  border-radius: var(--radius); padding: 11px 16px; margin-bottom: 16px;
  cursor: pointer; transition: background 0.12s;
}
.tdy-att:hover { background: color-mix(in srgb, var(--warn-bg) 70%, var(--hover)); }
.tdy-att-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--warn); flex-shrink: 0; }
.tdy-att-text { flex: 1; font-size: 13px; color: var(--text-2); }
.tdy-att-cta { font-size: 12.5px; font-weight: 600; color: var(--warn); flex-shrink: 0; }

/* ── Today: Work / Personal columns ────────────────────────────────────── */
.tdy-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; margin-bottom: 18px; }
@media (max-width: 900px) { .tdy-cols { grid-template-columns: 1fr; } }
.tdy-addrow { padding: 8px 16px 12px; }

/* ── Today: habit strip ─────────────────────────────────────────────────── */
.tdy-habits {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 12px 16px; margin-bottom: 18px; flex-direction: column; gap: 10px;
}
.tdy-habits-h { display: flex; align-items: center; justify-content: space-between; }
.tdy-habits-row { display: flex; flex-wrap: wrap; gap: 8px; }
.tdy-hchip {
  display: flex; align-items: center; gap: 6px;
  background: var(--surface-2); border: 1px solid var(--border-2); border-radius: 20px;
  padding: 6px 12px; font-size: 12.5px; color: var(--text-2); cursor: pointer;
  transition: background 0.12s, border-color 0.12s, color 0.12s;
}
.tdy-hchip:hover { background: var(--hover); }
.tdy-hchip.on { background: var(--ok-bg); border-color: color-mix(in srgb, var(--ok) 40%, var(--border-2)); color: var(--ok); }
.tdy-hchip-icon { font-size: 13px; }

/* ── Today: close-out prompt ────────────────────────────────────────────── */
.tdy-prompt-inner {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  background: var(--accent-bg); border: 1px solid color-mix(in srgb, var(--accent) 30%, var(--border));
  border-radius: var(--radius); padding: 16px 18px;
}
.tdy-prompt-t { font-size: 14px; font-weight: 600; color: var(--text); margin-bottom: 2px; }
.tdy-prompt-s { font-size: 12.5px; color: var(--text-3); }

/* ── Today: attention triage modal ─────────────────────────────────────── */
.modal-triage { width: 460px; max-width: 92vw; max-height: 80vh; }
.tdy-triage-row {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px;
  padding: 12px 0; border-bottom: 1px solid var(--border);
}
.tdy-triage-row:last-child { border-bottom: none; }
.tdy-triage-text { flex: 1 1 100%; font-size: 13.5px; color: var(--text); }
.tdy-triage-meta { font-size: 11.5px; color: var(--bad); flex: 1; }
.tdy-triage-actions { display: flex; gap: 6px; }

/* ── Quick Capture modal (⌘K) ───────────────────────────────────────────── */
.modal-capture {
  display: flex; align-items: center; gap: 10px;
  background: var(--surface); border: 1px solid var(--border-2);
  border-radius: 40px; padding: 8px 8px 8px 20px;
  box-shadow: var(--shadow); width: 560px; max-width: 92vw;
  animation: slide-up 0.18s ease;
}
.modal-capture input {
  flex: 1; background: none; border: none; outline: none;
  color: var(--text); font-size: 14.5px; font-family: inherit;
}
.modal-capture input::placeholder { color: var(--text-3); }

/* ── Daily Log ──────────────────────────────────────────────────────────── */
.dl-wrap { max-width: 640px; display: flex; flex-direction: column; gap: 18px; }

.dl-carry {
  background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 12px 16px;
}
.dl-carry-title { font-size: 12px; font-weight: 600; color: var(--text-3); text-transform: uppercase; letter-spacing: 0.04em; margin-bottom: 8px; }
.dl-carry-row { display: flex; gap: 10px; font-size: 13px; color: var(--text-2); padding: 3px 0; }
.dl-carry-pri { font-family: var(--font-mono); font-size: 10.5px; color: var(--text-3); min-width: 44px; }

.dl-textarea {
  width: 100%; min-height: 180px; resize: vertical;
  background: var(--surface-2); border: 1px solid var(--border-2); border-radius: var(--radius);
  padding: 14px 16px; font-size: 14px; font-family: inherit; color: var(--text); line-height: 1.55;
  outline: none;
}
.dl-textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-bg); }
.dl-textarea::placeholder { color: var(--text-3); white-space: pre-line; }
.dl-textarea-sm { min-height: 80px; margin-bottom: 14px; }

.dl-actions { display: flex; align-items: center; gap: 10px; margin-top: 12px; }
.dl-hint { font-size: 12px; color: var(--text-3); }
.dl-status { margin-top: 10px; font-size: 13px; color: var(--text-3); }

.dl-manual-hint { font-size: 12.5px; color: var(--text-3); margin-bottom: 14px; }
.dl-manual-label { display: block; font-size: 11px; font-weight: 600; color: var(--text-3); text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 6px; }

.dl-group { margin-bottom: 18px; }
.dl-group-h { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; margin-bottom: 8px; }
.dl-row {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 0; border-bottom: 1px solid var(--border); font-size: 13.5px;
}
.dl-row:last-child { border-bottom: none; }
.dl-row input[type="checkbox"] { width: 16px; height: 16px; accent-color: var(--accent); cursor: pointer; flex-shrink: 0; }
.dl-row-cat { font-size: 11px; font-weight: 600; color: var(--text-3); text-transform: uppercase; flex-shrink: 0; }
.dl-row-text { flex: 1; color: var(--text); }
.dl-row-note { font-size: 11px; color: var(--accent); flex-shrink: 0; }
.dl-row-pri { font-family: var(--font-mono); font-size: 10.5px; color: var(--text-3); flex-shrink: 0; min-width: 24px; }

.dl-impact {
  background: var(--accent-bg); border: 1px solid color-mix(in srgb, var(--accent) 30%, var(--border));
  border-radius: var(--radius); padding: 16px; margin-bottom: 18px;
}
.dl-impact-h { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; color: var(--accent); margin-bottom: 8px; }
.dl-impact-text { font-size: 14px; color: var(--text); line-height: 1.5; }

.dl-ask { margin-top: 14px; padding-top: 14px; border-top: 1px dashed var(--border-2); }
.dl-ask-label { font-size: 11px; font-weight: 700; color: var(--text-3); text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 6px; }
.dl-ask-q { font-size: 13.5px; color: var(--text); margin-bottom: 10px; line-height: 1.45; }
.dl-ask-input {
  width: 100%; background: var(--surface); border: 1px solid var(--border-2); border-radius: var(--radius-sm);
  padding: 9px 12px; font-size: 13.5px; font-family: inherit; color: var(--text); outline: none;
}
.dl-ask-input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-bg); }

.dl-closed { text-align: center; padding: 48px 20px; color: var(--text-3); }
.dl-closed-icon { font-size: 38px; color: var(--ok); margin-bottom: 12px; }

.dl-recent-title { font-size: 12px; font-weight: 600; color: var(--text-3); text-transform: uppercase; letter-spacing: 0.04em; margin-bottom: 10px; }
.dl-recent-row {
  display: flex; align-items: baseline; justify-content: space-between;
  padding: 9px 0; border-bottom: 1px solid var(--border); font-size: 13px;
}
.dl-recent-row:last-child { border-bottom: none; }
.dl-recent-date { color: var(--text); font-weight: 500; }
.dl-recent-meta { color: var(--text-3); font-size: 12px; }

/* ── Impact ─────────────────────────────────────────────────────────────── */
.impact-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px; margin-bottom: 12px;
}
.impact-card-text { font-size: 14px; color: var(--text); line-height: 1.55; }
.impact-card-draft { color: var(--text-2); font-style: italic; margin-bottom: 4px; }
.impact-card-foot { display: flex; align-items: center; gap: 10px; margin-top: 10px; }
.impact-date { font-size: 11.5px; color: var(--text-3); flex: 1; }
.impact-star {
  background: none; border: none; cursor: pointer; font-size: 16px; color: var(--text-3); padding: 0;
}
.impact-star.on { color: var(--warn); }

.impact-ask { margin-top: 12px; padding-top: 12px; border-top: 1px dashed var(--border-2); }
.impact-ask-label { font-size: 11px; font-weight: 700; color: var(--text-3); text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 6px; }
.impact-ask-q { font-size: 13.5px; color: var(--text); margin-bottom: 10px; line-height: 1.45; }
.impact-ask-input {
  width: 100%; background: var(--surface-2); border: 1px solid var(--border-2); border-radius: var(--radius-sm);
  padding: 9px 12px; font-size: 13.5px; font-family: inherit; color: var(--text); outline: none; margin-bottom: 10px;
}
.impact-ask-input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-bg); }
.impact-ask-actions { display: flex; gap: 8px; }

/* ── Inbox ──────────────────────────────────────────────────────────────── */
.ibx-row {
  display: flex; flex-wrap: wrap; align-items: center; gap: 4px 14px;
  padding: 13px 0; border-bottom: 1px solid var(--border);
}
.ibx-row:last-child { border-bottom: none; }
.ibx-text { flex: 1 1 100%; font-size: 13.5px; color: var(--text); }
.ibx-meta { font-size: 11.5px; color: var(--text-3); }
.ibx-actions { display: flex; gap: 6px; margin-left: auto; }

/* ── Goals ──────────────────────────────────────────────────────────────── */
.goals-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; }
.goal-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px; display: flex; flex-direction: column; gap: 8px;
}
.goal-card-inactive { opacity: 0.55; }
.goal-card-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.goal-ctx-badge {
  font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em;
  padding: 2px 8px; border-radius: 999px;
}
.goal-ctx-work     { background: color-mix(in srgb, var(--work) 18%, transparent);     color: var(--work); }
.goal-ctx-personal { background: color-mix(in srgb, var(--personal) 18%, transparent); color: var(--personal); }
.goal-drift-badge {
  font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em;
  padding: 2px 8px; border-radius: 999px; background: var(--bad-bg); color: var(--bad);
}
.goal-days-left { font-size: 11.5px; color: var(--text-3); }
.goal-days-left.goal-overdue { color: var(--bad); font-weight: 600; }
.goal-title { font-size: 15px; font-weight: 600; color: var(--text); margin: 0; }
.goal-why { font-size: 13px; color: var(--text-2); line-height: 1.45; margin: 0; }
.goal-progress { display: flex; flex-direction: column; gap: 4px; margin-top: 2px; }
.goal-progress-bar { height: 6px; border-radius: 999px; background: var(--raise); overflow: hidden; }
.goal-progress-fill { height: 100%; background: var(--accent); border-radius: 999px; }
.goal-progress-fill.is-drifting { background: var(--bad); }
.goal-progress-label { font-size: 11.5px; color: var(--text-3); }
.goal-target-date { font-size: 11.5px; color: var(--text-3); }
.goal-card-actions { display: flex; justify-content: flex-end; gap: 4px; margin-top: 4px; }

/* ── Milestones (inside the Project modal) ───────────────────────────────── */
.pf-milestones-list { display: flex; flex-direction: column; gap: 6px; margin-bottom: 10px; }
.pf-milestones-empty { font-size: 12.5px; color: var(--text-3); margin: 0; }
.pf-milestone-row {
  display: flex; align-items: center; gap: 8px; padding: 6px 0; border-bottom: 1px solid var(--border);
}
.pf-milestone-row:last-child { border-bottom: none; }
.pf-milestone-title { flex: 1; font-size: 13px; color: var(--text); }
.pf-milestone-title.is-done { color: var(--text-3); text-decoration: line-through; }
.pf-milestone-date { font-size: 11.5px; color: var(--text-3); }
.pf-milestone-add-row { display: flex; gap: 8px; }
.pf-milestone-add-row input[type="text"] { flex: 1; }

/* ── Fitness ────────────────────────────────────────────────────────────── */
.fit-list { display: flex; flex-direction: column; gap: 10px; }
.fit-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 14px 16px; display: flex; align-items: flex-start; gap: 14px;
}
.fit-card-icon { font-size: 20px; line-height: 1; margin-top: 2px; }
.fit-card-body { flex: 1; }
.fit-card-date { font-size: 13.5px; font-weight: 600; color: var(--text); }
.fit-card-stats { display: flex; gap: 12px; font-size: 12px; color: var(--text-3); margin-top: 2px; }
.fit-card-notes { font-size: 12.5px; color: var(--text-2); margin-top: 6px; line-height: 1.4; }

/* Sets (inside the Workout modal) */
.wf-sets-list { display: flex; flex-direction: column; gap: 6px; margin-bottom: 10px; }
.wf-sets-empty { font-size: 12.5px; color: var(--text-3); margin: 0; }
.wf-set-row {
  display: flex; align-items: center; gap: 8px; padding: 6px 0; border-bottom: 1px solid var(--border);
  font-size: 13px;
}
.wf-set-row:last-child { border-bottom: none; }
.wf-set-exercise { flex: 1; color: var(--text); font-weight: 500; }
.wf-set-detail { color: var(--text-3); font-size: 12px; }
.wf-set-warmup-tag {
  font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.03em;
  color: var(--text-3); background: var(--raise); padding: 1px 6px; border-radius: 999px;
}
.wf-set-add-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.wf-set-add-row input[type="text"] { flex: 1 1 140px; }
.wf-set-add-row input[type="number"] { width: 80px; }
.wf-set-warmup { display: flex; align-items: center; gap: 4px; font-size: 12px; color: var(--text-3); white-space: nowrap; }

/* ── Lists ──────────────────────────────────────────────────────────────── */
.lists-tabs { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }
.lst-tab {
  display: flex; align-items: center; gap: 6px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 999px;
  padding: 6px 12px; font-size: 13px; color: var(--text-2); cursor: pointer; font-family: inherit;
}
.lst-tab.active { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.lst-tab-delete { font-size: 12px; opacity: 0.6; }
.lst-tab-delete:hover { opacity: 1; }
.lst-detail-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.lst-kind-badge {
  font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em;
  color: var(--text-3); background: var(--raise); padding: 3px 9px; border-radius: 999px;
}
.lst-add-item-row { display: flex; gap: 8px; margin-bottom: 14px; }
.lst-add-item-row input { flex: 1; }
.lst-items { display: flex; flex-direction: column; gap: 2px; }
.lst-items-empty { font-size: 13px; color: var(--text-3); }
.lst-item-row {
  display: flex; align-items: center; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--border);
}
.lst-item-row:last-child { border-bottom: none; }
.lst-item-text { flex: 1; font-size: 13.5px; color: var(--text); }
.lst-item-row.is-checked .lst-item-text { color: var(--text-3); text-decoration: line-through; }
.lst-add-panel {
  display: flex; flex-wrap: wrap; align-items: center; gap: 10px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 14px; margin-bottom: 16px;
}
.lst-add-panel input[type="text"] { flex: 1 1 180px; }
.lst-clears-label { display: flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--text-3); white-space: nowrap; }

/* ── Finance ────────────────────────────────────────────────────────────── */
.fin-trend {
  display: flex; align-items: flex-end; gap: 14px; height: 100px;
  padding: 12px 4px; margin-bottom: 18px; border-bottom: 1px solid var(--border);
}
.fin-trend-col { display: flex; flex-direction: column; align-items: center; gap: 6px; flex: 1; height: 100%; justify-content: flex-end; }
.fin-trend-bar { width: 60%; max-width: 28px; border-radius: 4px 4px 0 0; }
.fin-trend-bar.is-positive { background: var(--ok); }
.fin-trend-bar.is-negative { background: var(--bad); }
.fin-trend-label { font-size: 11px; color: var(--text-3); }

.fin-list { display: flex; flex-direction: column; gap: 2px; }
.fin-tx-row {
  display: flex; align-items: center; gap: 14px; padding: 10px 0; border-bottom: 1px solid var(--border);
  font-size: 13.5px;
}
.fin-tx-row:last-child { border-bottom: none; }
.fin-tx-date { color: var(--text-3); font-size: 12px; width: 90px; flex-shrink: 0; }
.fin-tx-merchant { flex: 1; color: var(--text); font-weight: 500; }
.fin-tx-category { color: var(--text-3); font-size: 12px; }
.fin-tx-amount { font-weight: 600; font-variant-numeric: tabular-nums; }
.fin-tx-amount.is-income  { color: var(--ok); }
.fin-tx-amount.is-expense { color: var(--text); }

/* Transaction modal — receipt scan */
.tx-receipt-row { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.tx-receipt-status { font-size: 12px; color: var(--text-3); }

/* Recurring transactions modal */
.recurring-list { display: flex; flex-direction: column; gap: 2px; margin-bottom: 14px; }
.recurring-empty { font-size: 13px; color: var(--text-3); margin: 0 0 14px; }
.recurring-row {
  display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--border);
  font-size: 13px;
}
.recurring-row:last-child { border-bottom: none; }
.recurring-merchant { flex: 1; color: var(--text); font-weight: 500; }
.recurring-amount { font-weight: 600; font-variant-numeric: tabular-nums; }
.recurring-amount.is-income  { color: var(--ok); }
.recurring-amount.is-expense { color: var(--text); }
.recurring-cadence { color: var(--text-3); font-size: 11.5px; text-transform: capitalize; }
.recurring-next { color: var(--text-3); font-size: 12px; }
.recurring-add-row { display: flex; flex-wrap: wrap; gap: 8px; }
.recurring-add-row input[type="text"] { flex: 1 1 120px; }
.recurring-add-row input[type="number"] { width: 90px; }
.recurring-add-row input[type="date"] { flex: 1 1 130px; }

/* ── Review ─────────────────────────────────────────────────────────────── */
.rev-content { display: flex; flex-direction: column; gap: 14px; max-width: 640px; }
.rev-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px;
}
.rev-card-title { font-size: 13px; font-weight: 700; color: var(--text-2); margin-bottom: 10px; }
.rev-card-empty { font-size: 13px; color: var(--text-3); margin: 0; }
.rev-row {
  display: flex; align-items: center; gap: 10px; padding: 7px 0; border-bottom: 1px solid var(--border);
  font-size: 13.5px;
}
.rev-row:last-child { border-bottom: none; }
.rev-row-label { flex: 1; color: var(--text); font-weight: 500; }
.rev-row-detail { color: var(--text-3); font-size: 12px; }
.rev-flag {
  font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.03em;
  padding: 2px 8px; border-radius: 999px; flex-shrink: 0;
}
.rev-flag-bad { background: var(--bad-bg); color: var(--bad); }
.rev-flag-ok  { background: var(--ok-bg);  color: var(--ok); }
.rev-rollup-text { font-size: 13.5px; color: var(--text); line-height: 1.55; margin-bottom: 10px; }
.rev-rollup-actions { display: flex; gap: 8px; }
.rev-rollup-textarea {
  width: 100%; background: var(--surface-2); border: 1px solid var(--border-2); border-radius: var(--radius-sm);
  padding: 9px 12px; font-size: 13.5px; font-family: inherit; color: var(--text); margin-bottom: 10px; resize: vertical;
}

/* ── User menu ──────────────────────────────────────────────────────────── */
.user-chip-wrap { position: relative; }
.user-menu-dropdown {
  position: absolute; bottom: calc(100% + 6px); left: 0; min-width: 160px;
  background: var(--surface); border: 1px solid var(--border-2); border-radius: var(--radius-sm);
  box-shadow: 0 8px 24px rgba(0,0,0,0.18); padding: 4px; z-index: 700;
}
.user-menu-item {
  display: block; width: 100%; text-align: left; background: none; border: none;
  padding: 8px 10px; font-size: 13px; color: var(--text-2); border-radius: 4px;
  cursor: pointer; font-family: inherit;
}
.user-menu-item:hover { background: var(--hover); color: var(--text); }

/* ── Welcome modal (first run) ────────────────────────────────────────────── */
.welcome-body { text-align: center; padding-top: 12px; }
.welcome-icon { font-size: 38px; margin-bottom: 10px; }
.welcome-title { font-size: 19px; font-weight: 700; color: var(--text); margin: 0 0 10px; }
.welcome-text { font-size: 13.5px; color: var(--text-3); line-height: 1.55; margin: 0 0 22px; }
.welcome-actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }

/* ── Tour (coachmark) ─────────────────────────────────────────────────────── */
.tour-backdrop {
  position: fixed; inset: 0; background: rgba(15,15,20,0.55); z-index: 1500;
}
.tour-highlight {
  position: fixed; border-radius: 8px; box-shadow: 0 0 0 3px var(--accent), 0 0 0 9999px rgba(15,15,20,0.55);
  z-index: 1500; pointer-events: none; transition: top 0.15s, left 0.15s, width 0.15s, height 0.15s;
}
.tour-popover {
  position: fixed; z-index: 1500; width: 280px; max-width: calc(100vw - 24px);
  background: var(--surface); border: 1px solid var(--border-2); border-radius: var(--radius);
  box-shadow: 0 12px 32px rgba(0,0,0,0.28); padding: 16px;
}
.tour-step-count { font-size: 11px; font-weight: 700; color: var(--text-3); text-transform: uppercase; letter-spacing: 0.04em; margin-bottom: 6px; }
.tour-title { font-size: 15px; font-weight: 700; color: var(--text); margin: 0 0 6px; }
.tour-body  { font-size: 13px; color: var(--text-2); line-height: 1.5; margin: 0 0 14px; }
.tour-actions { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.tour-actions-right { display: flex; gap: 8px; }

/* ── Phase 1: mobile ────────────────────────────────────────────────────── */
@media (max-width: 768px) {
  .tdy-cols { grid-template-columns: 1fr; }
  .modal-capture { width: 92vw; }
  .dl-wrap { max-width: none; }
  .goals-grid { grid-template-columns: 1fr; }
}
