@font-face {
  font-family: "Inter";
  src: url("fonts/inter-latin-wght-normal.woff2") format("woff2");
  font-weight: 100 900;
  font-display: swap;
}

:root {
  --bg: #f7f7f5;
  --surface: #ffffff;
  --surface-2: #f1f1ee;
  --surface-3: #e9e8e4;
  --line: #e4e3df;
  --line-soft: #eeede9;
  --text: #1c1c1e;
  --muted: #6c6c70;
  --faint: #a3a3a8;
  --accent: #3e63dd;
  --accent-soft: color-mix(in srgb, var(--accent) 12%, transparent);
  --accent-ink: #ffffff;
  --danger: #dc3e42;
  --shadow-1: 0 1px 2px rgb(0 0 0 / 0.06), 0 1px 1px rgb(0 0 0 / 0.04);
  --shadow-2: 0 10px 30px rgb(20 20 30 / 0.14), 0 2px 6px rgb(20 20 30 / 0.08);
  --radius: 12px;
  --tabbar-h: 58px;
  --topbar-h: 56px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --ease: cubic-bezier(.2, .8, .2, 1);
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #141519;
    --surface: #1b1c21;
    --surface-2: #23242a;
    --surface-3: #2c2d34;
    --line: #2d2e35;
    --line-soft: #24252b;
    --text: #ececf0;
    --muted: #9b9ca5;
    --faint: #686973;
    --accent: #7090ff;
    --accent-ink: #0d1020;
    --danger: #ff6369;
    --shadow-1: 0 1px 2px rgb(0 0 0 / 0.4);
    --shadow-2: 0 12px 36px rgb(0 0 0 / 0.5), 0 2px 8px rgb(0 0 0 / 0.35);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-feature-settings: "cv11", "ss01", "tnum";
  font-size: 15px;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }
svg { width: 20px; height: 20px; flex: none; }
[hidden] { display: none !important; }

