:root {
  color-scheme: light dark;
  --bg: #f2f2f7; --card: #fff; --fg: #000; --mute: #8a8a8e; --line: rgba(60,60,67,.18);
  --accent: #e0901b; --danger: #ff3b30; --field: rgba(118,118,128,.12); --veil: #f2f2f7;
  --top: env(safe-area-inset-top); --bottom: env(safe-area-inset-bottom);
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #000; --card: #1c1c1e; --fg: #fff; --mute: #8d8d93; --line: rgba(84,84,88,.6); --accent: #ffa733; --field: rgba(118,118,128,.24); --veil: #000; }
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--fg); }
body { font: 17px/1.3 -apple-system, BlinkMacSystemFont, "SF Pro Text", system-ui, sans-serif; -webkit-text-size-adjust: 100%; overscroll-behavior: none; }
button { font: inherit; color: var(--accent); background: none; border: 0; padding: 0; cursor: pointer; }
input { font: inherit; color: inherit; }
svg { width: 22px; height: 22px; display: block; }

#app { display: flex; flex-direction: column; height: 100%; padding-top: var(--top); }
.scroll { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; padding: 0 16px 24px; }

/* Bars */
.bar { display: flex; align-items: center; justify-content: space-between; min-height: 44px; padding: 0 16px; }
.bar.large { padding-top: 8px; }
.bar h1 { font-size: 34px; font-weight: 700; letter-spacing: .01em; margin: 0; }
.bar .back { font-size: 17px; padding: 10px 0; }
.bar-actions { display: flex; gap: 18px; }
.icon { padding: 8px 0; font-weight: 700; letter-spacing: 1px; }

/* Search */
.search { position: relative; margin: 6px 16px 12px; }
.search svg { position: absolute; left: 9px; top: 50%; transform: translateY(-50%); width: 17px; height: 17px; color: var(--mute); pointer-events: none; }
.search input { width: 100%; height: 36px; border: 0; border-radius: 10px; background: var(--field); padding: 0 10px 0 32px; outline: none; -webkit-appearance: none; appearance: none; }
.search input::placeholder { color: var(--mute); }
.search input::-webkit-search-decoration { -webkit-appearance: none; }

/* Grouped rows */
.group { list-style: none; margin: 0 0 20px; padding: 0; background: var(--card); border-radius: 12px; overflow: hidden; }
.group-label { color: var(--mute); font-size: 13px; text-transform: uppercase; margin: 16px 16px 6px; }
.row { display: flex; align-items: center; gap: 12px; min-height: 48px; padding: 0 16px; position: relative; cursor: pointer; }
.row + .row::before { content: ""; position: absolute; top: 0; left: 52px; right: 0; border-top: .5px solid var(--line); }
.row .grow { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .count { color: var(--mute); }
.row .chev { color: var(--mute); opacity: .6; font-size: 22px; }
.dot { width: 24px; height: 24px; border-radius: 50%; background: var(--accent); flex: none; }
.done { color: var(--mute); }
.empty { text-align: center; color: var(--mute); margin-top: 72px; line-height: 1.5; }

/* Checklist */
.list-title { width: 100%; border: 0; background: none; font-size: 30px; font-weight: 700; color: var(--accent); padding: 4px 0 10px; outline: none; }
.list-title::placeholder { color: var(--mute); }
.items { list-style: none; margin: 0; padding: 0; }
.items li { display: flex; align-items: center; gap: 12px; min-height: 46px; border-bottom: .5px solid var(--line); }
.items .item { flex: 1; border: 0; background: none; outline: none; padding: 12px 0; }
.items .item.done { color: var(--mute); }
.check { width: 24px; height: 24px; flex: none; border-radius: 50%; border: 1.5px solid var(--mute); position: relative; display: inline-block; }
.check.on { border-color: var(--accent); }
.check.on::after { content: ""; position: absolute; inset: 3px; border-radius: 50%; background: var(--accent); }
.check.ghost { border-style: dashed; opacity: .5; }

/* Toolbar */
.toolbar { padding: 8px 16px calc(8px + var(--bottom)); }
.toolbar .add { font-weight: 600; display: flex; align-items: center; gap: 8px; }
.toolbar .add span { display: inline-grid; place-items: center; width: 24px; height: 24px; border-radius: 50%; background: var(--accent); color: var(--card); font-size: 20px; line-height: 1; }

/* Sheets */
.sheet-back { position: fixed; inset: 0; background: rgba(0,0,0,0); transition: background .2s; display: flex; align-items: flex-end; z-index: 10; }
.sheet-back.in { background: rgba(0,0,0,.35); }
.sheet { width: 100%; padding: 8px 8px calc(8px + var(--bottom)); transform: translateY(100%); transition: transform .22s ease-out; }
.sheet-back.in .sheet { transform: none; }
.sheet-title { text-align: center; color: var(--mute); font-size: 13px; padding: 12px; background: var(--card); border-radius: 14px 14px 0 0; border-bottom: .5px solid var(--line); }
.sheet-group { background: var(--card); border-radius: 14px; overflow: hidden; margin-bottom: 8px; }
.sheet-title + .sheet-group { border-radius: 0 0 14px 14px; }
.sheet-group button { display: block; width: 100%; padding: 17px; font-size: 19px; text-align: center; }
.sheet-group button + button { border-top: .5px solid var(--line); }
.danger { color: var(--danger) !important; }
.bold { font-weight: 600; }
.form { background: var(--card); border-radius: 14px; padding-bottom: 12px; }
.form-head { display: flex; justify-content: space-between; align-items: center; padding: 14px 16px; border-bottom: .5px solid var(--line); }
.form-head button:disabled { opacity: .4; }
.form-fields label { display: flex; flex-direction: column; gap: 4px; padding: 10px 16px 0; font-size: 13px; color: var(--mute); }
.form-fields input { border: 0; border-radius: 10px; background: var(--field); padding: 10px 12px; outline: none; font-size: 17px; }
.form-error { color: var(--danger); font-size: 14px; min-height: 18px; padding: 8px 16px 0; }

.toast { position: fixed; left: 50%; bottom: calc(40px + var(--bottom)); transform: translate(-50%, 20px); background: rgba(40,40,40,.92); color: #fff; padding: 10px 16px; border-radius: 20px; font-size: 15px; opacity: 0; transition: .25s; z-index: 20; }
.toast.in { opacity: 1; transform: translate(-50%, 0); }

/* Covers the screen while Memo isn't focused, so the app switcher never shows the vault. */
body.veil::after { content: ""; position: fixed; inset: 0; background: var(--veil); z-index: 100; }
