:root {
  --bg: #f5f3f0;
  --bg-alt: #eae7e2;
  --bg-card: #ffffff;
  --bg-input: #f5f3f0;
  --text: #1a1a1a;
  --text-secondary: #6b6560;
  --text-tertiary: #9e9892;
  --border: #ddd8d2;
  --border-light: #eae7e2;
  --accent: #7c3aed;
  --accent-light: rgba(124,58,237,0.1);
  --accent-hover: #6d28d9;
  --on-accent: #fff;
  --green: #3a8a5c;
  --green-light: rgba(58,138,92,0.12);
  --red: #c0392b;
  --red-light: rgba(192,57,43,0.1);
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.06);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.08);
  --shadow-lg: 0 8px 30px rgba(0,0,0,0.12);
  --radius: 10px;
  --radius-sm: 6px;
  --radius-lg: 14px;
  --font: 'DM Sans', -apple-system, sans-serif;
  --font-display: 'Outfit', 'DM Sans', -apple-system, sans-serif;
  --today-highlight: rgba(89, 42, 192, 0.06);
  --today-border: var(--accent);
  --completed-text: var(--text-tertiary);
  --drag-bg: rgba(192,88,42,0.04);
  --tag-bg: #eae7e2;
  --tag-text: #6b6560;
  --note-yellow: #fef3c7;
  --note-green: #d1fae5;
  --note-blue: #dbeafe;
  --note-pink: #fce7f3;
  --note-purple: #ede9fe;
  --note-orange: #ffedd5;
  --note-red: #fee2e2;
  --note-gray: #f1f0ee;
  --overlay: rgba(0,0,0,0.3);
  --scrollbar-thumb: #ccc7c0;
  --scrollbar-track: transparent;
}

[data-theme="dark"] {
  --bg: #151515;
  --bg-alt: #1e1e1e;
  --bg-card: #222222;
  --bg-input: #1e1e1e;
  --text: #e8e4e0;
  --text-secondary: #9e9892;
  --text-tertiary: #6b6560;
  --border: #333;
  --border-light: #2a2a2a;
  --accent: #8b5cf6;
  --accent-light: rgba(139,92,246,0.12);
  --accent-hover: #a78bfa;
  --on-accent: #fff;
  --green: #4ead75;
  --green-light: rgba(78,173,117,0.15);
  --red: #e74c3c;
  --red-light: rgba(231,76,60,0.15);
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.2);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.3);
  --shadow-lg: 0 8px 30px rgba(0,0,0,0.4);
  --today-highlight: rgba(97, 82, 217, 0.08);
  --drag-bg: rgba(217,122,82,0.06);
  --tag-bg: #2a2a2a;
  --tag-text: #9e9892;
  --note-yellow: #3d3520;
  --note-green: #1a3328;
  --note-blue: #1a2535;
  --note-pink: #35202a;
  --note-purple: #2a2535;
  --note-orange: #352a1a;
  --note-red: #351a1a;
  --note-gray: #2a2a2a;
  --overlay: rgba(0,0,0,0.6);
  --scrollbar-thumb: #444;
}

/* ============================================================
   THEME PALETTES
   Each palette sets mode-independent structure (font, radius)
   plus light — [data-palette]:not([data-theme="dark"]) — and
   dark — [data-palette][data-theme="dark"] — colour sets.
   Anything left unset falls back to :root (light) or the base
   [data-theme="dark"] block above.
   ============================================================ */

/* ---------- CUPERTINO — Apple iOS / macOS ---------- */
[data-palette="cupertino"] {
  --font: -apple-system, BlinkMacSystemFont, 'Inter', 'Helvetica Neue', Arial, sans-serif;
  --font-display: -apple-system, BlinkMacSystemFont, 'Inter', 'Helvetica Neue', Arial, sans-serif;
  --radius: 12px;
  --radius-sm: 8px;
  --radius-lg: 18px;
}
[data-palette="cupertino"]:not([data-theme="dark"]) {
  --bg: #f2f2f7;
  --bg-alt: #e5e5ea;
  --bg-card: #ffffff;
  --bg-input: #ffffff;
  --text: #1c1c1e;
  --text-secondary: #6c6c70;
  --text-tertiary: #aeaeb2;
  --border: #d1d1d6;
  --border-light: #e5e5ea;
  --accent: #007aff;
  --accent-light: rgba(0,122,255,0.10);
  --accent-hover: #0a6ce0;
  --on-accent: #ffffff;
  --green: #2bb14e;
  --green-light: rgba(43,177,78,0.14);
  --red: #ff3b30;
  --red-light: rgba(255,59,48,0.12);
  --today-highlight: rgba(0,122,255,0.06);
  --tag-bg: #e5e5ea;
  --tag-text: #6c6c70;
  --scrollbar-thumb: #c7c7cc;
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.06);
  --shadow-md: 0 4px 16px rgba(0,0,0,0.10);
  --shadow-lg: 0 12px 40px rgba(0,0,0,0.16);
}
[data-palette="cupertino"][data-theme="dark"] {
  --bg: #000000;
  --bg-alt: #1c1c1e;
  --bg-card: #1c1c1e;
  --bg-input: #2c2c2e;
  --text: #ffffff;
  --text-secondary: #98989f;
  --text-tertiary: #636366;
  --border: #38383a;
  --border-light: #2c2c2e;
  --accent: #0a84ff;
  --accent-light: rgba(10,132,255,0.20);
  --accent-hover: #409cff;
  --on-accent: #ffffff;
  --green: #30d158;
  --green-light: rgba(48,209,88,0.18);
  --red: #ff453a;
  --red-light: rgba(255,69,58,0.18);
  --today-highlight: rgba(10,132,255,0.12);
  --tag-bg: #2c2c2e;
  --tag-text: #98989f;
  --scrollbar-thumb: #48484a;
}

/* ---------- MATERIAL — Google Material 3 ---------- */
[data-palette="material"] {
  --font: 'Roboto', 'Inter', -apple-system, sans-serif;
  --font-display: 'Roboto', 'Inter', -apple-system, sans-serif;
  --radius: 16px;
  --radius-sm: 10px;
  --radius-lg: 28px;
}
[data-palette="material"]:not([data-theme="dark"]) {
  --bg: #fef7ff;
  --bg-alt: #f3edf7;
  --bg-card: #ffffff;
  --bg-input: #f3edf7;
  --text: #1d1b20;
  --text-secondary: #49454f;
  --text-tertiary: #79747e;
  --border: #cac4d0;
  --border-light: #e7e0ec;
  --accent: #6750a4;
  --accent-light: rgba(103,80,164,0.12);
  --accent-hover: #7965b0;
  --on-accent: #ffffff;
  --green: #2e7d32;
  --green-light: rgba(46,125,50,0.14);
  --red: #b3261e;
  --red-light: rgba(179,38,30,0.12);
  --today-highlight: rgba(103,80,164,0.08);
  --tag-bg: #e8def8;
  --tag-text: #21005d;
  --scrollbar-thumb: #cac4d0;
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.16);
  --shadow-md: 0 2px 6px rgba(0,0,0,0.16);
  --shadow-lg: 0 8px 24px rgba(0,0,0,0.22);
}
[data-palette="material"][data-theme="dark"] {
  --bg: #141218;
  --bg-alt: #1d1b20;
  --bg-card: #211f26;
  --bg-input: #2b2930;
  --text: #e6e0e9;
  --text-secondary: #cac4d0;
  --text-tertiary: #938f99;
  --border: #49454f;
  --border-light: #322f37;
  --accent: #d0bcff;
  --accent-light: rgba(208,188,255,0.16);
  --accent-hover: #e0d0ff;
  --on-accent: #381e72;
  --green: #66bb6a;
  --green-light: rgba(102,187,106,0.16);
  --red: #ef5350;
  --red-light: rgba(239,83,80,0.16);
  --today-highlight: rgba(208,188,255,0.12);
  --tag-bg: #4a4458;
  --tag-text: #e8def8;
  --scrollbar-thumb: #49454f;
}

