/* pocketpip styles
   Colours live in the theme tokens below. Light is the default; dark applies when the
   phone is in dark mode (Auto) or when Dark is picked in Settings. */

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

/* ── THEME TOKENS ─────────────────────────────────────────── */
body {
  --bg: #f5f2ec; --bg-surface: #fffdf9; --bg-elevated: #ffffff; --bg-hover: #ece7dd; --bg-sunken: #ebe6dc;
  --border: #d9d2c4; --border-subtle: #e8e2d6;
  --text: #2a2925; --text-secondary: #57534a; --text-muted: #736d60;
  --accent: #6b7d4c; --accent-strong: #586840; --accent-text: #ffffff; --accent-soft: rgba(107,125,76,.12);
  --danger: #a8453d; --danger-soft: rgba(184,90,82,.10);
  --ok: #5b8a4a; --warn: #c49a3c;
  --toast-bg: #2f2d27; --toast-text: #f5f2ec; --overlay: rgba(42,41,37,.35);
  --shadow-sm: 0 1px 2px rgba(60,50,30,.05), 0 1px 1px rgba(60,50,30,.03);
  --shadow-md: 0 6px 18px rgba(60,50,30,.08), 0 1px 3px rgba(60,50,30,.05);
  --shadow-lg: 0 16px 40px rgba(60,50,30,.14), 0 2px 6px rgba(60,50,30,.06);
  color-scheme: light;
}
/* Dark tokens: written twice — once for "Auto" when the phone is in dark mode,
   once for an explicit Dark choice. Keep the two blocks identical. */
@media (prefers-color-scheme: dark) {
  body:not([data-theme="light"]) {
    --bg: #161513; --bg-surface: #201f1c; --bg-elevated: #292723; --bg-hover: #2d2b27; --bg-sunken: #1b1a17;
    --border: #3a3732; --border-subtle: #2c2a26;
    --text: #ece8de; --text-secondary: #bbb6a9; --text-muted: #918c80;
    --accent: #a3b97e; --accent-strong: #b4c991; --accent-text: #1a1c14; --accent-soft: rgba(163,185,126,.14);
    --danger: #e0857c; --danger-soft: rgba(224,133,124,.12);
    --ok: #8fc27a; --warn: #dcbd6c;
    --toast-bg: #ece8de; --toast-text: #1a1916; --overlay: rgba(0,0,0,.55);
    --shadow-sm: 0 1px 2px rgba(0,0,0,.3);
    --shadow-md: 0 6px 18px rgba(0,0,0,.35);
    --shadow-lg: 0 16px 40px rgba(0,0,0,.5);
    color-scheme: dark;
  }
}
body[data-theme="dark"] {
  --bg: #161513; --bg-surface: #201f1c; --bg-elevated: #292723; --bg-hover: #2d2b27; --bg-sunken: #1b1a17;
  --border: #3a3732; --border-subtle: #2c2a26;
  --text: #ece8de; --text-secondary: #bbb6a9; --text-muted: #918c80;
  --accent: #a3b97e; --accent-strong: #b4c991; --accent-text: #1a1c14; --accent-soft: rgba(163,185,126,.14);
  --danger: #e0857c; --danger-soft: rgba(224,133,124,.12);
  --ok: #8fc27a; --warn: #dcbd6c;
  --toast-bg: #ece8de; --toast-text: #1a1916; --overlay: rgba(0,0,0,.55);
  --shadow-sm: 0 1px 2px rgba(0,0,0,.3);
  --shadow-md: 0 6px 18px rgba(0,0,0,.35);
  --shadow-lg: 0 16px 40px rgba(0,0,0,.5);
  color-scheme: dark;
}

:root {
  --radius-sm: 8px; --radius: 14px; --radius-lg: 22px;
  --ease: cubic-bezier(.2,.8,.2,1); --transition: 180ms var(--ease);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-display: 'Fraunces', Georgia, serif;
  --nav-height: 64px;
}

/* ── BASE ─────────────────────────────────────────────────── */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--font); background: var(--bg); color: var(--text);
  min-height: 100vh; line-height: 1.5; -webkit-font-smoothing: antialiased;
  padding-bottom: 32px;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: none; -webkit-tap-highlight-color: transparent; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
