:root {
  --bg: #faf7f2;
  --card: #ffffff;
  --text: #2b2622;
  --muted: #8a8079;
  --line: #ebe4dc;
  --accent: #e8833a;
  --accent-text: #ffffff;
  --warn-bg: #fdecd9;
  --warn-text: #9a4a0c;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1c1a18;
    --card: #262320;
    --text: #f1ece6;
    --muted: #9c928a;
    --line: #37322d;
    --accent: #f0934f;
    --accent-text: #1c1a18;
    --warn-bg: #4a3120;
    --warn-text: #ffc79c;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 17px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-tap-highlight-color: transparent;
}
main, .login {
  max-width: 560px;
  margin: 0 auto;
  padding: calc(env(safe-area-inset-top) + 12px) 16px calc(env(safe-area-inset-bottom) + 32px);
}
[hidden] { display: none !important; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
input {
  font: inherit;
  color: var(--text);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px 14px;
  min-width: 0;
}
input:focus { outline: 2px solid var(--accent); outline-offset: -1px; }

header { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 12px; }
h1 { font-size: 26px; margin: 0; }
h1 { display: flex; align-items: center; gap: 10px; }
.logo { width: 36px; height: 36px; border-radius: 9px; flex: none; }
.login h1 { justify-content: center; }
.status { font-size: 13px; padding: 4px 10px; border-radius: 999px; background: var(--line); color: var(--muted); white-space: nowrap; }
.status.offline { background: var(--warn-bg); color: var(--warn-text); }

#add-form { display: flex; gap: 8px; }
#name { flex: 1; }
#qty { width: 90px; }
#add-form button {
  width: 48px; flex: none;
  border-radius: 12px;
  background: var(--accent); color: var(--accent-text);
  font-size: 26px; line-height: 1;
}

.suggestions { list-style: none; margin: 6px 0 0; padding: 0; background: var(--card); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.suggestions li + li { border-top: 1px solid var(--line); }
.suggestions button { display: block; width: 100%; text-align: left; padding: 12px 14px; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.chip { padding: 7px 12px; border-radius: 999px; background: var(--card); border: 1px solid var(--line); font-size: 15px; }
.chip::before { content: "+ "; color: var(--accent); }

.list { list-style: none; margin: 16px 0 0; padding: 0; }
.item { display: flex; align-items: center; background: var(--card); border-radius: 12px; margin-bottom: 6px; min-height: 52px; }
.item-main { flex: 1; display: flex; align-items: center; gap: 12px; padding: 12px 4px 12px 14px; text-align: left; min-width: 0; }
.item-name { overflow-wrap: anywhere; }
.box { flex: none; width: 22px; height: 22px; border-radius: 50%; border: 2px solid var(--muted); }
.item-qty { padding: 12px 8px; color: var(--muted); font-size: 15px; white-space: nowrap; max-width: 40%; overflow: hidden; text-overflow: ellipsis; }
.item-qty.empty-qty { opacity: .35; font-size: 13px; }
.done .item-qty.empty-qty { visibility: hidden; }
.item-del { padding: 12px 14px; color: var(--muted); font-size: 22px; line-height: 1; }
.qty-edit { width: 110px; padding: 8px 10px; margin-right: 4px; }

.empty { color: var(--muted); text-align: center; margin: 24px 0; }

.done-header { display: flex; align-items: baseline; justify-content: space-between; margin-top: 28px; }
h2 { font-size: 15px; font-weight: 600; color: var(--muted); margin: 0; text-transform: uppercase; letter-spacing: .04em; }
.link { color: var(--accent); font-size: 15px; padding: 6px 0 6px 12px; }
.done .item { background: transparent; border: 1px solid var(--line); }
.done .item-name { text-decoration: line-through; color: var(--muted); }
.done .box { background: var(--accent); border-color: var(--accent); position: relative; }
.done .box::after {
  content: ""; position: absolute; left: 5px; top: 1px; width: 6px; height: 11px;
  border: solid var(--accent-text); border-width: 0 2px 2px 0; transform: rotate(45deg);
}

.login { display: flex; flex-direction: column; gap: 12px; padding-top: calc(env(safe-area-inset-top) + 20vh); text-align: center; }
.login p { color: var(--muted); margin: 0 0 8px; }
.login button { padding: 12px; border-radius: 12px; background: var(--accent); color: var(--accent-text); font-weight: 600; }
.error { color: #d0453a; }
