/* ==========================================================================
   Task Notes — stylesheet
   Sections: tokens · reset · layout · sidebar · topbar · cards · views ·
             editor · dialogs · alarm · toasts · responsive
   ========================================================================== */

/* ---------- tokens ---------- */

:root {
  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;

  --r-xs: 6px;
  --r-sm: 10px;
  --r-md: 14px;
  --r-lg: 20px;
  --r-xl: 28px;
  --r-full: 999px;

  --gap: 14px;
  --pad: 18px;

  --ease: cubic-bezier(.22, .68, .3, 1);
  --dur: .18s;

  --accent: #7c5cff;
  --accent-ink: #fff;
  --accent-soft: rgba(124, 92, 255, .14);
}

/* accent palettes */
[data-accent="violet"] { --accent: #7c5cff; --accent-soft: rgba(124,92,255,.14); }
[data-accent="blue"]   { --accent: #2f7bff; --accent-soft: rgba(47,123,255,.14); }
[data-accent="teal"]   { --accent: #0aa5a0; --accent-soft: rgba(10,165,160,.16); }
[data-accent="green"]  { --accent: #22a05a; --accent-soft: rgba(34,160,90,.16); }
[data-accent="amber"]  { --accent: #d98613; --accent-soft: rgba(217,134,19,.16); }
[data-accent="rose"]   { --accent: #e0507e; --accent-soft: rgba(224,80,126,.14); }
[data-accent="slate"]  { --accent: #5b6478; --accent-soft: rgba(91,100,120,.16); }

/* light */
:root, [data-theme="light"] {
  --bg: #f6f5f9;
  --bg-2: #eeecf4;
  --surface: #ffffff;
  --surface-2: #f7f6fa;
  --ink: #1b1b23;
  --ink-2: #5b5b6b;
  --ink-3: #8b8b9c;
  --line: #e4e2ec;
  --line-2: #d5d2e0;
  --shadow-1: 0 1px 2px rgba(24,20,50,.06), 0 2px 6px rgba(24,20,50,.05);
  --shadow-2: 0 4px 12px rgba(24,20,50,.10), 0 12px 30px rgba(24,20,50,.10);
  --shadow-3: 0 20px 60px rgba(24,20,50,.22);
  --danger: #d64545;
  --danger-soft: rgba(214,69,69,.12);
  --warn: #d98613;
  --warn-soft: rgba(217,134,19,.14);
  --ok: #22a05a;
}

/* dark */
[data-theme="dark"] {
  --bg: #101018;
  --bg-2: #16161f;
  --surface: #1c1c27;
  --surface-2: #232331;
  --ink: #edecf3;
  --ink-2: #a9a7ba;
  --ink-3: #77758a;
  --line: #2c2c3a;
  --line-2: #3a3a4c;
  --shadow-1: 0 1px 2px rgba(0,0,0,.4);
  --shadow-2: 0 6px 18px rgba(0,0,0,.45);
  --shadow-3: 0 24px 70px rgba(0,0,0,.6);
  --danger: #ff6b6b;
  --danger-soft: rgba(255,107,107,.16);
  --warn: #f0a53a;
  --warn-soft: rgba(240,165,58,.16);
  --ok: #45d18a;
}

/* note colours — a tinted surface per theme */
.color-default { --card: var(--surface);  --card-edge: var(--line); --card-ink: var(--ink); }
[data-theme="light"] .color-yellow { --card: #fff8d6; --card-edge: #f2e6a8; }
[data-theme="light"] .color-amber  { --card: #ffe9cf; --card-edge: #f3d3ab; }
[data-theme="light"] .color-rose   { --card: #ffe0e9; --card-edge: #f5c3d2; }
[data-theme="light"] .color-lilac  { --card: #ece2ff; --card-edge: #d6c6f7; }
[data-theme="light"] .color-sky    { --card: #d9edff; --card-edge: #b8daf7; }
[data-theme="light"] .color-mint   { --card: #d8f5e3; --card-edge: #b3e5c8; }
[data-theme="light"] .color-sand   { --card: #f2ece1; --card-edge: #ded4c2; }
[data-theme="light"] .color-slate  { --card: #e6e8ef; --card-edge: #cdd0dc; }

[data-theme="dark"] .color-yellow { --card: #3b3618; --card-edge: #554d22; }
[data-theme="dark"] .color-amber  { --card: #3d2f19; --card-edge: #574123; }
[data-theme="dark"] .color-rose   { --card: #3d1f2c; --card-edge: #572c3e; }
[data-theme="dark"] .color-lilac  { --card: #2b2350; --card-edge: #3d3270; }
[data-theme="dark"] .color-sky    { --card: #16324a; --card-edge: #204767; }
[data-theme="dark"] .color-mint   { --card: #15382a; --card-edge: #1f503c; }
[data-theme="dark"] .color-sand   { --card: #322d25; --card-edge: #4a4237; }
[data-theme="dark"] .color-slate  { --card: #23262f; --card-edge: #343947; }

/* swatch fills used in pickers */
.swatch.color-default { background: linear-gradient(135deg, var(--surface) 50%, var(--line) 50%); }
.swatch.color-yellow { background: #ffe97a; }
.swatch.color-amber  { background: #ffc46b; }
.swatch.color-rose   { background: #ff9dbb; }
.swatch.color-lilac  { background: #b79dff; }
.swatch.color-sky    { background: #7cc4ff; }
.swatch.color-mint   { background: #77dda4; }
.swatch.color-sand   { background: #d9c9a8; }
.swatch.color-slate  { background: #9aa2b8; }
.swatch.accent-violet { background: #7c5cff; }
.swatch.accent-blue   { background: #2f7bff; }
.swatch.accent-teal   { background: #0aa5a0; }
.swatch.accent-green  { background: #22a05a; }
.swatch.accent-amber  { background: #d98613; }
.swatch.accent-rose   { background: #e0507e; }
.swatch.accent-slate  { background: #5b6478; }

[data-density="compact"] { --gap: 9px; --pad: 12px; }

/* ---------- reset ---------- */

*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.55;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
}
h1, h2, h3, h4, p, ul, ol, figure, blockquote { margin: 0; }
ul, ol { padding-left: 1.2em; }
button, input, select, textarea { font: inherit; color: inherit; }
button { background: none; border: 0; cursor: pointer; color: inherit; }
a { color: var(--accent); }
kbd {
  font: 600 11px/1 var(--mono);
  padding: 3px 6px;
  border-radius: var(--r-xs);
  background: var(--surface-2);
  border: 1px solid var(--line);
  color: var(--ink-2);
}
::selection { background: var(--accent-soft); }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: var(--r-xs);
}

/* scrollbars */
* { scrollbar-width: thin; scrollbar-color: var(--line-2) transparent; }
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-thumb { background: var(--line-2); border-radius: 10px; border: 3px solid transparent; background-clip: content-box; }
*::-webkit-scrollbar-track { background: transparent; }

/* ---------- shared controls ---------- */

.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 34px; height: 34px;
  border-radius: var(--r-sm);
  color: var(--ink-2);
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease), transform var(--dur) var(--ease);
}
.icon-btn:hover { background: var(--surface-2); color: var(--ink); }
.icon-btn:active { transform: scale(.94); }
.icon-btn.is-on { color: var(--accent); background: var(--accent-soft); }
.icon-btn.danger:hover { background: var(--danger-soft); color: var(--danger); }

.btn-primary {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 9px 16px;
  border-radius: var(--r-full);
  background: var(--accent);
  color: var(--accent-ink);
  font-weight: 600;
  box-shadow: var(--shadow-1);
  transition: filter var(--dur) var(--ease), transform var(--dur) var(--ease);
}
.btn-primary:hover { filter: brightness(1.08); }
.btn-primary:active { transform: scale(.97); }

.btn-ghost {
  padding: 8px 14px;
  border-radius: var(--r-full);
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink-2);
  font-weight: 500;
  transition: border-color var(--dur) var(--ease), color var(--dur) var(--ease);
}
.btn-ghost:hover { border-color: var(--line-2); color: var(--ink); }
.btn-ghost.danger { color: var(--danger); border-color: var(--danger-soft); }
.btn-ghost.danger:hover { background: var(--danger-soft); }
.btn-danger-ghost { color: var(--danger); font-weight: 600; text-decoration: underline; }

.pill-btn {
  padding: 7px 13px;
  border-radius: var(--r-full);
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
  font-size: 13px;
  white-space: nowrap;
}
.pill-btn.is-denied { background: var(--danger-soft); color: var(--danger); }

.swatch {
  width: 26px; height: 26px;
  border-radius: 50%;
  border: 2px solid transparent;
  box-shadow: inset 0 0 0 1px rgba(0,0,0,.10);
  transition: transform var(--dur) var(--ease);
}
.swatch:hover { transform: scale(1.14); }
.swatch.is-on { border-color: var(--ink); transform: scale(1.1); }

.seg { display: inline-flex; background: var(--surface-2); border-radius: var(--r-full); padding: 3px; gap: 2px; }
.seg button {
  padding: 6px 14px; border-radius: var(--r-full);
  font-size: 13px; font-weight: 600; color: var(--ink-2);
}
.seg button.is-on { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-1); }

.spacer { flex: 1; }

/* ---------- splash ---------- */

#splash {
  position: fixed; inset: 0; z-index: 200;
  display: grid; place-items: center;
  background: var(--bg);
  transition: opacity .35s var(--ease);
}
#splash.is-out { opacity: 0; pointer-events: none; }
.splash-inner { text-align: center; color: var(--ink-3); }
.splash-mark {
  width: 62px; height: 62px; margin: 0 auto 14px;
  border-radius: 50%;
  border: 3px solid var(--accent);
  position: relative;
}
.splash-clock {
  position: absolute; left: 50%; top: 50%;
  width: 2px; height: 20px; margin-left: -1px;
  background: var(--accent); border-radius: 2px;
  transform-origin: 50% 0;
  animation: sweep 1.4s linear infinite;
}
@keyframes sweep { to { transform: rotate(360deg); } }
.splash-inner p { font-weight: 600; letter-spacing: .04em; }
.splash-error { max-width: 420px; padding: 24px; text-align: left; color: var(--ink); }

/* ---------- layout ---------- */

.app { display: flex; height: 100dvh; overflow: hidden; }

.main {
  flex: 1; min-width: 0;
  display: flex; flex-direction: column;
  background: var(--bg);
}

.content {
  flex: 1; min-height: 0;
  overflow-y: auto;
  padding: var(--pad) var(--pad) 120px;
  scroll-padding-bottom: 80px;
}

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

.sidebar {
  width: 258px; flex-shrink: 0;
  display: flex; flex-direction: column;
  background: var(--bg-2);
  border-right: 1px solid var(--line);
  padding: 14px 12px;
  gap: 12px;
}
.sb-top { display: flex; align-items: center; justify-content: space-between; padding: 0 4px; }
.brand { display: flex; align-items: center; gap: 9px; font-weight: 700; letter-spacing: -.01em; }
.brand-mark {
  width: 30px; height: 30px; display: grid; place-items: center;
  border-radius: 9px; background: var(--accent-soft); font-size: 16px;
}
.sb-close { display: none; }
.btn-new { width: 100%; }

.sb-body { flex: 1; overflow-y: auto; margin: 0 -4px; padding: 0 4px; }
.sb-group { margin-bottom: 16px; }
.sb-group-head {
  display: flex; align-items: center; justify-content: space-between;
  font-size: 11px; font-weight: 700; letter-spacing: .09em; text-transform: uppercase;
  color: var(--ink-3);
  padding: 8px 10px 6px;
}
.sb-add { width: 22px; height: 22px; border-radius: var(--r-xs); color: var(--ink-3); font-size: 15px; }
.sb-add:hover { background: var(--surface); color: var(--ink); }

.sb-item {
  width: 100%;
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px;
  border-radius: var(--r-sm);
  font-size: 14px; font-weight: 500;
  color: var(--ink-2);
  text-align: left;
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease);
}
.sb-item:hover { background: var(--surface); color: var(--ink); }
.sb-item.is-active { background: var(--accent-soft); color: var(--accent); font-weight: 650; }
.sb-icon { width: 20px; text-align: center; flex-shrink: 0; }
.sb-label { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sb-count {
  font-size: 11px; font-weight: 700;
  padding: 1px 7px; border-radius: var(--r-full);
  background: rgba(128,128,150,.16); color: var(--ink-3);
}
.sb-item.is-active .sb-count { background: rgba(255,255,255,.35); color: inherit; }
.sb-more { opacity: 0; padding: 0 4px; color: var(--ink-3); }
.sb-item:hover .sb-more { opacity: 1; }
.sb-empty { font-size: 12px; color: var(--ink-3); padding: 2px 10px 6px; }

.sb-tags { display: flex; flex-wrap: wrap; gap: 5px; padding: 2px 8px 4px; }
.tag-chip {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 12px; font-weight: 600;
  padding: 4px 9px; border-radius: var(--r-full);
  background: var(--surface); color: var(--ink-2);
  border: 1px solid var(--line);
}
.tag-chip span { font-size: 10px; color: var(--ink-3); }
.tag-chip:hover { border-color: var(--accent); color: var(--accent); }
.tag-chip.is-active { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.tag-chip.is-active span { color: inherit; opacity: .8; }

.sb-foot { display: flex; flex-direction: column; gap: 4px; border-top: 1px solid var(--line); padding-top: 10px; }
.sb-foot-btn {
  text-align: left; padding: 8px 10px; border-radius: var(--r-sm);
  font-size: 13px; color: var(--ink-2);
}
.sb-foot-btn:hover { background: var(--surface); color: var(--ink); }

.scrim {
  position: fixed; inset: 0; z-index: 40;
  background: rgba(10,10,20,.45);
  opacity: 0; pointer-events: none;
  transition: opacity var(--dur) var(--ease);
}

/* ---------- topbar ---------- */

.topbar {
  display: flex; align-items: center; gap: 12px;
  padding: 12px var(--pad);
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--bg) 85%, transparent);
  backdrop-filter: saturate(1.4) blur(10px);
  position: sticky; top: 0; z-index: 20;
}
.scope-title {
  font-size: 17px; font-weight: 700; letter-spacing: -.01em;
  display: flex; align-items: center; gap: 8px;
  white-space: nowrap;
}
.scope-icon { font-size: 15px; }

.search {
  flex: 1; min-width: 0; max-width: 460px;
  display: flex; align-items: center; gap: 8px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-full);
  padding: 0 12px;
  height: 38px;
  transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}
.search:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.search-icon { font-size: 13px; opacity: .6; }
.search input {
  flex: 1; min-width: 0; border: 0; background: none; outline: none;
  font-size: 14px;
}
.search input::-webkit-search-cancel-button { display: none; }
.search-clear { color: var(--ink-3); font-size: 12px; }

.topbar-actions { display: flex; align-items: center; gap: 8px; margin-left: auto; }

.view-switch { display: flex; background: var(--surface-2); border-radius: var(--r-full); padding: 3px; }
.view-switch button {
  width: 32px; height: 28px; border-radius: var(--r-full);
  color: var(--ink-3); font-size: 13px;
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease);
}
.view-switch button:hover { color: var(--ink); }
.view-switch button.is-active { background: var(--surface); color: var(--accent); box-shadow: var(--shadow-1); }

/* ---------- status strip ---------- */

.status-strip {
  display: flex; gap: 8px; flex-wrap: wrap;
  padding: 10px var(--pad) 0;
}
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12px; font-weight: 600;
  padding: 5px 11px; border-radius: var(--r-full);
  background: var(--surface); border: 1px solid var(--line);
  color: var(--ink-2);
  max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.chip-warn { background: var(--warn-soft); border-color: transparent; color: var(--warn); }
.chip-quiet { background: transparent; border-style: dashed; color: var(--ink-3); }

/* ---------- selection bar ---------- */

.selection-bar {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  margin: 10px var(--pad) 0;
  padding: 8px 12px;
  border-radius: var(--r-md);
  background: var(--accent);
  color: var(--accent-ink);
  box-shadow: var(--shadow-2);
  animation: slideDown .22s var(--ease);
}
@keyframes slideDown { from { opacity: 0; transform: translateY(-8px); } }
.sel-count { font-weight: 700; font-size: 13px; }
.sel-actions { display: flex; gap: 4px; flex-wrap: wrap; margin-left: auto; }
.sel-actions button {
  padding: 6px 11px; border-radius: var(--r-full);
  font-size: 13px; font-weight: 600;
  background: rgba(255,255,255,.16);
}
.sel-actions button:hover { background: rgba(255,255,255,.3); }
.sel-actions button.danger:hover { background: var(--danger); }

/* ---------- note cards ---------- */

.note-grid { columns: 268px; column-gap: var(--gap); }
[data-density="compact"] .note-grid { columns: 230px; }
.note-grid .note-card { break-inside: avoid; margin-bottom: var(--gap); }

.note-list { display: flex; flex-direction: column; gap: var(--gap); max-width: 860px; }

.note-card {
  position: relative;
  display: block; width: 100%;
  background: var(--card, var(--surface));
  color: var(--card-ink, var(--ink));
  border: 1px solid var(--card-edge, var(--line));
  border-radius: var(--r-md);
  padding: var(--pad);
  box-shadow: var(--shadow-1);
  transition: box-shadow var(--dur) var(--ease), transform var(--dur) var(--ease), border-color var(--dur) var(--ease);
  cursor: pointer;
}
.note-card:hover { box-shadow: var(--shadow-2); transform: translateY(-2px); }
.note-card:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.note-card.is-done { opacity: .58; }
.note-card.is-done .nc-title { text-decoration: line-through; }
.note-card.is-pinned::after {
  content: "📌";
  position: absolute; top: -7px; right: 10px;
  font-size: 14px; transform: rotate(12deg);
  filter: drop-shadow(0 1px 2px rgba(0,0,0,.25));
}
.note-card.is-overdue { border-color: var(--danger); }
.note-card.is-selected { outline: 2.5px solid var(--accent); outline-offset: 1px; }
.note-card.is-dragging { opacity: .4; }
.note-card.is-drop-before { box-shadow: 0 -3px 0 var(--accent), var(--shadow-2); }
.note-card.is-drop-after { box-shadow: 0 3px 0 var(--accent), var(--shadow-2); }

.nc-prio {
  position: absolute; left: 0; top: 14px; bottom: 14px;
  width: 3px; border-radius: 0 3px 3px 0;
}
.prio-high .nc-prio { background: var(--danger); }
.prio-medium .nc-prio { background: var(--warn); }
.prio-low .nc-prio { background: #4c8fe0; }

.nc-select {
  position: absolute; top: 10px; left: 10px;
  width: 22px; height: 22px; border-radius: 50%;
  border: 2px solid var(--ink-3);
  background: var(--surface);
  opacity: 0; transform: scale(.8);
  transition: opacity var(--dur) var(--ease), transform var(--dur) var(--ease);
  z-index: 2;
}
.note-card:hover .nc-select,
.is-selecting .nc-select { opacity: 1; transform: scale(1); }
.nc-select[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); }
.nc-select[aria-pressed="true"]::after { content: "✓"; color: #fff; font-size: 12px; font-weight: 700; }

.nc-title { font-size: 15px; font-weight: 700; letter-spacing: -.01em; margin-bottom: 4px; overflow-wrap: anywhere; }
.nc-body { font-size: 14px; color: inherit; overflow: hidden; max-height: 320px; overflow-wrap: anywhere; }
.note-card.is-compact .nc-body { max-height: 76px; }
.nc-empty { color: var(--ink-3); font-style: italic; }

.nc-progress { display: flex; align-items: center; gap: 8px; margin-top: 10px; }
.nc-progress-bar { flex: 1; height: 5px; border-radius: 5px; background: rgba(128,128,150,.25); overflow: hidden; }
.nc-progress-bar span { display: block; height: 100%; background: var(--accent); border-radius: 5px; transition: width .3s var(--ease); }
.nc-progress-label { font-size: 11px; font-weight: 700; color: var(--ink-3); }

.nc-tags { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 10px; }
.nc-tag, .nc-book {
  font-size: 11px; font-weight: 600;
  padding: 2px 8px; border-radius: var(--r-full);
  background: rgba(128,128,150,.16); color: var(--ink-2);
}
.nc-tag:hover { background: var(--accent); color: var(--accent-ink); }

.nc-alarms { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 10px; }
.rem-chip {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 11.5px; font-weight: 600;
  padding: 3px 9px; border-radius: var(--r-full);
  background: var(--surface); border: 1px solid var(--line);
  color: var(--ink-2);
  max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.rem-chip.is-alarm { border-color: var(--accent); color: var(--accent); }
.rem-chip.is-late { background: var(--danger-soft); border-color: transparent; color: var(--danger); }
.rem-chip.is-off { opacity: .5; text-decoration: line-through; }
.rem-repeat { opacity: .6; }

.nc-foot {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  margin-top: 12px; padding-top: 10px;
  border-top: 1px solid rgba(128,128,150,.16);
}
.nc-meta { font-size: 11px; color: var(--ink-3); white-space: nowrap; }
.nc-actions { display: flex; gap: 1px; opacity: 0; transition: opacity var(--dur) var(--ease); }
.note-card:hover .nc-actions, .note-card:focus-within .nc-actions { opacity: 1; }
.nc-actions button {
  width: 27px; height: 27px; border-radius: var(--r-xs);
  font-size: 13px; color: var(--ink-2);
}
.nc-actions button:hover { background: rgba(128,128,150,.2); color: var(--ink); }
.nc-actions button.is-on { color: var(--accent); }

@media (hover: none) {
  .nc-actions, .nc-select { opacity: 1; }
}

/* markdown inside cards and previews */
.md > * + * { margin-top: .5em; }
.md h3 { font-size: 15px; font-weight: 700; }
.md h4 { font-size: 14px; font-weight: 700; }
.md h5, .md h6 { font-size: 13px; font-weight: 700; color: var(--ink-2); }
.md p { overflow-wrap: anywhere; }
.md ul, .md ol { padding-left: 1.25em; }
.md li { margin: 2px 0; }
.md blockquote {
  border-left: 3px solid var(--accent);
  padding: 2px 0 2px 10px;
  color: var(--ink-2);
  font-style: italic;
}
.md code {
  font-family: var(--mono); font-size: .88em;
  background: rgba(128,128,150,.18); padding: 1px 5px; border-radius: var(--r-xs);
}
.md pre {
  background: rgba(20,20,35,.06); padding: 10px 12px; border-radius: var(--r-sm);
  overflow-x: auto; font-size: 12.5px;
}
[data-theme="dark"] .md pre { background: rgba(0,0,0,.3); }
.md pre code { background: none; padding: 0; }
.md hr { border: 0; border-top: 1px solid var(--line-2); margin: .8em 0; }
.md mark { background: rgba(255,220,0,.4); color: inherit; padding: 0 2px; border-radius: 3px; }
.md a { text-decoration: underline; text-underline-offset: 2px; }

.md-checklist { list-style: none; padding-left: 0; }
.md-check { display: flex; align-items: flex-start; gap: 8px; }
.md-box {
  flex-shrink: 0; margin-top: 3px;
  width: 16px; height: 16px; border-radius: 5px;
  border: 2px solid var(--ink-3);
  transition: background var(--dur) var(--ease), border-color var(--dur) var(--ease);
}
.md-box:hover { border-color: var(--accent); }
.md-check.is-checked .md-box { background: var(--accent); border-color: var(--accent); }
.md-check.is-checked .md-box::after {
  content: "✓"; display: block; color: #fff;
  font-size: 11px; line-height: 12px; font-weight: 800; text-align: center;
}
.md-check.is-checked .md-check-text { text-decoration: line-through; opacity: .55; }

/* ---------- board view ---------- */

.board { display: flex; gap: var(--gap); align-items: flex-start; overflow-x: auto; padding-bottom: 12px; }
.board-col {
  flex: 0 0 288px;
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: 10px;
}
.board-head {
  display: flex; align-items: center; justify-content: space-between;
  font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em;
  color: var(--ink-2); padding: 4px 6px 10px;
}
.board-head span { font-size: 11px; background: var(--surface); padding: 1px 7px; border-radius: var(--r-full); }
.board-body { display: flex; flex-direction: column; gap: 9px; max-height: calc(100dvh - 260px); overflow-y: auto; }
.board-empty { font-size: 12px; color: var(--ink-3); text-align: center; padding: 18px 0; }

/* ---------- agenda view ---------- */

.agenda { max-width: 780px; display: flex; flex-direction: column; gap: 22px; }
.agenda-group { display: flex; flex-direction: column; gap: 7px; }
.agenda-head {
  display: flex; align-items: center; gap: 8px;
  font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em;
  color: var(--ink-2); padding-bottom: 2px;
}
.agenda-head span {
  font-size: 11px; background: var(--surface-2); color: var(--ink-3);
  padding: 1px 7px; border-radius: var(--r-full);
}
.agenda-row {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 14px;
}
.agenda-check { font-size: 17px; color: var(--ink-2); flex-shrink: 0; }
.agenda-main { flex: 1; min-width: 0; text-align: left; }
.agenda-title { font-weight: 600; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.agenda-sub { font-size: 12px; color: var(--ink-3); }
.agenda-row.is-done .agenda-title { text-decoration: line-through; }
.agenda-actions { display: flex; gap: 2px; opacity: 0; transition: opacity var(--dur) var(--ease); }
.agenda-row:hover .agenda-actions { opacity: 1; }
.agenda-actions button { width: 28px; height: 28px; border-radius: var(--r-xs); color: var(--ink-2); }
.agenda-actions button:hover { background: rgba(128,128,150,.2); }

/* ---------- calendar view ---------- */

.calendar { max-width: 1080px; }
.cal-head { display: flex; align-items: center; gap: 8px; margin-bottom: 14px; }
.cal-head h2 { font-size: 17px; font-weight: 700; min-width: 190px; }
.cal-head button {
  width: 32px; height: 32px; border-radius: var(--r-sm);
  background: var(--surface); border: 1px solid var(--line); color: var(--ink-2);
  font-size: 16px;
}
.cal-head button:hover { border-color: var(--accent); color: var(--accent); }
.cal-today { width: auto !important; padding: 0 14px; font-size: 13px !important; font-weight: 600; }

.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.cal-dow {
  font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em;
  color: var(--ink-3); text-align: center; padding-bottom: 4px;
}
.cal-cell {
  min-height: 104px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  padding: 6px;
  display: flex; flex-direction: column; gap: 3px;
  overflow: hidden;
}
.cal-cell.is-pad { background: transparent; border-color: transparent; }
.cal-cell.is-today { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); }
.cal-num { font-size: 12px; font-weight: 700; color: var(--ink-2); }
.cal-cell.is-today .cal-num { color: var(--accent); }
.cal-item {
  font-size: 11px; text-align: left;
  padding: 3px 6px; border-radius: var(--r-xs);
  background: var(--card, var(--surface-2));
  border: 1px solid var(--card-edge, var(--line));
  color: var(--card-ink, var(--ink));
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.cal-item:hover { filter: brightness(.96); }
.cal-time { font-weight: 700; opacity: .75; }
.cal-more { font-size: 10px; color: var(--ink-3); padding-left: 4px; }

/* ---------- trash bar / empty state ---------- */

.trash-bar {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 10px 14px; margin-bottom: var(--gap);
  border-radius: var(--r-md);
  background: var(--surface-2); border: 1px dashed var(--line-2);
  font-size: 13px; color: var(--ink-2);
}

.empty-state {
  max-width: 380px; margin: 12vh auto; text-align: center;
  display: flex; flex-direction: column; align-items: center; gap: 10px;
}
.empty-icon { font-size: 46px; opacity: .85; }
.empty-state h2 { font-size: 18px; font-weight: 700; }
.empty-state p { color: var(--ink-3); font-size: 14px; }
.empty-state .btn-primary { margin-top: 8px; }

/* ---------- FAB + bottom nav ---------- */

.fab {
  position: fixed; right: 22px; bottom: 22px; z-index: 30;
  width: 56px; height: 56px; border-radius: 50%;
  background: var(--accent); color: var(--accent-ink);
  font-size: 26px; line-height: 1;
  box-shadow: var(--shadow-2);
  transition: transform var(--dur) var(--ease), filter var(--dur) var(--ease);
}
.fab:hover { filter: brightness(1.08); transform: scale(1.05); }
.fab:active { transform: scale(.94); }

.bottom-nav { display: none; }

/* ---------- popover menu ---------- */

.popmenu {
  position: fixed; z-index: 120;
  min-width: 208px; max-width: 280px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-3);
  padding: 6px;
  animation: pop .14s var(--ease);
}
@keyframes pop { from { opacity: 0; transform: translateY(-6px) scale(.98); } }
.popmenu-item {
  width: 100%; display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; border-radius: var(--r-sm);
  font-size: 14px; text-align: left; color: var(--ink);
}
.popmenu-item:hover { background: var(--surface-2); }
.popmenu-item.is-danger { color: var(--danger); }
.popmenu-item.is-danger:hover { background: var(--danger-soft); }
.popmenu-icon { width: 18px; text-align: center; flex-shrink: 0; }
.popmenu-item span:nth-child(2) { flex: 1; }
.popmenu-check { color: var(--accent); font-weight: 700; }
.popmenu-sep { height: 1px; background: var(--line); margin: 5px 4px; }
.popmenu-heading {
  font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .08em;
  color: var(--ink-3); padding: 8px 10px 4px;
}
.popmenu-swatches { display: flex; flex-wrap: wrap; gap: 7px; padding: 6px 10px 10px; }
.popmenu kbd { margin-left: auto; }

/* ---------- editor panel ---------- */

.editor {
  position: fixed; top: 0; right: 0; bottom: 0; z-index: 90;
  width: min(560px, 100vw);
  background: var(--bg);
  border-left: 1px solid var(--line);
  box-shadow: var(--shadow-3);
  transform: translateX(102%);
  transition: transform .26s var(--ease);
  display: flex; flex-direction: column;
}
.editor-open .editor { transform: none; }
.ed-shell { display: flex; flex-direction: column; height: 100%; background: var(--card, var(--surface)); }

.ed-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 12px;
  border-bottom: 1px solid rgba(128,128,150,.2);
  flex-shrink: 0;
}
.ed-head-actions { display: flex; gap: 2px; }

.ed-scroll { flex: 1; overflow-y: auto; padding: 16px 20px 40px; }

.ed-title {
  width: 100%; border: 0; background: none; outline: none;
  font-size: 22px; font-weight: 700; letter-spacing: -.02em;
  padding: 4px 0 8px;
}
.ed-title::placeholder { color: var(--ink-3); }

.ed-toolbar {
  display: flex; flex-wrap: wrap; gap: 2px;
  padding: 4px 0 8px;
  border-bottom: 1px solid rgba(128,128,150,.18);
  margin-bottom: 10px;
}
.ed-toolbar button {
  min-width: 30px; height: 30px; padding: 0 7px;
  border-radius: var(--r-xs);
  font-size: 13px; color: var(--ink-2);
}
.ed-toolbar button:hover { background: rgba(128,128,150,.2); color: var(--ink); }

.ed-body {
  width: 100%; min-height: 220px;
  border: 0; background: none; outline: none; resize: none;
  font-size: 15px; line-height: 1.65;
  font-family: inherit;
  overflow-wrap: anywhere;
}
.ed-body::placeholder { color: var(--ink-3); }
.ed-preview { min-height: 200px; font-size: 15px; }

.ed-section {
  margin-top: 26px; padding-top: 18px;
  border-top: 1px solid rgba(128,128,150,.2);
}
.ed-section h3 {
  font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .09em;
  color: var(--ink-3); margin-bottom: 12px;
}
.ed-hint { font-size: 12px; color: var(--ink-3); margin-top: 4px; }

.ed-rems { display: flex; flex-direction: column; gap: 7px; margin-bottom: 12px; }
.ed-rem {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 11px;
  border-radius: var(--r-sm);
  background: var(--surface); border: 1px solid var(--line);
}
.ed-rem.is-off { opacity: .55; }
.ed-rem-toggle {
  width: 34px; height: 34px; border-radius: var(--r-sm);
  background: var(--accent-soft); font-size: 15px; flex-shrink: 0;
}
.ed-rem.is-off .ed-rem-toggle { background: var(--surface-2); filter: grayscale(1); }
.ed-rem-main { flex: 1; min-width: 0; text-align: left; }
.ed-rem-when { display: block; font-size: 14px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ed-rem-next { display: block; font-size: 12px; color: var(--ink-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ed-rem-del { width: 28px; height: 28px; border-radius: var(--r-xs); color: var(--ink-3); flex-shrink: 0; }
.ed-rem-del:hover { background: var(--danger-soft); color: var(--danger); }

.ed-quick { display: flex; flex-wrap: wrap; gap: 6px; }
.ed-quick button {
  padding: 6px 12px; border-radius: var(--r-full);
  background: var(--surface); border: 1px solid var(--line);
  font-size: 12.5px; font-weight: 600; color: var(--ink-2);
}
.ed-quick button:hover { border-color: var(--accent); color: var(--accent); }
.ed-quick .btn-primary { background: var(--accent); border-color: transparent; color: var(--accent-ink); }

.ed-field { margin-bottom: 14px; }
.ed-field > label {
  display: block; font-size: 12px; font-weight: 600; color: var(--ink-2);
  margin-bottom: 6px;
}
.ed-field input[type="text"], .ed-field input[type="number"], .ed-field input[type="time"],
.ed-field input[type="date"], .ed-field input[type="datetime-local"], .ed-field select,
.ed-field input:not([type]), .rem-inline input, .rem-inline select, .pal-input {
  padding: 9px 12px;
  border-radius: var(--r-sm);
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  outline: none;
  transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
  font-size: 14px;
  max-width: 100%;
}
.ed-field input:focus, .ed-field select:focus, .rem-inline input:focus, .rem-inline select:focus {
  border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft);
}
.ed-field select,
.ed-field input[type="datetime-local"],
.ed-field input[type="date"],
.ed-field input[type="text"],
.ed-field > input:not([type]) { width: 100%; }
.rem-inline .ed-field select { min-width: 140px; }
.ed-field input[type="range"] { width: 100%; accent-color: var(--accent); }

.ed-swatches { display: flex; flex-wrap: wrap; gap: 8px; }

.ed-tags { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.ed-tag {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 12px; font-weight: 600;
  padding: 4px 6px 4px 10px; border-radius: var(--r-full);
  background: var(--accent-soft); color: var(--accent);
}
.ed-tag button { font-size: 10px; opacity: .7; }
.ed-tag button:hover { opacity: 1; }
.ed-tags input { flex: 1; min-width: 110px; border: 0 !important; background: none !important; box-shadow: none !important; }

.ed-check {
  display: flex; align-items: flex-start; gap: 9px;
  font-size: 14px; color: var(--ink-2);
  padding: 7px 0; cursor: pointer;
}
.ed-check input { margin-top: 3px; accent-color: var(--accent); width: 16px; height: 16px; }
.ed-check small { display: block; color: var(--ink-3); font-size: 12px; }

.ed-foot {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 10px 14px;
  border-top: 1px solid rgba(128,128,150,.2);
  flex-shrink: 0;
}
.ed-meta { font-size: 11.5px; color: var(--ink-3); }
.ed-foot-actions { display: flex; gap: 2px; }

/* ---------- modals ---------- */

.modal-wrap { position: fixed; inset: 0; z-index: 130; display: grid; place-items: center; padding: 20px; }
.modal-scrim {
  position: absolute; inset: 0;
  background: rgba(8,8,18,.5);
  backdrop-filter: blur(3px);
  opacity: 0; transition: opacity var(--dur) var(--ease);
}
.modal-wrap.is-in .modal-scrim { opacity: 1; }
.modal {
  position: relative;
  width: min(560px, 100%);
  max-height: min(86dvh, 800px);
  display: flex; flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-3);
  opacity: 0; transform: translateY(14px) scale(.98);
  transition: opacity var(--dur) var(--ease), transform var(--dur) var(--ease);
}
.modal-wrap.is-in .modal { opacity: 1; transform: none; }
.modal-wrap.is-out .modal { opacity: 0; transform: translateY(10px) scale(.98); }
.modal-wrap.is-out .modal-scrim { opacity: 0; }
.modal-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px; border-bottom: 1px solid var(--line);
}
.modal-head h2 { font-size: 16px; font-weight: 700; }
.modal-body { flex: 1; overflow-y: auto; padding: 18px; }
.modal-foot {
  display: flex; align-items: center; gap: 8px;
  padding: 12px 16px; border-top: 1px solid var(--line);
}

/* reminder dialog */
.rem-modes { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 14px; }
.rem-mode {
  display: flex; flex-direction: column; align-items: flex-start; gap: 1px;
  padding: 11px 13px; border-radius: var(--r-md);
  border: 1.5px solid var(--line); background: var(--surface);
  text-align: left;
}
.rem-mode span { font-size: 17px; }
.rem-mode strong { font-size: 14px; }
.rem-mode small { font-size: 11.5px; color: var(--ink-3); }
.rem-mode.is-on { border-color: var(--accent); background: var(--accent-soft); }

.rem-presets { display: flex; flex-wrap: wrap; gap: 5px; margin-bottom: 14px; }
.rem-presets button {
  padding: 5px 11px; border-radius: var(--r-full);
  background: var(--surface-2); font-size: 12.5px; font-weight: 600; color: var(--ink-2);
}
.rem-presets button:hover { background: var(--accent); color: var(--accent-ink); }

.rem-kinds { display: flex; gap: 3px; background: var(--surface-2); padding: 3px; border-radius: var(--r-full); margin-bottom: 16px; overflow-x: auto; }
.rem-kinds button {
  flex: 1; padding: 7px 10px; border-radius: var(--r-full);
  font-size: 13px; font-weight: 600; color: var(--ink-2); white-space: nowrap;
}
.rem-kinds button.is-on { background: var(--surface); color: var(--accent); box-shadow: var(--shadow-1); }

.rem-days { display: flex; gap: 4px; flex-wrap: wrap; }
.rem-days button {
  width: 42px; height: 36px; border-radius: var(--r-sm);
  border: 1px solid var(--line); background: var(--surface);
  font-size: 12px; font-weight: 600; color: var(--ink-2);
}
.rem-days button.is-on { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }

.rem-inline { display: flex; align-items: flex-end; gap: 8px; flex-wrap: wrap; }
.rem-inline .ed-field { margin-bottom: 0; }
.rem-inline span { font-size: 13px; color: var(--ink-2); padding-bottom: 10px; }
.rem-inline input[type="number"] { width: 78px; }
.rem-sub { padding-left: 26px; margin-bottom: 8px; }
.rem-sub label { font-size: 13px; color: var(--ink-2); padding-bottom: 10px; }
.rem-sub span { padding-bottom: 10px; }

.rem-preview {
  padding: 11px 13px; border-radius: var(--r-sm);
  background: var(--accent-soft); color: var(--ink);
  font-size: 13.5px; margin-bottom: 14px;
}
.rem-preview-none { color: var(--danger); font-weight: 600; }

.rem-adv { border-top: 1px solid var(--line); padding-top: 12px; }
.rem-adv summary {
  cursor: pointer; font-size: 12px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .07em; color: var(--ink-3);
  margin-bottom: 12px;
}

/* settings */
.set-tabs { display: flex; gap: 3px; background: var(--surface-2); padding: 3px; border-radius: var(--r-full); margin-bottom: 18px; }
.set-tabs button { flex: 1; padding: 7px; border-radius: var(--r-full); font-size: 13px; font-weight: 600; color: var(--ink-2); }
.set-tabs button.is-on { background: var(--surface); color: var(--accent); box-shadow: var(--shadow-1); }

.set-perm {
  display: flex; align-items: center; gap: 12px;
  padding: 13px; border-radius: var(--r-md);
  background: var(--surface-2); border: 1px solid var(--line);
  margin-bottom: 16px;
}
.set-perm p { font-size: 12.5px; color: var(--ink-3); margin-top: 2px; }
.set-perm.is-ok { border-color: var(--ok); }
.set-perm.is-bad { border-color: var(--danger); }
.set-perm button { flex-shrink: 0; }

.set-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(96px, 1fr)); gap: 9px; margin-bottom: 14px; }
.set-stats > div {
  background: var(--surface-2); border-radius: var(--r-sm);
  padding: 12px; text-align: center;
}
.set-stats strong { display: block; font-size: 22px; font-weight: 700; letter-spacing: -.02em; }
.set-stats span { font-size: 11.5px; color: var(--ink-3); }

.set-actions { display: flex; flex-direction: column; gap: 8px; margin: 16px 0; }
.set-actions .btn-ghost { text-align: left; }
.set-danger { border-top: 1px solid var(--line); padding-top: 14px; display: flex; flex-direction: column; gap: 8px; }
.set-danger h4 { font-size: 12px; text-transform: uppercase; letter-spacing: .07em; color: var(--danger); }
.set-about p { font-size: 14px; color: var(--ink-2); margin-bottom: 10px; }
.set-about h4 { font-size: 13px; margin: 18px 0 8px; }
.kbd-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.kbd-table td { padding: 4px 0; color: var(--ink-2); }
.kbd-table td:first-child { width: 110px; }

/* palette */
.modal-palette .modal-body { padding: 12px; }
.pal-input { width: 100%; margin-bottom: 10px; font-size: 15px !important; }
.pal-results { max-height: 46dvh; overflow-y: auto; display: flex; flex-direction: column; gap: 2px; }
.pal-item {
  display: flex; align-items: center; gap: 11px;
  padding: 9px 11px; border-radius: var(--r-sm);
  text-align: left; font-size: 14px;
}
.pal-item.is-on { background: var(--accent-soft); }
.pal-icon { width: 20px; text-align: center; flex-shrink: 0; }
.pal-label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pal-label small { display: block; font-size: 11.5px; color: var(--ink-3); overflow: hidden; text-overflow: ellipsis; }

/* ---------- alarm screen ---------- */

.alarm-screen { position: fixed; inset: 0; z-index: 160; display: none; }
.alarm-ringing .alarm-screen {
  display: grid; place-items: center;
  padding: 20px;
  background: radial-gradient(120% 80% at 50% 0%, color-mix(in srgb, var(--accent) 35%, transparent), transparent 70%), var(--bg);
  animation: alarmIn .3s var(--ease);
}
@keyframes alarmIn { from { opacity: 0; } }

.alarm-sheet {
  position: relative;
  width: min(460px, 100%);
  max-height: 92dvh; overflow-y: auto;
  padding: 30px 26px 24px;
  border-radius: var(--r-xl);
  background: var(--card, var(--surface));
  border: 1px solid var(--card-edge, var(--line));
  box-shadow: var(--shadow-3);
  text-align: center;
}

.alarm-rings { position: absolute; inset: 0; z-index: 0; pointer-events: none; overflow: hidden; border-radius: inherit; }
.alarm-sheet > *:not(.alarm-rings) { position: relative; z-index: 1; }
.alarm-rings span {
  position: absolute; left: 50%; top: 62px;
  width: 90px; height: 90px; margin-left: -45px;
  border-radius: 50%;
  border: 2px solid var(--accent);
  opacity: 0;
  animation: ring 2.4s var(--ease) infinite;
}
.alarm-rings span:nth-child(2) { animation-delay: .8s; }
.alarm-rings span:nth-child(3) { animation-delay: 1.6s; }
@keyframes ring {
  0% { transform: scale(.4); opacity: .65; }
  100% { transform: scale(3.4); opacity: 0; }
}
.alarm-sheet.is-missed .alarm-rings { display: none; }

.alarm-top { display: flex; align-items: center; justify-content: center; gap: 10px; position: relative; }
.alarm-kind {
  font-size: 11.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .12em;
  color: var(--accent);
}
.is-missed .alarm-kind { color: var(--warn); }
.alarm-count {
  font-size: 11px; font-weight: 700;
  padding: 2px 8px; border-radius: var(--r-full);
  background: rgba(128,128,150,.2); color: var(--ink-2);
}

.alarm-time { display: flex; align-items: baseline; justify-content: center; gap: 5px; margin: 10px 0 4px; }
.alarm-clock { font-size: 54px; font-weight: 300; letter-spacing: -.03em; line-height: 1; font-variant-numeric: tabular-nums; }
.alarm-seconds { font-size: 17px; color: var(--ink-3); font-variant-numeric: tabular-nums; }
.alarm-was { font-size: 12.5px; color: var(--warn); font-weight: 600; margin-bottom: 6px; }

.alarm-title { font-size: 21px; font-weight: 700; letter-spacing: -.02em; margin: 10px 0 4px; overflow-wrap: anywhere; }
.alarm-note-title { font-size: 13px; color: var(--ink-2); font-weight: 600; }
.alarm-body {
  font-size: 14px; color: var(--ink-2); margin: 8px 0;
  max-height: 130px; overflow-y: auto;
  white-space: pre-wrap; text-align: left;
  padding: 10px 12px; border-radius: var(--r-sm);
  background: rgba(128,128,150,.12);
}
.alarm-schedule { font-size: 12px; color: var(--ink-3); margin-bottom: 20px; }

.alarm-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; }
.alarm-btn {
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  padding: 14px 10px;
  border-radius: var(--r-md);
  font-size: 14px; font-weight: 650;
  background: var(--surface); border: 1px solid var(--line);
  transition: transform var(--dur) var(--ease), filter var(--dur) var(--ease);
}
.alarm-btn:active { transform: scale(.96); }
.alarm-btn-icon { font-size: 19px; }
.alarm-btn small { font-weight: 500; color: var(--ink-3); font-size: 11px; }
.alarm-snooze { background: var(--surface-2); }
.alarm-done { background: var(--ok); color: #fff; border-color: transparent; }
.alarm-done small, .alarm-dismiss small { color: inherit; opacity: .8; }
.alarm-dismiss { grid-column: 1 / -1; background: var(--accent); color: var(--accent-ink); border-color: transparent; }

.alarm-more { display: flex; justify-content: center; gap: 16px; margin-top: 14px; flex-wrap: wrap; }
.alarm-link { font-size: 12.5px; font-weight: 600; color: var(--ink-3); text-decoration: underline; text-underline-offset: 3px; }
.alarm-link:hover { color: var(--accent); }

.alarm-snooze-menu { display: none; flex-wrap: wrap; gap: 6px; justify-content: center; margin-top: 14px; }
.alarm-snooze-menu.open { display: flex; }
.alarm-snooze-menu button {
  padding: 7px 13px; border-radius: var(--r-full);
  background: var(--surface-2); font-size: 13px; font-weight: 600;
}
.alarm-snooze-menu button:hover { background: var(--accent); color: var(--accent-ink); }

/* ---------- toasts ---------- */

/* Bottom-right on desktop so toasts never sit on top of a centred dialog. */
.toasts {
  position: fixed; z-index: 150;
  right: 22px; bottom: 22px;
  display: flex; flex-direction: column-reverse; gap: 9px;
  width: min(390px, calc(100vw - 32px));
  pointer-events: none;
}
.toast {
  pointer-events: auto;
  display: flex; align-items: center; gap: 11px;
  padding: 11px 13px;
  border-radius: var(--r-md);
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-2);
  font-size: 13.5px;
  animation: toastIn .22s var(--ease);
}
@keyframes toastIn { from { opacity: 0; transform: translateY(14px); } }
.toast.is-out { opacity: 0; transform: translateY(10px); transition: opacity .2s, transform .2s; }
.toast-msg { flex: 1; min-width: 0; }
.toast-action { font-weight: 700; color: var(--accent); white-space: nowrap; }
.toast-close { color: var(--ink-3); font-size: 12px; }
.toast-error { border-color: var(--danger); }

.toast-reminder {
  flex-direction: column; align-items: stretch; gap: 9px;
  background: var(--card, var(--surface));
  border-color: var(--card-edge, var(--line));
  border-left: 4px solid var(--accent);
}
.tr-title { font-weight: 700; font-size: 14px; }
.tr-sub { font-size: 12.5px; color: var(--ink-2); overflow: hidden; text-overflow: ellipsis; }
.tr-actions { display: flex; gap: 6px; }
.tr-actions button {
  flex: 1; padding: 7px; border-radius: var(--r-sm);
  background: rgba(128,128,150,.16); font-size: 12.5px; font-weight: 600;
}
.tr-actions button:last-child { flex: 0 0 34px; }
.tr-actions button:hover { background: var(--accent); color: var(--accent-ink); }

/* ---------- responsive ---------- */

.only-mobile { display: none; }

@media (max-width: 960px) {
  .sidebar {
    position: fixed; top: 0; left: 0; bottom: 0; z-index: 50;
    width: 272px;
    transform: translateX(-104%);
    transition: transform .24s var(--ease);
    box-shadow: var(--shadow-3);
  }
  .sidebar-open .sidebar { transform: none; }
  .sidebar-open .scrim { opacity: 1; pointer-events: auto; }
  .sb-close { display: inline-flex; }
  .only-mobile { display: inline-flex; }
  .scope-title { font-size: 16px; }
  .topbar { flex-wrap: wrap; }
  .search { order: 3; flex-basis: 100%; max-width: none; }
  .topbar-actions { gap: 6px; }
}

@media (max-width: 620px) {
  body { font-size: 14.5px; }
  .content { padding: 12px 12px 150px; }
  .topbar { padding: 10px 12px; gap: 8px; }
  .status-strip, .selection-bar { margin-inline: 12px; padding-inline: 0; }
  .selection-bar { padding: 8px 10px; }
  .note-grid { columns: 1; column-gap: 0; }
  .view-switch button:nth-child(n+4) { display: none; }
  .pill-btn { font-size: 12px; padding: 6px 10px; }

  .editor { width: 100vw; border-left: 0; border-radius: var(--r-lg) var(--r-lg) 0 0; top: 6dvh; }
  .ed-scroll { padding: 14px 16px 40px; }

  .fab { right: 16px; bottom: 78px; width: 52px; height: 52px; }

  .bottom-nav {
    display: flex;
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 35;
    background: color-mix(in srgb, var(--bg) 92%, transparent);
    backdrop-filter: blur(12px) saturate(1.4);
    border-top: 1px solid var(--line);
    padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
  }
  .bottom-nav button {
    flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px;
    font-size: 10.5px; font-weight: 600; color: var(--ink-3);
    padding: 5px 2px; border-radius: var(--r-sm);
  }
  .bottom-nav button span { font-size: 17px; }
  .bottom-nav button.is-on { color: var(--accent); }

  .toasts { bottom: 84px; right: 12px; left: 12px; width: auto; }
  .modal-wrap { padding: 0; align-items: flex-end; }
  .modal { width: 100%; max-height: 92dvh; border-radius: var(--r-lg) var(--r-lg) 0 0; border-bottom: 0; }
  .alarm-sheet { padding: 26px 18px 20px; }
  .alarm-clock { font-size: 46px; }
  .cal-cell { min-height: 74px; padding: 4px; }
  .cal-item { font-size: 9.5px; padding: 2px 4px; }
  .cal-time { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
  }
}

@media print {
  .sidebar, .topbar, .fab, .bottom-nav, .nc-actions, .selection-bar, .status-strip { display: none !important; }
  .note-card { break-inside: avoid; box-shadow: none; border: 1px solid #ccc; }
  .note-grid { columns: 2; }
}
