/* ========== DESIGN TOKENS ========== */
:root {
  --accent: #7c5cff;
  --accent-soft: rgba(124, 92, 255, 0.15);
  --accent-hover: #8f73ff;

  /* Category palette */
  --cat-work: #4f8cff;
  --cat-personal: #2dd4bf;
  --cat-focus: #a78bfa;
  --cat-meeting: #fb923c;
  --cat-deadline: #f43f5e;

  /* Priority palette */
  --pri-low: #64748b;
  --pri-medium: #3b82f6;
  --pri-high: #f59e0b;
  --pri-critical: #ef4444;

  /* Status palette */
  --st-todo: #64748b;
  --st-progress: #3b82f6;
  --st-blocked: #f59e0b;
  --st-done: #10b981;
}

[data-theme="dark"] {
  --bg: #0b0d12;
  --bg-elev: #11141b;
  --bg-elev-2: #161a24;
  --bg-hover: #1d2230;
  --surface: #141821;
  --border: #232838;
  --border-strong: #2e3447;
  --text: #e7eaf3;
  --text-muted: #8a91a5;
  --text-dim: #5d6478;
  --shadow: 0 10px 40px rgba(0,0,0,0.5);
  --shadow-sm: 0 2px 8px rgba(0,0,0,0.25);
  --glass: rgba(20, 24, 33, 0.85);
}

[data-theme="light"] {
  --bg: #f5f6fa;
  --bg-elev: #ffffff;
  --bg-elev-2: #f9fafc;
  --bg-hover: #eef0f7;
  --surface: #ffffff;
  --border: #e3e6ee;
  --border-strong: #c9cee0;
  --text: #1a1d29;
  --text-muted: #5a6175;
  --text-dim: #8d93a6;
  --shadow: 0 10px 30px rgba(20,30,60,0.08);
  --shadow-sm: 0 2px 8px rgba(20,30,60,0.06);
  --glass: rgba(255, 255, 255, 0.85);
}

/* ========== RESET ========== */
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; overflow: hidden; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  transition: background 0.2s, color 0.2s;
}
button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }
input, textarea, select { font-family: inherit; }
kbd {
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 11px;
  padding: 2px 6px;
  background: var(--bg-hover);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text-muted);
}
.hidden { display: none !important; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 5px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-dim); }

/* ========== APP SHELL ========== */
#app { display: flex; height: 100vh; width: 100vw; }

/* Sidebar */
.sidebar {
  width: 240px;
  flex-shrink: 0;
  background: var(--bg-elev);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  transition: width 0.25s cubic-bezier(.4,0,.2,1), transform 0.25s;
}
.sidebar.collapsed { width: 0; overflow: hidden; }
.sidebar-header {
  padding: 16px 16px 8px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.logo { display: flex; align-items: center; gap: 10px; }
.logo-mark {
  width: 26px; height: 26px;
  background: linear-gradient(135deg, var(--accent), var(--accent-hover));
  border-radius: 8px;
  position: relative;
  box-shadow: 0 0 20px var(--accent-soft);
}
.logo-mark::after {
  content: ''; position: absolute; inset: 6px;
  border-radius: 4px;
  background: var(--bg-elev);
}
.logo-text { font-size: 16px; font-weight: 700; letter-spacing: -0.3px; }
.nav { padding: 8px; display: flex; flex-direction: column; gap: 2px; }
.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 9px 12px;
  border-radius: 8px;
  color: var(--text-muted);
  font-size: 13.5px;
  font-weight: 500;
  text-align: left;
  width: 100%;
  transition: background 0.15s, color 0.15s;
  position: relative;
}
.nav-item:hover { background: var(--bg-hover); color: var(--text); }
.nav-item.active {
  background: var(--accent-soft);
  color: var(--accent);
}
.nav-item.active svg { color: var(--accent); }
.nav-item .badge {
  margin-left: auto;
  background: var(--pri-critical);
  color: white;
  font-size: 10px;
  padding: 2px 7px;
  border-radius: 10px;
  font-weight: 600;
}
.nav-item .badge:empty { display: none; }

