:root {
  --bg: #0b0b0d;
  --surface: #17171c;
  --surface-2: #1f1f26;
  --border: #2a2a33;
  --text: #eaeaf0;
  --text-dim: #9a9aa8;
  --accent: #4f8cff;
  --accent-2: #3b6fd8;
  --warn: #ff5f52;
  --warn-bg: #402018;
  --ok: #3cc29a;
  --high: #ff5f52;
  --med: #ffc23a;
  --low: #4a9fff;
  --pin: #c68fff;
  --safe-top: env(safe-area-inset-top);
  --safe-bottom: env(safe-area-inset-bottom);
  --tab-h: 66px;
  --hdr-h: 52px;
}
html.is-android {
  --safe-bottom: 0px;
}
@media (prefers-color-scheme: light) {
  :root {
    --bg: #f7f7fa;
    --surface: #ffffff;
    --surface-2: #f0f0f5;
    --border: #dcdce2;
    --text: #111;
    --text-dim: #666;
    --warn-bg: #ffe2de;
  }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; height: 100%; background: var(--bg); color: var(--text);
  font: 16px/1.35 -apple-system, BlinkMacSystemFont, "SF Pro Text", system-ui, sans-serif;
  overscroll-behavior: none;
  -webkit-user-select: none; user-select: none;
}
input, textarea, select, [contenteditable="true"] { -webkit-user-select: text; user-select: text; }
body { min-height: 100dvh; }

.hidden { display: none !important; }

/* ---------- screens / tabs ---------- */
.screen { min-height: 100dvh; display: flex; flex-direction: column; }
#app { padding-bottom: calc(var(--tab-h) + var(--safe-bottom)); }
.tab-screen { display: none; flex-direction: column; flex: 1; min-height: 100dvh;
  padding-top: var(--safe-top); padding-bottom: calc(var(--tab-h) + var(--safe-bottom));
}
.tab-screen.active { display: flex; }
header {
  position: sticky; top: var(--safe-top); z-index: 5;
  background: var(--bg); padding: 10px 56px 8px 16px;
  display: flex; align-items: center; justify-content: space-between;
  border-bottom: 1px solid var(--border); min-height: var(--hdr-h);
}
header h1 { margin: 0; font-size: 22px; font-weight: 700; letter-spacing: -0.01em; display: flex; align-items: center; gap: 8px; }
header h1 .app-icon { width: 26px; height: 26px; border-radius: 6px; display: inline-block; flex-shrink: 0; }
.hdr-btn { background: transparent; color: var(--accent); border: 0; font-size: 15px; padding: 6px 8px; min-height: 0; }
.date-badge { color: var(--text-dim); font-size: 14px; }
.refresh-btn {
  position: fixed;
  top: calc(env(safe-area-inset-top) + 10px);
  right: calc(env(safe-area-inset-right) + 10px);
  z-index: 200;
  width: 34px; height: 34px; min-height: 0; padding: 0;
  background: var(--surface-2); color: var(--text);
  border: 1px solid var(--border); border-radius: 999px;
  font-size: 18px; line-height: 1; font-weight: 400;
  display: flex; align-items: center; justify-content: center;
}
.refresh-btn:active { opacity: 0.7; }

/* ---------- tab bar ---------- */
.tabs {
  position: fixed; left: 0; right: 0; bottom: 0;
  height: calc(var(--tab-h) + var(--safe-bottom));
  padding-bottom: var(--safe-bottom);
  background: var(--surface);
  border-top: 1px solid var(--border);
  display: grid; grid-template-columns: repeat(4, 1fr);
  z-index: 20;
}
.tab-btn {
  background: transparent; border: 0; color: var(--text-dim);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 3px; font-size: 11px; padding: 6px;
}
.tab-btn span { font-size: 20px; line-height: 1; }
.tab-btn.active { color: var(--accent); }

