:root {
  --bg: #f6f7fb; --card: #ffffff; --text: #0f172a; --muted: #64748b; --line: #e2e8f0;
  --accent: #4f46e5; --accent-soft: #eef2ff;
  --p1: #dc2626; --p2: #d97706; --p3: #64748b;
  --radius: 14px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b1120; --card: #131c2e; --text: #e2e8f0; --muted: #94a3b8; --line: #1e293b;
    --accent: #818cf8; --accent-soft: #1e1b4b;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text);
  font: 16px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
button, input, select, textarea { font: inherit; color: inherit; }
.hidden { display: none !important; }
.muted { color: var(--muted); font-size: 13px; }
.error { color: var(--p1); min-height: 1.2em; }

/* login */
#login { min-height: 100dvh; display: grid; place-items: center; padding: 16px; }
.login-card { width: 100%; max-width: 340px; text-align: center; }
.logo { font-size: 40px; color: var(--accent); }
.login-card input { width: 100%; margin: 16px 0 10px; }

input, select, textarea { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; width: 100%; }
button { cursor: pointer; border: 1px solid var(--line); background: var(--card); border-radius: 10px; padding: 10px 14px; }
button.primary { background: var(--accent); color: #fff; border-color: var(--accent); }
a.button { display: inline-block; text-align: center; text-decoration: none; border-radius: 10px; padding: 10px 14px; border: 1px solid var(--line); color: inherit; }
a.button.primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.meta a { color: var(--accent); text-decoration: none; }
#gmail-list { margin: 0; padding-left: 18px; }
#gmail-list button { margin-left: 8px; padding: 2px 8px; font-size: 12px; }
button.danger { color: var(--p1); }

/* header */
header { position: sticky; top: 0; z-index: 5; background: var(--bg); padding: 12px 16px 8px;
  padding-top: max(12px, env(safe-area-inset-top)); border-bottom: 1px solid var(--line); }
.top { display: flex; align-items: center; justify-content: space-between; }
.top h1 { font-size: 20px; margin: 0; }
.chip { border-radius: 999px; padding: 6px 12px; }
.chip.city { background: var(--accent-soft); border-color: transparent; font-weight: 600; }
.chip.small { padding: 4px 10px; font-size: 13px; }
.chip.active { background: var(--accent); color: #fff; border-color: var(--accent); }
nav#views, #contexts, nav#list-tabs, .chips { display: flex; gap: 6px; overflow-x: auto; margin-top: 10px; scrollbar-width: none; }
.tab { border: none; background: none; padding: 6px 10px; color: var(--muted); white-space: nowrap; border-radius: 8px; }
.tab.active { color: var(--text); background: var(--card); font-weight: 600; box-shadow: 0 1px 2px rgba(0,0,0,.06); }
.badge { background: var(--p1); color: #fff; border-radius: 999px; font-size: 11px; padding: 1px 6px; margin-left: 2px; }

/* list */
main { padding: 12px 16px 170px; max-width: 760px; margin: 0 auto; }
.group-title { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 18px 4px 6px; }
.task { display: flex; gap: 12px; align-items: flex-start; background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 12px; margin-bottom: 8px; }
.task .check { flex: none; width: 24px; height: 24px; border-radius: 50%; border: 2px solid var(--muted); padding: 0; background: none; margin-top: 1px; }
.task.p1 .check { border-color: var(--p1); }
.task.p2 .check { border-color: var(--p2); }
.task.done .check { background: var(--accent); border-color: var(--accent); }
.task.done .title { text-decoration: line-through; color: var(--muted); }
.task .body { flex: 1; min-width: 0; }
.task .title { font-weight: 500; overflow-wrap: anywhere; }
.meta { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; font-size: 12px; color: var(--muted); }
.meta .pill { background: var(--bg); border-radius: 6px; padding: 1px 6px; }
.meta .overdue { color: var(--p1); font-weight: 600; }
.meta .pri1 { color: var(--p1); font-weight: 700; }
.meta .pri2 { color: var(--p2); font-weight: 700; }
.inbox-actions { display: flex; gap: 6px; margin-top: 8px; }
.inbox-actions button { padding: 4px 10px; font-size: 13px; }
.empty { text-align: center; color: var(--muted); padding: 48px 0; }

/* capture bar */
.capture { position: fixed; left: 0; right: 0; bottom: 0; padding: 10px 16px;
  padding-bottom: max(10px, env(safe-area-inset-bottom)); background: linear-gradient(transparent, var(--bg) 30%); }
.capture form { display: flex; gap: 8px; max-width: 760px; margin: 0 auto; }
.capture input { border-radius: 999px; padding: 14px 18px; box-shadow: 0 4px 16px rgba(0,0,0,.08); }
.mic { flex: none; width: 52px; height: 52px; border-radius: 50%; background: var(--accent); color: #fff; border: none;
  font-size: 22px; box-shadow: 0 4px 16px rgba(79,70,229,.4); touch-action: none; user-select: none; -webkit-user-select: none; }
.mic.recording { background: var(--p1); animation: pulse 1s infinite; }
.mic.busy { opacity: .6; }
@keyframes pulse { 50% { transform: scale(1.1); } }

.toast { position: fixed; left: 16px; right: 16px; bottom: 150px; max-width: 728px; margin: 0 auto; background: var(--text); color: var(--bg);
  padding: 12px 14px; border-radius: 12px; font-size: 14px; z-index: 10; }

/* dialogs */
dialog { border: none; border-radius: 18px; padding: 0; width: min(520px, calc(100vw - 32px)); background: var(--card); color: var(--text); }
dialog::backdrop { background: rgba(15,23,42,.5); }
dialog form { padding: 18px; display: flex; flex-direction: column; gap: 10px; }
dialog h2 { margin: 0 0 4px; font-size: 18px; }
dialog label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); }
.row { display: flex; gap: 10px; }
.row > * { flex: 1; }
.actions { display: flex; gap: 8px; margin-top: 6px; }
.actions span { flex: 1; }
.loc-picker, .city-list { display: flex; flex-wrap: wrap; gap: 6px; }
.city-list button { flex: 1 1 40%; padding: 14px; }
details summary { color: var(--muted); font-size: 14px; margin: 6px 0; }

/* pages & bottom nav */
.bottom-nav { display: flex; max-width: 760px; margin: 8px auto 0; background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 4px; }
.bottom-nav button { flex: 1; border: none; background: none; padding: 6px 0; display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: 18px; border-radius: 12px; }
.bottom-nav button span { font-size: 11px; color: var(--muted); }
.bottom-nav button.active { background: var(--accent-soft); }
.bottom-nav button.active span { color: var(--text); font-weight: 600; }
.inline-form { display: flex; gap: 8px; margin-top: 10px; }
.inline-form input { flex: 1; min-width: 0; }
#recipe-search { margin-top: 8px; }

/* recipes */
.recipe-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 12px; }
.recipe { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; display: flex; flex-direction: column; }
.recipe a.thumb { display: block; aspect-ratio: 16/10; background: var(--line) center/cover no-repeat; }
.recipe .rbody { padding: 8px 10px 10px; display: flex; flex-direction: column; gap: 4px; flex: 1; }
.recipe .rtitle { color: inherit; text-decoration: none; font-weight: 600; font-size: 14px; line-height: 1.3; overflow-wrap: anywhere; }
.recipe .rmeta { font-size: 12px; color: var(--muted); }
.recipe .ractions { display: flex; gap: 6px; margin-top: auto; padding-top: 6px; }
.recipe .ractions button { flex: 1; padding: 6px 4px; font-size: 12px; white-space: nowrap; }
.recipe .ractions button.x { flex: 0 0 auto; }
.diet-veg { color: #16a34a; } .diet-non-veg { color: var(--p1); } .diet-egg { color: var(--p2); }

/* list items */
.item { display: flex; align-items: center; gap: 12px; background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 12px; margin-bottom: 6px; }
.item .check { flex: none; width: 24px; height: 24px; border-radius: 6px; border: 2px solid var(--muted); background: none; padding: 0; }
.item.done .check { background: var(--accent); border-color: var(--accent); }
.item.done .itext { text-decoration: line-through; color: var(--muted); }
.item .itext { flex: 1; }
.item .qty { color: var(--muted); font-size: 13px; }

/* settings */
.settings { display: flex; flex-direction: column; gap: 12px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; display: flex; flex-direction: column; gap: 8px; }
.card h3 { margin: 0; font-size: 16px; }
.card .inline-form { margin-top: 0; }
#login-form input { margin: 6px 0; }