.mini-month {
  margin: 12px;
  padding: 12px;
  background: var(--bg-elev-2);
  border-radius: 10px;
  border: 1px solid var(--border);
}
.mini-month-header {
  display: flex; align-items: center; justify-content: space-between;
  font-size: 12px; font-weight: 600; margin-bottom: 8px;
}
.mini-month-nav { display: flex; gap: 2px; }
.mini-month-nav button {
  width: 20px; height: 20px; border-radius: 4px;
  color: var(--text-muted);
  display: flex; align-items: center; justify-content: center;
}
.mini-month-nav button:hover { background: var(--bg-hover); color: var(--text); }
.mini-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 1px; }
.mini-dow { text-align: center; font-size: 10px; color: var(--text-dim); padding: 4px 0; }
.mini-day {
  text-align: center; font-size: 11px; padding: 4px 0;
  border-radius: 4px; cursor: pointer; position: relative;
  color: var(--text);
}
.mini-day:hover { background: var(--bg-hover); }
.mini-day.other-month { color: var(--text-dim); }
.mini-day.today {
  color: var(--accent);
  font-weight: 700;
}
.mini-day.selected {
  background: var(--accent);
  color: white;
  font-weight: 700;
}
.mini-day.has-event::after {
  content: ''; position: absolute; bottom: 2px; left: 50%;
  transform: translateX(-50%);
  width: 3px; height: 3px; border-radius: 50%; background: var(--accent);
}
.mini-day.selected.has-event::after { background: white; }

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

/* Main */
.main { flex: 1; display: flex; flex-direction: column; overflow: hidden; }
.topbar {
  height: 56px;
  border-bottom: 1px solid var(--border);
  padding: 0 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  background: var(--bg-elev);
  flex-shrink: 0;
}
.topbar-left { display: flex; align-items: center; gap: 12px; min-width: 200px; }
.view-title { font-size: 16px; font-weight: 600; letter-spacing: -0.2px; }
.topbar-center { flex: 1; max-width: 600px; margin: 0 auto; }
.topbar-right { display: flex; align-items: center; gap: 8px; min-width: 200px; justify-content: flex-end; }

.search-wrap {
  position: relative;
  display: flex; align-items: center;
}
.search-wrap svg { position: absolute; left: 12px; color: var(--text-dim); }
.search-wrap kbd { position: absolute; right: 10px; }
.search-wrap input {
  width: 100%;
  padding: 8px 40px 8px 36px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 13px;
  outline: none;
  transition: border-color 0.15s, background 0.15s;
}
.search-wrap input:focus { border-color: var(--accent); background: var(--surface); }

.icon-btn {
  width: 32px; height: 32px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 6px;
  color: var(--text-muted);
  transition: background 0.15s, color 0.15s;
}
.icon-btn:hover { background: var(--bg-hover); color: var(--text); }
.primary-btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 14px;
  background: var(--accent);
  color: white;
  border-radius: 7px;
  font-size: 13px;
  font-weight: 600;
  transition: background 0.15s, transform 0.1s;
}
.primary-btn:hover { background: var(--accent-hover); }
.primary-btn:active { transform: scale(0.97); }
.ghost-btn {
  padding: 7px 13px;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 7px;
  font-size: 13px;
  font-weight: 500;
  transition: background 0.15s, border-color 0.15s;
}
.ghost-btn:hover { background: var(--bg-hover); border-color: var(--border-strong); }
.danger-btn {
  padding: 7px 13px;
  background: var(--pri-critical);
  color: white;
  border-radius: 7px;
  font-size: 13px;
  font-weight: 500;
}
.danger-btn:hover { opacity: 0.9; }

.view-container { flex: 1; overflow: auto; padding: 24px 28px; }

/* ========== SEARCH RESULTS ========== */
.search-results {
  position: absolute;
  top: 56px;
  left: 50%;
  transform: translateX(-50%);
  width: 600px;
  max-height: 500px;
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow);
  z-index: 90;
  margin-top: 4px;
}
.search-section { padding: 8px; }
.search-section-title {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-dim);
  padding: 8px 12px 4px;
  font-weight: 600;
}
.search-item {
  padding: 8px 12px;
  border-radius: 6px;
  cursor: pointer;
  display: flex; align-items: center; gap: 10px;
}
.search-item:hover { background: var(--bg-hover); }
.search-item-title { font-size: 13px; font-weight: 500; flex: 1; }
.search-item-meta { font-size: 11px; color: var(--text-dim); }

/* ========== DASHBOARD ========== */
.dash-grid {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 20px;
  max-width: 1400px;
  margin: 0 auto;
}
.dash-greeting {
  grid-column: span 2;
  display: flex; align-items: end; justify-content: space-between;
  margin-bottom: 4px;
}
.dash-greeting h2 { font-size: 26px; font-weight: 700; letter-spacing: -0.5px; }
.dash-greeting p { color: var(--text-muted); margin-top: 4px; font-size: 14px; }
.dash-date-big { font-size: 32px; font-weight: 700; color: var(--accent); }

