/* ============================================================
   Caldender — design system
   Light + dark themes via CSS custom properties.
   ============================================================ */

:root {
  --bg:           #fafaf9;
  --bg-elev:      #ffffff;
  --bg-soft:      #f4f4f5;
  --bg-hover:     #ececec;
  --text:         #18181b;
  --text-soft:    #71717a;
  --text-faint:   #a1a1aa;
  --border:       #e7e5e4;
  --border-soft:  #f0eeed;
  --accent:       #6366f1;
  --accent-hover: #4f46e5;
  --accent-soft:  rgba(99, 102, 241, 0.10);
  --danger:       #ef4444;
  --shadow-sm:    0 1px 2px rgba(15, 15, 20, 0.04);
  --shadow-md:    0 6px 20px rgba(15, 15, 20, 0.06);
  --shadow-lg:    0 18px 50px rgba(15, 15, 20, 0.12);
  --radius-sm:    8px;
  --radius-md:    12px;
  --radius-lg:    18px;
  --radius-xl:    24px;
  --hour-h:       56px;
  --time-col-w:   60px;
  --sidebar-w:    380px;
  --header-h:     68px;
}

[data-theme="dark"] {
  --bg:           #0b0b0d;
  --bg-elev:      #161618;
  --bg-soft:      #1f1f23;
  --bg-hover:     #26262b;
  --text:         #f4f4f5;
  --text-soft:    #a1a1aa;
  --text-faint:   #71717a;
  --border:       #27272a;
  --border-soft:  #1f1f23;
  --accent:       #818cf8;
  --accent-hover: #a5b4fc;
  --accent-soft:  rgba(129, 140, 248, 0.14);
  --shadow-sm:    0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow-md:    0 6px 20px rgba(0, 0, 0, 0.45);
  --shadow-lg:    0 18px 50px rgba(0, 0, 0, 0.55);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
[hidden] { display: none !important; }

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'SF Pro Text', system-ui, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  transition: background-color 0.25s ease, color 0.25s ease;
}

button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }
input, select, textarea { font-family: inherit; color: inherit; }
input::placeholder, textarea::placeholder { color: var(--text-faint); }
hr { border: none; border-top: 1px solid var(--border); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }

/* ============================================================
   Layout
   ============================================================ */
#app {
  display: grid;
  grid-template-rows: var(--header-h) 1fr;
  height: 100vh;
  overflow: hidden;
}

.layout {
  display: grid;
  grid-template-columns: 1fr var(--sidebar-w);
  gap: 0;
  min-height: 0;
  overflow: hidden;
}

/* ============================================================
   Top bar
   ============================================================ */
.topbar {
  display: grid;
  grid-template-columns: 280px 1fr auto auto;
  align-items: center;
  gap: 16px;
  padding: 0 22px;
  background: var(--bg-elev);
  border-bottom: 1px solid var(--border);
  height: var(--header-h);
  position: relative;
  z-index: 20;
}

.brand { display: flex; align-items: center; gap: 12px; }

.logo {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--accent), #a855f7);
  color: white;
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 16px;
  box-shadow: var(--shadow-sm);
  letter-spacing: -0.02em;
}

.brand-text h1 {
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.01em;
}
.brand-sub {
  font-size: 12px;
  color: var(--text-soft);
  margin-top: 1px;
}

/* Search */
.search-wrap {
  position: relative;
  max-width: 460px;
  width: 100%;
  justify-self: center;
}
.search-wrap input {
  width: 100%;
  height: 38px;
  background: var(--bg-soft);
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  padding: 0 14px 0 38px;
  font-size: 13px;
  transition: background 0.15s, border-color 0.15s;
}
.search-wrap input:focus {
  outline: none;
  background: var(--bg-elev);
  border-color: var(--border);
  box-shadow: var(--shadow-sm);
}
.search-icon {
  position: absolute;
  left: 13px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-faint);
  pointer-events: none;
}
.search-results {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  max-height: 320px;
  overflow-y: auto;
  z-index: 50;
  padding: 6px;
}
.search-results .result {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 10px 12px;
  border-radius: 8px;
  cursor: pointer;
}
.search-results .result:hover { background: var(--bg-soft); }
.search-results .result:active { background: var(--accent-soft); }
.search-results .result-title { font-weight: 500; font-size: 13px; }
.search-results .result-meta { font-size: 12px; color: var(--text-soft); }
.search-results .empty { padding: 14px; text-align: center; color: var(--text-soft); font-size: 13px; }