/* ---------- anytime checklist ---------- */
.anytime-section {
  padding: 8px 12px 4px;
  display: flex; flex-direction: column; gap: 6px;
}
.anytime-section.hidden { display: none; }
.anytime-head {
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--text-dim); font-weight: 600; padding: 2px 2px 0;
}
.anytime-item {
  display: flex; align-items: center; gap: 10px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px;
  padding: 10px 12px; min-height: 44px;
}
.anytime-item.done .anytime-title { opacity: 0.5; text-decoration: line-through; }
.anytime-check {
  flex: 0 0 auto; width: 26px; height: 26px; border-radius: 999px;
  border: 2px solid var(--text-dim); background: transparent;
  display: inline-flex; align-items: center; justify-content: center;
  padding: 0; cursor: pointer; color: transparent;
  min-height: 0;
}
.anytime-check.is-checked { background: var(--ok); border-color: var(--ok); color: #fff; }
.anytime-check.is-checked::after { content: '✓'; font-size: 16px; font-weight: 700; line-height: 1; }
.anytime-title { flex: 1; font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.anytime-cal { width: 8px; height: 8px; border-radius: 999px; flex-shrink: 0; }

.at-cal { display: flex; flex-direction: column; gap: 6px; }
.at-cal-head {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 12px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px;
  color: var(--text); font: inherit; min-height: 0; text-align: left;
}
.at-cal-head .at-chev {
  display: inline-block; width: 12px;
  color: var(--text-dim); font-size: 12px;
  transition: transform 120ms ease-out;
}
.at-cal.is-open > .at-cal-head .at-chev { transform: rotate(90deg); }
.at-cal-head .cal-dot { width: 10px; height: 10px; border-radius: 999px; flex-shrink: 0; }
.at-cal-head .at-cal-name { font-size: 15px; font-weight: 700; flex: 1; }
.at-cal-head .at-cal-count {
  background: var(--surface-2); color: var(--text-dim);
  padding: 2px 8px; border-radius: 999px; font-size: 11px; font-weight: 500;
}
.at-cal-body { display: flex; flex-direction: column; gap: 6px; margin-left: 14px; }

.at-cat { display: flex; flex-direction: column; gap: 4px; }
.at-cat-head {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 10px;
  background: transparent; border: none;
  color: var(--text-dim); font: inherit; min-height: 0; text-align: left;
}
.at-cat-head .at-chev {
  display: inline-block; width: 10px;
  font-size: 10px;
  transition: transform 120ms ease-out;
}
.at-cat.is-open > .at-cat-head .at-chev { transform: rotate(90deg); }
.at-cat-head .at-cat-name { font-size: 12px; text-transform: uppercase; letter-spacing: 0.06em; font-weight: 600; flex: 1; }
.at-cat-head .at-cat-count { font-size: 11px; font-weight: 500; }
.at-cat-body { display: flex; flex-direction: column; gap: 4px; margin-left: 8px; }

/* ---------- list ---------- */
.list { padding: 10px 12px 40px; display: flex; flex-direction: column; gap: 8px; }
.task-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
  padding: 12px 14px; display: flex; flex-direction: column; gap: 4px;
  position: relative; overflow: hidden;
}
.task-card.conflict { border-color: var(--warn); background: var(--warn-bg); }
.task-card.done { opacity: 0.55; }
.task-card .row1 { display: flex; align-items: center; gap: 8px; }
.task-card .title { flex: 1; font-weight: 600; font-size: 16px; }
.task-card.done .title { text-decoration: line-through; }
.task-card .time { color: var(--text-dim); font-size: 13px; font-variant-numeric: tabular-nums; }
.task-card .meta { display: flex; gap: 8px; color: var(--text-dim); font-size: 12px; flex-wrap: wrap; }
.task-card .prio-dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.prio-high { background: var(--high); }
.prio-medium { background: var(--med); }
.prio-low { background: var(--low); }
.pill {
  background: var(--surface-2); color: var(--text-dim);
  padding: 2px 8px; border-radius: 999px; font-size: 11px;
}
.pill.warn { background: var(--warn); color: #fff; }
.pill.pin  { background: var(--pin); color: #fff; }

/* ---------- FAB ---------- */
.fab {
  position: fixed; right: 18px; z-index: 15;
  bottom: calc(var(--tab-h) + var(--safe-bottom) + 16px);
  width: 58px; height: 58px; border-radius: 50%;
  background: var(--accent); color: #fff; border: 0;
  box-shadow: 0 4px 14px rgba(0,0,0,0.3);
  display: flex; align-items: center; justify-content: center;
  font-size: 32px; line-height: 1; padding: 0;
  font-weight: 300;
}
.fab::before { content: "+"; display: block; margin-top: -3px; }
.fab:active { background: var(--accent-2); }

/* ---------- sheet (modal) ---------- */
.sheet {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(0,0,0,0.45);
  display: flex; align-items: flex-end; justify-content: center;
}
.sheet-body {
  width: 100%; max-width: 560px;
  background: var(--surface); border-radius: 18px 18px 0 0;
  padding: 10px 16px calc(16px + var(--safe-bottom));
  display: flex; flex-direction: column; gap: 10px;
  max-height: 90dvh; overflow-y: auto;
}
.sheet-handle {
  width: 40px; height: 4px; background: var(--border);
  border-radius: 2px; margin: 4px auto 6px;
}
.sheet h2 { margin: 0 0 4px; font-size: 18px; }
.sheet-head-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 4px; }
.sheet-head-row h2 { margin: 0; }
.sheet-head-actions { display: flex; gap: 6px; align-items: center; }
.sheet-head-actions .icon-btn {
  flex: 0 0 auto; min-height: 0;
  width: 40px; height: 40px; padding: 0;
  display: inline-flex; align-items: center; justify-content: center;
}
.sheet-head-actions .icon-btn svg { display: block; }
.sheet label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--text-dim); }
.sheet label.row { flex-direction: row; align-items: center; justify-content: space-between; }
.sheet input, .sheet textarea, .sheet select {
  background: var(--surface-2); border: 1px solid var(--border); color: var(--text);
  border-radius: 10px; padding: 12px; font: inherit;
}
/* ---------- Inbox view switch + grouped view ---------- */
.seg-switch {
  display: flex; gap: 0; margin: 10px 12px 0;
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 10px; padding: 3px;
}
.seg-switch .seg-btn {
  flex: 1; background: transparent; color: var(--text-dim);
  border: 0; border-radius: 7px; padding: 8px 10px;
  font-size: 14px; font-weight: 500; min-height: 0;
}
.seg-switch .seg-btn.active {
  background: var(--surface); color: var(--text);
  box-shadow: 0 1px 2px rgba(0,0,0,0.15);
}
.inbox-search {
  position: relative;
  padding: 8px 12px 0;
}
.inbox-search input[type="search"] {
  width: 100%;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 10px;
  padding: 10px 36px 10px 14px;
  font: inherit; font-size: 14px;
  -webkit-appearance: none; appearance: none;
}
.inbox-search input[type="search"]::-webkit-search-cancel-button { display: none; }
.inbox-search input[type="search"]:focus { outline: 1px solid var(--accent); border-color: var(--accent); }
.inbox-search-clear {
  position: absolute; right: 18px; top: 50%; transform: translateY(-50%);
  width: 26px; height: 26px; min-height: 0; padding: 0;
  background: transparent; color: var(--text-dim);
  border: 0; font-size: 22px; line-height: 1;
  display: flex; align-items: center; justify-content: center;
}
.inbox-empty {
  padding: 30px 12px;
  text-align: center;
  color: var(--text-dim);
  font-size: 14px;
}
.grouped { padding: 10px 12px 40px; display: flex; flex-direction: column; gap: 14px; }
.grp-cal { display: flex; flex-direction: column; gap: 6px; }
.grp-cal-head {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  font: inherit;
  min-height: 0;
  text-align: left;
}
.grp-cal-head.drop-target { border-color: var(--accent); background: rgba(79,140,255,0.1); }
.grp-cal-head .grp-chev {
  display: inline-block; width: 12px;
  color: var(--text-dim); font-size: 12px;
  transition: transform 120ms ease-out;
}
.grp-cal.is-open .grp-cal-head .grp-chev { transform: rotate(90deg); }
.grp-cal-head .cal-dot {
  width: 12px; height: 12px; border-radius: 999px; flex-shrink: 0;
  border: 1px solid rgba(0,0,0,0.15);
}
.grp-cal-head .cal-name { font-size: 15px; font-weight: 700; letter-spacing: -0.01em; flex: 1; }
.grp-cal-head .grp-cal-count {
  background: var(--surface-2); color: var(--text-dim);
  padding: 2px 8px; border-radius: 999px; font-size: 11px; font-weight: 500;
}
.grp-cal-body { display: flex; flex-direction: column; gap: 6px; margin-left: 14px; }
.grp-cat {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 12px; padding: 8px 10px;
  display: flex; flex-direction: column; gap: 6px;
}
.grp-cat.drop-target { border-color: var(--accent); background: rgba(79,140,255,0.1); }
.grp-cat-head {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 4px;
  min-height: 36px;
  cursor: pointer;
  user-select: none;
}
.grp-cat-head .grp-cat-chev {
  display: inline-flex; align-items: center; justify-content: center;
  width: 18px; height: 18px;
  color: var(--text); font-size: 14px;
  transition: transform 120ms ease-out;
  flex-shrink: 0;
}
.grp-cat.is-open > .grp-cat-head .grp-cat-chev { transform: rotate(90deg); }
.grp-cat-name {
  flex: 0 0 auto;
  background: transparent; border: 0; color: var(--text);
  font-weight: 600; font-size: 13px; padding: 2px 4px;
  border-radius: 6px; min-width: 0;
  width: auto;
  /* Shrink to content where supported (Chrome 123+/Safari 18+); the JS
     `size` attribute is the fallback for everything else. */
  field-sizing: content;
}
.grp-cat-name:focus { outline: 1px solid var(--accent); background: var(--surface-2); }
/* Pushes the count + delete to the far right; the gap between the name
   input and the count becomes header-clickable area for toggling collapse. */
