:root {
  --bg: #f4efe6;
  --paper: #fffdf8;
  --ink: #1f2a24;
  --muted: #6d7268;
  --line: #e4dccd;
  --accent: #2f6b4f;
  --accent-ink: #ffffff;
  --alexa: #1f8fb3;
  --danger: #b4432f;
  --radius: 14px;
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, sans-serif;
  --display: ui-rounded, "SF Pro Rounded", -apple-system, "Segoe UI", sans-serif;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #151a17; --paper: #1d2420; --ink: #ecebe4; --muted: #9aa197;
    --line: #2c3530; --accent: #6fbf8f; --accent-ink: #0f1a14; --alexa: #5cc3e4; --danger: #e07a64;
  }
}

[hidden] { display: none !important; }
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--ink);
  min-height: 100dvh;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) 0 env(safe-area-inset-left);
}
button, input, select, textarea { font: inherit; color: inherit; }
code { font-size: .85em; background: color-mix(in srgb, var(--line) 60%, transparent); padding: 1px 5px; border-radius: 5px; word-break: break-all; }

.top {
  display: flex; align-items: flex-end; justify-content: space-between;
  padding: 18px 20px 10px;
  position: sticky; top: 0; z-index: 5;
  background: linear-gradient(var(--bg) 75%, transparent);
}
h1 { font-family: var(--display); font-size: 34px; letter-spacing: -.02em; margin: 0; }
.sub { margin: 2px 0 0; color: var(--muted); font-size: 14px; }

.icon-btn {
  position: relative; border: 0; background: var(--paper); width: 42px; height: 42px; border-radius: 50%;
  display: grid; place-items: center; color: var(--muted); box-shadow: 0 1px 0 var(--line);
}
.dot { position: absolute; top: 6px; right: 6px; width: 10px; height: 10px; border-radius: 50%; background: var(--danger); border: 2px solid var(--paper); }

.banner {
  margin: 0 16px 8px; padding: 10px 14px; border-radius: var(--radius);
  background: color-mix(in srgb, var(--danger) 14%, var(--paper)); color: var(--ink); font-size: 14px;
}
.banner button { border: 0; background: none; color: var(--danger); font-weight: 600; padding: 0; margin-left: 4px; }

main { padding: 0 16px calc(150px + env(safe-area-inset-bottom)); }

