/* ── dark theme ── */
[data-theme="dark"] {
  --bg: #0e0e10;
  --surface: #18181b;
  --surface2: #232326;
  --border: rgba(255,255,255,0.06);
  --border-hover: rgba(255,255,255,0.12);
  --text: #e4e4e7;
  --text-muted: #a1a1aa;
  --text-dim: #8b8b94;
  --accent: #a78bfa;
  --accent-dim: rgba(167,139,250,0.12);
  --modal-overlay: rgba(0,0,0,0.55);
  --ev-hover-border: rgba(255,255,255,0.08);
  --ev-act-bg: rgba(0,0,0,0.3);
  --ev-act-hover: rgba(0,0,0,0.5);
  --shared-badge-bg: rgba(255,255,255,0.08);
  --half-line: rgba(255,255,255,0.03);
  --quarter-line: rgba(255,255,255,0.015);
  --month-cell-hover: rgba(255,255,255,0.03);
  --today-ring: rgba(167,139,250,0.5);
}

/* ── light theme ── */
[data-theme="light"] {
  --bg: #f4f4f5;
  --surface: #ffffff;
  --surface2: #e4e4e7;
  --border: rgba(0,0,0,0.08);
  --border-hover: rgba(0,0,0,0.15);
  --text: #18181b;
  --text-muted: #52525b;
  --text-dim: #60606a;
  --accent: #7c3aed;
  --accent-dim: rgba(124,58,237,0.1);
  --modal-overlay: rgba(0,0,0,0.3);
  --ev-hover-border: rgba(0,0,0,0.1);
  --ev-act-bg: rgba(255,255,255,0.5);
  --ev-act-hover: rgba(255,255,255,0.8);
  --shared-badge-bg: rgba(0,0,0,0.06);
  --half-line: rgba(0,0,0,0.04);
  --quarter-line: rgba(0,0,0,0.02);
  --month-cell-hover: rgba(0,0,0,0.02);
  --today-ring: rgba(124,58,237,0.4);
}

:root {
  --radius: 10px;
  --radius-sm: 6px;
  --font: 'DM Sans', -apple-system, sans-serif;
  --mono: 'DM Mono', monospace;
}

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

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: fixed;
  top: 8px;
  left: 8px;
  z-index: 3000;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  background: var(--accent);
  color: #fff;
  font-size: 13px;
  transform: translateY(-150%);
  transition: transform 0.15s ease-out;
}
.skip-link:focus { transform: translateY(0); }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

button:focus:not(:focus-visible),
[role="button"]:focus:not(:focus-visible),
[role="tab"]:focus:not(:focus-visible) { outline: none; }

input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 2px solid var(--accent) !important;
  outline-offset: 2px;
}

html, body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  height: 100%;
  overflow: hidden;
  transition: background 0.25s, color 0.25s;
}

/* ── app shell ── */
.app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  width: 100%;
  padding: 20px 24px 0;
}

/* ── header ── */
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
  flex-shrink: 0;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 14px;
}

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

.title {
  font-size: 18px;
  font-weight: 500;
  letter-spacing: -0.02em;
  color: var(--text);
}

/* ── nav controls ── */
.nav-controls {
  display: flex;
  align-items: center;
  gap: 4px;
}

.nav-btn {
  font-family: var(--font);
  font-size: 18px;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--surface);
  color: var(--text-muted);
  border: 0.5px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.15s;
  line-height: 1;
}
.nav-btn:hover { color: var(--text); background: var(--surface2); }

.nav-label {
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
  min-width: 200px;
  text-align: center;
  padding: 0 4px;
}

.nav-today-btn {
  font-family: var(--font);
  font-size: 11px;
  padding: 4px 10px;
  background: var(--accent-dim);
  color: var(--accent);
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.15s;
}
.nav-today-btn:hover { background: rgba(167,139,250,0.2); }

/* ── view switch ── */
.view-switch {
  display: flex;
  background: var(--surface);
  border-radius: var(--radius-sm);
  padding: 2px;
  border: 0.5px solid var(--border);
}

.view-btn {
  font-family: var(--font);
  font-size: 11px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  padding: 4px 9px;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.15s;
}
.view-btn.active {
  background: var(--surface2);
  color: var(--text);
}

/* ── buttons ── */
.btn-find, .btn-conflicts, .btn-calendar-tools, .btn-icon, .notes-toggle {
  font-family: var(--font);
  font-size: 13px;
  padding: 6px 14px;
  background: var(--accent-dim);
  color: var(--accent);
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.15s;
}
.btn-find:hover, .btn-conflicts:hover, .btn-calendar-tools:hover, .btn-icon:hover, .notes-toggle:hover { background: rgba(167,139,250,0.2); }