/* Nav controls */
.nav-controls {
  display: flex;
  align-items: center;
  gap: 4px;
  background: var(--bg-soft);
  border-radius: var(--radius-md);
  padding: 4px;
}

.actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.icon-btn {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  border-radius: 10px;
  color: var(--text-soft);
  font-size: 16px;
  transition: background 0.15s, color 0.15s;
}
.icon-btn:hover { background: var(--bg-hover); color: var(--text); }

.pill-btn {
  height: 32px;
  padding: 0 14px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  transition: background 0.15s, color 0.15s, transform 0.06s;
}
.pill-btn:hover { background: var(--bg-hover); }
.pill-btn:active { transform: scale(0.98); }
.pill-btn.primary {
  background: var(--accent);
  color: white;
  box-shadow: var(--shadow-sm);
}
.pill-btn.primary:hover { background: var(--accent-hover); }

/* Theme toggle: show one icon per theme */
.theme-icon-dark { display: none; }
[data-theme="dark"] .theme-icon-light { display: none; }
[data-theme="dark"] .theme-icon-dark { display: inline; }

/* Menu */
.menu-wrap { position: relative; }
.menu-items {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  min-width: 180px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  padding: 6px;
  z-index: 50;
  display: flex;
  flex-direction: column;
}
.menu-items button {
  text-align: left;
  padding: 9px 12px;
  border-radius: 8px;
  font-size: 13px;
  color: var(--text);
}
.menu-items button:hover { background: var(--bg-soft); }
.menu-items button.danger { color: var(--danger); }
.menu-items hr { margin: 4px 0; }

/* ============================================================
   Calendar
   ============================================================ */
.calendar {
  display: grid;
  grid-template-rows: auto 1fr;
  background: var(--bg);
  min-height: 0;
  overflow: hidden;
}

.day-headers {
  display: grid;
  grid-template-columns: var(--time-col-w) 1fr;
  border-bottom: 1px solid var(--border);
  background: var(--bg-elev);
}
.time-col-spacer { width: var(--time-col-w); }
.day-headers-inner {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
}
.day-head {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 12px 8px;
  cursor: pointer;
  border-left: 1px solid var(--border-soft);
  transition: background 0.15s;
  user-select: none;
}
.day-head:first-child { border-left: none; }
.day-head:hover { background: var(--bg-soft); }
.day-head.is-today .day-num {
  background: var(--accent);
  color: white;
}
.day-head.is-selected { background: var(--accent-soft); }
.day-head .day-name {
  font-size: 11px;
  font-weight: 500;
  color: var(--text-soft);
  letter-spacing: 0.02em;
  text-transform: uppercase;
}
.day-head .day-num {
  margin-top: 4px;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 15px;
  font-weight: 600;
}
.day-head.is-weekend .day-name { color: var(--text-faint); }

/* Body grid: time labels + 7 day columns */
.cal-body {
  display: grid;
  grid-template-columns: var(--time-col-w) 1fr;
  overflow-y: auto;
  position: relative;
}

.time-col {
  display: grid;
  grid-template-rows: repeat(24, var(--hour-h));
  background: var(--bg-elev);
  border-right: 1px solid var(--border);
}
.time-label {
  position: relative;
  font-size: 10px;
  color: var(--text-faint);
  text-align: right;
  padding-right: 8px;
  padding-top: 2px;
  letter-spacing: 0.04em;
}

.days-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  position: relative;
}
.day-col {
  position: relative;
  border-left: 1px solid var(--border-soft);
  background:
    repeating-linear-gradient(
      to bottom,
      transparent 0,
      transparent calc(var(--hour-h) - 1px),
      var(--border-soft) calc(var(--hour-h) - 1px),
      var(--border-soft) var(--hour-h)
    );
  min-height: calc(var(--hour-h) * 24);
  cursor: cell;
}
.day-col:first-child { border-left: none; }
.day-col.is-today {
  background-color: rgba(99, 102, 241, 0.025);
}
[data-theme="dark"] .day-col.is-today {
  background-color: rgba(129, 140, 248, 0.05);
}

