:root {
  color-scheme: light;
  --paper: #f4f2ed;
  --surface: #fbfaf7;
  --ink: #191a18;
  --muted: #6f706a;
  --line: #dedbd2;
  --accent: #244c3d;
  --accent-soft: #e5ece7;
  --gold: #a9874f;
  --shadow: 0 18px 45px rgb(44 43 38 / 8%);
  --radius: 22px;
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

html { background: var(--paper); }

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at 85% -10%, rgb(169 135 79 / 10%), transparent 28rem),
    var(--paper);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
}

button, input { font: inherit; }
button { -webkit-tap-highlight-color: transparent; }

.access-dialog {
  width: min(calc(100% - 32px), 430px);
  border: 1px solid rgb(255 255 255 / 70%);
  border-radius: 22px;
  padding: 0;
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 28px 80px rgb(20 25 22 / 28%);
}
.access-dialog::backdrop { background: rgb(24 28 26 / 48%); backdrop-filter: blur(4px); }
.access-dialog form { display: grid; gap: 17px; padding: 26px; }
.access-dialog h2 { font-size: 1.6rem; }
.access-copy { margin: -7px 0 2px; color: var(--muted); line-height: 1.5; }
.access-error { margin: -4px 0 0; color: #9d493f; font-size: 0.82rem; font-weight: 700; }
.access-error[hidden] { display: none; }
.access-dialog .add-button { grid-column: auto; width: 100%; }

.app-shell {
  width: min(100%, 760px);
  margin: 0 auto;
  padding: max(22px, env(safe-area-inset-top)) 18px max(96px, calc(36px + env(safe-area-inset-bottom)));
}

.topbar,
.composer-heading,
.shopping-heading,
.shopping-item {
  display: flex;
  align-items: center;
}

.topbar {
  justify-content: space-between;
  gap: 16px;
  margin: 4px 2px 28px;
}

.eyebrow, .section-kicker {
  margin: 0 0 5px;
  color: var(--gold);
  font-size: 0.72rem;
  font-weight: 760;
  letter-spacing: 0.13em;
  text-transform: uppercase;
}

h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 0; font-size: clamp(1.65rem, 6vw, 2.2rem); letter-spacing: -0.045em; }
h2 { margin-bottom: 0; font-size: 1.45rem; letter-spacing: -0.035em; }

.status {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  flex: 0 0 auto;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 8px 10px;
  color: var(--muted);
  background: rgb(251 250 247 / 72%);
  font-size: 0.72rem;
  font-weight: 650;
}

.status-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--gold); }

.composer {
  position: relative;
  overflow: hidden;
  border: 1px solid rgb(255 255 255 / 70%);
  border-radius: var(--radius);
  padding: 20px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.composer::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 4px;
  background: var(--gold);
}

.composer-heading, .shopping-heading { justify-content: space-between; gap: 16px; }
.shortcut { color: #aaa79e; font-size: 1.2rem; }

#add-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 92px;
  gap: 10px;
  margin-top: 20px;
}

.field { display: flex; flex-direction: column; gap: 7px; }
.field span { color: var(--muted); font-size: 0.72rem; font-weight: 700; }

.field input {
  width: 100%;
  height: 52px;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 0 14px;
  outline: none;
  background: white;
  color: var(--ink);
  font-size: 1rem;
  transition: border-color 160ms, box-shadow 160ms;
}

