@font-face {
  font-family: 'Fraunces';
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url('/fonts/fraunces-latin-600.woff2') format('woff2');
}

@font-face {
  font-family: 'Outfit';
  font-style: normal;
  font-weight: 300 700;
  font-display: swap;
  src: url('/fonts/outfit-latin-var.woff2') format('woff2');
}

:root {
  color-scheme: light;
  --bg: #f5efe6;
  --surface: #faf6ee;
  --elev: #fcfcfc;
  --text: #2c241b;
  --text-2: #6b5c4c;
  --text-3: #9a8a7a;
  --line: #e8ddd0;
  --line-soft: #ede5d8;
  --fill: rgba(44, 36, 27, 0.06);
  --hover: rgba(44, 36, 27, 0.04);
  --accent: #111111;
  --accent-hover: #333333;
  --accent-contrast: #faf6ee;
  --red: #c53030;
  --rose: #b23a48;
  --orange: #9a6700;
  --yellow: #8a6d00;
  --lime: #5f7d00;
  --green: #2d8a56;
  --teal: #0f766e;
  --cyan: #0e7490;
  --blue: #2f6f9f;
  --indigo: #4f46a3;
  --purple: #6b46a3;
  --pink: #c2185b;
  --brown: #8a6a4a;
  --slate: #5b6b7a;
  --gray: #8a8a8a;
  --shadow-card: 0 1px 2px rgba(44, 36, 27, 0.04);
  --radius: 14px;
  --radius-sm: 6px;
  --control-height: 40px;
  --settings-control-width: 170px;
  --sidebar-width: 280px;
  --list-red: var(--red);
  --list-rose: var(--rose);
  --list-orange: var(--orange);
  --list-yellow: var(--yellow);
  --list-lime: var(--lime);
  --list-green: var(--green);
  --list-teal: var(--teal);
  --list-cyan: var(--cyan);
  --list-blue: var(--blue);
  --list-indigo: var(--indigo);
  --list-purple: var(--purple);
  --list-pink: var(--pink);
  --list-brown: var(--brown);
  --list-slate: var(--slate);
  --list-gray: var(--gray);
}

[data-theme="dark"] {
  color-scheme: dark;
  --bg: #000000;
  --surface: #101010;
  --elev: #1c1c1c;
  --text: #e4e4e4;
  --text-2: #a0a0a0;
  --text-3: #737373;
  --line: #2a2a2a;
  --line-soft: #1e1e1e;
  --fill: rgba(228, 228, 228, 0.07);
  --hover: rgba(228, 228, 228, 0.05);
  --accent: #f5f5f5;
  --accent-hover: #cccccc;
  --accent-contrast: #101010;
  --red: #f87171;
  --rose: #fda4af;
  --orange: #fbbf24;
  --yellow: #fde047;
  --lime: #d9f99d;
  --green: #4ade80;
  --teal: #5eead4;
  --cyan: #67e8f9;
  --blue: #7cb3e0;
  --indigo: #a5b4fc;
  --purple: #a78bfa;
  --pink: #f9a8d4;
  --brown: #c9a27e;
  --slate: #94a3b8;
  --gray: #9a9a9a;
  --shadow-card: none;
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
}

body {
  font-family: 'Outfit', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: contain;
  overflow: hidden;
}

[hidden] { display: none !important; }

button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }

button, a, input, select, textarea, [tabindex] { touch-action: manipulation; }

.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.ic { width: 22px; height: 22px; flex: none; }

/* ---------- Auth ---------- */

.auth {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 24px;
  background: var(--bg);
}

.auth-card {
  width: min(300px, 100%);
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.auth-brand {
  display: flex;
  align-items: center;
  gap: 9px;
  margin-bottom: 10px;
}

.auth-mark { border-radius: 8px; }

.auth-card h1 {
  margin: 0;
  font-family: 'Fraunces', serif;
  font-size: 1.0625rem;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.auth-sub {
  margin: 0 0 2px;
  font-size: 0.8rem;
  color: var(--text-2);
}

.auth-card input {
  width: 100%;
  height: var(--control-height);
  min-height: var(--control-height);
  background: var(--elev);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font-size: 0.875rem;
  color: var(--text);
}

.auth-card input::placeholder { color: var(--text-3); }
.auth-card input:focus { outline: none; border-color: var(--accent); }

.auth-error {
  margin: 0;
  font-size: 0.78rem;
  color: var(--red);
}

.primary-btn {
  border: 0;
  border-radius: 5px;
  padding: 9px 16px;
  background: var(--accent);
  color: var(--accent-contrast);
  font-weight: 550;
  font-size: 0.875rem;
  min-height: 36px;
}

.primary-btn:hover { background: var(--accent-hover); }
.primary-btn:disabled { opacity: 0.4; cursor: not-allowed; }

.secondary-btn {
  border: 1px solid var(--line);
  border-radius: 5px;
  padding: 8px 16px;
  background: transparent;
  color: var(--text-2);
  font-weight: 550;
  font-size: 0.8125rem;
  min-height: 34px;
}

.secondary-btn:hover { background: var(--fill); color: var(--text); }
.danger-text { color: var(--red); }

/* ---------- Shell ---------- */

.shell {
  display: flex;
  height: 100dvh;
  width: 100%;
}

.sidebar {
  width: var(--sidebar-width);
  flex: none;
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 18px 12px calc(14px + env(safe-area-inset-bottom));
  background: var(--surface);
  border-right: 1px solid var(--line-soft);
  overflow-y: auto;
}

.sidebar-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0;
}

.sidebar-head-actions {
  display: flex;
  align-items: center;
  /* Same gap as .main-head so refresh/menu sit at identical coordinates
     on Home and detail. */
  gap: 12px;
}

#sidebar-menu-btn { display: grid; }

.wordmark {
  margin: 0;
  font-family: 'Fraunces', serif;
  font-size: 1.375rem;
  font-weight: 600;
  letter-spacing: -0.025em;
}

.icon-btn {
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 5px;
  background: transparent;
  color: var(--text-2);
  transition: all 0.15s;
}

.icon-btn:hover { background: var(--fill); color: var(--text); }
.icon-btn .ic { width: 16px; height: 16px; }
.icon-btn.small { width: 26px; height: 26px; }
.icon-btn.small .ic { width: 14px; height: 14px; }

.refresh-btn { flex: none; }
.refresh-btn:disabled { opacity: 0.45; }
.refresh-btn.loading .ic { animation: spin 0.7s linear infinite; transform-origin: center; }

@keyframes spin {
  to { transform: rotate(360deg); }
}

@media (prefers-reduced-motion: reduce) {
  .refresh-btn.loading .ic { animation: none; }
}

.search {
  position: relative;
  display: flex;
  align-items: center;
  margin: 10px 0 0;
}

.search-ic {
  position: absolute;
  left: 10px;
  width: 16px;
  height: 16px;
  color: var(--text-3);
  pointer-events: none;
}

.search input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 7px 10px 7px 32px;
  background: var(--elev);
  color: var(--text);
  font-size: 0.8125rem;
  -webkit-appearance: none;
  appearance: none;
  appearance: none;
}