.card {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 18px;
}
.card-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 14px;
}
.card-title { font-size: 14px; font-weight: 600; }
.card-link { font-size: 12px; color: var(--accent); cursor: pointer; }
.card-link:hover { text-decoration: underline; }

.focus-pin {
  background: linear-gradient(135deg, var(--accent-soft), transparent);
  border: 1px solid var(--accent);
  padding: 16px;
  border-radius: 10px;
  margin-bottom: 12px;
}
.focus-pin-label {
  font-size: 10px; text-transform: uppercase; letter-spacing: 0.8px;
  color: var(--accent); font-weight: 700;
}
.focus-pin-text { font-size: 15px; font-weight: 600; margin-top: 4px; }
.focus-pin-empty { color: var(--text-muted); font-style: italic; font-size: 13px; }
.focus-pin-actions { margin-top: 10px; display: flex; gap: 8px; }

.quick-capture {
  width: 100%;
  padding: 10px 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 13px;
  outline: none;
  resize: vertical;
  min-height: 44px;
}
.quick-capture:focus { border-color: var(--accent); }

/* Event list rows */
.event-row, .task-row {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.12s;
}
.event-row:hover, .task-row:hover { background: var(--bg-hover); }
.event-row-time {
  font-size: 12px; color: var(--text-muted);
  width: 90px; flex-shrink: 0; font-variant-numeric: tabular-nums;
}
.event-row-dot { width: 10px; height: 10px; border-radius: 3px; flex-shrink: 0; }
.event-row-title { flex: 1; font-size: 13px; font-weight: 500; }
.event-row-cat { font-size: 11px; color: var(--text-dim); padding: 2px 8px; border-radius: 10px; background: var(--bg-hover); }

.task-row { gap: 10px; }
.task-checkbox {
  width: 18px; height: 18px;
  border: 1.5px solid var(--border-strong);
  border-radius: 5px;
  flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  transition: all 0.15s;
}
.task-checkbox:hover { border-color: var(--accent); }
.task-checkbox.done {
  background: var(--accent); border-color: var(--accent);
}
.task-checkbox.done::after {
  content: '✓'; color: white; font-size: 12px; font-weight: 700;
}
.task-row.done .task-row-title { text-decoration: line-through; color: var(--text-dim); }
.task-row-title { flex: 1; font-size: 13px; font-weight: 500; }
.task-row-meta { display: flex; gap: 6px; align-items: center; }
.task-row.overdue { background: rgba(239, 68, 68, 0.08); }
.task-row.overdue .task-row-title { color: var(--pri-critical); }

.priority-dot {
  width: 8px; height: 8px; border-radius: 50%;
}
.pill {
  font-size: 10px; padding: 2px 7px; border-radius: 8px;
  background: var(--bg-hover); color: var(--text-muted);
  font-weight: 500;
  display: inline-flex; align-items: center; gap: 4px;
}
.empty-state {
  text-align: center; padding: 32px 16px; color: var(--text-muted);
  font-size: 13px; font-style: italic;
}
.empty-state-emoji { font-size: 32px; margin-bottom: 8px; }

/* ========== CALENDAR ========== */
.cal-toolbar {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 16px; gap: 12px; flex-wrap: wrap;
}
.cal-toolbar-left { display: flex; align-items: center; gap: 10px; }
.cal-nav-btn {
  width: 32px; height: 32px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 7px;
  border: 1px solid var(--border);
  color: var(--text);
  background: var(--bg-elev);
}
.cal-nav-btn:hover { background: var(--bg-hover); }
.cal-current-range { font-size: 16px; font-weight: 600; letter-spacing: -0.2px; min-width: 180px; }
.view-switcher {
  display: inline-flex; background: var(--bg-elev); border: 1px solid var(--border); border-radius: 8px; padding: 3px;
}
.view-switcher button {
  padding: 6px 14px; font-size: 12.5px; font-weight: 500;
  color: var(--text-muted); border-radius: 6px;
}
.view-switcher button.active { background: var(--accent); color: white; }

.cal-grid-wrap {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
}

