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

:root {
  --sb:          #EDEDED;
  --bg:          #FFFFFF;
  --text:        #1C1C1E;
  --muted:       #8E8E93;
  --border:      rgba(0,0,0,0.07);
  --hover:       rgba(0,0,0,0.04);
  --hover-blue:  rgba(0,122,255,0.10);   /* hover / press feedback: the primary blue at 10% */
  --selected:    rgba(0,0,0,0.07);
  --blue:        #007AFF;
  --blue-bg:     #E4F0FF;
  --check:       #34C759;
  --orange:      #FF9500;
  --red:         #FF3B30;
  --ring-track:  rgba(0,0,0,0.12);
  --ring-fill:   #1C1C1E;
  --shadow:      0 1px 3px rgba(0,0,0,0.06), 0 0 0 0.5px rgba(0,0,0,0.05);
  /* menus & popovers */
  --menu-bg:     #FFFFFF;
  --menu-border: #EDEDED;
  --menu-shadow: 0 4px 16px rgba(0,0,0,0.08), 0 1px 4px rgba(0,0,0,0.05);
  /* collaborator colours */
  --c1: #C07A6A; --c2: #5A9E96; --c3: #7E6DB8; --c4: #B8922A; --c5: #4A8BB5;
}

@media (prefers-color-scheme: dark) {
  :root {
    --sb:         #1C1C1E;
    --bg:         #242426;
    --text:       #F2F2F7;
    --muted:      #58585E;
    --border:     rgba(255,255,255,0.07);
    --hover:      rgba(255,255,255,0.04);
    --hover-blue: rgba(10,132,255,0.10);
    --selected:   rgba(255,255,255,0.08);
    --blue:       #0A84FF;
    --blue-bg:    rgba(10,132,255,0.15);
    --ring-track: rgba(255,255,255,0.13);
    --ring-fill:  #F2F2F7;
    /* menus & popovers — dark */
    --menu-bg:     #2C2C2E;
    --menu-border: rgba(255,255,255,0.1);
    --menu-shadow: 0 4px 24px rgba(0,0,0,0.4), 0 1px 6px rgba(0,0,0,0.3);
  }
}

html, body {
  width: 100%; height: 100%;
  overflow: hidden;
  font-family: -apple-system, 'SF Pro Text', 'Helvetica Neue', sans-serif;
  color: var(--text);
  background: var(--bg);
}

/* ─── App shell — fills the Electron window ──────────────── */
.app {
  display: flex;
  width: 100%;
  height: 100vh;
  height: 100dvh;           /* iPad/iPhone Safari: 100vh ignores the toolbars and hides the bottom of the page */
  background: var(--bg);
  overflow: hidden;
}

/* ─── Sidebar ─────────────────────────────────────────────── */
.sidebar {
  width: 240px;
  min-width: 0;
  background: var(--sb);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  flex-shrink: 0;
  user-select: none;
  transition: width 0.22s cubic-bezier(0.4,0,0.2,1);
}
.sidebar.collapsed {
  width: 0 !important;
}
/* Desktop: the OS animates the window for ~270ms with an ease-in-out curve, so the sidebar
   uses the same timing to stay in step with it. */
.is-desktop .sidebar { transition: width 0.27s ease-in-out 0.04s; }
/* Keep the content at the expanded width so hiding the sidebar slides it away
   (clipped by overflow:hidden) instead of squashing and re-wrapping it. */
.sidebar > * {
  flex-shrink: 0;
  width: var(--sb-w, 240px);
}

/* ─── Resize handle ───────────────────────────────────────── */
.sb-resize-handle {
  width: 10px;
  flex-shrink: 0;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: col-resize;
  z-index: 10;
}
/* The pill indicator — hidden until hover */
.sb-resize-pip {
  width: 5px;
  height: 52px;
  border-radius: 4px;
  background: transparent;
  transition: background 0.15s;
  pointer-events: none;
}
.sb-resize-handle:hover .sb-resize-pip,
.sb-resize-handle.dragging .sb-resize-pip {
  background: rgba(0,0,0,0.22);
}
@media (prefers-color-scheme: dark) {
  .sb-resize-handle:hover .sb-resize-pip,
  .sb-resize-handle.dragging .sb-resize-pip {
    background: rgba(255,255,255,0.28);
  }
}
/* Collapsed state — same style, just pointer cursor */
.sidebar.collapsed ~ .sb-resize-handle {
  cursor: pointer;
}

.sidebar-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 10px 0 6px;
}
.sidebar-scroll::-webkit-scrollbar { display: none; }

.nav-section { padding: 0; }

/* ── Nav items ── */
.nav-item {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 5px 12px;
  margin: 1px 6px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 15px;
  color: var(--text);
  transition: background 0.1s;
}
.nav-item:hover  { background: var(--hover-blue); }
/* Gray pill highlight — no colour inversion */
.nav-item.active { background: var(--selected); }
.nav-item.active .nc { color: var(--muted); }

.nav-label { flex: 1; line-height: 1.3; }
.nc {
  font-size: 13px;
  color: var(--muted);
  margin-left: auto;
  min-width: 14px;
  text-align: right;
}

/* ── Nav icons — coloured icon, no square box ── */
.nav-icon {
  width: 24px; height: 24px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.nav-icon svg { width: 22px; height: 22px; }

.sb-divider {
  height: 0.5px;
  background: var(--border);
  margin: 5px 12px;
}

/* ─── Areas ───────────────────────────────────────────────── */
.area-block { margin-top: 4px; }

.area-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 12px;
  margin: 1px 6px;
  border-radius: 8px;
  cursor: default;
}

.area-label {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  flex: 1;
}

/* ── Inline rename (new area / new project) ── */
.area-label.inline-editing,
.proj-name.inline-editing {
  outline: none;
  background: var(--bg);
  border-radius: 5px;
  padding: 1px 5px;
  margin: -1px -5px;
  min-width: 60px;
  caret-color: var(--blue);
  color: var(--text);
}

.shared-pip {
  font-size: 10px;
  padding: 1px 6px;
  border-radius: 10px;
  background: var(--blue-bg);
  color: var(--blue);
  font-weight: 500;
  flex-shrink: 0;
}
.shared-pip.shared-with-me {
  background: rgba(52,199,89,0.12);
  color: #1A8A36;
}

.collab-stack { display: flex; }
.mini-av {
  width: 15px; height: 15px;
  border-radius: 50%;
  border: 1.5px solid var(--sb);
  font-size: 6px; font-weight: 600;
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  margin-left: -4px;
  flex-shrink: 0;
}
.mini-av:first-child { margin-left: 0; }

.proj-list { padding: 0 6px 2px 16px; }

.proj-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 8px;
  border-radius: 7px;
  cursor: pointer;
  font-size: 14px;
  color: var(--text);
}
.proj-row:hover  { background: var(--hover-blue); }
.proj-row.active { background: var(--selected); }
.proj-name { flex: 1; }
.proj-ring { flex-shrink: 0; }

/* ── Sidebar footer ── */
.sidebar-footer {
  border-top: 0.5px solid var(--border);
  /* Same 8px as the web. Only a device reporting a big home-indicator inset (>20px) gets a little more:
     the buttons sit in the corners, away from the centred home bar, so they need far less than the full inset. */
  padding: 8px 10px max(8px, calc(env(safe-area-inset-bottom) - 12px));
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}

.btn-new-list {
  display: flex;
  align-items: center;
  gap: 5px;
  background: none;
  border: none;
  font-family: inherit;
  font-size: 13px;
  color: var(--muted);
  cursor: pointer;
  padding: 4px 6px;
  border-radius: 6px;
  transition: color 0.15s, background 0.15s;
}
.btn-new-list:hover { color: var(--blue); background: var(--hover-blue); }

/* ── Avatar button (bottom-right of sidebar) ── */
.btn-avatar {
  width: 30px; height: 30px;
  border-radius: 50%;
  border: none;
  padding: 0;
  cursor: pointer;
  overflow: hidden;
  flex-shrink: 0;
  background: var(--selected);
  display: flex; align-items: center; justify-content: center;
  transition: opacity 0.15s, box-shadow 0.15s;
  color: var(--muted);
}
.btn-avatar:hover { opacity: 0.85; box-shadow: 0 0 0 2px var(--blue); }
.btn-avatar img {
  width: 100%; height: 100%; object-fit: cover; border-radius: 50%;
}
.btn-avatar .av-initials {
  font-size: 11px; font-weight: 600; color: var(--text);
  text-transform: uppercase; line-height: 1; user-select: none;
}

