:root {
  --bg: #0e0f12;
  --bg2: #15171c;
  --surface: #1b1e25;
  --surface2: #232733;
  --line: #2c313c;
  --text: #f4f5f7;
  --muted: #8b929e;
  --red: #e0322b;
  --red-dim: #7a1f1b;
  --amber: #f0a020;
  --green: #2fb36b;
  --shadow: 0 6px 20px rgba(0, 0, 0, 0.45);
  --header-h: 150px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 17px;
  line-height: 1.3;
  padding-bottom: 96px;
}
.font-head { font-family: "Barlow Condensed", "Arial Narrow", sans-serif; text-transform: uppercase; letter-spacing: 0.04em; }

/* ---- Header ---- */
header {
  position: sticky; top: 0; z-index: 30;
  background: linear-gradient(180deg, #15171c 0%, #0e0f12 100%);
  border-bottom: 2px solid var(--red);
  padding: 14px 16px 8px;
  box-shadow: var(--shadow);
  overflow: hidden;
}
.brand { display: flex; align-items: center; gap: 12px; position: relative; }
.badge {
  font-family: "Barlow Condensed", sans-serif; font-weight: 700;
  background: var(--red); color: #fff; font-size: 26px;
  width: 46px; height: 46px; border-radius: 10px;
  display: grid; place-items: center; line-height: 1;
  box-shadow: inset 0 -3px 0 rgba(0,0,0,0.25);
}
.brand h1 { font-family: "Barlow Condensed", sans-serif; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; margin: 0; font-size: 26px; }
.brand h1 small { display: block; font-size: 12px; color: var(--muted); letter-spacing: 0.18em; font-weight: 500; }

/* ---- Mode toggle ---- */
.modes { display: flex; gap: 4px; margin-top: 12px; background: var(--surface); padding: 4px; border-radius: 12px; position: relative; }
.modes button {
  flex: 1; border: 0; background: transparent; color: var(--muted);
  font-family: "Barlow Condensed", sans-serif; text-transform: uppercase; letter-spacing: 0.06em;
  font-size: 18px; font-weight: 600; padding: 9px 0; border-radius: 9px; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
}
.modes button.active { background: var(--red); color: #fff; }
.pill {
  background: #fff; color: var(--red); font-family: -apple-system, sans-serif; font-weight: 700;
  font-size: 12px; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 10px;
  display: inline-flex; align-items: center; justify-content: center; letter-spacing: 0;
}
.modes button.active .pill { background: rgba(0,0,0,0.25); color: #fff; }

/* ---- Toolbar ---- */
.toolbar { display: flex; gap: 8px; align-items: center; margin-top: 10px; position: relative; }
.toolbar input.search { flex: 1; background: var(--surface); border: 1px solid var(--line); color: var(--text); border-radius: 10px; padding: 11px 12px; font-size: 16px; }
.btn { border: 1px solid var(--line); background: var(--surface); color: var(--text); border-radius: 10px; padding: 10px 13px; font-size: 15px; font-weight: 600; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.btn.active { background: var(--amber); color: #1a1205; border-color: var(--amber); }
.btn.danger { color: #ffb4b0; border-color: var(--red-dim); }

/* ---- Jump bar ---- */
.jump { display: flex; gap: 6px; overflow-x: auto; margin-top: 10px; padding-bottom: 2px; scrollbar-width: none; position: relative; }
.jump::-webkit-scrollbar { display: none; }
.jump.hidden { display: none; }
.jump .chip {
  flex: none; background: var(--surface); border: 1px solid var(--line); color: var(--muted);
  border-radius: 20px; padding: 6px 11px; font-size: 13px; cursor: pointer; white-space: nowrap;
  display: inline-flex; align-items: center; gap: 5px;
}
.jump .chip .n { color: var(--red); font-weight: 700; }

main { padding: 0 12px; max-width: 720px; margin: 0 auto; }

/* ---- Category sections ---- */
.cat { margin-bottom: 14px; }
.cat-head {
  position: sticky; top: var(--header-h); z-index: 10;
  display: flex; align-items: center; justify-content: space-between;
  font-family: "Barlow Condensed", sans-serif; text-transform: uppercase; letter-spacing: 0.06em;
  font-size: 19px; font-weight: 700; color: #cfd4dd;
  padding: 10px 6px 8px; border-bottom: 1px solid var(--line); margin-bottom: 6px;
  background: linear-gradient(180deg, var(--bg) 70%, rgba(14,15,18,0.85)); cursor: pointer;
}
.cat-head .left { display: flex; align-items: center; gap: 8px; min-width: 0; }
.cat-head .caret { color: var(--muted); font-size: 14px; transition: transform 0.15s; }
.cat.collapsed .cat-head .caret { transform: rotate(-90deg); }
.cat-head .count { color: var(--red); font-size: 15px; margin-left: 2px; }
.cat-head .tools { display: flex; gap: 2px; }
.cat.collapsed .item, .cat.collapsed .cat-add { display: none; }

/* ---- Item rows ---- */
.item { display: flex; align-items: center; gap: 12px; background: var(--surface); border: 1px solid var(--line); border-radius: 11px; padding: 12px 13px; margin-bottom: 7px; cursor: pointer; transition: background 0.12s, border-color 0.12s, transform 0.08s; }
.item:active { transform: scale(0.99); background: var(--surface2); }
.item.on { border-color: var(--red); background: #221a1a; }
.item.on { border-left: 4px solid var(--red); }
.item .tick { width: 24px; height: 24px; flex: none; border-radius: 7px; border: 2px solid var(--line); display: grid; place-items: center; font-size: 15px; color: transparent; }
.item.on .tick { border-color: var(--red); color: var(--red); }
.item .name { flex: 1; }
.item .qty { width: 86px; flex: none; background: var(--bg2); border: 1px solid var(--line); color: var(--text); border-radius: 8px; padding: 7px 8px; font-size: 14px; text-align: center; }
.item .qty::placeholder { color: #5b626d; }
.item.flash { animation: flash 0.5s ease; }
@keyframes flash { 0% { background: #3a2a18; } 100% { } }

/* ---- Shopping mode ---- */
.shop .item.checked { opacity: 0.45; background: var(--bg2); border-color: var(--line); border-left-color: var(--line); }
.shop .item.checked .name { text-decoration: line-through; }
.shop .item .tick { width: 28px; height: 28px; border-radius: 8px; }
.shop .item.checked .tick { border-color: var(--green); color: var(--green); }
.shop .item .qtytext { color: var(--amber); font-weight: 600; font-size: 14px; }
.tick.pop { animation: pop 0.32s ease; }
@keyframes pop { 0% { transform: scale(1); } 45% { transform: scale(1.35); } 100% { transform: scale(1); } }

/* ---- Progress ---- */
.progress { margin: 12px 4px 14px; }
.progress .bar { height: 8px; background: var(--surface); border-radius: 6px; overflow: hidden; }
.progress .bar i { display: block; height: 100%; background: var(--green); width: 0; transition: width 0.25s; }
.progress .lbl { font-size: 14px; color: var(--muted); margin-bottom: 6px; display: flex; justify-content: space-between; }

/* ---- Edit affordances ---- */
.editbtn { color: var(--muted); background: transparent; border: 0; font-size: 18px; padding: 6px; cursor: pointer; flex: none; }
.cat-add, .add-cat { width: 100%; border: 1px dashed var(--line); background: transparent; color: var(--muted); border-radius: 10px; padding: 10px; font-size: 14px; cursor: pointer; margin-top: 2px; }
.add-cat { margin: 4px 0 40px; border-color: var(--red-dim); color: #ffb4b0; }

/* ---- Empty / misc ---- */
.empty { text-align: center; color: var(--muted); padding: 48px 20px; }
.empty .big { font-family: "Barlow Condensed", sans-serif; font-size: 30px; text-transform: uppercase; color: #5b626d; }
.coffee-note { text-align: center; color: var(--amber); font-family: "Barlow Condensed", sans-serif; letter-spacing: 0.1em; text-transform: uppercase; font-size: 15px; padding: 10px 0 24px; }

/* ---- Floating reset ---- */
.fab { position: fixed; left: 0; right: 0; bottom: 0; padding: 12px 16px calc(12px + env(safe-area-inset-bottom)); background: linear-gradient(0deg, var(--bg) 60%, transparent); display: flex; gap: 10px; max-width: 720px; margin: 0 auto; z-index: 25; }
.fab .btn { flex: 1; justify-content: center; padding: 14px; font-size: 16px; }

.toast { position: fixed; bottom: 90px; left: 50%; transform: translateX(-50%); background: var(--surface2); border: 1px solid var(--line); color: var(--text); padding: 10px 16px; border-radius: 10px; font-size: 14px; box-shadow: var(--shadow); opacity: 0; transition: opacity 0.2s; pointer-events: none; z-index: 40; }
.toast.show { opacity: 1; }