.grp-cat-head .grp-cat-count { margin-left: auto; color: var(--text-dim); font-size: 11px; }
.grp-cat-head .grp-cat-hide {
  display: inline-flex; align-items: center; gap: 4px;
  color: var(--text-dim); font-size: 11px;
  cursor: pointer; user-select: none;
}
.grp-cat-head .grp-cat-hide input { width: 14px; height: 14px; margin: 0; accent-color: var(--accent); }
.grp-cat-head .grp-cat-hide input:checked + span { color: var(--accent); }
.grp-cat-head .grp-cat-del {
  background: transparent; color: var(--text-dim); border: 0;
  min-height: 0; padding: 2px 6px; font-size: 16px; line-height: 1;
}
.grp-cat-head .grp-cat-del:active { color: var(--warn); }
.grp-cat .grp-tasks { display: flex; flex-direction: column; gap: 4px; }
.grp-task {
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 8px; padding: 8px 10px;
  display: flex; align-items: center; gap: 8px;
  font-size: 14px; touch-action: pan-y;
}
.grp-task.done { opacity: 0.5; text-decoration: line-through; }
.grp-task .prio-dot { width: 8px; height: 8px; border-radius: 999px; flex-shrink: 0; }
.grp-task .grp-task-title { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.grp-task .grp-task-dur { color: var(--text-dim); font-size: 12px; }
.grp-task.is-dragging { opacity: 0.3; }
.grp-add-cat {
  align-self: flex-start; background: transparent; color: var(--accent);
  border: 1px dashed var(--border); border-radius: 8px;
  padding: 6px 10px; font-size: 13px; min-height: 0;
}
.drag-ghost {
  position: fixed; pointer-events: none; z-index: 999;
  background: var(--surface); border: 1px solid var(--accent);
  border-radius: 8px; padding: 8px 10px; font-size: 14px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.4);
  transform: rotate(-1.5deg);
  max-width: 280px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.cal-picker { position: relative; }
.cal-picker-trigger {
  width: 100%; background: var(--surface-2); color: var(--text);
  border: 1px solid var(--border); border-radius: 10px;
  padding: 12px; font: inherit; font-weight: 400;
  display: flex; align-items: center; gap: 10px;
  min-height: 0; text-align: left;
}
.cal-picker-trigger .cal-picker-name { flex: 1; }
.cal-picker-trigger .cal-picker-chev { color: var(--text-dim); font-size: 12px; }
.cal-picker .cal-picker-dot {
  width: 14px; height: 14px; border-radius: 999px;
  background: #888; flex-shrink: 0;
  border: 1px solid rgba(0,0,0,0.15);
  box-sizing: border-box;
}
.cal-picker-list {
  margin-top: 6px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 4px;
  display: flex; flex-direction: column; gap: 2px;
  max-height: 240px; overflow-y: auto;
}
.cal-picker-item {
  width: 100%; background: transparent; color: var(--text);
  border: 0; border-radius: 8px;
  padding: 10px 12px; font: inherit; font-weight: 400;
  display: flex; align-items: center; gap: 10px;
  min-height: 0; text-align: left;
}
.cal-picker-item:active { background: var(--surface); }
.cal-picker-item em { color: var(--text-dim); font-style: normal; font-size: 12px; }

.done-toggle {
  width: 100%;
  background: var(--surface-2); color: var(--text);
  border: 1px solid var(--border);
  margin-top: 2px;
  display: flex; align-items: center; justify-content: center;
  line-height: 1;
}
.done-toggle.is-done {
  background: var(--ok); color: #fff; border-color: var(--ok);
}
.sheet-actions { display: flex; gap: 8px; margin-top: 8px; flex-wrap: wrap; align-items: stretch; }
.sheet-actions button { flex: 1 0 auto; }

button {
  background: var(--accent); color: #fff; border: 0;
  padding: 14px 18px; border-radius: 10px; font-size: 15px; font-weight: 600;
  min-height: 44px;
}
button:active { opacity: 0.85; }
button.ghost { background: var(--surface-2); color: var(--text); }
button.danger { background: var(--warn); color: #fff; }

/* ---------- settings ---------- */
.settings { padding: 14px; display: flex; flex-direction: column; gap: 10px; }
.settings label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--text-dim); }
.settings label.row { flex-direction: row; align-items: center; justify-content: space-between; }
.settings input[type=text], .settings input[type=number], .settings input[type=password] {
  background: var(--surface-2); border: 1px solid var(--border); color: var(--text);
  border-radius: 10px; padding: 12px; font: inherit;
}
.settings hr { border: 0; border-top: 1px solid var(--border); margin: 8px 0; }
.cal-list { display: flex; flex-direction: column; gap: 8px; }
.cal-row {
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px;
  padding: 10px; display: flex; flex-direction: column; gap: 8px;
}
.cal-row .cal-row-head { display: flex; align-items: center; gap: 8px; }
.cal-row .cal-swatch { width: 22px; height: 22px; border-radius: 6px; border: 1px solid var(--border); flex-shrink: 0; padding: 0; }
.cal-row .cal-name { flex: 1; background: transparent; border: 0; color: var(--text); font-weight: 600; font-size: 15px; padding: 0; }
.cal-row .cal-default-badge { font-size: 11px; color: var(--text-dim); background: var(--surface); padding: 2px 6px; border-radius: 999px; }
.cal-row .cal-url-row { display: flex; gap: 6px; }
.cal-row .cal-url-row input { flex: 1; font-size: 12px; padding: 8px; }
.cal-row .cal-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.cal-row .cal-actions button { flex: 1 0 auto; min-height: 36px; padding: 6px 10px; font-size: 13px; }
.cal-new { display: flex; gap: 6px; align-items: stretch; }
.cal-new input[type=text] { flex: 1; }
.cal-new input[type=color] { width: 48px; padding: 4px; }
.cal-new button { min-height: 44px; }