/* "Now" indicator line */
.now-line {
  position: absolute;
  left: 0;
  right: 0;
  height: 2px;
  background: var(--danger);
  z-index: 5;
  pointer-events: none;
}
.now-line::before {
  content: '';
  position: absolute;
  left: -5px;
  top: -4px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--danger);
}

/* Event cards */
.event {
  position: absolute;
  left: 4px;
  right: 4px;
  border-radius: 8px;
  padding: 6px 8px;
  background: var(--accent);
  color: white;
  font-size: 12px;
  overflow: hidden;
  cursor: grab;
  touch-action: none;
  box-shadow: var(--shadow-sm);
  transition: transform 0.08s, box-shadow 0.15s, filter 0.15s;
  border-left: 3px solid rgba(0, 0, 0, 0.18);
  z-index: 2;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.event:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
  filter: brightness(1.04);
  z-index: 3;
}
.event.is-dragging {
  cursor: grabbing;
  z-index: 50;
  opacity: 0.96;
  box-shadow: var(--shadow-lg);
  transition: none;
}
.event.is-dragging:hover { transform: none; filter: brightness(1.06); }

/* Resize handle: bottom edge, subtle indicator on hover */
.event-resize-handle {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 7px;
  cursor: ns-resize;
  touch-action: none;
}
.event-resize-handle::after {
  content: '';
  position: absolute;
  bottom: 2px;
  left: 50%;
  transform: translateX(-50%);
  width: 22px;
  height: 2px;
  border-radius: 2px;
  background: rgba(255, 255, 255, 0.6);
  opacity: 0;
  transition: opacity 0.12s;
}
.event:hover .event-resize-handle::after,
.event.is-dragging .event-resize-handle::after { opacity: 1; }

body.is-dragging { user-select: none; cursor: grabbing; }
body.is-dragging * { cursor: inherit !important; }

.day-col.is-drop-target {
  background-color: var(--accent-soft);
}
[data-theme="dark"] .day-col.is-drop-target {
  background-color: rgba(129, 140, 248, 0.12);
}
.event-title {
  font-weight: 600;
  font-size: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.event-time {
  font-size: 10.5px;
  opacity: 0.85;
}
.event-photo-dot {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.85);
}
.event.is-search-hit { animation: pulse-event 1.4s ease-out 2; }
@keyframes pulse-event {
  0%   { box-shadow: 0 0 0 0 var(--accent); }
  70%  { box-shadow: 0 0 0 12px rgba(99, 102, 241, 0); }
  100% { box-shadow: 0 0 0 0 rgba(99, 102, 241, 0); }
}

/* ============================================================
   Sidebar (daily detail)
   ============================================================ */
.sidebar {
  background: var(--bg-elev);
  border-left: 1px solid var(--border);
  padding: 22px;
  overflow-y: auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 22px;
}