/* ── Settings photo upload ── */
.settings-photo-row {
  display: flex; justify-content: center;
  padding: 4px 0 16px;
}
.settings-photo-wrap {
  display: flex; flex-direction: column; align-items: center; gap: 8px;
}
.settings-photo-preview {
  width: 72px; height: 72px;
  border-radius: 50%;
  background: var(--selected);
  display: flex; align-items: center; justify-content: center;
  overflow: hidden;
  font-size: 22px; font-weight: 600; color: var(--text);
  border: 2px solid var(--border);
}
.settings-photo-preview img {
  width: 100%; height: 100%; object-fit: cover;
}
.settings-photo-change {
  display: flex; align-items: center; gap: 5px;
  background: none; border: 1px solid var(--border);
  border-radius: 7px; padding: 5px 12px;
  font-family: inherit; font-size: 12px; color: var(--muted);
  cursor: pointer; transition: background 0.13s, color 0.13s;
}
.settings-photo-change:hover { background: var(--hover-blue); color: var(--text); }

/* ─── Main pane ───────────────────────────────────────────── */
.main {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 0;
}

.main-header {
  padding: calc(20px + env(safe-area-inset-top)) 24px 0;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  flex-shrink: 0;
}

.main-title {
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.4px;
  display: flex;
  align-items: center;
  gap: 10px;
  line-height: 1.2;
}
#titleText[contenteditable="true"] {
  border-radius: 6px;
  background: var(--hover);
  padding: 0 6px;
  caret-color: var(--blue);
  cursor: text;
}
/* Subtle double-click hint on project/area titles */
#titleText[ondblclick] { cursor: default; }
#titleText[ondblclick]:hover { opacity: 0.85; }

.proj-sub {
  font-size: 12px;
  color: var(--muted);
  margin-top: 3px;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 4px;
}

.av-stack { display: flex; align-items: center; }
.av {
  width: 27px; height: 27px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 9px; font-weight: 600;
  color: #fff;
  border: 2px solid var(--bg);
  margin-left: -8px;
  cursor: pointer;
  transition: transform 0.15s;
  flex-shrink: 0;
}
.av:first-child { margin-left: 0; }
.av:hover { transform: scale(1.15); z-index: 1; }

.add-av {
  width: 27px; height: 27px;
  border-radius: 50%;
  border: 1.5px dashed var(--muted);
  display: flex; align-items: center; justify-content: center;
  font-size: 16px; line-height: 1;
  color: var(--muted);
  cursor: pointer;
  margin-left: 3px;
  transition: border-color 0.15s, color 0.15s;
}
.add-av:hover { border-color: var(--blue); color: var(--blue); }

.btn-share {
  font-size: 12px;
  background: var(--blue-bg);
  color: var(--blue);
  border: none;
  padding: 5px 13px;
  border-radius: 20px;
  cursor: pointer;
  font-weight: 500;
  transition: opacity 0.15s;
}
.btn-share:hover { opacity: 0.8; }

/* ─── Quick-add bar ───────────────────────────────────────── */
.quick-add-wrap {
  padding: 10px 16px 0;
  flex-shrink: 0;
}
.quick-add {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 7px 12px;
  background: var(--hover);
  border-radius: 9px;
  border: 1px solid transparent;
  transition: border-color 0.15s, background 0.15s;
}
.quick-add:focus-within {
  background: var(--bg);
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(0,122,255,0.1);
}
.quick-add-input {
  flex: 1;
  background: none;
  border: none;
  outline: none;
  font-size: 14px;
  color: var(--text);
  font-family: inherit;
}
.quick-add-input::placeholder { color: var(--muted); }

/* ─── Task list ───────────────────────────────────────────── */
.task-list {
  flex: 1;
  overflow-y: auto;
  padding: 10px 16px 60px;
}
.task-list::-webkit-scrollbar { display: none; }

.sec-label {
  font-size: 11px;
  font-weight: 500;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 8px 8px 5px;
}
.sec-label:first-child { padding-top: 4px; }

.task-group-header {
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
  padding: 10px 8px 4px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.task-group-proj-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--blue);
  flex-shrink: 0;
}

.task-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 6px 8px;
  border-radius: 9px;
  cursor: default;
  position: relative;
  user-select: none;
}

.task-row:hover { background: var(--hover-blue); }
.task-row.selected { background: var(--selected); }

/* ── Calendar date button (hover-reveal) ── */
.task-date-btn {
  width: 18px; height: 18px;
  flex-shrink: 0;
  margin-top: 2px;
  display: flex; align-items: center; justify-content: center;
  opacity: 0;
  cursor: pointer;
  border-radius: 4px;
  transition: opacity 0.13s, background 0.13s;
  color: var(--muted);
  position: relative;
}
.task-row:hover .task-date-btn { opacity: 1; }
.task-date-btn:hover { background: var(--selected); color: var(--blue); }
.task-date-btn input[type="date"] {
  position: absolute; inset: 0; opacity: 0; cursor: pointer;
  width: 100%; height: 100%; border: none; padding: 0;
}

/* ── Task drag-and-drop ── */
.task-row[draggable="true"] { cursor: grab; }
.task-row[draggable="true"]:active { cursor: grabbing; }
.task-row.task-dragging { opacity: 0.35; }
.task-drop-zone {
  /* Large hit area, but visually a thin line via the ::after trick */
  height: 20px;
  margin: -10px 8px;
  position: relative;
  z-index: 4;
}
.task-drop-zone::after {
  content: '';
  position: absolute;
  left: 0; right: 0;
  top: 50%; transform: translateY(-50%);
  height: 2px;
  border-radius: 2px;
  background: transparent;
  transition: background 0.1s;
}
.task-drop-zone.drag-over::after {
  background: var(--blue);
}
/* Drop onto a heading */
.heading-row.heading-drag-over .heading-name {
  outline: 2px solid var(--blue);
  border-radius: 5px;
}

/* ── Rounded-square checkbox ── */
.check {
  width: 18px; height: 18px;
  border-radius: 5px;
  border: 1.5px solid var(--muted);
  flex-shrink: 0;
  margin-top: 2px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s;
}
.check:hover  { border-color: var(--check); }
.check.done   { background: var(--check); border-color: var(--check); }
.check.done::after {
  content: '';
  display: block;
  width: 4px; height: 7px;
  border: 1.5px solid #fff;
  border-top: none; border-left: none;
  transform: rotate(45deg) translate(-1px, -1px);
}

.task-body { flex: 1; min-width: 0; }
.task-name { display: inline-block; max-width: 100%; font-size: 14px; line-height: 1.45; cursor: text; border-radius: 4px; overflow-wrap: anywhere; }
.task-name.done { cursor: text; }
.task-row.is-editing { background: var(--hover-blue); }
.task-name[contenteditable="true"], .task-name[contenteditable="plaintext-only"] {
  outline: none; cursor: text; user-select: text; -webkit-user-select: text; min-width: 40px;
  box-shadow: 0 0 0 2px var(--blue-bg), 0 0 0 3px var(--blue); background: var(--bg); padding: 0 4px; margin: 0 -4px;
}
.task-name.done { text-decoration: line-through; color: var(--muted); }

.task-meta {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-top: 2px;
  flex-wrap: wrap;
}

.tag { font-size: 11px; border-radius: 10px; font-weight: 500; padding: 1px 7px; }
.tag-label { background: rgba(0,0,0,0.06); color: var(--muted); }
@media (prefers-color-scheme: dark) { .tag-label { background: rgba(255,255,255,0.09); } }
.tag-today  { color: var(--orange); font-weight: 600; padding: 0; }
.tag-date   { color: var(--muted); padding: 0; }

.task-av {
  width: 20px; height: 20px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 7px; font-weight: 600;
  color: #fff;
  flex-shrink: 0;
  margin-top: 2px;
  cursor: pointer;
  transition: transform 0.15s;
}
.task-av:hover { transform: scale(1.2); }

.gap { height: 12px; }

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 200px;
  color: var(--muted);
  gap: 8px;
}
.empty-state p { font-size: 14px; }

/* ─── Area view ───────────────────────────────────────────── */
.area-proj-grid {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 16px 0 60px;
}

.area-proj-card {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 13px 16px;
  border-radius: 10px;
  background: var(--sb);
  border: 0.5px solid var(--border);
  cursor: pointer;
  transition: box-shadow 0.15s, border-color 0.15s;
}
.area-proj-card:hover {
  border-color: rgba(0,0,0,0.12);
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}