.hidden { display: none !important; }
.visually-hidden {
  position: absolute !important; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap;
}
.icon {
  width: 20px; height: 20px; flex-shrink: 0;
  fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round;
}
.icon-sm { width: 16px; height: 16px; }
.icon-xs { width: 14px; height: 14px; stroke-width: 2; }
.icon-inline { width: 1.1em; height: 1.1em; vertical-align: -0.2em; }
.status-ok { color: var(--ok); } .status-warn { color: var(--warn); } .status-error { color: var(--danger); }
.status-ok, .status-warn, .status-error { vertical-align: -3px; margin-right: 4px; }

.app { max-width: 680px; margin: 0 auto; padding: 0 20px; }
main { padding: 8px 0 24px; }

/* ── HEADER ───────────────────────────────────────────────── */
.app-header {
  position: sticky; top: 0; z-index: 100;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: max(14px, env(safe-area-inset-top)) 0 12px;
  background: var(--bg);
}
.header-left { display: flex; align-items: center; gap: 10px; min-width: 0; }
.header-right { display: flex; align-items: center; gap: 6px; }
.logo-mark {
  width: 34px; height: 34px; border-radius: 11px; flex-shrink: 0;
  background: linear-gradient(140deg, #8a9d68, #5f7044);
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-display); font-style: italic; font-size: 20px; color: #fff;
  box-shadow: 0 2px 8px rgba(95,112,68,.25), inset 0 1px 0 rgba(255,255,255,.2);
}
.round-btn {
  position: relative; width: 40px; height: 40px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: var(--text-secondary); transition: background var(--transition), color var(--transition);
}
.round-btn:hover { background: var(--bg-hover); color: var(--text); }

/* Sync status dot on the cloud button */
.sync-dot {
  position: absolute; top: 9px; right: 8px; width: 8px; height: 8px; border-radius: 50%;
  border: 2px solid var(--bg); background: transparent;
}
.sync-btn[data-state="off"] { color: var(--text-muted); opacity: .7; }
.sync-btn[data-state="ok"] .sync-dot { background: var(--ok); }
.sync-btn[data-state="loading"] .sync-dot { background: var(--warn); animation: pulse 1s ease-in-out infinite; }
.sync-btn[data-state="error"] { color: var(--danger); }
.sync-btn[data-state="offline"] { color: var(--text-muted); }
.sync-btn[data-state="offline"] .sync-dot { background: var(--text-muted); }
.sync-btn[data-state="error"] .sync-dot { background: var(--danger); }
@keyframes pulse { 50% { opacity: .35; } }

/* ── CHILD SELECTOR ───────────────────────────────────────── */
.child-selector { position: relative; min-width: 0; }
.child-active-btn {
  display: inline-flex; align-items: center; gap: 4px; max-width: 100%;
  font-family: var(--font-display); font-size: 22px; font-weight: 500; letter-spacing: -.3px;
  padding: 4px 8px 4px 6px; border-radius: 10px; color: var(--text);
  transition: background var(--transition);
}
.child-active-btn span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.child-active-btn .icon { color: var(--text-muted); margin-top: 2px; }
.child-active-btn:hover { background: var(--bg-hover); }
.child-dropdown {
  position: absolute; top: calc(100% + 6px); left: 0; min-width: 210px; z-index: 300;
  background: var(--bg-elevated); border: 1px solid var(--border-subtle); border-radius: var(--radius);
  box-shadow: var(--shadow-lg); padding: 6px; display: none; animation: pop .14s var(--ease);
}
.child-dropdown.open { display: block; }
@keyframes pop { from { opacity: 0; transform: translateY(-4px) scale(.98); } }
.child-option {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 10px 12px; border-radius: 9px; font-size: 15px; cursor: pointer; min-height: 44px;
}
.child-option:hover { background: var(--bg-hover); }
.child-option.active { color: var(--accent); font-weight: 600; }
.child-remove {
  width: 28px; height: 28px; border-radius: 50%; display: flex; align-items: center; justify-content: center;
  color: var(--text-muted); font-size: 18px; line-height: 1;
}
.child-remove:hover { color: var(--danger); background: var(--danger-soft); }
.child-add-option {
  margin-top: 4px; padding: 10px 12px; border-top: 1px solid var(--border-subtle);
  font-size: 14px; font-weight: 600; color: var(--accent); cursor: pointer; border-radius: 0 0 9px 9px;
}
.child-add-option:hover { background: var(--bg-hover); }