/* ---------- BANG — fun neubrutalist ---------- */
[data-palette="bang"] {
  --font: 'Sora', 'DM Sans', -apple-system, sans-serif;
  --font-display: 'Sora', 'Outfit', sans-serif;
  --radius: 8px;
  --radius-sm: 6px;
  --radius-lg: 12px;
}
[data-palette="bang"]:not([data-theme="dark"]) {
  --bg: #fdf3df;
  --bg-alt: #ffe6a7;
  --bg-card: #ffffff;
  --bg-input: #ffffff;
  --text: #16120a;
  --text-secondary: #4a4334;
  --text-tertiary: #8a7f63;
  --border: #16120a;
  --border-light: #d8caa0;
  --accent: #ffd400;
  --accent-light: rgba(255,212,0,0.22);
  --accent-hover: #ffc400;
  --on-accent: #16120a;
  --green: #16a34a;
  --green-light: rgba(22,163,74,0.18);
  --red: #ff3b30;
  --red-light: rgba(255,59,48,0.16);
  --today-highlight: rgba(255,212,0,0.16);
  --tag-bg: #16120a;
  --tag-text: #ffd400;
  --scrollbar-thumb: #16120a;
  --shadow-sm: 2px 2px 0 #16120a;
  --shadow-md: 4px 4px 0 #16120a;
  --shadow-lg: 6px 6px 0 #16120a;
}
[data-palette="bang"][data-theme="dark"] {
  --bg: #18141f;
  --bg-alt: #221c2e;
  --bg-card: #262030;
  --bg-input: #1c1726;
  --text: #f7f2ff;
  --text-secondary: #c9bedd;
  --text-tertiary: #8b7fa3;
  --border: #f7f2ff;
  --border-light: #3a3247;
  --accent: #ffe000;
  --accent-light: rgba(255,224,0,0.18);
  --accent-hover: #fff04d;
  --on-accent: #18141f;
  --green: #22c55e;
  --green-light: rgba(34,197,94,0.18);
  --red: #ff6b5e;
  --red-light: rgba(255,107,94,0.18);
  --today-highlight: rgba(255,224,0,0.12);
  --tag-bg: #f7f2ff;
  --tag-text: #18141f;
  --scrollbar-thumb: #f7f2ff;
  --shadow-sm: 2px 2px 0 #000000;
  --shadow-md: 4px 4px 0 #000000;
  --shadow-lg: 6px 6px 0 #000000;
}
/* Bang: chunky outlines + hard offset shadows on key surfaces */
[data-palette="bang"] .modal,
[data-palette="bang"] .note-viewer,
[data-palette="bang"] .search-box,
[data-palette="bang"] .btn,
[data-palette="bang"] input,
[data-palette="bang"] textarea,
[data-palette="bang"] select,
[data-palette="bang"] .note-card,
[data-palette="bang"] .tag,
[data-palette="bang"] .filter-tag-btn,
[data-palette="bang"] .toggle,
[data-palette="bang"] .someday-fab {
  border-width: 2px;
  border-style: solid;
  border-color: var(--border);
}
[data-palette="bang"] .btn { box-shadow: var(--shadow-sm); }
[data-palette="bang"] .btn:active { box-shadow: none; transform: translate(2px,2px); }

/* ---------- TERMINAL — mono, sharp, high-contrast B/W ---------- */
[data-palette="terminal"] {
  --font: ui-monospace, 'SF Mono', 'Cascadia Code', Menlo, Consolas, 'Roboto Mono', monospace;
  --font-display: ui-monospace, 'SF Mono', 'Cascadia Code', Menlo, Consolas, 'Roboto Mono', monospace;
  --radius: 0px;
  --radius-sm: 0px;
  --radius-lg: 0px;
  --shadow-sm: none;
  --shadow-md: 0 0 0 1px var(--border);
  --shadow-lg: 0 0 0 1px var(--border);
}
[data-palette="terminal"]:not([data-theme="dark"]) {
  --bg: #ffffff;
  --bg-alt: #f0f0f0;
  --bg-card: #ffffff;
  --bg-input: #ffffff;
  --text: #000000;
  --text-secondary: #333333;
  --text-tertiary: #666666;
  --border: #000000;
  --border-light: #cccccc;
  --accent: #000000;
  --accent-light: rgba(0,0,0,0.08);
  --accent-hover: #333333;
  --on-accent: #ffffff;
  --green: #1a7f37;
  --green-light: rgba(26,127,55,0.12);
  --red: #cf222e;
  --red-light: rgba(207,34,46,0.10);
  --today-highlight: rgba(0,0,0,0.05);
  --tag-bg: #000000;
  --tag-text: #ffffff;
  --scrollbar-thumb: #000000;
}
[data-palette="terminal"][data-theme="dark"] {
  --bg: #000000;
  --bg-alt: #0d0d0d;
  --bg-card: #000000;
  --bg-input: #0d0d0d;
  --text: #e8e8e8;
  --text-secondary: #b0b0b0;
  --text-tertiary: #777777;
  --border: #4d4d4d;
  --border-light: #262626;
  --accent: #e8e8e8;
  --accent-light: rgba(232,232,232,0.12);
  --accent-hover: #ffffff;
  --on-accent: #000000;
  --green: #3fb950;
  --green-light: rgba(63,185,80,0.14);
  --red: #f85149;
  --red-light: rgba(248,81,73,0.14);
  --today-highlight: rgba(232,232,232,0.07);
  --tag-bg: #e8e8e8;
  --tag-text: #000000;
  --scrollbar-thumb: #4d4d4d;
}
/* Terminal: square off the rounded bits the radius vars can't reach */
[data-palette="terminal"] .toggle,
[data-palette="terminal"] .toggle::after,
[data-palette="terminal"] .task-checkbox,
[data-palette="terminal"] .someday-fab .someday-count {
  border-radius: 0 !important;
}

* { margin:0; padding:0; box-sizing:border-box; }

html { font-size:15px; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  overflow: hidden;
  height: 100dvh;
  -webkit-font-smoothing: antialiased;
}

::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: var(--scrollbar-track); }
::-webkit-scrollbar-thumb { background: var(--scrollbar-thumb); border-radius: 4px; }

button {
  font-family: var(--font);
  cursor: pointer;
  border: none;
  background: none;
  color: var(--text);
  font-size: 1rem;
}

input, textarea, select {
  font-family: var(--font);
  font-size: 0.93rem;
  color: var(--text);
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  outline: none;
  width: 100%;
  transition: border-color .2s;
}
input:focus, textarea:focus, select:focus {
  border-color: var(--accent);
}
textarea { resize: vertical; min-height: 80px; line-height: 1.6; }

/* HEADER */
.header {
  border: 1px solid var(--border);
  background: var(--bg-card);
  flex-shrink: 0;
  z-index: 50;
  position: relative;
  overflow: visible;
  margin-top: 20px;
  margin-left: 20px;
  margin-right: 20px;
  margin-bottom: 20px;
  border-radius: 10px;
}

@media only screen and (min-device-width: 768px) and (max-device-width: 1024px) {
  .header {
    margin-top: 50px;
  }
}

.header-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: calc(12px + env(safe-area-inset-top, 0px)) calc(20px + env(safe-area-inset-right, 0px)) 12px calc(20px + env(safe-area-inset-left, 0px));
  gap: 12px;
}
.header-left { display:flex; align-items:center; gap:14px; min-width:0; }

/* VIEW TABS */
.view-tabs {
  display: flex;
  background: var(--bg-alt);
  border-radius: 8px;
  padding: 5px;
  gap: 2px;
  flex-shrink: 0;
}
.view-tab {
  padding: 10px 14px;
  border-radius: 6px;
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-secondary);
  transition: all .15s;
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: 5px;
}
.view-tab:hover { color: var(--text); }
.view-tab.active {
  background: var(--bg-card);
  color: var(--text);
  box-shadow: var(--shadow-sm);
}
.view-tab svg { width:14px; height:14px; }

.logo {
  font-family: var(--font-display);
  font-size: 1.3rem;
  font-weight: 600;
  color: var(--accent);
  letter-spacing: -0.02em;
  white-space: nowrap;
}
.week-nav { display:flex; align-items:center; gap:4px; flex-shrink:0; position:relative; }
.week-nav button {
  width: 32px; height: 32px;
  flex-shrink: 0;
  display: flex; align-items:center; justify-content:center;
  border-radius: var(--radius-sm);
  transition: background .15s;
  font-size: 1.1rem;
  color: var(--text-secondary);
}
.week-nav button:hover { background: var(--bg-alt); }
.week-label {
  font-size: 1rem;
  font-weight: 500;
  color: var(--text-secondary);
  min-width: 120px;
  flex-shrink: 0;
  text-align: center;
  white-space: nowrap;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  transition: background .15s, color .15s;
}
.week-label:hover { background: var(--bg-alt); color: var(--text); }
.week-picker {
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  margin-top: 6px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  padding: 12px;
  z-index: 200;
  width: 260px;
  user-select: none;
  -webkit-user-select: none;
}
.week-picker-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}
.week-picker-title {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text);
  cursor: pointer;
  padding: 2px 6px;
  border-radius: var(--radius-sm);
  transition: background .15s;
}
.week-picker-title:hover { background: var(--bg-alt); }
.week-picker-nav {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  font-size: 1rem;
  color: var(--text-secondary);
  cursor: pointer;
  transition: background .15s;
}
.week-picker-nav:hover { background: var(--bg-alt); }
.week-picker-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 2px;
  text-align: center;
}
.week-picker-dow {
  font-size: 0.68rem;
  font-weight: 600;
  color: var(--text-tertiary);
  padding: 4px 0;
  text-transform: uppercase;
}
.week-picker-day {
  font-size: 0.78rem;
  padding: 6px 0;
  border-radius: var(--radius-sm);
  cursor: pointer;
  color: var(--text);
  transition: background .1s;
}
.week-picker-day:hover { background: var(--bg-alt); }
.week-picker-day.other-month { color: var(--text-tertiary); }
.week-picker-day.is-today { font-weight: 700; color: var(--accent); }
.week-picker-day.selected { background: var(--accent); color: var(--on-accent); }
.week-picker-day.selected:hover { background: var(--accent-hover); }
.week-picker-months {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 4px;
  text-align: center;
}
.week-picker-month {
  font-size: 0.8rem;
  padding: 10px 0;
  border-radius: var(--radius-sm);
  cursor: pointer;
  color: var(--text);
  transition: background .1s;
}
.week-picker-month:hover { background: var(--bg-alt); }
.week-picker-month.current { font-weight: 700; color: var(--accent); }
.week-picker-month.selected { background: var(--accent); color: var(--on-accent); }
.week-picker-month.selected:hover { background: var(--accent-hover); }
.btn-today {
  font-size: 0.78rem;
  font-weight: 600;
  padding: 5px 14px;
  border-radius: 20px;
  background: var(--accent);
  color: var(--on-accent) !important;
  transition: background .15s;
  white-space: nowrap;
  flex-shrink: 0;
  min-width: fit-content;
}
.btn-today:hover { background: var(--accent-hover); }
.btn-today.hidden { display:none; }
.hidden { display:none !important; }