.group { margin-top: 14px; }
.group h2 {
  font-size: 12px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted);
  margin: 0 4px 6px; font-weight: 600; display: flex; justify-content: space-between;
}
.group ul { list-style: none; margin: 0; padding: 0; background: var(--paper); border-radius: var(--radius); overflow: hidden; }
.item { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-top: 1px solid var(--line); min-height: 52px; }
.item:first-child { border-top: 0; }
.check {
  flex: none; width: 26px; height: 26px; border-radius: 50%; border: 2px solid var(--line);
  background: transparent; display: grid; place-items: center; padding: 0;
  transition: background .15s, border-color .15s;
}
.check svg { opacity: 0; transition: opacity .15s; }
.item.done .check { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.item.done .check svg { opacity: 1; }
.body { flex: 1; min-width: 0; border: 0; background: none; text-align: left; padding: 0; }
.name { font-size: 17px; display: block; overflow: hidden; text-overflow: ellipsis; }
.meta { font-size: 13px; color: var(--muted); display: flex; gap: 8px; align-items: center; margin-top: 2px; }
.meta:empty { display: none; }
.qty { flex: none; font-size: 14px; font-variant-numeric: tabular-nums; color: var(--muted); background: var(--bg); padding: 3px 9px; border-radius: 999px; }
.via-alexa { color: var(--alexa); font-weight: 600; font-size: 12px; }
.item.done .name { text-decoration: line-through; color: var(--muted); }
.item.fresh { animation: fresh 1.2s ease-out; }
@keyframes fresh { from { background: color-mix(in srgb, var(--alexa) 22%, var(--paper)); } }

.cart-head { display: flex; align-items: center; justify-content: space-between; margin: 26px 4px 6px; }
.cart-head h2 { margin: 0; }
.link-btn { border: 0; background: none; color: var(--accent); font-weight: 600; font-size: 14px; padding: 4px 0; }

.empty { text-align: center; color: var(--muted); padding: 60px 20px; line-height: 1.5; }
.empty strong { display: block; color: var(--ink); font-family: var(--display); font-size: 20px; margin-bottom: 4px; }

/* Barra de adicionar */
.add {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 6;
  padding: 8px 12px calc(10px + env(safe-area-inset-bottom));
  background: linear-gradient(transparent, var(--bg) 30%);
}
.chips { display: flex; gap: 8px; overflow-x: auto; padding: 4px 2px 8px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex: none; border: 1px solid var(--line); background: var(--paper); border-radius: 999px; padding: 6px 12px; font-size: 14px; }
.add-row { display: flex; gap: 8px; background: var(--paper); border-radius: 999px; padding: 6px; box-shadow: 0 6px 24px rgb(0 0 0 / .08), 0 0 0 1px var(--line); }
.add-row input { flex: 1; border: 0; background: none; padding: 8px 12px; font-size: 17px; outline: none; min-width: 0; }
.add-row button { border: 0; width: 42px; height: 42px; border-radius: 50%; background: var(--accent); color: var(--accent-ink); display: grid; place-items: center; }
.add-row.slim { border-radius: 12px; box-shadow: 0 0 0 1px var(--line); }
.add-row.slim button { width: auto; border-radius: 9px; padding: 0 14px; height: 38px; }

/* Bottom sheets */
.sheet {
  border: 0; padding: 0 18px calc(18px + env(safe-area-inset-bottom)); width: 100%; max-width: 560px;
  margin: auto auto 0; border-radius: 22px 22px 0 0; background: var(--paper); color: var(--ink);
  max-height: 92dvh; overflow-y: auto;
}
.sheet[open] { animation: up .22s ease-out; }
@keyframes up { from { transform: translateY(30px); opacity: .4; } }
.sheet::backdrop { background: rgb(0 0 0 / .35); }
.grab { width: 40px; height: 5px; border-radius: 3px; background: var(--line); margin: 10px auto 14px; }
.sheet h2 { font-family: var(--display); margin: 0 0 12px; }
.sheet h3 { margin: 0 0 4px; font-size: 16px; }
.sheet label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--muted); margin-bottom: 12px; }
.sheet label.row { flex-direction: row; justify-content: space-between; align-items: center; color: var(--ink); font-size: 15px; }
.sheet input:not([type=checkbox]), .sheet select, .sheet textarea {
  font-size: 17px; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--bg); color: var(--ink); width: 100%;
}
.sheet textarea { font-family: ui-monospace, monospace; font-size: 13px; resize: vertical; }
.sheet input[type=checkbox] { width: 22px; height: 22px; accent-color: var(--accent); }
.two { display: grid; grid-template-columns: 1fr 1.3fr; gap: 10px; }
.sheet-actions { display: flex; gap: 8px; align-items: center; margin-top: 6px; }
.spacer { flex: 1; }
.primary, .ghost, .danger { border: 0; border-radius: 10px; padding: 11px 16px; font-weight: 600; }
.primary { background: var(--accent); color: var(--accent-ink); }
.ghost { background: var(--bg); }
.danger { background: none; color: var(--danger); padding-left: 0; }
.small { padding: 8px 12px; }
.full { width: 100%; margin-top: 8px; }
.card { background: var(--bg); border-radius: var(--radius); padding: 14px; margin-bottom: 12px; }
.card .ghost { background: var(--paper); }
.muted { color: var(--muted); font-size: 14px; margin: 0 0 10px; line-height: 1.45; }
.status { padding: 10px 12px; border-radius: 10px; background: var(--paper); margin-bottom: 12px; }
.status.ok { color: var(--accent); }
.status.err { color: var(--danger); }
details { margin-top: 14px; }
summary { font-weight: 600; cursor: pointer; padding: 6px 0; }
.steps { padding-left: 18px; margin-top: 8px; }
.steps li { margin-bottom: 4px; }

.login {
  position: fixed; inset: 0; z-index: 30; background: var(--bg);
  display: grid; place-items: center; padding: 24px calc(24px + env(safe-area-inset-right)) 24px calc(24px + env(safe-area-inset-left));
}
.login form { width: 100%; max-width: 360px; }
.login h1 { margin-bottom: 6px; }
.login input {
  width: 100%; font-size: 17px; padding: 12px 14px; border-radius: 12px;
  border: 1px solid var(--line); background: var(--paper); color: var(--ink); font-family: ui-monospace, monospace;
}
.login-error { color: var(--danger); font-size: 14px; margin: 8px 0 0; }

.toast {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(150px + env(safe-area-inset-bottom)); z-index: 20;
  background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 999px; font-size: 14px;
  display: flex; gap: 12px; align-items: center; box-shadow: 0 6px 20px rgb(0 0 0 / .2); max-width: 90vw;
}
.toast button { border: 0; background: none; color: var(--accent); font-weight: 700; padding: 0; filter: brightness(1.5); }

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