/* Calendar app — base styles. Aesthetic switched via [data-aesthetic] on root. */

* { box-sizing: border-box; }
html, body, #root { height: 100%; }
body {
  margin: 0;
  font-family: var(--font-ui);
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  font-feature-settings: "ss01", "cv11";
}

button { font: inherit; color: inherit; background: none; border: none; cursor: pointer; padding: 0; text-align: left; }
ul { list-style: none; padding: 0; margin: 0; }

/* ─── Aesthetic 1: Editorial (warm paper) ─── */
:root[data-aesthetic="editorial"] {
  --font-ui: "Inter", system-ui, sans-serif;
  --font-display: "Fraunces", Georgia, serif;
  --font-mono: "JetBrains Mono", ui-monospace, monospace;
  --bg: oklch(0.985 0.005 80);
  --bg-soft: oklch(0.97 0.008 80);
  --bg-card: oklch(1 0 0);
  --ink: oklch(0.22 0.005 80);
  --ink-soft: oklch(0.45 0.005 80);
  --ink-faint: oklch(0.65 0.005 80);
  --rule: oklch(0.90 0.005 80);
  --rule-strong: oklch(0.82 0.005 80);
  --accent: oklch(0.62 0.14 145);
  --accent-soft: oklch(0.94 0.04 145);
  --today-bg: oklch(0.95 0.06 145);
  --shadow: 0 1px 2px oklch(0.22 0.005 80 / 0.04), 0 8px 24px oklch(0.22 0.005 80 / 0.06);
  --display-weight: 400;
}
:root[data-aesthetic="editorial"] .month-name {
  font-family: var(--font-display);
  font-style: italic;
  font-weight: 400;
}

/* ─── Aesthetic 2: Clean minimal ─── */
:root[data-aesthetic="minimal"] {
  --font-ui: "Inter", system-ui, sans-serif;
  --font-display: "Inter", system-ui, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, monospace;
  --bg: oklch(0.99 0.002 240);
  --bg-soft: oklch(0.97 0.003 240);
  --bg-card: oklch(1 0 0);
  --ink: oklch(0.20 0.005 240);
  --ink-soft: oklch(0.45 0.005 240);
  --ink-faint: oklch(0.68 0.005 240);
  --rule: oklch(0.92 0.003 240);
  --rule-strong: oklch(0.85 0.003 240);
  --accent: oklch(0.62 0.14 145);
  --accent-soft: oklch(0.94 0.04 145);
  --today-bg: oklch(0.96 0.05 145);
  --shadow: 0 1px 2px oklch(0.2 0.005 240 / 0.04), 0 8px 24px oklch(0.2 0.005 240 / 0.06);
  --display-weight: 600;
}

/* ─── Aesthetic 3: Mono planner ─── */
:root[data-aesthetic="mono"] {
  --font-ui: "JetBrains Mono", ui-monospace, monospace;
  --font-display: "JetBrains Mono", ui-monospace, monospace;
  --font-mono: "JetBrains Mono", ui-monospace, monospace;
  --bg: oklch(0.96 0.012 80);
  --bg-soft: oklch(0.94 0.015 80);
  --bg-card: oklch(0.985 0.008 80);
  --ink: oklch(0.20 0.01 80);
  --ink-soft: oklch(0.42 0.01 80);
  --ink-faint: oklch(0.62 0.01 80);
  --rule: oklch(0.85 0.01 80);
  --rule-strong: oklch(0.70 0.01 80);
  --accent: oklch(0.55 0.14 145);
  --accent-soft: oklch(0.90 0.04 145);
  --today-bg: oklch(0.92 0.07 145);
  --shadow: none;
  --display-weight: 500;
}
:root[data-aesthetic="mono"] .day-cell,
:root[data-aesthetic="mono"] .month-block,
:root[data-aesthetic="mono"] .drawer,
:root[data-aesthetic="mono"] .mini-month {
  border-radius: 0 !important;
}

/* ════════════════════════════════════════════════════════════════════ */
/* DESKTOP                                                              */
/* ════════════════════════════════════════════════════════════════════ */

.app-desktop {
  display: grid;
  grid-template-columns: 232px minmax(0, 1fr) 320px;
  height: 100vh;
  overflow: hidden;
}
@media (max-width: 1400px) {
  .app-desktop { grid-template-columns: 208px minmax(0, 1fr) 296px; }
}
@media (max-width: 1200px) {
  .app-desktop { grid-template-columns: 200px minmax(0, 1fr); }
  .app-desktop > .drawer { display: none !important; }
}

/* ─── Left rail ─── */
.rail {
  border-right: 1px solid var(--rule);
  padding: 20px 16px;
  overflow-y: auto;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  gap: 18px;
}
.rail-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--rule);
}
.rail-tweaks-btn {
  margin-left: auto;
  width: 28px; height: 28px;
  border-radius: 6px;
  border: 1px solid var(--rule);
  display: grid; place-items: center;
  font-size: 14px;
  color: var(--ink-soft);
  background: var(--bg-card);
  flex-shrink: 0;
}
.rail-tweaks-btn:hover { border-color: var(--rule-strong); color: var(--ink); }

/* Monogram theme switch — light variant by default, dark variant in dark mode.
   Both images stack in the same box; we toggle opacity. */
.brand-monogram-dark { opacity: 0; transition: opacity 120ms ease; }
.brand-monogram-light { opacity: 1; transition: opacity 120ms ease; }

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .brand-monogram-dark { opacity: 1; }
  :root:not([data-theme="light"]) .brand-monogram-light { opacity: 0; }
}
:root[data-theme="dark"] .brand-monogram-dark { opacity: 1; }
:root[data-theme="dark"] .brand-monogram-light { opacity: 0; }
.rail-brand-mark {
  flex: 0 0 auto;
  color: var(--ink);
  display: flex;
  align-items: center;
  justify-content: center;
}
.rail-brand-mini {
  color: var(--ink);
  letter-spacing: 0.2em;
}

/* Main title bar — prominent brand wordmark across the top */
.main-titlebar {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 4px 0 18px;
  margin-bottom: 18px;
  border-bottom: 1px solid var(--rule);
  color: var(--ink);
}
.main-wordmark {
  color: var(--ink);
  flex: 0 0 auto;
}
.main-titlebar-meta {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-left: auto;
  color: var(--ink-faint);
}
.main-titlebar-divider {
  width: 1px;
  height: 14px;
  background: var(--rule-strong);
}
.main-titlebar-tag {
  font-family: var(--font-mono, ui-monospace, monospace);
  font-size: 11px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

/* Mobile brand */
.m-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--ink);
}
.m-brand-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.m-top-month { margin-top: 8px; }