.header-right { display:flex; align-items:center; gap:6px; }

.header-week-row {
  display: flex;
  justify-content: center;
  padding: 8px calc(14px + env(safe-area-inset-right, 0px)) 10px calc(14px + env(safe-area-inset-left, 0px));
  border-top: 1px solid var(--border-light);
}
.icon-btn {
  width: 34px; height: 34px;
  display: flex; align-items:center; justify-content:center;
  border-radius: var(--radius-sm);
  transition: background .15s;
  color: var(--text-secondary);
  position: relative;
  flex-shrink: 0;
}
.icon-btn:hover { background: var(--bg-alt); }
.icon-btn svg { width:18px; height:18px; }
.icon-btn.active { color: var(--accent); background: var(--accent-light); }

.filter-badge {
  position:absolute; top:4px; right:4px;
  width:7px; height:7px;
  background: var(--accent);
  border-radius: 50%;
  display:none;
}
.icon-btn.active .filter-badge { display:block; }

/* WEEK GRID */
.week-container {
  display: flex;
  flex: 1;
  overflow-x: auto;
  overflow-y: hidden;
  scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch;
  padding-left: env(safe-area-inset-left, 0px);
  padding-right: env(safe-area-inset-right, 0px);
}
.app-layout {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  overflow: hidden;
}

.day-column {
  flex: 1;
  min-width: 340px;
  max-width: none;
  border-right: 1px solid var(--border-light);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  scroll-snap-align: start;
  transition: background .2s;
}
.day-column:last-child { border-right:none; }
// .day-column.is-today { background: var(--today-highlight); }
.day-column.drag-over { background: var(--drag-bg); }

.day-header {
  padding: 12px 14px 8px;
  border-bottom: 1px solid var(--border-light);
  flex-shrink: 0;
  position: sticky;
  top: 0;
  z-index: 5;
}
.day-column.is-today .day-header {
  border-bottom-color: var(--today-border);
}
.day-name {
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-tertiary);
  margin-bottom: 1px;
}
.day-column.is-today .day-name { color: var(--accent); }
.day-date {
  font-family: var(--font-display);
  font-size: 1.3rem;
  color: var(--text);
}
.day-column.is-today .day-date { color: var(--accent); }

.day-content {
  flex: 1;
  overflow-y: auto;
  padding: 6px 8px calc(16px + env(safe-area-inset-bottom, 0px));
}

/* TASKS */
.tasks-section { margin-bottom: 8px; }
.task-item {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 7px 8px;
  border-radius: var(--radius-sm);
  cursor: grab;
  transition: background .1s, opacity .2s;
  position: relative;
  background: transparent;
}
.task-item:active { cursor:grabbing; }
.task-item:hover { background: var(--bg-alt); }
/* Task rows are draggable UI — disable text selection + the iOS selection
   callout so a long-press / resting palm drags (or does nothing) instead of
   selecting the task text. Expanded description content stays selectable. */
.task-item, .someday-task-item {
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}
.task-desc-content {
  -webkit-user-select: text;
  user-select: text;
  -webkit-touch-callout: default;
}
.task-item.dragging { opacity:0.4; }
.task-item.drag-above { box-shadow: 0 -2px 0 0 var(--accent); }
.task-item.drag-below { box-shadow: 0 2px 0 0 var(--accent); }
.task-item.completed .task-text { text-decoration: line-through; color: var(--completed-text); }

.task-checkbox {
  width: 20px; height: 20px;
  border-radius: 50%;
  border: 2px solid var(--border);
  flex-shrink: 0;
  cursor: pointer;
  display: flex;
  align-items:center; justify-content:center;
  transition: all .2s;
  margin-top: 2px;
}
.task-checkbox:hover { border-color: var(--accent); }
.task-item.completed .task-checkbox {
  background: var(--green);
  border-color: var(--green);
}
.task-item.completed .task-checkbox::after {
  content: '\2713';
  color: #fff;
  font-size: 11px;
  font-weight: 700;
}

.task-body { flex:1; min-width:0; }
.task-top-row { display:flex; align-items:center; gap:6px; flex-wrap: wrap; }
.task-text {
  font-size: 1rem;
  font-weight: 400;
  word-break: break-word;
  flex: 1;
  min-width: 0;
}
.task-time {
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--accent);
  white-space: nowrap;
  flex-shrink: 0;
}
.task-recurring-badge {
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--green);
  background: var(--green-light);
  padding: 1px 6px;
  border-radius: 10px;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: 3px;
  flex-shrink: 0;
}
.task-tags { display:flex; gap:4px; flex-wrap:wrap; margin-top:3px; }
.tag {
  font-size: 0.75rem;
  font-weight: 500;
  padding: 1px 7px;
  border-radius: 10px;
  background: var(--tag-bg);
  color: var(--tag-text);
  white-space: nowrap;
}
.task-desc-indicator {
  font-size: 0.75rem;
  color: var(--text-tertiary);
  cursor: pointer;
  margin-top: 2px;
  display: inline-flex;
  align-items:center;
  gap: 3px;
}
.task-desc-indicator:hover { color: var(--accent); }

.task-actions {
  display: flex; gap:2px; opacity:0; transition: opacity .15s; flex-shrink:0;
  position: absolute; right: 8px; top: 5px;
  background: var(--bg-alt);
  border-radius: var(--radius-sm);
  padding: 2px;
}
.task-item:hover .task-actions { opacity:1; }
.task-action-btn {
  width:24px; height:24px;
  display:flex; align-items:center; justify-content:center;
  border-radius: 4px;
  font-size: 0.75rem;
  color: var(--text-tertiary);
  transition: all .1s;
}
.task-action-btn:hover { background: var(--bg-alt); color: var(--text); }

.add-task-btn {
  display: flex;
  align-items:center;
  gap: 6px;
  padding: 7px 8px;
  border-radius: var(--radius-sm);
  font-size: 1rem;
  color: var(--text-tertiary);
  transition: all .15s;
  width: 100%;
}
.add-task-btn:hover { color: var(--accent); background: var(--accent-light); }
.add-task-btn svg { width:14px; height:14px; }

/* NOTES */
.notes-section {
  border-top: 1px dashed var(--border);
  padding-top: 20px;
  margin-top: 40px;
}
.notes-label {
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-tertiary);
  padding: 0 8px 6px;
}
.notes-grid { display:flex; flex-direction:column; gap:5px; }
.note-card {
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  cursor: pointer;
  transition: box-shadow .15s, transform .1s;
  position: relative;
}
.note-card:hover { box-shadow: var(--shadow-sm); }
.note-card.dragging { opacity:0.4; }
/* Note list items (day-column cards + Notes-view cards/rows) are clickable,
   draggable UI — disable selection + the iOS callout so a long-press / resting
   palm opens or drags instead of selecting the title/preview text. The full
   note body stays selectable in the note viewer. */