/* ── NAVIGATION ───────────────────────────────────────────── */
.desktop-nav { display: flex; gap: 2px; background: var(--bg-sunken); padding: 4px; border-radius: 12px; }
.desktop-nav button {
  position: relative; font-size: 14px; font-weight: 500; padding: 7px 16px; border-radius: 9px;
  color: var(--text-secondary); transition: all var(--transition);
}
.desktop-nav button:hover { color: var(--text); }
.desktop-nav button.active { background: var(--bg-elevated); color: var(--text); font-weight: 600; box-shadow: var(--shadow-sm); }
.mobile-nav {
  display: none; position: fixed; left: 0; right: 0; bottom: 0; z-index: 400;
  background: color-mix(in srgb, var(--bg-surface) 92%, transparent);
  backdrop-filter: saturate(1.4) blur(14px); -webkit-backdrop-filter: saturate(1.4) blur(14px);
  border-top: 1px solid var(--border-subtle);
  padding: 6px 12px max(8px, env(safe-area-inset-bottom));
  justify-content: space-around;
}
.mobile-nav button {
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  min-width: 72px; padding: 6px 0; border-radius: 12px;
  font-size: 11px; font-weight: 600; color: var(--text-muted); transition: color var(--transition);
}
.mobile-nav button .icon { width: 24px; height: 24px; }
.mobile-nav button.active { color: var(--accent); }
.mobile-nav button.active .icon { stroke-width: 2.1; }

/* ── CAPTURE ──────────────────────────────────────────────── */
.capture-view { max-width: 560px; margin: 0 auto; padding-top: 12px; display: flex; flex-direction: column; gap: 16px; }
.capture-prompt {
  font-family: var(--font-display); font-style: italic; font-weight: 400;
  font-size: 26px; letter-spacing: -.3px; color: var(--text-secondary); text-align: center; margin-top: 8px;
}
.capture-card {
  position: relative; background: var(--bg-surface); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md); border: 1px solid var(--border-subtle);
  transition: box-shadow var(--transition), border-color var(--transition);
}
.capture-card:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft), var(--shadow-md); }
.capture-input {
  display: block; width: 100%; min-height: 132px; resize: none; outline: none;
  padding: 22px 22px 12px; border: none; background: transparent;
  font-size: 20px; line-height: 1.5;
}
.capture-input::placeholder { color: var(--text-muted); font-family: var(--font-display); font-style: italic; }
.capture-char-count {
  position: absolute; top: 12px; right: 16px; font-size: 11px; color: var(--text-muted);
  font-variant-numeric: tabular-nums; opacity: 0; transition: opacity var(--transition);
}
.capture-card:focus-within .capture-char-count { opacity: 1; }

.capture-tags { border-top: 1px dashed var(--border-subtle); padding: 12px 16px 6px; }
.tag-container { position: relative; display: flex; flex-wrap: wrap; align-items: center; gap: 6px; padding: 6px 2px; }
.tag-hash { color: var(--text-muted); }
.tag-chip {
  display: inline-flex; align-items: center; gap: 2px;
  background: var(--bg-hover); color: var(--text-secondary);
  font-size: 13px; padding: 3px 4px 3px 10px; border-radius: 100px;
}
.tag-chip .tag-remove {
  display: inline-flex; align-items: center; justify-content: center;
  width: 24px; height: 24px; border-radius: 50%; color: var(--text-muted);
}
.tag-chip .tag-remove:hover { color: var(--danger); background: var(--danger-soft); }
.tag-select-input { flex: 1; min-width: 90px; border: none; background: transparent; outline: none; font-size: 16px; padding: 4px 0; }
.tag-select-input::placeholder { color: var(--text-muted); }
.tag-dropdown {
  position: absolute; top: calc(100% + 4px); left: 8px; right: 8px; z-index: 200; display: none;
  max-height: 200px; overflow-y: auto; padding: 4px;
  background: var(--bg-elevated); border: 1px solid var(--border-subtle); border-radius: var(--radius); box-shadow: var(--shadow-lg);
}
.tag-dropdown.open { display: block; }
.tag-option { padding: 10px 12px; border-radius: 8px; font-size: 14px; cursor: pointer; }
.tag-option:hover, .tag-option.highlighted { background: var(--bg-hover); }