/* legacy hide */
.rail-brand-title, .rail-brand-sub { display: none; }

.rail-section-label {
  font-size: 10px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink-faint);
  margin-bottom: 10px;
}

.view-tabs {
  display: flex;
  gap: 2px;
  padding: 3px;
  background: var(--bg-soft);
  border-radius: 8px;
  border: 1px solid var(--rule);
}
.view-tabs button {
  flex: 1;
  padding: 6px 8px;
  font-size: 12px;
  border-radius: 6px;
  color: var(--ink-soft);
  text-align: center;
  font-weight: 500;
}
.view-tabs button.active {
  background: var(--bg-card);
  color: var(--ink);
  box-shadow: var(--shadow);
}

.year-jump {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-family: var(--font-display);
  font-weight: var(--display-weight);
  font-size: 18px;
}
:root[data-aesthetic="editorial"] .year-jump-num { font-style: italic; }
.year-jump button {
  width: 28px; height: 28px;
  border-radius: 999px;
  display: grid;
  place-items: center;
  color: var(--ink-soft);
  font-size: 14px;
}
.year-jump button:hover { background: var(--bg-soft); color: var(--ink); }

.cat-list { display: flex; flex-direction: column; gap: 4px; }
.cat-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 8px;
  border-radius: 6px;
  font-size: 13px;
  color: var(--ink-soft);
}
.cat-item:hover { background: var(--bg-soft); color: var(--ink); }
.cat-item.off { opacity: 0.4; }
.cat-dot { width: 10px; height: 10px; border-radius: 3px; flex: 0 0 10px; }

/* ─── Main area ─── */
.main {
  overflow-y: auto;
  padding: 20px 24px 60px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-width: 0;
}
.main-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
  flex-shrink: 0;
}
.main-title {
  font-family: var(--font-display);
  font-weight: var(--display-weight);
  font-size: 26px;
  letter-spacing: -0.02em;
  margin: 0;
  line-height: 1.1;
}
@media (min-width: 1500px) {
  .main-title { font-size: 32px; }
}
:root[data-aesthetic="editorial"] .main-title { font-style: italic; }
.main-sub {
  color: var(--ink-faint);
  font-size: 13px;
  margin-top: 6px;
}
.main-nav {
  display: flex;
  gap: 8px;
  align-items: center;
}
.btn {
  padding: 8px 14px;
  border-radius: 8px;
  border: 1px solid var(--rule);
  background: var(--bg-card);
  font-size: 13px;
  color: var(--ink);
  font-weight: 500;
}
.btn:hover { border-color: var(--rule-strong); }
.btn.icon { padding: 8px 10px; }
.btn.primary {
  background: var(--ink);
  color: var(--bg);
  border-color: var(--ink);
}

/* Two-month grid */
.two-month {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  min-height: 0;
}
@media (max-width: 820px) {
  .two-month { grid-template-columns: 1fr; }
}

.month-block {
  background: var(--bg-card);
  border: 1px solid var(--rule);
  border-radius: 10px;
  padding: 12px 14px 8px;
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.month-header { padding: 2px 2px 8px; }
.month-title {
  margin: 0;
  font-family: var(--font-display);
  font-weight: var(--display-weight);
  font-size: 18px;
  letter-spacing: -0.01em;
  display: flex;
  gap: 8px;
  align-items: baseline;
}
.month-year { font-size: 12px; color: var(--ink-faint); font-style: normal; font-family: var(--font-ui); font-weight: 400; }

.dow-row {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  font-size: 9px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-faint);
  padding: 0 0 6px;
  border-bottom: 1px solid var(--rule);
}
.dow-cell { padding: 4px 5px; }

.month-grid {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}
.week-row {
  position: relative;
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  flex: 1;
  min-height: 92px;
  border-bottom: 1px solid var(--rule);
}
.week-row:last-child { border-bottom: none; }

.day-cell {
  padding: 3px 4px 2px;
  border-right: 1px solid var(--rule);
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
  min-height: 0;
  text-align: left;
  background: transparent;
  position: relative;
  transition: background 120ms;
  overflow: hidden;
}
.day-cell:hover { background: var(--bg-soft); }
.day-cell:nth-child(7) { border-right: none; }
.day-cell.out { opacity: 0.35; }
.day-cell.out .day-num { color: var(--ink-faint); }
.day-cell.today { background: var(--today-bg); }
.day-cell.sel { box-shadow: inset 0 0 0 2px var(--ink); }

/* Event overlay sits on top of day cells, lane-aligned across the week. */
.week-overlay {
  position: absolute;
  left: 0; right: 0;
  top: 22px;          /* below day-num-row */
  bottom: 4px;
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  grid-auto-rows: 18px;
  gap: 2px 1px;
  pointer-events: none;
  padding: 0 1px;
}
.banner {
  pointer-events: auto;
  align-self: start;
  height: 18px;
  font-size: 10.5px;
  font-weight: 500;
  padding: 1px 6px;
  border-left: 2px solid;
  border-radius: 3px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: flex;
  align-items: center;
  gap: 4px;
  line-height: 1.3;
  font-family: var(--font-ui);
  text-align: left;
}
.banner-band { /* multi-day or all-day filled bar */ }
.banner-chip {
  background: transparent !important;
  border-left: none;
  padding-left: 4px;
}
.banner-dot { width: 6px; height: 6px; border-radius: 50%; flex-shrink: 0; }
.banner-time {
  font-feature-settings: "tnum";
  font-variant-numeric: tabular-nums;
  color: var(--ink-faint);
  font-size: 9.5px;
  flex-shrink: 0;
}
.banner-title { overflow: hidden; text-overflow: ellipsis; min-width: 0; flex: 1; }
.banner.continues-left { border-top-left-radius: 0; border-bottom-left-radius: 0; border-left: none; padding-left: 4px; }
.banner.continues-right { border-top-right-radius: 0; border-bottom-right-radius: 0; }
.banner-more {
  pointer-events: auto;
  align-self: start;
  font-size: 10px;
  color: var(--ink-faint);
  padding: 1px 4px;
  background: transparent;
  border: none;
  text-align: left;
  font-family: var(--font-ui);
}
.banner-more:hover { color: var(--ink); }

