:root {
  --bg: #16110d;
  --surface: #221a14;
  --surface-2: #2d231b;
  --line: #3c2f25;
  --text: #f3e9dc;
  --muted: #b3a291;
  --accent: #e0a64b;
  --accent-ink: #1d1409;
  --low: #d9774a;
  --radius: 14px;
  color-scheme: dark;
}

* { box-sizing: border-box; }

html, body { margin: 0; }

body {
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  padding: env(safe-area-inset-top) 16px calc(24px + env(safe-area-inset-bottom));
  max-width: 640px;
  margin: 0 auto;
}

.top { padding: 28px 4px 12px; }
.top h1 {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 2.2rem;
  letter-spacing: 0.02em;
  color: var(--accent);
}
.tag { margin: 2px 0 0; color: var(--muted); }

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px 16px;
  margin: 14px 0;
}
.card h2 {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0 0 4px;
  font-size: 1.1rem;
}
.num {
  display: inline-grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--accent);
  color: var(--accent-ink);
  font-size: 0.85rem;
  font-weight: 700;
}
.count { color: var(--muted); font-weight: 400; font-size: 0.95rem; }
.hint { margin: 0 0 14px; color: var(--muted); font-size: 0.92rem; }

.row { display: flex; gap: 10px; flex-wrap: wrap; }

.btn {
  appearance: none;
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--text);
  font: inherit;
  font-weight: 600;
  padding: 11px 16px;
  border-radius: 10px;
  cursor: pointer;
  text-align: center;
  flex: 1 1 auto;
}
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.wide { display: block; width: 100%; margin-top: 14px; }
.btn.big { padding: 15px; font-size: 1.05rem; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn:focus-visible, .tab:focus-visible, .chip:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.link {
  background: none;
  border: 0;
  color: var(--muted);
  font: inherit;
  font-size: 0.88rem;
  text-decoration: underline;
  padding: 8px 0 0;
  cursor: pointer;
}

.thumbs { display: grid; grid-template-columns: repeat(auto-fill, minmax(84px, 1fr)); gap: 8px; margin-top: 14px; }
.thumbs:empty { display: none; }
.thumb { position: relative; aspect-ratio: 1; border-radius: 10px; overflow: hidden; border: 1px solid var(--line); }
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb button {
  position: absolute; top: 4px; right: 4px;
  width: 26px; height: 26px; border-radius: 50%;
  border: 0; background: rgba(0,0,0,.7); color: #fff; font-size: 16px; line-height: 1; cursor: pointer;
}

.status { margin: 10px 0 0; color: var(--muted); font-size: 0.92rem; min-height: 0; }
.status:empty { display: none; }
.status.error { color: var(--low); }
.status.busy::before {
  content: "";
  display: inline-block;
  width: 12px; height: 12px; margin-right: 8px; vertical-align: -1px;
  border: 2px solid var(--muted); border-top-color: transparent; border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.bottles { list-style: none; margin: 0; padding: 0; }
.bottles li {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 0; border-bottom: 1px solid var(--line);
}
.bottles li:last-child { border-bottom: 0; }
.bottles .meta { flex: 1; min-width: 0; }
.bottles .name { display: block; overflow-wrap: anywhere; }
.bottles .style { display: block; color: var(--muted); font-size: 0.85rem; }
.bottles .low { color: var(--low); font-size: 0.8rem; margin-left: 6px; }
.bottles .remove {
  flex: none; width: 34px; height: 34px; border-radius: 8px;
  border: 1px solid var(--line); background: transparent; color: var(--muted); font-size: 18px; cursor: pointer;
}

.add { display: flex; gap: 8px; margin-top: 12px; }
.add input {
  flex: 1; min-width: 0;
  background: var(--bg); color: var(--text);
  border: 1px solid var(--line); border-radius: 10px;
  padding: 11px 12px; font: inherit;
}
.add .btn { flex: none; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  border: 1px solid var(--line); background: transparent; color: var(--muted);
  border-radius: 999px; padding: 7px 13px; font: inherit; font-size: 0.92rem; cursor: pointer;
}
.chip[aria-pressed="true"] { background: var(--surface-2); color: var(--text); border-color: var(--accent); }

.tabs { display: flex; gap: 6px; margin: 22px 0 10px; background: var(--surface); padding: 4px; border-radius: 12px; border: 1px solid var(--line); }
.tab {
  flex: 1; border: 0; background: transparent; color: var(--muted);
  font: inherit; font-weight: 600; padding: 10px; border-radius: 9px; cursor: pointer;
}
.tab.active { background: var(--surface-2); color: var(--text); }

.drink { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); margin: 10px 0; overflow: hidden; }
.drink summary { list-style: none; cursor: pointer; padding: 14px 16px; }
.drink summary::-webkit-details-marker { display: none; }
.drink h3 { margin: 0; font-family: Georgia, serif; font-size: 1.2rem; }
.drink .desc { margin: 4px 0 8px; color: var(--muted); font-size: 0.92rem; }
.tags { display: flex; flex-wrap: wrap; gap: 6px; }
.tags span { font-size: 0.78rem; padding: 2px 9px; border-radius: 999px; background: var(--surface-2); color: var(--muted); }
.tags .need { background: rgba(217,119,74,.15); color: var(--low); }
.recipe { padding: 0 16px 16px; border-top: 1px solid var(--line); }
.recipe h4 { margin: 14px 0 6px; font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--accent); }
.recipe ul, .recipe ol { margin: 0; padding-left: 20px; }
.recipe li { margin: 3px 0; }
.recipe .amt { font-weight: 600; }
.empty { color: var(--muted); text-align: center; padding: 20px 0; }

.foot { text-align: center; color: var(--muted); font-size: 0.8rem; margin-top: 28px; }

/* ---------- v2: bottle types, pantry groups, drink list ---------- */

select, input[type="search"] {
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 9px 10px;
  font: inherit;
  font-size: 0.92rem;
  min-width: 0;
}
.bottles select { display: block; width: 100%; margin-top: 6px; padding: 6px 8px; font-size: 0.85rem; color: var(--muted); }
.bottles li.is-low select { border-color: var(--low); color: var(--text); }

.pantry-group { border-top: 1px solid var(--line); padding: 10px 0 4px; }
.pantry-group:first-child { border-top: 0; padding-top: 0; }
.pantry-group summary { cursor: pointer; font-weight: 600; margin-bottom: 8px; color: var(--text); }
.pantry-group .chips { margin-bottom: 8px; }

.section-title { font-size: 1.25rem; margin: 26px 4px 6px; font-family: Georgia, serif; color: var(--accent); }
#drinks-section > .hint { padding: 0 4px; }

.filters { display: grid; grid-template-columns: 1fr 1fr auto; gap: 8px; margin-bottom: 6px; }
.filters input[type="search"] { grid-column: 1 / -1; }
.btn.small { padding: 8px 12px; flex: none; font-size: 0.9rem; min-width: 52px; }

.drink-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.tier { flex: none; font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); }
.tier-deep_cut { color: var(--accent); }
.drink.deep { border-color: rgba(224, 166, 75, 0.45); }
.recipe li.missing { color: var(--low); }
.recipe .muted { color: var(--muted); }
.recipe .sub { color: var(--accent); font-size: 0.88rem; }
.recipe .origin { margin: 14px 0 0; color: var(--muted); font-size: 0.85rem; font-style: italic; }

.buy { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 16px; margin: 10px 0; }
.buy-head { display: flex; justify-content: space-between; gap: 10px; align-items: baseline; }
.buy-list { margin: 4px 0 0; color: var(--muted); font-size: 0.9rem; }