/* Week / Day grid */
.cal-week {
  display: grid;
  grid-template-columns: 56px 1fr;
  height: calc(100vh - 200px);
  overflow: hidden;
}
.cal-week-header {
  grid-column: 2;
  display: grid;
  border-bottom: 1px solid var(--border);
  background: var(--bg-elev);
}
.cal-corner { border-bottom: 1px solid var(--border); border-right: 1px solid var(--border); }
.cal-day-header {
  padding: 10px 8px;
  text-align: center;
  border-right: 1px solid var(--border);
  font-size: 12px;
}
.cal-day-header:last-child { border-right: none; }
.cal-day-header .dow { color: var(--text-muted); font-weight: 500; text-transform: uppercase; font-size: 10px; letter-spacing: 0.5px; }
.cal-day-header .dom { font-size: 18px; font-weight: 600; margin-top: 2px; }
.cal-day-header.today .dom { color: var(--accent); }
.cal-day-header.today .dom { display: inline-flex; width: 28px; height: 28px; border-radius: 50%; background: var(--accent); color: white; align-items: center; justify-content: center; }

.cal-body { display: contents; }
.cal-times {
  display: flex; flex-direction: column;
  border-right: 1px solid var(--border);
  overflow-y: scroll;
  scrollbar-width: none;
}
.cal-times::-webkit-scrollbar { display: none; }
.cal-times .hour {
  height: 48px;
  font-size: 10.5px;
  color: var(--text-dim);
  text-align: right;
  padding: 0 6px;
  position: relative;
}
.cal-days {
  display: grid;
  overflow-y: auto;
  position: relative;
}
.cal-day-col {
  border-right: 1px solid var(--border);
  position: relative;
}
.cal-day-col:last-child { border-right: none; }
.cal-day-col.today { background: var(--accent-soft); }
.cal-day-col.non-work::before {
  content: ''; position: absolute; inset: 0;
  background: repeating-linear-gradient(45deg, transparent, transparent 4px, rgba(0,0,0,0.05) 4px, rgba(0,0,0,0.05) 8px);
  pointer-events: none;
}
.hour-line {
  position: absolute; left: 0; right: 0;
  height: 48px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background 0.1s;
}
.hour-line:hover { background: var(--accent-soft); }
.hour-line.half { border-bottom: 1px dashed var(--border); }

.event-block {
  position: absolute;
  left: 4px; right: 4px;
  background: var(--accent);
  color: white;
  padding: 4px 8px;
  border-radius: 6px;
  font-size: 11.5px;
  font-weight: 500;
  cursor: pointer;
  overflow: hidden;
  border-left: 3px solid rgba(255,255,255,0.4);
  box-shadow: 0 2px 6px rgba(0,0,0,0.15);
  transition: transform 0.1s, box-shadow 0.1s;
  z-index: 2;
}
.event-block:hover { transform: translateY(-1px); box-shadow: 0 4px 10px rgba(0,0,0,0.25); z-index: 5; }
.event-block.focus-block {
  background: repeating-linear-gradient(135deg, var(--cat-focus), var(--cat-focus) 8px, color-mix(in srgb, var(--cat-focus) 80%, black) 8px, color-mix(in srgb, var(--cat-focus) 80%, black) 16px);
  border-left: 3px solid white;
}
.event-block.task-block {
  background: var(--bg-elev) !important;
  border: 1.5px dashed;
  border-left-width: 3px;
  border-left-style: solid;
  color: var(--text);
  box-shadow: 0 1px 4px rgba(0,0,0,0.1);
}
.event-block.task-block .eb-title {
  display: flex; align-items: center; gap: 5px;
  color: var(--text);
}
.event-block.task-block .eb-check {
  width: 11px; height: 11px;
  border: 1.5px solid;
  border-radius: 3px;
  flex-shrink: 0;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 9px; font-weight: 800;
}
.event-block.task-block.done .eb-title {
  opacity: 0.55;
  text-decoration: line-through;
}
.event-block.task-block .eb-time { color: var(--text-muted); }
.month-event.task-marker {
  background: var(--bg-elev) !important;
  border: 1px dashed;
  color: var(--text);
  font-weight: 500;
}
.month-event.task-marker.done {
  opacity: 0.55;
  text-decoration: line-through;
}
.event-block .eb-time { font-size: 10px; opacity: 0.85; }
.event-block .eb-title { white-space: nowrap; text-overflow: ellipsis; overflow: hidden; font-weight: 600; }

.now-line {
  position: absolute; left: 0; right: 0;
  height: 2px; background: var(--pri-critical);
  z-index: 6; pointer-events: none;
}
.now-line::before {
  content: ''; position: absolute; left: -4px; top: -3px;
  width: 8px; height: 8px; border-radius: 50%; background: var(--pri-critical);
}