.day-num-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 4px;
}
.day-num {
  font-size: 12px;
  font-weight: 500;
  color: var(--ink);
  font-feature-settings: "tnum";
  line-height: 1.2;
}
.today-pip {
  font-size: 9px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent);
  font-weight: 600;
}

.ribbons { display: flex; flex-direction: column; gap: 2px; }
.ribbon {
  font-size: 10px;
  font-weight: 500;
  padding: 1px 5px;
  border-left: 2px solid;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  border-radius: 0 3px 3px 0;
  line-height: 1.4;
}
.ribbon-text { display: block; overflow: hidden; text-overflow: ellipsis; }
.ribbon-more {
  font-size: 10px;
  color: var(--ink-faint);
  padding: 0 4px;
}

.timed-list { display: flex; flex-direction: column; gap: 2px; margin-top: 2px; }
.timed-item {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 10px;
  color: var(--ink-soft);
  white-space: nowrap;
  overflow: hidden;
  line-height: 1.3;
  min-width: 0;
}
.timed-time { display: none; }
@media (min-width: 1500px) {
  .timed-time { display: inline; }
}
.timed-dot { width: 6px; height: 6px; border-radius: 50%; }
.timed-time { font-feature-settings: "tnum"; font-variant-numeric: tabular-nums; color: var(--ink-faint); font-size: 9px; flex-shrink: 0; }
.timed-title { overflow: hidden; text-overflow: ellipsis; color: var(--ink); min-width: 0; flex: 1; }
.timed-more { font-size: 10px; color: var(--ink-faint); padding-left: 11px; }

/* ─── Right drawer ─── */
.drawer {
  border-left: 1px solid var(--rule);
  overflow-y: auto;
  padding: 20px 18px 60px;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  gap: 18px;
}
.drawer-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--rule);
}
.drawer-dow {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--ink-faint);
  margin-bottom: 4px;
}
.drawer-date {
  display: flex;
  align-items: baseline;
  gap: 8px;
  font-family: var(--font-display);
  font-weight: var(--display-weight);
}
:root[data-aesthetic="editorial"] .drawer-date { font-style: italic; }
.drawer-day { font-size: 36px; line-height: 1; letter-spacing: -0.02em; }
.drawer-month { font-size: 18px; color: var(--ink-soft); font-style: normal; font-family: var(--font-ui); font-weight: 400; }
.drawer-nav { display: flex; gap: 4px; }
.drawer-nav button {
  width: 32px; height: 32px;
  border-radius: 999px;
  display: grid; place-items: center;
  border: 1px solid var(--rule);
  font-size: 16px;
  color: var(--ink-soft);
}
.drawer-nav button:hover { border-color: var(--rule-strong); color: var(--ink); }

.drawer-section-title {
  margin: 0 0 10px;
  font-size: 10px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink-faint);
  font-weight: 600;
}
.drawer-allday { display: flex; flex-direction: column; gap: 6px; }
.drawer-allday-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 500;
}
.drawer-allday-item .dot { width: 6px; height: 6px; border-radius: 50%; flex: 0 0 6px; }
.drawer-allday-item .t { flex: 1; }
.drawer-allday-item .range { font-size: 11px; opacity: 0.7; font-weight: 400; }

.drawer-empty {
  font-size: 13px;
  color: var(--ink-faint);
  font-style: italic;
  padding: 20px 0;
}

.drawer-timed { display: flex; flex-direction: column; gap: 14px; }
.drawer-timed-item {
  display: grid;
  grid-template-columns: 50px 3px 1fr;
  gap: 14px;
  align-items: stretch;
}
.dt-times {
  font-feature-settings: "tnum";
  font-variant-numeric: tabular-nums;
}
.dt-start { font-size: 13px; color: var(--ink); font-weight: 500; }
.dt-end { font-size: 11px; color: var(--ink-faint); margin-top: 2px; }
.dt-bar { width: 3px; border-radius: 2px; align-self: stretch; }
.dt-title { font-size: 14px; color: var(--ink); font-weight: 500; }
.dt-cat { font-size: 11px; text-transform: uppercase; letter-spacing: 0.1em; margin-top: 3px; }

.drawer-habits {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}
.habit-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  border: 1px solid var(--rule);
  border-radius: 6px;
  font-size: 12px;
  color: var(--ink-soft);
  background: var(--bg-card);
  font-family: var(--font-ui);
  transition: border-color .12s, color .12s;
}
.habit-pill:hover { border-color: var(--rule-strong); color: var(--ink); }
.habit-pill.done { color: var(--ink); border-color: var(--rule-strong); }
.habit-mark {
  width: 12px; height: 12px;
  border: 1.5px solid;
  border-radius: 3px;
  flex: 0 0 12px;
}

/* ─── Mini month ─── */
.mini-month { padding: 4px 0; }
.mini-month-title {
  font-size: 12px;
  font-weight: 600;
  margin-bottom: 8px;
  font-family: var(--font-display);
  font-weight: var(--display-weight);
  letter-spacing: -0.01em;
}
:root[data-aesthetic="editorial"] .mini-month-title { font-style: italic; }
.mini-month-dows, .mini-month-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
}
.mini-dow {
  font-size: 9px;
  color: var(--ink-faint);
  text-align: center;
  padding: 4px 0;
}
.mini-cell {
  position: relative;
  height: 26px;
  font-size: 11px;
  color: var(--ink);
  display: grid;
  place-items: center;
  border-radius: 4px;
  font-feature-settings: "tnum";
}
.mini-cell:hover { background: var(--bg-soft); }
.mini-cell.out { color: var(--ink-faint); opacity: 0.4; }
.mini-cell.today {
  background: var(--ink);
  color: var(--bg);
  font-weight: 600;
}
.mini-cell.sel { box-shadow: inset 0 0 0 1px var(--ink); }
.mini-dot {
  position: absolute;
  bottom: 2px;
  width: 3px; height: 3px;
  background: var(--accent);
  border-radius: 50%;
}
.mini-cell.today .mini-dot { background: var(--bg); }