.sb-header {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.sb-header .sb-day-num {
  font-size: 30px;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.1;
}
.sb-header .sb-day-meta {
  font-size: 13px;
  color: var(--text-soft);
}

.sb-section {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.sb-section h3 {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-soft);
}

/* Schedule list */
.sb-schedule { display: flex; flex-direction: column; gap: 6px; }
.sb-schedule .sched-item {
  display: grid;
  grid-template-columns: 56px 4px 1fr;
  gap: 10px;
  align-items: center;
  padding: 8px 10px;
  border-radius: 10px;
  cursor: pointer;
  transition: background 0.12s;
}
.sb-schedule .sched-item:hover { background: var(--bg-soft); }
.sched-time {
  font-size: 11px;
  color: var(--text-soft);
  font-variant-numeric: tabular-nums;
  line-height: 1.2;
}
.sched-time span {
  display: block;
  color: var(--text-faint);
}
.sched-bar { height: 28px; border-radius: 2px; }
.sched-title {
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sb-empty {
  font-size: 13px;
  color: var(--text-faint);
  padding: 10px 0;
}

/* Priorities */
.priority-list { display: flex; flex-direction: column; gap: 8px; }
.priority-item {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--bg-soft);
  border-radius: 10px;
  padding: 8px 12px;
}
.priority-item .pri-num {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 11px;
  font-weight: 600;
  background: var(--bg-elev);
  color: var(--text-soft);
  flex-shrink: 0;
}
.priority-item input {
  flex: 1;
  background: transparent;
  border: none;
  font-size: 13px;
  outline: none;
}

/* Notes */
.notes-box {
  width: 100%;
  background: var(--bg-soft);
  border: 1px solid transparent;
  border-radius: 12px;
  padding: 12px;
  font-size: 13px;
  resize: vertical;
  min-height: 90px;
  transition: background 0.15s, border-color 0.15s;
  outline: none;
}
.notes-box:focus { background: var(--bg-elev); border-color: var(--border); }

/* Habits */
.habits { display: flex; flex-direction: column; gap: 6px; }
.habit-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 10px;
  transition: background 0.12s;
}
.habit-item:hover { background: var(--bg-soft); }
.habit-item input[type="checkbox"] {
  appearance: none;
  -webkit-appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 6px;
  border: 1.5px solid var(--border);
  background: var(--bg-elev);
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: background 0.15s, border-color 0.15s;
  flex-shrink: 0;
}
.habit-item input[type="checkbox"]:checked {
  background: var(--accent);
  border-color: var(--accent);
}
.habit-item input[type="checkbox"]:checked::after {
  content: '✓';
  color: white;
  font-size: 12px;
  font-weight: 700;
}
.habit-name {
  flex: 1;
  font-size: 13px;
  cursor: pointer;
}
.habit-item.is-done .habit-name {
  text-decoration: line-through;
  color: var(--text-faint);
}
.habit-remove {
  opacity: 0.55;
  font-size: 14px;
  color: var(--text-faint);
  transition: opacity 0.12s, color 0.12s;
  width: 22px;
  height: 22px;
  border-radius: 6px;
}
.habit-item:hover .habit-remove { opacity: 1; }
.habit-remove:focus-visible { opacity: 1; }
.habit-remove:hover { color: var(--danger); background: var(--bg-hover); }

.habit-add {
  display: flex;
  gap: 6px;
  margin-top: 4px;
}
.habit-add input {
  flex: 1;
  background: var(--bg-soft);
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 7px 10px;
  font-size: 13px;
  outline: none;
  transition: background 0.15s, border-color 0.15s;
}
.habit-add input:focus { background: var(--bg-elev); border-color: var(--border); }
.habit-add button {
  padding: 0 12px;
  height: 32px;
  border-radius: 8px;
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 500;
  font-size: 13px;
}
.habit-add button:hover { background: var(--accent); color: white; }

/* Photos */
.photos-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
}
.photo-thumb {
  position: relative;
  aspect-ratio: 1;
  border-radius: 10px;
  overflow: hidden;
  background: var(--bg-soft);
  cursor: pointer;
}
.photo-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.photo-loading {
  width: 100%;
  height: 100%;
  display: grid;
  place-items: center;
  color: var(--text-faint);
  font-size: 11px;
  background: var(--bg-soft);
}
.photo-thumb .photo-del {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.55);
  color: white;
  display: grid;
  place-items: center;
  opacity: 0;
  transition: opacity 0.15s;
  font-size: 13px;
}
.photo-thumb:hover .photo-del { opacity: 1; }
.photo-add {
  aspect-ratio: 1;
  border: 1.5px dashed var(--border);
  border-radius: 10px;
  display: grid;
  place-items: center;
  color: var(--text-soft);
  font-size: 22px;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s, background 0.15s;
}
.photo-add:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-soft);
}

/* ============================================================
   Modal
   ============================================================ */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 15, 20, 0.45);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  display: grid;
  place-items: center;
  z-index: 100;
  animation: fade-in 0.18s ease;
  padding: 20px;
}
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }

.modal-card {
  background: var(--bg-elev);
  border-radius: var(--radius-xl);
  width: 100%;
  max-width: 480px;
  max-height: calc(100vh - 40px);
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--border);
  animation: pop-in 0.22s cubic-bezier(0.2, 0.8, 0.2, 1);
}
@keyframes pop-in {
  from { opacity: 0; transform: translateY(8px) scale(0.98); }
  to   { opacity: 1; transform: none; }
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 20px 8px;
}
.modal-header h2 { font-size: 17px; font-weight: 600; letter-spacing: -0.01em; }