.area-proj-ring { flex-shrink: 0; }

.area-proj-body { flex: 1; min-width: 0; }
.area-proj-name { font-size: 15px; font-weight: 600; margin-bottom: 2px; }
.area-proj-meta { font-size: 12px; color: var(--muted); }

.area-proj-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.area-proj-av-stack { display: flex; }
.area-proj-av {
  width: 22px; height: 22px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 8px; font-weight: 600; color: #fff;
  border: 2px solid var(--sb);
  margin-left: -6px;
  flex-shrink: 0;
}
.area-proj-av:first-child { margin-left: 0; }

.area-proj-chevron { color: var(--muted); font-size: 14px; }

/* ─── Headings inside projects ────────────────────────────── */
.heading-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 22px 8px 0;
}

.heading-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  flex: 1;
  outline: none;
  cursor: text;
  padding-bottom: 7px;
  border-bottom: 0.5px solid var(--border);
  min-width: 0;
  /* stop it from growing the row height */
  align-self: flex-end;
  width: 100%;
}
.heading-name:empty::before {
  content: attr(placeholder);
  color: var(--muted);
  pointer-events: none;
}

.heading-actions {
  display: flex;
  gap: 2px;
  opacity: 0;
  transition: opacity 0.15s;
  flex-shrink: 0;
  padding-bottom: 7px;
  align-self: flex-end;
}
.heading-row:hover .heading-actions { opacity: 1; }

.heading-btn {
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  font-size: 15px;
  line-height: 1;
  padding: 2px 5px;
  border-radius: 4px;
}
.heading-btn:hover { background: var(--hover-blue); color: var(--text); }

/* "Add Heading" button at bottom of project task list */
.btn-add-heading {
  display: flex;
  align-items: center;
  gap: 6px;
  background: none;
  border: none;
  font-family: inherit;
  font-size: 13px;
  color: var(--muted);
  cursor: pointer;
  padding: 8px 8px;
  border-radius: 7px;
  margin-top: 6px;
  transition: color 0.15s, background 0.15s;
}
.btn-add-heading:hover { color: var(--blue); background: var(--hover-blue); }

/* active area highlight in sidebar */
.area-header.active .area-label { color: var(--blue); }

/* ─── New List popover ────────────────────────────────────── */
.nl-popover {
  position: fixed;
  background: var(--menu-bg);
  border-radius: 10px;
  box-shadow: var(--menu-shadow);
  border: 1px solid var(--menu-border);
  padding: 4px;
  z-index: 500;
  min-width: 180px;
  animation: popIn 0.14s cubic-bezier(0.34,1.56,0.64,1);
}
@keyframes popIn { from { transform: scale(0.92) translateY(4px); opacity: 0; } to { transform: none; opacity: 1; } }

