:root {
  --bg: #ffffff;
  --bg-soft: #f8fafd;
  --surface: #ffffff;
  --surface-2: #f1f3f4;
  --text: #1f1f1f;
  --text-2: #444746;
  --muted: #70757a;
  --line: #dadce0;
  --line-soft: #e8eaed;
  --primary: #0b57d0;
  --primary-soft: #d3e3fd;
  --primary-text: #ffffff;
  --today: #0b57d0;
  --now: #ea4335;
  --danger: #b3261e;
  --shadow: 0 1px 3px rgba(60,64,67,.3), 0 4px 8px 3px rgba(60,64,67,.15);
  --hour: 48px;
  --radius: 8px;
  --sidebar-w: 256px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1f1f1f;
    --bg-soft: #1b1b1b;
    --surface: #2b2b2b;
    --surface-2: #333537;
    --text: #e3e3e3;
    --text-2: #c4c7c5;
    --muted: #9aa0a6;
    --line: #444746;
    --line-soft: #3a3b3c;
    --primary: #a8c7fa;
    --primary-soft: #004a77;
    --primary-text: #062e6f;
    --today: #a8c7fa;
    --now: #f28b82;
    --danger: #f2b8b5;
    --shadow: 0 1px 3px rgba(0,0,0,.5), 0 4px 8px 3px rgba(0,0,0,.35);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; margin: 0; }
body {
  font: 14px/1.4 "Google Sans", Roboto, system-ui, -apple-system, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}
button, input, select, textarea { font: inherit; color: inherit; }
svg { width: 24px; height: 24px; fill: currentColor; flex: none; }
.muted { color: var(--muted); }
.error { color: var(--danger); margin: 0; }

/* ---------- buttons ---------- */
.icon-btn {
  display: inline-grid; place-items: center;
  width: 40px; height: 40px; border-radius: 50%;
  border: 0; background: transparent; cursor: pointer; color: var(--text-2); flex: none;
}
.icon-btn:hover { background: var(--surface-2); }
.icon-btn.small { width: 28px; height: 28px; }
.icon-btn.small svg { width: 18px; height: 18px; }
.btn {
  border: 0; border-radius: 20px; padding: 8px 20px; cursor: pointer;
  background: transparent; font-weight: 500; white-space: nowrap;
}
.btn.outline { border: 1px solid var(--line); }
.btn.outline:hover, .btn.text:hover { background: var(--surface-2); }
.btn.text { color: var(--primary); padding: 8px 12px; }
.btn.primary { background: var(--primary); color: var(--primary-text); }
.btn.primary:hover { filter: brightness(1.08); box-shadow: 0 1px 3px rgba(0,0,0,.25); }
.btn.danger { color: var(--danger); }
.btn:disabled { opacity: .5; cursor: default; }

/* ---------- layout ---------- */
.app { display: flex; flex-direction: column; height: 100%; height: 100dvh; }
.topbar {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 12px; padding-top: max(8px, env(safe-area-inset-top));
  border-bottom: 1px solid var(--line-soft); background: var(--bg); min-height: 64px;
}
.brand { display: flex; align-items: center; gap: 8px; font-size: 22px; color: var(--text-2); margin-right: 24px; }
.title { font-size: 22px; font-weight: 400; margin: 0 0 0 8px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.title-btn { display: flex; align-items: center; min-width: 0; border: 0; background: none; padding: 0; cursor: default; color: inherit; }
.title-btn .caret, .today-icon, .mini-drop, .drawer-head, .view-list, .drawer-foot { display: none; }
.spacer { flex: 1; }
.nav-arrows { display: flex; }
.view-select {
  border: 1px solid var(--line); border-radius: 20px; padding: 8px 12px; background: var(--bg); cursor: pointer;
}
.search { display: flex; align-items: center; border-radius: 24px; }
.search input {
  width: 0; padding: 0; border: 0; background: transparent; outline: none; transition: width .2s;
}
.search.open { background: var(--surface-2); padding-right: 12px; }
.search.open input { width: 220px; padding: 8px 0; }
.sync-indicator { font-size: 12px; color: var(--muted); border: 1px solid var(--line); border-radius: 12px; padding: 2px 8px; }

.body { flex: 1; display: flex; min-height: 0; position: relative; }
.sidebar {
  width: var(--sidebar-w); flex: none; overflow-y: auto; padding: 8px 8px 24px 8px;
  background: var(--bg); transition: margin-left .2s;
}
.app.sidebar-hidden .sidebar { margin-left: calc(-1 * var(--sidebar-w)); }
.scrim { display: none; }
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; position: relative; }