/* Tag chips — one look everywhere: Capture, Review, the editor and Timeline filters */
.chip-row { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  display: inline-flex; align-items: center; gap: 1px; white-space: nowrap;
  font-size: 14px; font-weight: 500; padding: 7px 14px; min-height: 38px; border-radius: 100px;
  border: 1px solid var(--border); color: var(--text-secondary); background: var(--bg-surface);
  transition: background var(--transition), color var(--transition), border-color var(--transition);
}
.chip:hover { background: var(--bg-hover); color: var(--text); }
.chip-hash { color: var(--text-muted); font-weight: 400; margin-right: 1px; }
.chip.selected { background: var(--accent); border-color: var(--accent); color: var(--accent-text); font-weight: 600; }
.chip.selected .chip-hash { color: inherit; opacity: .7; }
.chip-sm { font-size: 13px; padding: 5px 12px; min-height: 34px; }

.date-row { display: flex; align-items: center; justify-content: center; flex-wrap: wrap; gap: 6px; color: var(--text-muted); }
.pill-btn {
  font-size: 13px; font-weight: 500; padding: 6px 12px; min-height: 34px; border-radius: 100px;
  color: var(--text-secondary); transition: background var(--transition);
}
.pill-btn:hover { background: var(--bg-hover); }
.date-override-input {
  font-size: 14px; padding: 6px 10px; min-height: 34px; border-radius: 10px;
  border: 1px solid var(--border-subtle); background: var(--bg-surface); color: var(--text-secondary); outline: none;
}
.date-override-input:focus { border-color: var(--accent); }

.capture-btn {
  width: 100%; height: 54px; border-radius: var(--radius);
  background: var(--accent); color: var(--accent-text); font-size: 17px; font-weight: 600; letter-spacing: .1px;
  box-shadow: 0 6px 16px var(--accent-soft), inset 0 1px 0 rgba(255,255,255,.15);
  transition: transform 120ms var(--ease), background var(--transition);
}
.capture-btn:hover { background: var(--accent-strong); }
.capture-btn:active { transform: scale(.985); }
.capture-hint { text-align: center; font-size: 12px; color: var(--text-muted); margin-top: -6px; }

/* ── CARDS ────────────────────────────────────────────────── */
.item-card {
  position: relative; background: var(--bg-surface); border: 1px solid var(--border-subtle);
  border-radius: var(--radius); padding: 16px 18px 12px; margin-bottom: 12px;
  box-shadow: var(--shadow-sm); transition: box-shadow var(--transition);
  animation: rise 220ms var(--ease);
}
.item-card:hover { box-shadow: var(--shadow-md); }
@keyframes rise { from { opacity: 0; transform: translateY(6px); } }
.item-text { font-size: 17px; line-height: 1.55; white-space: pre-wrap; overflow-wrap: anywhere; }
.item-card.is-quote .item-text {
  font-family: var(--font-display); font-style: italic; font-size: 20px; line-height: 1.45; letter-spacing: -.1px;
}
.quote-mark { font-family: var(--font-display); color: var(--accent); opacity: .6; }
.item-footer { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 10px; }
.item-meta { display: flex; align-items: center; flex-wrap: wrap; gap: 6px 10px; font-size: 13px; color: var(--text-muted); min-width: 0; }
.item-tag {
  color: var(--text-secondary); font-size: inherit; padding: 2px 4px; margin: -2px -4px; border-radius: 6px;
  transition: background var(--transition), color var(--transition);
}
.item-tag::before { content: '#'; color: var(--text-muted); }
button.item-tag:hover { background: var(--bg-hover); color: var(--accent); }
.item-age {
  font-size: 12px; font-weight: 600; color: var(--accent); background: var(--accent-soft);
  padding: 1px 8px; border-radius: 100px; font-variant-numeric: tabular-nums;
}
/* On this day (Capture view) */
.on-this-day { margin-top: 12px; }
.otd-title {
  display: flex; align-items: center; gap: 6px; font-family: var(--font-display);
  font-size: 18px; font-weight: 500; color: var(--text-secondary); margin-bottom: 10px;
}
.otd-title .icon { color: var(--accent); }
.otd-card {
  background: var(--accent-soft); border-radius: var(--radius); padding: 14px 16px; margin-bottom: 10px;
  border: 1px solid color-mix(in srgb, var(--accent) 18%, transparent);
}
.otd-when { font-size: 12px; font-weight: 600; color: var(--accent); margin-bottom: 4px; text-transform: uppercase; letter-spacing: .04em; }
.otd-text { font-size: 16px; line-height: 1.5; white-space: pre-wrap; overflow-wrap: anywhere; }
.otd-card.is-quote .otd-text { font-family: var(--font-display); font-style: italic; font-size: 18px; }