.search input::placeholder { color: var(--text-3); }
.search input:focus { outline: none; border-color: var(--accent); }
.search input::-webkit-search-cancel-button { -webkit-appearance: none; }

.nav { display: flex; flex-direction: column; gap: 1px; }

.nav-row, .list-row {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  border: 0;
  border-radius: 5px;
  padding: 6px 8px;
  background: transparent;
  text-align: left;
  font-size: 0.875rem;
  color: var(--text);
}

.nav-row:hover, .list-row:hover { background: var(--hover); }
.nav-row.active, .list-row.active { background: var(--fill); }

.nav-ic {
  width: 22px;
  height: 22px;
  flex: none;
  display: grid;
  place-items: center;
  color: var(--text-3);
}

.nav-ic .ic { width: 17px; height: 17px; }
.nav-row.active .nav-ic { color: var(--accent); }

.nav-row::after {
  content: "";
  width: 22px;
  height: 22px;
  flex: none;
}

.nav-label { flex: 1; font-weight: 500; padding-left: 2px; }
.nav-row.active .nav-label { font-weight: 600; }

.badge {
  min-width: 20px;
  text-align: right;
  font-size: 0.72rem;
  font-weight: 500;
  color: var(--text-3);
  font-variant-numeric: tabular-nums;
}

.new-list-btn {
  border: 0;
  background: transparent;
  padding: 3px 2px;
  color: var(--text-2);
  font-family: inherit;
  font-size: 0.75rem;
  font-weight: 550;
  text-transform: none;
  letter-spacing: 0;
}

.new-list-btn:hover { color: var(--text); }

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 6px 0 0;
  margin-top: 2px;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.lists { display: flex; flex-direction: column; gap: 1px; }

.list-row .list-dot {
  width: 12px;
  height: 12px;
  flex: none;
  border-radius: 50%;
  background: var(--c);
  margin: 0 10px 0 0;
}

.list-row .list-name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 500;
}

/* Apple-style list rows: divider between every row and a tall,
   fat-finger-proof touch target. */
.list-row {
  min-height: 56px;
  padding: 12px 8px;
  border-bottom: 1px solid var(--line-soft);
  border-radius: 0;
}

.list-row .list-dot {
  width: 14px;
  height: 14px;
}

.list-row .badge { font-size: 0.8125rem; }

.list-grip {
  width: 22px;
  height: 22px;
  flex: none;
  display: grid;
  place-items: center;
  border-radius: 5px;
  color: var(--text-3);
  opacity: 0.55;
  cursor: grab;
  touch-action: none;
  transition: opacity 0.15s, background 0.15s;
}

.list-grip .ic { width: 15px; height: 15px; }
.list-row:hover .list-grip { opacity: 0.9; }
.list-row:focus-visible .list-grip { opacity: 1; }
.list-grip:hover { background: var(--fill); }

.list-lock {
  width: 22px;
  height: 22px;
  flex: none;
  display: grid;
  place-items: center;
  color: var(--text-3);
  opacity: 0.5;
}
.list-lock .ic { width: 14px; height: 14px; }

.list-row.dragging {
  opacity: 0.3;
  background: var(--fill);
}

.list-row.drop-before { box-shadow: inset 0 2px 0 var(--accent); }
.list-row.drop-after { box-shadow: inset 0 -2px 0 var(--accent); }

.list-drag-ghost {
  position: fixed;
  z-index: 100;
  margin: 0;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: var(--surface);
  box-shadow: 0 12px 34px rgba(0, 0, 0, 0.26);
  opacity: 0.97;
  pointer-events: none;
}

.list-drag-ghost .list-grip { opacity: 0.75; }

body.list-dragging {
  user-select: none;
  cursor: grabbing;
}

body.list-dragging .list-grip { cursor: grabbing; }

@media (hover: none) {
  .list-grip { opacity: 0.55; }
}

.sidebar-foot {
  margin-top: auto;
  padding-top: 10px;
  border-top: 1px solid var(--line-soft);
  display: none;
  flex-direction: column;
  gap: 1px;
}