/* Month view */
.cal-month {
  display: grid;
  grid-template-rows: auto 1fr;
  height: calc(100vh - 200px);
}
.cal-month-header {
  display: grid; grid-template-columns: repeat(7, 1fr);
  border-bottom: 1px solid var(--border);
}
.cal-month-header div {
  padding: 10px;
  text-align: center;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  font-weight: 600;
}
.cal-month-body {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  grid-auto-rows: 1fr;
}
.month-cell {
  border-right: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  padding: 6px;
  cursor: pointer;
  overflow: hidden;
  min-height: 100px;
  transition: background 0.1s;
}
.month-cell:hover { background: var(--bg-hover); }
.month-cell.other-month { background: var(--bg); color: var(--text-dim); }
.month-cell.today { background: var(--accent-soft); }
.month-cell-date { font-size: 12px; font-weight: 600; margin-bottom: 4px; }
.month-cell.today .month-cell-date {
  display: inline-flex; width: 22px; height: 22px;
  background: var(--accent); color: white; border-radius: 50%;
  align-items: center; justify-content: center;
}
.month-event {
  font-size: 11px;
  padding: 2px 6px;
  margin-bottom: 2px;
  border-radius: 4px;
  background: var(--accent);
  color: white;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  cursor: pointer;
}
.month-more { font-size: 10px; color: var(--text-muted); padding: 2px 6px; }

/* ========== TASKS ========== */
.tasks-layout {
  display: grid;
  grid-template-columns: 220px 1fr;
  gap: 20px;
  height: calc(100vh - 120px);
}
.tasks-filters {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px;
  overflow-y: auto;
}
.filter-group { margin-bottom: 16px; }
.filter-group-title {
  font-size: 10px; text-transform: uppercase; letter-spacing: 0.6px;
  color: var(--text-dim); margin-bottom: 8px; font-weight: 700;
}
.filter-item {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 8px; border-radius: 6px;
  font-size: 13px; cursor: pointer;
  margin-bottom: 2px;
}
.filter-item:hover { background: var(--bg-hover); }
.filter-item.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.filter-item .count {
  margin-left: auto; font-size: 11px; color: var(--text-dim);
  background: var(--bg-hover); padding: 1px 6px; border-radius: 8px;
}
.filter-item.active .count { background: rgba(124,92,255,0.25); color: var(--accent); }

