: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;
  --fab-bg: #007aff;
  --fab-hover: #0066d6;
  --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;
  --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;
  --fab-bg: #0a84ff;
  --fab-hover: #409cff;
  --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%;
  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 6px;
}

.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: 0 4px;
}

.search-ic {
  position: absolute;
  left: 9px;
  width: 15px;
  height: 15px;
  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 30px;
  background: var(--elev);
  color: var(--text);
  font-size: 0.8125rem;
  -webkit-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-label { flex: 1; font-weight: 500; }
.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;
}

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 6px 0 10px;
  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 5px;
}

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

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

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

.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: flex;
  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;
}

.main-head {
  width: 100%;
  max-width: 860px;
  margin: 0 auto;
  padding: 22px 36px 12px;
  display: flex;
  align-items: flex-end;
  gap: 12px;
  border-bottom: 1px solid var(--line-soft);
}

.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;
  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; }

.content {
  flex: 1;
  width: 100%;
  max-width: 860px;
  margin: 0 auto;
  padding: 16px 36px 88px;
  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 {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line-soft);
  cursor: pointer;
}

.reminder:last-child { border-bottom: 0; }
.reminder:hover { background: var(--hover); }

.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); }

.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; }
.meta-due .ic { width: 12px; height: 12px; }
.meta-due.overdue { color: var(--red); }
.meta-urgent { display: inline-flex; align-items: center; gap: 5px; color: var(--red); }
.meta-urgent .ic { width: 12px; height: 12px; }

.reminder-notes {
  font-size: 0.75rem;
  color: var(--text-2);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

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

.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 p { margin: 0; font-size: 0.875rem; }

/* ---------- Home grid ---------- */

.grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  padding-top: 2px;
}

@media (min-width: 620px) {
  .grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (min-width: 1080px) {
  .grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}

.list-card {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-height: 112px;
  padding: 14px;
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--c) 7%, var(--surface));
  box-shadow: var(--shadow-card);
  text-align: left;
  transition: border-color 0.15s, transform 0.1s;
}

.list-card:hover { border-color: var(--line); }
.list-card:active { transform: scale(0.99); }

.card-count {
  position: absolute;
  top: 12px;
  right: 14px;
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--text-3);
  font-variant-numeric: tabular-nums;
}

.card-dot {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 2px solid var(--c);
  background: color-mix(in srgb, var(--c) 16%, var(--surface));
}

.card-name {
  font-size: 0.875rem;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.card-add {
  align-items: center;
  justify-content: center;
  gap: 8px;
  color: var(--text-3);
  background: transparent;
  border-style: dashed;
  border-color: var(--line);
  font-size: 0.8125rem;
  font-weight: 500;
}

.card-add:hover { color: var(--text-2); border-color: var(--text-3); }
.card-add .ic { width: 20px; height: 20px; }

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

/* ---------- 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(--fab-bg);
  color: #ffffff;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.22), 0 2px 7px rgba(0, 0, 0, 0.16);
  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(--fab-hover);
  transform: translateY(-1px);
  box-shadow: 0 13px 32px rgba(0, 0, 0, 0.25), 0 3px 8px rgba(0, 0, 0, 0.18);
}

.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);
}

.sheet-card {
  position: relative;
  width: min(560px, 100%);
  max-height: min(88dvh, 780px);
  overflow-y: auto;
  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); }

.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(--fab-bg); }

#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;
}

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

#editor .e-notes {
  min-height: 48px;
  font-size: 0.9375rem;
  resize: none;
}

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

.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: 44px;
  height: 27px;
  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) 14%, transparent);
  transition: background 0.18s;
}

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

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

.ed-subrow { padding: 0 14px 10px 48px; }

.ed-subrow input[type="date"],
.ed-subrow input[type="time"] {
  width: 100%;
  border: 0;
  border-radius: 9px;
  background: color-mix(in srgb, var(--text) 7%, transparent);
  padding: 9px 11px;
  color: var(--text);
  font-size: 0.9375rem;
}

.ed-subrow input:focus {
  outline: none;
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--fab-bg) 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; }
.ed-details-toggle { cursor: pointer; }
.ed-details-toggle .ed-chevron { transition: transform 0.18s; }
.ed-details-toggle.open .ed-chevron { transform: rotate(90deg); }

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

.ed-delete-row { padding: 0 14px 14px 48px; }
.ed-delete-row .danger-btn { width: 100%; margin: 0; }

.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 {
  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); }

.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 ---------- */

@media (max-width: 899px) {
  .sidebar {
    position: fixed;
    inset: 0;
    width: 100%;
    border-right: 0;
    padding-top: calc(14px + env(safe-area-inset-top));
    padding-left: 16px;
    padding-right: 16px;
    z-index: 5;
  }

  .main { width: 100%; }

  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; }

  .back-btn { display: flex; }

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

  .back-btn { order: 1; width: 100%; padding: 2px 0 4px; }
  .title-wrap { order: 2; flex-direction: row; align-items: baseline; gap: 8px; }
  .title-wrap h2 { font-size: 1.25rem; }
  .view-count { font-size: 0.8125rem; }
  #view-menu { order: 3; }
  #refresh-btn { order: 4; }

  .search input, .main-search input,
  .auth-card input, .settings-group input, .e-title, .e-notes { font-size: 16px; }

  .main-search {
    display: flex;
    align-items: center;
    position: relative;
    margin: 8px 18px 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: 8px 10px 8px 32px;
    background: var(--elev);
    -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(96px + env(safe-area-inset-bottom)); }

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

  body[data-screen="home"] .sidebar {
    padding-bottom: calc(86px + env(safe-area-inset-bottom));
  }

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

  .grid { gap: 10px; }
  .list-card { min-height: 100px; }

  .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) {
  .reminder:hover,
  .nav-row:hover,
  .list-row:hover,
  .icon-btn:hover,
  .text-btn:hover,
  .list-card:hover { background: transparent; }
  .text-btn:hover { color: var(--text-2); }
  .reminder:active { background: var(--hover); }
}

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