.text-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  border: 0;
  background: transparent;
  padding: 6px 8px;
  border-radius: 5px;
  font-size: 0.8125rem;
  color: var(--text-2);
  text-align: left;
  transition: all 0.15s;
}

.text-btn:hover { background: var(--hover); color: var(--text); }
.text-btn .foot-ic {
  width: 22px;
  height: 22px;
  flex: none;
  display: grid;
  place-items: center;
  color: var(--text-3);
}
.text-btn .foot-ic .ic { width: 17px; height: 17px; }

/* ---------- Main ---------- */

.main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  /* Same canvas as Home so both screens share one background. */
  background: var(--surface);
}

.main-head {
  width: 100%;
  max-width: 860px;
  margin: 0 auto;
  padding: 22px 36px 10px;
  display: flex;
  align-items: flex-end;
  gap: 12px;
}

.back-btn {
  display: none;
  align-items: center;
  gap: 2px;
  border: 0;
  background: transparent;
  color: var(--text-2);
  font-size: 0.875rem;
  padding: 6px 0;
  margin-right: -6px;
}

.back-btn .ic { width: 18px; height: 18px; }
.back-btn:hover { color: var(--text); }

.title-wrap {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: baseline;
  gap: 10px;
}

.title-wrap h2 {
  margin: 0;
  font-family: 'Fraunces', serif;
  font-size: 1.375rem;
  font-weight: 600;
  font-optical-sizing: none;
  font-variation-settings: 'opsz' 22;
  letter-spacing: -0.025em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.view-count {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-3);
  font-variant-numeric: tabular-nums;
}

.main-search { display: none; }

.sort-bar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 5px 12px;
  width: auto;
  max-width: 100%;
  margin: 8px 24px 0;
  padding: 0;
  font-size: 0.75rem;
  color: var(--text-3);
}

.sort-control {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  border: 0;
  background: transparent;
  padding: 0;
  flex: none;
}

.sort-control > span {
  flex: none;
  font-size: 0.75rem;
  font-weight: 500;
  letter-spacing: 0;
  text-transform: none;
  color: var(--text-3);
}

.sort-control select {
  width: auto;
  max-width: 150px;
  border: 0;
  background: transparent;
  color: var(--text-2);
  font-size: 0.75rem;
  padding: 0 2px;
}

.sort-control select:focus { outline: none; color: var(--text); }

.content {
  flex: 1;
  width: 100%;
  max-width: 860px;
  margin: 0 auto;
  padding: 16px 36px 120px;
  overflow-y: auto;
  overscroll-behavior: contain;
}

/* ---------- Reminders ---------- */

.reminder-group {
  background: var(--surface);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 14px;
}

.reminder {
  position: relative;
  overflow: hidden;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
  cursor: pointer;
  touch-action: pan-y;
}

.reminder:last-child { border-bottom: 0; }

/* Swipe layer: the content slides left, revealing Delete underneath.
   (Completion lives on the checkbox, so there is no Done swipe action.) */
.swipe-bg {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: stretch;
  justify-content: flex-end;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.12s ease;
}

/* Never show the action color through a resting row's edge. It appears only
   while the card is actually being swiped or parked open. */
.reminder.swipe-active .swipe-bg,
.reminder.swipe-open .swipe-bg { opacity: 1; }

.swipe-act {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0 18px;
  color: #ffffff;
  font-family: inherit;
  font-size: 0.8125rem;
  font-weight: 600;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
  white-space: nowrap;
  border: 0;
  cursor: pointer;
  pointer-events: auto;
}

.swipe-act .ic { width: 18px; height: 18px; }
.swipe-act.del { background: var(--red); width: min(140px, 45%); justify-content: flex-end; }

.swipe-content {
  position: relative;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  min-height: 64px;
  padding: 14px;
  background: var(--surface);
  transition: transform 0.18s ease;
  will-change: transform;
}

.swipe-content.swiping { transition: none; user-select: none; -webkit-user-select: none; }

.reminder:hover .swipe-content { background: var(--elev); }

.check {
  flex: none;
  width: 22px;
  height: 22px;
  margin-top: 1px;
  padding: 0;
  border: 1.6px solid var(--text-3);
  border-radius: 50%;
  background: transparent;
  color: var(--accent-contrast);
  display: grid;
  place-items: center;
  transition: all 0.15s;
}

.reminder:hover .check { border-color: var(--c); }

.row-delete {
  flex: none;
  align-self: center;
  min-width: 30px;
  height: 30px;
  padding: 0;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--text-3);
  font-family: inherit;
  font-size: 0.75rem;
  font-weight: 600;
  opacity: 0;
  transition: opacity 0.15s, background 0.15s, color 0.15s, width 0.15s, padding 0.15s;
}

.row-delete .ic { width: 15px; height: 15px; }

.reminder:hover .row-delete,
.row-delete:focus-visible { opacity: 0.8; }

.row-delete:hover { background: color-mix(in srgb, var(--red) 12%, transparent); color: var(--red); opacity: 1; }

.row-delete.confirming {
  width: auto;
  padding: 0 12px;
  background: color-mix(in srgb, var(--red) 14%, transparent);
  color: var(--red);
  opacity: 1;
}

/* Deleting collapses the row after the inline confirm. */
.reminder.removing {
  overflow: hidden;
  transition: height 0.22s ease, opacity 0.18s ease;
}

.reminder.removing .swipe-content {
  transform: translateX(-100%);
  opacity: 0;
}

@media (hover: none) {
  .row-delete { display: none; }
}