/* Edit dialog */
.modal-textarea { height: auto; min-height: 96px; padding: 12px 14px; line-height: 1.5; resize: vertical; }
.edit-quick { margin-bottom: 8px; }
.edit-tags { border: 1px solid var(--border); border-radius: 10px; padding: 6px 12px; margin-bottom: 14px; background: var(--bg); }
.edit-tags:focus-within { border-color: var(--accent); }
.item-actions { display: flex; gap: 2px; margin-right: -8px; }
.icon-btn {
  width: 40px; height: 40px; border-radius: 50%; display: flex; align-items: center; justify-content: center;
  color: var(--text-muted); transition: background var(--transition), color var(--transition);
}
.icon-btn .icon { width: 18px; height: 18px; }
.icon-btn:hover { background: var(--bg-hover); color: var(--text); }
.icon-btn.active-pin { color: var(--accent); }
.icon-btn.active-pin .icon { fill: currentColor; }
.icon-btn.delete:hover { color: var(--danger); background: var(--danger-soft); }
.item-card.is-pinned { border-color: color-mix(in srgb, var(--accent) 40%, var(--border-subtle)); }

/* Untagged moments: a quiet "+ tag" link, or one-tap tags under the Untagged filter */
.add-tag {
  font-size: inherit; color: var(--text-muted); padding: 2px 8px; margin: -2px -4px; border-radius: 100px;
  border: 1px dashed var(--border); transition: color var(--transition), border-color var(--transition);
}
.add-tag:hover { color: var(--accent); border-color: var(--accent); }
.card-quick-tags { margin-top: 10px; }
.chip-count {
  display: inline-flex; align-items: center; justify-content: center; min-width: 18px; height: 18px;
  margin-left: 6px; padding: 0 5px; border-radius: 9px; font-size: 11px; font-weight: 700;
  background: var(--accent-soft); color: var(--accent);
}
.chip.selected .chip-count { background: rgba(255,255,255,.25); color: inherit; }

/* ── TIMELINE ─────────────────────────────────────────────── */
.timeline-toolbar { display: flex; flex-direction: column; gap: 12px; margin: 8px 0 8px; }
.search-row { display: flex; gap: 8px; }
.input-wrap { position: relative; flex: 1; }
.search-icon { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--text-muted); pointer-events: none; }
.input-wrap input {
  width: 100%; height: 46px; padding: 0 44px 0 40px; font-size: 16px;
  background: var(--bg-surface); border: 1px solid var(--border-subtle); border-radius: 12px; outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
  -webkit-appearance: none; appearance: none;
}
.input-wrap input::-webkit-search-cancel-button { display: none; }
.input-wrap input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.input-clear {
  position: absolute; right: 4px; top: 50%; transform: translateY(-50%);
  width: 38px; height: 38px; border-radius: 50%; display: none; align-items: center; justify-content: center; color: var(--text-muted);
}
.input-wrap.has-value .input-clear { display: flex; }
.sort-select {
  height: 46px; padding: 0 12px; font-size: 15px; border-radius: 12px;
  border: 1px solid var(--border-subtle); background: var(--bg-surface); color: var(--text-secondary); outline: none;
}
.filter-row {
  display: flex; gap: 6px; overflow-x: auto; padding: 2px 20px 4px; margin: 0 -20px;
  scrollbar-width: none; -webkit-overflow-scrolling: touch;
}
.filter-row::-webkit-scrollbar { display: none; }
.filter-row .chip { font-size: 13px; padding: 5px 14px; min-height: 36px; border-color: var(--border-subtle); }
.date-group-label {
  font-family: var(--font-display); font-size: 16px; font-weight: 600; color: var(--text-secondary);
  padding: 18px 2px 10px; display: flex; align-items: center; gap: 6px;
}
.date-group-label .icon { color: var(--accent); }

