/* Kalendar — macOS Calendar-inspired styles. Light + dark, desktop + phone. */
:root {
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro", "Helvetica Neue", "Inter", "Segoe UI", Roboto, system-ui, sans-serif;
  --font-display: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Helvetica Neue", "Inter", "Segoe UI", Roboto, system-ui, sans-serif;
  --bg: #ffffff;
  --bg-elev: #ffffff;
  --bg-toolbar: rgba(246, 245, 244, 0.86);
  --bg-sidebar: rgba(236, 235, 234, 0.78);
  --bg-alt: #f6f6f6;
  --bg-hover: rgba(0, 0, 0, 0.05);
  --bg-press: rgba(0, 0, 0, 0.09);
  --text: #1d1d1f;
  --text-2: #6e6e73;
  --text-3: #a1a1a6;
  --sep: rgba(0, 0, 0, 0.1);
  --sep-strong: rgba(0, 0, 0, 0.16);
  --grid: rgba(0, 0, 0, 0.075);
  --red: #ff3b30;
  --accent: #007aff;
  --accent-text: #fff;
  --offhours: rgba(0, 0, 0, 0.022);
  --weekend: rgba(0, 0, 0, 0.018);
  --shadow-pop: 0 0 0 0.5px rgba(0, 0, 0, 0.14), 0 10px 38px rgba(0, 0, 0, 0.17), 0 2px 8px rgba(0, 0, 0, 0.06);
  --shadow-win: 0 0 0 0.5px rgba(0, 0, 0, 0.2), 0 24px 70px rgba(0, 0, 0, 0.3);
  --control: #ffffff;
  --control-border: rgba(0, 0, 0, 0.13);
  --seg-bg: rgba(0, 0, 0, 0.06);
  --seg-on: #ffffff;
  --ev-mix: 18%;
  --ev-text-mix: 62%;
  --ev-text-base: #000;
  --sidebar-w: 236px;
  --toolbar-h: 52px;
  --radius: 6px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1e1e1e;
    --bg-elev: #2a2a2c;
    --bg-toolbar: rgba(42, 42, 42, 0.86);
    --bg-sidebar: rgba(36, 36, 38, 0.82);
    --bg-alt: #252526;
    --bg-hover: rgba(255, 255, 255, 0.07);
    --bg-press: rgba(255, 255, 255, 0.12);
    --text: #f5f5f7;
    --text-2: #98989d;
    --text-3: #636366;
    --sep: rgba(255, 255, 255, 0.1);
    --sep-strong: rgba(255, 255, 255, 0.16);
    --grid: rgba(255, 255, 255, 0.075);
    --red: #ff453a;
    --accent: #0a84ff;
    --offhours: rgba(0, 0, 0, 0.18);
    --weekend: rgba(255, 255, 255, 0.012);
    --shadow-pop: 0 0 0 0.5px rgba(255, 255, 255, 0.12), 0 12px 40px rgba(0, 0, 0, 0.55);
    --shadow-win: 0 0 0 0.5px rgba(255, 255, 255, 0.14), 0 24px 70px rgba(0, 0, 0, 0.6);
    --control: rgba(255, 255, 255, 0.08);
    --control-border: rgba(255, 255, 255, 0.12);
    --seg-bg: rgba(255, 255, 255, 0.08);
    --seg-on: rgba(255, 255, 255, 0.2);
    --ev-mix: 30%;
    --ev-text-mix: 55%;
    --ev-text-base: #fff;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font: 13px/1.35 var(--font); color: var(--text); background: var(--bg);
  -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale;
  overflow: hidden; overscroll-behavior: none; -webkit-tap-highlight-color: transparent;
  letter-spacing: -0.003em;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: default; background: none; border: 0; padding: 0; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
:focus-visible { outline: 3px solid color-mix(in srgb, var(--accent) 50%, transparent); outline-offset: 1px; border-radius: 5px; }
[hidden] { display: none !important; }
.boot { height: 100vh; display: grid; place-items: center; opacity: .5; }
.spacer { flex: 1; }
body.is-dragging, body.is-dragging * { cursor: grabbing !important; user-select: none; }

/* ---------- shell ---------- */
#app { height: 100%; }
.shell { display: grid; grid-template-columns: var(--sidebar-w) 1fr; height: 100dvh; transition: grid-template-columns .22s ease; }
.shell.no-sidebar { grid-template-columns: 0 1fr; }
.main { grid-column: 2; grid-row: 1; display: grid; grid-template-rows: var(--toolbar-h) 1fr; min-width: 0; min-height: 0; background: var(--bg); position: relative; }
.sidebar-scrim, .tabbar { display: none; }

/* ---------- sidebar ---------- */
.sidebar {
  background: var(--bg-sidebar); backdrop-filter: saturate(180%) blur(30px); -webkit-backdrop-filter: saturate(180%) blur(30px);
  border-right: 1px solid var(--sep); display: flex; flex-direction: column; min-height: 0; overflow: hidden;
  padding-top: calc(var(--toolbar-h) - 8px);
}
.no-sidebar .sidebar { border-right: 0; }
.sb-scroll { flex: 1; overflow-y: auto; padding: 0 10px 8px; min-width: calc(var(--sidebar-w) - 1px); }
.sb-section { margin-bottom: 14px; }
.sb-heading { display: flex; align-items: center; gap: 6px; font-size: 11px; font-weight: 600; color: var(--text-3); padding: 6px 8px 4px; }
.sb-heading .sb-add { margin-left: auto; width: 20px; height: 20px; border-radius: 5px; display: grid; place-items: center; color: var(--text-2); opacity: 0; transition: opacity .15s; }
.sb-section:hover .sb-add, .sb-add:focus-visible { opacity: 1; }
.sb-add:hover { background: var(--bg-hover); }
.sb-count { margin-left: auto; font-weight: 500; }
.sb-cal { display: flex; align-items: center; gap: 8px; padding: 3px 8px; border-radius: 6px; font-size: 13px; }
.sb-cal:hover { background: var(--bg-hover); }
.cal-check { appearance: none; -webkit-appearance: none; width: 14px; height: 14px; margin: 0; border-radius: 4px; border: 1.5px solid var(--c); display: grid; place-items: center; flex: none; }
.cal-check:checked { background: var(--c); }
.cal-check:checked::after { content: ""; width: 7px; height: 4px; border: solid #fff; border-width: 0 0 1.6px 1.6px; transform: translateY(-1px) rotate(-45deg); }
.sb-cal-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cal-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--c, #8e8e93); flex: none; display: inline-block; }

.rem { display: flex; align-items: flex-start; gap: 8px; padding: 3px 8px; border-radius: 6px; }
.rem:hover { background: var(--bg-hover); }
.rem-check { width: 15px; height: 15px; border-radius: 50%; border: 1.5px solid var(--text-3); flex: none; margin-top: 1px; display: grid; place-items: center; color: #fff; }
.rem-check:hover { border-color: var(--accent); }
.rem.done .rem-check { background: var(--accent); border-color: var(--accent); }
.rem.done .rem-title { color: var(--text-3); }
.rem-check.ghost { border-style: dashed; color: var(--text-3); }
.rem-body { flex: 1; min-width: 0; text-align: left; display: flex; flex-direction: column; }
.rem-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rem-due { font-size: 11px; color: var(--text-2); }
.rem-due.overdue { color: var(--red); }
.rem-new { display: flex; align-items: center; gap: 8px; padding: 3px 8px; }
.rem-input { flex: 1; min-width: 0; border: 0; background: transparent; outline: none; padding: 2px 0; font-size: 13px; }
.rem-input::placeholder { color: var(--text-3); }

.mini { padding: 10px 14px 8px; border-top: 1px solid var(--sep); min-width: calc(var(--sidebar-w) - 1px); }
.mini-head { display: flex; align-items: center; gap: 2px; margin-bottom: 6px; }
.mini-title { flex: 1; font-size: 12px; color: var(--text-2); }
.mini-title b { color: var(--text); font-weight: 600; }
.mini-nav { width: 20px; height: 20px; border-radius: 5px; display: grid; place-items: center; color: var(--text-2); }
.mini-nav:hover { background: var(--bg-hover); }
.mini-grid { display: grid; grid-template-columns: repeat(7, 1fr); row-gap: 1px; }
.mini-dow { font-size: 9.5px; font-weight: 600; color: var(--text-3); text-align: center; padding-bottom: 3px; }
.mini-day { font-size: 10.5px; height: 22px; text-align: center; border-radius: 50%; width: 22px; justify-self: center; font-variant-numeric: tabular-nums; }
.mini-day.other { color: var(--text-3); }
.mini-day:hover { background: var(--bg-hover); }
.mini-day.inrange { background: color-mix(in srgb, var(--text) 7%, transparent); border-radius: 4px; width: 100%; }
.mini-day.sel { background: color-mix(in srgb, var(--text) 16%, transparent); border-radius: 50%; width: 22px; font-weight: 600; }
.mini-day.today { background: var(--red); color: #fff; font-weight: 600; border-radius: 50%; width: 22px; }
.sb-footer { padding: 6px 10px 10px; border-top: 1px solid var(--sep); min-width: calc(var(--sidebar-w) - 1px); }
.sb-foot-btn { display: flex; align-items: center; gap: 7px; padding: 5px 8px; border-radius: 6px; color: var(--text-2); width: 100%; }
.sb-foot-btn:hover { background: var(--bg-hover); color: var(--text); }

/* ---------- toolbar ---------- */
.toolbar {
  display: flex; align-items: center; gap: 10px; padding: 0 12px 0 10px; height: var(--toolbar-h);
  background: var(--bg-toolbar); backdrop-filter: saturate(180%) blur(20px); -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 1px solid var(--sep); position: relative; z-index: 5;
}
.tb-left { display: flex; gap: 2px; }
.tb-btn { width: 32px; height: 28px; border-radius: 6px; display: grid; place-items: center; color: var(--text-2); }
.tb-btn:hover { background: var(--bg-hover); color: var(--text); }
.tb-btn:active { background: var(--bg-press); }
.tb-title { font: 600 20px/1 var(--font-display); letter-spacing: -0.02em; white-space: nowrap; margin-left: 6px; display: flex; align-items: baseline; gap: 0; min-width: 0; }
.tb-title b { font-weight: 700; }
.tb-title span { font-weight: 400; color: var(--text); margin-left: 5px; }
.tb-title small { font: 400 13px var(--font); color: var(--text-2); margin-left: 10px; letter-spacing: 0; }
.tb-loading { width: 12px; height: 12px; border-radius: 50%; border: 2px solid var(--sep-strong); border-top-color: var(--text-2); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.tb-center { position: absolute; left: 50%; transform: translateX(-50%); }
.seg { display: inline-flex; background: var(--seg-bg); border-radius: 7px; padding: 2px; gap: 0; }
.seg button { padding: 3px 14px; border-radius: 5px; font-size: 13px; color: var(--text); position: relative; min-width: 58px; }
.seg button + button::before { content: ""; position: absolute; left: 0; top: 5px; bottom: 5px; width: 1px; background: var(--sep-strong); }
.seg button.on { background: var(--seg-on); box-shadow: 0 0 0 0.5px rgba(0, 0, 0, .06), 0 1px 3px rgba(0, 0, 0, .14); font-weight: 500; }
.seg button.on::before, .seg button.on + button::before { display: none; }
.tb-right { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.tb-nav { display: inline-flex; align-items: center; background: var(--seg-bg); border-radius: 7px; padding: 2px; }
.tb-navbtn { width: 26px; height: 22px; border-radius: 5px; display: grid; place-items: center; color: var(--text); }
.tb-today { padding: 2px 10px; border-radius: 5px; font-size: 13px; height: 22px; }
.tb-navbtn:hover, .tb-today:hover { background: var(--seg-on); }
.tb-navbtn:active, .tb-today:active { background: var(--bg-press); }
.search-wrap { position: relative; display: flex; align-items: center; }
.search-ic { position: absolute; left: 8px; color: var(--text-3); pointer-events: none; }
.search { width: 180px; height: 26px; border-radius: 7px; border: 0; background: var(--seg-bg); padding: 0 8px 0 27px; outline: none; font-size: 13px; transition: width .2s, box-shadow .15s; }
.search:focus { box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 45%, transparent); background: var(--bg-elev); width: 230px; }
.search::placeholder { color: var(--text-3); }
.search-results {
  position: absolute; top: 34px; right: 0; width: 330px; max-height: 60vh; overflow-y: auto; background: var(--bg-elev);
  border-radius: 10px; box-shadow: var(--shadow-pop); padding: 5px; z-index: 50;
}
.sr-head { font-size: 11px; font-weight: 600; color: var(--text-3); padding: 6px 8px 3px; }
.sr-item { display: flex; align-items: center; gap: 8px; width: 100%; padding: 6px 8px; border-radius: 6px; text-align: left; }
.sr-item:hover, .sr-item:focus-visible { background: var(--accent); color: #fff; outline: none; }
.sr-item:hover .sr-when, .sr-item:focus-visible .sr-when { color: rgba(255, 255, 255, .85); }
.sr-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--c); flex: none; }
.sr-title { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sr-when { font-size: 11.5px; color: var(--text-2); white-space: nowrap; }
.sr-empty { padding: 14px; text-align: center; color: var(--text-3); }
.assistant-btn { color: var(--accent); }
.assistant-open .assistant-btn { background: var(--bg-press); }

.content { min-height: 0; overflow: hidden; position: relative; display: flex; flex-direction: column; }

/* ---------- time grid (day / week) ---------- */
.tg { --gutter: 56px; display: flex; flex-direction: column; height: 100%; min-height: 0; }
.tg-gutter { width: var(--gutter); flex: none; }
.tg-head { display: flex; border-bottom: 1px solid var(--sep); background: var(--bg); position: relative; z-index: 3; }
.tg-dayhead { flex: 1; display: flex; align-items: baseline; justify-content: flex-end; gap: 4px; padding: 8px 8px 6px; font-size: 12.5px; color: var(--text); min-width: 0; text-align: right; border-left: 1px solid transparent; }
.tg-week .tg-dayhead { justify-content: center; }
.tg-dayhead .dow { color: var(--text); }
.tg-dayhead .num { font: 400 20px/1 var(--font-display); letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.tg-week .tg-dayhead .dow { font-size: 12.5px; order: 0; }
.tg-week .tg-dayhead .num { order: 1; margin-left: 4px; }
.tg-day .tg-dayhead { justify-content: flex-start; padding-left: 10px; }
.tg-day .tg-dayhead .num { font-size: 22px; font-weight: 600; }
.tg-day .tg-dayhead .dow { font-size: 15px; color: var(--text-2); }
.tg-dayhead.weekend .dow, .tg-dayhead.weekend .num { color: var(--text-2); }
.tg-dayhead.today .num { background: var(--red); color: #fff; border-radius: 13px; padding: 3px 6px; min-width: 26px; text-align: center; font-weight: 600; font-size: 17px; }
.tg-dayhead.today .dow { color: var(--red); font-weight: 600; }
.tg-dayhead:hover .num:not(.today .num) { text-decoration: underline; text-underline-offset: 3px; }

.tg-allday { display: flex; border-bottom: 1px solid var(--sep-strong); min-height: 26px; position: relative; z-index: 2; background: var(--bg); }
.tg-allday-label { font-size: 10.5px; color: var(--text-2); text-align: right; padding: 6px 8px 0 0; }
.tg-allday-grid { flex: 1; display: grid; grid-template-columns: repeat(var(--ndays), minmax(0, 1fr)); grid-auto-rows: 22px; padding: 2px 0 3px; row-gap: 2px; max-height: 98px; overflow-y: auto; }
.tg-allday.expanded .tg-allday-grid { max-height: 40vh; }
.tg-allday-more { display: block; margin: 4px 0 0 auto; font: inherit; font-size: 10px; font-weight: 600; color: var(--accent, #007aff); background: none; border: 0; padding: 1px 0; cursor: pointer; }
.tg-allday-more:hover { text-decoration: underline; }
.tg-allday-cell { border-left: 1px solid var(--grid); margin: -2px 0 -3px; }
.tg-allday-grid .ev-allday { position: relative; margin: 0 3px; z-index: 1; }

.tg-scroll { flex: 1; overflow-y: auto; overflow-x: hidden; position: relative; overscroll-behavior: contain; }
.tg-body { display: flex; position: relative; }
.tg-hours { position: relative; }
.tg-hour { position: absolute; right: 8px; transform: translateY(-50%); font-size: 10.5px; color: var(--text-2); white-space: nowrap; font-variant-numeric: tabular-nums; }
.tg-hour.hide { visibility: hidden; }
.tg-cols { flex: 1; display: flex; position: relative; min-width: 0;
  background-image: linear-gradient(to bottom, var(--grid) 1px, transparent 1px); background-size: 100% var(--hour); }
.tg-col { flex: 1; position: relative; border-left: 1px solid var(--grid); min-width: 0; }
.tg-week .tg-col:nth-child(1), .tg-week .tg-col:nth-child(7) { }
.tg-offhours { position: absolute; left: 0; right: 0; background: var(--offhours); pointer-events: none; }

/* events */
.ev {
  --tint: color-mix(in srgb, var(--c) var(--ev-mix), var(--bg));
  --ink: color-mix(in srgb, var(--c) var(--ev-text-mix), var(--ev-text-base));
  display: block; text-align: left; overflow: hidden; color: var(--ink); background: var(--tint);
  border-radius: 4px; font-size: 11.5px; line-height: 1.25; cursor: default;
}
.ev-timed { position: absolute; padding: 2px 5px 2px 7px; box-shadow: inset 3px 0 0 var(--c); z-index: 1; transition: box-shadow .12s, opacity .12s; touch-action: auto; }
.ev-timed:hover { z-index: 4; }
.ev-timed:focus-visible { z-index: 5; }
.ev-title { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ev-timed:not(.short) .ev-title { white-space: normal; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; }
.ev-time-inline { font-weight: 400; opacity: .9; }
.ev-time, .ev-loc { font-size: 11px; opacity: .92; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ev-timed.short { padding-top: 1px; }
.ev.past { opacity: .62; }
.ev.tentative { background-image: repeating-linear-gradient(135deg, transparent 0 5px, color-mix(in srgb, var(--c) 14%, transparent) 5px 10px); }
.ev.cancelled .ev-title { text-decoration: line-through; }
.ev-handle { position: absolute; left: 0; right: 0; bottom: 0; height: 6px; cursor: ns-resize; }
.ev.selected, .ev:active { background: var(--c); color: #fff; }
.ev.dragging { opacity: .9; box-shadow: inset 3px 0 0 var(--c), 0 6px 18px rgba(0, 0, 0, .22); z-index: 10; background: var(--c); color: #fff; }
.ev.ghost { background: color-mix(in srgb, var(--c) 35%, var(--bg)); box-shadow: inset 3px 0 0 var(--c), 0 4px 14px rgba(0, 0, 0, .15); z-index: 6; pointer-events: none; }
.ev-allday { padding: 2px 7px; height: 21px; white-space: nowrap; font-weight: 600; font-size: 11.5px; background: var(--tint); }
.ev-allday.clip-l { border-top-left-radius: 0; border-bottom-left-radius: 0; margin-left: 0 !important; }
.ev-allday.clip-r { border-top-right-radius: 0; border-bottom-right-radius: 0; margin-right: 0 !important; }

/* now line */
.now-line { position: absolute; left: 0; right: 0; height: 0; z-index: 7; pointer-events: none; }
.now-line::before { content: ""; position: absolute; left: 0; right: 0; border-top: 1px solid color-mix(in srgb, var(--red) 40%, transparent); }
.now-label { position: absolute; right: calc(100% + 6px); top: -7px; font-size: 10.5px; font-weight: 600; color: var(--red); white-space: nowrap; font-variant-numeric: tabular-nums; }
.now-track { position: absolute; top: -1px; height: 2px; background: var(--red); }
.now-dot { position: absolute; left: -4px; top: -3.5px; width: 9px; height: 9px; border-radius: 50%; background: var(--red); }

/* ---------- month ---------- */
.mv { display: flex; flex-direction: column; height: 100%; min-height: 0; }
.mv-head { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); border-bottom: 1px solid var(--sep); }
.mv-dow { text-align: right; padding: 7px 10px 5px; font-size: 12.5px; color: var(--text); }
.mv-weeks { flex: 1; display: grid; grid-template-rows: repeat(var(--weeks), minmax(0, 1fr)); min-height: 0; }
.mv-week { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); position: relative; border-bottom: 1px solid var(--grid); min-height: 0; }
.mv-week:last-child { border-bottom: 0; }
.mv-cell { grid-row: 1; border-left: 1px solid var(--grid); padding: 4px 6px; display: flex; justify-content: flex-end; align-items: flex-start; min-width: 0; }
.mv-cell:first-child { border-left: 0; }
.mv-cell.weekend { background: var(--weekend); }
.mv-cell.other .mv-num { color: var(--text-3); }
.mv-cell.selected { background: color-mix(in srgb, var(--accent) 7%, transparent); }
.mv-num { font-size: 13px; font-variant-numeric: tabular-nums; padding: 1px 6px; border-radius: 11px; min-width: 22px; height: 22px; line-height: 20px; text-align: center; white-space: nowrap; }
.mv-num:hover { background: var(--bg-hover); }
.mv-cell.today .mv-num { background: var(--red); color: #fff; font-weight: 600; }
.mv-items { position: absolute; left: 0; right: 0; top: 28px; bottom: 2px; display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); row-gap: 1px; pointer-events: none; overflow: hidden; }
.mv-item { pointer-events: auto; margin: 0 4px; display: flex; align-items: center; gap: 5px; min-width: 0; height: 19px; padding: 0 6px; border-radius: 4px; font-size: 11.5px; text-align: left; }
.mv-title { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mv-time { color: var(--text-2); font-size: 11px; flex: none; font-variant-numeric: tabular-nums; }
.mv-bar { --tint: color-mix(in srgb, var(--c) var(--ev-mix), var(--bg)); background: var(--tint); color: color-mix(in srgb, var(--c) var(--ev-text-mix), var(--ev-text-base)); font-weight: 600; }
.mv-bar .mv-time { color: inherit; opacity: .8; font-weight: 400; }
.mv-bar.clip-l { margin-left: 0; border-top-left-radius: 0; border-bottom-left-radius: 0; }
.mv-bar.clip-r { margin-right: 0; border-top-right-radius: 0; border-bottom-right-radius: 0; }
.mv-timed { padding-left: 4px; }
.mv-timed .mv-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--c); flex: none; }
.mv-timed:hover, .mv-bar:hover { filter: brightness(.97); background: var(--bg-hover); }
.mv-bar:hover { background: color-mix(in srgb, var(--c) calc(var(--ev-mix) + 8%), var(--bg)); }
.mv-timed.past { opacity: .6; }
.mv-more { color: var(--text-2); font-size: 11px; font-weight: 500; }
.mv-more:hover { color: var(--text); }
/* compact (phone) month */
.mv.compact { height: auto; flex: none; }
.mv.compact .mv-weeks { grid-template-rows: repeat(var(--weeks), 52px); }
.mv.compact .mv-cell { flex-direction: column; align-items: center; justify-content: flex-start; padding: 4px 0; border-left: 0; }
.mv.compact .mv-dow { text-align: center; font-size: 11px; color: var(--text-2); }
.mv.compact .mv-num { font-size: 16px; height: 30px; width: 30px; line-height: 28px; border-radius: 50%; padding: 0; }
.mv.compact .mv-cell.selected { background: none; }
.mv.compact .mv-cell.selected .mv-num { background: var(--text); color: var(--bg); font-weight: 600; }
.mv.compact .mv-cell.today.selected .mv-num, .mv.compact .mv-cell.today .mv-num { background: var(--red); color: #fff; }
.mv.compact .mv-cell.weekend { background: none; }
.mv-dots { display: flex; gap: 3px; margin-top: 3px; }
.mv-dots .mv-dot { width: 5px; height: 5px; border-radius: 50%; background: var(--c); }
.mv-agenda { flex: 1; overflow-y: auto; border-top: 1px solid var(--sep); padding: 6px 0 80px; }
.mv-agenda-head { font-weight: 600; padding: 8px 16px; font-size: 14px; }
.agenda-row { display: flex; align-items: center; gap: 10px; width: 100%; padding: 10px 16px; text-align: left; border-bottom: 1px solid var(--sep); }
.agenda-row .bar { width: 4px; align-self: stretch; border-radius: 2px; background: var(--c); }
.agenda-title { flex: 1; font-size: 15px; min-width: 0; display: flex; flex-direction: column; }
.agenda-title small { color: var(--text-2); font-size: 12.5px; }
.agenda-time { font-size: 12.5px; color: var(--text-2); text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.agenda-empty { color: var(--text-3); text-align: center; padding: 30px 0; font-size: 15px; }

/* ---------- year ---------- */
.yv { flex: 1; overflow-y: auto; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 26px 34px; padding: 22px 34px 40px; align-content: start; }
.ym-name { font: 600 17px var(--font-display); color: var(--red); padding: 0 0 6px 4px; letter-spacing: -0.01em; }
.ym-name:not(.current) { color: var(--red); }
.ym-name:hover { opacity: .75; }
.ym-grid { display: grid; grid-template-columns: repeat(7, 1fr); row-gap: 2px; }
.ym-dow { font-size: 10px; color: var(--text-3); text-align: center; font-weight: 600; padding-bottom: 3px; }
.ym-day { font-size: 11px; height: 22px; width: 22px; justify-self: center; border-radius: 50%; font-variant-numeric: tabular-nums; position: relative; }
.ym-day.weekend { color: var(--text-2); }
.ym-day:hover { background: var(--bg-hover); }
.ym-day.busy::after { content: ""; position: absolute; bottom: 1px; left: 50%; width: 3px; height: 3px; margin-left: -1.5px; border-radius: 50%; background: var(--text-3); }
.ym-day.today { background: var(--red); color: #fff; font-weight: 600; }
.ym-day.today::after { background: #fff; }

/* ---------- popovers ---------- */
.popover {
  position: fixed; z-index: 100; background: var(--bg-elev); border-radius: 12px; box-shadow: var(--shadow-pop);
  animation: pop-in .14s ease-out; max-height: calc(100vh - 20px); display: flex; flex-direction: column;
}
@media (prefers-color-scheme: light) { .popover:not(.sheet) { background: rgba(255, 255, 255, .96); backdrop-filter: blur(30px); -webkit-backdrop-filter: blur(30px); } }
.popover.closing { animation: pop-out .14s ease-in forwards; }
@keyframes pop-in { from { opacity: 0; transform: scale(.97); } }
@keyframes pop-out { to { opacity: 0; transform: scale(.98); } }
.pop-body { overflow-y: auto; padding: 14px 16px 12px; }
.pop-arrow { position: absolute; width: 14px; height: 14px; background: inherit; transform: rotate(45deg); box-shadow: -1px 1px 0 -0.5px rgba(0, 0, 0, .1); z-index: -1; }
.pop-arrow.right { left: -6px; }
.pop-arrow.left { right: -6px; box-shadow: 1px -1px 0 -0.5px rgba(0, 0, 0, .1); }
.pop-arrow.bottom { top: -6px; }
.pop-arrow.top { bottom: -6px; }
.pop-actions { display: flex; align-items: center; gap: 8px; margin-top: 12px; }
.sheet { left: 0 !important; right: 0; bottom: 0; top: auto !important; width: 100% !important; border-radius: 14px 14px 0 0; max-height: 92dvh; padding-bottom: env(safe-area-inset-bottom); animation: sheet-in .22s cubic-bezier(.2, .8, .2, 1); }
.sheet.closing { animation: sheet-out .16s ease-in forwards; }
@keyframes sheet-in { from { transform: translateY(100%); } }
@keyframes sheet-out { to { transform: translateY(100%); } }
.sheet-grabber { width: 36px; height: 5px; border-radius: 3px; background: var(--sep-strong); margin: 7px auto 0; flex: none; }
.sheet-backdrop { position: fixed; inset: 0; background: rgba(0, 0, 0, .28); z-index: 99; animation: fade .2s; }
.sheet-backdrop.closing { opacity: 0; transition: opacity .15s; }
@keyframes fade { from { opacity: 0; } }

/* detail */
.detail { min-width: 0; }
.d-title { display: block; width: 100%; text-align: left; color: var(--text); cursor: text; font: 600 17px/1.25 var(--font-display); letter-spacing: -0.01em; word-break: break-word; padding-left: 12px; position: relative; }
.d-title::before { content: ""; position: absolute; left: 0; top: 2px; bottom: 2px; width: 4px; border-radius: 2px; background: var(--c); }
.d-loc { color: var(--text-2); margin: 3px 0 0 12px; }
.d-when { margin: 10px 0 4px 12px; color: var(--text); font-size: 12.5px; }
.d-row { display: flex; gap: 8px; margin: 8px 0 0 10px; font-size: 12.5px; color: var(--text-2); align-items: flex-start; }
.d-ic { flex: none; margin-top: 1px; }
.d-val { min-width: 0; word-break: break-word; }
.d-notes { white-space: pre-wrap; max-height: 160px; overflow-y: auto; color: var(--text); }
.d-cal { display: flex; align-items: center; gap: 7px; margin: 12px 0 0 12px; font-size: 12.5px; color: var(--text-2); }

/* buttons / controls */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 4px; padding: 3px 12px; min-height: 24px; border-radius: 6px; background: var(--control); box-shadow: 0 0 0 0.5px var(--control-border), 0 1px 1px rgba(0, 0, 0, .05); font-size: 13px; white-space: nowrap; color: var(--text); text-decoration: none !important; }
.btn:hover { filter: brightness(.98); }
.btn:active { filter: brightness(.93); }
.btn:disabled { opacity: .5; }
.btn.primary { background: linear-gradient(to bottom, color-mix(in srgb, var(--accent) 88%, #fff), var(--accent)); color: #fff; box-shadow: 0 0 0 0.5px color-mix(in srgb, var(--accent) 70%, #000), 0 1px 1px rgba(0, 0, 0, .1); }
.btn.destructive { background: var(--red); color: #fff; box-shadow: none; }
.btn.icon-btn { padding: 0; width: 28px; color: var(--text-2); }
.btn.icon-btn:hover { color: var(--red); }
.link-btn { color: var(--accent); font-size: 12.5px; padding: 2px 0; }
.link-btn:hover { text-decoration: underline; }
.link-btn.danger { color: var(--red); }
.icon-plain { width: 26px; height: 26px; border-radius: 6px; display: grid; place-items: center; color: var(--text-2); }
.icon-plain:hover { background: var(--bg-hover); color: var(--text); }
input:not([type]), input[type=text], input[type=password], input[type=url], input[type=search]:not(.search), input[type=date], input[type=time], input[type=number], select, textarea {
  border: 0; border-radius: 6px; background: var(--control); box-shadow: 0 0 0 0.5px var(--control-border), 0 0.5px 1px rgba(0, 0, 0, .05); padding: 4px 8px; font-size: 13px; outline: none; min-height: 24px; max-width: 100%;
}
select { padding-right: 22px; appearance: none; -webkit-appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='8' height='12' viewBox='0 0 8 12'%3E%3Cpath d='M1 4.5 4 1.5l3 3M1 7.5l3 3 3-3' fill='none' stroke='%23888' stroke-width='1.3' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 7px center; }
input:focus, select:focus, textarea:focus { box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 45%, transparent); }
input[type=color] { width: 28px; height: 22px; padding: 0; border: 0; background: none; border-radius: 5px; }
.switch { appearance: none; -webkit-appearance: none; width: 32px; height: 18px; border-radius: 9px; background: var(--seg-bg); box-shadow: inset 0 0 0 0.5px var(--control-border); position: relative; margin: 0; transition: background .18s; flex: none; }
.switch::after { content: ""; position: absolute; top: 1px; left: 1px; width: 16px; height: 16px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(0, 0, 0, .3); transition: transform .18s; }
.switch:checked { background: #34c759; }
.switch:checked::after { transform: translateX(14px); }

/* editor */
.editor { display: flex; flex-direction: column; gap: 6px; }
.f-head { display: flex; align-items: center; gap: 8px; }
.f-title { flex: 1; font: 600 17px var(--font-display) !important; border: 0 !important; box-shadow: none !important; background: transparent !important; padding: 2px 0 !important; letter-spacing: -0.01em; }
.f-plain { border: 0 !important; box-shadow: none !important; background: transparent !important; padding: 2px 0 !important; width: 100%; resize: vertical; }
.f-plain::placeholder, .f-title::placeholder { color: var(--text-3); }
.f-sep { height: 1px; background: var(--sep); margin: 4px 0; }
.f-line { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.f-line.top { align-items: flex-start; }
.f-line > label, .f-grid > label { width: 66px; text-align: right; color: var(--text-2); font-size: 12.5px; flex: none; }
.f-line.top > label { padding-top: 4px; }
.f-grid { display: grid; grid-template-columns: 66px 1fr; gap: 6px 8px; align-items: center; }
.f-dt { display: flex; gap: 6px; min-width: 0; }
.f-dt input[type=date] { flex: 1.4; min-width: 0; }
.f-dt input[type=time] { flex: 1; min-width: 0; }
.f-line select { flex: 1; min-width: 0; }
.f-alerts { display: flex; flex-direction: column; gap: 5px; flex: 1; min-width: 0; align-items: flex-start; }
.f-alert { display: flex; gap: 6px; align-items: center; width: 100%; }
.f-alert select { flex: 1; }
.btn-x { width: 18px; height: 18px; border-radius: 50%; display: grid; place-items: center; color: var(--text-2); background: var(--seg-bg); flex: none; }
.btn-x:hover { background: var(--red); color: #fff; }
.f-custom { display: flex; flex-direction: column; gap: 6px; padding-left: 74px; }
.f-custom:empty { display: none; }
.f-custom .f-line > label { width: auto; text-align: left; min-width: 76px; }
.f-num { width: 64px; }
.f-unit { color: var(--text-2); font-size: 12.5px; }
.f-weekdays { display: flex; gap: 4px; }
.wd { width: 26px; height: 26px; border-radius: 50%; background: var(--seg-bg); font-size: 11.5px; font-weight: 600; }
.wd.on { background: var(--accent); color: #fff; }
.f-error { color: var(--red); font-size: 12.5px; min-height: 0; }
.f-error:empty { display: none; }
.mini-form { display: flex; flex-direction: column; gap: 8px; }
.mini-form-title { font-weight: 600; font-size: 14px; }
.mini-form .f-line > label { width: 60px; }
.swatches { display: flex; gap: 6px; flex-wrap: wrap; }
.swatch { width: 20px; height: 20px; border-radius: 50%; background: var(--c); }
.swatch.on { box-shadow: 0 0 0 2px var(--bg-elev), 0 0 0 4px var(--c); }

/* ---------- dialogs ---------- */
.modal-backdrop { position: fixed; inset: 0; z-index: 200; background: rgba(0, 0, 0, .22); display: grid; place-items: center; animation: fade .15s; padding: 16px; }
.modal-backdrop.closing { opacity: 0; transition: opacity .12s; }
.alert { width: 260px; background: var(--bg-elev); border-radius: 12px; box-shadow: var(--shadow-win); padding: 18px 16px 16px; text-align: center; animation: pop-in .16s ease-out; }
@media (prefers-color-scheme: light) { .alert { background: rgba(242, 242, 242, .97); backdrop-filter: blur(30px); } }
.alert-icon img { width: 56px; height: 56px; }
.alert-title { font-weight: 700; font-size: 13px; margin: 8px 0 6px; }
.alert-msg { font-size: 11.5px; color: var(--text); margin-bottom: 14px; }
.alert-buttons { display: flex; gap: 8px; }
.alert-buttons .btn { flex: 1; min-height: 28px; }
.alert-buttons.vertical { flex-direction: column; }
.window { background: var(--bg); border-radius: 12px; box-shadow: var(--shadow-win); overflow: hidden; display: flex; flex-direction: column; max-height: min(720px, calc(100dvh - 32px)); animation: pop-in .18s ease-out; }
.window-titlebar { height: 38px; display: flex; align-items: center; padding: 0 12px; border-bottom: 1px solid var(--sep); background: var(--bg-toolbar); position: relative; flex: none; }
.window-title { position: absolute; left: 50%; transform: translateX(-50%); font-weight: 600; font-size: 13px; }
.traffic { display: flex; gap: 8px; }
.tl { width: 12px; height: 12px; border-radius: 50%; display: grid; place-items: center; box-shadow: inset 0 0 0 0.5px rgba(0, 0, 0, .15); }
.tl.close { background: #ff5f57; color: transparent; }
.tl.close:hover { color: rgba(0, 0, 0, .55); }
.tl.min { background: #febc2e; } .tl.max { background: #28c840; }
.window-done { margin-left: auto; color: var(--accent); font-weight: 500; display: none; }
.window-body { overflow-y: auto; }

/* settings */
.set-tabs { display: flex; justify-content: center; gap: 4px; padding: 8px; border-bottom: 1px solid var(--sep); background: var(--bg-toolbar); }
.set-tabs button { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 5px 10px; border-radius: 7px; font-size: 11px; color: var(--text-2); min-width: 78px; }
.set-tabs button:hover { background: var(--bg-hover); }
.set-tabs button.on { background: var(--bg-press); color: var(--accent); }
.set-pane { padding: 18px 26px 24px; }
.set-pane h3 { font-size: 13px; margin: 18px 0 8px; }
.set-row { display: grid; grid-template-columns: 190px 1fr; gap: 10px; align-items: center; margin-bottom: 9px; }
.set-row > label { text-align: right; color: var(--text); }
.set-ctl { display: flex; flex-direction: column; align-items: flex-start; gap: 4px; min-width: 0; }
.set-ctl select { min-width: 220px; }
.set-hint { font-size: 11.5px; color: var(--text-2); }
.set-form { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 8px; }
.set-form input { flex: 1; min-width: 160px; }
.set-user { display: flex; align-items: center; gap: 12px; }
.set-cals { display: flex; flex-direction: column; gap: 6px; margin-top: 10px; }
.set-cal { display: flex; align-items: center; gap: 8px; }
.set-cal input:not([type=color]) { flex: 1; }
.tag { font-size: 11px; color: var(--text-2); background: var(--seg-bg); padding: 2px 8px; border-radius: 10px; }
.set-tokens { display: flex; flex-direction: column; gap: 4px; margin-bottom: 8px; }
.set-token { display: flex; gap: 10px; align-items: center; padding: 6px 10px; background: var(--bg-alt); border-radius: 6px; }
.set-token span:first-child { flex: 1; }
.token-out { display: block; padding: 8px; background: var(--bg-alt); border-radius: 6px; word-break: break-all; margin: 6px 0; font-size: 12px; user-select: all; }

/* toast + notifications */
.toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); background: rgba(40, 40, 40, .92); color: #fff; padding: 9px 16px; border-radius: 10px; z-index: 300; display: flex; gap: 14px; align-items: center; font-size: 13px; box-shadow: 0 8px 30px rgba(0, 0, 0, .25); animation: toast-in .2s ease-out; backdrop-filter: blur(20px); max-width: calc(100vw - 32px); }
.toast.error { background: rgba(200, 40, 30, .95); }
.toast.closing { opacity: 0; transition: opacity .2s; }
.toast-action { color: #64d2ff; font-weight: 600; }
@keyframes toast-in { from { opacity: 0; transform: translate(-50%, 10px); } }
.notif-stack { position: fixed; top: 12px; right: 12px; z-index: 400; display: flex; flex-direction: column; gap: 8px; width: 340px; max-width: calc(100vw - 24px); }
.notif { position: relative; background: rgba(246, 246, 246, .9); backdrop-filter: blur(30px) saturate(180%); -webkit-backdrop-filter: blur(30px) saturate(180%); border-radius: 14px; padding: 10px 14px 11px; box-shadow: 0 0 0 0.5px rgba(0, 0, 0, .1), 0 10px 30px rgba(0, 0, 0, .18); animation: notif-in .35s cubic-bezier(.2, .9, .3, 1.1); }
@media (prefers-color-scheme: dark) { .notif { background: rgba(50, 50, 52, .9); } }
.notif.closing { transform: translateX(120%); opacity: 0; transition: all .3s ease-in; }
@keyframes notif-in { from { transform: translateX(110%); } }
.notif-app { display: flex; align-items: center; gap: 6px; font-size: 10.5px; color: var(--text-2); letter-spacing: .03em; margin-bottom: 3px; }
.notif-app img { width: 16px; height: 16px; }
.notif-now { margin-left: auto; text-transform: none; letter-spacing: 0; }
.notif-title { font-weight: 600; }
.notif-body { color: var(--text); font-size: 12.5px; }
.notif-close { position: absolute; left: -6px; top: -6px; width: 18px; height: 18px; border-radius: 50%; background: var(--bg-elev); box-shadow: 0 0 0 0.5px var(--sep-strong), 0 1px 3px rgba(0, 0, 0, .2); display: none; place-items: center; color: var(--text-2); }
.notif:hover .notif-close { display: grid; }

/* ---------- assistant ---------- */
.assistant {
  position: fixed; right: 14px; bottom: 14px; top: calc(var(--toolbar-h) + 10px); width: 380px; z-index: 60; display: flex; flex-direction: column;
  background: var(--bg-elev); border-radius: 14px; box-shadow: var(--shadow-pop); transform: translateX(calc(100% + 30px)); transition: transform .28s cubic-bezier(.2, .85, .25, 1); overflow: hidden;
}
@media (prefers-color-scheme: light) { .assistant { background: rgba(252, 252, 252, .94); backdrop-filter: blur(30px) saturate(180%); -webkit-backdrop-filter: blur(30px) saturate(180%); } }
.assistant.open { transform: none; }
.as-head { display: flex; align-items: center; gap: 10px; padding: 12px 10px 10px 14px; border-bottom: 1px solid var(--sep); }
.as-badge { width: 28px; height: 28px; border-radius: 8px; display: grid; place-items: center; color: #fff; background: linear-gradient(135deg, #5e5ce6, #bf5af2 55%, #ff375f); flex: none; }
.as-titles { flex: 1; min-width: 0; }
.as-title { font-weight: 600; }
.as-sub { font-size: 11px; color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.as-log { flex: 1; overflow-y: auto; padding: 14px 12px; display: flex; flex-direction: column; gap: 8px; }
.as-msg { max-width: 86%; padding: 7px 12px; border-radius: 17px; font-size: 13px; line-height: 1.4; word-wrap: break-word; animation: pop-in .15s ease-out; }
.as-msg.me { align-self: flex-end; background: var(--accent); color: #fff; border-bottom-right-radius: 5px; }
.as-msg.bot { align-self: flex-start; background: var(--seg-bg); border-bottom-left-radius: 5px; }
.as-msg.error { color: var(--red); }
.as-msg.typing { display: flex; gap: 4px; padding: 11px 14px; }
.as-msg.typing span { width: 7px; height: 7px; border-radius: 50%; background: var(--text-3); animation: blink 1.2s infinite; }
.as-msg.typing span:nth-child(2) { animation-delay: .2s; } .as-msg.typing span:nth-child(3) { animation-delay: .4s; }
@keyframes blink { 0%, 60%, 100% { opacity: .3; } 30% { opacity: 1; } }
.as-changes { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; }
.as-change { font-size: 11px; padding: 2px 8px; border-radius: 10px; background: color-mix(in srgb, #34c759 18%, transparent); color: color-mix(in srgb, #34c759 70%, var(--ev-text-base)); }
.as-change.deleted { background: color-mix(in srgb, var(--red) 15%, transparent); color: var(--red); }
.as-change.updated { background: color-mix(in srgb, var(--accent) 15%, transparent); color: var(--accent); }
.as-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 2px; }
.chip { padding: 5px 11px; border-radius: 14px; font-size: 12px; box-shadow: inset 0 0 0 1px var(--sep-strong); color: var(--accent); }
.chip:hover { background: var(--bg-hover); }
.as-form { display: flex; align-items: flex-end; gap: 6px; padding: 10px; border-top: 1px solid var(--sep); }
.as-input { flex: 1; resize: none; border-radius: 17px !important; padding: 7px 14px !important; max-height: 140px; line-height: 1.35; }
.as-send { width: 30px; height: 30px; border-radius: 50%; background: var(--accent); color: #fff; display: grid; place-items: center; flex: none; }
.as-send:active { filter: brightness(.9); }

/* ---------- auth ---------- */
.auth { min-height: 100dvh; display: grid; place-items: center; padding: 24px; background: radial-gradient(1200px 600px at 50% -10%, color-mix(in srgb, var(--red) 10%, var(--bg)), var(--bg)); overflow-y: auto; }
.auth-card { width: 320px; max-width: 100%; display: flex; flex-direction: column; gap: 10px; text-align: center; }
.auth-card h1 { font: 700 26px var(--font-display); letter-spacing: -0.02em; margin: 8px 0 0; }
.auth-icon { width: 96px; height: 96px; margin: 0 auto; }
.auth-sub { color: var(--text-2); margin: 0 0 10px; }
.auth-card input { min-height: 34px; font-size: 14px; padding: 6px 12px; text-align: left; }
.auth-btn { min-height: 34px; font-size: 14px; margin-top: 4px; }
.auth-error { color: var(--red); font-size: 12.5px; min-height: 16px; }
.shake { animation: shake .4s; }
@keyframes shake { 20%, 60% { transform: translateX(-8px); } 40%, 80% { transform: translateX(8px); } }

/* ---------- tablet ---------- */
@media (max-width: 1100px) {
  .search { width: 130px; } .search:focus { width: 170px; }
  .tb-center { position: static; transform: none; margin-left: 8px; }
}
@media (max-width: 900px) {
  .shell, .shell.no-sidebar { grid-template-columns: 0 1fr; }
  .sidebar { position: fixed; left: 0; top: 0; bottom: 0; width: var(--sidebar-w); z-index: 80; transform: translateX(-100%); transition: transform .25s ease; padding-top: 12px; box-shadow: 0 0 40px rgba(0, 0, 0, .2); background: var(--bg-alt); }
  .shell.sidebar-open .sidebar { transform: none; }
  .shell.sidebar-open .sidebar-scrim { display: block; position: fixed; inset: 0; z-index: 79; background: rgba(0, 0, 0, .2); }
  .yv { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

/* ---------- phone ---------- */
@media (max-width: 700px) {
  :root { --toolbar-h: 50px; }
  body { font-size: 15px; }
  .main { grid-template-rows: auto 1fr auto; }
  .toolbar { padding: env(safe-area-inset-top) 8px 0; height: auto; min-height: var(--toolbar-h); flex-wrap: wrap; gap: 4px 6px; row-gap: 0; }
  .tb-left .tb-btn:nth-child(2), .assistant-btn, .search-wrap { display: none; }
  .tb-title { font-size: 22px; order: 1; flex: 1; margin-left: 2px; overflow: hidden; text-overflow: ellipsis; }
  .tb-title small { display: none; }
  .tb-right { order: 2; margin-left: 0; }
  .tb-today { display: none; }
  .tb-center { order: 3; width: 100%; padding: 4px 0 8px; display: flex; }
  .seg { width: 100%; }
  .seg button { flex: 1; min-width: 0; padding: 4px 0; }
  .tabbar { display: flex; align-items: center; justify-content: space-around; border-top: 1px solid var(--sep); background: var(--bg-toolbar); backdrop-filter: blur(20px); padding: 6px 8px calc(6px + env(safe-area-inset-bottom)); }
  .tabbar button { color: var(--red); font-size: 15px; padding: 6px 10px; display: flex; align-items: center; gap: 4px; }
  .tabbar-ai { color: var(--accent) !important; font-weight: 500; }
  .tg { --gutter: 44px; }
  .tg-hour { font-size: 10px; right: 5px; }
  .tg-dayhead { flex-direction: column; align-items: center; padding: 4px 0 6px; gap: 2px; }
  .tg-week .tg-dayhead .dow { font-size: 10.5px; color: var(--text-2); }
  .tg-week .tg-dayhead .num { margin: 0; font-size: 17px; }
  .tg-dayhead.today .num { font-size: 15px; padding: 3px 0; width: 28px; min-width: 0; }
  .tg-day .tg-dayhead { flex-direction: row; align-items: baseline; padding-left: 10px; justify-content: flex-start; }
  .tg-allday-label { font-size: 9.5px; padding-right: 4px; }
  .ev { font-size: 11px; }
  .ev-timed { padding: 1px 3px 1px 5px; }
  .tg-week .ev-time, .tg-week .ev-loc { display: none; }
  .tg-week .ev-time-inline { display: none; }
  .tg-week .ev-timed .ev-title { display: block; white-space: nowrap; text-overflow: clip; font-size: 10.5px; }
  .now-label { font-size: 9.5px; right: calc(100% + 3px); }
  .yv { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; padding: 14px; }
  .ym-day { width: 20px; height: 20px; font-size: 10px; }
  .assistant { left: 0; right: 0; bottom: 0; top: 40px; width: auto; border-radius: 14px 14px 0 0; transform: translateY(105%); padding-bottom: env(safe-area-inset-bottom); }
  .assistant.open { transform: none; }
  .as-msg { font-size: 15px; }
  .pop-body { padding: 10px 18px 18px; }
  input:not([type]), input[type=text], input[type=password], input[type=url], input[type=date], input[type=time], input[type=number], select, textarea { font-size: 16px; min-height: 32px; }
  .f-title { font-size: 20px !important; }
  .btn { min-height: 32px; font-size: 15px; padding: 4px 14px; }
  .modal-backdrop { padding: 0; align-items: end; }
  .window { width: 100% !important; border-radius: 14px 14px 0 0; max-height: 94dvh; }
  .window-titlebar .traffic { display: none; }
  .window-done { display: block; }
  .set-row { grid-template-columns: 1fr; gap: 4px; }
  .set-row > label { text-align: left; color: var(--text-2); font-size: 13px; }
  .set-ctl select { min-width: 0; width: 100%; }
  .set-pane { padding: 14px 16px 30px; }
  .set-tabs { overflow-x: auto; justify-content: flex-start; }
  .notif-stack { left: 8px; right: 8px; width: auto; top: calc(8px + env(safe-area-inset-top)); }
  .toast { bottom: calc(76px + env(safe-area-inset-bottom)); }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; } }
@media print { .sidebar, .toolbar, .tabbar, .assistant { display: none !important; } .shell { display: block; } body { overflow: visible; } }

/* Touch: events can be tapped, held and dragged without selecting text or opening menus. */
.ev-timed { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
.ev.dragging { transform: scale(1.015); transition: transform .12s; }
@media (pointer: coarse) {
  .ev-handle { height: 16px; }
  .sheet .pop-actions .btn { min-height: 40px; padding: 8px 18px; font-size: 16px; }
  .sheet .pop-actions .btn.icon-btn { padding: 8px 12px; }
}

/* Tasks: separate from events, shown on their day with a checkbox. */
.task { display: flex; align-items: center; gap: 6px; min-width: 0; font-size: 12px; line-height: 1.3; }
.task-check { width: 15px; height: 15px; border-radius: 50%; border: 1.5px solid var(--text-3); flex: none; display: grid; place-items: center; color: #fff; background: var(--bg); transition: background .12s, border-color .12s; }
.task-check:hover { border-color: var(--accent); }
.task.done .task-check { background: var(--accent); border-color: var(--accent); }
.task-check.ghost { border-style: dashed; }
.task-body { flex: 1; min-width: 0; display: flex; align-items: baseline; gap: 6px; text-align: left; color: var(--text); padding: 2px 0; }
.task-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.task.done .task-title { color: var(--text-3); text-decoration: line-through; }
.task-when { flex: none; font-size: 11px; color: var(--text-2); }
.task.overdue .task-when { color: var(--red); }
.task-prio { color: var(--red); font-weight: 700; flex: none; }
.task-add { display: inline-flex; align-items: center; gap: 4px; color: var(--text-3); font-size: 11.5px; padding: 2px 4px; border-radius: 4px; }
.task-add:hover { color: var(--accent); background: var(--bg-hover); }

.tg-tasks { display: flex; border-bottom: 1px solid var(--sep-strong); min-height: 24px; position: relative; z-index: 2; background: var(--bg); }
.tg-tasks-grid { flex: 1; display: grid; grid-template-columns: repeat(var(--ndays), minmax(0, 1fr)); max-height: 112px; overflow-y: auto; }
.tg-tasks-cell { border-left: 1px solid var(--grid); padding: 2px 4px; display: flex; flex-direction: column; align-items: flex-start; gap: 1px; min-width: 0; }
.tg-tasks-cell .task { width: 100%; }
.tg-tasks-cell .task-add { opacity: .55; }
.tg-tasks-cell:hover .task-add, .tg-tasks-cell .task-add:only-child { opacity: 1; }
.tg-day .tg-tasks-cell .task { font-size: 13px; }

.mv-item.mv-task { padding: 0 2px; background: none; }
.mv-task .task { width: 100%; font-size: 11.5px; }
.mv-task .task-check { width: 12px; height: 12px; }
.mv-dot.task-dot { background: none; box-shadow: inset 0 0 0 1.5px var(--text-2); }

.agenda-tasks { padding: 4px 16px 16px; display: flex; flex-direction: column; gap: 4px; }
.agenda-tasks-head { display: flex; align-items: center; justify-content: space-between; font-size: 13px; font-weight: 600; color: var(--text-2); padding: 8px 0 2px; border-top: 1px solid var(--sep); }
.agenda-tasks .task { font-size: 15px; }
.agenda-tasks .task-check { width: 20px; height: 20px; }

.kind-seg { display: flex; margin: 0 auto 10px; width: max-content; }
@media (pointer: coarse) {
  .task-check { width: 20px; height: 20px; }
  .tg-tasks-cell .task-add { opacity: 1; }
}