.note-card, .nv-card, .nv-list-item {
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}
.note-title {
  font-size: 0.9rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.note-preview {
  font-size: 0.73rem;
  color: var(--text-secondary);
  margin-top: 2px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.note-card-tags { margin-top:4px; display:flex; gap:3px; flex-wrap:wrap; }
.note-type-badge, .note-shared-badge {
  display: inline-block;
  font-size: 0.65rem;
  font-weight: 600;
  padding: 1px 6px;
  border-radius: 4px;
  margin-top: 4px;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}
.note-type-badge {
  background: var(--bg-alt);
  color: var(--text-tertiary);
}
.note-shared-badge {
  background: var(--green-light);
  color: var(--green);
}

.add-note-btn {
  display: flex;
  align-items:center;
  gap:6px;
  padding: 6px 8px;
  border-radius: var(--radius-sm);
  font-size: 1rem;
  color: var(--text-tertiary);
  transition: all .15s;
  width: 100%;
}
.add-note-btn:hover { color: var(--accent); background: var(--accent-light); }
.add-note-btn svg { width:13px; height:13px; }

/* MODALS / PANELS */
.modal-overlay {
  position: fixed;
  inset: 0;
  backdrop-filter: blur(3px);
  z-index: 100;
  display: flex;
  align-items:center;
  justify-content:center;
  padding: 20px;
  opacity:0;
  visibility: hidden;
  transition: all .2s;
}
.modal-overlay.open { opacity:1; visibility: visible; }
.modal {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 480px;
  max-height: 85dvh;
  overflow-y: auto;
  transform: translateY(10px);
  transition: transform .2s;
}
.modal-overlay.open .modal { transform: translateY(0); }
.modal-header {
  display:flex; align-items:center; justify-content:space-between;
  padding: 16px 20px 12px;
  border-bottom: 1px solid var(--border-light);
}
.modal-title {
  font-family: var(--font-display);
  font-size: 1.3rem;
}
.modal-close {
  width:30px; height:30px;
  display:flex; align-items:center; justify-content:center;
  border-radius: var(--radius-sm);
  font-size: 1.5rem;
  color: var(--text-secondary);
  transition: background .15s;
}
.modal-close:hover { background:var(--bg-alt); }
.modal-body { padding: 16px 20px 20px; }
.modal-body label {
  display:block;
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 4px;
  margin-top: 12px;
}
.modal-body label:first-child { margin-top:0; }

.form-row { display:flex; gap:8px; }
.form-row > * { flex:1; }

.btn {
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-size: 0.82rem;
  font-weight: 600;
  transition: all .15s;
}
.btn-primary { background: var(--accent); color: var(--on-accent) !important; }
.btn-primary:hover { background: var(--accent-hover); }
.btn-secondary { background: var(--bg-alt); color: var(--text); border:1px solid var(--border); }
.btn-secondary:hover { border-color: var(--text-tertiary); }
.btn-danger { background: var(--red-light); color: var(--red); }
.btn-danger:hover { background: var(--red); color:#fff; }
.btn-sm { padding:5px 10px; font-size:0.75rem; }
.btn-group { display:flex; gap:8px; margin-top:16px; justify-content:flex-end; }

/* NOTE EDITOR PAGE (full-viewport WYSIWYG editor) */
#noteEditorPage {
  position: fixed;
  inset: 0;
  height: 100dvh;
  width: 100vw;
  background: var(--bg);
  color: var(--text);
  z-index: 1600;  /* above subscribe (1500), below toasts */
  display: none;
  flex-direction: column;
  padding-top: env(safe-area-inset-top, 0);
  padding-bottom: env(safe-area-inset-bottom, 0);
  padding-left: env(safe-area-inset-left, 0);
  padding-right: env(safe-area-inset-right, 0);
}
#noteEditorPage.open { display: flex; }

.note-page-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
  flex-shrink: 0;
}
.note-page-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px; height: 36px;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  border: none;
  flex-shrink: 0;
}
.note-page-btn:hover { background: var(--bg-alt); color: var(--text); }
.note-page-title {
  flex: 1;
  min-width: 0;
  border: none;
  outline: none;
  background: transparent;
  font-size: 1.25rem;
  font-weight: 600;
  font-family: var(--font);
  color: var(--text);
  padding: 4px 0;
}
.note-page-title::placeholder { color: var(--text-tertiary); font-weight: 500; }
.note-page-actions {
  display: flex;
  gap: 6px;
  align-items: center;
  flex-shrink: 0;
}

.note-page-toolbar {
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 6px 14px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-alt);
  flex-shrink: 0;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
}
.note-page-toolbar .fmt-btn { width: 32px; height: 30px; }

.note-page-body {
  flex: 1 1 auto;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  position: relative;
  padding: 20px 16px;
  background: var(--bg);
  /* Keep the caret comfortably above the bottom edge when auto-scrolled. */
  scroll-padding-bottom: 30vh;
}

.note-page-editor {
  min-height: 100%;
  outline: none;
  font-size: 1rem;
  line-height: 1.65;
  color: var(--text);
  max-width: 760px;
  margin: 0 auto;
  caret-color: var(--accent);
  /* Generous scrollable space below the last line so typing at the end of
     a long note is never flush against the bottom edge (and never hidden
     behind the sticky meta footer or the on-screen keyboard). */
  padding-bottom: 40vh;
}
.note-page-editor:focus { outline: none; }
.note-page-editor:empty::before {
  content: attr(data-placeholder);
  color: var(--text-tertiary);
  pointer-events: none;
}
/* Rendered markdown look inside the editor — mirrors the viewer */
.note-page-editor h1 { font-family: var(--font-display, var(--font)); font-size: 1.7rem; font-weight: 700; margin: 20px 0 8px; }
.note-page-editor h2 { font-size: 1.3rem; font-weight: 600; margin: 20px 0 6px; }
.note-page-editor h3 { font-size: 1.1rem; font-weight: 600; margin: 16px 0 4px; }
.note-page-editor h1:first-child, .note-page-editor h2:first-child, .note-page-editor h3:first-child { margin-top: 0; }
.note-page-editor p { margin: 0 0 10px; }
.note-page-editor ul, .note-page-editor ol { padding-left: 22px; margin: 0 0 10px; }
.note-page-editor li { margin: 3px 0; }
.note-page-editor li.task-list-item,
.note-page-editor li:has(> input[type="checkbox"]) {
  list-style: none;
  margin-left: -20px;
  display: flex;
  align-items: flex-start;
  gap: 6px;
}
.note-page-editor li.task-list-item > input[type="checkbox"],
.note-page-editor li:has(> input[type="checkbox"]) > input[type="checkbox"] {
  margin: 0;
  margin-top: 6px;
  flex-shrink: 0;
  cursor: pointer;
  width: 15px; height: 15px;
  accent-color: var(--accent);
}
.note-page-editor blockquote {
  border-left: 3px solid var(--accent);
  padding: 4px 12px;
  margin: 8px 0;
  color: var(--text-secondary);
  background: var(--accent-light, transparent);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}
.note-page-editor code {
  background: var(--bg-alt);
  padding: 1px 5px;
  border-radius: 3px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.92em;
}
.note-page-editor pre {
  background: var(--bg-alt);
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  overflow-x: auto;
  margin: 8px 0;
}
.note-page-editor pre code { background: none; padding: 0; }
.note-page-editor hr {
  border: none; height: 1px; background: var(--border); margin: 18px 0;
}
.note-page-editor .wiki-link {
  color: var(--accent);
  border-bottom: 1px dashed var(--accent);
  pointer-events: none;  /* decorative in editor; clickable only in viewer */
  text-decoration: none;
}
.note-page-editor a:not(.wiki-link) {
  color: var(--accent);
  text-decoration: underline;
}

/* Tables — shared across editor and viewer */
.note-page-editor table,
.md-content table {
  border-collapse: collapse;
  margin: 12px 0;
  font-size: 0.95em;
  max-width: 100%;
}
.note-page-editor th,
.note-page-editor td,
.md-content th,
.md-content td {
  border: 1px solid var(--border);
  padding: 6px 10px;
  text-align: left;
  vertical-align: top;
  min-width: 60px;
  word-break: break-word;
}
.note-page-editor th,
.md-content th {
  background: rgba(0, 0, 0, 0.04);
  font-weight: 600;
}
.note-page-editor td:focus,
.note-page-editor th:focus {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}