/* Empty states */
.empty-state { text-align: center; padding: 56px 20px; color: var(--text-muted); }
.empty-icon {
  width: 64px; height: 64px; margin: 0 auto 16px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: var(--accent-soft); color: var(--accent);
}
.empty-icon .icon { width: 28px; height: 28px; }
.empty-state h3 { font-family: var(--font-display); font-size: 20px; font-weight: 500; color: var(--text); margin-bottom: 4px; }
.empty-state p { font-size: 14px; }

/* ── SETTINGS PANEL ───────────────────────────────────────── */
.settings-panel-overlay { position: fixed; inset: 0; z-index: 700; background: var(--overlay); display: none; }
.settings-panel-overlay.open { display: block; animation: fade .2s ease; }
@keyframes fade { from { opacity: 0; } }
.settings-panel {
  position: fixed; top: 0; right: 0; bottom: 0; width: min(360px, 92vw); z-index: 701;
  display: flex; flex-direction: column; overflow-y: auto;
  background: var(--bg); box-shadow: var(--shadow-lg);
  padding-top: env(safe-area-inset-top);
  animation: slide-in .26s var(--ease);
}
@keyframes slide-in { from { transform: translateX(100%); } }
.settings-panel-header { display: flex; align-items: center; justify-content: space-between; padding: 16px 12px 8px 20px; }
.settings-panel-title { font-family: var(--font-display); font-size: 26px; font-weight: 500; letter-spacing: -.4px; }
.settings-panel-body { flex: 1; padding: 0 12px 12px; }
.settings-section-label {
  font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .08em;
  color: var(--text-muted); padding: 18px 10px 6px;
}
.settings-row-item {
  display: flex; align-items: center; gap: 14px; width: 100%; min-height: 56px; padding: 10px 12px;
  text-align: left; font-size: 15px; font-weight: 500; border-radius: 12px; transition: background var(--transition);
}
.settings-row-item:hover { background: var(--bg-hover); }
.settings-row-item .icon { color: var(--text-secondary); }
.settings-row-item.danger, .settings-row-item.danger .icon { color: var(--danger); }
.settings-row-item-label { display: flex; flex-direction: column; flex: 1; line-height: 1.3; }
.settings-row-item-sub { font-size: 13px; font-weight: 400; color: var(--text-muted); margin-top: 2px; }
.settings-panel-footer {
  padding: 14px 22px max(14px, env(safe-area-inset-bottom)); border-top: 1px solid var(--border-subtle);
  font-size: 12px; color: var(--text-muted); font-variant-numeric: tabular-nums;
}
.theme-switch { display: flex; gap: 4px; margin: 0 10px; padding: 4px; background: var(--bg-sunken); border-radius: 12px; }
.theme-switch button {
  flex: 1; min-height: 38px; border-radius: 9px; font-size: 14px; font-weight: 500; color: var(--text-secondary);
  transition: all var(--transition);
}
.theme-switch button[aria-checked="true"] { background: var(--bg-elevated); color: var(--text); font-weight: 600; box-shadow: var(--shadow-sm); }

/* Install instructions (inside the modal) */
.install-steps { margin: 0 0 8px 20px; font-size: 15px; line-height: 1.6; color: var(--text-secondary); }
.install-steps li { padding: 4px 0; }

/* Trash list (inside the modal) */
.trash-item { padding: 12px; border: 1px solid var(--border-subtle); border-radius: 10px; margin-bottom: 8px; background: var(--bg-surface); }
.trash-item-text { font-size: 14px; line-height: 1.5; margin-bottom: 8px; color: var(--text-secondary); white-space: pre-wrap; overflow-wrap: anywhere; }
.trash-item-meta { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 12px; color: var(--text-muted); }
.trash-item-actions { display: flex; gap: 6px; margin-left: auto; }
.subtle-btn {
  font-size: 13px; padding: 8px 12px; border-radius: 9px; border: 1px solid var(--border);
  color: var(--text-secondary); transition: background var(--transition);
}
.subtle-btn:hover { background: var(--bg-hover); color: var(--text); }
.subtle-btn.danger { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 30%, transparent); }