.create-btn {
  display: flex; align-items: center; gap: 12px; margin: 8px 0 16px 0;
  padding: 0 24px 0 16px; height: 56px; border-radius: 16px; border: 0; cursor: pointer;
  background: var(--surface); box-shadow: var(--shadow); font-weight: 500; font-size: 14px;
}
.create-btn svg { width: 36px; height: 36px; }
.create-btn:hover { background: var(--bg-soft); }
.fab { display: none; }

/* ---------- mini calendar ---------- */
.mini-cal { padding: 0 8px; user-select: none; }
.mini-head { display: flex; align-items: center; justify-content: space-between; padding: 4px 0 4px 8px; font-weight: 500; }
.mini-grid { display: grid; grid-template-columns: repeat(7, 1fr); text-align: center; font-size: 11px; }
.mini-grid .dow { color: var(--muted); padding: 4px 0; }
.mini-grid button {
  width: 28px; height: 28px; margin: 1px auto; border-radius: 50%; border: 0; background: transparent;
  cursor: pointer; font-size: 11px;
}
.mini-grid button:hover { background: var(--surface-2); }
.mini-grid button.other { color: var(--muted); }
.mini-grid button.in-range { background: var(--primary-soft); }
.mini-grid button.today { background: var(--today); color: var(--bg); font-weight: 600; }
.mini-grid button.selected:not(.today) { background: var(--primary-soft); font-weight: 600; }

