:root {
  --green: #2f7d4f;
  --green-dark: #245f3c;
  --ink: #1c2124;
  --muted: #6b7480;
  --line: #e3e6ea;
  --bg: #f6f7f9;
  --card: #ffffff;
  --danger: #b3261e;
  --radius: 14px;
  --tap: 48px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font: 17px/1.35 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  overscroll-behavior-y: contain;
}

body {
  padding-bottom: calc(84px + env(safe-area-inset-bottom));
}

/* ---------- top bar ---------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: var(--green);
  color: #fff;
  padding: calc(10px + env(safe-area-inset-top)) 14px 8px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, .12);
}

.topbar-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.topbar h1 {
  font-size: 20px;
  font-weight: 650;
  margin: 0;
  letter-spacing: .2px;
}

.topbar-row.sub {
  font-size: 13.5px;
  opacity: .95;
  margin-top: 6px;
}

.icon-btn {
  background: rgba(255, 255, 255, .16);
  border: 0;
  color: #fff;
  font-size: 22px;
  line-height: 1;
  width: 40px;
  height: 36px;
  border-radius: 10px;
}

.link-btn {
  background: none;
  border: 0;
  color: #fff;
  font-size: 13.5px;
  text-decoration: underline;
  padding: 4px 0;
}

.progress {
  height: 6px;
  background: rgba(255, 255, 255, .25);
  border-radius: 99px;
  margin-top: 10px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  width: 0%;
  background: #ffffff;
  border-radius: 99px;
  transition: width .25s ease;
}

/* ---------- list ---------- */

.list { padding: 12px 12px 4px; }

.recipes {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px 12px;
  margin-bottom: 12px;
  font-size: 14px;
}

.recipes h3 {
  margin: 0 0 6px;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .6px;
  color: var(--muted);
}

.recipes a { color: var(--green-dark); }
.recipes div { margin: 3px 0; }

.cat {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 12px;
}

.cat-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  font-weight: 650;
  font-size: 15px;
  border-bottom: 1px solid var(--line);
}

.cat-head .count {
  margin-left: auto;
  font-weight: 500;
  font-size: 13px;
  color: #33404a;
  background: rgba(255, 255, 255, .55);
  border-radius: 99px;
  padding: 2px 9px;
}

.item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 0 12px;
  min-height: var(--tap);
  border-top: 1px solid #f1f3f5;
}

.item:first-of-type { border-top: 0; }

.item-tap {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  flex: 1;
  background: none;
  border: 0;
  padding: 12px 0;
  text-align: left;
  font: inherit;
  color: inherit;
  min-height: var(--tap);
}

.box {
  flex: 0 0 24px;
  width: 24px;
  height: 24px;
  margin-top: 1px;
  border: 2px solid #b9c0c8;
  border-radius: 6px;
  display: grid;
  place-items: center;
  font-size: 15px;
  color: #fff;
  transition: background .15s, border-color .15s;
}

.item.done .box {
  background: var(--green);
  border-color: var(--green);
}

.item-text { flex: 1; }

.item.done .item-text {
  text-decoration: line-through;
  color: #9aa3ac;
}

.item-source {
  display: block;
  font-size: 12px;
  color: var(--muted);
  margin-top: 2px;
}

.item.done .item-source { color: #b6bdc4; }

.del {
  background: none;
  border: 0;
  color: #c3cad1;
  font-size: 20px;
  width: 40px;
  align-self: stretch;
}

/* ---------- bottom bar ---------- */

.actionbar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 20;
  display: flex;
  gap: 10px;
  padding: 10px 12px calc(10px + env(safe-area-inset-bottom));
  background: rgba(246, 247, 249, .94);
  backdrop-filter: blur(8px);
  border-top: 1px solid var(--line);
}

button.primary {
  flex: 1;
  min-height: 52px;
  border: 0;
  border-radius: 12px;
  background: var(--green);
  color: #fff;
  font-size: 17px;
  font-weight: 600;
}

button.primary.alt { background: #3b5f8a; }
button.primary:disabled { opacity: .5; }
button.ghost {
  background: none;
  border: 1px solid var(--line);
  border-radius: 12px;
  min-height: 48px;
  padding: 0 18px;
  font-size: 16px;
  color: var(--ink);
}

/* ---------- sheets ---------- */

.sheet-backdrop {
  position: fixed;
  inset: 0;
  z-index: 40;
  background: rgba(20, 24, 28, .45);
  display: flex;
  align-items: flex-end;
}

.sheet {
  width: 100%;
  max-height: 88vh;
  overflow-y: auto;
  background: var(--card);
  border-radius: 18px 18px 0 0;
  padding: 18px 16px calc(18px + env(safe-area-inset-bottom));
  animation: rise .18s ease-out;
}

.sheet.tall { min-height: 55vh; }

@keyframes rise { from { transform: translateY(14px); opacity: .6; } to { transform: none; opacity: 1; } }

.sheet h2 { margin: 0 0 10px; font-size: 19px; }

.sheet textarea,
.sheet input[type="text"],
.sheet input[type="url"],
.sheet select {
  width: 100%;
  font: inherit;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fbfcfd;
  margin-bottom: 10px;
  color: var(--ink);
}

.sheet textarea { resize: vertical; }

.field { display: block; margin-bottom: 8px; }
.field > span { display: block; font-size: 13px; color: var(--muted); margin-bottom: 4px; }

.sheet-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 8px;
}

.sheet-actions .primary { flex: 0 0 auto; padding: 0 22px; }

.tabs { display: flex; gap: 8px; margin-bottom: 12px; }

.tab {
  flex: 1;
  min-height: 42px;
  border: 1px solid var(--line);
  background: #fbfcfd;
  border-radius: 10px;
  font: inherit;
  color: var(--muted);
}

.tab.active { background: var(--green); border-color: var(--green); color: #fff; font-weight: 600; }

.menu-item {
  display: block;
  width: 100%;
  text-align: left;
  background: none;
  border: 0;
  border-bottom: 1px solid #f1f3f5;
  padding: 15px 4px;
  font: inherit;
  color: var(--ink);
}

.menu-item.danger { color: var(--danger); }

/* ---------- misc ---------- */

.empty { text-align: center; padding: 48px 24px; color: var(--muted); }
.empty-emoji { font-size: 46px; margin: 0 0 8px; }
.empty strong { color: var(--ink); }

.muted { color: var(--muted); }
.small { font-size: 13px; }
.hidden { display: none !important; }

.toast {
  position: fixed;
  left: 12px;
  right: 12px;
  bottom: calc(94px + env(safe-area-inset-bottom));
  z-index: 60;
  background: #1c2124;
  color: #fff;
  padding: 13px 15px;
  border-radius: 12px;
  font-size: 15px;
  box-shadow: 0 6px 24px rgba(0, 0, 0, .25);
}

.toast.bad { background: var(--danger); }

.busy {
  position: fixed;
  inset: 0;
  z-index: 70;
  background: rgba(246, 247, 249, .82);
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 14px;
  color: var(--muted);
  font-size: 15px;
}

.spinner {
  width: 34px;
  height: 34px;
  border: 3px solid #d7dce1;
  border-top-color: var(--green);
  border-radius: 50%;
  animation: spin .8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.arch-shop { border-bottom: 1px solid var(--line); padding: 10px 0; }
.arch-shop h4 { margin: 0 0 4px; font-size: 15px; }
.arch-shop p { margin: 0; font-size: 13px; color: var(--muted); }

.offline-banner {
  background: #8a5300;
  color: #fff;
  text-align: center;
  font-size: 13px;
  padding: 6px 10px;
}