.task-card .cal-badge {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 11px; color: var(--text-dim);
}
.task-card .cal-swatch { width: 8px; height: 8px; border-radius: 2px; display: inline-block; }

/* ---------- login ---------- */
.login-box {
  max-width: 340px; width: 88%;
  background: var(--surface); border: 1px solid var(--border); border-radius: 16px;
  padding: 22px; margin: auto;
  display: flex; flex-direction: column; gap: 10px;
}
.login-box h1 { margin: 0 0 8px; text-align: center; }
.login-box input {
  background: var(--surface-2); border: 1px solid var(--border); color: var(--text);
  border-radius: 10px; padding: 14px; font: inherit;
}
.err { color: var(--warn); font-size: 13px; min-height: 18px; text-align: center; }

/* ---------- calendar ---------- */
#calendar {
  padding: 4px 6px 4px;
  overflow-x: hidden;
}
#calendar .fc-view-harness { will-change: transform; }
#calendar .fc-toolbar.fc-header-toolbar { margin-bottom: 6px; }
.fc .fc-weekendsToggle-button {
  font-weight: 600; letter-spacing: 0.5px; min-width: 42px;
}
.fc .fc-weekendsToggle-button.weekends-off {
  text-decoration: line-through; opacity: 0.55;
}
.fc .fc-hours24-button {
  font-weight: 600; letter-spacing: 0.5px; min-width: 42px;
}
.fc .fc-hours24-button.hours24-off {
  text-decoration: line-through; opacity: 0.55;
}
#calendar:not(.day-view) .fc-hours24-button { display: none; }
.fc { background: var(--bg); color: var(--text); font-family: inherit; }
.fc .fc-toolbar-title { font-size: 15px !important; font-weight: 600; }
.fc .fc-button {
  background: var(--surface-2); border-color: var(--border); color: var(--text);
  padding: 6px 10px; font-size: 13px; text-transform: none;
}
.fc .fc-prev-button, .fc .fc-next-button {
  padding: 4px 6px; min-width: 0;
  display: inline-flex; align-items: center; justify-content: center;
}
.fc .fc-prev-button .fc-icon, .fc .fc-next-button .fc-icon {
  font-size: 14px; line-height: 1;
}
.fc .fc-button-primary:not(:disabled).fc-button-active,
.fc .fc-button-primary:not(:disabled):active { background: var(--accent); border-color: var(--accent); }
.fc .fc-col-header-cell-cushion { color: var(--text-dim); }
.fc .fc-daygrid-day-number, .fc .fc-list-day-text, .fc .fc-list-day-side-text { color: var(--text); text-decoration: none; }
.fc-theme-standard td, .fc-theme-standard th, .fc-theme-standard .fc-scrollgrid { border-color: var(--border); }
.fc .fc-day-today { background: rgba(79,140,255,0.08) !important; }
.fc .fc-day.is-focus-day { background: rgba(79,140,255,0.22) !important; box-shadow: inset 0 0 0 2px var(--accent); }
.fc .fc-day.is-focus-day .fc-daygrid-day-number { color: var(--accent); font-weight: 700; }