.note-page-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  padding: 10px 14px;
  border-top: 1px solid var(--border);
  background: var(--bg);
  flex-shrink: 0;
}
.note-page-meta-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.82rem;
}
.note-page-meta-row label {
  margin: 0 !important;
  white-space: nowrap;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.note-page-meta-row .color-picker { margin-top: 0; }
.note-page-meta-row .tag-input-container {
  min-height: 32px; min-width: 180px;
}
.note-page-meta-row input[type="date"] {
  min-width: 140px;
}

/* Toolbar format buttons are already styled via the existing .fmt-btn rules below */
.fmt-btn {
  width: 30px; height: 28px;
  display: flex; align-items: center; justify-content: center;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 0.72rem;
  transition: all .12s;
  flex-shrink: 0;
  background: transparent;
  border: none;
  cursor: pointer;
}
.fmt-btn:hover { background: var(--bg-card); color: var(--text); }
.fmt-btn svg { width: 15px; height: 15px; }
.fmt-btn b { font-size: 0.7rem; letter-spacing: -0.02em; }
.fmt-btn-danger:hover { background: var(--red-light); color: var(--red); }

/* Contextual table tools — revealed only when the caret is inside a table */
.note-table-tools { display: none; align-items: center; gap: 2px; }
.note-table-tools.open { display: inline-flex; }
.fmt-sep {
  width: 1px;
  height: 18px;
  background: var(--border-light);
  margin: 0 3px;
  flex-shrink: 0;
}

/* Mobile layout: tighter spacing, meta scrolls horizontally */
@media (max-width: 600px) {
  .note-page-header { padding: 8px 10px; }
  .note-page-title { font-size: 1.05rem; }
  .note-page-toolbar { padding: 6px 10px; }
  .note-page-body { padding: 16px 12px; }
  .note-page-editor { font-size: 1rem; }
  .note-page-meta {
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    padding: 8px 10px;
  }
  .note-page-meta-row { flex-shrink: 0; }
  .note-page-meta-row .tag-input-container { min-width: 160px; }
}

/* iPad: indent note editor header to clear iOS 26 windowed-mode window controls */
html.ipad .note-page-header { padding-left: 94px; } /* 14px base + 80px clearance */

/* TASK EDITOR MODAL */
.task-editor-modal {
  max-width: 480px;
}
.task-editor-body {
  padding: 12px 20px 16px !important;
}
.task-editor-body > .btn-group { margin-top: 14px; }
.task-editor-title {
  font-size: 1.05rem;
  font-weight: 600;
  border: none;
  border-bottom: 1px solid var(--border-light);
  border-radius: 0;
  padding: 8px 0;
  margin-bottom: 10px;
  background: none;
}
.task-editor-title:focus { border-bottom-color: var(--accent); outline: none; }
.task-editor-meta {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.task-editor-meta-row {
  display: flex;
  align-items: center;
  gap: 8px;
}
.task-editor-meta-row > label:first-child {
  margin: 0 !important;
  white-space: nowrap;
  min-width: 44px;
  font-size: 0.82rem;
}
.task-editor-meta-row input[type="date"],
.task-editor-meta-row input[type="time"] { flex: 1; }
.task-editor-meta-row select { flex: 1; }
.task-editor-meta-row .tag-input-container { flex: 1; min-height: 32px; }
.task-editor-check {
  display: flex !important;
  align-items: center;
  gap: 5px;
  cursor: pointer;
  font-weight: 400 !important;
  font-size: 0.82rem !important;
  color: var(--text-secondary) !important;
  margin: 0 !important;
  white-space: nowrap;
  flex-shrink: 0;
}
.task-editor-check input[type="checkbox"] {
  width: auto;
  accent-color: var(--accent);
}
.task-editor-desc-section {
  margin-top: 10px;
}
.task-editor-desc-toggle {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 0;
  font-size: 0.82rem;
  color: var(--text-tertiary);
  transition: color .15s;
  width: 100%;
}
.task-editor-desc-toggle:hover { color: var(--text-secondary); }
.task-editor-desc-toggle svg:first-child { width: 14px; height: 14px; flex-shrink: 0; }
.task-editor-desc-toggle span { flex: 1; text-align: left; }
.task-editor-desc-chevron {
  width: 14px; height: 14px;
  flex-shrink: 0;
  transition: transform .2s;
}
.task-editor-desc-section.open .task-editor-desc-chevron {
  transform: rotate(180deg);
}
.task-editor-desc-wrapper {
  max-height: 0;
  overflow: hidden;
  transition: max-height .25s ease;
}
.task-editor-desc-section.open .task-editor-desc-wrapper {
  max-height: 200px;
}
.task-editor-desc {
  margin-top: 6px;
  min-height: 80px;
  font-size: 0.88rem;
  resize: none;
  width: 100%;
  box-sizing: border-box;
}
@media (max-width: 500px) {
  .task-editor-modal { max-width: 100%; }
}

/* COLOR PICKER */
.color-picker { display:flex; gap:6px; flex-wrap:wrap; margin-top:6px; }
.color-dot {
  width:24px; height:24px;
  border-radius: 50%;
  cursor:pointer;
  border: 2px solid transparent;
  transition: border-color .15s, transform .1s;
}
.color-dot:hover { transform:scale(1.15); }
.color-dot.active { border-color: var(--text); }
.color-dot[data-color=""] { background: var(--bg-alt); border:2px dashed var(--border); }
.color-dot[data-color="yellow"] { background: #fbbf24; }
.color-dot[data-color="green"] { background: #34d399; }
.color-dot[data-color="blue"] { background: #60a5fa; }
.color-dot[data-color="pink"] { background: #f472b6; }
.color-dot[data-color="purple"] { background: #a78bfa; }
.color-dot[data-color="orange"] { background: #fb923c; }
.color-dot[data-color="red"] { background: #f87171; }
.color-dot[data-color="gray"] { background: #9ca3af; }

/* TAG INPUT */
.tag-input-container {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 6px 8px;
  background: var(--bg-input);
  cursor: text;
  min-height: 36px;
  align-items: center;
}
.tag-input-container:focus-within { border-color: var(--accent); }
.tag-input-tag {
  display: flex;
  align-items:center;
  gap:3px;
  background: var(--tag-bg);
  color: var(--tag-text);
  padding: 2px 6px 2px 8px;
  border-radius: 10px;
  font-size: 0.72rem;
  font-weight: 500;
}
.tag-input-remove {
  width: 14px; height:14px;
  display:flex; align-items:center; justify-content:center;
  border-radius: 50%;
  font-size: 0.7rem;
  cursor:pointer;
  color: var(--text-tertiary);
}
.tag-input-remove:hover { color: var(--red); }
.tag-input-field {
  border:none; background:none; outline:none;
  font-size: 0.82rem;
  color: var(--text);
  flex:1;
  min-width: 60px;
  padding: 0;
}

/* DROPDOWN MENUS */
.dropdown {
  position:absolute;
  background: var(--bg-card);
  border:1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  z-index: 200;
  min-width: 180px;
  padding: 4px;
  opacity:0;
  visibility:hidden;
  transform: translateY(-4px);
  transition: all .15s;
}
.dropdown.open { opacity:1; visibility:visible; transform:translateY(0); }
.dropdown-item {
  display:flex;
  align-items:center;
  gap:8px;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  font-size: 0.82rem;
  color: var(--text);
  transition: background .1s;
  width:100%;
  text-align:left;
}
.dropdown-item:hover { background: var(--bg-alt); }
.dropdown-item.danger { color: var(--red); }
.dropdown-sep { height:1px; background: var(--border-light); margin:4px 0; }

/* NOTE VIEWER */
.note-viewer-overlay {
  position:fixed; inset:0;
  z-index:100; display:flex; align-items:center; justify-content:center;
  padding:20px;
  opacity:0; visibility:hidden; transition:all .2s; backdrop-filter: blur(3px);
}
.note-viewer-overlay.open { opacity:1; visibility:visible; }
.note-viewer {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: 100%; max-width: 600px;
  max-height: 85dvh;
  display: flex;
  flex-direction: column;
  transform: translateY(10px);
  transition: transform .2s;
}
.note-viewer-overlay.open .note-viewer { transform:translateY(0); }
.note-viewer-header {
  display:flex; align-items:center; justify-content:space-between;
  padding:14px 18px 10px;
  border-bottom:1px solid var(--border-light);
  margin-bottom: 10px;
  gap: 8px;
}
.note-viewer-title {
  font-family: var(--font-display);
  font-size: 1.5rem;
  flex:1;
  min-width:0;
  overflow:hidden;
  text-overflow:ellipsis;
  white-space:nowrap;
}
.note-viewer-actions { display:flex; gap:4px; }
.note-viewer-body {
  padding: 16px 18px 20px;
  overflow-y: auto;
  flex:1;
}
.md-content {
  font-size: 1rem;
  line-height: 1.7;
}
.md-content h1 { font-family: var(--font-display); font-size:1.4rem; margin:24px 0 8px; }
.md-content h1:first-child { margin-top: 0; }
.md-content h2 { font-size:1.15rem; font-weight:600; margin:24px 0 6px; }
.md-content h2:first-child { margin-top: 0; }
.md-content h3 { font-size:1rem; font-weight:600; margin:20px 0 4px; }
.md-content h3:first-child { margin-top: 0; }
.md-content p { margin:0 0 10px; }
.md-content ul, .md-content ol { padding-left:20px; margin:0 0 10px; }
.md-content li { margin:2px 0; }
/* Task-list items (checkboxes in bullets) — keep checkbox inline with text, no bullet marker */
.md-content li.task-list-item,
.md-content li:has(> input[type="checkbox"]) {
  list-style: none;
  margin-left: -20px;
  display: flex;
  align-items: flex-start;
  gap: 6px;
}
.md-content li.task-list-item > input[type="checkbox"],
.md-content li:has(> input[type="checkbox"]) > input[type="checkbox"] {
  margin: 0;
  margin-top: 6px;
  flex-shrink: 0;
  cursor: pointer;
  width: 15px;
  height: 15px;
  accent-color: var(--accent);
}
.md-content li.task-list-item > p,
.md-content li:has(> input[type="checkbox"]) > p {
  margin: 0;
  display: inline;
}
.md-content strong { font-weight:600; }
.md-content a { color: var(--accent); text-decoration:underline; }
.md-content a:hover { color: var(--accent-hover); }
.md-content blockquote {
  border-left:3px solid var(--accent);
  padding:4px 12px;
  margin:8px 0;
  color: var(--text-secondary);
  background: var(--accent-light);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}
.md-content code {
  background: var(--bg-alt);
  padding:1px 5px;
  border-radius:3px;
  font-size:1em;
}
.md-content pre {
  background: var(--bg-alt);
  padding:12px;
  border-radius: var(--radius-sm);
  overflow-x:auto;
  margin:8px 0;
}
.md-content pre code { background:none; padding:0; }
.md-content img { max-width:100%; border-radius: var(--radius-sm); }
.md-content hr {
  border: none;
  height: 1px;
  background: var(--border);
  margin: 24px 0;
}
/* Tables */
.md-content table {
  border-collapse: collapse;
  width: 100%;
  margin: 12px 0;
  font-size: 0.92em;
  display: block;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}
.md-content thead {
  background: var(--bg-alt);
}
.md-content th,
.md-content td {
  padding: 8px 12px;
  border-bottom: 1px solid var(--border-light);
  border-right: 1px solid var(--border-light);
  text-align: left;
  vertical-align: top;
  line-height: 1.5;
}
.md-content th:last-child,
.md-content td:last-child {
  border-right: none;
}
.md-content tbody tr:last-child td {
  border-bottom: none;
}
.md-content th {
  font-weight: 600;
  color: var(--text);
  font-size: 0.85em;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}
.md-content tbody tr:nth-child(even) {
  background: color-mix(in srgb, var(--bg-alt) 50%, transparent);
}
.md-content tbody tr:hover {
  background: var(--bg-alt);
}
.md-content table p {
  margin: 0;
}
.md-content mark { background: #fde68a; padding: 0 2px; border-radius: 2px; }
[data-theme="dark"] .md-content mark { background:#854d0e; color:#fef3c7; }
.note-viewer-tags { padding:0 18px 12px; display:flex; gap:4px; flex-wrap:wrap; }

/* TASK DESC VIEWER */
.task-desc-content {
  margin-top:4px;
  padding: 6px 8px;
  background: var(--bg-alt);
  border-radius: var(--radius-sm);
  font-size: 0.78rem;
  line-height: 1.6;
}
.task-desc-content a { color: var(--accent); }
.task-desc-content p { margin:0 0 4px; }
.task-desc-content p:last-child { margin:0; }

/* SETTINGS */
.settings-section { margin-bottom:20px; }
.settings-section h3 {
  font-size:0.82rem;
  font-weight:600;
  color: var(--text-secondary);
  margin-bottom:8px;
  text-transform:uppercase;
  letter-spacing:0.04em;
}
.settings-row {
  display:flex; align-items:center; justify-content:space-between;
  padding:10px 0;
  border-bottom:1px solid var(--border-light);
}
.settings-row:last-child { border:none; }
.settings-row-label { font-size:0.87rem; }
.settings-row-desc { font-size:0.75rem; color:var(--text-tertiary); }

/* TOGGLE */
.toggle {
  width:40px; height:22px;
  background: var(--border);
  border-radius:11px;
  position:relative;
  cursor:pointer;
  transition: background .2s;
  flex-shrink:0;
}
.toggle.on { background: var(--accent); }
.toggle::after {
  content:'';
  width:18px; height:18px;
  background: #fff;
  border-radius:50%;
  position:absolute;
  top:2px; left:2px;
  transition: transform .2s;
}
.toggle.on::after { transform:translateX(18px); }

/* FILTER PANEL */
.filter-tags-list {
  display:flex; flex-wrap:wrap; gap:6px; margin-top:8px;
}
.filter-tag-btn {
  padding: 5px 12px;
  border-radius: 20px;
  font-size: 0.9rem;
  font-weight: 500;
  background: var(--bg-alt);
  color: var(--text-secondary);
  border: 1px solid var(--border);
  transition: all .15s;
}
.filter-tag-btn:hover { border-color: var(--accent); color:var(--accent); }
.filter-tag-btn.active { background: var(--accent); color: var(--on-accent); border-color: var(--accent); }

/* ALL NOTES VIEW */
.notes-view {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 0;
  display: none;
  min-width: 0;
}
.notes-view.active { display: flex; flex-direction: column; }
.notes-view-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px calc(20px + env(safe-area-inset-right, 0px)) 12px calc(20px + env(safe-area-inset-left, 0px));
  gap: 10px;
  border-bottom: 1px solid var(--border-light);
  flex-shrink: 0;
  flex-wrap: wrap;
  min-width: 0;
}
.notes-view-toolbar-left { display:flex; align-items:center; gap:8px; flex-wrap:wrap; }
.notes-view-toolbar-right { display:flex; align-items:center; gap:6px; }

.notes-sort-btn {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 5px 10px;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text-secondary);
  background: var(--bg-alt);
  border: 1px solid var(--border);
  transition: all .15s;
  white-space: nowrap;
}
.notes-sort-btn:hover { border-color: var(--accent); color: var(--accent); }
.notes-sort-btn svg { width:13px; height:13px; }

.notes-view-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 10px;
  padding: 16px calc(20px + env(safe-area-inset-right, 0px)) calc(80px + env(safe-area-inset-bottom, 0px)) calc(20px + env(safe-area-inset-left, 0px));
  flex: 1;
  align-content: start;
  min-width: 0;
  overflow-wrap: break-word;
  word-break: break-word;
}
.nv-card {
  padding: 12px 14px;
  border-radius: var(--radius);
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  cursor: pointer;
  transition: box-shadow .15s, transform .1s;
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-height: 70px;
  min-width: 0;
  overflow: hidden;
}
.nv-card:hover { box-shadow: var(--shadow-sm); transform:translateY(-1px); }
.nv-card-title {
  font-size: 1rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.nv-card-preview {
  font-size: 0.9rem;
  color: var(--text-secondary);
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  line-height: 1.5;
}
.nv-card-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: auto;
  padding-top: 6px;
  flex-wrap: wrap;
}
.nv-card-date {
  font-size: 0.8rem;
  color: var(--text-tertiary);
  white-space: nowrap;
}
.nv-card-source {
  font-size: 0.75rem;
  color: var(--text-tertiary);
  background: var(--bg-alt);
  padding: 1px 6px;
  border-radius: 8px;
}
.nv-card-header {
  display: flex;
  align-items: flex-start;
  gap: 4px;
}
.nv-card-header .nv-card-title { flex: 1; min-width: 0; }
.nv-pin-btn {
  flex-shrink: 0;
  width: 24px; height: 24px;
  display: flex; align-items: center; justify-content: center;
  border-radius: var(--radius-sm);
  color: var(--border);
  transition: color .15s, background .15s;
  margin: -4px -6px 0 0;
}
.nv-pin-btn:hover { background: var(--bg-alt); color: var(--text-secondary); }
.nv-pin-btn.pinned { color: var(--accent); }
.nv-pin-btn svg { width: 14px; height: 14px; }
.notes-view-empty {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-tertiary);
  font-size: 1rem;
  grid-column: 1 / -1;
}

/* Sort dropdown for notes view */
.notes-sort-dropdown {
  position: absolute;
  top: 100%;
  right: 0;
  left: auto;
  margin-top: 4px;
  z-index: 200;
}
.sort-option {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  font-size: 1rem;
  color: var(--text);
  transition: background .1s;
  width: 100%;
  text-align: left;
}
.sort-option:hover { background: var(--bg-alt); }
.sort-option.active { color: var(--accent); font-weight:600; }
.sort-option .check-mark { width:14px; text-align:center; font-size:0.75rem; }
.sort-divider { height:1px; background:var(--border-light); margin:4px 0; }
.sort-toggle {
  display:flex; align-items:center; justify-content:space-between;
  padding: 8px 12px;
  font-size: 0.82rem;
  width:100%;
  text-align:left;
}
.sort-toggle:hover { background: var(--bg-alt); border-radius: var(--radius-sm); }
.sort-toggle .toggle {
  width: 32px;
  height: 18px;
  min-width: 32px;
  border-radius: 9px;
  background: var(--bg-alt);
  border: 1.5px solid var(--border);
  position: relative;
  transition: all .2s;
  cursor: pointer;
  flex-shrink: 0;
}
.sort-toggle .toggle::after {
  content: '';
  position: absolute;
  top: 2px; left: 2px;
  width: 12px; height: 12px;
  border-radius: 50%;
  background: var(--text-tertiary);
  transition: all .2s;
}
.sort-toggle .toggle.active {
  background: var(--accent);
  border-color: var(--accent);
}
.sort-toggle .toggle.active::after {
  transform: translateX(14px);
  background: #fff;
}

/* SOMEDAY DRAWER */
.someday-fab {
  position: fixed;
  bottom: calc(20px + env(safe-area-inset-bottom, 0px));
  right: calc(20px + env(safe-area-inset-right, 0px));
  z-index: 60;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 18px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 28px;
  box-shadow: var(--shadow-md);
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
  cursor: pointer;
  transition: all .2s;
  user-select: none;
}
.someday-fab:hover { box-shadow: var(--shadow-lg); border-color: var(--accent); color: var(--accent); }
.someday-fab svg { width:16px; height:16px; flex-shrink:0; }
.someday-fab .someday-count {
  background: var(--accent);
  color: var(--on-accent);
  font-size: 0.68rem;
  font-weight: 700;
  min-width: 18px;
  height: 18px;
  border-radius: 9px;
  display: flex;
  align-items:center;
  justify-content:center;
  padding: 0 5px;
}
.someday-fab .someday-count.hidden { display:none; }

.someday-drawer-overlay {
  position: fixed;
  inset: 0;
  background: var(--overlay);
  z-index: 90;
  opacity: 0;
  visibility: hidden;
  transition: all .25s;
}
.someday-drawer-overlay.open { opacity:1; visibility:visible; }

.someday-drawer {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 91;
  background: var(--bg-card);
  border-top: 1px solid var(--border);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  box-shadow: 0 -4px 30px rgba(0,0,0,0.15);
  max-height: 55dvh;
  display: flex;
  flex-direction: column;
  transform: translateY(100%);
  transition: transform .3s cubic-bezier(.32,.72,0,1);
}
.someday-drawer.open { transform: translateY(0); }
.someday-drawer.minimized {
  transform: translateY(calc(100% - 40px));
  pointer-events: none;
  opacity: 0.6;
}
.someday-drawer-overlay.minimized {
  opacity: 0;
  pointer-events: none;
}

.someday-drawer-handle {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 10px;
  cursor: grab;
  flex-shrink: 0;
}
.someday-drawer-handle::before {
  content: '';
  width: 36px;
  height: 4px;
  border-radius: 2px;
  background: var(--border);
}

.someday-drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 18px 10px;
  flex-shrink: 0;
}
.someday-drawer-title {
  font-family: var(--font-display);
  font-size: 1.1rem;
  font-weight: 600;
}
.someday-drawer-body {
  flex: 1;
  overflow-y: auto;
  padding: 0 12px calc(16px + env(safe-area-inset-bottom, 0px));
}
.someday-empty {
  text-align: center;
  padding: 28px 16px;
  color: var(--text-tertiary);
  font-size: 0.82rem;
}
.someday-task-item {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  cursor: grab;
  transition: background .1s;
  position: relative;
}
.someday-task-item:hover { background: var(--bg-alt); }
.someday-task-item:active { cursor: grabbing; }
.someday-task-item.dragging { opacity: 0.4; }
.someday-task-item.completed .task-text { text-decoration: line-through; color: var(--completed-text); }
.someday-task-item.completed .task-checkbox {
  background: var(--green);
  border-color: var(--green);
}
.someday-task-item.completed .task-checkbox::after {
  content: '\2713';
  color: #fff;
  font-size: 11px;
  font-weight: 700;
}
.someday-task-item .task-actions { opacity: 0; }
.someday-task-item:hover .task-actions { opacity: 1; }
.someday-drag-hint {
  font-size: 0.72rem;
  color: var(--text-tertiary);
  text-align: center;
  padding: 4px 0 8px;
  border-bottom: 1px solid var(--border-light);
  margin-bottom: 6px;
}

/* MOBILE */
@media (max-width:768px) {
  .header-top { padding: calc(10px + env(safe-area-inset-top, 0px)) calc(14px + env(safe-area-inset-right, 0px)) 10px calc(14px + env(safe-area-inset-left, 0px)); }
  .week-label { min-width:auto; font-size:0.82rem; }
  .day-column { min-width: 85vw; }
  .day-header { padding:10px 12px 8px; }
  .day-content { padding:6px 6px calc(80px + env(safe-area-inset-bottom, 0px)); }
  .task-actions { opacity:1; position:static; background:none; padding:0; }
  .someday-task-item .task-actions { opacity:1; position:static; background:none; padding:0; }
  .someday-fab { bottom:calc(14px + env(safe-area-inset-bottom, 0px)); right:calc(14px + env(safe-area-inset-right, 0px)); padding:9px 14px; font-size:0.78rem; }
  .desktop-only { display:none !important; }
  .notes-view-grid { grid-template-columns: 1fr; padding: 12px calc(14px + env(safe-area-inset-right, 0px)) calc(80px + env(safe-area-inset-bottom, 0px)) calc(14px + env(safe-area-inset-left, 0px)); }
  .notes-view-toolbar { padding: 10px calc(14px + env(safe-area-inset-right, 0px)) 10px calc(14px + env(safe-area-inset-left, 0px)); }
  .view-tab { padding: 5px 10px; font-size: 0.76rem; }
}
@media (min-width:769px) {
  .mobile-only { display:none !important; }
  .header-week-row { display:none !important; }
}

/* ADD INLINE */
.inline-add {
  padding: 4px 8px;
}
.inline-add input {
  font-size: 0.85rem;
  padding: 6px 8px;
  background: var(--bg-card);
}

/* EMPTY STATE */
.empty-state {
  text-align:center;
  padding:20px 10px;
  color: var(--text-tertiary);
  font-size:0.8rem;
}

/* CONFIRM DIALOG */
.confirm-body { text-align:center; padding:8px 0; }
.confirm-body p { font-size:0.9rem; margin-bottom:4px; }
.confirm-body .sub { font-size:0.78rem; color:var(--text-tertiary); }
.settings-action-btn svg { flex-shrink:0; }
.settings-legal-link {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 0;
  font-size: 0.88rem;
  color: var(--text-secondary);
  text-decoration: none;
  transition: color 0.15s;
}
.settings-legal-link:hover { color: var(--accent); text-decoration: none; }
.settings-legal-link svg { flex-shrink: 0; }

/* Settings tabs */
.settings-tab-panel { display: none; }
.settings-tab-panel.active { display: block; }

/* Theme selector */
.theme-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}
.theme-option {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-card);
  cursor: pointer;
  transition: border-color .15s, background .15s;
  text-align: left;
  font-family: var(--font);
}
.theme-option:hover { border-color: var(--accent); }
.theme-option.active { border-color: var(--accent); background: var(--accent-light); }
.theme-option-name { font-size: 0.82rem; font-weight: 600; color: var(--text); }
.theme-swatch {
  width: 30px; height: 30px;
  border-radius: 7px;
  flex-shrink: 0;
  border: 1px solid var(--border-light);
  display: flex;
  overflow: hidden;
}
.theme-swatch span { flex: 1; }

/* ===== SYNC & AUTH ===== */

/* Sync icon states */
.sync-synced { color: var(--green) !important; }
.sync-syncing { color: var(--accent) !important; }
.sync-offline { color: var(--red) !important; }
.sync-error { color: var(--red) !important; }

@keyframes sync-spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}
.sync-syncing svg {
  animation: sync-spin 1.2s linear infinite;
}

/* Auth tabs */
.auth-tabs {
  display: flex;
  background: var(--bg-alt);
  border-radius: 8px;
  padding: 2px;
  gap: 2px;
  margin-bottom: 12px;
}
.auth-tab {
  flex: 1;
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-align: center;
  cursor: pointer;
  transition: all .15s;
  border: none;
  background: none;
  font-family: var(--font);
}
.auth-tab:hover { color: var(--text); }
.auth-tab.active {
  background: var(--bg-card);
  color: var(--text);
  box-shadow: var(--shadow-sm);
}

/* Auth form */
.auth-form label {
  display: block;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 4px;
  margin-top: 10px;
}
.auth-form label:first-of-type { margin-top: 0; }
.auth-form input {
  width: 100%;
  margin-bottom: 2px;
}

.auth-error {
  font-size: 0.78rem;
  color: var(--red);
  background: var(--red-light);
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  margin-bottom: 8px;
}

.auth-success {
  font-size: 0.78rem;
  color: var(--green);
  background: var(--green-light);
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  margin-bottom: 8px;
}

/* Session list */
.session-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 0;
  border-bottom: 1px solid var(--border-light);
  gap: 8px;
}
.session-item:last-child { border-bottom: none; }

.session-revoke-btn {
  flex-shrink: 0;
}

/* Offline mode */
.offline-mode .app-layout {
  position: relative;
}
.offline-mode .app-layout::after {
  content: '';
  position: fixed;
  inset: 0;
  background: var(--overlay);
  opacity: 0.15;
  z-index: 40;
  pointer-events: none;
}
.offline-mode .add-task-btn,
.offline-mode .add-note-btn,
.offline-mode .task-checkbox,
.offline-mode .task-action-btn,
.offline-mode .task-item[draggable],
.offline-mode .note-card[draggable],
.offline-mode .someday-fab,
.offline-mode .someday-task-item[draggable],
.offline-mode .btn-primary,
.offline-mode .week-menu-btn,
.offline-mode #weekMenuBtn {
  pointer-events: none;
  opacity: 0.5;
}

/* Toast notification */
.toast {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--bg-card);
  color: var(--text);
  border: 1px solid var(--border);
  padding: 10px 20px;
  border-radius: 28px;
  font-size: 0.82rem;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  z-index: 9999;
  opacity: 0;
  transition: opacity .3s, transform .3s;
  white-space: nowrap;
  font-family: var(--font);
}
.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* Sync dropdown content */
#syncDropdown {
  min-width: 240px;
}
#syncDropdownContent .btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* SEARCH */
.search-overlay {
  position: fixed; inset: 0; z-index: 1000;
  display: none; align-items: flex-start; justify-content: center;
  padding-top: min(20vh, 120px);
  backdrop-filter: blur(2px);
}
.search-overlay.open { display: flex; }
.search-box {
  background: var(--bg); border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  width: 90%; max-width: 520px;
  box-shadow: 0 16px 48px rgba(0,0,0,0.18);
  overflow: hidden;
}
.search-box-input-row {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
}
.search-box-input-row svg { color: var(--text-tertiary); flex-shrink: 0; }
.search-box-input-row input {
  flex: 1; border: none; background: none; outline: none;
  font-size: 0.95rem; color: var(--text); font-family: inherit;
}
.search-results { max-height: 360px; overflow-y: auto; }
.search-result-item {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 10px 16px; cursor: pointer; transition: background 0.1s;
}
.search-result-item:hover { background: var(--bg-alt); }
.search-result-icon { margin-top: 2px; color: var(--text-tertiary); flex-shrink: 0; }
.search-result-body { flex: 1; min-width: 0; }
.search-result-title { font-size: 0.85rem; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.search-result-preview { font-size: 0.75rem; color: var(--text-tertiary); margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.search-result-type { font-size: 0.68rem; color: var(--text-tertiary); flex-shrink: 0; margin-top: 2px; }
.search-empty { padding: 20px; text-align: center; color: var(--text-tertiary); font-size: 0.85rem; }

/* NOTES LIST LAYOUT */
.nv-list-layout {
  display: flex !important;
  flex-direction: column;
  gap: 0 !important;
}
.nv-list-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  cursor: pointer;
  border-bottom: 1px solid var(--border-light);
  border-left: 3px solid transparent;
  transition: background 0.1s;
}
.nv-list-item:hover { background: var(--bg-alt); }
.nv-list-title {
  flex: 1;
  min-width: 0;
  font-size: 0.9rem;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: flex;
  align-items: center;
  gap: 6px;
}
.nv-list-pin { color: var(--text-tertiary); flex-shrink: 0; }
.nv-list-right {
  display: flex;
  gap: 3px;
  flex-shrink: 0;
  align-items: center;
}
.notes-layout-btn { padding: 5px; }
.notes-layout-btn svg { width: 16px; height: 16px; }

/* TASK COLORS */
/* Uses the same palette as notes (--note-*). Full background so the whole
   task item reads as the chosen color, no left border. */
.task-item.task-colored,
.someday-task-item.task-colored {
  border: 1px solid transparent;
}
.task-item.task-color-yellow,  .someday-task-item.task-color-yellow  { background: var(--note-yellow); }
.task-item.task-color-green,   .someday-task-item.task-color-green   { background: var(--note-green); }
.task-item.task-color-blue,    .someday-task-item.task-color-blue    { background: var(--note-blue); }
.task-item.task-color-pink,    .someday-task-item.task-color-pink    { background: var(--note-pink); }
.task-item.task-color-purple,  .someday-task-item.task-color-purple  { background: var(--note-purple); }
.task-item.task-color-orange,  .someday-task-item.task-color-orange  { background: var(--note-orange); }
.task-item.task-color-red,     .someday-task-item.task-color-red     { background: var(--note-red); }
.task-item.task-color-gray,    .someday-task-item.task-color-gray    { background: var(--note-gray); }
/* Preserve a subtle hover feedback without overriding the colour */
.task-item.task-colored:hover,
.someday-task-item.task-colored:hover {
  filter: brightness(0.97);
}

/* WIKI AUTOCOMPLETE */
.wiki-autocomplete {
  display: none;
  position: absolute;
  bottom: 4px;
  left: 12px;
  right: 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: 0 4px 16px rgba(0,0,0,0.12);
  max-height: 200px;
  overflow-y: auto;
  z-index: 10;
}
.wiki-autocomplete.open { display: block; }
.wiki-ac-item {
  padding: 8px 12px;
  font-size: 0.85rem;
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.wiki-ac-item:hover, .wiki-ac-item.active { background: var(--bg-alt); }

/* WIKI LINKS */
.wiki-link {
  color: var(--accent);
  text-decoration: none;
  border-bottom: 1px dashed var(--accent);
  cursor: pointer;
}
.wiki-link:hover { border-bottom-style: solid; }

/* INSTALL BANNER */
.install-banner {
  display: none;
  position: fixed;
  left: 12px;
  right: 12px;
  bottom: calc(12px + env(safe-area-inset-bottom, 0px));
  z-index: 1500;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.14);
  animation: install-slide-in 0.25s ease-out;
}
.install-banner.open { display: block; }
.install-banner-inner {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  max-width: 500px;
  margin: 0 auto;
}
.install-banner-icon {
  border-radius: 8px;
  flex-shrink: 0;
}
.install-banner-text {
  flex: 1;
  min-width: 0;
}
.install-banner-title {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text);
  line-height: 1.3;
}
.install-banner-desc {
  font-size: 0.75rem;
  color: var(--text-secondary);
  line-height: 1.4;
  margin-top: 2px;
}
.install-banner-btn { flex-shrink: 0; white-space: nowrap; }
.install-banner-close {
  background: none;
  border: none;
  color: var(--text-tertiary);
  font-size: 1.3rem;
  line-height: 1;
  padding: 4px 6px;
  cursor: pointer;
  flex-shrink: 0;
  align-self: flex-start;
}
.install-banner-close:hover { color: var(--text); }
@keyframes install-slide-in {
  from { transform: translateY(100%); opacity: 0; }
  to   { transform: translateY(0);    opacity: 1; }
}

