:root {
  --orange:      #d2691e;
  --orange-deep: #b4541a;
  --orange-bright:#e8730f;
  --ink:         #2a2018;
  --ink-soft:    #6a5a4a;
  --ink-faint:   #9a8a7a;
  --cream:       #fdf8f3;
  --surface:     #ffffff;
  --line:        #f0e6dd;
  --line-strong: #e4d5c6;
  --good:        #2e7d4f;

  --r-lg: 16px;
  --r-md: 12px;
  --r-sm: 9px;
  --shadow: 0 1px 3px rgba(90,60,30,.06), 0 6px 20px rgba(90,60,30,.05);
  --tap: 52px;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: "Barlow", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  color: var(--ink);
  background: var(--cream);
  padding-bottom: env(safe-area-inset-bottom);
}

/* ── Top bar ───────────────────────────────────────────── */
.topbar {
  position: sticky; top: 0; z-index: 20; overflow: hidden;
  background: linear-gradient(135deg, var(--orange-bright), var(--orange-deep));
  padding-top: env(safe-area-inset-top);
  box-shadow: 0 2px 14px rgba(140,70,20,.22);
}
.topbar::after {
  content: ""; position: absolute; right: -50px; top: -70px;
  width: 240px; height: 240px; border-radius: 50%;
  background: radial-gradient(circle, rgba(255,255,255,.17), transparent 68%);
  pointer-events: none;
}
.topbar__inner {
  max-width: 720px; margin: 0 auto;
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; padding: 14px 18px;
}
.eyebrow {
  margin: 0; font-size: 10.5px; letter-spacing: .14em; text-transform: uppercase;
  color: #ffe7d0; font-weight: 600;
}
.topbar h1 {
  margin: 1px 0 0; font-family: "Archivo", sans-serif; font-weight: 800;
  font-size: 30px; color: #fff; letter-spacing: .04em; line-height: 1;
}
.subtitle {
  margin: 3px 0 0; font-size: 13px; font-weight: 600;
  color: #ffe7d0; letter-spacing: .02em;
}
.loc-pill {
  background: rgba(255,255,255,.18); color: #fff;
  border: 1px solid rgba(255,255,255,.35);
  padding: 6px 14px; border-radius: 999px;
  font-size: 13px; font-weight: 600; white-space: nowrap;
}

/* ── Sheet tabs ────────────────────────────────────────── */
.tabs {
  max-width: 720px; margin: 0 auto;
  display: flex; gap: 6px; padding: 0 14px 12px;
  overflow-x: auto; -webkit-overflow-scrolling: touch;
}
.tab {
  flex: 0 0 auto; background: rgba(255,255,255,.14); color: #ffe7d0;
  border: 1px solid rgba(255,255,255,.28); border-radius: 999px;
  font-family: "Archivo", sans-serif; font-weight: 700; font-size: 14px;
  padding: 9px 20px; min-height: 42px; cursor: pointer;
  transition: background .15s, color .15s, transform .12s;
}
.tab:active { transform: translateY(1px); }
.tab.is-active { background: #fff; color: var(--orange-deep); border-color: #fff; box-shadow: 0 3px 12px rgba(80,40,10,.2); }
.topbar__inner, .tabs { position: relative; z-index: 1; }

/* ── Layout ────────────────────────────────────────────── */
main { max-width: 720px; margin: 0 auto; padding: 16px 14px 0; }
.card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-lg); box-shadow: var(--shadow);
  padding: 16px; margin-bottom: 14px;
}
.spacer { height: 96px; }

/* ── Meta fields ───────────────────────────────────────── */
.meta { display: grid; gap: 12px; }
@media (min-width: 560px) { .meta { grid-template-columns: 1fr 1fr 1fr; } }
.field { display: flex; flex-direction: column; gap: 5px; }
.field > span { font-size: 12px; font-weight: 600; color: var(--ink-soft); letter-spacing: .02em; }
input, textarea, select {
  font: inherit; color: var(--ink);
  background: var(--cream);
  border: 1.5px solid var(--line-strong); border-radius: var(--r-sm);
  padding: 12px 13px; min-height: var(--tap);
  width: 100%; transition: border-color .15s, box-shadow .15s;
}
textarea { min-height: 0; resize: vertical; }
input:focus, textarea:focus {
  outline: none; border-color: var(--orange);
  box-shadow: 0 0 0 3px rgba(210,105,30,.15);
}