/* ---------- buttons ---------- */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 40px; padding: 0 16px; border-radius: 10px; border: 0;
  font-weight: 600; font-size: 14.5px; letter-spacing: -0.005em;
  background: var(--surface-2); color: var(--text);
  transition: background .15s, transform .1s, opacity .15s;
}
.btn:active { transform: scale(.97); }
.btn svg { width: 18px; height: 18px; }
.btn.primary { background: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { background: color-mix(in srgb, var(--accent) 88%, black); }
.btn.ghost { background: transparent; }
.btn.ghost:hover { background: var(--surface-2); }
.btn.danger { color: var(--danger); }
.btn.danger-fill { background: var(--danger); color: #fff; }
.btn.muted { color: var(--muted); }
.btn.wide { width: 100%; height: 46px; }
.btn.small { height: 32px; padding: 0 12px; font-size: 13.5px; }
.btn:disabled { opacity: .5; }

.icon-btn {
  display: inline-grid; place-items: center; width: 40px; height: 40px;
  border: 0; border-radius: 10px; background: transparent; color: var(--muted);
  transition: background .15s, color .15s;
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.icon-btn.tiny { width: 30px; height: 30px; border-radius: 8px; }
.icon-btn.tiny svg { width: 17px; height: 17px; }

.segmented {
  display: inline-flex; padding: 3px; gap: 2px; border-radius: 11px; background: var(--surface-2);
}
.segmented button {
  height: 32px; padding: 0 12px; border: 0; border-radius: 8px; background: transparent;
  color: var(--muted); font-weight: 550; font-size: 13.5px; white-space: nowrap;
}
.segmented button.on { background: var(--surface); color: var(--text); box-shadow: var(--shadow-1); }
.segmented.small button { height: 28px; padding: 0 10px; font-size: 13px; }

/* ---------- login ---------- */

.login { min-height: 100dvh; display: grid; place-items: center; padding: 24px 16px; }
.login-card {
  width: min(380px, 100%); background: var(--surface); border-radius: 20px; padding: 32px 24px 24px;
  box-shadow: var(--shadow-2); display: flex; flex-direction: column; gap: 14px;
}
.login-icon { align-self: center; border-radius: 16px; }
.login-card h1 { margin: 0 0 6px; text-align: center; font-size: 22px; letter-spacing: -0.02em; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field > span { font-size: 13px; font-weight: 600; color: var(--muted); }
.field input, .field textarea {
  width: 100%; border: 1px solid var(--line); background: var(--bg); border-radius: 10px;
  padding: 11px 12px; outline: none; transition: border-color .15s, box-shadow .15s;
}
.field input:focus, .field textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.login-error { margin: 0; color: var(--danger); font-size: 14px; }
.login-card .btn { margin-top: 6px; }

/* ---------- shell ---------- */

.app-page { overflow: hidden; overscroll-behavior: none; }
.app { display: grid; grid-template-columns: 272px 1fr; height: 100dvh; }
.main { display: flex; flex-direction: column; min-width: 0; min-height: 0; background: var(--surface); }
.phone-only { display: none !important; }

.topbar {
  height: var(--topbar-h); flex: none; display: flex; align-items: center; gap: 6px;
  padding: 0 16px; border-bottom: 1px solid var(--line);
}
.topbar .title {
  border: 0; background: none; padding: 6px 8px; margin-left: -8px; border-radius: 8px;
  font-size: 20px; font-weight: 700; letter-spacing: -0.025em; white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis; min-width: 0;
}
.topbar .title:hover { background: var(--surface-2); }
.spacer { flex: 1; }
.nav-arrows { display: flex; }
.today-btn { gap: 8px; height: 36px; padding: 0 12px; border: 1px solid var(--line); }
.today-num {
  display: inline-grid; place-items: center; width: 22px; height: 22px; border-radius: 6px;
  border: 1.6px solid currentColor; font-size: 11px; font-weight: 700; position: relative;
}
.today-num::before {
  content: ""; position: absolute; top: -1.6px; left: -1.6px; right: -1.6px; height: 5px;
  background: currentColor; border-radius: 6px 6px 0 0;
}
.views { margin-left: 8px; }

.loading {
  width: 16px; height: 16px; border-radius: 50%; border: 2px solid var(--line);
  border-top-color: var(--accent); opacity: 0; transition: opacity .2s;
  animation: spin .8s linear infinite;
}
.loading.on { opacity: 1; }
@keyframes spin { to { transform: rotate(360deg); } }

.cal-wrap { flex: 1; min-height: 0; position: relative; }
#calendar { height: 100%; }
.cal-wrap.slide-l #calendar { animation: slide-l .22s var(--ease); }
.cal-wrap.slide-r #calendar { animation: slide-r .22s var(--ease); }
@keyframes slide-l { from { transform: translateX(24px); opacity: .4; } }
@keyframes slide-r { from { transform: translateX(-24px); opacity: .4; } }

/* ---------- sidebar ---------- */

.sidebar {
  background: var(--bg); border-right: 1px solid var(--line); padding: 16px 14px;
  display: flex; flex-direction: column; gap: 18px; overflow-y: auto; min-height: 0;
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 17px; letter-spacing: -0.02em; padding: 2px 6px; }
.brand img { border-radius: 8px; }
.new-event { height: 44px; border-radius: 12px; box-shadow: var(--shadow-1); }
.side-section h2 {
  margin: 0 0 6px; padding: 0 6px; font-size: 12px; font-weight: 650; text-transform: uppercase;
  letter-spacing: .06em; color: var(--faint);
}
.side-section .segmented { margin-left: 4px; }
.side-footer { margin-top: auto; display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 8px 6px 0; border-top: 1px solid var(--line); }
.who { color: var(--muted); font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; }

.mini-head { display: flex; align-items: center; justify-content: space-between; padding: 0 2px 6px 8px; font-weight: 650; font-size: 14px; }
.mini-head span { order: -1; flex: 1; }
.mini-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 1px; }
.mini-dow { text-align: center; font-size: 11px; font-weight: 600; color: var(--faint); padding: 4px 0; }
.mini-day {
  position: relative; aspect-ratio: 1; border: 0; background: none; border-radius: 50%;
  font-size: 12.5px; font-weight: 500; color: var(--text); padding: 0;
}
.mini-day.other { color: var(--faint); }
.mini-day.in { background: var(--accent-soft); border-radius: 6px; }
.mini-day.today { background: var(--accent); color: var(--accent-ink); font-weight: 700; border-radius: 50%; }
.mini-day.busy::after {
  content: ""; position: absolute; bottom: 3px; left: 50%; width: 3px; height: 3px; margin-left: -1.5px;
  border-radius: 50%; background: currentColor; opacity: .45;
}
.mini-day:hover:not(.today) { background: var(--surface-3); }

.cal-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 1px; }
.cal-sep { height: 1px; background: var(--line); margin: 6px 6px; }
.cal-item { display: flex; align-items: center; gap: 4px; border-radius: 10px; padding: 2px 2px 2px 6px; }
.cal-item:hover { background: var(--surface-2); }
.cal-swatch {
  width: 18px; height: 18px; border-radius: 6px; border: 0; padding: 0; flex: none;
  background: var(--ev); box-shadow: inset 0 0 0 1px rgb(0 0 0 / .08);
}
.cal-name {
  flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: flex-start;
  border: 0; background: none; padding: 7px 6px; text-align: left;
}
.cal-name .n { font-weight: 550; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.cal-name .o { font-size: 12px; color: var(--faint); }
.cal-name .o:empty { display: none; }
.cal-item.off .cal-swatch { background: transparent; box-shadow: inset 0 0 0 2px var(--ev); }
.cal-item.off .cal-name .n { color: var(--faint); }
.cal-item .star { color: var(--faint); }
.cal-item .star.on { color: #f5a524; }
.cal-item .ro { color: var(--faint); opacity: .7; }
.cal-item .eye { color: var(--faint); }

.popover {
  position: fixed; z-index: 50; display: grid; grid-template-columns: repeat(6, 30px); gap: 8px;
  padding: 12px; background: var(--surface); border-radius: 14px; box-shadow: var(--shadow-2);
  border: 1px solid var(--line);
}
.pal { width: 30px; height: 30px; border-radius: 50%; border: 0; transition: transform .1s; }
.pal:hover { transform: scale(1.1); }
.pal.on { box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--text); }

.scrim { display: none; }

/* ---------- FullCalendar theme ---------- */

.fc {
  --fc-border-color: var(--line-soft);
  --fc-page-bg-color: var(--surface);
  --fc-neutral-bg-color: var(--surface-2);
  --fc-today-bg-color: transparent;
  --fc-now-indicator-color: var(--danger);
  --fc-highlight-color: var(--accent-soft);
  --fc-event-border-color: transparent;
  --fc-list-event-hover-bg-color: var(--surface-2);
  --fc-small-font-size: 12px;
  font-size: 13px;
}
.fc .fc-scrollgrid, .fc-theme-standard td, .fc-theme-standard th { border-color: var(--line-soft); }
.fc .fc-scrollgrid { border-left: 0; border-right: 0; border-top: 0; }
.fc-theme-standard .fc-scrollgrid { border: 0; }
.fc .fc-col-header-cell { border-left-color: transparent; border-right-color: transparent; }
.fc .fc-col-header-cell-cushion { padding: 8px 4px; color: var(--muted); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; text-decoration: none; }
.fc a { color: inherit; text-decoration: none; }

/* Day headers in time views: weekday over a date bubble. */
.dh { display: flex; flex-direction: column; align-items: center; gap: 2px; text-transform: none; letter-spacing: 0; }
.dh .dow { font-size: 11.5px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.dh .num { display: grid; place-items: center; min-width: 32px; height: 32px; padding: 0 4px; border-radius: 16px; font-size: 18px; font-weight: 650; color: var(--text); letter-spacing: -0.02em; }
.dh.today .num { background: var(--accent); color: var(--accent-ink); }
.dh.today .dow { color: var(--accent); }
.fc-timegrid .fc-col-header-cell-cushion { padding: 6px 2px 8px; }

/* Month */
.fc .fc-daygrid-day-top { justify-content: center; }
.fc .fc-daygrid-day-number { padding: 4px 0 2px; }
.dnum { display: inline-grid; place-items: center; min-width: 24px; height: 24px; padding: 0 3px; border-radius: 12px; font-size: 12.5px; font-weight: 600; color: var(--text); }
.fc .fc-day-today .dnum { background: var(--accent); color: var(--accent-ink); }
.fc .fc-day-other .dnum { color: var(--faint); }
.fc .fc-day-other { background: color-mix(in srgb, var(--surface-2) 45%, transparent); }
.fc .fc-daygrid-day.fc-day-sat, .fc .fc-daygrid-day.fc-day-sun { background: color-mix(in srgb, var(--surface-2) 35%, transparent); }
.fc .fc-daygrid-day-frame { min-height: 100%; }
.fc .fc-daygrid-day-events { margin: 0 0 4px; min-height: 0; }
.fc .fc-daygrid-body-natural .fc-daygrid-day-events { margin-bottom: 4px; }

/* Events */
.fc .fc-event { cursor: pointer; transition: box-shadow .15s, transform .12s; }
.fc .fc-h-event, .fc .fc-daygrid-block-event {
  background: color-mix(in srgb, var(--ev) 16%, var(--surface));
  border: 0; border-radius: 5px;
  box-shadow: inset 3px 0 0 var(--ev);
}
.fc .fc-h-event .fc-event-main { color: color-mix(in srgb, var(--ev) 55%, var(--text)); padding: 1px 4px 1px 7px; }
.fc .fc-h-event .fc-event-title { font-weight: 600; }
.fc .fc-h-event .fc-event-time { font-weight: 500; opacity: .8; margin-right: 3px; }
/* All-day and multi-day: a solid bar that runs straight through the days. */
.fc .fc-h-event.is-allday { background: var(--ev); box-shadow: none; }
.fc .fc-h-event.is-allday .fc-event-main { color: var(--ev-ink, #fff); padding-left: 6px; }
.fc .fc-h-event:not(.fc-event-start) { border-top-left-radius: 0; border-bottom-left-radius: 0; }
.fc .fc-h-event:not(.fc-event-end) { border-top-right-radius: 0; border-bottom-right-radius: 0; }
.fc .fc-h-event.is-timed:not(.fc-event-start) { box-shadow: none; }
.fc .fc-daygrid-event { margin-top: 1px; font-size: 12px; line-height: 1.35; }
.fc .fc-daygrid-event-harness { margin: 0 1px; }
.fc .fc-daygrid-event.fc-event-start { margin-left: 3px; }
.fc .fc-daygrid-event.fc-event-end { margin-right: 3px; }
.fc .fc-event.ro { cursor: default; }

.fc .fc-v-event {
  background: color-mix(in srgb, var(--ev) 18%, var(--surface));
  border: 0; border-radius: 7px;
  box-shadow: inset 3px 0 0 var(--ev), 0 0 0 1px var(--surface);
}
.fc .fc-v-event .fc-event-main { color: color-mix(in srgb, var(--ev) 50%, var(--text)); padding: 3px 5px 3px 8px; }
.ev-body { display: flex; flex-direction: column; gap: 1px; overflow: hidden; height: 100%; }
.ev-title { font-weight: 650; font-size: 12.5px; line-height: 1.25; }
.ev-time, .ev-loc { font-size: 11.5px; opacity: .8; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fc-timegrid-event-short .ev-body { flex-direction: row; gap: 6px; align-items: baseline; }
.fc-timegrid-event-short .ev-loc { display: none; }

.fc .fc-event-dragging, .fc .fc-event-mirror { box-shadow: var(--shadow-2) !important; transform: scale(1.02); opacity: .95; z-index: 10; }
.fc .fc-event-dragging.is-allday { box-shadow: var(--shadow-2) !important; }
.fc .fc-highlight { border-radius: 6px; }
.fc .fc-event-resizer { --fc-event-resizer-thickness: 10px; }

/* Time grid */
.fc .fc-timegrid-slot { height: 2.6em; border-bottom: 0; }
.fc .fc-timegrid-slot-minor { border-top-style: none; }
.fc .fc-timegrid-slot-label-cushion { font-size: 11px; color: var(--faint); font-weight: 550; text-transform: lowercase; padding: 0 6px; }
.fc .fc-timegrid-slot-label { vertical-align: top; border: 0; }
.fc .fc-timegrid-slot-label-frame { transform: translateY(-0.7em); text-align: right; }
.fc .fc-timegrid-axis { border: 0; }
.fc .fc-timegrid-axis-cushion { font-size: 11px; color: var(--faint); }
.fc .fc-timegrid-divider { padding: 0 0 2px; background: var(--line-soft); border: 0; }
.fc .fc-daygrid-body .fc-daygrid-day-events { min-height: 6px; }
.fc .fc-timegrid-now-indicator-line { border-width: 2px 0 0; }
.fc .fc-timegrid-now-indicator-arrow { border: 0; width: 9px; height: 9px; border-radius: 50%; background: var(--danger); margin-top: -4.5px; left: auto; right: -5px; }
.fc .fc-timegrid-col.fc-day-today { background: color-mix(in srgb, var(--accent) 3%, transparent); }
.fc .fc-scrollgrid-section-sticky > * { background: var(--surface); }
.fc .fc-scrollgrid-section-header > th { border-bottom: 1px solid var(--line); }

/* Agenda */
.fc .fc-list { border: 0; }
.fc .fc-list-table { border-collapse: separate; border-spacing: 0; }
.fc .fc-list-day-cushion {
  background: color-mix(in srgb, var(--surface) 92%, transparent) !important;
  backdrop-filter: blur(8px); padding: 14px 16px 6px;
}
.fc .fc-list-day > * { border: 0; }
.fc .fc-list-day-text { font-size: 13px; font-weight: 700; letter-spacing: -0.01em; }
.fc .fc-list-day.fc-day-today .fc-list-day-text { color: var(--accent); }
.fc .fc-list-event td { border: 0; padding: 9px 12px; font-size: 14px; }
.fc .fc-list-event-time { color: var(--muted); font-size: 13px; width: 1%; padding-left: 16px !important; }
.fc .fc-list-event-graphic { padding: 9px 4px !important; }
.fc .fc-list-event-dot { border: 5px solid var(--ev); border-radius: 3px; height: 10px; width: 10px; box-sizing: border-box; }
.fc .fc-list-event-title { font-weight: 550; }
.fc .fc-list-event:hover td { background: var(--surface-2); }
.fc .fc-list-empty { background: none; }

/* ---------- sheets ---------- */

dialog.sheet {
  border: 0; padding: 0 20px 20px; color: var(--text); background: var(--surface);
  border-radius: 18px; width: min(460px, calc(100vw - 32px)); max-height: 88dvh;
  box-shadow: var(--shadow-2); overflow-y: auto; overscroll-behavior: contain;
  animation: pop-in .2s var(--ease);
}
dialog.sheet.closing { animation: pop-out .16s ease-in forwards; }
dialog.sheet::backdrop { background: rgb(10 10 20 / .32); animation: fade .2s; }
dialog.sheet.closing::backdrop { animation: fade .16s reverse forwards; }
dialog.sheet.compact { width: min(360px, calc(100vw - 32px)); padding-top: 20px; }
dialog.sheet.compact h2 { margin: 0 0 16px; font-size: 17px; text-align: center; }
@keyframes pop-in { from { opacity: 0; transform: translateY(8px) scale(.98); } }
@keyframes pop-out { to { opacity: 0; transform: translateY(8px) scale(.98); } }
@keyframes fade { from { opacity: 0; } }
.sheet-grip { display: none; }
.sheet-head {
  position: sticky; top: 0; z-index: 2; background: var(--surface);
  display: flex; align-items: center; gap: 10px; padding: 16px 0 10px; margin: 0 -4px;
}
.sheet-head h2 { flex: 1; margin: 0; font-size: 19px; font-weight: 700; letter-spacing: -0.02em; line-height: 1.25; overflow-wrap: anywhere; }
.swatch { width: 14px; height: 14px; border-radius: 4px; background: var(--ev); flex: none; margin-left: 4px; }
.stack { display: flex; flex-direction: column; gap: 8px; }

.facts { list-style: none; margin: 4px 0 0; padding: 0; display: flex; flex-direction: column; gap: 12px; }
.facts li { display: flex; gap: 14px; align-items: flex-start; font-size: 14.5px; line-height: 1.4; }
.facts svg { color: var(--faint); margin-top: 0; }
.facts .notes { white-space: pre-wrap; overflow-wrap: anywhere; color: var(--muted); }

.move-row { margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--line); display: flex; flex-direction: column; gap: 10px; }
.move-label { display: flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 650; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.move-label svg { width: 16px; height: 16px; }
.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; height: 38px; padding: 0 14px; border-radius: 19px;
  border: 1px solid var(--line); background: var(--surface); font-weight: 600; font-size: 14px;
  transition: background .15s, border-color .15s, transform .1s;
}
.chip:hover { background: var(--surface-2); }
.chip:active { transform: scale(.96); }
.chip:first-child { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.chip svg { width: 16px; height: 16px; }
.sheet-actions { display: flex; justify-content: space-between; gap: 10px; margin-top: 18px; }
.sheet-actions .btn { flex: 1; }
.readonly-note { margin-top: 16px; display: flex; gap: 8px; align-items: center; color: var(--faint); font-size: 13px; }
.readonly-note svg { width: 16px; height: 16px; }

/* Editor */
#edit-form { display: flex; flex-direction: column; gap: 14px; }
#edit-form .sheet-head h2 { text-align: center; font-size: 16px; }
.title-input {
  border: 0; border-bottom: 2px solid var(--line); background: none; padding: 6px 2px 10px;
  font-size: 22px; font-weight: 650; letter-spacing: -0.02em; outline: none; width: 100%;
}
.title-input:focus { border-color: var(--accent); }
.cal-chips { display: flex; gap: 6px; overflow-x: auto; padding: 2px 0 4px; scrollbar-width: none; }
.cal-chips::-webkit-scrollbar { display: none; }
.cal-chip {
  flex: none; display: inline-flex; align-items: center; gap: 7px; height: 32px; padding: 0 12px 0 10px;
  border-radius: 16px; border: 1px solid var(--line); background: var(--surface); font-size: 13.5px; font-weight: 550;
}
.cal-chip::before { content: ""; width: 10px; height: 10px; border-radius: 50%; background: var(--ev); }
.cal-chip.on { background: color-mix(in srgb, var(--ev) 16%, var(--surface)); border-color: var(--ev); }
.cal-chip:disabled { opacity: .4; }
.toggle-row { display: flex; align-items: center; justify-content: space-between; font-weight: 550; padding: 2px 0; }
.switch {
  appearance: none; width: 46px; height: 28px; border-radius: 14px; background: var(--surface-3);
  position: relative; transition: background .2s; margin: 0; cursor: pointer;
}
.switch::after {
  content: ""; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 3px rgb(0 0 0 / .25); transition: transform .2s var(--ease);
}
.switch:checked { background: var(--accent); }
.switch:checked::after { transform: translateX(18px); }
.when-grid { display: grid; grid-template-columns: auto 1fr auto; gap: 8px 10px; align-items: center; }
.all-day .when-grid { grid-template-columns: auto 1fr; }
.when-label { font-size: 13px; font-weight: 600; color: var(--muted); min-width: 48px; }
.when-grid input {
  border: 1px solid var(--line); background: var(--bg); border-radius: 10px; padding: 9px 10px;
  min-width: 0; outline: none; font-variant-numeric: tabular-nums;
}
.when-grid input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.icon-field { flex-direction: row; align-items: center; gap: 12px; }
.icon-field.top { align-items: flex-start; }
.icon-field.top svg { margin-top: 11px; }
.icon-field svg { color: var(--faint); }
.icon-field textarea { resize: vertical; min-height: 76px; }
.form-error { margin: 0; color: var(--danger); font-size: 14px; min-height: 0; }
.form-error:empty { display: none; }

/* Day sheet */
.day-list { list-style: none; margin: 4px 0 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.day-item {
  display: flex; gap: 12px; align-items: center; padding: 11px 12px; border-radius: 10px; cursor: pointer;
  background: color-mix(in srgb, var(--ev) 12%, var(--surface)); box-shadow: inset 3px 0 0 var(--ev);
}
.day-item .t { font-size: 12.5px; color: var(--muted); min-width: 56px; font-weight: 550; }
.day-item .n { font-weight: 600; overflow-wrap: anywhere; }
.day-empty { display: grid; place-items: center; padding: 28px 0; color: var(--faint); }
.day-empty svg { width: 34px; height: 34px; }

.hidden-date { position: fixed; bottom: 0; left: 50%; width: 1px; height: 1px; opacity: 0; pointer-events: none; }

/* Snackbar */
.snackbar {
  position: fixed; left: 50%; bottom: 24px; z-index: 100; transform: translate(-50%, 140%);
  display: flex; align-items: center; gap: 16px; min-height: 46px; padding: 6px 8px 6px 18px;
  border-radius: 12px; background: #2a2b31; color: #f2f2f5; box-shadow: var(--shadow-2);
  font-size: 14.5px; font-weight: 500; max-width: calc(100vw - 32px);
  visibility: hidden; opacity: 0; transition: transform .25s var(--ease), opacity .2s, visibility 0s .25s;
}
.snackbar.show { transform: translate(-50%, 0); visibility: visible; opacity: 1; transition: transform .25s var(--ease), opacity .2s; }
.snackbar button { border: 0; background: none; color: #9db1ff; font-weight: 700; padding: 8px 12px; border-radius: 8px; }
.snackbar button:hover { background: rgb(255 255 255 / .08); }

/* ---------- phone ---------- */

@media (max-width: 899px) {
  .desktop-only { display: none !important; }
  .phone-only { display: revert !important; }
  .app { display: block; }
  .main { height: 100dvh; }
  .topbar { padding: 0 8px 0 4px; gap: 2px; padding-top: env(safe-area-inset-top, 0px); height: calc(var(--topbar-h) + env(safe-area-inset-top, 0px)); }
  .topbar .title { font-size: 19px; margin-left: 0; }
  .today-btn { border: 0; padding: 0 10px; color: var(--muted); }
  .today-num { width: 24px; height: 24px; }

  .sidebar {
    position: fixed; z-index: 40; inset: 0 auto 0 0; width: min(320px, 86vw);
    transform: translateX(-102%); transition: transform .28s var(--ease); box-shadow: var(--shadow-2);
    padding-top: calc(16px + env(safe-area-inset-top, 0px)); padding-bottom: calc(16px + var(--safe-b));
  }
  .sidebar.open { transform: none; }
  .scrim {
    display: block; position: fixed; inset: 0; z-index: 30; background: rgb(10 10 20 / .35);
    opacity: 0; pointer-events: none; transition: opacity .25s;
  }
  .scrim.show { opacity: 1; pointer-events: auto; }

  .tabbar {
    flex: none; display: flex !important; height: calc(var(--tabbar-h) + var(--safe-b)); padding: 6px 6px var(--safe-b);
    border-top: 1px solid var(--line); background: var(--surface); gap: 2px;
  }
  .tabbar button {
    flex: 1; border: 0; background: none; border-radius: 10px; color: var(--muted);
    font-size: 12.5px; font-weight: 600; padding: 0 2px; white-space: nowrap;
  }
  .tabbar button.on { color: var(--accent); background: var(--accent-soft); }

  .fab {
    position: fixed; z-index: 20; right: 16px; bottom: calc(var(--tabbar-h) + var(--safe-b) + 16px);
    width: 56px; height: 56px; border-radius: 18px; border: 0;
    display: grid !important; place-items: center; background: var(--accent); color: var(--accent-ink);
    box-shadow: 0 6px 18px color-mix(in srgb, var(--accent) 45%, transparent), var(--shadow-1);
    transition: transform .15s;
  }
  .fab:active { transform: scale(.94); }
  .fab svg { width: 26px; height: 26px; }
  .dragging .fab { opacity: 0; pointer-events: none; }

  .snackbar { bottom: calc(var(--tabbar-h) + var(--safe-b) + 14px); }

  /* Bottom sheets */
  dialog.sheet {
    margin: auto 0 0; width: 100%; max-width: 100%; border-radius: 20px 20px 0 0;
    padding-bottom: calc(20px + var(--safe-b)); max-height: 90dvh;
    animation: sheet-up .26s var(--ease);
  }
  dialog.sheet.closing { animation: sheet-down .16s ease-in forwards; }
  dialog.sheet.compact { width: 100%; }
  .sheet-grip { display: block; position: sticky; top: 0; z-index: 3; height: 18px; margin: 0 -20px -8px; background: var(--surface); }
  .sheet-grip::before { content: ""; position: absolute; top: 7px; left: 50%; width: 38px; height: 5px; margin-left: -19px; border-radius: 3px; background: var(--surface-3); }
  .sheet-head { top: 10px; padding-top: 6px; }
  @keyframes sheet-up { from { transform: translateY(100%); } }
  @keyframes sheet-down { to { transform: translateY(100%); } }

  .fc { font-size: 12px; }
  .fc .fc-col-header-cell-cushion { font-size: 11px; padding: 6px 0; }
  .dh .num { font-size: 16px; min-width: 28px; height: 28px; }
  .dh .dow { font-size: 10.5px; }
  .fc .fc-timegrid-slot-label-cushion { padding: 0 4px; font-size: 10.5px; }
  /* Month on a phone: rows grow to show every event; titles wrap to two lines. */
  .fc .fc-daygrid-event { font-size: 11px; line-height: 1.3; }
  .fc .fc-daygrid-event .fc-event-main { padding: 0 1px 0 5px; }
  .fc .fc-h-event.is-allday .fc-event-main { padding-left: 3px; }
  .fc .fc-daygrid-event .fc-event-time { display: none; }
  .fc-dayGridMonth-view .fc-daygrid-event.fc-event-start.fc-event-end .fc-event-title {
    white-space: normal; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
    word-break: normal; overflow-wrap: normal; text-overflow: clip;
  }
  .fc-dayGridMonth-view .fc-daygrid-event { letter-spacing: -0.015em; }
  .fc .fc-daygrid-event.fc-event-start { margin-left: 2px; }
  .fc .fc-daygrid-event.fc-event-end { margin-right: 2px; }
  .fc .fc-daygrid-event-harness { margin: 0; }
  .dnum { font-size: 11.5px; min-width: 21px; height: 21px; }
  .fc .fc-daygrid-day-number { padding: 3px 0 1px; }
  .ev-title { font-size: 11.5px; }
  .ev-time, .ev-loc { font-size: 10.5px; }
  .fc .fc-v-event .fc-event-main { padding: 2px 3px 2px 6px; }
  .fc .fc-list-event td { padding: 11px 10px; }
  .fc .fc-list-day-cushion { padding: 14px 14px 6px; }
}

@media (hover: none) {
  .icon-btn:hover, .btn.ghost:hover, .chip:hover, .cal-item:hover { background: inherit; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
