: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;
  --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;
  --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;
}

* { 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;
  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;
  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: #fff; }
.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: #fff; }
.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: #fff !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-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-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; }

.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;
  background: var(--overlay);
  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:#fff !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 MODAL */
.note-editor-modal {
  max-width: 640px;
  max-height: 90dvh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.note-editor-body {
  display: flex;
  flex-direction: column;
  flex: 1;
  overflow: hidden;
  padding: 12px 20px 16px !important;
}
.note-editor-body label {
  margin-top: 0;
  margin-bottom: 2px;
  font-size: 0.82rem;
}
.note-editor-title {
  font-size: 1.15rem;
  font-weight: 600;
  border: none;
  border-bottom: 1px solid var(--border-light);
  border-radius: 0;
  padding: 8px 0;
  margin-bottom: 8px;
  background: none;
}
.note-editor-title:focus { border-bottom-color: var(--accent); outline: none; }
.note-editor-content-area {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
  margin-bottom: 10px;
}
.note-editor-content-area:focus-within { border-color: var(--accent); }
.note-editor-toolbar {
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 4px 6px;
  border-bottom: 1px solid var(--border-light);
  background: var(--bg-alt);
  flex-shrink: 0;
  flex-wrap: wrap;
}
.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;
}
.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-sep {
  width: 1px;
  height: 18px;
  background: var(--border-light);
  margin: 0 3px;
  flex-shrink: 0;
}
.note-editor-textarea {
  flex: 1;
  min-height: 180px;
  border: none;
  border-radius: 0;
  padding: 10px 12px;
  font-size: 0.9rem;
  line-height: 1.6;
  resize: none;
  font-family: var(--font);
  background: var(--bg-card);
}
.note-editor-textarea:focus { outline: none; }
.note-editor-meta {
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex-shrink: 0;
}
.note-editor-meta-row {
  display: flex;
  align-items: center;
  gap: 10px;
}
.note-editor-meta-row label {
  margin: 0 !important;
  white-space: nowrap;
  min-width: 40px;
}
.note-editor-meta-row .color-picker { margin-top: 0; }
.note-editor-meta-row .tag-input-container { flex: 1; min-height: 32px; }
.note-editor-meta-row input[type="date"] { flex: 1; }
.note-editor-body .btn-group { margin-top: 12px; flex-shrink: 0; }

@media (max-width: 500px) {
  .note-editor-modal { max-width: 100%; }
  .note-editor-textarea { min-height: 140px; }
}

/* 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; background:var(--overlay);
  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;
}
.note-viewer-body .md-content {
  font-size: 1rem;
  line-height: 1.7;
}
.note-viewer-body .md-content h1 { font-family: var(--font-display); font-size:1.4rem; margin:0 0 8px; }
.note-viewer-body .md-content h2 { font-size:1.15rem; font-weight:600; margin:16px 0 6px; }
.note-viewer-body .md-content h3 { font-size:1rem; font-weight:600; margin:12px 0 4px; }
.note-viewer-body .md-content p { margin:0 0 10px; }
.note-viewer-body .md-content ul, .note-viewer-body .md-content ol { padding-left:20px; margin:0 0 10px; }
.note-viewer-body .md-content li { margin:2px 0; }
.note-viewer-body .md-content strong { font-weight:600; }
.note-viewer-body .md-content a { color: var(--accent); text-decoration:underline; }
.note-viewer-body .md-content a:hover { color: var(--accent-hover); }
.note-viewer-body .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;
}
.note-viewer-body .md-content code {
  background: var(--bg-alt);
  padding:1px 5px;
  border-radius:3px;
  font-size:1em;
}
.note-viewer-body .md-content pre {
  background: var(--bg-alt);
  padding:12px;
  border-radius: var(--radius-sm);
  overflow-x:auto;
  margin:8px 0;
}
.note-viewer-body .md-content pre code { background:none; padding:0; }
.note-viewer-body .md-content img { max-width:100%; border-radius: var(--radius-sm); }
.note-viewer-body .md-content mark { background: #fde68a; padding: 0 2px; border-radius: 2px; }
[data-theme="dark"] .note-viewer-body .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:#fff; 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: #fff;
  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; }

/* ===== 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;
}