/* ---------- Dots view (Apple-style month grid) ---------- */
#calendar.dots-view .fc-daygrid-day-events,
#calendar.dots-view .fc-daygrid-day-bottom { display: none !important; min-height: 0 !important; }
#calendar.dots-view .fc-daygrid-body tr { height: 44px !important; }
#calendar.dots-view .fc-daygrid-day-frame { min-height: 44px !important; height: 44px !important; padding: 0; }
#calendar.dots-view .fc-daygrid-day-top { flex-direction: column; align-items: center; padding-top: 2px; gap: 0; height: 44px; justify-content: flex-start; }
#calendar.dots-view .fc-daygrid-day-number {
  font-size: 15px; font-weight: 600; line-height: 1;
  width: 26px; height: 26px; padding: 0; margin: 0;
  display: inline-flex; align-items: center; justify-content: center;
  box-sizing: border-box;
}
#calendar.dots-view .fc-col-header-cell-cushion { font-size: 11px; padding: 4px 0; }
#calendar.dots-view .fc-day-today .fc-daygrid-day-number {
  background: var(--accent); color: #fff; border-radius: 999px;
}
#calendar.dots-view .fc-day.is-focus-day { box-shadow: none; background: transparent !important; }
#calendar.dots-view .fc-day.is-focus-day .fc-daygrid-day-number {
  background: var(--text); color: var(--bg); border-radius: 999px; font-weight: 700;
}
#calendar.dots-view .fc-day.is-focus-day.fc-day-today .fc-daygrid-day-number { background: var(--accent); color: #fff; }
#calendar.dots-view .fc-day.drop-target {
  background: rgba(79,140,255,0.22) !important;
  outline: 2px dashed var(--accent);
  outline-offset: -3px;
}
#calendar.dots-view .fc-day.drop-target .fc-daygrid-day-number {
  color: var(--accent); font-weight: 700;
}
.dots-row {
  display: flex; justify-content: center; align-items: center;
  margin-top: 3px; min-height: 6px;
  width: 100%; max-width: 100%;
  padding: 0 3px; box-sizing: border-box;
}
.dots-row .pill {
  display: flex; height: 6px; border-radius: 3px; overflow: hidden;
  padding: 0; gap: 0; font-size: 0; line-height: 0;
  width: min(46px, 100%);
  max-width: 100%;
}
.dots-row .pill .seg {
  height: 100%; display: block; padding: 0; margin: 0;
  flex: 0 0 auto; min-width: 0;
}
.dots-row .pill .seg.is-done { opacity: 0.35; }
.dots-row .pill .seg.is-conflict { box-shadow: inset 0 0 0 1.5px var(--warn); }