.check .ic { width: 13px; height: 13px; opacity: 0; }
.reminder.done .check { background: var(--c); border-color: var(--c); }
.reminder.done .check .ic { opacity: 1; }
.reminder.done .reminder-title { text-decoration: line-through; color: var(--text-3); }

.reminder-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }

.reminder-title {
  font-size: 0.9375rem;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.reminder-meta {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  font-size: 0.75rem;
  color: var(--text-3);
}

.meta-list { display: inline-flex; align-items: center; gap: 5px; }

.meta-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--c);
}

.meta-due { display: inline-flex; align-items: center; gap: 5px; font-weight: 550; }
.meta-due .ic { width: 12px; height: 12px; }
.meta-due.overdue {
  color: var(--red);
  font-weight: 700;
  background: color-mix(in srgb, var(--red) 10%, transparent);
  border-radius: 4px;
  padding: 1px 6px;
}
.meta-urgent { display: inline-flex; align-items: center; gap: 5px; color: var(--red); }
.meta-urgent .ic { width: 12px; height: 12px; }
.meta-repeat { display: inline-flex; align-items: center; gap: 5px; }
.meta-repeat .ic { width: 12px; height: 12px; }
.meta-model { display: inline-flex; align-items: center; color: var(--text-3); }
.meta-edited { font-style: italic; }
.meta-snoozed { display: inline-flex; align-items: center; gap: 5px; }
.meta-snoozed .ic { width: 12px; height: 12px; }

.reminder-notes {
  font-size: 0.75rem;
  line-height: 1.4;
  color: var(--text-2);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  white-space: normal;
  overflow-wrap: anywhere;
}

.reminder-links {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 3px;
}

.link-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  max-width: 180px;
  margin: 0 2px;
  padding: 1px 8px 1px 6px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--text) 8%, transparent);
  color: var(--text-2);
  font-size: 0.72rem;
  font-weight: 550;
  text-decoration: none;
  vertical-align: -3px;
}

.link-chip .ic { width: 12px; height: 12px; flex: none; }

.link-chip .link-domain {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.link-chip:hover { color: var(--text); }

.row-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-top: 6px;
}

.row-actions-label {
  flex-basis: 100%;
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-3);
}

.mini-btn {
  border: 1px solid var(--line);
  border-radius: 999px;
  background: transparent;
  color: var(--text-2);
  font-size: 0.75rem;
  font-weight: 550;
  padding: 6px 12px;
  min-height: 32px;
}

.mini-btn:hover { background: var(--fill); color: var(--text); }

.group-title {
  margin: 22px 0 4px;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.overdue-title { color: var(--red); }

.toggle-completed {
  display: block;
  width: 100%;
  border: 0;
  background: transparent;
  color: var(--text-2);
  text-align: left;
  font-size: 0.8125rem;
  padding: 12px 14px;
}

.toggle-completed:hover { color: var(--text); }

.empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 64px 20px;
  color: var(--text-3);
  text-align: center;
}

.empty .ic { width: 36px; height: 36px; opacity: 0.6; }
.empty-heading { margin: 4px 0 0; font-family: 'Fraunces', serif; font-size: 1.0625rem; color: var(--text); }
.empty p { margin: 0; font-size: 0.875rem; max-width: 300px; }
.empty .primary-btn { margin-top: 8px; }

/* ---------- Floating add button ---------- */

.fab {
  position: fixed;
  right: 28px;
  bottom: calc(28px + env(safe-area-inset-bottom));
  z-index: 40;
  width: 56px;
  height: 56px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 50%;
  background: var(--accent);
  color: var(--accent-contrast);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18), 0 2px 6px rgba(0, 0, 0, 0.12);
  transition: background 0.15s, transform 0.15s, box-shadow 0.15s, opacity 0.15s;
}

body.sheet-open .fab {
  opacity: 0;
  pointer-events: none;
}

.fab:hover {
  background: var(--accent-hover);
  transform: translateY(-1px);
  box-shadow: 0 11px 28px rgba(0, 0, 0, 0.2), 0 3px 7px rgba(0, 0, 0, 0.14);
}

.fab:active { transform: scale(0.95); }
.fab .ic { width: 26px; height: 26px; }

@media (prefers-reduced-motion: reduce) {
  .fab, .fab:hover, .fab:active { transition: none; transform: none; }
}

/* ---------- Sheets ---------- */

.sheet {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.sheet-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  touch-action: none;
}

/* With any sheet open the page behind is fully locked: fixed body (the
   iOS-proof part — overflow:hidden alone doesn't stop touch scrolling),
   hidden background scrollers, and no scroll chaining out of the sheet. */
body.sheet-open {
  position: fixed;
  inset: 0;
  width: 100%;
  overscroll-behavior: none;
}

body.sheet-open .content,
body.sheet-open .sidebar {
  overflow: hidden;
}

.sheet-card {
  position: relative;
  width: min(560px, 100%);
  max-height: min(88dvh, 780px);
  overflow-y: auto;
  overscroll-behavior: contain;
  background: var(--elev);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.28);
  animation: pop 0.16s ease-out;
}

@keyframes pop {
  from { opacity: 0; transform: scale(0.98) translateY(4px); }
  to { opacity: 1; transform: none; }
}

.sheet-head {
  position: sticky;
  top: 0;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 13px 16px;
  background: var(--elev);
  border-bottom: 1px solid var(--line-soft);
  font-size: 0.875rem;
  font-weight: 600;
}

.sheet-head .text-btn { padding: 4px 2px; color: var(--text-2); font-size: 0.8125rem; }
.sheet-head .text-btn:hover { background: transparent; color: var(--text); }
.sheet-head .strong { color: var(--accent); font-weight: 600; }