/* ─── Toast ─── */
.toast {
  position: fixed;
  bottom: 16px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border-radius: 10px;
  background: var(--bg-card);
  color: var(--ink);
  border: 1px solid var(--rule);
  box-shadow: var(--shadow);
  font-size: 13px;
  z-index: 2000;
  max-width: calc(100vw - 32px);
}
.toast.error { border-color: oklch(0.65 0.18 25); }
.toast-msg { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.toast-action {
  border: 1px solid var(--rule-strong);
  border-radius: 6px;
  padding: 4px 10px;
  font-size: 12px;
  font-weight: 500;
  background: var(--bg);
  color: var(--ink);
}
.toast-action:hover { background: var(--bg-soft); }
.toast-x {
  width: 22px; height: 22px;
  border-radius: 4px;
  color: var(--ink-faint);
  font-size: 16px;
  display: grid; place-items: center;
}
.toast-x:hover { background: var(--bg-soft); color: var(--ink); }
.toast-spin {
  width: 12px; height: 12px;
  border: 2px solid var(--rule-strong);
  border-top-color: var(--ink);
  border-radius: 50%;
  animation: toast-spin .9s linear infinite;
  flex-shrink: 0;
}
@keyframes toast-spin { to { transform: rotate(360deg); } }
.import-btn { font-size: 14px; }

/* ─── Search bar ─── */
.search { position: relative; flex-shrink: 0; }
.search-row {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-card);
  border: 1px solid var(--rule);
  border-radius: 10px;
  padding: 9px 12px;
}
.search-row:focus-within { border-color: var(--rule-strong); }
.search-icon { color: var(--ink-faint); font-size: 14px; line-height: 1; }
.search-input {
  flex: 1;
  border: none;
  background: transparent;
  color: var(--ink);
  font: inherit;
  font-size: 14px;
  outline: none;
  font-family: var(--font-ui);
  min-width: 0;
}
.search-input::placeholder { color: var(--ink-faint); }
.search-kbd {
  font-family: var(--font-mono);
  font-size: 10px;
  padding: 2px 6px;
  background: var(--bg-soft);
  border: 1px solid var(--rule);
  border-radius: 4px;
  color: var(--ink-faint);
}
.search-results {
  position: absolute;
  top: calc(100% + 4px);
  left: 0; right: 0;
  background: var(--bg-card);
  border: 1px solid var(--rule);
  border-radius: 10px;
  box-shadow: var(--shadow);
  z-index: 40;
  max-height: 320px;
  overflow-y: auto;
  padding: 4px;
}
.search-empty {
  padding: 12px 14px;
  color: var(--ink-faint);
  font-size: 13px;
  font-style: italic;
}
.search-item {
  display: grid;
  grid-template-columns: 8px 1fr auto;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 6px;
  font-size: 13px;
  cursor: pointer;
}
.search-item.active { background: var(--bg-soft); }
.search-dot { width: 8px; height: 8px; border-radius: 50%; }
.search-title { color: var(--ink); font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.search-meta { color: var(--ink-faint); font-size: 11px; font-feature-settings: "tnum"; white-space: nowrap; }
.search-mobile .search-row { padding: 11px 14px; }
.search-mobile .search-input { font-size: 15px; }

/* ─── Quick capture ─── */
.quick-capture {
  background: var(--bg-card);
  border: 1px solid var(--rule);
  border-radius: 10px;
  padding: 12px 14px;
}
.qc-row {
  display: flex;
  align-items: center;
  gap: 8px;
}
.qc-prefix { color: var(--ink-faint); font-size: 16px; }
.qc-input {
  flex: 1;
  border: none;
  background: transparent;
  color: var(--ink);
  font-size: 14px;
  outline: none;
  font-family: var(--font-ui);
}
.qc-input::placeholder { color: var(--ink-faint); }
.qc-kbd {
  font-family: var(--font-mono);
  font-size: 10px;
  padding: 2px 6px;
  background: var(--bg-soft);
  border: 1px solid var(--rule);
  border-radius: 4px;
  color: var(--ink-faint);
}
.qc-preview {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px dashed var(--rule);
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
}
.qc-preview-dot { width: 8px; height: 8px; border-radius: 50%; }
.qc-preview-title { color: var(--ink); font-weight: 500; }
.qc-preview-meta { color: var(--ink-faint); }

/* ─── Habit strip (desktop main) ─── */
.habit-strip {
  background: var(--bg-card);
  border: 1px solid var(--rule);
  border-radius: 10px;
  padding: 10px 14px;
  display: flex;
  align-items: center;
  gap: 18px;
  overflow-x: auto;
  flex-shrink: 0;
}
.habit-strip-label {
  font-size: 9px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink-faint);
  flex-shrink: 0;
}
.habit-track {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}
.habit-track-name {
  font-size: 11px;
  color: var(--ink-soft);
  width: auto;
  flex-shrink: 0;
  white-space: nowrap;
}
.habit-week {
  display: grid;
  grid-template-columns: repeat(7, 10px);
  gap: 3px;
}
.habit-dot-week {
  width: 10px; height: 10px;
  border-radius: 2px;
  border: 1px solid currentColor;
  background: transparent;
  padding: 0;
  cursor: pointer;
}
.habit-dot-week.done { background: currentColor; }
.habit-dot-week.empty { opacity: 0.25; }
.habit-dot-week:hover { opacity: 1; }

/* ─── Week view ─── */
.week-view {
  background: var(--bg-card);
  border: 1px solid var(--rule);
  border-radius: 12px;
  overflow: hidden;
}
.week-head {
  display: grid;
  grid-template-columns: 60px repeat(7, minmax(0, 1fr));
  border-bottom: 1px solid var(--rule);
  background: var(--bg-soft);
}
.week-head-cell {
  padding: 10px 8px;
  border-right: 1px solid var(--rule);
  text-align: center;
}
.week-head-cell:last-child { border-right: none; }
.week-head-cell.today { background: var(--today-bg); }
.week-head-dow {
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-faint);
}
.week-head-num {
  font-family: var(--font-display);
  font-weight: var(--display-weight);
  font-size: 22px;
  letter-spacing: -0.01em;
  margin-top: 2px;
}
:root[data-aesthetic="editorial"] .week-head-num { font-style: italic; }