.nl-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-radius: 7px;
  cursor: pointer;
  font-size: 14px;
  color: var(--text);
  transition: background 0.1s;
}
.nl-item:hover { background: var(--hover-blue); }
.nl-icon { width: 20px; height: 20px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.ctx-av { width: 16px; height: 16px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 6px; font-weight: 600; color: #fff; flex-shrink: 0; }
.nl-label { font-size: 14px; }
.nl-text { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.nl-desc { font-size: 11.5px; line-height: 1.35; color: var(--muted); }
.nl-popover { min-width: 250px; max-width: 280px; }
.nl-item { align-items: flex-start; }
.nl-icon { margin-top: 1px; }
.nl-sep { height: 0.5px; background: var(--border); margin: 3px 0; }

/* ─── Context menu ────────────────────────────────────────── */
.ctx-menu {
  position: fixed;
  background: var(--menu-bg);
  border-radius: 10px;
  box-shadow: var(--menu-shadow);
  border: 1px solid var(--menu-border);
  padding: 4px;
  z-index: 600;
  min-width: 200px;
  animation: popIn 0.12s cubic-bezier(0.34,1.56,0.64,1);
  user-select: none;
}

.ctx-group-label {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.07em;
  color: var(--muted);
  padding: 5px 10px 2px;
  text-transform: uppercase;
}

.ctx-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border-radius: 6px;
  font-size: 13.5px;
  color: var(--text);
  cursor: pointer;
  transition: background 0.1s;
}
.ctx-item:hover { background: var(--hover-blue); }
.ctx-item.ctx-danger { color: var(--red); }
.ctx-item.ctx-danger:hover { background: rgba(255,59,48,0.08); }
.ctx-icon { width: 14px; height: 14px; flex-shrink: 0; }
.ctx-sep { height: 0.5px; background: var(--border); margin: 3px 4px; }

.ctx-submenu-wrap { position: relative; }
.ctx-has-sub { justify-content: flex-start; }
.ctx-chevron { width: 8px; height: 12px; margin-left: auto; }

.ctx-submenu {
  display: none;
  position: absolute;
  left: calc(100% + 4px);
  top: -4px;
  background: var(--menu-bg);
  border-radius: 10px;
  box-shadow: var(--menu-shadow);
  border: 1px solid var(--menu-border);
  padding: 4px;
  min-width: 170px;
  z-index: 601;
  animation: popIn 0.12s cubic-bezier(0.34,1.56,0.64,1);
}
.ctx-submenu-wrap:hover .ctx-submenu { display: block; }

/* ─── Drag and drop ───────────────────────────────────────── */
.proj-row.dragging { opacity: 0.4; }
.proj-row.drag-over {
  background: var(--blue-bg);
  outline: 1.5px solid var(--blue);
  outline-offset: -1px;
}
.area-drop-zone {
  height: 3px;
  margin: 1px 8px;
  border-radius: 2px;
  transition: background 0.15s, height 0.15s;
}
.area-drop-zone.drag-over {
  height: 6px;
  background: var(--blue);
}

/* ─── Settings modal ──────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.28);
  z-index: 300;
  display: flex; align-items: center; justify-content: center;
  backdrop-filter: blur(4px);
  animation: fadeIn 0.15s ease;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.modal {
  background: var(--sb);
  border-radius: 14px;
  width: 440px;
  max-width: 92vw;
  max-height: 90vh;
  max-height: 90dvh;
  overflow-y: auto;
  box-shadow: 0 24px 64px rgba(0,0,0,0.2), 0 0 0 0.5px var(--border);
  animation: slideUp 0.18s cubic-bezier(0.34,1.56,0.64,1);
}
.modal::-webkit-scrollbar { display: none; }
@keyframes slideUp { from { transform: translateY(16px); opacity: 0; } to { transform: none; opacity: 1; } }

.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 20px 14px;
  border-bottom: 0.5px solid var(--border);
}
.modal-header h2 { font-size: 17px; font-weight: 600; }
.modal-header button {
  background: var(--hover); border: none;
  width: 26px; height: 26px; border-radius: 50%;
  font-size: 13px; color: var(--muted); cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}
.modal-header button:hover { background: var(--selected); color: var(--text); }

.modal-section {
  padding: 16px 20px;
  border-bottom: 0.5px solid var(--border);
}
.modal-section:last-child { border-bottom: none; }
.modal-section-title {
  font-size: 11px; font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.06em; color: var(--muted); margin-bottom: 12px;
}

.field-row {
  display: flex; align-items: center; gap: 10px; margin-bottom: 10px;
}
.field-row:last-child { margin-bottom: 0; }
.field-row label { font-size: 13px; color: var(--muted); width: 80px; flex-shrink: 0; }
.field-row input[type="text"],
.field-row input[type="email"] {
  flex: 1; background: var(--hover);
  border: 1px solid transparent; border-radius: 7px;
  padding: 6px 10px; font-size: 14px;
  font-family: inherit; color: var(--text);
  outline: none; transition: border-color 0.15s;
}
.field-row input:focus { border-color: var(--blue); background: var(--bg); }

.btn-manage {
  width: 100%; padding: 9px;
  background: none; border: 1px solid var(--border);
  border-radius: 8px; font-family: inherit;
  font-size: 13px; color: var(--blue);
  cursor: pointer; margin-top: 14px;
  transition: background 0.15s;
}
.btn-manage:hover { background: var(--blue-bg); }

/* ── Plan picker (Settings) ── */
.plan-list { display: flex; flex-direction: column; gap: 8px; }
.plan-opt {
  display: flex; align-items: center; gap: 12px; width: 100%; text-align: left;
  padding: 10px 12px; background: var(--bg); color: inherit; font: inherit;
  border: 1.5px solid var(--border); border-radius: 10px; cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.plan-opt:hover { border-color: var(--blue); }
.plan-opt:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }
.plan-opt[aria-checked="true"] { border-color: var(--blue); background: var(--blue-bg); }
.plan-opt-radio {
  width: 16px; height: 16px; border-radius: 50%; flex-shrink: 0;
  border: 1.5px solid var(--muted); position: relative;
}
.plan-opt[aria-checked="true"] .plan-opt-radio { border-color: var(--blue); }
.plan-opt[aria-checked="true"] .plan-opt-radio::after {
  content: ''; position: absolute; inset: 2.5px; border-radius: 50%; background: var(--blue);
}
.plan-opt-main { flex: 1; min-width: 0; }
.plan-opt-name { font-size: 14px; font-weight: 600; }
.plan-opt-sub { font-size: 12px; color: var(--muted); }
.plan-opt-tag { font-size: 11px; font-weight: 600; color: var(--blue); background: var(--blue-bg); padding: 2px 8px; border-radius: 10px; }
.plan-note { font-size: 12px; color: var(--muted); margin-top: 10px; }

.btn-signout {
  background: none; border: none; margin-right: auto;
  padding: 7px 10px; border-radius: 8px;
  font-family: inherit; font-size: 13px; color: var(--red); cursor: pointer;
}
.btn-signout:hover { background: var(--hover-blue); }

/* ── Demo banner ── */
.demo-banner {
  display: flex; align-items: center; justify-content: center; gap: 10px; flex-shrink: 0;
  padding: 6px 12px; font-size: 12px; background: var(--blue-bg); color: var(--blue);
}
.demo-banner[hidden] { display: none; }
.demo-banner a { color: var(--blue); font-weight: 600; text-decoration: underline; cursor: pointer; }

/* ── Desktop (Electron) window chrome ── */
.is-desktop .sidebar { position: relative; }
.is-desktop .sidebar::before {
  content: ''; position: absolute; top: 0; left: 0; right: 0; height: 38px;
  -webkit-app-region: drag; z-index: 5;
}
.is-desktop .sidebar-scroll { padding-top: 38px; }
html:not(.is-desktop) .sidebar-scroll { padding-top: calc(10px + env(safe-area-inset-top)); }
.is-desktop .main-header { -webkit-app-region: drag; }
.is-desktop .main-title, .is-desktop .proj-sub, .is-desktop .header-right { -webkit-app-region: no-drag; }
.is-desktop .sidebar.collapsed ~ .main .main-header { padding-left: 90px; }
.is-desktop .demo-banner a, .is-desktop .demo-banner { -webkit-app-region: no-drag; }

.modal-footer {
  padding: 12px 20px;
  border-top: 0.5px solid var(--border);
  display: flex; justify-content: flex-end; gap: 8px;
}
.btn-cancel {
  background: var(--hover); border: none;
  padding: 7px 16px; border-radius: 8px;
  font-family: inherit; font-size: 13px;
  color: var(--text); cursor: pointer;
}
.btn-cancel:hover { background: var(--selected); }
.btn-save {
  background: var(--blue); border: none;
  padding: 7px 20px; border-radius: 8px;
  font-family: inherit; font-size: 13px; font-weight: 500;
  color: #fff; cursor: pointer;
  transition: opacity 0.15s;
}
.btn-save:hover { opacity: 0.88; }

/* ─── Share modal ────────────────────────────────────────── */
.modal-share { width: 460px; }

.share-link-row {
  display: flex; align-items: center; gap: 8px; margin-bottom: 8px;
}
.share-link-pill {
  flex: 1; display: flex; align-items: center; gap: 8px;
  background: var(--hover); border: 1px solid var(--border);
  border-radius: 8px; padding: 7px 11px; min-width: 0;
}
.share-link-icon { flex-shrink: 0; }
.share-link-text {
  font-size: 13px; color: var(--muted);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  flex: 1; min-width: 0;
}
.btn-copy-link {
  display: flex; align-items: center; gap: 6px;
  background: var(--hover); border: 1px solid var(--border);
  border-radius: 8px; padding: 7px 13px;
  font-family: inherit; font-size: 13px; font-weight: 500;
  color: var(--text); cursor: pointer; white-space: nowrap;
  transition: background 0.13s;
  flex-shrink: 0;
}
.btn-copy-link:hover { background: var(--selected); }
.btn-copy-link.copied {
  color: var(--check); border-color: rgba(52,199,89,0.3);
  background: rgba(52,199,89,0.08);
}
.share-link-hint {
  font-size: 12px; color: var(--muted); line-height: 1.4;
}

.invite-email-row {
  display: flex; align-items: center; gap: 8px;
}
.invite-input-wrap {
  flex: 1; display: flex; align-items: center; gap: 8px;
  background: var(--hover); border: 1px solid transparent;
  border-radius: 8px; padding: 7px 11px;
  transition: border-color 0.15s;
}
.invite-input-wrap:focus-within {
  border-color: var(--blue); background: var(--bg);
}
.invite-input-icon { flex-shrink: 0; }
.invite-email-input {
  flex: 1; border: none; background: transparent;
  font-family: inherit; font-size: 14px; color: var(--text);
  outline: none; min-width: 0;
}
.invite-email-input::placeholder { color: var(--muted); }
.btn-send-invite {
  background: var(--blue); border: none;
  padding: 8px 16px; border-radius: 8px;
  font-family: inherit; font-size: 13px; font-weight: 500;
  color: #fff; cursor: pointer; white-space: nowrap;
  flex-shrink: 0; transition: opacity 0.15s;
}
.btn-send-invite:hover { opacity: 0.88; }
.btn-send-invite:disabled { opacity: 0.4; cursor: default; }

.share-collabs-list { display: flex; flex-direction: column; gap: 8px; }
.share-collab-row {
  display: flex; align-items: center; gap: 10px;
}
.share-collab-av {
  width: 32px; height: 32px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 600; color: #fff; flex-shrink: 0;
}
.share-collab-info { flex: 1; min-width: 0; }
.share-collab-name { font-size: 13px; font-weight: 500; }
.share-collab-email { font-size: 11px; color: var(--muted); }
.share-collab-role {
  font-size: 11px; color: var(--muted);
  background: var(--hover); padding: 2px 9px;
  border-radius: 10px; white-space: nowrap;
}
.share-collab-role.owner { color: var(--blue); background: var(--blue-bg); }

.btn-collab-remove {
  background: none; border: none; cursor: pointer;
  color: var(--muted); padding: 4px; border-radius: 6px;
  display: flex; align-items: center; opacity: 0;
  transition: opacity 0.15s, color 0.15s;
}
.share-collab-row:hover .btn-collab-remove { opacity: 1; }
.btn-collab-remove:hover { color: var(--red); }

/* Add team members list */
.share-add-list { display: flex; flex-direction: column; gap: 6px; }
.share-add-row {
  display: flex; align-items: center; gap: 10px;
}
.share-add-info { flex: 1; min-width: 0; }
.share-add-name { font-size: 13px; font-weight: 500; }
.share-add-role { font-size: 11px; color: var(--muted); }
.btn-add-collab {
  font-size: 12px; font-weight: 500;
  padding: 4px 12px; border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg); color: var(--text);
  cursor: pointer; white-space: nowrap;
  transition: background 0.13s, border-color 0.13s;
}
.btn-add-collab:hover { background: var(--hover-blue); border-color: rgba(0,0,0,0.13); }
.share-add-empty { font-size: 13px; color: var(--muted); padding: 4px 0; }

/* ─── Toast ───────────────────────────────────────────────── */
.toast {
  position: fixed;
  bottom: 28px; left: 50%;
  transform: translateX(-50%) translateY(16px);
  background: rgba(28,28,30,0.86);
  color: #fff; font-size: 13px;
  padding: 7px 18px; border-radius: 20px;
  pointer-events: none; opacity: 0;
  transition: opacity 0.2s, transform 0.2s;
  white-space: nowrap;
  backdrop-filter: blur(14px);
  z-index: 400;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
@media (prefers-color-scheme: dark) {
  .toast { background: rgba(242,242,247,0.14); }
}

/* ═══════════════════════════════════════════════════════════
   MOBILE  (≤ 720px, browser only — the desktop app keeps two panes)
   Two screens: the menu (sidebar) and a page (main), joined by a
   back arrow. A "+" pinned bottom-right adds things.
   ═══════════════════════════════════════════════════════════ */

/* Mobile-only pieces are invisible everywhere else */
.m-back, .m-menu-heading, .m-fab, .m-menu, .m-sheet, .m-backdrop, .m-title-icon { display: none; }
.m-back[hidden], .m-fab[hidden], .m-menu[hidden], .m-sheet[hidden], .m-backdrop[hidden] { display: none !important; }

@media (max-width: 720px) {
  html:not(.is-desktop) body { overscroll-behavior: none; }
  html:not(.is-desktop) .app { position: relative; height: 100vh; height: 100dvh; }
  html:not(.is-desktop) .sb-resize-handle { display: none; }

  /* ── The two screens, stacked and slid like a navigation stack ── */
  html:not(.is-desktop) .sidebar,
  html:not(.is-desktop) .sidebar.collapsed {
    position: absolute; inset: 0; width: 100% !important; z-index: 1;
    padding-top: env(safe-area-inset-top);
    transition: transform 0.32s cubic-bezier(0.32, 0.72, 0, 1), visibility 0s;
  }
  html:not(.is-desktop) .sidebar > * { width: 100%; }
  html:not(.is-desktop) .main {
    position: absolute; inset: 0; z-index: 2; background: var(--bg);
    transition: transform 0.32s cubic-bezier(0.32, 0.72, 0, 1), visibility 0s;
    box-shadow: -10px 0 30px rgba(0,0,0,0.10);
  }
  html:not(.is-desktop) .app[data-screen="content"] .sidebar {
    transform: translateX(-26%); visibility: hidden;
    transition: transform 0.32s cubic-bezier(0.32, 0.72, 0, 1), visibility 0s 0.32s;
  }
  html:not(.is-desktop) .app[data-screen="menu"] .main {
    transform: translateX(100%); visibility: hidden;
    transition: transform 0.32s cubic-bezier(0.32, 0.72, 0, 1), visibility 0s 0.32s;
  }
  @media (prefers-reduced-motion: reduce) {
    html:not(.is-desktop) .sidebar, html:not(.is-desktop) .main { transition: none !important; }
  }

  /* ── Menu screen ── */
  html:not(.is-desktop) .sidebar-footer {
    order: -1; border-top: none; border-bottom: 0.5px solid var(--border);
    padding: 12px 16px 10px;
  }
  html:not(.is-desktop) .m-menu-heading { display: block; font-size: 26px; font-weight: 700; letter-spacing: -0.5px; }
  html:not(.is-desktop) .btn-new-list { display: none; }
  html:not(.is-desktop) .btn-avatar { width: 36px; height: 36px; }
  html:not(.is-desktop) .sidebar-scroll { padding: 8px 0 calc(110px + env(safe-area-inset-bottom)); -webkit-overflow-scrolling: touch; }

  html:not(.is-desktop) .nav-item { padding: 11px 14px; margin: 1px 8px; font-size: 17px; border-radius: 10px; }
  html:not(.is-desktop) .nav-icon svg { width: 26px; height: 26px; }
  html:not(.is-desktop) .sb-divider { margin: 8px 16px; }

  /* Areas are separated by dividers; an area and its projects are one unit with none */
  html:not(.is-desktop) .area-drop-zone { display: none; }
  html:not(.is-desktop) .area-block { margin-top: 0; }
  html:not(.is-desktop) .area-block + .area-block::before {
    content: ''; display: block; height: 0.5px; background: var(--border); margin: 8px 16px 10px;
  }
  html:not(.is-desktop) .area-header { padding: 10px 14px; margin: 1px 8px; font-size: 16px; font-weight: 600; border-radius: 10px; }
  html:not(.is-desktop) .proj-list { padding: 0 8px 2px 26px; }
  html:not(.is-desktop) .proj-row { padding: 10px 12px; font-size: 16px; border-radius: 10px; }
  html:not(.is-desktop) .nav-item, html:not(.is-desktop) .proj-row, html:not(.is-desktop) .area-header,
  html:not(.is-desktop) .task-row { -webkit-touch-callout: none; -webkit-user-select: none; user-select: none; }

  /* ── Page screen ── */
  html:not(.is-desktop) .main-header { padding: calc(env(safe-area-inset-top) + 12px) 12px 0 6px; align-items: center; gap: 2px; }
  html:not(.is-desktop) .m-back {
    display: flex; align-items: center; justify-content: center; flex-shrink: 0;
    width: 44px; height: 44px; margin-right: 0; border: none; background: none;
    color: var(--blue); border-radius: 12px; cursor: pointer; -webkit-tap-highlight-color: transparent;
  }
  html:not(.is-desktop) .m-back:active { background: var(--hover-blue); }
  html:not(.is-desktop) .header-left { flex: 1; min-width: 0; }
  html:not(.is-desktop) .main-title { font-size: 26px; }
  html:not(.is-desktop) .proj-sub { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  html:not(.is-desktop) .quick-add-wrap { display: none !important; }   /* the "+" replaces it */
  html:not(.is-desktop) .task-list { padding: 8px 10px calc(110px + env(safe-area-inset-bottom)); -webkit-overflow-scrolling: touch; }
  html:not(.is-desktop) .task-row { padding-top: 11px; padding-bottom: 11px; }
  html:not(.is-desktop) .task-date-btn { opacity: 0.4; }
  html:not(.is-desktop) .m-title-icon { display: flex; flex-shrink: 0; width: 28px; height: 28px; }
  html:not(.is-desktop) .m-title-icon svg { width: 28px; height: 28px; }
  html:not(.is-desktop) .toast { bottom: calc(92px + env(safe-area-inset-bottom)); max-width: calc(100vw - 32px); white-space: normal; text-align: center; }
  html:not(.is-desktop) .modal { max-width: 94vw; }
  html:not(.is-desktop) input, html:not(.is-desktop) select { font-size: 16px; }   /* stops iOS zooming into fields */

  /* ── The "+" call to action, bottom-right ── */
  html:not(.is-desktop) .m-fab {
    position: fixed; z-index: 60; right: 16px; bottom: calc(16px + env(safe-area-inset-bottom));
    display: flex; align-items: center; justify-content: center; gap: 8px;
    height: 56px; min-width: 56px; padding: 0; border: none; border-radius: 28px;
    background: var(--blue); color: #fff; cursor: pointer; -webkit-tap-highlight-color: transparent;
    box-shadow: 0 8px 22px rgba(0,122,255,0.38), 0 2px 6px rgba(0,0,0,0.18);
    transition: transform 0.12s, padding 0.2s, box-shadow 0.2s;
  }
  html:not(.is-desktop) .m-fab:active { transform: scale(0.95); }
  html:not(.is-desktop) .m-fab-plus { transition: transform 0.22s cubic-bezier(0.34, 1.56, 0.64, 1); flex-shrink: 0; }
  html:not(.is-desktop) .m-fab[aria-expanded="true"] .m-fab-plus { transform: rotate(45deg); }
  /* Menu screen: label + caret tell you a menu opens, instead of a single action */
  html:not(.is-desktop) .m-fab .m-fab-label, html:not(.is-desktop) .m-fab .m-fab-caret { display: none; }
  html:not(.is-desktop) .m-fab.is-menu { padding: 0 18px 0 16px; }
  html:not(.is-desktop) .m-fab.is-menu .m-fab-label { display: inline; font-size: 17px; font-weight: 600; letter-spacing: -0.2px; }
  html:not(.is-desktop) .m-fab.is-menu .m-fab-caret { display: block; opacity: 0.85; transition: transform 0.2s; }
  html:not(.is-desktop) .m-fab.is-menu[aria-expanded="true"] .m-fab-caret { transform: rotate(180deg); }


  /* Create menu: three options, each with a short description */
  html:not(.is-desktop) .m-menu {
    display: block; position: fixed; z-index: 55; right: 16px;
    bottom: calc(16px + 56px + 12px + env(safe-area-inset-bottom));
    width: min(340px, calc(100vw - 32px)); padding: 6px;
    background: var(--menu-bg); border: 1px solid var(--menu-border); border-radius: 18px;
    box-shadow: 0 16px 40px rgba(0,0,0,0.22); transform-origin: bottom right;
    animation: mPop 0.2s cubic-bezier(0.34, 1.4, 0.64, 1);
  }
  @keyframes mPop { from { opacity: 0; transform: scale(0.9) translateY(8px); } to { opacity: 1; transform: none; } }
  html:not(.is-desktop) .m-menu-item {
    display: flex; align-items: flex-start; gap: 12px; width: 100%; padding: 12px; text-align: left;
    border: none; background: none; color: var(--text); font: inherit; border-radius: 12px; cursor: pointer;
    -webkit-tap-highlight-color: transparent;
  }
  html:not(.is-desktop) .m-menu-item + .m-menu-item { margin-top: 2px; }
  html:not(.is-desktop) .m-menu-item:active, html:not(.is-desktop) .m-menu-item:focus-visible { background: var(--hover-blue); outline: none; }
  html:not(.is-desktop) .m-menu-ico { width: 38px; height: 38px; border-radius: 11px; flex-shrink: 0; display: flex; align-items: center; justify-content: center; }
  html:not(.is-desktop) .m-menu-ico.todo    { background: rgba(0,122,255,0.14);  color: var(--blue); }
  html:not(.is-desktop) .m-menu-ico.project { background: rgba(52,199,89,0.16);  color: var(--check); }
  html:not(.is-desktop) .m-menu-ico.area    { background: rgba(255,149,0,0.16);  color: var(--orange); }
  html:not(.is-desktop) .m-menu-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
  html:not(.is-desktop) .m-menu-title { font-size: 16px; font-weight: 600; }
  html:not(.is-desktop) .m-menu-desc { font-size: 12.5px; line-height: 1.35; color: var(--muted); }

}

/* ── Mobile: readable text and thumb-sized targets ──────────
   Body text 16–17px (iOS default is 17), secondary text never below 13px,
   every tap target at least 44px. */
@media (max-width: 720px) {
  /* Menu */
  html:not(.is-desktop) .nav-label  { font-size: 17px; }
  html:not(.is-desktop) .nc         { font-size: 16px; }
  html:not(.is-desktop) .area-label { font-size: 16px; font-weight: 600; }
  html:not(.is-desktop) .proj-name  { font-size: 16px; }
  html:not(.is-desktop) .shared-pip { font-size: 12px; padding: 2px 7px; }
  html:not(.is-desktop) .nav-item, html:not(.is-desktop) .area-header, html:not(.is-desktop) .proj-row { min-height: 44px; }
  html:not(.is-desktop) .area-header, html:not(.is-desktop) .proj-row { align-items: center; }

  /* Page header */
  html:not(.is-desktop) .proj-sub { font-size: 14px; }

  /* To-do list */
  html:not(.is-desktop) .task-group-header { font-size: 15px; padding: 16px 6px 6px; }
  html:not(.is-desktop) .heading-name      { font-size: 16px; }
  html:not(.is-desktop) .task-row          { gap: 14px; padding: 10px 6px; align-items: flex-start; }
  html:not(.is-desktop) .task-name         { font-size: 17px; line-height: 1.35; }
  html:not(.is-desktop) .task-meta         { gap: 8px; margin-top: 3px; }
  html:not(.is-desktop) .tag               { font-size: 13px; }
  html:not(.is-desktop) .tag-label         { padding: 2px 9px; }
  html:not(.is-desktop) .task-av           { width: 28px; height: 28px; font-size: 10px; margin-top: 0; }
  html:not(.is-desktop) .empty-state p     { font-size: 16px; }
  html:not(.is-desktop) .area-proj-name    { font-size: 17px; }
  html:not(.is-desktop) .area-proj-meta    { font-size: 14px; }

  /* Checkbox: bigger, with an invisible 44px hit area */
  html:not(.is-desktop) .check { position: relative; width: 26px; height: 26px; border-radius: 8px; margin-top: 0; }
  html:not(.is-desktop) .check::before { content: ''; position: absolute; inset: -9px; }
  html:not(.is-desktop) .check.done::after { width: 6px; height: 11px; border-width: 2px; }

  /* The calendar button used to sit right beside the checkbox and caught its taps.
     It stays in the page (the "Set Due Date…" item in the long-press menu opens its picker) but cannot be tapped. */
  html:not(.is-desktop) .task-date-btn {
    position: absolute; width: 1px; height: 1px; margin: 0; overflow: hidden;
    opacity: 0; pointer-events: none;
  }

  /* Long-press menu */
  html:not(.is-desktop) .ctx-menu { min-width: 240px; padding: 6px; }
  html:not(.is-desktop) .ctx-item { padding: 12px 14px; font-size: 16px; }
}

/* ── To-do action sheet and swipe-to-open: phones and any touch device ───────── */
@media (max-width: 720px), (pointer: coarse) {
  html:not(.is-desktop) .m-task-sheet { max-height: 86vh; max-height: 86dvh; overflow-y: auto; -webkit-overflow-scrolling: touch; }
  html:not(.is-desktop) .m-task-sheet .m-sheet-head h2 { font-size: 18px; font-weight: 600; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; padding-right: 12px; }
  html:not(.is-desktop) .m-task-body { padding-bottom: 4px; }

  html:not(.is-desktop) .m-act {
    position: relative; display: flex; align-items: center; gap: 14px; width: 100%; min-height: 52px; padding: 8px 2px;
    background: none; border: none; border-bottom: 0.5px solid var(--border); color: var(--text);
    font: inherit; font-size: 17px; text-align: left; cursor: pointer; -webkit-tap-highlight-color: transparent;
  }
  html:not(.is-desktop) .m-act:active { background: var(--hover-blue); }
  html:not(.is-desktop) .m-act-ico { width: 26px; height: 26px; flex-shrink: 0; display: flex; align-items: center; justify-content: center; color: var(--muted); }
  html:not(.is-desktop) .m-act-ico svg { width: 24px; height: 24px; }
  html:not(.is-desktop) .m-act-label { flex: 1; min-width: 0; }
  html:not(.is-desktop) .m-act-val { max-width: 45%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 15px; color: var(--muted); }
  html:not(.is-desktop) .m-act-chev { width: 8px; height: 14px; color: var(--muted); flex-shrink: 0; margin-left: -4px; }
  html:not(.is-desktop) .m-act.has-sub::after { content: '›'; font-size: 24px; color: var(--muted); margin-left: -6px; line-height: 1; }
  html:not(.is-desktop) .m-act.danger, html:not(.is-desktop) .m-act.danger .m-act-ico { color: var(--red); }
  html:not(.is-desktop) .m-act-section { font-size: 13px; font-weight: 600; letter-spacing: 0.3px; text-transform: uppercase; color: var(--muted); padding: 16px 2px 8px; }

  /* "When": four big choices */
  html:not(.is-desktop) .m-when { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; padding-bottom: 12px; border-bottom: 0.5px solid var(--border); }
  html:not(.is-desktop) .m-when-btn {
    display: flex; align-items: center; gap: 10px; min-height: 48px; padding: 0 14px;
    background: var(--bg); border: 1.5px solid var(--border); border-radius: 12px; color: var(--text);
    font: inherit; font-size: 16px; font-weight: 500; cursor: pointer; -webkit-tap-highlight-color: transparent;
  }
  html:not(.is-desktop) .m-when-btn.is-current { border-color: var(--blue); background: var(--blue-bg); }
  html:not(.is-desktop) .m-when-dot { width: 12px; height: 12px; border-radius: 50%; flex-shrink: 0; }

  /* The date control sits invisibly over its row so a tap opens the phone's own picker */
  html:not(.is-desktop) .m-act-date input[type="date"] { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; border: 0; padding: 0; font-size: 16px; }

  html:not(.is-desktop) .m-sub-head { display: flex; align-items: center; gap: 6px; font-size: 17px; font-weight: 600; padding: 0 0 6px; }
  html:not(.is-desktop) .m-sub-back { width: 44px; height: 44px; margin-left: -10px; display: flex; align-items: center; justify-content: center; background: none; border: none; color: var(--blue); cursor: pointer; }
  html:not(.is-desktop) .m-avatar { width: 28px; height: 28px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 11px; font-weight: 600; color: #fff; }
  html:not(.is-desktop) .m-tag-form { display: flex; flex-direction: column; gap: 4px; padding-top: 6px; }

  /* Swiping a to-do left: its content slides over a hint that arms at the threshold */
  html:not(.is-desktop) .task-row { touch-action: pan-y; }
  html:not(.is-desktop) .task-row.m-swiping { overflow: hidden; background: var(--blue-bg); }
  html:not(.is-desktop) .task-row.m-swiping > * { transform: translateX(calc(-1 * var(--swipe, 0px))); }
  html:not(.is-desktop) .task-row.m-swipe-release > * { transition: transform 0.22s cubic-bezier(0.32, 0.72, 0, 1); }
  html:not(.is-desktop) .task-row.m-swiping::before {
    content: '•••'; position: absolute; right: 20px; top: 50%; transform: translateY(-50%);
    font-size: 11px; font-weight: 600; letter-spacing: 1px; color: var(--blue); opacity: 0.5; transition: opacity 0.15s, transform 0.15s;
  }
  html:not(.is-desktop) .task-row.m-swiping.m-armed::before { opacity: 1; transform: translateY(-50%) scale(1.15); }
}


/* ── Bottom sheets: any touch device (phones, and iPads at any width) ── */
@media (max-width: 720px), (pointer: coarse) {
  html:not(.is-desktop) .m-backdrop { display: block; position: fixed; inset: 0; z-index: 50; background: rgba(0,0,0,0.30); animation: fadeIn 0.18s ease; }

  /* Create sheet */
  html:not(.is-desktop) .m-sheet {
    display: block; position: fixed; z-index: 70; left: 0; right: 0; bottom: 0;
    background: var(--menu-bg); border-radius: 22px 22px 0 0; padding: 8px 18px calc(18px + env(safe-area-inset-bottom));
    box-shadow: 0 -10px 40px rgba(0,0,0,0.22); animation: mSheetUp 0.26s cubic-bezier(0.32, 0.72, 0, 1);
  }
  @keyframes mSheetUp { from { transform: translateY(40px); opacity: 0; } to { transform: none; opacity: 1; } }
  html:not(.is-desktop) .m-sheet-grab { width: 38px; height: 4px; border-radius: 2px; background: var(--border); margin: 0 auto 10px; }
  html:not(.is-desktop) .m-sheet-head { display: flex; align-items: center; justify-content: space-between; }
  html:not(.is-desktop) .m-sheet-head h2 { font-size: 20px; font-weight: 700; letter-spacing: -0.3px; }
  html:not(.is-desktop) .m-sheet-close { width: 30px; height: 30px; border: none; border-radius: 50%; background: var(--hover); color: var(--muted); font-size: 13px; cursor: pointer; }
  html:not(.is-desktop) .m-sheet-desc { font-size: 13px; color: var(--muted); margin: 2px 0 14px; }
  html:not(.is-desktop) .m-sheet-input {
    width: 100%; padding: 13px 14px; font: inherit; font-size: 17px; color: var(--text);
    background: var(--bg); border: 1px solid var(--border); border-radius: 12px; outline: none;
  }
  html:not(.is-desktop) .m-sheet-input:focus { border-color: var(--blue); box-shadow: 0 0 0 3px var(--blue-bg); }
  html:not(.is-desktop) .m-sheet-field { display: flex; align-items: center; gap: 10px; margin-top: 12px; font-size: 14px; color: var(--muted); }
  html:not(.is-desktop) .m-sheet-field[hidden] { display: none; }
  html:not(.is-desktop) .m-sheet-field select {
    flex: 1; min-width: 0; padding: 10px 12px; font: inherit; color: var(--text);
    background: var(--bg); border: 1px solid var(--border); border-radius: 10px;
  }
  html:not(.is-desktop) .m-sheet-submit {
    width: 100%; margin-top: 16px; padding: 14px; border: none; border-radius: 12px;
    background: var(--blue); color: #fff; font: inherit; font-size: 17px; font-weight: 600; cursor: pointer;
  }
  html:not(.is-desktop) .m-sheet-submit:disabled { opacity: 0.4; cursor: default; }
}

/* ── Tablets with touch (iPad): keep two panes, add finger-sized targets ── */
@media (min-width: 721px) and (pointer: coarse) {
  html:not(.is-desktop) .m-task-sheet,
  html:not(.is-desktop) .m-sheet { left: 0; right: 0; margin: 0 auto; width: min(560px, 100%); border-radius: 22px 22px 0 0; }
  html:not(.is-desktop) .m-task-sheet { max-height: 80vh; max-height: 80dvh; }

  html:not(.is-desktop) .task-row { gap: 14px; padding: 10px 8px; -webkit-touch-callout: none; -webkit-user-select: none; user-select: none; }
  html:not(.is-desktop) .check { position: relative; width: 24px; height: 24px; border-radius: 7px; margin-top: 1px; }
  html:not(.is-desktop) .check::before { content: ''; position: absolute; inset: -10px; }
  html:not(.is-desktop) .check.done::after { width: 5px; height: 10px; border-width: 2px; }
  html:not(.is-desktop) .task-name { font-size: 16px; }
  html:not(.is-desktop) .tag { font-size: 12.5px; }
  /* the hover-only calendar button cannot be used by touch; "Due date" lives in the action sheet */
  html:not(.is-desktop) .task-date-btn { position: absolute; width: 1px; height: 1px; overflow: hidden; opacity: 0; pointer-events: none; }

  html:not(.is-desktop) .nav-item { padding-top: 8px; padding-bottom: 8px; }
  html:not(.is-desktop) .area-header, html:not(.is-desktop) .proj-row { min-height: 40px; display: flex; align-items: center; }
  html:not(.is-desktop) .btn-new-list { padding: 10px 12px; font-size: 14px; }
  html:not(.is-desktop) .btn-avatar { width: 36px; height: 36px; }
  html:not(.is-desktop) .sidebar-footer { padding-top: 10px; }
}

/* ── Mobile: finger-tracking swipe from the left edge back to the menu ── */
@media (max-width: 720px) {
  html:not(.is-desktop) { overscroll-behavior-x: none; }
  html:not(.is-desktop) .app.m-edge-dragging .main {
    transform: translateX(calc(var(--edge, 0) * 100%)); visibility: visible; transition: none !important;
    box-shadow: -14px 0 32px rgba(0,0,0,0.16);
  }
  html:not(.is-desktop) .app.m-edge-dragging .sidebar {
    transform: translateX(calc(-26% * (1 - var(--edge, 0)))); visibility: visible; transition: none !important;
  }
}

/* ── Calendar (due dates) ─────────────────────────────────── */
.dp { width: 100%; user-select: none; -webkit-user-select: none; }
.dp-quick { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 12px; }
.dp-quick button {
  padding: 6px 12px; font: inherit; font-size: 13px; font-weight: 500; color: var(--blue);
  background: var(--blue-bg); border: none; border-radius: 999px; cursor: pointer;
}
.dp-quick button:hover { filter: brightness(0.96); }
.dp-quick .dp-clear { color: var(--red); background: rgba(255,59,48,0.10); margin-left: auto; }
.dp-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.dp-title { font-size: 14px; font-weight: 600; }
.dp-nav {
  width: 30px; height: 30px; font-size: 20px; line-height: 1; color: var(--muted);
  background: none; border: none; border-radius: 50%; cursor: pointer;
}
.dp-nav:hover { background: var(--hover-blue); color: var(--text); }
.dp-weekdays, .dp-grid { display: grid; grid-template-columns: repeat(7, 1fr); }
.dp-weekdays span { text-align: center; font-size: 11px; font-weight: 500; color: var(--muted); padding: 4px 0; }
.dp-day {
  height: 34px; font: inherit; font-size: 14px; color: var(--text); background: none; border: none;
  border-radius: 50%; cursor: pointer; transition: background 0.12s;
}
.dp-day:hover { background: var(--hover-blue); }
.dp-day.is-out { color: var(--muted); opacity: 0.55; }
.dp-day.is-today { color: var(--blue); font-weight: 700; }
.dp-day.is-selected { background: var(--blue); color: #fff; font-weight: 600; opacity: 1; }
.dp-popover {
  position: fixed; z-index: 700; width: 292px; padding: 14px;
  background: var(--menu-bg); border: 1px solid var(--menu-border); border-radius: 14px; box-shadow: var(--menu-shadow);
  animation: popIn 0.14s cubic-bezier(0.34, 1.56, 0.64, 1);
}
@media (max-width: 720px), (pointer: coarse) {
  .dp-quick button { padding: 9px 14px; font-size: 15px; }
  .dp-title { font-size: 17px; }
  .dp-nav { width: 44px; height: 44px; font-size: 26px; }
  .dp-weekdays span { font-size: 12px; }
  .dp-day { height: 44px; font-size: 17px; }
}

/* ── Today & other cross-project lists: Area → Project ── */
.task-group-area {
  font-size: 11px; font-weight: 600; letter-spacing: 0.6px; text-transform: uppercase; color: var(--muted);
  padding: 14px 8px 0;
}
.task-group-area + .task-group-header { padding-top: 4px; }
@media (max-width: 720px) {
  html:not(.is-desktop) .task-group-area { font-size: 12px; padding: 18px 6px 0; }
}

/* ── Adding to-dos in place ───────────────────────────────── */
.header-tools { display: flex; align-items: center; gap: 10px; }
.btn-add-todo {
  width: 28px; height: 28px; border: none; border-radius: 50%; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  background: var(--blue-bg); color: var(--blue); transition: background 0.15s, color 0.15s, transform 0.12s;
}
.btn-add-todo:hover { background: var(--blue); color: #fff; }
.btn-add-todo:active { transform: scale(0.92); }
.btn-add-todo[hidden] { display: none; }

/* the small "+" that appears under a to-do on hover */
.row-add {
  position: absolute; left: 50%; bottom: -11px; z-index: 4;
  width: 22px; height: 22px; padding: 0; border: none; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: var(--blue); color: #fff; cursor: pointer;
  box-shadow: 0 2px 8px rgba(0,122,255,0.35);
  opacity: 0; pointer-events: none; transform: translateX(-50%) scale(0.8);
  transition: opacity 0.12s, transform 0.14s cubic-bezier(0.34, 1.56, 0.64, 1);
}
#taskList[data-add="1"] .task-row:hover .row-add { opacity: 1; pointer-events: auto; transform: translateX(-50%) scale(1); }
.row-add:hover { transform: translateX(-50%) scale(1.12) !important; }
.task-row-new .row-add { display: none; }

/* the new line being typed */
.task-row-new { align-items: center; overflow: hidden; background: var(--hover-blue); animation: newRowIn 0.2s ease-out; }
.task-row-new .check { border-style: dashed; opacity: 0.55; pointer-events: none; margin-top: 0; }
.task-row-new .task-body { flex: 1; min-width: 0; }
.task-new-input {
  width: 100%; padding: 2px 0; border: none; outline: none; background: transparent;
  font: inherit; font-size: 14px; line-height: 1.45; color: var(--text);
}
.task-new-input::placeholder { color: var(--muted); }
@keyframes newRowIn { from { max-height: 0; opacity: 0; } to { max-height: 56px; opacity: 1; } }

/* ── Empty pages: a calm call-to-action in the middle ── */
.empty-state { height: 100%; min-height: 260px; gap: 4px; animation: emptyIn 0.35s ease both; }   /* fills the page, so it sits in the middle */
.empty-state:has(+ .btn-add-heading) { height: calc(100% - 44px); }
.empty-ring { width: 56px; height: 56px; margin-bottom: 10px; border: 2px dashed var(--muted); border-radius: 50%; opacity: 0.35; }
.empty-state p { font-size: 15px; color: var(--muted); }
.empty-cta {
  display: inline-flex; align-items: center; gap: 8px; margin-top: 16px; padding: 9px 18px;
  border: none; border-radius: 999px; cursor: pointer; font: inherit; font-size: 14px; font-weight: 600;
  background: var(--blue); color: #fff; box-shadow: 0 6px 16px rgba(0,122,255,0.28);
  transition: transform 0.16s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.2s;
}
.empty-cta:hover { transform: translateY(-1px) scale(1.03); box-shadow: 0 10px 22px rgba(0,122,255,0.34); }
.empty-cta:active { transform: scale(0.97); }
.empty-cta:focus-visible { outline: 3px solid var(--blue-bg); outline-offset: 3px; }
@keyframes emptyIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .empty-state, .task-row-new { animation: none; } .empty-cta, .row-add { transition: none; } }

/* touch screens have no hover: the "+" button (phones) and the header "+" (iPad) take over */
@media (hover: none), (max-width: 720px) { .row-add { display: none !important; } }
@media (max-width: 720px) {
  html:not(.is-desktop) .btn-add-todo { display: none; }
  html:not(.is-desktop) .task-new-input { font-size: 17px; }
  html:not(.is-desktop) .empty-state p { font-size: 16px; }
  html:not(.is-desktop) .empty-cta { font-size: 17px; padding: 13px 24px; }
}
@media (min-width: 721px) and (pointer: coarse) {
  html:not(.is-desktop) .btn-add-todo { width: 36px; height: 36px; }
  html:not(.is-desktop) .task-new-input { font-size: 16px; }
}

/* ── Settings: privacy toggle and help links ── */
.settings-toggle { display: flex; align-items: center; gap: 14px; cursor: pointer; }
.settings-toggle[hidden] { display: none; }
.settings-toggle-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.settings-toggle-title { font-size: 14px; }
.settings-toggle-sub { font-size: 12px; color: var(--muted); line-height: 1.4; }
.switch {
  appearance: none; -webkit-appearance: none; flex-shrink: 0; margin: 0;
  width: 42px; height: 26px; border-radius: 13px; position: relative; cursor: pointer;
  background: rgba(120,120,128,0.32); transition: background 0.2s;
}
.switch::after {
  content: ''; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,0.25); transition: transform 0.2s;
}
.switch:checked { background: var(--blue); }
.switch:checked::after { transform: translateX(16px); }
.switch:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }
.settings-links { display: flex; flex-wrap: wrap; gap: 8px 18px; margin-top: 14px; font-size: 13px; }
.settings-links a { color: var(--blue); text-decoration: none; }
.settings-links a:hover { text-decoration: underline; }
.settings-links a[hidden] { display: none; }

/* ── Settings: plan ── */
.plan-current { padding: 10px 12px; margin-bottom: 10px; border-radius: 10px; background: var(--blue-bg); }
.plan-current-name { font-size: 15px; font-weight: 600; color: var(--blue); }
.plan-current-usage { font-size: 12px; color: var(--muted); margin-top: 2px; line-height: 1.4; }
.plan-row { cursor: default; }
.plan-row:hover { border-color: var(--border); }
.plan-row.is-current, .plan-row.is-current:hover { border-color: var(--blue); }
.plan-opt-price { font-size: 13px; font-weight: 600; color: var(--text); margin-left: 4px; }
.plan-opt-price span { font-weight: 400; color: var(--muted); font-size: 12px; }
.plan-opt-btn {
  flex-shrink: 0; font-size: 12px; font-weight: 600; color: #fff; background: var(--blue);
  padding: 5px 12px; border-radius: 14px; text-decoration: none; white-space: nowrap;
}
.plan-opt-soon { flex-shrink: 0; font-size: 11px; color: var(--muted); white-space: nowrap; }

/* ── Team: people manager and activity log ── */
.team-actions { display: flex; gap: 8px; }
.team-actions .btn-manage { margin-top: 0; }
.team-modal { width: 560px; }
.team-tabs { display: flex; gap: 4px; padding: 0 20px; }
.team-tabs button {
  flex: 1; padding: 7px; border: none; border-radius: 8px; background: none; color: var(--muted);
  font: inherit; font-size: 13px; font-weight: 600; cursor: pointer;
}
.team-tabs button[aria-selected="true"] { background: var(--bg); color: var(--text); box-shadow: var(--shadow); }
.team-body { min-height: 160px; }
.team-count { font-size: 12px; color: var(--muted); margin-bottom: 8px; }
.team-empty { font-size: 13px; color: var(--muted); padding: 12px 0; line-height: 1.5; }
.team-row { display: flex; align-items: center; gap: 10px; padding: 9px 0; border-bottom: 0.5px solid var(--border); }
.team-row-main { flex: 1; min-width: 0; }
.team-row-name { font-size: 14px; }
.team-row-sub { font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.team-remove {
  flex-shrink: 0; background: none; border: 1px solid var(--border); border-radius: 7px; padding: 4px 10px;
  font: inherit; font-size: 12px; color: var(--red); cursor: pointer;
}
.team-remove:hover { background: var(--hover); }
.activity-row { display: flex; gap: 12px; align-items: baseline; padding: 8px 0; border-bottom: 0.5px solid var(--border); font-size: 13px; line-height: 1.45; }
.activity-text { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.activity-time { flex-shrink: 0; font-size: 12px; color: var(--muted); white-space: nowrap; }

/* ── Plan limits elsewhere ── */
.share-plan-note { font-size: 12px; line-height: 1.4; color: var(--orange); margin-top: 8px; }
.share-plan-note[hidden] { display: none; }
.ctx-item.ctx-disabled { color: var(--muted); cursor: default; }
.ctx-item.ctx-disabled:hover { background: none; }
.m-act-note { font-size: 15px; color: var(--muted); padding: 14px 2px; }