.sheet-body {
  padding: 16px 18px calc(20px + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.e-title {
  border: 1px solid var(--line);
  background: var(--elev);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font-size: 0.9375rem;
  font-weight: 500;
}

.e-title:focus, .e-notes:focus { outline: none; border-color: var(--accent); }

#l-name { height: var(--control-height); min-height: var(--control-height); }
#l-name:disabled { opacity: 0.65; cursor: default; }

.e-notes {
  border: 1px solid var(--line);
  background: var(--elev);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font-size: 0.875rem;
  resize: vertical;
  min-height: 64px;
}

/* ---------- Reminder editor ---------- */

.editor-card { max-height: min(92dvh, 820px); }

#editor .editor-head {
  background: var(--elev);
  border-bottom: 0;
  padding: 12px 16px 4px;
}

.editor-head > span {
  font-size: 0.9375rem;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.round-btn {
  width: 34px;
  height: 34px;
  flex: none;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 50%;
  background: color-mix(in srgb, var(--text) 10%, transparent);
  color: var(--text-2);
  transition: background 0.15s, color 0.15s;
}

.round-btn:hover {
  background: color-mix(in srgb, var(--text) 16%, transparent);
  color: var(--text);
}

.round-btn .ic { width: 17px; height: 17px; }
.round-btn.save { color: var(--accent); }

#editor .editor-body {
  gap: 18px;
  padding: 10px 18px calc(26px + env(safe-area-inset-bottom));
}

.editor-fields {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

#editor .e-title,
#editor .e-notes {
  background: color-mix(in srgb, var(--text) 7%, transparent);
  border: 0;
  border-radius: 12px;
  padding: 13px 15px;
}

#editor .e-title {
  font-size: 1.0625rem;
  font-weight: 550;
  line-height: 1.35;
  min-height: 64px;
  max-height: 40dvh;
  resize: none;
  overflow-y: auto;
}

#editor .e-title::placeholder,
#editor .e-notes::placeholder {
  color: var(--text-3);
  font-weight: 400;
}

#editor .e-notes {
  min-height: 48px;
  max-height: 30dvh;
  font-size: 0.9375rem;
  resize: none;
  overflow-y: auto;
}

#editor .e-title:focus,
#editor .e-notes:focus {
  outline: none;
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 45%, transparent);
}

.ed-note-links {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 0 4px;
}

.ed-note-links a {
  color: var(--accent);
  font-size: 0.8125rem;
  text-decoration: underline;
  text-underline-offset: 2px;
  overflow-wrap: anywhere;
}

.ed-section {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.ed-section-label {
  padding: 0 4px;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  color: var(--text-3);
}

.ed-group {
  background: color-mix(in srgb, var(--text) 6%, transparent);
  border-radius: 14px;
  overflow: hidden;
}

.ed-row {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 50px;
  padding: 10px 14px;
  border: 0;
  background: transparent;
  text-align: left;
  font-size: 0.9375rem;
  color: var(--text);
}

.ed-row + .ed-row,
.ed-subrow + .ed-row {
  border-top: 1px solid color-mix(in srgb, var(--text) 7%, transparent);
}

.ed-ic {
  width: 22px;
  height: 22px;
  flex: none;
  display: grid;
  place-items: center;
  color: var(--text-3);
}

.ed-ic .ic { width: 19px; height: 19px; }
.ed-label { flex: 1; min-width: 0; }

.ed-value {
  max-width: 46%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text-3);
  font-size: 0.875rem;
}

.ed-chevron {
  width: 15px;
  height: 15px;
  flex: none;
  color: var(--text-3);
}

.ed-switch {
  position: relative;
  flex: none;
  width: 46px;
  height: 28px;
  cursor: pointer;
}

.ed-switch input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  opacity: 0;
  cursor: pointer;
}

.ed-switch span {
  display: block;
  pointer-events: none;
  width: 100%;
  height: 100%;
  border-radius: 999px;
  background: color-mix(in srgb, var(--text) 26%, transparent);
  transition: background 0.18s;
}

.ed-switch span::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--elev);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.28);
  transition: transform 0.18s;
}

.ed-switch input:checked + span { background: var(--accent); }
.ed-switch input:checked + span::after { transform: translateX(18px); }
.ed-switch input:focus-visible + span { box-shadow: 0 0 0 2px var(--accent); }

.ed-group,
.ed-row,
.ed-subrow,
.editor-body {
  min-width: 0;
}

.ed-subrow {
  display: flex;
  align-items: center;
  padding: 0 14px 10px 48px;
}

.ed-subrow input[type="date"],
.ed-subrow input[type="time"] {
  flex: 1 1 auto;
  width: auto;
  max-width: 100%;
  min-width: 0;
  height: var(--control-height);
  border: 0;
  border-radius: 8px;
  background: color-mix(in srgb, var(--text) 7%, transparent);
  padding: 7px 10px;
  color: var(--text);
  font-size: 0.9375rem;
}

.ed-subrow input[type="date"]::-webkit-calendar-picker-indicator,
.ed-subrow input[type="time"]::-webkit-calendar-picker-indicator {
  width: 18px;
  height: 18px;
}

.ed-subrow input:focus {
  outline: none;
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 45%, transparent);
}

.ed-hint {
  margin: -2px 4px 0;
  font-size: 0.75rem;
  line-height: 1.4;
  color: var(--text-3);
}

.ed-list-row { cursor: pointer; }

.ed-list-row select {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
  background: transparent;
  opacity: 0;
  cursor: pointer;
}

.ed-list-ic {
  width: 28px;
  height: 28px;
  flex: none;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: var(--c, var(--blue));
  color: var(--accent-contrast);
}