.week-grid {
  display: grid;
  grid-template-columns: 60px repeat(7, minmax(0, 1fr));
  position: relative;
  height: 720px;
  overflow-y: auto;
}
.week-hours {
  border-right: 1px solid var(--rule);
}
.week-hour {
  height: 50px;
  padding: 4px 8px;
  font-size: 10px;
  color: var(--ink-faint);
  font-feature-settings: "tnum";
  border-bottom: 1px dashed var(--rule);
}
.week-col {
  border-right: 1px solid var(--rule);
  position: relative;
}
.week-col:last-child { border-right: none; }
.week-col-hour {
  height: 50px;
  border-bottom: 1px dashed var(--rule);
}
.week-evt {
  position: absolute;
  left: 4px; right: 4px;
  border-radius: 4px;
  padding: 4px 6px;
  font-size: 11px;
  border-left: 3px solid;
  overflow: hidden;
}
.week-evt-time {
  font-feature-settings: "tnum";
  font-size: 10px;
  opacity: 0.7;
}
.week-evt-title { font-weight: 500; line-height: 1.2; margin-top: 1px; }
.week-allday {
  display: grid;
  grid-template-columns: 60px repeat(7, minmax(0, 1fr));
  border-bottom: 1px solid var(--rule);
  background: var(--bg);
}
.week-allday-label {
  padding: 6px 8px;
  font-size: 9px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-faint);
  border-right: 1px solid var(--rule);
}
.week-allday-col {
  padding: 4px;
  border-right: 1px solid var(--rule);
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-height: 28px;
}
.week-allday-col:last-child { border-right: none; }
.week-allday-chip {
  font-size: 10.5px;
  padding: 2px 6px;
  border-radius: 3px;
  border-left: 2px solid;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ════════════════════════════════════════════════════════════════════ */
/* MOBILE                                                                */
/* ════════════════════════════════════════════════════════════════════ */

.app-mobile {
  display: none;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
  background: var(--bg);
}
.m-top {
  padding: 16px 20px 8px;
  border-bottom: 1px solid var(--rule);
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.m-top-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.m-month-title {
  font-family: var(--font-display);
  font-weight: var(--display-weight);
  font-size: 26px;
  letter-spacing: -0.02em;
}
:root[data-aesthetic="editorial"] .m-month-title { font-style: italic; }
.m-month-year {
  font-size: 13px;
  color: var(--ink-faint);
  margin-left: 6px;
  font-family: var(--font-ui);
  font-style: normal;
  font-weight: 400;
}
.m-nav-btns { display: flex; gap: 6px; }
.m-nav-btns button {
  width: 32px; height: 32px;
  border-radius: 999px;
  border: 1px solid var(--rule);
  display: grid; place-items: center;
  font-size: 14px;
  color: var(--ink-soft);
}

.m-view-tabs {
  display: flex;
  gap: 2px;
  padding: 3px;
  background: var(--bg-soft);
  border-radius: 8px;
  border: 1px solid var(--rule);
}
.m-view-tabs button {
  flex: 1;
  padding: 7px 10px;
  font-size: 12px;
  border-radius: 6px;
  color: var(--ink-soft);
  text-align: center;
  font-weight: 500;
}
.m-view-tabs button.active {
  background: var(--bg-card);
  color: var(--ink);
}

.m-body {
  flex: 1;
  overflow-y: auto;
  padding: 12px 16px 100px;
}

.m-month {}
.m-dow-row {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  font-size: 10px;
  text-align: center;
  color: var(--ink-faint);
  letter-spacing: 0.1em;
  padding: 8px 0;
}
.m-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  grid-auto-rows: 64px;
  gap: 1px;
  background: var(--rule);
  border: 1px solid var(--rule);
  border-radius: 8px;
  overflow: hidden;
}
.m-cell {
  background: var(--bg-card);
  padding: 4px 4px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  text-align: left;
  min-height: 0;
}
.m-cell.out { opacity: 0.35; }
.m-cell.today { background: var(--today-bg); }
.m-cell.sel { box-shadow: inset 0 0 0 2px var(--ink); }
.m-num {
  font-size: 12px;
  font-weight: 500;
  font-feature-settings: "tnum";
}
.m-ribbon {
  font-size: 9px;
  padding: 1px 4px;
  border-radius: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-weight: 500;
  min-height: 12px;
}
.m-ribbon.tail { padding: 1px 0; border-radius: 0; }
.m-dots {
  display: flex;
  gap: 3px;
  margin-top: auto;
  padding-bottom: 2px;
}
.m-d { width: 5px; height: 5px; border-radius: 50%; }

.m-week { display: flex; flex-direction: column; }
.m-week-day {
  display: grid;
  grid-template-columns: 56px 1fr;
  gap: 12px;
  padding: 14px 0;
  border-bottom: 1px solid var(--rule);
  cursor: pointer;
}
.m-week-day:last-child { border-bottom: none; }
.m-week-day.today .m-week-num { color: var(--accent); }
.m-week-date { text-align: right; }
.m-week-dow {
  font-size: 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-faint);
}
.m-week-num {
  font-family: var(--font-display);
  font-weight: var(--display-weight);
  font-size: 28px;
  line-height: 1;
  margin-top: 2px;
  letter-spacing: -0.02em;
}
:root[data-aesthetic="editorial"] .m-week-num { font-style: italic; }
.m-week-evts { display: flex; flex-direction: column; gap: 4px; padding-top: 4px; }
.m-week-empty { font-size: 12px; color: var(--ink-faint); font-style: italic; }
.m-week-evt {
  border-left: 3px solid;
  padding: 4px 8px;
  font-size: 12px;
}
.m-week-time {
  font-feature-settings: "tnum";
  font-size: 10px;
  color: var(--ink-faint);
}
.m-week-title { font-weight: 500; }

/* Mobile day sheet (modal) */
.m-sheet-backdrop {
  position: fixed;
  inset: 0;
  background: oklch(0.2 0 0 / 0.4);
  z-index: 50;
  display: flex;
  align-items: flex-end;
}
.m-sheet {
  background: var(--bg);
  border-top-left-radius: 16px;
  border-top-right-radius: 16px;
  width: 100%;
  max-height: 85vh;
  overflow-y: auto;
  padding: 8px 20px 32px;
  animation: slideUp 240ms cubic-bezier(0.2, 0.8, 0.2, 1);
}
@keyframes slideUp {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}
.m-sheet-handle {
  width: 36px; height: 4px;
  background: var(--rule-strong);
  border-radius: 2px;
  margin: 8px auto 16px;
}
.m-sheet-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--rule);
}
.m-sheet-dow {
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-faint);
}
.m-sheet-date {
  display: flex;
  gap: 8px;
  align-items: baseline;
  font-family: var(--font-display);
  font-weight: var(--display-weight);
}
:root[data-aesthetic="editorial"] .m-sheet-date { font-style: italic; }
.m-sheet-day { font-size: 36px; line-height: 1; letter-spacing: -0.02em; }
.m-sheet-month { font-size: 16px; color: var(--ink-soft); font-style: normal; font-family: var(--font-ui); font-weight: 400; }