/* iOS INSTALL STEPS */
.ios-install-steps {
  list-style: none;
  counter-reset: step;
  padding: 0;
  margin: 0;
}
.ios-install-steps li {
  counter-increment: step;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border-light);
  font-size: 0.88rem;
  color: var(--text);
  line-height: 1.4;
}
.ios-install-steps li:last-child { border-bottom: none; }
.ios-install-steps li::before {
  content: counter(step);
  flex-shrink: 0;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--accent);
  color: var(--on-accent);
  font-size: 0.78rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
}
.ios-install-steps li > div:first-of-type { flex: 1; }
.ios-install-icon {
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--accent);
}

/* Hide install banner when running in standalone mode */
@media (display-mode: standalone) {
  .install-banner { display: none !important; }
}

/* WELCOME SCREEN */
.welcome-screen {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 2000;
  background: var(--bg);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
.welcome-screen.open { display: flex; align-items: center; justify-content: center; }
.welcome-card {
  width: 100%;
  max-width: 400px;
  padding: 32px 28px 24px;
  margin: auto;
}
.welcome-header {
  text-align: center;
  margin-bottom: 24px;
}
.welcome-logo {
  margin-bottom: 12px;
}
.welcome-logo img {
  border-radius: 14px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}
.welcome-title {
  font-family: var(--font-display);
  font-size: 1.6rem;
  font-weight: 700;
  margin-bottom: 4px;
  letter-spacing: -0.01em;
}
.welcome-subtitle {
  font-size: 0.9rem;
  color: var(--text-secondary);
}
.welcome-body {
  margin-bottom: 8px;
}
.welcome-body .auth-tabs { margin-bottom: 16px; }
.welcome-body .auth-form label {
  margin-top: 10px;
}
.welcome-body .auth-form label:first-of-type,
.welcome-body .auth-form .auth-error + label { margin-top: 0; }
.welcome-body .auth-form input { width: 100%; }
.welcome-consent {
  margin-top: 12px;
  font-size: 0.72rem;
  color: var(--text-tertiary);
  line-height: 1.5;
  text-align: center;
}
.welcome-consent a { color: var(--accent); text-decoration: underline; }
.welcome-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 16px 0;
  font-size: 0.78rem;
  color: var(--text-tertiary);
}
.welcome-divider::before,
.welcome-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}
.welcome-local-btn {
  width: 100%;
  padding: 10px;
  font-size: 0.9rem;
}
.welcome-local-hint {
  text-align: center;
  font-size: 0.72rem;
  color: var(--text-tertiary);
  margin-top: 10px;
  line-height: 1.5;
}
.welcome-footer {
  text-align: center;
  margin-top: 24px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}
.welcome-footer a {
  font-size: 0.75rem;
  color: var(--text-tertiary);
  text-decoration: none;
}
.welcome-footer a:hover { color: var(--accent); text-decoration: underline; }

@media (max-width: 500px) {
  .welcome-card { padding: 24px 20px 20px; }
  .welcome-title { font-size: 1.4rem; }
}