.tasks-main { display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.task-quick-add {
  display: flex; align-items: center; gap: 8px;
  background: var(--bg-elev); border: 1px solid var(--border);
  border-radius: 10px; padding: 8px 14px;
}
.task-quick-add input {
  flex: 1; background: transparent; border: none; outline: none;
  color: var(--text); font-size: 13.5px; padding: 6px 0;
}
.task-quick-add input::placeholder { color: var(--text-dim); }

.task-list-card {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 12px;
  flex: 1;
  overflow-y: auto;
}
.task-list { padding: 8px; }
.task-card {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 12px 14px;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.12s;
  border-left: 3px solid transparent;
}
.task-card:hover { background: var(--bg-hover); }
.task-card[draggable="true"] { cursor: grab; }
.task-card.dragging { opacity: 0.4; }
.task-card .task-title { font-size: 13.5px; font-weight: 500; }
.task-card .task-meta {
  display: flex; align-items: center; gap: 8px;
  margin-top: 6px; font-size: 11.5px; color: var(--text-muted);
  flex-wrap: wrap;
}
.task-card.priority-critical { border-left-color: var(--pri-critical); }
.task-card.priority-high { border-left-color: var(--pri-high); }
.task-card.priority-medium { border-left-color: var(--pri-medium); }
.task-card.priority-low { border-left-color: var(--pri-low); }
.task-card.done { opacity: 0.55; }
.task-card.done .task-title { text-decoration: line-through; }
.task-card.overdue .task-meta .due { color: var(--pri-critical); font-weight: 600; }

.subtask-progress {
  width: 60px; height: 4px; background: var(--bg-hover);
  border-radius: 2px; overflow: hidden;
}
.subtask-progress-bar { height: 100%; background: var(--accent); }

.task-section-header {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.7px;
  color: var(--text-dim);
  padding: 12px 14px 6px;
  font-weight: 700;
}

/* ========== NOTES ========== */
.notes-layout {
  display: grid;
  grid-template-columns: 260px 1fr;
  gap: 16px;
  height: calc(100vh - 120px);
}
.notes-list-panel {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 12px;
  display: flex; flex-direction: column;
  overflow: hidden;
}
.notes-list-header {
  padding: 12px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 8px;
}
.notes-search {
  flex: 1;
  padding: 6px 10px; background: var(--bg); border: 1px solid var(--border);
  border-radius: 6px; color: var(--text); font-size: 12.5px; outline: none;
}
.notes-folders {
  padding: 8px; border-bottom: 1px solid var(--border);
  max-height: 200px; overflow-y: auto;
}
.folder-item {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 8px; border-radius: 6px; cursor: pointer; font-size: 12.5px;
}
.folder-item:hover { background: var(--bg-hover); }
.folder-item.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.folder-add { color: var(--text-muted); font-style: italic; }
.notes-list { flex: 1; overflow-y: auto; padding: 8px; }
.note-item {
  padding: 10px 12px;
  border-radius: 8px;
  cursor: pointer;
  margin-bottom: 2px;
  border-left: 3px solid transparent;
  transition: background 0.12s;
}
.note-item:hover { background: var(--bg-hover); }
.note-item.active { background: var(--accent-soft); border-left-color: var(--accent); }
.note-item-title { font-size: 13px; font-weight: 600; display: flex; align-items: center; gap: 6px; }
.note-item-preview {
  font-size: 11.5px; color: var(--text-muted);
  margin-top: 4px;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}
.note-item-meta { font-size: 10.5px; color: var(--text-dim); margin-top: 6px; }
.pin-icon { color: var(--accent); }

.note-editor-panel {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 12px;
  display: flex; flex-direction: column;
  overflow: hidden;
  min-width: 0;
}
.note-editor-header {
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 10px;
}
.note-title-input {
  flex: 1;
  background: transparent; border: none; outline: none;
  color: var(--text); font-size: 20px; font-weight: 700;
  letter-spacing: -0.3px;
}
.note-toolbar {
  padding: 6px 12px;
  border-bottom: 1px solid var(--border);
  display: flex; gap: 4px; flex-wrap: wrap; align-items: center;
}
.note-toolbar button {
  padding: 6px 10px; border-radius: 5px;
  color: var(--text-muted); font-size: 12px; font-weight: 600;
}
.note-toolbar button:hover { background: var(--bg-hover); color: var(--text); }
.note-toolbar .divider { width: 1px; height: 18px; background: var(--border); margin: 0 4px; }
.note-body {
  flex: 1; overflow-y: auto;
  padding: 20px 32px;
  outline: none; font-size: 14.5px; line-height: 1.7;
}
.note-body:empty::before { content: 'Start writing…'; color: var(--text-dim); }
.note-body h1 { font-size: 24px; margin: 16px 0 8px; }
.note-body h2 { font-size: 20px; margin: 14px 0 6px; }
.note-body h3 { font-size: 17px; margin: 12px 0 6px; }
.note-body p { margin-bottom: 8px; }
.note-body ul, .note-body ol { padding-left: 24px; margin-bottom: 8px; }
.note-body code {
  background: var(--bg-hover); padding: 2px 6px; border-radius: 4px;
  font-family: ui-monospace, monospace; font-size: 0.9em;
}
.note-body hr { border: none; border-top: 1px solid var(--border); margin: 16px 0; }
.note-body a { color: var(--accent); text-decoration: underline; }

.note-tags {
  padding: 12px 18px; border-top: 1px solid var(--border);
  display: flex; gap: 6px; flex-wrap: wrap; align-items: center;
}
.tag-pill {
  display: inline-flex; align-items: center; gap: 4px;
  background: var(--bg-hover); color: var(--text);
  padding: 3px 9px; border-radius: 10px;
  font-size: 11.5px;
}
.tag-pill .remove { cursor: pointer; color: var(--text-dim); }
.tag-pill .remove:hover { color: var(--pri-critical); }
.tag-input {
  background: transparent; border: 1px dashed var(--border-strong);
  padding: 3px 8px; border-radius: 10px; outline: none;
  font-size: 11.5px; color: var(--text); width: 100px;
}

/* ========== FOCUS VIEW ========== */
.focus-view {
  max-width: 900px; margin: 0 auto;
  display: flex; flex-direction: column; gap: 20px;
}
.focus-timer-card {
  background: linear-gradient(135deg, var(--accent-soft), transparent);
  border: 1px solid var(--accent);
  border-radius: 16px;
  padding: 40px;
  text-align: center;
}
.focus-timer-display {
  font-size: 88px; font-weight: 800; letter-spacing: -3px;
  font-variant-numeric: tabular-nums;
  background: linear-gradient(135deg, var(--accent), var(--accent-hover));
  -webkit-background-clip: text; background-clip: text;
  color: transparent;
}
.focus-mode-label {
  font-size: 13px; text-transform: uppercase; letter-spacing: 1.5px;
  color: var(--accent); font-weight: 700; margin-bottom: 12px;
}
.focus-controls { display: flex; gap: 10px; justify-content: center; margin-top: 20px; }
.focus-task-current {
  margin-top: 16px; padding: 12px 16px;
  background: var(--bg-elev); border-radius: 8px;
  font-size: 13px; color: var(--text-muted);
}

.time-allocation {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
}
.allocation-card {
  background: var(--bg-elev); border: 1px solid var(--border);
  padding: 16px; border-radius: 10px;
}
.allocation-value { font-size: 24px; font-weight: 700; }
.allocation-label { font-size: 11px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; margin-top: 4px; }
.allocation-bar { height: 6px; background: var(--bg-hover); border-radius: 3px; overflow: hidden; margin-top: 10px; }
.allocation-bar-fill { height: 100%; border-radius: 3px; }

/* ========== MODAL ========== */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.5);
  backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center;
  z-index: 100;
  animation: fadeIn 0.15s;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideUp { from { transform: translateY(20px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
.modal {
  width: 540px; max-width: 90vw; max-height: 90vh;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: var(--shadow);
  overflow: hidden;
  display: flex; flex-direction: column;
  animation: slideUp 0.2s cubic-bezier(.2,0,.2,1);
}
.modal-header {
  padding: 18px 22px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
}
.modal-title { font-size: 16px; font-weight: 600; }
.modal-body { padding: 22px; overflow-y: auto; }
.modal-footer {
  padding: 14px 22px;
  border-top: 1px solid var(--border);
  display: flex; gap: 10px; justify-content: flex-end;
}

.form-row { margin-bottom: 14px; }
.form-row label {
  display: block; font-size: 11.5px; font-weight: 600;
  margin-bottom: 6px; color: var(--text-muted);
  text-transform: uppercase; letter-spacing: 0.4px;
}
.form-row input[type="text"],
.form-row input[type="date"],
.form-row input[type="time"],
.form-row input[type="number"],
.form-row textarea,
.form-row select {
  width: 100%;
  padding: 9px 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 7px;
  color: var(--text);
  font-size: 13.5px;
  outline: none;
  transition: border-color 0.15s;
}
.form-row input:focus, .form-row textarea:focus, .form-row select:focus {
  border-color: var(--accent);
}
.form-row textarea { resize: vertical; min-height: 70px; font-family: inherit; }
.form-row-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.form-row-grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; }

.color-picker { display: flex; gap: 8px; flex-wrap: wrap; }
.color-swatch {
  width: 26px; height: 26px; border-radius: 7px;
  cursor: pointer; border: 2px solid transparent;
  transition: transform 0.1s;
}
.color-swatch:hover { transform: scale(1.1); }
.color-swatch.selected { border-color: var(--text); }

.subtask-list { margin-top: 6px; }
.subtask-item {
  display: flex; align-items: center; gap: 8px;
  padding: 5px 0;
}
.subtask-item input[type="text"] {
  flex: 1; padding: 4px 8px; font-size: 13px;
  background: transparent; border: none;
  color: var(--text); outline: none;
}
.subtask-item input[type="text"]:focus {
  background: var(--bg); border-radius: 4px;
}
.subtask-item .task-checkbox { width: 16px; height: 16px; }
.subtask-add {
  font-size: 12px; color: var(--text-muted); cursor: pointer;
  padding: 4px 0;
}
.subtask-add:hover { color: var(--accent); }

.reminder-list { display: flex; flex-direction: column; gap: 6px; }
.reminder-item {
  display: flex; align-items: center; gap: 8px;
  font-size: 12px;
}
.reminder-item select { width: auto; padding: 4px 8px; font-size: 12px; }

/* ========== POMODORO WIDGET ========== */
.pomodoro {
  position: fixed; bottom: 20px; right: 20px;
  width: 280px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 16px;
  box-shadow: var(--shadow);
  z-index: 80;
  animation: slideUp 0.2s;
}
.pomo-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 8px;
}
.pomo-mode {
  font-size: 10px; text-transform: uppercase; letter-spacing: 1px;
  color: var(--accent); font-weight: 700;
}
.pomo-time {
  font-size: 42px; font-weight: 700; text-align: center;
  font-variant-numeric: tabular-nums; letter-spacing: -1px;
  margin: 6px 0;
}
.pomo-task {
  font-size: 11.5px; color: var(--text-muted);
  text-align: center; margin-bottom: 12px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.pomo-controls { display: flex; gap: 6px; justify-content: center; }
.pomo-controls .primary-btn,
.pomo-controls .ghost-btn { padding: 6px 12px; font-size: 12px; }
.pomo-progress {
  height: 3px; background: var(--bg-hover); border-radius: 2px;
  overflow: hidden; margin-top: 12px;
}
.pomo-progress-bar {
  height: 100%; background: var(--accent); width: 0%;
  transition: width 0.3s;
}

/* ========== TOAST ========== */
.toast-root {
  position: fixed; top: 70px; right: 20px;
  display: flex; flex-direction: column; gap: 8px;
  z-index: 200;
}
.toast {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  padding: 12px 16px;
  border-radius: 8px;
  box-shadow: var(--shadow);
  min-width: 240px;
  animation: slideInRight 0.25s;
  font-size: 13px;
}
.toast.danger { border-left-color: var(--pri-critical); }
.toast.success { border-left-color: var(--st-done); }
@keyframes slideInRight { from { transform: translateX(20px); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

/* ========== QUICK MENU ========== */
.quick-menu {
  position: absolute; top: 50px; right: 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: var(--shadow);
  padding: 6px;
  z-index: 90;
  min-width: 180px;
  animation: slideUp 0.15s;
}
.quick-menu button {
  display: flex; align-items: center; gap: 12px;
  width: 100%; padding: 8px 12px;
  border-radius: 6px;
  font-size: 13px;
  color: var(--text);
  text-align: left;
}
.quick-menu button:hover { background: var(--bg-hover); }
.quick-menu kbd { margin-left: auto; }

/* ========== SETTINGS ========== */
.settings-view { max-width: 700px; margin: 0 auto; }
.settings-section {
  background: var(--bg-elev); border: 1px solid var(--border);
  border-radius: 12px; padding: 20px; margin-bottom: 16px;
}
.settings-section-title {
  font-size: 14px; font-weight: 600; margin-bottom: 14px;
}
.setting-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}
.setting-row:last-child { border-bottom: none; }
.setting-label { font-size: 13.5px; font-weight: 500; }
.setting-desc { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.setting-control select, .setting-control input {
  padding: 6px 10px; background: var(--bg); border: 1px solid var(--border);
  border-radius: 6px; color: var(--text); font-size: 12.5px;
}
.toggle {
  width: 40px; height: 22px; border-radius: 11px;
  background: var(--bg-hover); position: relative; cursor: pointer;
  transition: background 0.2s;
}
.toggle::after {
  content: ''; position: absolute; top: 2px; left: 2px;
  width: 18px; height: 18px; border-radius: 50%; background: white;
  transition: transform 0.2s;
}
.toggle.on { background: var(--accent); }
.toggle.on::after { transform: translateX(18px); }

.category-row {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; background: var(--bg); border-radius: 6px;
  margin-bottom: 6px;
}
.category-color {
  width: 16px; height: 16px; border-radius: 4px;
}
.category-name { flex: 1; font-size: 13px; }

/* Drag-over highlight on cal */
.hour-line.drop-target { background: var(--accent-soft); border-bottom-color: var(--accent); }

/* ========== RESPONSIVE ========== */
@media (max-width: 900px) {
  .sidebar { position: absolute; height: 100%; z-index: 50; transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); box-shadow: var(--shadow); }
  #expandSidebar { display: inline-flex !important; }
  .dash-grid { grid-template-columns: 1fr; }
  .dash-greeting { grid-column: span 1; }
  .tasks-layout, .notes-layout { grid-template-columns: 1fr; }
  .topbar-center { display: none; }
}

/* =========================================
   AUTHENTICATION STYLES
========================================= */
.login-overlay {
  position: fixed; inset: 0; background: var(--bg); z-index: 9999;
  display: flex; align-items: center; justify-content: center;
}
.login-overlay.hidden { display: none !important; }

.login-modal {
  background: var(--surface); padding: 35px; border-radius: 12px;
  border: 1px solid var(--border); width: 100%; max-width: 320px;
  display: flex; flex-direction: column; gap: 15px;
  box-shadow: 0 10px 40px rgba(0,0,0,0.5);
}

.login-modal input {
  width: 100%; padding: 10px 12px; background: var(--bg);
  border: 1px solid var(--border); border-radius: 6px; color: var(--text);
  font-family: inherit; font-size: 14px; box-sizing: border-box;
}

.login-error { color: var(--pri-critical); font-size: 13px; text-align: center; }
.login-error.hidden { display: none; }

/* Hides the main app when logged out */
#app.hidden { display: none !important; }