.m-sheet-habits {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  padding: 14px 0;
  border-bottom: 1px solid var(--rule);
}
.m-habit {
  display: flex; align-items: center; gap: 6px;
  padding: 6px 10px;
  border: 1px solid var(--rule);
  border-radius: 999px;
  font-size: 11px;
  color: var(--ink-soft);
  background: var(--bg-card);
  font-family: var(--font-ui);
}
.m-habit.done { color: var(--ink); border-color: var(--rule-strong); }
.m-habit-mark {
  width: 10px; height: 10px;
  border-radius: 3px;
  border: 1.5px solid;
}

.m-sheet-body { padding-top: 14px; display: flex; flex-direction: column; gap: 14px; }
.m-sheet-empty { font-style: italic; color: var(--ink-faint); padding: 24px 0; text-align: center; }
.m-sheet-evt {
  display: grid;
  grid-template-columns: 48px 3px 1fr;
  gap: 12px;
  align-items: stretch;
}
.m-sheet-time {
  font-size: 13px;
  font-feature-settings: "tnum";
  font-weight: 500;
}
.m-sheet-end { font-size: 11px; color: var(--ink-faint); font-weight: 400; margin-top: 2px; }
.m-sheet-bar { width: 3px; border-radius: 2px; }
.m-sheet-title { font-size: 14px; font-weight: 500; }
.m-sheet-cat { font-size: 11px; text-transform: uppercase; letter-spacing: 0.1em; margin-top: 2px; }

/* FAB */
.fab {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 56px; height: 56px;
  border-radius: 999px;
  background: var(--ink);
  color: var(--bg);
  display: grid; place-items: center;
  font-size: 24px;
  box-shadow: 0 8px 24px oklch(0.2 0 0 / 0.2);
  z-index: 30;
}

/* Responsive */
@media (max-width: 900px) {
  .app-desktop { display: none; }
  .app-mobile { display: flex; }
}

/* Toggle for forced view (used by tweaks) */
.app-desktop[data-force="mobile"] { display: none; }
.app-mobile[data-force="mobile"] { display: flex !important; }
.app-desktop[data-force="desktop"] { display: grid !important; }
.app-mobile[data-force="desktop"] { display: none !important; }

/* Mobile preview frame for desktop showcase */
.mobile-preview-wrap {
  position: relative;
  width: 390px;
  height: 780px;
  border: 1px solid var(--rule-strong);
  border-radius: 32px;
  overflow: hidden;
  background: var(--bg);
  box-shadow: var(--shadow);
}
.mobile-preview-wrap > .app-mobile {
  display: flex !important;
  height: 100%;
}


/* ════════════════════════════════════════════════════════════════════
   DARK MODE — auto via prefers-color-scheme + manual override via [data-theme]
   Cards/categories rely on the same --cat-soft mix; we re-derive them
   from --is-dark so soft fills become deep transparent tints, not white blocks.
   ════════════════════════════════════════════════════════════════════ */

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"])[data-aesthetic="editorial"] {
    --bg: oklch(0.16 0.008 80);
    --bg-soft: oklch(0.20 0.010 80);
    --bg-card: oklch(0.22 0.012 80);
    --ink: oklch(0.94 0.005 80);
    --ink-soft: oklch(0.72 0.005 80);
    --ink-faint: oklch(0.52 0.005 80);
    --rule: oklch(0.30 0.008 80);
    --rule-strong: oklch(0.40 0.010 80);
    --today-bg: oklch(0.30 0.08 145);
    --shadow: 0 1px 2px oklch(0 0 0 / 0.5), 0 8px 24px oklch(0 0 0 / 0.6);
    --is-dark: 1;
  }
  :root:not([data-theme="light"])[data-aesthetic="minimal"] {
    --bg: oklch(0.15 0.005 240);
    --bg-soft: oklch(0.19 0.006 240);
    --bg-card: oklch(0.22 0.008 240);
    --ink: oklch(0.94 0.003 240);
    --ink-soft: oklch(0.72 0.003 240);
    --ink-faint: oklch(0.52 0.003 240);
    --rule: oklch(0.30 0.005 240);
    --rule-strong: oklch(0.42 0.006 240);
    --today-bg: oklch(0.30 0.08 145);
    --shadow: 0 1px 2px oklch(0 0 0 / 0.5), 0 8px 24px oklch(0 0 0 / 0.6);
    --is-dark: 1;
  }
  :root:not([data-theme="light"])[data-aesthetic="mono"] {
    --bg: oklch(0.14 0.012 80);
    --bg-soft: oklch(0.18 0.015 80);
    --bg-card: oklch(0.20 0.015 80);
    --ink: oklch(0.94 0.008 80);
    --ink-soft: oklch(0.70 0.008 80);
    --ink-faint: oklch(0.52 0.008 80);
    --rule: oklch(0.32 0.012 80);
    --rule-strong: oklch(0.45 0.015 80);
    --today-bg: oklch(0.30 0.08 145);
    --shadow: none;
    --is-dark: 1;
  }
}

/* Manual dark mode (overrides prefers) */
:root[data-theme="dark"][data-aesthetic="editorial"] {
  --bg: oklch(0.16 0.008 80);
  --bg-soft: oklch(0.20 0.010 80);
  --bg-card: oklch(0.22 0.012 80);
  --ink: oklch(0.94 0.005 80);
  --ink-soft: oklch(0.72 0.005 80);
  --ink-faint: oklch(0.52 0.005 80);
  --rule: oklch(0.30 0.008 80);
  --rule-strong: oklch(0.40 0.010 80);
  --today-bg: oklch(0.30 0.08 145);
  --shadow: 0 1px 2px oklch(0 0 0 / 0.5), 0 8px 24px oklch(0 0 0 / 0.6);
  --is-dark: 1;
}
:root[data-theme="dark"][data-aesthetic="minimal"] {
  --bg: oklch(0.15 0.005 240);
  --bg-soft: oklch(0.19 0.006 240);
  --bg-card: oklch(0.22 0.008 240);
  --ink: oklch(0.94 0.003 240);
  --ink-soft: oklch(0.72 0.003 240);
  --ink-faint: oklch(0.52 0.003 240);
  --rule: oklch(0.30 0.005 240);
  --rule-strong: oklch(0.42 0.006 240);
  --today-bg: oklch(0.30 0.08 145);
  --shadow: 0 1px 2px oklch(0 0 0 / 0.5), 0 8px 24px oklch(0 0 0 / 0.6);
  --is-dark: 1;
}
:root[data-theme="dark"][data-aesthetic="mono"] {
  --bg: oklch(0.14 0.012 80);
  --bg-soft: oklch(0.18 0.015 80);
  --bg-card: oklch(0.20 0.015 80);
  --ink: oklch(0.94 0.008 80);
  --ink-soft: oklch(0.70 0.008 80);
  --ink-faint: oklch(0.52 0.008 80);
  --rule: oklch(0.32 0.012 80);
  --rule-strong: oklch(0.45 0.015 80);
  --today-bg: oklch(0.30 0.08 145);
  --shadow: none;
  --is-dark: 1;
}