.ed-list-ic .ic { width: 17px; height: 17px; }

.editor-delete { width: 100%; margin: 0; }

.parse-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  border: 1px dashed color-mix(in srgb, var(--accent) 45%, transparent);
  border-radius: 12px;
  background: transparent;
  color: var(--text-2);
  font-size: 0.8125rem;
  padding: 9px 12px;
  text-align: left;
}

.parse-chip span { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.parse-chip .ic { width: 14px; height: 14px; flex: none; }

.ed-select-row { cursor: pointer; }

.ed-select-row select {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
  background: transparent;
  opacity: 0;
  cursor: pointer;
  font-size: 16px;
}

.ed-repeat-custom {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-2);
  font-size: 0.875rem;
}

.ed-repeat-custom input[type="number"],
.ed-repeat-custom select {
  height: var(--control-height);
  border: 0;
  border-radius: 9px;
  background: color-mix(in srgb, var(--text) 7%, transparent);
  padding: 0 11px;
  color: var(--text);
  font-size: 0.9375rem;
}

.ed-repeat-custom input[type="number"] { width: 72px; flex: none; }
.ed-repeat-custom select { flex: 1; }

.segmented {
  display: flex;
  gap: 2px;
  background: color-mix(in srgb, var(--text) 8%, transparent);
  border-radius: 8px;
  padding: 2px;
}

.segmented-btn {
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--text-2);
  font-size: 0.75rem;
  font-weight: 550;
  padding: 6px 10px;
}

.segmented-btn.active { background: var(--elev); color: var(--text); box-shadow: 0 1px 2px rgba(0, 0, 0, 0.12); }

.ed-history { display: flex; flex-direction: column; gap: 4px; padding: 0 4px; }

.history-row {
  display: flex;
  align-items: baseline;
  gap: 10px;
  font-size: 0.8125rem;
  color: var(--text-2);
}

.history-status { font-weight: 600; min-width: 74px; }
.history-empty { margin: 0; font-size: 0.8125rem; color: var(--text-3); }

.danger-btn {
  margin-top: 6px;
  border: 1px solid color-mix(in srgb, var(--red) 35%, var(--line));
  border-radius: var(--radius-sm);
  padding: 10px;
  background: transparent;
  color: var(--red);
  font-size: 0.8125rem;
  font-weight: 550;
}

.danger-btn:hover { background: color-mix(in srgb, var(--red) 8%, transparent); }

.swatches {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 12px;
  padding: 10px 4px;
}

.swatch {
  width: 30px;
  height: 30px;
  justify-self: center;
  border: 0;
  border-radius: 50%;
  background: var(--c);
  box-shadow: inset 0 0 0 2px transparent;
}

.swatch.selected { box-shadow: 0 0 0 2px var(--elev), 0 0 0 4px var(--text); }

.section-empty {
  margin: 0;
  padding: 8px 10px;
  font-size: 0.8125rem;
  color: var(--text-3);
}

.notify-status { margin: 2px 0 6px; font-size: 0.875rem; }
.notify-hint { margin: 0 0 6px; font-size: 0.8125rem; color: var(--text-2); line-height: 1.45; }
.sheet-body .secondary-btn { margin-top: 4px; }

/* ---------- Settings ---------- */

.settings-group {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--line-soft);
}

.settings-group:last-child {
  padding-bottom: 0;
  border-bottom: 0;
}