/* ---------- calendar list ---------- */
.cal-section { margin-top: 16px; }
.cal-section-head { display: flex; align-items: center; justify-content: space-between; padding: 4px 8px; font-weight: 500; }
.cal-list { list-style: none; margin: 0; padding: 0; }
.cal-list li { display: flex; align-items: center; gap: 4px; padding: 0 0 0 8px; border-radius: 4px; min-height: 32px; }
.cal-list li:hover { background: var(--surface-2); }
.cal-list label { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; cursor: pointer; padding: 6px 0; }
.cal-list .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cal-list .warn { color: var(--danger); font-size: 12px; }
.cal-list .more { opacity: 0; }
.cal-list li:hover .more, .cal-list li:focus-within .more { opacity: 1; }
.check {
  appearance: none; width: 18px; height: 18px; border-radius: 3px; border: 2px solid var(--c); margin: 0; flex: none;
  display: grid; place-items: center; cursor: pointer;
}
.check:checked { background: var(--c); }
.check:checked::after { content: ""; width: 5px; height: 10px; border: solid #fff; border-width: 0 2px 2px 0; transform: translateY(-1px) rotate(45deg); }

/* ---------- time grid (day / week) ---------- */
.grid-head { display: flex; border-bottom: 1px solid var(--line); flex: none; padding-right: var(--sbw, 0px); }
.gutter { width: 64px; flex: none; position: relative; }
.grid-head .gutter { display: flex; align-items: flex-end; justify-content: center; font-size: 10px; color: var(--muted); padding-bottom: 4px; }
.day-heads { flex: 1; display: grid; grid-template-columns: repeat(var(--cols), 1fr); }
.day-head { text-align: center; padding: 8px 0 4px; border-left: 1px solid var(--line-soft); cursor: pointer; }
.day-head .dow { font-size: 11px; font-weight: 500; color: var(--muted); text-transform: uppercase; }
.day-head .num {
  display: inline-grid; place-items: center; width: 46px; height: 46px; border-radius: 50%;
  font-size: 24px; margin-top: 2px;
}
.day-head:hover .num { background: var(--surface-2); }
.day-head.today .dow { color: var(--today); }
.day-head.today .num { background: var(--today); color: var(--bg); }
.allday-row { display: flex; border-bottom: 1px solid var(--line); flex: none; padding-right: var(--sbw, 0px); }
.allday-row .lanes { flex: 1; position: relative; display: grid; grid-template-columns: repeat(var(--cols), 1fr); min-height: 8px; }
.allday-row .lanes .cell { border-left: 1px solid var(--line-soft); }
.allday-row .gutter { font-size: 10px; color: var(--muted); text-align: right; padding: 4px 8px 0 0; }

.grid-scroll { flex: 1; overflow-y: auto; overflow-x: hidden; position: relative; }
.grid-inner { display: flex; position: relative; height: calc(var(--hour) * 24); }
.hours .hour-label { position: absolute; right: 8px; font-size: 10px; color: var(--muted); transform: translateY(-50%); }
.cols { flex: 1; display: grid; grid-template-columns: repeat(var(--cols), 1fr); position: relative;
  background-image: linear-gradient(var(--line-soft) 1px, transparent 1px);
  background-size: 100% var(--hour);
}
.col { position: relative; border-left: 1px solid var(--line-soft); touch-action: pan-y; }
.now-line { position: absolute; left: -1px; right: 0; height: 2px; background: var(--now); z-index: 4; pointer-events: none; }
.now-line::before { content: ""; position: absolute; left: -6px; top: -5px; width: 12px; height: 12px; border-radius: 50%; background: var(--now); }

.ev {
  position: absolute; border-radius: 4px; padding: 2px 6px; font-size: 12px; line-height: 1.25;
  background: var(--c); color: var(--fg, #fff); overflow: hidden; cursor: pointer; z-index: 2;
  border: 1px solid var(--bg); user-select: none; touch-action: pan-y;
}
.ev .t { font-weight: 500; overflow: hidden; text-overflow: ellipsis; }
.ev .s { opacity: .92; }
.ev.short { display: flex; gap: 4px; white-space: nowrap; padding-top: 0; padding-bottom: 0; }
.ev.short .t { flex: none; max-width: 100%; }
.ev.short .s { overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.ev.past { opacity: .62; }
.ev.dragging { opacity: .85; box-shadow: var(--shadow); z-index: 5; }
.ev .resize { position: absolute; left: 0; right: 0; bottom: 0; height: 6px; cursor: ns-resize; }
.ev.ghost { background: var(--primary-soft); color: var(--text); border: 1px solid var(--primary); z-index: 3; }

.bar {
  position: absolute; height: 20px; border-radius: 4px; padding: 0 6px; font-size: 12px; line-height: 20px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; cursor: pointer;
  background: var(--c); color: var(--fg, #fff); margin: 0 2px; user-select: none;
}
.bar.timed { background: transparent; color: var(--text); display: flex; align-items: center; gap: 4px; }
.bar.timed::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--c); flex: none; }
.bar.timed:hover { background: var(--surface-2); }
.bar.past { opacity: .62; }
.bar .tm { color: var(--muted); }
.more-link { position: absolute; height: 20px; font-size: 12px; font-weight: 500; padding: 0 8px; cursor: pointer; border-radius: 4px; line-height: 20px; color: var(--text-2); }
.more-link:hover { background: var(--surface-2); }

/* ---------- month ---------- */
.month { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.month-dows { display: grid; grid-template-columns: repeat(7, 1fr); flex: none; }
.month-dows div { text-align: center; font-size: 11px; font-weight: 500; color: var(--muted); padding-top: 8px; border-left: 1px solid var(--line-soft); }
.month-rows { flex: 1; display: grid; min-height: 0; }
.week-row { position: relative; display: grid; grid-template-columns: repeat(7, 1fr); border-bottom: 1px solid var(--line-soft); min-height: 0; }
.mcell { border-left: 1px solid var(--line-soft); text-align: center; padding-top: 4px; cursor: pointer; min-width: 0; }
.mcell.other .dnum { color: var(--muted); }
.mcell .dnum { display: inline-grid; place-items: center; min-width: 24px; height: 24px; border-radius: 12px; font-size: 12px; font-weight: 500; padding: 0 4px; }
.mcell .dnum:hover { background: var(--surface-2); }
.mcell.today .dnum { background: var(--today); color: var(--bg); }
.week-row .bars { position: absolute; left: 0; right: 0; top: 30px; bottom: 0; pointer-events: none; }
.week-row .bars > * { pointer-events: auto; }

/* ---------- schedule ---------- */
.schedule { flex: 1; overflow-y: auto; padding: 8px 16px 80px; }
.sched-day { display: flex; gap: 16px; padding: 10px 0; border-bottom: 1px solid var(--line-soft); }
.sched-date { width: 110px; flex: none; display: flex; align-items: flex-start; gap: 8px; cursor: pointer; }
.sched-date .num { display: inline-grid; place-items: center; width: 32px; height: 32px; border-radius: 50%; font-size: 20px; }
.sched-date .meta { font-size: 11px; color: var(--muted); text-transform: uppercase; padding-top: 8px; }
.sched-day.today .num { background: var(--today); color: var(--bg); }
.sched-day.today .meta { color: var(--today); }
.sched-events { flex: 1; min-width: 0; }
.sched-ev { display: flex; align-items: center; gap: 16px; padding: 8px; border-radius: 8px; cursor: pointer; }
.sched-ev:hover { background: var(--surface-2); }
.sched-ev .dot { width: 12px; height: 12px; border-radius: 50%; background: var(--c); flex: none; }
.sched-ev .time { width: 150px; flex: none; color: var(--text-2); font-size: 13px; }
.sched-ev .ttl { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sched-empty { padding: 48px; text-align: center; color: var(--muted); }
.load-more { display: block; margin: 16px auto; }
.search-head { padding: 12px 0 4px; font-weight: 500; }

/* ---------- popover ---------- */
.popover {
  position: fixed; z-index: 30; width: 420px; max-width: calc(100vw - 16px); max-height: calc(100vh - 16px); overflow-y: auto;
  background: var(--surface); border-radius: 12px; box-shadow: var(--shadow); padding: 8px 8px 20px;
}
.pop-actions { display: flex; justify-content: flex-end; }
.pop-row { display: flex; gap: 16px; padding: 6px 16px 6px 20px; align-items: flex-start; }
.pop-row svg { width: 20px; height: 20px; color: var(--muted); margin-top: 2px; }
.pop-row .sw { width: 14px; height: 14px; border-radius: 4px; background: var(--c); margin: 4px 3px; flex: none; }
.pop-title { font-size: 22px; line-height: 1.3; word-break: break-word; }
.pop-desc { white-space: pre-wrap; word-break: break-word; max-height: 240px; overflow-y: auto; }
.pop-desc a, .pop-row a { color: var(--primary); }

/* ---------- modal ---------- */
.modal-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.35); z-index: 40; display: grid; place-items: center; padding: 16px; }
.modal {
  background: var(--surface); border-radius: 16px; box-shadow: var(--shadow); width: 560px; max-width: 100%;
  max-height: calc(100dvh - 32px); display: flex; flex-direction: column;
}
.modal.wide { width: 720px; }
.modal-head { display: flex; align-items: center; gap: 8px; padding: 12px 12px 0 24px; }
.modal-head h2 { font-size: 20px; font-weight: 400; margin: 0; flex: 1; }
.modal-body { padding: 12px 24px; overflow-y: auto; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 24px 20px; flex-wrap: wrap; }
.modal-foot .left { margin-right: auto; }

.field { display: flex; flex-direction: column; gap: 4px; margin: 10px 0; }
.field > span { font-size: 12px; color: var(--muted); }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.row > .grow { flex: 1; min-width: 120px; }
input[type=text], input[type=password], input[type=url], input[type=date], input[type=time], input[type=number],
select, textarea {
  border: 1px solid var(--line); border-radius: 6px; padding: 8px 10px; background: var(--bg); outline: none; min-width: 0;
}
input:focus, select:focus, textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 1px var(--primary); }
textarea { resize: vertical; min-height: 80px; }
.title-input { font-size: 22px !important; border: 0 !important; border-bottom: 1px solid var(--line) !important; border-radius: 0 !important; padding: 8px 0 !important; width: 100%; box-shadow: none !important; background: transparent !important; }
.title-input:focus { border-bottom: 2px solid var(--primary) !important; }
.toggle { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; }
.modal-head .head-save { display: none; }
.when { display: flex; flex-direction: column; gap: 8px; margin: 8px 0; }
.when-row { display: grid; grid-template-columns: 56px 1fr 120px; gap: 8px; align-items: center; }
.when-row > span { font-size: 13px; color: var(--muted); }
.when.all-day .when-row { grid-template-columns: 56px 1fr; }
.when.all-day [data-timed] { display: none; }
.reminder-row { display: flex; gap: 8px; align-items: center; margin: 4px 0; }
.reminder-row input { width: 72px; }
.colors { display: flex; gap: 6px; flex-wrap: wrap; }
.colors button { width: 24px; height: 24px; border-radius: 50%; border: 2px solid transparent; background: var(--c); cursor: pointer; padding: 0; }
.colors button.on { outline: 2px solid var(--text); outline-offset: 2px; }
.colors button.none { background: conic-gradient(#d50000, #f6bf26, #33b679, #039be5, #8e24aa, #d50000); }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 8px; overflow-x: auto; }
.tabs button { border: 0; background: transparent; padding: 10px 14px; cursor: pointer; border-bottom: 3px solid transparent; font-weight: 500; color: var(--text-2); white-space: nowrap; }
.tabs button.on { color: var(--primary); border-bottom-color: var(--primary); }

.settings-section { padding: 8px 0 16px; border-bottom: 1px solid var(--line-soft); }
.settings-section:last-child { border-bottom: 0; }
.settings-section h3 { font-size: 15px; font-weight: 500; margin: 8px 0; }
.settings-section p { margin: 6px 0; }
.code { font-family: ui-monospace, Consolas, monospace; font-size: 12px; background: var(--surface-2); padding: 2px 6px; border-radius: 4px; word-break: break-all; }
.conn-row { display: flex; justify-content: space-between; gap: 12px; padding: 6px 0; border-bottom: 1px solid var(--line-soft); }
.conn-row span { color: var(--text-2); }
.conn-row b { font-weight: 500; text-align: right; word-break: break-all; }
.conn-row.bad b, .conn-list .bad { color: var(--danger); font-weight: 600; }
.conn-list { font-size: 12px; display: flex; flex-direction: column; gap: 4px; word-break: break-all; }
.acct { display: flex; align-items: center; gap: 8px; padding: 6px 0; }
.acct .grow { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.help { font-size: 13px; color: var(--text-2); background: var(--bg-soft); border: 1px solid var(--line-soft); border-radius: 8px; padding: 10px 12px; margin: 8px 0; }
.help ol { margin: 4px 0; padding-left: 20px; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; margin: 6px 0; }
.chip { border: 1px solid var(--line); border-radius: 16px; padding: 4px 12px; background: transparent; cursor: pointer; font-size: 13px; }
.chip.on { background: var(--primary-soft); border-color: var(--primary-soft); }

/* ---------- login ---------- */
.login { position: fixed; inset: 0; display: grid; place-items: center; background: var(--bg-soft); padding: 16px; }
.login-card { width: 360px; max-width: 100%; background: var(--surface); border-radius: 16px; box-shadow: var(--shadow); padding: 32px; display: flex; flex-direction: column; gap: 12px; align-items: stretch; text-align: center; }
.login-card img { margin: 0 auto; }
.login-card h2 { margin: 0; font-weight: 400; }
.login-card p { margin: 0; }

/* ---------- toast ---------- */
.toast {
  position: fixed; left: 24px; bottom: 24px; z-index: 50; background: #323232; color: #fff; padding: 12px 16px;
  border-radius: 6px; box-shadow: var(--shadow); max-width: calc(100vw - 48px); display: flex; gap: 16px; align-items: center;
}
.toast button { color: #8ab4f8; background: none; border: 0; cursor: pointer; font-weight: 500; }

/* ---------- phones & small tablets ---------- */
@media (max-width: 800px) {
  :root { --hour: 56px; --sidebar-w: 300px; }
  body { font-size: 15px; }
  /* 16px inputs stop iOS from zooming in when a field is focused */
  input, select, textarea { font-size: 16px !important; }
  button, .ev, .bar, .col, .mcell { touch-action: manipulation; }

  /* top bar: menu · month title (tap for mini month) · search · today */
  .topbar { gap: 0; padding: 4px 4px; padding-top: max(4px, env(safe-area-inset-top)); min-height: 56px; border-bottom: 0; }
  .brand, .nav-arrows, #todayBtn, .view-select, #settingsBtn { display: none; }
  .title-btn { cursor: pointer; padding: 6px 4px 6px 8px; border-radius: 8px; flex: 0 1 auto; }
  .title-btn:active { background: var(--surface-2); }
  .title { font-size: 20px; margin: 0; }
  .title-btn .caret { display: block; width: 22px; height: 22px; transition: transform .2s; color: var(--text-2); }
  .title-btn[aria-expanded="true"] .caret { transform: rotate(180deg); }
  .today-icon { display: inline-grid; position: relative; }
  .today-icon span { position: absolute; left: 0; right: 0; top: 17px; font-size: 9px; font-weight: 700; text-align: center; color: var(--text-2); }
  .icon-btn { width: 44px; height: 44px; }
  .search.open { position: absolute; left: 4px; right: 4px; top: max(8px, env(safe-area-inset-top)); z-index: 12; padding-right: 12px; }
  .search.open input { width: 100%; padding: 10px 0; }

  /* mini month that drops down under the title */
  .mini-drop:not([hidden]) {
    display: block; padding: 0 12px 8px; border-bottom: 1px solid var(--line-soft); background: var(--bg);
  }
  .mini-drop .mini-grid button { width: 36px; height: 36px; font-size: 13px; }
  .mini-drop .mini-grid .dow { font-size: 12px; }
  .mini-drop .mini-head { font-size: 15px; }

  /* side drawer */
  .sidebar {
    position: fixed; z-index: 30; top: 0; bottom: 0; left: 0; margin-left: 0 !important;
    width: min(var(--sidebar-w), 85vw); padding: 0 0 calc(16px + env(safe-area-inset-bottom));
    padding-top: env(safe-area-inset-top); border-radius: 0 16px 16px 0;
    box-shadow: var(--shadow); transform: translateX(-105%); transition: transform .22s ease;
    display: flex; flex-direction: column;
  }
  .app.sidebar-open .sidebar { transform: none; }
  .app.sidebar-open .scrim { display: block; position: fixed; inset: 0; z-index: 25; background: rgba(0,0,0,.4); }
  .drawer-head { display: flex; align-items: center; gap: 10px; padding: 18px 20px 10px; font-size: 20px; color: var(--text-2); }
  .view-list { display: flex; flex-direction: column; padding: 4px 8px 8px; border-bottom: 1px solid var(--line-soft); }
  .view-list button, .drawer-foot button {
    display: flex; align-items: center; gap: 20px; border: 0; background: none; text-align: left;
    padding: 0 16px; min-height: 48px; border-radius: 24px; font-size: 15px; font-weight: 500; cursor: pointer; color: var(--text);
  }
  .view-list button svg, .drawer-foot svg { color: var(--text-2); }
  .view-list button.on { background: var(--primary-soft); color: var(--text); }
  .view-list button.on svg { color: var(--text); }
  .drawer-foot { display: block; margin-top: auto; padding: 8px 8px 0; border-top: 1px solid var(--line-soft); }
  .drawer-foot button { width: 100%; }
  .sidebar #miniCal, .create-btn { display: none; }
  .cal-section { padding: 0 8px; margin-top: 12px; }
  .cal-list li { min-height: 44px; }
  .cal-list .more { opacity: 1; }
  .check { width: 20px; height: 20px; }

  /* time grid */
  .gutter { width: 44px; }
  .hours .hour-label { right: 6px; font-size: 11px; }
  .grid-head .gutter { font-size: 9px; }
  .day-head { padding: 6px 0 4px; }
  .day-head .dow { font-size: 11px; }
  .day-head .num { width: 34px; height: 34px; font-size: 19px; margin-top: 0; }
  .ev { font-size: 12.5px; padding: 3px 5px; border-radius: 6px; line-height: 1.2; }
  .ev .t { font-weight: 600; white-space: normal; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; }
  .ev.short .t { white-space: nowrap; display: block; }
  .ev .s { font-size: 11.5px; }
  .ev .resize { display: none; }
  .bar { height: 22px; line-height: 22px; font-size: 12.5px; font-weight: 500; border-radius: 6px; }
  .now-line { height: 2px; }

  /* month */
  .month-dows div { font-size: 10px; padding: 6px 0 2px; }
  .mcell { padding-top: 2px; }
  .mcell .dnum { font-size: 12px; height: 22px; min-width: 22px; }
  .week-row .bars { top: 26px; }
  .week-row .bar { height: 17px; line-height: 17px; font-size: 10.5px; padding: 0 3px; margin: 0 1px; border-radius: 3px; }
  .week-row .bar.timed { padding: 0 2px; gap: 2px; }
  .week-row .bar.timed::before { width: 5px; height: 5px; }
  .week-row .bar .tm { display: none; }
  .week-row .more-link { height: 17px; line-height: 17px; font-size: 10px; padding: 0 3px; }

  /* schedule */
  .schedule { padding: 0 8px 100px; }
  .sched-day { gap: 8px; padding: 6px 0; }
  .sched-date { width: 52px; flex-direction: column; align-items: center; gap: 0; padding-top: 6px; }
  .sched-date .meta { padding-top: 0; order: -1; font-size: 11px; }
  .sched-date .num { width: 36px; height: 36px; font-size: 20px; }
  .sched-events { display: flex; flex-direction: column; gap: 4px; padding-top: 6px; }
  .sched-ev {
    display: grid; grid-template-columns: 1fr; gap: 1px; padding: 8px 12px; border-radius: 8px;
    background: var(--c); color: var(--fg);
  }
  .sched-ev:hover { background: var(--c); }
  .sched-ev .dot { display: none; }
  .sched-ev .ttl { order: -1; font-weight: 600; white-space: normal; }
  .sched-ev .ttl .muted { color: inherit; opacity: .85; font-weight: 400; }
  .sched-ev .time { width: auto; font-size: 13px; color: inherit; opacity: .9; }

  /* create button */
  .fab {
    display: grid; place-items: center; position: fixed; right: 16px; bottom: calc(20px + env(safe-area-inset-bottom));
    width: 56px; height: 56px; border-radius: 16px; border: 0; background: var(--primary-soft); color: var(--text);
    box-shadow: var(--shadow); z-index: 10; cursor: pointer;
  }
  .fab svg { width: 28px; height: 28px; }

  /* event details: bottom sheet */
  .popover {
    left: 0 !important; right: 0; top: auto !important; bottom: 0; width: auto; max-width: none;
    max-height: 75dvh; border-radius: 20px 20px 0 0; padding: 4px 4px calc(20px + env(safe-area-inset-bottom));
    animation: sheet-up .2s ease;
  }
  .popover::before { content: ""; display: block; width: 36px; height: 4px; border-radius: 2px; background: var(--line); margin: 6px auto 0; }
  .pop-title { font-size: 22px; }

  /* dialogs: full screen */
  .modal-backdrop { padding: 0; place-items: stretch; }
  .modal, .modal.wide {
    width: 100%; max-width: none; height: 100dvh; max-height: none; border-radius: 0;
    padding-top: env(safe-area-inset-top); padding-bottom: env(safe-area-inset-bottom); animation: sheet-up .2s ease;
  }
  .modal-head { padding: 8px 8px 4px 16px; position: sticky; top: 0; background: var(--surface); z-index: 2; }
  .modal-body { padding: 8px 16px 16px; flex: 1; }
  .modal-foot { padding: 12px 16px; border-top: 1px solid var(--line-soft); }
  .modal-head .head-save { display: inline-flex; }
  .modal-foot .foot-save { display: none; }
  .when-row { grid-template-columns: 52px 1fr 1fr; }
  .tabs button { padding: 12px 14px; }
  .help { font-size: 14px; }

  .toast { left: 12px; right: 12px; bottom: calc(92px + env(safe-area-inset-bottom)); }
}
@keyframes sheet-up { from { transform: translateY(24px); opacity: 0; } to { transform: none; opacity: 1; } }