/* ---------- mini day timegrid (below dots view) ---------- */
.mini-day-panel {
  padding: 0 12px 20px;
  display: flex; flex-direction: column; gap: 2px;
}
.mini-day-panel .day-panel-header { padding-top: 2px; padding-bottom: 2px; gap: 0; }
.mini-day-panel .day-panel-hint { display: none; }
#mini-day { min-height: 340px; }
#mini-day .fc { font-size: 12px; }
#mini-day .fc .fc-timegrid-slot { height: 1.8em; }
.fc-event { font-size: 12px; border-radius: 6px; padding: 1px 4px; cursor: grab; }
.fc-event.is-conflict { background: var(--warn) !important; border-color: var(--warn) !important; }
.fc-event.is-pinned { background: var(--pin) !important; border-color: var(--pin) !important; }
.fc-event.is-done { opacity: 0.45; text-decoration: line-through; }
.fc-timegrid-event .fc-event-main { padding-right: 44px; }
.fc-timegrid-event .fc-event-main-frame { display: flex; flex-direction: column; height: 100%; }
.fc-timegrid-event .evt-notes {
  flex: 1 1 auto;
  min-height: 0;
  margin-top: 3px;
  font-size: 11px;
  line-height: 1.3;
  color: rgba(255, 255, 255, 0.8);
  white-space: pre-wrap;
  word-break: break-word;
  overflow: hidden;
}
#mini-day .fc-timegrid-event .evt-notes { font-size: 10px; line-height: 1.25; margin-top: 2px; }
.fc-timegrid-event-harness .evt-check {
  position: absolute; top: 6px; right: 6px;
  width: 34px; height: 34px; min-height: 0; padding: 0;
  border: 0; background: transparent;
  font-size: 0; line-height: 1;
  display: flex; align-items: center; justify-content: center;
  touch-action: manipulation; cursor: pointer; z-index: 10;
  box-sizing: border-box;
  border-radius: 999px;
}
.evt-check::before {
  content: ""; display: block; width: 26px; height: 26px;
  border: 2px solid rgba(255,255,255,0.95);
  border-radius: 999px;
  background: transparent;
  box-sizing: border-box;
}
.evt-check.is-checked::before { background: rgba(255,255,255,0.95); }
.evt-check.is-checked::after {
  content: "✓"; position: absolute;
  color: #111; font-size: 15px; font-weight: 900; line-height: 1;
}
.fc-event.is-done .evt-check { opacity: 1; }
.fc-list-event-dot { background: var(--accent); border-color: var(--accent); }
.fc-list-event.fc-event.is-pinned,
.fc-list-event.fc-event.is-pinned td,
.fc-list-event.fc-event.is-conflict,
.fc-list-event.fc-event.is-conflict td { background: transparent !important; }
.fc-list-event.fc-event.is-pinned .fc-list-event-dot { background: var(--pin) !important; border-color: var(--pin) !important; }
.fc-list-event.fc-event.is-conflict .fc-list-event-dot { background: var(--warn) !important; border-color: var(--warn) !important; }
.fc-list-event.is-conflict td { color: var(--warn); }
.fc-list-event.is-done td { opacity: 0.55; text-decoration: line-through; }

/* ---------- mini-day panel header (below month view) ---------- */
.day-panel-header {
  display: flex; flex-direction: column; gap: 2px;
  padding: 2px 2px 6px;
}
.day-panel-head-row { display: flex; align-items: center; gap: 8px; }
.day-panel-head-row #mini-day-title { flex: 1; font-weight: 600; font-size: 15px; }
.day-panel-goto {
  background: transparent; color: var(--accent); border: 0;
  padding: 2px 4px; font-size: 13px; font-weight: 500; min-height: 0;
}
.day-panel-goto:active { opacity: 0.6; }
.day-panel-hint { color: var(--text-dim); font-size: 11px; }
.fc-event-mirror,
.fc-event-dragging {
  box-shadow: 0 8px 24px rgba(0,0,0,0.35);
  transform: rotate(-1.5deg) scale(1.02);
  opacity: 0.95;
  z-index: 999;
}

/* ---------- toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: calc(var(--tab-h) + var(--safe-bottom) + 84px);
  transform: translateX(-50%);
  background: var(--surface); border: 1px solid var(--border);
  padding: 10px 16px; border-radius: 24px; font-size: 13px; color: var(--text);
  z-index: 200; box-shadow: 0 4px 16px rgba(0,0,0,0.4);
}