.settings-group h3 {
  margin: 0 0 2px;
  font-family: 'Fraunces', serif;
  font-size: 0.9375rem;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.settings-group input {
  height: var(--control-height);
  min-height: var(--control-height);
  border: 1px solid var(--line);
  background: var(--elev);
  border-radius: var(--radius-sm);
  padding: 9px 12px;
  font-size: 0.875rem;
  color: var(--text);
}

.settings-group input::placeholder { color: var(--text-3); }
.settings-group input:focus { outline: none; border-color: var(--accent); }
.settings-group .primary-btn { margin-top: 2px; }

.theme-toggle-row {
  display: flex;
  gap: 2px;
  background: var(--fill);
  border-radius: 6px;
  padding: 2px;
  width: fit-content;
}

.theme-option-btn {
  padding: 5px 14px;
  border: none;
  border-radius: 4px;
  background: transparent;
  color: var(--text-2);
  font-size: 0.72rem;
  font-weight: 550;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.15s;
}

.theme-option-btn:hover { color: var(--text); }
.theme-option-btn.active { background: var(--accent); color: var(--accent-contrast); }

.settings-note {
  margin: 0;
  padding: 10px 12px;
  border: 1px solid color-mix(in srgb, var(--accent) 22%, var(--line));
  border-radius: 8px;
  background: color-mix(in srgb, var(--accent) 6%, transparent);
  font-size: 0.8125rem;
  line-height: 1.45;
  color: var(--text-2);
}

.settings-note strong { color: var(--text); }

.settings-row {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: var(--control-height);
  font-size: 0.875rem;
  color: var(--text);
}

.settings-row > span { flex: 1; min-width: 0; }

.settings-row select,
.settings-row input[type="time"],
.settings-row input[type="number"],
.settings-row input[type="text"] {
  flex: 0 0 var(--settings-control-width);
  width: var(--settings-control-width);
  height: var(--control-height);
  border: 1px solid var(--line);
  background: var(--elev);
  border-radius: var(--radius-sm);
  padding: 0 10px;
  font-size: 0.875rem;
  color: var(--text);
  text-align: left;
}

.settings-row input[type="checkbox"] {
  width: 22px;
  height: 22px;
  flex: none;
  margin: 0;
  accent-color: var(--accent);
}

.settings-row input:focus, .settings-row select:focus { outline: none; border-color: var(--accent); }

.token-once {
  border: 1px dashed color-mix(in srgb, var(--accent) 45%, transparent);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.token-value {
  margin: 0;
  font-family: ui-monospace, monospace;
  font-size: 0.75rem;
  overflow-wrap: anywhere;
  user-select: all;
}

.token-list { display: flex; flex-direction: column; gap: 6px; }

.token-row {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.8125rem;
}

.token-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 550; }
.token-meta { color: var(--text-3); font-size: 0.75rem; }

.small-btn { padding: 6px 12px; min-height: 32px; font-size: 0.75rem; }

.token-examples { font-size: 0.8125rem; color: var(--text-2); }

.token-examples summary { cursor: pointer; font-weight: 550; }

.token-examples pre {
  margin: 8px 0 0;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: color-mix(in srgb, var(--text) 6%, transparent);
  font-size: 0.7rem;
  line-height: 1.5;
  overflow-x: auto;
  white-space: pre;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.form-msg {
  margin: 0;
  font-size: 0.78rem;
  color: var(--red);
}

.form-msg.ok { color: var(--green); }

/* ---------- Toast ---------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(28px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  z-index: 80;
  max-width: min(420px, calc(100% - 32px));
  padding: 10px 15px;
  border-radius: var(--radius-sm);
  background: var(--accent);
  color: var(--accent-contrast);
  font-size: 0.8125rem;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.22);
  animation: toast-in 0.18s ease-out;
}

@keyframes toast-in {
  from { opacity: 0; transform: translate(-50%, 8px); }
  to { opacity: 1; transform: translate(-50%, 0); }
}

/* ---------- Mobile ---------- */

#menu-btn { display: grid; }

.account-menu {
  position: fixed;
  top: calc(56px + env(safe-area-inset-top));
  right: 12px;
  z-index: 70;
  min-width: 210px;
  padding: 6px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  background: var(--elev);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.22);
}

.account-menu .text-btn { width: 100%; }

/* ---------- Desktop: mirror the mobile Home ---------- */
@media (min-width: 900px) {
  html, body { height: 100%; }
  body { overflow: hidden; overscroll-behavior-y: contain; }

  .shell { display: flex; height: 100dvh; min-height: 0; }

  .sidebar {
    position: static;
    width: min(54vw, 990px);
    height: 100%;
    margin: 0 auto;
    border-right: 0;
    padding: 18px 24px calc(96px + env(safe-area-inset-bottom));
    z-index: auto;
    transform: none;
    transition: none;
    overflow-y: auto;
    scrollbar-width: none;
    -ms-overflow-style: none;
  }

  .sidebar::-webkit-scrollbar { display: none; width: 0; height: 0; }

  body[data-screen="home"] .sidebar { display: flex; }
  body[data-screen="home"] .main { display: none; }
  body[data-screen="detail"] .sidebar { display: none; }
  body[data-screen="detail"] .main { display: flex; }

  .sidebar .sidebar-foot { display: none; }

  .main {
    width: min(54vw, 990px);
    min-height: 0;
    margin: 0 auto;
    display: flex;
    flex: none;
  }

  .main-head {
    position: static;
    max-width: none;
    padding: 18px 24px 10px;
    align-items: center;
  }

  .back-btn { display: flex; }
  body[data-screen="home"] .back-btn { display: none; }
  .back-btn span { display: inline; }

  #menu-btn { display: grid; }
  #sidebar-menu-btn { display: grid; }

  .main-search {
    display: flex;
    align-items: center;
    position: relative;
    margin: 0 24px 0;
  }

  .main-search .search-ic { left: 10px; width: 16px; height: 16px; }

  .main-search input {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    padding: 7px 10px 7px 32px;
    background: var(--elev);
    color: var(--text);
    font-size: 0.8125rem;
    -webkit-appearance: none;
    appearance: none;
  }

  .main-search input::placeholder { color: var(--text-3); }
  .main-search input:focus { outline: none; border-color: var(--accent); }
  .main-search input::-webkit-search-cancel-button { -webkit-appearance: none; }

  .sort-bar { margin: 8px 24px 0; }

  .account-menu {
    right: max(12px, calc((100vw - min(54vw, 990px)) / 2 + 12px));
  }

  .fab {
    right: max(28px, calc((100vw - min(54vw, 990px)) / 2 + 28px));
  }

  .content {
    width: 100%;
    max-width: none;
    margin: 0;
    padding: 12px 24px calc(132px + env(safe-area-inset-bottom));
    overflow-y: auto;
  }
}

/* ---------- Compact density (opt-in) ---------- */

[data-density="compact"] .list-row { min-height: 0; padding: 6px 8px; }
[data-density="compact"] .swipe-content { min-height: 0; padding: 8px 12px; gap: 10px; }
[data-density="compact"] .reminder-title { font-size: 0.875rem; }
[data-density="compact"] .reminder-meta { font-size: 0.7rem; gap: 8px; }
[data-density="compact"] .reminder-notes { font-size: 0.7rem; }
[data-density="compact"] .check { width: 20px; height: 20px; }
[data-density="compact"] .content { padding-top: 10px; }
[data-density="compact"] .group-title { margin-top: 14px; }

@media (max-width: 899px) {
  .sidebar {
    position: static;
    width: 100%;
    height: 100%;
    border-right: 0;
    padding-top: calc(14px + env(safe-area-inset-top));
    padding-left: 18px;
    padding-right: 18px;
    padding-bottom: calc(96px + env(safe-area-inset-bottom));
    z-index: auto;
    transform: none;
    overflow-y: auto;
    scrollbar-width: none;
    -ms-overflow-style: none;
  }

  .sidebar::-webkit-scrollbar { display: none; width: 0; height: 0; }

  /* Mobile home is the full-screen list panel: search, smart views, My Lists,
     then the lists. The footer actions live in the hamburger menu. */
  body[data-screen="home"] .sidebar { display: flex; padding-top: 0; }
  body[data-screen="home"] .main { display: none; }
  body[data-screen="detail"] .sidebar { display: none; }
  body[data-screen="detail"] .main { display: flex; }

  /* Only the header + search stay frozen; everything below scrolls as one
     page (no nested list scroller). The top padding lives on the sticky
     wrapper so stuck and unstuck geometry match exactly. */
  .sidebar-top {
    position: sticky;
    top: 0;
    z-index: 5;
    background: var(--surface);
    padding-top: calc(14px + env(safe-area-inset-top));
  }

  .sidebar .sidebar-foot { display: none; }

  .back-btn { display: flex; }
  body[data-screen="home"] .back-btn { display: none; }

  #menu-btn { display: grid; }
  #sidebar-menu-btn { display: grid; }

  .list-row { -webkit-touch-callout: none; user-select: none; }

  /* Home and detail headers share the same height so the menu button never
     shifts vertically when opening a list. */
  .sidebar-head, .main-head { min-height: 33px; }
  .sidebar-head { align-items: flex-start; }

  .main-head {
    flex-wrap: wrap;
    align-items: center;
    row-gap: 0;
    padding: calc(14px + env(safe-area-inset-top)) 18px 10px;
  }

  .back-btn { order: 1; flex: none; padding: 6px 6px 6px 0; margin-right: 2px; }
  .back-btn span { display: none; }
  .title-wrap { order: 2; flex-direction: row; align-items: baseline; gap: 8px; }
  .title-wrap h2 { font-size: 1.375rem; }
  .view-count { font-size: 0.8125rem; }
  #view-menu { order: 3; }
  #refresh-btn { order: 4; }
  #menu-btn { order: 5; }
  /* Pin the action icons to the top edge exactly like the Home header
     actions, so they never drift when the title size changes. */
  #menu-btn, #refresh-btn { align-self: flex-start; }

  .search input, .main-search input,
  .auth-card input, .settings-group input, .e-title, .e-notes,
  #editor .e-title, #editor .e-notes,
  .ed-subrow input[type="date"], .ed-subrow input[type="time"],
  .ed-list-row select { font-size: 16px; }

  .ed-subrow {
    padding: 0 14px 12px;
    overflow: hidden;
  }

  .ed-subrow input[type="date"],
  .ed-subrow input[type="time"] {
    display: block;
    flex: 1 1 auto;
    width: auto;
    max-width: 100%;
    min-width: 0;
    margin: 0 3px;
  }

  /* The cross is a desktop affordance; on mobile just the centered label. */
  .swipe-act.del { gap: 0; padding: 0; justify-content: center; }
  .swipe-act.del .ic { display: none; }

  .main-search {
    display: flex;
    align-items: center;
    position: relative;
    margin: 0 18px 0;
  }

  .sort-bar {
    margin: 8px 18px 0;
  }

  .sort-control select {
    max-width: 130px;
    font-size: 0.75rem;
  }

  .main-search .search-ic { left: 10px; width: 16px; height: 16px; }

  .main-search input {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    padding: 7px 10px 7px 32px;
    background: var(--elev);
    color: var(--text);
    -webkit-appearance: none;
    appearance: none;
  }

  .main-search input::placeholder { color: var(--text-3); }
  .main-search input:focus { outline: none; border-color: var(--accent); }
  .main-search input::-webkit-search-cancel-button { -webkit-appearance: none; }

  .content { padding: 12px 18px calc(132px + env(safe-area-inset-bottom)); }

  .fab {
    right: 20px;
    bottom: calc(20px + env(safe-area-inset-bottom));
  }


  #editor .editor-card {
    height: 94dvh;
    max-height: 94dvh;
  }
  .swipe-content { padding: 12px 14px; }
  .reminder-title { font-size: 0.9375rem; }
  .reminder-meta { font-size: 0.75rem; }

  .sheet { align-items: flex-end; padding: 0; }
  .sheet-card {
    width: 100%;
    max-height: 92dvh;
    border-radius: var(--radius) var(--radius) 0 0;
    border-bottom: 0;
    animation: slide-up 0.2s cubic-bezier(0.22, 1, 0.36, 1);
  }

  @keyframes slide-up {
    from { transform: translateY(20px); opacity: 0.7; }
    to { transform: none; opacity: 1; }
  }

  .toast { bottom: calc(80px + env(safe-area-inset-bottom)); }
}

@media (max-width: 899px) and (prefers-reduced-motion: reduce) {
  .sheet-card, .toast { animation: none; }
}

@media (hover: none) {
  .nav-row:hover,
  .list-row:hover,
  .icon-btn:hover,
  .text-btn:hover { background: transparent; }
  .text-btn:hover { color: var(--text-2); }
  /* Keep the swipe content opaque on touch: the Delete layer sits beneath. */
  .reminder:hover .swipe-content { background: var(--surface); }
  .reminder:active .swipe-content { background: var(--elev); }
}

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

.list-grip:focus-visible { opacity: 0.9; }

::selection { background: rgba(44, 36, 27, 0.18); }
[data-theme="dark"] ::selection { background: rgba(245, 245, 245, 0.2); }