/* In dark mode, tone down the brand-bright category soft fills so events
   don't look like neon stickers stuck on dark cards.
   We re-render category chips/pills with a translucent ink-on-dot mix. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .month-evt,
  :root:not([data-theme="light"]) .week-evt,
  :root:not([data-theme="light"]) .week-allday-chip,
  :root:not([data-theme="light"]) .drawer-allday-item,
  :root:not([data-theme="light"]) .m-multi-bar,
  :root:not([data-theme="light"]) .qc-preview {
    background: color-mix(in oklch, var(--bg-card) 60%, transparent) !important;
    color: var(--ink) !important;
    border-color: color-mix(in oklch, currentColor 30%, transparent);
  }
}
:root[data-theme="dark"] .month-evt,
:root[data-theme="dark"] .week-evt,
:root[data-theme="dark"] .week-allday-chip,
:root[data-theme="dark"] .drawer-allday-item,
:root[data-theme="dark"] .m-multi-bar,
:root[data-theme="dark"] .qc-preview {
  background: color-mix(in oklch, var(--bg-card) 60%, transparent) !important;
  color: var(--ink) !important;
}

/* For .m-evt and category pills, respect dot color but lighten ink */
:root[data-theme="dark"] .m-sheet,
:root[data-theme="dark"] .ev-modal {
  background: var(--bg-card);
  color: var(--ink);
}

/* ════════════════════════════════════════════════════════════════════
   "+ Add event" buttons in drawer / mobile sheet
   ════════════════════════════════════════════════════════════════════ */
.drawer-add,
.m-sheet-add {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  width: 100%;
  padding: 10px 12px;
  margin: 12px 0 4px;
  border: 1px dashed var(--rule-strong);
  border-radius: 10px;
  font-size: 13px;
  color: var(--ink-soft);
  background: transparent;
  transition: all .12s ease;
  font-family: var(--font-ui);
}
.drawer-add:hover,
.m-sheet-add:hover {
  background: var(--bg-soft);
  border-style: solid;
  color: var(--ink);
}

.btn.primary {
  background: var(--ink);
  color: var(--bg);
  padding: 6px 12px;
  border-radius: 8px;
  font-weight: 500;
  font-size: 13px;
}
.btn.primary:hover { opacity: 0.9; }

/* ════════════════════════════════════════════════════════════════════
   EVENT EDITOR MODAL
   ════════════════════════════════════════════════════════════════════ */
.ev-backdrop {
  position: fixed; inset: 0;
  background: oklch(0 0 0 / 0.45);
  display: flex; align-items: center; justify-content: center;
  z-index: 1000;
  padding: 16px;
  animation: ev-fade .15s ease;
}
@keyframes ev-fade { from { opacity: 0; } to { opacity: 1; } }

.ev-modal {
  background: var(--bg-card);
  color: var(--ink);
  border: 1px solid var(--rule);
  border-radius: 14px;
  box-shadow: var(--shadow);
  width: 100%;
  max-width: 600px;
  max-height: calc(100vh - 32px);
  display: flex; flex-direction: column;
  overflow: hidden;
  animation: ev-pop .18s cubic-bezier(.2,.8,.2,1);
}
@keyframes ev-pop { from { transform: translateY(8px) scale(.98); opacity: 0; } to { transform: none; opacity: 1; } }

.ev-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px 12px;
  border-bottom: 1px solid var(--rule);
}
.ev-title {
  font-family: var(--font-display);
  font-weight: var(--display-weight);
  font-size: 20px;
  margin: 0;
}
:root[data-aesthetic="editorial"] .ev-title { font-style: italic; }
.ev-x {
  font-size: 22px;
  color: var(--ink-soft);
  width: 32px; height: 32px;
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
}
.ev-x:hover { background: var(--bg-soft); color: var(--ink); }

.ev-body {
  padding: 18px 22px;
  overflow-y: auto;
  display: flex; flex-direction: column;
  gap: 16px;
}

/* Field — vertical label + input stack */
.ev-field {
  display: flex; flex-direction: column;
  gap: 6px;
  min-width: 0;
}
.ev-flabel {
  font-size: 13px;
  font-weight: 500;
  color: var(--ink-soft);
  font-family: var(--font-ui);
  letter-spacing: 0;
}

/* Grid layouts */
.ev-grid {
  display: grid;
  gap: 12px;
  min-width: 0;
}
.ev-grid-2 { grid-template-columns: 1fr 1fr; }
.ev-grid-4 { grid-template-columns: repeat(4, 1fr); }

/* Universal text input look — flat, square corners, blue focus */
.ev-text {
  font: inherit;
  font-size: 14px;
  padding: 9px 11px;
  border: 1px solid var(--rule);
  border-radius: 6px;
  background: var(--bg-card);
  color: var(--ink);
  width: 100%;
  min-width: 0;
  outline: none;
  font-family: var(--font-ui);
  transition: border-color .12s, box-shadow .12s;
}
.ev-text:focus {
  border-color: oklch(0.62 0.17 240);
  box-shadow: 0 0 0 1px oklch(0.62 0.17 240);
}
.ev-text-error {
  border-color: oklch(0.6 0.18 25);
}
.ev-text-error:focus {
  border-color: oklch(0.6 0.18 25);
  box-shadow: 0 0 0 1px oklch(0.6 0.18 25);
}
.ev-text-lg { font-size: 15px; padding: 10px 12px; }
.ev-textarea { resize: vertical; min-height: 72px; padding: 9px 11px; }
.ev-text::placeholder, .ev-textarea::placeholder { color: var(--ink-faint); }