/* ── Toolbar ───────────────────────────────────────────── */
.toolbar { display: flex; gap: 10px; margin-bottom: 14px; }
.toolbar #search { flex: 1; min-height: var(--tap); }
.ghost-btn {
  background: var(--surface); color: var(--orange-deep);
  border: 1.5px solid var(--line-strong); border-radius: var(--r-sm);
  font-weight: 600; padding: 0 16px; min-height: var(--tap);
  cursor: pointer; white-space: nowrap; transition: background .15s, border-color .15s;
}
.ghost-btn:hover { background: #fff7f0; border-color: var(--orange); }
.ghost-btn:active { transform: translateY(1px); }
.ghost-btn.add { width: 100%; margin-top: 6px; }

/* ── Sections & items ──────────────────────────────────── */
.section-title {
  margin: 0 0 4px; font-family: "Archivo", sans-serif;
  font-size: 17px; font-weight: 700; color: var(--ink);
}
.section-head {
  display: flex; align-items: baseline; gap: 8px; margin-bottom: 10px;
}
.section-head .badge {
  font-size: 11px; font-weight: 700; color: var(--orange-deep);
  background: #fbeada; border-radius: 999px; padding: 3px 9px;
}
.section-head .sel-pill {
  margin-left: auto; font-size: 11px; font-weight: 700; color: #fff;
  background: var(--orange); border-radius: 999px; padding: 3px 10px;
  white-space: nowrap;
}
.section-dot { color: var(--orange); }
.hint { margin: 0 0 10px; font-size: 12.5px; color: var(--ink-faint); }

.item {
  display: grid; grid-template-columns: 1fr auto; align-items: center;
  gap: 10px; padding: 4px 8px; margin: 0 -8px;
  border-bottom: 1px solid var(--line);
  border-radius: 10px; position: relative;
  transition: background .15s;
}
.item:last-child { border-bottom: none; }
.item.is-checked {
  background: linear-gradient(90deg, #fff3e8, #fff8f2);
  border-bottom-color: transparent;
}
.item.is-checked::before {
  content: ""; position: absolute; left: -8px; top: 6px; bottom: 6px;
  width: 4px; border-radius: 0 4px 4px 0; background: var(--orange);
}
.item__label {
  display: flex; align-items: center; gap: 13px;
  min-height: var(--tap); cursor: pointer; flex: 1;
  font-size: 16px; line-height: 1.25; user-select: none;
}
.item__box {
  width: 26px; height: 26px; flex: 0 0 26px;
  border: 2px solid var(--line-strong); border-radius: 7px;
  background: var(--surface); position: relative; transition: all .15s;
}
.item input[type=checkbox] { position: absolute; opacity: 0; width: 0; height: 0; }
.item input:checked + .item__label .item__box {
  background: var(--orange); border-color: var(--orange);
}
.item input:checked + .item__label .item__box::after {
  content: ""; position: absolute; left: 8px; top: 3px;
  width: 6px; height: 12px; border: solid #fff;
  border-width: 0 3px 3px 0; transform: rotate(45deg);
}
.item input:focus-visible + .item__label .item__box {
  box-shadow: 0 0 0 3px rgba(210,105,30,.3);
}
.item input:checked + .item__label .item__name { font-weight: 600; }
.item__qty {
  width: 92px; opacity: .5; pointer-events: none;
  min-height: 44px; padding: 8px 10px; text-align: center;
  transition: opacity .15s;
}
.item.is-checked .item__qty { opacity: 1; pointer-events: auto; }
.item.is-hidden { display: none; }

.writein-row { display: flex; gap: 10px; margin-bottom: 8px; }
.writein-row input.name { flex: 1; }
.writein-row input.qty { width: 92px; text-align: center; }

/* ── Submit bar ────────────────────────────────────────── */
.submitbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  background: rgba(255,255,255,.94); backdrop-filter: blur(10px);
  border-top: 1px solid var(--line-strong);
  display: flex; align-items: center; gap: 12px;
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
}
.submitbar .count { font-weight: 700; color: var(--ink-soft); font-size: 15px; }
.submit-btn {
  margin-left: auto;
  background: linear-gradient(135deg, var(--orange-bright), var(--orange-deep));
  color: #fff; border: none; border-radius: var(--r-md);
  font-family: "Archivo", sans-serif; font-weight: 700; font-size: 16px;
  padding: 0 26px; min-height: var(--tap); cursor: pointer;
  box-shadow: 0 4px 14px rgba(180,84,26,.35); transition: transform .12s, opacity .15s;
}
.submit-btn:active { transform: translateY(1px); }
.submit-btn:disabled { opacity: .45; box-shadow: none; cursor: not-allowed; }

/* ── Loading / toast ───────────────────────────────────── */
.loading {
  max-width: 720px; margin: 40px auto; text-align: center;
  color: var(--ink-faint); font-size: 15px;
}
.toast {
  position: fixed; left: 50%; bottom: 92px; transform: translateX(-50%);
  z-index: 40; max-width: 90%; text-align: center;
  background: var(--ink); color: #fff; padding: 14px 22px;
  border-radius: var(--r-md); font-weight: 600; font-size: 15px;
  box-shadow: 0 8px 30px rgba(0,0,0,.25);
  animation: pop .25s ease-out;
}
.toast.good { background: var(--good); }
.toast.bad { background: #b3261e; }
@keyframes pop { from { opacity: 0; transform: translate(-50%, 10px); } }

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