/* ── MODAL ────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0; z-index: 800; display: none; align-items: center; justify-content: center; padding: 20px;
  background: var(--overlay); backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px);
}
.modal-overlay.open { display: flex; animation: fade .18s ease; }
.modal {
  width: 100%; max-width: 420px; max-height: calc(100vh - 40px); overflow-y: auto;
  background: var(--bg-elevated); border-radius: var(--radius-lg); padding: 24px;
  box-shadow: var(--shadow-lg); animation: pop .2s var(--ease);
}
.modal h3 { font-family: var(--font-display); font-size: 22px; font-weight: 500; letter-spacing: -.3px; margin-bottom: 6px; }
.modal p { font-size: 14px; color: var(--text-secondary); margin-bottom: 18px; }
.modal p:empty { display: none; }
.modal label { display: block; font-size: 13px; font-weight: 600; color: var(--text-secondary); margin-bottom: 6px; }
.modal-input {
  width: 100%; height: 46px; padding: 0 14px; margin-bottom: 14px; font-size: 16px;
  border: 1px solid var(--border); border-radius: 10px; background: var(--bg); outline: none;
}
.modal-input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 6px; }
.modal-btn { min-height: 42px; padding: 0 18px; border-radius: 10px; font-size: 15px; font-weight: 600; background: var(--bg-hover); color: var(--text); }
.modal-btn.primary { background: var(--accent); color: var(--accent-text); }
.modal-btn.confirm-danger { background: var(--danger); color: #fff; }
.modal-btn:disabled { cursor: not-allowed; }

/* ── FLASH & UNDO ─────────────────────────────────────────── */
.capture-flash {
  position: fixed; top: max(16px, env(safe-area-inset-top)); left: 50%; z-index: 900;
  display: flex; align-items: center; gap: 8px; pointer-events: none;
  padding: 10px 18px; border-radius: 100px; font-size: 14px; font-weight: 500;
  background: var(--bg-elevated); border: 1px solid var(--border-subtle); box-shadow: var(--shadow-lg);
  opacity: 0; transform: translate(-50%, -70px); transition: all 280ms cubic-bezier(.175,.885,.32,1.275);
}
.capture-flash.show { opacity: 1; transform: translate(-50%, 0); }
.capture-flash .flash-ok { color: var(--ok); }
.capture-flash .flash-err { color: var(--danger); display: none; }
.capture-flash.is-error .flash-ok { display: none; }
.capture-flash.is-error .flash-err { display: block; }
.undo-toast {
  position: fixed; left: 50%; bottom: 28px; z-index: 900; width: max-content; max-width: calc(100% - 32px);
  display: flex; align-items: center; gap: 14px; padding: 10px 10px 10px 18px; border-radius: 100px;
  background: var(--toast-bg); color: var(--toast-text); font-size: 14px; box-shadow: var(--shadow-lg);
  opacity: 0; pointer-events: none; transform: translate(-50%, 16px); transition: all 260ms var(--ease);
}
.undo-toast.show { opacity: 1; pointer-events: auto; transform: translate(-50%, 0); }
.undo-toast button { font-weight: 700; padding: 6px 12px; border-radius: 100px; background: rgba(127,127,127,.2); }

/* ── RESPONSIVE ───────────────────────────────────────────── */
@media (max-width: 640px) {
  .desktop-nav { display: none; }
  .mobile-nav { display: flex; }
  body { padding-bottom: calc(var(--nav-height) + env(safe-area-inset-bottom) + 24px); }
  .app { padding: 0 16px; }
  .filter-row { padding: 2px 16px 4px; margin: 0 -16px; }
  .undo-toast { bottom: calc(var(--nav-height) + env(safe-area-inset-bottom) + 16px); }
  .capture-hint { display: none; }
  .capture-input { font-size: 19px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* Sync Diagnostics and install instructions */
.fix-list { margin: 0 0 0 18px; font-size: 12px; line-height: 1.7; color: var(--text-secondary); }
.subtle-btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; }
.child-remove .icon { display: block; }