/* Date/time native pickers — keep clickable native indicators visible */
.ev-text[type="date"],
.ev-text[type="time"] {
  font-variant-numeric: tabular-nums;
}
.ev-text:disabled { opacity: 0.45; cursor: not-allowed; }

/* Select wrapping with category dot */
.ev-select-wrap { position: relative; }
.ev-select-wrap select.ev-text { padding-left: 28px; appearance: none; -webkit-appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--ink-faint) 50%), linear-gradient(135deg, var(--ink-faint) 50%, transparent 50%); background-position: calc(100% - 14px) 50%, calc(100% - 9px) 50%; background-size: 5px 5px; background-repeat: no-repeat; padding-right: 28px; }
.ev-cat-dot-fixed {
  position: absolute;
  left: 11px; top: 50%;
  transform: translateY(-50%);
  width: 9px; height: 9px;
  border-radius: 50%;
  pointer-events: none;
}

/* All-day square checkbox */
.ev-field-inline {
  display: flex; align-items: center;
  margin: 0;
}
.ev-checkbox {
  display: inline-flex; align-items: center; gap: 9px;
  cursor: pointer;
  font-size: 14px;
  color: var(--ink);
  font-family: var(--font-ui);
  user-select: none;
}
.ev-checkbox input { position: absolute; opacity: 0; pointer-events: none; }
.ev-cbox-square {
  width: 16px; height: 16px;
  border: 1.5px solid var(--ink-soft);
  border-radius: 3px;
  background: var(--bg-card);
  position: relative;
  transition: all .12s;
  flex-shrink: 0;
}
.ev-checkbox:hover .ev-cbox-square { border-color: var(--ink); }
.ev-checkbox input:checked + .ev-cbox-square {
  background: oklch(0.62 0.17 240);
  border-color: oklch(0.62 0.17 240);
}
.ev-checkbox input:checked + .ev-cbox-square::after {
  content: "";
  position: absolute;
  left: 4px; top: 1px;
  width: 4px; height: 8px;
  border: solid white;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}
.ev-checkbox input:focus-visible + .ev-cbox-square {
  box-shadow: 0 0 0 2px oklch(0.62 0.17 240 / 0.3);
}

.ev-foot {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 22px;
  border-top: 1px solid var(--rule);
  background: var(--bg-soft);
  gap: 8px;
}
.ev-foot-right { display: flex; gap: 10px; margin-left: auto; }
.ev-btn {
  padding: 8px 18px;
  border: 1px solid var(--rule);
  border-radius: 6px;
  font-size: 13px;
  background: var(--bg-card);
  color: var(--ink);
  font-family: var(--font-ui);
  font-weight: 500;
  transition: all .12s;
}
.ev-btn:hover { border-color: var(--ink-soft); background: var(--bg); }
.ev-btn.ev-primary {
  background: oklch(0.62 0.17 240);
  color: white;
  border-color: oklch(0.62 0.17 240);
}
.ev-btn.ev-primary:hover { background: oklch(0.55 0.17 240); border-color: oklch(0.55 0.17 240); }
.ev-btn.ev-danger {
  color: oklch(0.55 0.18 25);
  border-color: oklch(0.85 0.06 25);
}
.ev-btn.ev-danger:hover {
  background: oklch(0.95 0.04 25);
  border-color: oklch(0.55 0.18 25);
}
:root[data-theme="dark"] .ev-btn.ev-danger {
  color: oklch(0.72 0.16 25);
  border-color: oklch(0.40 0.10 25);
}
:root[data-theme="dark"] .ev-btn.ev-danger:hover {
  background: oklch(0.30 0.08 25);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .ev-btn.ev-danger {
    color: oklch(0.72 0.16 25);
    border-color: oklch(0.40 0.10 25);
  }
  :root:not([data-theme="light"]) .ev-btn.ev-danger:hover {
    background: oklch(0.30 0.08 25);
  }
}

/* ════════════════════════════════════════════════════════════════════
   MOBILE TUNING for the editor + sheet
   ════════════════════════════════════════════════════════════════════ */
@media (max-width: 720px) {
  .ev-backdrop {
    padding: 0;
    align-items: flex-end;
  }
  .ev-modal {
    max-width: 100%;
    max-height: 92vh;
    border-radius: 18px 18px 0 0;
    animation: ev-slide-up .22s cubic-bezier(.2,.8,.2,1);
  }
  @keyframes ev-slide-up { from { transform: translateY(100%); } to { transform: none; } }

  .ev-head { padding: 14px 18px 10px; padding-top: max(14px, env(safe-area-inset-top, 14px)); }
  .ev-body { padding: 14px 18px; gap: 16px; }
  .ev-foot {
    padding: 12px 18px;
    padding-bottom: max(12px, env(safe-area-inset-bottom, 12px));
    flex-wrap: wrap;
  }

  .ev-row {
    grid-template-columns: 1fr;
    gap: 6px;
  }
  .ev-label {
    font-size: 11px;
  }

  .ev-text {
    font-size: 16px;  /* iOS won't auto-zoom on focus when ≥16px */
    padding: 12px 12px;
  }
  .ev-text-lg { font-size: 17px; padding: 13px 12px; }
  .ev-textarea { font-size: 16px; }

  /* Stack 4-col into 2x2 on mobile, 2-col stays as-is */
  .ev-grid-4 { grid-template-columns: 1fr 1fr; }

  .ev-btn {
    padding: 12px 16px;
    font-size: 14px;
    min-height: 44px;
    flex: 1;
  }
  .ev-btn.ev-danger { flex: 0 0 auto; }

  .ev-cbox-square { width: 20px; height: 20px; }
  .ev-checkbox input:checked + .ev-cbox-square::after {
    left: 5px; top: 1px; width: 6px; height: 11px; border-width: 0 2.5px 2.5px 0;
  }

  .m-sheet-add {
    padding: 14px;
    font-size: 14px;
    min-height: 48px;
  }
}

/* Fix: ensure sheet/modal allows scrolling on small phones */
.m-sheet { max-height: 88vh; overflow-y: auto; }

/* Better hit target on mobile day-sheet event cards */
@media (max-width: 720px) {
  .m-sheet-evt {
    padding: 10px 4px;
    min-height: 56px;
  }
  .m-sheet-evt:active {
    background: var(--bg-soft);
    border-radius: 8px;
  }
}