.modal-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 8px 20px 20px;
}
.field { display: flex; flex-direction: column; gap: 6px; }
.field > span {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-soft);
}
.field input,
.field select,
.field textarea {
  background: var(--bg-soft);
  border: 1px solid transparent;
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 13.5px;
  outline: none;
  transition: background 0.15s, border-color 0.15s;
}
.field input:focus,
.field select:focus,
.field textarea:focus {
  background: var(--bg-elev);
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.field textarea { resize: vertical; min-height: 70px; font-family: inherit; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

.photo-field { gap: 8px; }
.photo-row { display: flex; align-items: center; gap: 10px; }
.photo-upload {
  display: inline-block;
  background: var(--bg-soft);
  border-radius: 10px;
  padding: 9px 14px;
  font-size: 13px;
  cursor: pointer;
  transition: background 0.15s;
}
.photo-upload:hover { background: var(--bg-hover); }
.photo-preview {
  margin-top: 6px;
  border-radius: 12px;
  overflow: hidden;
  max-height: 200px;
  background: var(--bg-soft);
}
.photo-preview img { width: 100%; height: 100%; object-fit: cover; max-height: 200px; display: block; }

.text-btn {
  background: transparent;
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 13px;
  color: var(--text-soft);
}
.text-btn:hover { background: var(--bg-hover); color: var(--text); }
.text-btn.danger { color: var(--danger); }
.text-btn.danger:hover { background: rgba(239, 68, 68, 0.1); color: var(--danger); }
.pill-btn.danger { background: var(--danger); color: white; }

.modal-footer {
  display: flex;
  align-items: center;
  gap: 8px;
  padding-top: 4px;
}
.spacer { flex: 1; }

/* ============================================================
   Toast
   ============================================================ */
.toast {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--text);
  color: var(--bg-elev);
  padding: 10px 18px;
  border-radius: 10px;
  font-size: 13px;
  box-shadow: var(--shadow-lg);
  z-index: 200;
  animation: toast-up 0.25s ease;
}
@keyframes toast-up {
  from { opacity: 0; transform: translate(-50%, 8px); }
  to   { opacity: 1; transform: translate(-50%, 0); }
}

/* ============================================================
   Responsive
   ============================================================ */
@media (max-width: 1024px) {
  :root { --sidebar-w: 320px; }
}

@media (max-width: 860px) {
  .topbar {
    grid-template-columns: 1fr auto;
    grid-template-rows: auto auto;
    height: auto;
    padding: 12px 14px;
    gap: 10px;
    row-gap: 10px;
  }
  .brand { grid-column: 1; grid-row: 1; }
  .actions { grid-column: 2; grid-row: 1; gap: 6px; }
  .search-wrap { grid-column: 1 / 2; grid-row: 2; max-width: none; }
  .nav-controls {
    grid-column: 2;
    grid-row: 2;
    display: flex;
  }
  .nav-controls .pill-btn { display: none; }
  .brand-text h1 { font-size: 14px; }
  #newEventBtn { width: 36px; padding: 0; font-size: 0; }
  #newEventBtn::before { content: '+'; font-size: 19px; line-height: 1; }

  #app { grid-template-rows: auto 1fr; }

  .layout {
    grid-template-columns: 1fr;
    grid-template-rows: 1fr auto;
    overflow-y: auto;
  }
  .calendar { min-height: 60vh; }
  .sidebar {
    border-left: none;
    border-top: 1px solid var(--border);
    max-height: none;
  }
  /* Make calendar horizontally scrollable on phones */
  .day-headers, .cal-body { min-width: 700px; }
  .calendar { overflow-x: auto; }
  .menu-items { right: -48px; }
}

@media (max-width: 480px) {
  :root { --hour-h: 48px; --time-col-w: 48px; }
  .topbar { padding: 10px; gap: 8px; }
  .logo { width: 32px; height: 32px; border-radius: 8px; }
  .icon-btn { width: 34px; height: 34px; }
  .search-wrap input { height: 36px; }
  .sidebar { padding: 18px; gap: 20px; }
  .modal-card { border-radius: var(--radius-lg); }
  .modal-backdrop { padding: 10px; }
  .field-row { grid-template-columns: 1fr; }
  .photos-grid { grid-template-columns: repeat(4, 1fr); }
}

/* Subtle scrollbars */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 10px;
  border: 2px solid var(--bg);
}
::-webkit-scrollbar-thumb:hover { background: var(--text-faint); }