.btn-icon {
  padding: 6px 9px;
  font-size: 15px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.btn-icon:disabled { opacity: 0.4; cursor: default; }
.btn-icon:disabled:hover { background: var(--accent-dim); }

/* ── user switcher ── */
.user-switcher {
  display: flex;
  gap: 2px;
  background: var(--surface);
  border-radius: var(--radius);
  padding: 3px;
  margin-bottom: 12px;
  flex-shrink: 0;
}

.user-tab {
  flex: 1;
  font-family: var(--font);
  font-size: 13px;
  font-weight: 500;
  padding: 7px 0;
  text-align: center;
  background: transparent;
  color: var(--text-muted);
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}
.user-tab:hover { color: var(--text); }
.user-tab.active.user-0 { background: rgba(96,165,250,0.15); color: #60a5fa; }
.user-tab.active.user-1 { background: rgba(244,114,182,0.15); color: #f472b6; }
[data-theme="light"] .user-tab.active.user-0 { background: rgba(96,165,250,0.15); color: #2563eb; }
[data-theme="light"] .user-tab.active.user-1 { background: rgba(244,114,182,0.15); color: #db2777; }
.user-tab.viewing { color: var(--text); }

.user-dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
}
.user-tab.user-0 .user-dot { background: #60a5fa; }
.user-tab.user-1 .user-dot { background: #f472b6; }

.user-presence-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #22c55e;
  box-shadow: 0 0 0 3px rgba(34,197,94,0.12);
  flex-shrink: 0;
}

/* ── presence strip ── */
.presence-strip {
  min-height: 28px;
  margin: -4px 0 10px;
  padding: 6px 10px;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  background: var(--surface);
  border: 0.5px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: 11px;
}

.presence-group,
.presence-status,
.presence-viewer {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.presence-group {
  gap: 8px;
  flex-wrap: wrap;
}

.presence-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
}
.presence-dot.online {
  background: #22c55e;
  box-shadow: 0 0 0 3px rgba(34,197,94,0.12);
}
.presence-dot.offline { background: var(--text-dim); }

.presence-viewer strong {
  color: var(--text);
  font-weight: 500;
}

.presence-viewer em {
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--accent);
  font-style: normal;
}

.presence-divider {
  width: 1px;
  height: 14px;
  background: var(--border-hover);
}

.presence-update,
.presence-extra {
  color: var(--text-dim);
}

/* ── main content area ── */
.main-content {
  flex: 1;
  overflow: hidden;
  position: relative;
  display: flex;
  flex-direction: column;
}

/* ══════════════════════════════════════
   DAY / WEEK VIEW
══════════════════════════════════════ */
.grid-wrap {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  border-radius: var(--radius) var(--radius) 0 0;
  scrollbar-width: thin;
  scrollbar-color: var(--surface2) transparent;
}

.grid {
  display: grid;
  position: relative;
}

.hours { display: flex; flex-direction: column; }

.hour-label {
  height: 60px;
  display: flex;
  align-items: flex-start;
  justify-content: flex-end;
  padding-right: 10px;
  font-family: var(--mono);
  font-size: 10px;
  color: var(--text-dim);
  transform: translateY(-6px);
  flex-shrink: 0;
}

.col {
  position: relative;
  border-left: 0.5px solid var(--border);
}

.col-head {
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  border-bottom: 0.5px solid var(--border);
  position: sticky;
  top: 0;
  background: var(--bg);
  z-index: 5;
}

.col-body {
  position: relative;
}

.hour-line {
  position: absolute;
  left: 0; right: 0;
  border-top: 0.5px solid var(--border);
  pointer-events: none;
}
.hour-line.half {
  border-top: 0.5px dashed var(--half-line);
}
.hour-line.quarter {
  border-top: 0.5px dashed var(--quarter-line);
}

/* ── events ── */
.ev {
  position: absolute;
  left: 4px; right: 4px;
  border-radius: var(--radius-sm);
  padding: 5px 8px;
  cursor: grab;
  overflow: hidden;
  z-index: 2;
  transition: transform 0.1s, opacity 0.15s;
  border: 0.5px solid transparent;
  user-select: none;
}
.ev.dragging { cursor: grabbing; }

.ev-create-ghost {
  position: absolute;
  left: 4px; right: 4px;
  border-radius: var(--radius-sm);
  border: 1.5px dashed var(--accent);
  background: var(--accent-dim);
  pointer-events: none;
  z-index: 3;
  font-family: var(--mono);
  font-size: 10px;
  color: var(--accent);
  padding: 3px 6px;
  overflow: hidden;
}
.ev:hover { transform: scale(1.005); border-color: var(--ev-hover-border); }
.ev:focus-visible { z-index: 8; border-color: var(--accent); }
.ev.conflict { box-shadow: inset 0 0 0 1px rgba(248,113,113,0.8); }
.ev.done { opacity: 0.35; }
.ev.done .ev-title { text-decoration: line-through; }

.ev-title {
  font-size: 12px;
  font-weight: 500;
  line-height: 1.3;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ev-time {
  font-family: var(--mono);
  font-size: 10px;
  margin-top: 2px;
  opacity: 0.6;
}

.ev-meta {
  font-family: var(--mono);
  font-size: 9px;
  margin-top: 2px;
  opacity: 0.48;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ev .ev-actions {
  position: absolute;
  top: 3px; right: 5px;
  display: flex; gap: 2px;
  opacity: 0;
  transition: opacity 0.15s;
}
.ev:hover .ev-actions,
.ev:focus-within .ev-actions { opacity: 1; }

.ev-act {
  font-size: 11px;
  cursor: pointer;
  background: var(--ev-act-bg);
  border: none;
  border-radius: 3px;
  padding: 1px 4px;
  line-height: 1.4;
  color: inherit;
}
.ev-act:hover { background: var(--ev-act-hover); }

.resize-handle {
  position: absolute;
  left: 0; right: 0;
  height: 6px;
  z-index: 3;
}
.resize-handle.top { top: 0; cursor: ns-resize; }
.resize-handle.bottom { bottom: 0; cursor: ns-resize; }

/* ── now line ── */
.now-line {
  position: absolute;
  left: 0; right: 0;
  height: 0;
  border-top: 1.5px solid rgba(250,204,21,0.85);
  z-index: 4;
  pointer-events: none;
}
.now-line::before {
  content: '';
  position: absolute;
  width: 7px; height: 7px;
  border-radius: 50%;
  background: rgba(250,204,21,0.9);
  top: -4px; left: -2px;
}

.ev-shared {
  display: inline-block;
  font-family: var(--mono);
  font-size: 9px;
  padding: 1px 4px;
  border-radius: 3px;
  background: var(--shared-badge-bg);
  margin-left: 5px;
  vertical-align: middle;
  opacity: 0.7;
}

.empty-state {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  text-align: center;
  color: var(--text-dim);
  font-size: 13px;
  pointer-events: none;
}
.empty-state span {
  display: block;
  font-size: 11px;
  margin-top: 4px;
  opacity: 0.6;
}

/* ══════════════════════════════════════
   MONTH VIEW
══════════════════════════════════════ */
.month-view {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border-radius: var(--radius) var(--radius) 0 0;
  border: 0.5px solid var(--border);
}

.month-day-headers {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  border-bottom: 0.5px solid var(--border);
  background: var(--surface);
  flex-shrink: 0;
}

.month-day-header {
  text-align: center;
  font-size: 11px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  padding: 8px 0;
}

.month-body {
  flex: 1;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--surface2) transparent;
}

.month-row {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  border-bottom: 0.5px solid var(--border);
  min-height: 110px;
}
.month-row:last-child { border-bottom: none; }

.month-cell {
  border-right: 0.5px solid var(--border);
  padding: 6px;
  cursor: pointer;
  transition: background 0.12s;
  position: relative;
  overflow: hidden;
}
.month-cell:last-child { border-right: none; }
.month-cell:hover { background: var(--month-cell-hover); }
.month-cell.other-month { opacity: 0.35; }
.month-cell.today { background: var(--accent-dim); box-shadow: inset 0 0 0 1.5px var(--accent); }

.month-date-num {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
  margin-bottom: 4px;
  width: 22px;
  height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
}
.month-cell.today .month-date-num {
  background: var(--accent);
  color: #fff;
}
[data-theme="dark"] .month-cell.today .month-date-num { color: #0e0e10; }

.month-ev-pill {
  font-size: 11px;
  font-weight: 500;
  padding: 2px 6px;
  border-radius: 4px;
  margin-bottom: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  cursor: pointer;
  transition: filter 0.1s;
}
.month-ev-pill:hover { filter: brightness(1.15); }
.month-ev-pill.done { opacity: 0.45; text-decoration: line-through; }

.month-more {
  font-size: 10px;
  color: var(--text-dim);
  padding: 1px 4px;
  margin-top: 1px;
}

/* ══════════════════════════════════════
   YEAR VIEW
══════════════════════════════════════ */
.year-view {
  flex: 1;
  overflow-y: auto;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  padding: 12px 4px;
  scrollbar-width: thin;
  scrollbar-color: var(--surface2) transparent;
  align-content: start;
}

@media (max-width: 900px) {
  .year-view { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 600px) {
  .year-view { grid-template-columns: repeat(2, 1fr); }
}

.mini-month {
  background: var(--surface);
  border: 0.5px solid var(--border);
  border-radius: var(--radius);
  padding: 10px;
}

.mini-month-header {
  font-size: 12px;
  font-weight: 500;
  color: var(--text);
  margin-bottom: 8px;
  text-transform: capitalize;
  cursor: pointer;
  transition: color 0.15s;
}
.mini-month-header:hover { color: var(--accent); }

.mini-day-headers {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  margin-bottom: 4px;
}
.mini-day-headers span {
  text-align: center;
  font-size: 9px;
  color: var(--text-dim);
  text-transform: uppercase;
}

.mini-week {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  margin-bottom: 2px;
}

.mini-cell {
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  color: var(--text-muted);
  border-radius: 50%;
  cursor: pointer;
  transition: background 0.12s, color 0.12s;
  position: relative;
}
.mini-cell:hover { background: var(--surface2); color: var(--text); }
.mini-cell.other-month { opacity: 0.25; }
.mini-cell.today {
  background: var(--accent);
  color: #fff;
  font-weight: 600;
}
[data-theme="dark"] .mini-cell.today { color: #0e0e10; }
.mini-cell.has-events::after {
  content: '';
  position: absolute;
  bottom: 1px;
  left: 50%;
  transform: translateX(-50%);
  width: 3px; height: 3px;
  border-radius: 50%;
  background: var(--accent);
}
.mini-cell.today::after { background: rgba(255,255,255,0.7); }

/* ══════════════════════════════════════
   MODAL
══════════════════════════════════════ */
.modal-bg {
  position: fixed;
  inset: 0;
  background: var(--modal-overlay);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(4px);
}

.modal {
  background: var(--surface);
  border: 0.5px solid var(--border-hover);
  border-radius: var(--radius);
  padding: 22px;
  width: 340px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.modal h3 {
  font-size: 15px;
  font-weight: 500;
}

.field label {
  display: block;
  font-size: 10px;
  color: var(--text-muted);
  margin-bottom: 4px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.field input, .field select, .field textarea {
  width: 100%;
  font-family: var(--font);
  font-size: 14px;
  padding: 7px 10px;
  background: var(--surface2);
  color: var(--text);
  border: 0.5px solid var(--border);
  border-radius: var(--radius-sm);
  outline: none;
  transition: border-color 0.15s;
}
.field textarea {
  resize: vertical;
  min-height: 60px;
  font-family: var(--font);
}
.field input[type="date"],
.field input[type="time"] { font-family: var(--mono); font-size: 13px; }
.field input[type="time"]::-webkit-calendar-picker-indicator { cursor: pointer; opacity: 0.5; }
.field input[type="time"]::-webkit-calendar-picker-indicator:hover { opacity: 1; }
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--accent); }
.field select option { background: var(--surface2); color: var(--text); }

.field-row { display: flex; gap: 8px; }
.field-row .field { flex: 1; }

.shared-toggle {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 0;
}
.shared-toggle > label {
  font-size: 13px;
  color: var(--text-muted);
  cursor: pointer;
  text-transform: none;
  letter-spacing: 0;
  margin-bottom: 0;
}

.toggle-switch {
  position: relative;
  width: 34px;
  height: 18px;
  flex-shrink: 0;
  display: inline-block;
}
.toggle-switch input { opacity: 0; width: 0; height: 0; position: absolute; }
.toggle-slider {
  position: absolute;
  inset: 0;
  background: var(--surface2);
  border-radius: 9px;
  cursor: pointer;
  transition: background 0.2s;
  border: 0.5px solid var(--border);
}
.toggle-slider::before {
  content: '';
  position: absolute;
  width: 12px; height: 12px;
  left: 3px; top: 50%;
  transform: translateY(-50%);
  background: var(--text-muted);
  border-radius: 50%;
  transition: all 0.2s;
}
.toggle-switch input:checked + .toggle-slider {
  background: rgba(167,139,250,0.25);
  border-color: rgba(167,139,250,0.3);
}
.toggle-switch input:focus-visible + .toggle-slider {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}
.toggle-switch input:checked + .toggle-slider::before {
  left: 18px;
  background: var(--accent);
}

.color-picker-row {
  display: flex;
  gap: 5px;
  flex-wrap: wrap;
  padding-top: 2px;
}
.color-swatch {
  width: 24px; height: 24px;
  border-radius: 5px;
  border: 2px solid transparent;
  cursor: pointer;
  transition: border-color 0.15s, transform 0.1s;
  position: relative;
  padding: 0;
}
.color-swatch:hover { transform: scale(1.1); }
.color-swatch:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.color-swatch.active { border-color: var(--text); }
.color-swatch.active::after {
  content: '\2713';
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: bold;
  color: white;
  text-shadow: 0 1px 2px rgba(0,0,0,0.5);
}

/* ── Custom color row ── */
.color-custom-row {
  margin-top: 6px;
}

.color-swatch-custom {
  position: relative;
  width: 24px;
  height: 24px;
  border-radius: 5px;
  border: 2px solid transparent;
  cursor: pointer;
  transition: border-color 0.15s, transform 0.1s;
  flex-shrink: 0;
}
.color-swatch-custom:hover { transform: scale(1.1); }
.color-swatch-custom.active { border-color: var(--text); }
.color-swatch-custom.active::after {
  content: '\2713';
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: bold;
  color: white;
  text-shadow: 0 1px 2px rgba(0,0,0,0.6);
  pointer-events: none;
  z-index: 1;
}

.color-swatch-inner {
  width: 100%;
  height: 100%;
  border-radius: 3px;
  border: none;
  padding: 0;
  cursor: pointer;
}

.color-swatch-del {
  position: absolute;
  top: -5px;
  right: -5px;
  width: 13px;
  height: 13px;
  border-radius: 50%;
  background: var(--text-muted);
  color: var(--bg);
  border: none;
  font-size: 10px;
  line-height: 13px;
  text-align: center;
  cursor: pointer;
  padding: 0;
  display: none;
  z-index: 2;
}
.color-swatch-custom:hover .color-swatch-del { display: block; }
.color-swatch-del:hover { background: #f87171; }

.color-add-btn {
  width: 24px;
  height: 24px;
  border-radius: 5px;
  border: 2px dashed var(--border-hover);
  background: transparent;
  color: var(--text-muted);
  font-size: 15px;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s, transform 0.1s;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  user-select: none;
}
.color-add-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
  transform: scale(1.1);
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  .ev:hover,
  .color-swatch:hover,
  .color-swatch-custom:hover,
  .color-add-btn:hover,
  .btn-icon:hover, .nav-btn:hover, .nav-today-btn:hover,
  .btn-icon:active, .nav-btn:active, .mbtn:active, .nav-today-btn:active { transform: none; }
}

.conflict-warning {
  font-size: 11px;
  color: #f87171;
  line-height: 1.4;
  min-height: 14px;
}

.event-meta {
  font-size: 11px;
  color: var(--text-dim);
  line-height: 1.4;
  margin-top: -4px;
}

.repeat-days {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.repeat-day {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  color: var(--text-muted);
  cursor: pointer;
}

.modal-btns {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  margin-top: 2px;
}

.mbtn {
  font-family: var(--font);
  font-size: 13px;
  padding: 7px 16px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  border: none;
  transition: background 0.15s;
}
.mbtn:disabled { opacity: 0.5; cursor: default; }
.mbtn-cancel { background: var(--surface2); color: var(--text-muted); }
.mbtn-cancel:hover { color: var(--text); }
.mbtn-save { background: var(--accent); color: white; font-weight: 500; }
[data-theme="dark"] .mbtn-save { color: #0e0e10; }
.mbtn-save:hover { filter: brightness(1.1); }

/* ── Find time modal ── */
.find-time-modal {
  width: 520px;
  max-height: calc(100vh - 48px);
}

.find-time-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.find-time-close {
  width: 26px;
  height: 26px;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-muted);
  font-size: 19px;
  line-height: 1;
  cursor: pointer;
}
.find-time-close:hover { background: var(--surface2); color: var(--text); }

.find-time-copy {
  color: var(--text-muted);
  font-size: 12px;
  line-height: 1.4;
  margin-top: -6px;
}

.find-time-summary {
  font-size: 12px;
  color: var(--accent);
  min-height: 18px;
}

.find-time-results {
  display: flex;
  flex-direction: column;
  gap: 8px;
  overflow-y: auto;
  padding-right: 2px;
}

.find-time-result {
  display: grid;
  grid-template-columns: 92px minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  padding: 10px;
  background: var(--surface2);
  border: 0.5px solid var(--border);
  border-radius: var(--radius-sm);
}
.find-time-result:hover { border-color: var(--border-hover); }

.find-time-date,
.find-time-slot {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.find-time-date strong,
.find-time-slot strong {
  color: var(--text);
  font-size: 13px;
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.find-time-date span,
.find-time-slot span {
  color: var(--text-muted);
  font-size: 11px;
  margin-top: 2px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.find-time-actions {
  display: flex;
  gap: 6px;
}

.find-time-actions .mbtn {
  padding: 6px 10px;
  font-size: 12px;
}

.find-time-empty {
  padding: 16px 10px;
  color: var(--text-muted);
  font-size: 12px;
  text-align: center;
  border: 0.5px dashed var(--border-hover);
  border-radius: var(--radius-sm);
}

/* ── Conflict center ── */
.conflict-center-modal,
.import-preview-modal {
  width: min(720px, calc(100vw - 32px));
  max-height: calc(100vh - 44px);
  overflow-y: auto;
}

.conflict-center-head,
.import-preview-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.conflict-center-head h3,
.import-preview-head h3 {
  font-size: 16px;
  margin-bottom: 3px;
}

.conflict-center-head p,
.import-preview-head p {
  color: var(--text-muted);
  font-size: 12px;
  line-height: 1.4;
}

.conflict-center-close,
.import-preview-close {
  width: 28px;
  height: 28px;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-muted);
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
}
.conflict-center-close:hover,
.import-preview-close:hover { background: var(--surface2); color: var(--text); }

.conflict-center-controls {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.conflict-center-controls label {
  min-width: 150px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.conflict-center-controls span {
  color: var(--text-muted);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.conflict-center-controls select {
  width: 100%;
  font-family: var(--font);
  font-size: 13px;
  padding: 7px 10px;
  background: var(--surface2);
  color: var(--text);
  border: 0.5px solid var(--border);
  border-radius: var(--radius-sm);
  outline: none;
}

.conflict-center-summary {
  color: var(--accent);
  font-size: 12px;
  min-height: 18px;
}

.conflict-center-list,
.import-preview-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.conflict-center-row {
  display: grid;
  grid-template-columns: 118px minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  padding: 10px;
  background: var(--surface2);
  border: 0.5px solid rgba(248,113,113,0.25);
  border-radius: var(--radius-sm);
}

.conflict-center-date,
.conflict-center-events {
  min-width: 0;
}

.conflict-center-date strong,
.conflict-center-events span {
  display: block;
  color: var(--text);
  font-size: 12px;
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.conflict-center-date span,
.conflict-center-events em {
  display: block;
  color: var(--text-muted);
  font-size: 11px;
  font-style: normal;
  margin-top: 2px;
}

.conflict-center-actions {
  display: flex;
  gap: 6px;
}

.conflict-center-actions .mbtn {
  padding: 6px 10px;
  font-size: 12px;
}

.conflict-center-empty,
.import-preview-more {
  padding: 15px 10px;
  color: var(--text-muted);
  font-size: 12px;
  text-align: center;
  border: 0.5px dashed var(--border-hover);
  border-radius: var(--radius-sm);
}

.import-preview-row {
  display: grid;
  grid-template-columns: 18px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  padding: 10px;
  background: var(--surface2);
  border: 0.5px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
}

.import-preview-row input {
  accent-color: var(--accent);
}

.import-preview-row strong,
.import-preview-row em {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.import-preview-row strong {
  color: var(--text);
  font-size: 12px;
  font-weight: 500;
}

.import-preview-row em {
  color: var(--text-muted);
  font-size: 11px;
  font-style: normal;
  margin-top: 2px;
}

/* ── Calendar tools ── */
.calendar-tools-modal {
  width: min(700px, calc(100vw - 32px));
  max-height: calc(100vh - 44px);
  overflow-y: auto;
}

.calendar-tools-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.calendar-tools-head h3 {
  font-size: 16px;
  margin-bottom: 3px;
}

.calendar-tools-head p {
  color: var(--text-muted);
  font-size: 12px;
  line-height: 1.4;
}

.calendar-tools-close {
  width: 28px;
  height: 28px;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-muted);
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
}
.calendar-tools-close:hover { background: var(--surface2); color: var(--text); }

.calendar-tools-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.calendar-tools-panel {
  background: var(--surface2);
  border: 0.5px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 13px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-width: 0;
}

.calendar-tools-panel-head h4 {
  color: var(--text);
  font-size: 13px;
  font-weight: 500;
  margin-bottom: 2px;
}

.calendar-tools-panel-head span,
.calendar-tools-hint {
  color: var(--text-muted);
  font-size: 11px;
  line-height: 1.4;
}

.calendar-tools-panel .field select {
  width: 100%;
  font-family: var(--font);
  font-size: 13px;
  padding: 7px 10px;
  background: var(--bg);
  color: var(--text);
  border: 0.5px solid var(--border);
  border-radius: var(--radius-sm);
  outline: none;
}

.calendar-tools-primary {
  width: 100%;
  font-family: var(--font);
  font-size: 13px;
  padding: 8px 12px;
  border: none;
  border-radius: var(--radius-sm);
  background: var(--accent);
  color: white;
  font-weight: 500;
  cursor: pointer;
  transition: filter 0.15s;
}
[data-theme="dark"] .calendar-tools-primary { color: #0e0e10; }
.calendar-tools-primary:hover { filter: brightness(1.08); }

.calendar-tools-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.calendar-tools-actions .export-btn {
  flex: 1;
  min-width: 120px;
}

/* ── Analytics dashboard ── */
.analytics-modal {
  width: min(920px, calc(100vw - 32px));
  max-height: calc(100vh - 40px);
  overflow-y: auto;
  gap: 14px;
}

.analytics-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.analytics-header h3 {
  font-size: 16px;
  margin-bottom: 3px;
}

.analytics-header p {
  color: var(--text-muted);
  font-size: 12px;
  line-height: 1.4;
}

.analytics-close {
  width: 28px;
  height: 28px;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-muted);
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
}
.analytics-close:hover { background: var(--surface2); color: var(--text); }

.analytics-controls {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.analytics-controls label {
  min-width: 150px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.analytics-controls span {
  color: var(--text-muted);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.analytics-controls select {
  width: 100%;
  font-family: var(--font);
  font-size: 13px;
  padding: 7px 10px;
  background: var(--surface2);
  color: var(--text);
  border: 0.5px solid var(--border);
  border-radius: var(--radius-sm);
  outline: none;
}
.analytics-controls select:focus { border-color: var(--accent); }

.analytics-kpis {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.analytics-kpi {
  background: var(--surface2);
  border: 0.5px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px;
  min-width: 0;
}

.analytics-kpi span,
.analytics-kpi em {
  display: block;
  color: var(--text-muted);
  font-size: 11px;
  font-style: normal;
}

.analytics-kpi strong {
  display: block;
  color: var(--accent);
  font-size: 25px;
  font-weight: 500;
  line-height: 1.1;
  margin: 3px 0;
}

.analytics-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.analytics-panel {
  background: var(--surface2);
  border: 0.5px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px;
  min-width: 0;
}

.analytics-panel-wide {
  grid-column: 1 / -1;
}

.analytics-panel-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 10px;
  margin-bottom: 10px;
}

.analytics-panel-head h4 {
  color: var(--text);
  font-size: 13px;
  font-weight: 500;
}

.analytics-panel-head span {
  color: var(--text-muted);
  font-size: 11px;
  text-align: right;
}

.analytics-bar-row {
  display: grid;
  grid-template-columns: 76px minmax(0, 1fr) 44px;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}
.analytics-bar-row:last-child { margin-bottom: 0; }

.analytics-bar-label {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  color: var(--text-muted);
  font-size: 12px;
}

.analytics-color-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.analytics-bar-track,
.analytics-profile-track {
  height: 8px;
  background: var(--bg);
  border-radius: 99px;
  overflow: hidden;
}

.analytics-bar-fill,
.analytics-profile-track div {
  height: 100%;
  border-radius: 99px;
}

.analytics-bar-value {
  color: var(--text-muted);
  font-family: var(--mono);
  font-size: 11px;
  text-align: right;
}

.analytics-week-bars {
  height: 150px;
  display: grid;
  grid-template-columns: repeat(8, minmax(0, 1fr));
  gap: 8px;
  align-items: end;
}

.analytics-week {
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  align-items: center;
  gap: 6px;
}

.analytics-week-bar {
  width: 100%;
  min-height: 4px;
  border-radius: 5px 5px 2px 2px;
  background: linear-gradient(180deg, var(--accent), rgba(167,139,250,0.28));
}

.analytics-week span {
  color: var(--text-muted);
  font-size: 10px;
  white-space: nowrap;
}

.analytics-heatmap {
  display: grid;
  grid-template-columns: 34px repeat(4, 1fr);
  gap: 5px;
  align-items: center;
}

.analytics-heatmap span {
  color: var(--text-muted);
  font-size: 10px;
  text-align: center;
}

.analytics-heat-cell {
  height: 22px;
  border-radius: 4px;
  background: var(--accent);
}

.analytics-profile-row,
.analytics-event-row {
  display: grid;
  grid-template-columns: 92px minmax(0, 1fr) 42px;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}
.analytics-profile-row:last-child,
.analytics-event-row:last-child { margin-bottom: 0; }

.analytics-profile-row strong,
.analytics-event-row strong {
  display: block;
  color: var(--text);
  font-size: 12px;
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.analytics-profile-row span,
.analytics-event-row span {
  display: block;
  color: var(--text-muted);
  font-size: 10px;
  margin-top: 2px;
}

.analytics-profile-row em,
.analytics-event-row em {
  color: var(--text-muted);
  font-family: var(--mono);
  font-size: 11px;
  font-style: normal;
  text-align: right;
}

.analytics-profile-row.user-0 .analytics-profile-track div { background: #60a5fa; }
.analytics-profile-row.user-1 .analytics-profile-track div { background: #f472b6; }

.analytics-event-row {
  grid-template-columns: minmax(0, 1fr) 46px;
  padding-bottom: 8px;
  border-bottom: 0.5px solid var(--border);
}

.analytics-empty,
.analytics-empty-small {
  border: 0.5px dashed var(--border-hover);
  border-radius: var(--radius-sm);
  padding: 18px 12px;
  color: var(--text-muted);
  text-align: center;
  font-size: 12px;
}

.analytics-empty strong {
  display: block;
  color: var(--text);
  font-size: 14px;
  font-weight: 500;
  margin-bottom: 4px;
}

/* ══════════════════════════════════════
   NOTES PANEL
══════════════════════════════════════ */
.notes-panel {
  position: fixed;
  top: 0; right: -320px;
  width: 320px;
  height: 100vh;
  background: var(--surface);
  border-left: 0.5px solid var(--border-hover);
  z-index: 90;
  display: flex;
  flex-direction: column;
  transition: right 0.25s ease, background 0.25s;
  box-shadow: -4px 0 24px rgba(0,0,0,0.12);
}
.notes-panel.open { right: 0; }

.notes-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px 10px;
  border-bottom: 0.5px solid var(--border);
  flex-shrink: 0;
}
.notes-header h3 { font-size: 14px; font-weight: 500; }

.notes-close {
  font-size: 18px;
  background: none; border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 4px;
  line-height: 1;
}
.notes-close:hover { color: var(--text); background: var(--surface2); }

.notes-list {
  flex: 1;
  overflow-y: auto;
  padding: 10px 14px;
  display: flex;
  flex-direction: column;
  gap: 7px;
  scrollbar-width: thin;
  scrollbar-color: var(--surface2) transparent;
}

.note-item {
  background: var(--surface2);
  border-radius: var(--radius-sm);
  padding: 9px 11px;
  border: 0.5px solid var(--border);
  transition: border-color 0.15s;
}
.note-item:hover { border-color: var(--border-hover); }

.note-text {
  font-size: 13px;
  line-height: 1.5;
  color: var(--text);
  white-space: pre-wrap;
  word-break: break-word;
}

.note-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 5px;
}

.note-time {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--text-dim);
}

.note-del {
  font-size: 13px;
  background: none; border: none;
  color: var(--text-dim);
  cursor: pointer;
  padding: 0 4px;
  border-radius: 3px;
  opacity: 0;
  transition: opacity 0.15s;
}
.note-item:hover .note-del { opacity: 1; }
.note-del:hover { color: #f87171; background: rgba(248,113,113,0.1); }

.notes-input-area {
  padding: 10px 14px;
  border-top: 0.5px solid var(--border);
  flex-shrink: 0;
}
.notes-input-row { display: flex; gap: 7px; }

.notes-input {
  flex: 1;
  font-family: var(--font);
  font-size: 13px;
  padding: 7px 9px;
  background: var(--surface2);
  color: var(--text);
  border: 0.5px solid var(--border);
  border-radius: var(--radius-sm);
  outline: none;
  resize: none;
  min-height: 34px;
  max-height: 80px;
  transition: border-color 0.15s;
}
.notes-input:focus { border-color: var(--accent); }
.notes-input::placeholder { color: var(--text-dim); }

.notes-send {
  font-family: var(--font);
  font-size: 13px;
  padding: 7px 13px;
  background: var(--accent);
  color: #0e0e10;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-weight: 500;
  align-self: flex-end;
  transition: filter 0.15s;
}
[data-theme="light"] .notes-send { color: white; }
.notes-send:hover { filter: brightness(1.1); }

.notes-empty {
  text-align: center;
  color: var(--text-dim);
  font-size: 12px;
  padding: 28px 0;
}

.note-actions {
  display: flex;
  gap: 2px;
  opacity: 0;
  transition: opacity 0.15s;
}
.note-item:hover .note-actions { opacity: 1; }

.note-edit-btn {
  font-size: 12px;
  background: none;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  padding: 0 4px;
  border-radius: 3px;
  transition: color 0.15s, background 0.15s;
}
.note-edit-btn:hover { color: var(--accent); background: var(--accent-dim); }

.note-edit-input {
  width: 100%;
  font-family: var(--font);
  font-size: 13px;
  line-height: 1.5;
  color: var(--text);
  background: var(--surface);
  border: 0.5px solid var(--accent);
  border-radius: var(--radius-sm);
  padding: 4px 6px;
  resize: none;
  outline: none;
  overflow: hidden;
  margin-bottom: 4px;
}

.note-text { cursor: default; }
.note-text:hover { cursor: text; }

/* ══════════════════════════════════════
   SEARCH
══════════════════════════════════════ */
.search-container {
  flex-direction: column;
  background: var(--surface);
  border: 0.5px solid var(--border-hover);
  border-radius: var(--radius);
  margin-bottom: 10px;
  flex-shrink: 0;
  overflow: hidden;
}

.search-bar-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-bottom: 0.5px solid var(--border);
}

.search-icon-inline {
  font-size: 14px;
  opacity: 0.5;
  flex-shrink: 0;
}

.search-input {
  flex: 1;
  font-family: var(--font);
  font-size: 14px;
  background: transparent;
  color: var(--text);
  border: none;
  outline: none;
}
.search-input::placeholder { color: var(--text-dim); }

.search-close-btn {
  font-size: 16px;
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 4px;
  line-height: 1;
  flex-shrink: 0;
}
.search-close-btn:hover { color: var(--text); background: var(--surface2); }

.search-results {
  max-height: 260px;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--surface2) transparent;
}

.search-empty {
  padding: 14px 16px;
  font-size: 12px;
  color: var(--text-dim);
  text-align: center;
}

.search-result {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  cursor: pointer;
  border-bottom: 0.5px solid var(--border);
  transition: background 0.1s;
}
.search-result:last-child { border-bottom: none; }
.search-result:hover { background: var(--surface2); }
.search-result.done { opacity: 0.5; }

.search-result-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
}

.search-result-date {
  font-size: 11px;
  color: var(--text-muted);
  min-width: 90px;
  flex-shrink: 0;
}
.search-result-date.today { color: var(--accent); font-weight: 500; }

.search-result-time {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--text-dim);
  min-width: 90px;
  flex-shrink: 0;
}

.search-result-name {
  font-size: 13px;
  font-weight: 500;
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.search-result-name mark {
  background: rgba(167,139,250,0.25);
  color: inherit;
  border-radius: 2px;
  padding: 0 1px;
}

.search-result-tag {
  font-family: var(--mono);
  font-size: 9px;
  color: var(--text-dim);
  background: var(--surface2);
  padding: 1px 5px;
  border-radius: 3px;
  flex-shrink: 0;
}

/* ══════════════════════════════════════
   REPEAT MODAL
══════════════════════════════════════ */
.repeat-ev-chip {
  font-size: 12px;
  font-weight: 500;
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.freq-btns {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}

.freq-btn {
  font-family: var(--font);
  font-size: 12px;
  padding: 5px 12px;
  border-radius: var(--radius-sm);
  border: 0.5px solid var(--border-hover);
  background: var(--surface2);
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.15s;
}
.freq-btn:hover { color: var(--text); border-color: var(--accent); }
.freq-btn.active {
  background: var(--accent-dim);
  color: var(--accent);
  border-color: var(--accent);
}

.repeat-preview-box {
  font-size: 12px;
  color: var(--text-muted);
  background: var(--surface2);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  line-height: 1.5;
  min-height: 34px;
}
.repeat-preview-box.warn { color: #f87171; }

/* ══════════════════════════════════════
   AUTH OVERLAY
══════════════════════════════════════ */
.auth-overlay {
  position: fixed;
  inset: 0;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 32px;
  z-index: 1000;
  padding: 32px 24px;
  overflow-y: auto;
}

/* ── Landing hero ── */
.auth-hero {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  text-align: center;
  animation: auth-in 0.4s ease both;
}

.auth-wordmark {
  font-size: 52px;
  font-weight: 500;
  letter-spacing: -0.05em;
  line-height: 1;
  color: var(--accent);
  text-shadow: 0 0 80px rgba(167,139,250,0.18);
}

.auth-tagline {
  font-size: 14px;
  color: var(--text-muted);
  letter-spacing: -0.01em;
  margin: 0;
}

@keyframes auth-in {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0);    }
}

.auth-card {
  background: var(--surface);
  border: 0.5px solid var(--border-hover);
  border-radius: var(--radius);
  padding: 28px 28px;
  width: 100%;
  max-width: 360px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  box-shadow: 0 8px 40px rgba(0,0,0,0.2);
  animation: auth-in 0.4s ease 0.1s both;
}

.auth-tabs {
  display: flex;
  gap: 2px;
  background: var(--surface2);
  border-radius: var(--radius-sm);
  padding: 3px;
}

.auth-tab {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--text-muted);
  padding: 7px 0;
  font-size: 13px;
  font-weight: 500;
  border-radius: 4px;
  cursor: pointer;
  font-family: var(--font);
  transition: all 0.15s;
}
.auth-tab:hover { color: var(--text); }
.auth-tab.active {
  background: var(--bg);
  color: var(--accent);
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.auth-form.hidden { display: none; }

.auth-form input {
  font-family: var(--font);
  font-size: 14px;
  padding: 10px 12px;
  background: var(--surface2);
  color: var(--text);
  border: 0.5px solid var(--border);
  border-radius: var(--radius-sm);
  outline: none;
  transition: border-color 0.15s;
}
.auth-form input:focus { border-color: var(--accent); }
.auth-form input::placeholder { color: var(--text-dim); }

.auth-form button[type="submit"] {
  font-family: var(--font);
  font-size: 14px;
  padding: 10px 16px;
  background: var(--accent);
  color: white;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-weight: 500;
  margin-top: 4px;
  transition: filter 0.15s;
}
[data-theme="dark"] .auth-form button[type="submit"] { color: #0e0e10; }
.auth-form button[type="submit"]:hover { filter: brightness(1.1); }

.auth-divider {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text-dim);
  font-size: 11px;
  margin: 2px 0;
}
.auth-divider::before, .auth-divider::after {
  content: '';
  flex: 1;
  height: 0.5px;
  background: var(--border);
}

.auth-google-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-family: var(--font);
  font-size: 13px;
  font-weight: 500;
  padding: 10px 16px;
  background: var(--surface2);
  color: var(--text);
  border: 0.5px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}
.auth-google-btn:hover { background: var(--border-hover); }

.auth-error {
  font-size: 12px;
  color: #f87171;
  min-height: 14px;
  text-align: center;
}

.auth-hint {
  font-size: 11px;
  color: var(--text-dim);
  text-align: center;
  line-height: 1.5;
}
.auth-hint code {
  font-family: var(--mono);
  background: var(--surface2);
  padding: 1px 5px;
  border-radius: 3px;
  font-size: 10px;
}

/* ══════════════════════════════════════
   USER PILL (logged-in indicator + logout)
══════════════════════════════════════ */
.user-pill {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--surface);
  border: 0.5px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 3px 3px 3px 10px;
  font-size: 11px;
  margin-right: 4px;
}

.user-pill-name {
  color: var(--text-muted);
  font-family: var(--mono);
}

.user-pill-logout,
.user-pill-settings {
  font-family: var(--font);
  font-size: 11px;
  padding: 4px 8px;
  background: var(--surface2);
  color: var(--text-muted);
  border: none;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.15s;
}
.user-pill-settings { font-size: 13px; padding: 3px 7px; }
.user-pill-settings:hover,
.user-pill-logout:hover { color: var(--text); background: var(--border-hover); }

/* ══════════════════════════════════════
   SETTINGS MODAL
══════════════════════════════════════ */
.settings-modal {
  width: 380px;
  max-height: 85vh;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--surface2) transparent;
}

.settings-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.settings-close-btn {
  font-size: 18px;
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0 2px;
  line-height: 1;
  transition: color 0.15s;
}
.settings-close-btn:hover { color: var(--text); }

.settings-section {
  border-top: 0.5px solid var(--border);
  padding-top: 14px;
  margin-top: 4px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.settings-section-title {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-muted);
}

.settings-save-btn {
  align-self: flex-end;
  padding: 6px 18px;
  font-size: 12px;
}

.settings-insights-btn {
  width: 100%;
  margin-top: 10px;
  background: var(--accent-dim);
  color: var(--accent);
  border: 0.5px solid rgba(167,139,250,0.28);
  font-size: 12px;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.settings-insights-btn:hover {
  background: rgba(167,139,250,0.2);
  border-color: var(--accent);
  color: var(--text);
}

.settings-msg {
  font-size: 11px;
  min-height: 14px;
  line-height: 1.4;
}
.settings-msg-error { color: #f87171; }
.settings-msg-ok    { color: #6ee7b7; }

/* ══════════════════════════════════════
   TOAST NOTIFICATIONS
══════════════════════════════════════ */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(12px);
  background: var(--surface);
  color: var(--text);
  border: 0.5px solid var(--border-hover);
  border-radius: var(--radius);
  padding: 10px 18px;
  font-size: 13px;
  z-index: 9999;
  opacity: 0;
  pointer-events: none;
  transition: transform 0.25s ease, opacity 0.25s;
  box-shadow: 0 4px 24px rgba(0,0,0,0.25);
  white-space: nowrap;
}
.toast.show { transform: translateX(-50%) translateY(0); opacity: 1; }
.toast.toast-error  { border-color: rgba(248,113,113,0.5); color: #f87171; }
.toast.toast-success{ border-color: rgba(52,211,153,0.4);  color: #6ee7b7; }
.toast.toast-info   { border-color: var(--border-hover); }

/* ══════════════════════════════════════
   SYNC BAR (top loading indicator)
══════════════════════════════════════ */
.sync-bar {
  position: fixed;
  top: 0; left: 0;
  width: 40%;
  height: 2px;
  background: var(--accent);
  z-index: 9998;
  animation: sync-slide 1.2s ease-in-out infinite alternate;
  border-radius: 0 2px 2px 0;
}
@keyframes sync-slide {
  0%   { left: 0;   width: 30%; opacity: 0.8; }
  100% { left: 70%; width: 30%; opacity: 1;   }
}

/* ══════════════════════════════════════
   MONTH EMPTY STATE
══════════════════════════════════════ */
.month-empty-state {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  text-align: center;
  color: var(--text-dim);
  font-size: 14px;
  pointer-events: none;
  width: 100%;
}
.month-empty-state span {
  display: block;
  font-size: 11px;
  margin-top: 6px;
  opacity: 0.6;
}

/* ══════════════════════════════════════
   MOBILE RESPONSIVE  (≤ 640px)
══════════════════════════════════════ */
@media (max-width: 640px) {
  .app { padding: 12px 10px 0; }

  /* Header: wrap into two rows */
  .header { flex-wrap: wrap; gap: 8px; margin-bottom: 10px; }
  .header-left { flex: 1; gap: 8px; min-width: 0; }
  .header-right { width: 100%; gap: 4px; overflow-x: auto; padding-bottom: 2px; flex-wrap: nowrap; }

  .title { font-size: 15px; }
  .nav-label { min-width: 120px; font-size: 12px; }
  .presence-strip {
    align-items: flex-start;
    flex-direction: column;
    gap: 5px;
    margin-top: -6px;
  }
  .presence-divider { display: none; }
  .presence-viewer em { max-width: 180px; }
  .analytics-modal { width: calc(100vw - 24px); max-height: calc(100vh - 24px); }
  .conflict-center-modal,
  .import-preview-modal { width: calc(100vw - 24px); max-height: calc(100vh - 24px); }
  .calendar-tools-modal { width: calc(100vw - 24px); max-height: calc(100vh - 24px); }
  .calendar-tools-grid { grid-template-columns: 1fr; }
  .conflict-center-row {
    grid-template-columns: 1fr;
    align-items: stretch;
    gap: 8px;
  }
  .conflict-center-actions { justify-content: flex-end; flex-wrap: wrap; }
  .analytics-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .analytics-grid { grid-template-columns: 1fr; }
  .analytics-panel-wide { grid-column: auto; }
  .analytics-week-bars { height: 120px; gap: 5px; }
  .analytics-week span { font-size: 9px; }
  .analytics-bar-row { grid-template-columns: 70px minmax(0, 1fr) 40px; }
  .analytics-profile-row { grid-template-columns: 82px minmax(0, 1fr) 38px; }

  /* Hide undo/redo on mobile — covered by the swipe-friendly tap flow */
  #btn-undo, #btn-redo { display: none; }

  /* Bigger tap targets for event action buttons; always visible (no hover on touch) */
  .ev .ev-actions { opacity: 1; gap: 3px; }
  .ev-act { padding: 3px 7px; font-size: 13px; }

  /* Allow week grid to scroll horizontally so all 7 columns are reachable */
  .grid-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .grid { min-width: 520px; }

  /* Tighter month cells */
  .month-row { min-height: 64px; }
  .month-cell { padding: 3px; }
  .month-ev-pill { font-size: 10px; padding: 1px 3px; }
  .month-day-header { font-size: 10px; }

  /* Modal: full-width */
  .modal { width: calc(100vw - 24px); }
  .find-time-result {
    grid-template-columns: 1fr;
    align-items: stretch;
    gap: 8px;
  }
  .find-time-actions { justify-content: flex-end; }

  /* Notes panel: full width */
  .notes-panel { width: 100%; right: -100%; }
  .notes-panel.open { right: 0; }

  /* Hide username in pill — just show logout button */
  .user-pill-name { display: none; }

  /* Landing: tighter on small screens */
  .auth-overlay { gap: 24px; padding: 24px 16px; }
  .auth-wordmark { font-size: 40px; }
  .auth-tagline  { font-size: 13px; }
}
.user-pill-logout:hover { color: #f87171; background: rgba(248,113,113,0.1); }

/* ══════════════════════════════════════
   SETTINGS — STATS
══════════════════════════════════════ */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}

.stat-card {
  background: var(--surface2);
  border: 0.5px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 8px;
  text-align: center;
  transition: border-color 0.15s;
}
.stat-card:hover { border-color: var(--border-hover); }

.stat-value {
  font-size: 22px;
  font-weight: 500;
  color: var(--accent);
  line-height: 1.1;
  letter-spacing: -0.02em;
}

.stat-label {
  font-size: 10px;
  color: var(--text-muted);
  margin-top: 3px;
  line-height: 1.3;
}

.stat-extras {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 2px;
}

.stat-extra-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  color: var(--text-muted);
  background: var(--surface2);
  border: 0.5px solid var(--border);
  border-radius: 20px;
  padding: 3px 9px;
}
.stat-extra-pill strong { color: var(--text); font-weight: 500; }

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

/* ══════════════════════════════════════
   SETTINGS — PROFILE EMOJI
══════════════════════════════════════ */
.profile-field {
  display: flex;
  align-items: center;
  gap: 8px;
}

.profile-field label {
  display: inline;
  font-size: 12px;
  color: var(--text-muted);
  white-space: nowrap;
  flex-shrink: 0;
  min-width: 52px;
  margin-bottom: 0;
  text-transform: none;
  letter-spacing: 0;
}

.profile-field input:last-of-type {
  flex: 1;
}

.emoji-picker-wrap {
  position: relative;
  flex-shrink: 0;
}

.emoji-picker-btn {
  width: 36px;
  height: 34px;
  border-radius: var(--radius-sm);
  border: 0.5px solid var(--border);
  background: var(--surface2);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  transition: border-color 0.15s, background 0.15s;
  color: var(--text-muted);  /* for the '+' placeholder */
}
.emoji-picker-btn:hover { border-color: var(--accent); background: var(--accent-dim); }

.emoji-picker-popover {
  position: fixed;
  background: var(--surface);
  border: 0.5px solid var(--border-hover);
  border-radius: var(--radius);
  padding: 8px;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 4px;
  box-shadow: 0 8px 28px rgba(0,0,0,0.25);
  z-index: 2000;
  opacity: 0;
  pointer-events: none;
  transform: translateY(-4px);
  transition: opacity 0.15s ease, transform 0.15s ease;
}
.emoji-picker-popover.open {
  opacity: 1;
  pointer-events: all;
  transform: translateY(0);
}

.emoji-opt {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  border: 1.5px solid transparent;
  background: transparent;
  font-size: 17px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  transition: background 0.1s, border-color 0.1s;
}
.emoji-opt:hover  { background: var(--surface2); }
.emoji-opt.active { border-color: var(--accent); background: var(--accent-dim); }

.user-emoji {
  font-size: 14px;
  line-height: 1;
  margin-right: 1px;
}

/* ══════════════════════════════════════
   SETTINGS — EXPORT
══════════════════════════════════════ */
.export-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.export-label {
  font-size: 12px;
  color: var(--text-muted);
  white-space: nowrap;
}

.export-select {
  font-family: var(--font);
  font-size: 13px;
  padding: 5px 9px;
  background: var(--surface2);
  color: var(--text);
  border: 0.5px solid var(--border);
  border-radius: var(--radius-sm);
  outline: none;
  cursor: pointer;
  transition: border-color 0.15s;
}
.export-select:focus { border-color: var(--accent); }

.export-btns {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.export-btn {
  background: var(--surface2);
  color: var(--text-muted);
  border: 0.5px solid var(--border);
  font-size: 12px;
  padding: 6px 12px;
  transition: all 0.15s;
}
.export-btn:hover {
  color: var(--text);
  border-color: var(--accent);
  background: var(--accent-dim);
}

/* ══════════════════════════════════════
   SETTINGS — DANGER ZONE
══════════════════════════════════════ */
.settings-danger-zone {
  border-color: rgba(248, 113, 113, 0.2) !important;
}

.danger-title {
  color: #f87171 !important;
}

.danger-desc {
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.5;
}

.danger-btn {
  background: rgba(248, 113, 113, 0.1);
  color: #f87171;
  border: 0.5px solid rgba(248, 113, 113, 0.3);
  font-size: 12px;
  padding: 6px 14px;
  align-self: flex-start;
  transition: all 0.15s;
}
.danger-btn:hover {
  background: rgba(248, 113, 113, 0.2);
  border-color: rgba(248, 113, 113, 0.6);
}

/* ══════════════════════════════════════
   MOTION & MICRO-INTERACTIONS
   (globally disabled by the prefers-reduced-motion block above)
══════════════════════════════════════ */
.modal-bg { animation: modal-fade 0.16s ease; }
.modal-bg > .modal { animation: modal-pop 0.22s cubic-bezier(0.16, 1, 0.3, 1); }
@keyframes modal-fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes modal-pop {
  from { opacity: 0; transform: translateY(10px) scale(0.985); }
  to   { opacity: 1; transform: none; }
}

/* View cross-fade — animates the container itself (added in app.js only on a
   view-mode change). It must NOT target the children (`> *`): renderGrid()
   rebuilds those on every edit/toggle/navigate, and since the class persists
   on the container, child-targeted animation would replay on every render and
   make the whole grid blink. Animating the container runs the animation once
   per view switch and is unaffected by later child replacement. */
.main-content.view-enter { animation: view-enter 0.2s ease; }
@keyframes view-enter {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: none; }
}

/* Now-line marker: a soft, slow pulse to draw the eye to the current time. */
.now-line::before { animation: now-pulse 2.6s ease-in-out infinite; }
@keyframes now-pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.4; } }

/* Button micro-interactions: a subtle lift on hover, a press-down on active. */
.btn-icon, .nav-btn, .view-btn, .mbtn, .auth-google-btn, .nav-today-btn {
  transition: transform 0.12s ease, background 0.15s ease, border-color 0.15s ease, filter 0.15s ease, color 0.15s ease;
}
.btn-icon:hover, .nav-btn:hover, .nav-today-btn:hover { transform: translateY(-1px); }
.btn-icon:active, .nav-btn:active, .mbtn:active, .nav-today-btn:active { transform: translateY(0) scale(0.97); }

/* ══════════════════════════════════════
   COMMAND PALETTE (⌘K)
══════════════════════════════════════ */

/* ══════════════════════════════════════
   LIQUID GLASS SHELL
   Kept as a focused override block so the treatment can be reverted without
   disturbing calendar layout or event colors.
══════════════════════════════════════ */
:root {
  --glass-bg: rgba(24, 24, 27, 0.78);
  --glass-bg-strong: rgba(24, 24, 27, 0.9);
  --glass-highlight: rgba(255, 255, 255, 0.12);
  --glass-shadow: 0 14px 38px rgba(0, 0, 0, 0.18);
  --liquid-pointer-x: 50vw;
  --liquid-pointer-y: 50vh;
}

[data-theme="light"] {
  --glass-bg: rgba(255, 255, 255, 0.82);
  --glass-bg-strong: rgba(255, 255, 255, 0.94);
  --glass-highlight: rgba(255, 255, 255, 0.75);
  --glass-shadow: 0 14px 38px rgba(39, 39, 42, 0.12);
}

body {
  position: relative;
  isolation: isolate;
  background:
    radial-gradient(ellipse 88px 64px at var(--liquid-pointer-x) var(--liquid-pointer-y), rgba(192, 132, 252, 0.16), rgba(139, 92, 246, 0.08) 42%, transparent 74%),
    radial-gradient(ellipse 190px 132px at calc(var(--liquid-pointer-x) + 18px) calc(var(--liquid-pointer-y) + 10px), rgba(168, 85, 247, 0.09), transparent 72%),
    radial-gradient(ellipse 42vw 31vw at 8% 19%, rgba(52, 211, 153, 0.1), transparent 72%),
    radial-gradient(ellipse 35vw 28vw at 84% 77%, rgba(248, 113, 113, 0.08), transparent 70%),
    var(--bg);
}

body::before,
body::after {
  content: '';
  position: fixed;
  z-index: -1;
  width: 42vw;
  height: 42vw;
  min-width: 320px;
  min-height: 320px;
  border-radius: 46% 54% 62% 38% / 42% 38% 62% 58%;
  pointer-events: none;
  filter: blur(64px);
  opacity: 0.2;
  transform: translate3d(0, 0, 0);
}

body::before {
  top: -22vw;
  right: -12vw;
  background: #7c3aed;
  animation: liquid-drift-a 18s ease-in-out infinite alternate;
}

body::after {
  bottom: -25vw;
  left: -14vw;
  background: #0891b2;
  animation: liquid-drift-b 23s ease-in-out infinite alternate;
}

[data-theme="light"] body::before,
[data-theme="light"] body::after { opacity: 0.11; }

.header,
.user-switcher,
.presence-strip {
  background: var(--glass-bg);
  border: 0.5px solid var(--glass-highlight);
  box-shadow: var(--glass-shadow);
  backdrop-filter: blur(18px) saturate(125%);
  -webkit-backdrop-filter: blur(18px) saturate(125%);
}

.header {
  position: relative;
  z-index: 2;
  padding: 8px 10px;
  margin: -8px -10px 14px;
  border-radius: var(--radius);
}

.user-switcher {
  position: relative;
  z-index: 1;
}

.user-tab.active.user-0,
.user-tab.active.user-1 {
  box-shadow: inset 0 0 0 0.5px currentColor, 0 0 18px color-mix(in srgb, currentColor 18%, transparent);
}

.btn-find,
.btn-conflicts,
.btn-calendar-tools,
.btn-icon,
.notes-toggle,
.nav-btn,
.nav-today-btn,
.view-switch,
.user-pill {
  border: 0.5px solid var(--glass-highlight);
  background: var(--glass-bg);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06), 0 5px 18px rgba(0, 0, 0, 0.12);
  backdrop-filter: blur(12px) saturate(130%);
  -webkit-backdrop-filter: blur(12px) saturate(130%);
}

.btn-find:hover,
.btn-conflicts:hover,
.btn-calendar-tools:hover,
.btn-icon:hover,
.notes-toggle:hover,
.nav-btn:hover,
.nav-today-btn:hover {
  border-color: currentColor;
  background: color-mix(in srgb, var(--accent) 16%, var(--glass-bg));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.1), 0 0 20px color-mix(in srgb, var(--accent) 22%, transparent);
}

#btn-conflicts:hover {
  color: #fca5a5;
  border-color: rgba(248, 113, 113, 0.7);
  background: rgba(127, 29, 29, 0.3);
  box-shadow: 0 0 20px rgba(248, 113, 113, 0.18);
}

#btn-find-time:hover {
  color: #86efac;
  border-color: rgba(74, 222, 128, 0.7);
  background: rgba(20, 83, 45, 0.3);
  box-shadow: 0 0 20px rgba(74, 222, 128, 0.18);
}

#btn-calendar-tools:hover,
#btn-notes:hover {
  color: #93c5fd;
  border-color: rgba(96, 165, 250, 0.7);
  background: rgba(30, 64, 175, 0.25);
  box-shadow: 0 0 20px rgba(96, 165, 250, 0.18);
}

.modal-bg {
  background: color-mix(in srgb, var(--modal-overlay) 78%, transparent);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.modal,
.find-time-modal,
.conflict-center-modal,
.import-preview-modal,
.calendar-tools-modal,
.analytics-modal,
.settings-modal,
.notes-panel,
.search-container,
.cmdk {
  background: var(--glass-bg-strong);
  border-color: var(--glass-highlight);
  box-shadow: var(--glass-shadow), inset 0 1px 0 rgba(255, 255, 255, 0.06);
  backdrop-filter: blur(22px) saturate(125%);
  -webkit-backdrop-filter: blur(22px) saturate(125%);
}

@keyframes liquid-drift-a {
  from { transform: translate3d(-4vw, 2vw, 0) rotate(-8deg) scale(0.96); }
  to { transform: translate3d(3vw, 5vw, 0) rotate(12deg) scale(1.08); }
}

@keyframes liquid-drift-b {
  from { transform: translate3d(3vw, -2vw, 0) rotate(8deg) scale(1.04); }
  to { transform: translate3d(-4vw, -5vw, 0) rotate(-14deg) scale(0.95); }
}

@supports not (backdrop-filter: blur(1px)) {
  .header,
  .user-switcher,
  .presence-strip,
  .btn-find,
  .btn-conflicts,
  .btn-calendar-tools,
  .btn-icon,
  .notes-toggle,
  .nav-btn,
  .nav-today-btn,
  .view-switch,
  .user-pill,
  .modal,
  .find-time-modal,
  .conflict-center-modal,
  .import-preview-modal,
  .calendar-tools-modal,
  .analytics-modal,
  .settings-modal,
  .notes-panel,
  .search-container,
  .cmdk { background: var(--surface); }
}

@media (prefers-reduced-motion: reduce) {
  body::before,
  body::after { animation: none; }
}
.cmdk-bg { align-items: flex-start; }
.cmdk {
  width: 540px;
  max-width: calc(100vw - 32px);
  margin-top: 12vh;
  padding: 0;
  gap: 0;
  overflow: hidden;
}
.cmdk-input-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  border-bottom: 0.5px solid var(--border);
}
.cmdk-icon { font-family: var(--mono); color: var(--text-dim); font-size: 14px; }
.cmdk-input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
}
.cmdk-input::placeholder { color: var(--text-dim); }
.cmdk-list {
  max-height: 320px;
  overflow-y: auto;
  padding: 6px;
  scrollbar-width: thin;
  scrollbar-color: var(--surface2) transparent;
}
.cmdk-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 13px;
  color: var(--text);
}
.cmdk-item.active { background: var(--accent-dim); }
.cmdk-label { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cmdk-kbd, .cmdk-hintbar kbd {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--text-muted);
  background: var(--surface2);
  border: 0.5px solid var(--border);
  border-radius: 4px;
  padding: 1px 5px;
}
.cmdk-empty { padding: 18px; text-align: center; color: var(--text-dim); font-size: 13px; }
.cmdk-hintbar {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 8px 14px;
  border-top: 0.5px solid var(--border);
  font-size: 11px;
  color: var(--text-dim);
}

/* ══════════════════════════════════════
   RECURRENCE CONTROL + SCOPE CHOOSER
══════════════════════════════════════ */
.recur-ends { margin-top: 8px; }
.recur-ends-row { display: flex; align-items: center; gap: 8px; }
.recur-ends-row input[type="number"] { width: 76px; }
.recur-ends-row span { font-size: 12px; color: var(--text-muted); }
.recur-preview { margin-top: 6px; font-size: 12px; color: var(--text-muted); font-family: var(--mono); }
.recur-note {
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.5;
  background: var(--surface2);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
}

.scope-modal { width: 320px; }
.scope-copy { font-size: 13px; color: var(--text-muted); line-height: 1.5; }
.scope-options { display: flex; flex-direction: column; gap: 8px; }
.scope-btn {
  background: var(--surface2);
  color: var(--text);
  border: 0.5px solid var(--border);
  text-align: left;
  padding: 10px 12px;
}
.scope-btn:hover { border-color: var(--accent); background: var(--accent-dim); }

/* ══════════════════════════════════════
   AUDIT LOG / CHANGE HISTORY
══════════════════════════════════════ */
.audit-modal { width: 460px; max-width: calc(100vw - 32px); }
.audit-header { display: flex; align-items: center; justify-content: space-between; }
.audit-copy { font-size: 12px; color: var(--text-muted); line-height: 1.5; margin: 0; }
.audit-list {
  list-style: none;
  margin: 4px 0 0;
  padding: 0;
  max-height: 52vh;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--surface2) transparent;
}
.audit-row {
  display: flex;
  align-items: baseline;
  gap: 9px;
  padding: 8px 4px;
  border-top: 0.5px solid var(--border);
  font-size: 13px;
  line-height: 1.4;
}
.audit-row:first-child { border-top: none; }
.audit-dot {
  flex-shrink: 0;
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--text-dim);
  transform: translateY(-1px);
}
.audit-created .audit-dot  { background: #6ee7b7; }
.audit-deleted .audit-dot  { background: #f87171; }
.audit-edited .audit-dot,
.audit-moved .audit-dot,
.audit-resized .audit-dot  { background: #93c5fd; }
.audit-completed .audit-dot { background: var(--accent); }
.audit-imported .audit-dot { background: #fde047; }

/* ── light glass refinement + translucent calendar surfaces ── */
[data-theme="light"] {
  --glass-bg: rgba(255, 255, 255, 0.72);
  --glass-bg-strong: rgba(255, 255, 255, 0.9);
  --glass-highlight: rgba(255, 255, 255, 0.92);
  --glass-shadow: 0 14px 38px rgba(51, 65, 85, 0.14);
}

[data-theme="light"] body::before {
  background: #60a5fa;
  opacity: 0.16;
}

[data-theme="light"] body::after {
  background: #c084fc;
  opacity: 0.14;
}

[data-theme="light"] body {
  background:
    radial-gradient(ellipse 88px 64px at var(--liquid-pointer-x) var(--liquid-pointer-y), rgba(167, 139, 250, 0.24), rgba(139, 92, 246, 0.12) 42%, transparent 74%),
    radial-gradient(ellipse 190px 132px at calc(var(--liquid-pointer-x) + 18px) calc(var(--liquid-pointer-y) + 10px), rgba(196, 181, 253, 0.22), transparent 72%),
    radial-gradient(ellipse 42vw 31vw at 8% 19%, rgba(52, 211, 153, 0.14), transparent 72%),
    radial-gradient(ellipse 35vw 28vw at 84% 77%, rgba(251, 113, 133, 0.12), transparent 70%),
    var(--bg);
}

[data-theme="light"] .ev,
[data-theme="light"] .month-ev-pill {
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.62), 0 5px 14px rgba(51, 65, 85, 0.1);
  border-color: rgba(255, 255, 255, 0.65);
}

[data-theme="light"] .ev.done { opacity: 0.52; }
[data-theme="light"] .month-ev-pill.done { opacity: 0.62; }

.ev,
.month-ev-pill {
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.24), inset 0 -1px 0 rgba(0, 0, 0, 0.06);
}
.audit-text { flex: 1; color: var(--text); }
.audit-text strong { font-weight: 500; }
.audit-detail { color: var(--text-muted); font-family: var(--mono); font-size: 11px; }
.audit-time {
  flex-shrink: 0;
  font-size: 11px;
  color: var(--text-dim);
  font-family: var(--mono);
  white-space: nowrap;
}
.audit-empty { padding: 20px; text-align: center; color: var(--text-dim); font-size: 13px; }