.field input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgb(36 76 61 / 11%); }
.field input::placeholder { color: #aaa9a3; }

.add-button {
  grid-column: 1 / -1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  min-height: 54px;
  border: 0;
  border-radius: 15px;
  padding: 0 18px;
  background: var(--accent);
  color: white;
  font-weight: 760;
  cursor: pointer;
  box-shadow: 0 10px 22px rgb(36 76 61 / 16%);
}

.add-button span { font-size: 1.35rem; font-weight: 400; }
.add-button:active { transform: translateY(1px); }

.category-hint { margin: 11px 2px 0; color: var(--muted); font-size: 0.76rem; }

.shopping { margin-top: 35px; }
.shopping-heading { margin: 0 2px 18px; }
.item-count { color: var(--muted); font-size: 0.82rem; font-weight: 650; }

.category-group { margin-top: 24px; }
.category-group:first-child { margin-top: 0; }
.category-title {
  margin: 0 4px 9px;
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 780;
  letter-spacing: 0.095em;
  text-transform: uppercase;
}

.category-items {
  overflow: hidden;
  border: 1px solid rgb(222 219 210 / 80%);
  border-radius: 18px;
  background: rgb(251 250 247 / 84%);
}

.shopping-item {
  min-height: 68px;
  gap: 12px;
  padding: 8px 9px 8px 11px;
  border-bottom: 1px solid var(--line);
}
.shopping-item:last-child { border-bottom: 0; }

.check-button {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  flex: 0 0 auto;
  border: 1.5px solid #b7b6af;
  border-radius: 13px;
  background: white;
  color: transparent;
  cursor: pointer;
}
.check-button:focus-visible, .bought-button:focus-visible, .add-button:focus-visible, .toast button:focus-visible {
  outline: 3px solid rgb(36 76 61 / 30%);
  outline-offset: 2px;
}

.item-copy { min-width: 0; flex: 1; display: flex; flex-direction: column; gap: 3px; }
.item-name {
  white-space: normal;
  overflow-wrap: anywhere;
  hyphens: auto;
  line-height: 1.3;
  font-size: 1rem;
}
.item-meta { color: var(--muted); font-size: 0.77rem; }

.bought-button {
  min-width: 86px;
  min-height: 46px;
  border: 0;
  border-radius: 13px;
  padding: 0 12px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 0.78rem;
  font-weight: 780;
  cursor: pointer;
}
.bought-button:active, .check-button:active { transform: scale(0.97); }

.shopping-item.leaving { animation: leave 260ms ease forwards; }
@keyframes leave { to { opacity: 0; transform: translateX(18px); } }

.completed {
  margin-top: 42px;
  padding-top: 28px;
  border-top: 1px solid var(--line);
}

.completed-list {
  overflow: hidden;
  border: 1px solid rgb(222 219 210 / 75%);
  border-radius: 18px;
  background: rgb(251 250 247 / 58%);
}

.completed-list:empty { display: none; }
.completed-empty { margin: 6px 2px 0; color: var(--muted); font-size: 0.86rem; }
.completed-empty[hidden] { display: none; }

.completed-item { opacity: 0.78; }
.completed-item .item-name { color: var(--muted); text-decoration: line-through; text-decoration-thickness: 1px; }
.completed-check {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  flex: 0 0 auto;
  border-radius: 13px;
  background: var(--accent);
  color: white;
  font-weight: 800;
}

.restore-button,
.delete-button {
  min-height: 44px;
  border: 0;
  border-radius: 12px;
  cursor: pointer;
}

.restore-button {
  padding: 0 11px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 0.76rem;
  font-weight: 760;
}

.delete-button {
  width: 44px;
  flex: 0 0 auto;
  background: transparent;
  color: #8d665d;
  font-size: 1.45rem;
  line-height: 1;
}

.restore-button:focus-visible,
.delete-button:focus-visible { outline: 3px solid rgb(36 76 61 / 30%); outline-offset: 2px; }

.empty-state { padding: 56px 20px; text-align: center; color: var(--muted); }
.empty-state h3 { margin: 12px 0 5px; color: var(--ink); }
.empty-state p { margin-bottom: 0; }
.empty-check { display: grid; place-items: center; width: 56px; height: 56px; margin: auto; border-radius: 18px; background: var(--accent-soft); color: var(--accent); font-size: 1.5rem; }

.toast {
  position: fixed;
  z-index: 10;
  left: 50%;
  bottom: max(18px, env(safe-area-inset-bottom));
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  width: min(calc(100% - 28px), 500px);
  min-height: 58px;
  transform: translateX(-50%);
  border-radius: 16px;
  padding: 10px 12px 10px 17px;
  background: #1d211f;
  color: white;
  box-shadow: 0 18px 45px rgb(0 0 0 / 24%);
  font-size: 0.86rem;
}
.toast[hidden] { display: none; }
.toast button { min-height: 40px; border: 0; border-radius: 11px; padding: 0 12px; background: #f4f2ed; color: #1d211f; font-weight: 760; cursor: pointer; }

@media (min-width: 560px) {
  .app-shell { padding-left: 28px; padding-right: 28px; }
  .composer { padding: 24px; }
  #add-form { grid-template-columns: minmax(0, 1fr) 100px auto; align-items: end; }
  .add-button { grid-column: auto; min-width: 145px; }
}

@media (max-width: 390px) {
  .status { max-width: 110px; line-height: 1.15; }
  .bought-button { min-width: 76px; padding: 0 9px; }
  .completed-item { gap: 9px; }
  .completed-item .item-meta { display: none; }
  .restore-button { padding: 0 9px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}
