:root {
  --bg: #f4f3ee;
  --card: #fbfaf6;
  --field: #ffffff;
  --ink: #1d2a24;
  --muted: #55645c;
  --line: #cfd3c8;
  --accent: #a8441f;
  --accent-ink: #ffffff;
  --link: #7e3216;
  --warn-bg: #fbeed8;
  --warn-ink: #5e3a06;
  --good: #2a6f4c;
  --error: #a3231b;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #131b17;
    --card: #1b2520;
    --field: #222e28;
    --ink: #e9efea;
    --muted: #a9b8af;
    --line: #34443b;
    --accent: #e58b62;
    --accent-ink: #2a1705;
    --link: #f0ad8d;
    --warn-bg: #3a2c12;
    --warn-ink: #f5d9a8;
    --good: #6bcb9c;
    --error: #ff9c94;
  }
}
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 400 1rem/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
a { color: var(--link); }
h1, h2, h3 { line-height: 1.2; margin: 0; }
h1 { font-size: 1.6rem; overflow-wrap: anywhere; }
h2 { font-size: 1.15rem; }
h3 { font-size: 1rem; overflow-wrap: anywhere; }
p { margin: 0; }
:focus-visible { outline: 3px solid var(--link); outline-offset: 2px; }
main:focus { outline: none; }

.top {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .25rem .75rem;
  padding: calc(.5rem + env(safe-area-inset-top)) max(1rem, env(safe-area-inset-right)) .5rem max(1rem, env(safe-area-inset-left));
  border-bottom: 1px solid var(--line);
  background: var(--card);
}
.brand { font-weight: 800; font-size: 1.2rem; color: var(--ink); text-decoration: none; }
.top-actions { display: flex; flex-wrap: wrap; align-items: center; gap: .25rem .5rem; }
.page {
  max-width: 48rem; margin: 0 auto;
  padding: 1rem max(1rem, env(safe-area-inset-right)) calc(3rem + env(safe-area-inset-bottom)) max(1rem, env(safe-area-inset-left));
  display: grid; gap: 1rem;
}
.page > * { min-width: 0; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
.pre { white-space: pre-wrap; overflow-wrap: anywhere; }
.stack { display: grid; gap: .75rem; min-width: 0; }
.row { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; }
.spread { justify-content: space-between; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 8px; padding: .9rem; display: grid; gap: .75rem; min-width: 0; }
.banner { background: var(--warn-bg); color: var(--warn-ink); border-radius: 8px; padding: .7rem .9rem; display: grid; gap: .5rem; }
.error { color: var(--error); }
.badge { display: inline-block; font-size: .8rem; font-weight: 600; border: 1px solid var(--line); border-radius: 999px; padding: .05rem .55rem; color: var(--muted); }

button, .button {
  font: inherit; font-weight: 600; min-height: 2.75rem; padding: .4rem .9rem; border-radius: 6px; cursor: pointer;
  background: var(--accent); color: var(--accent-ink); border: 1px solid transparent;
  display: inline-flex; align-items: center; justify-content: center; text-decoration: none;
}
button.ghost, .button.ghost { background: transparent; color: var(--ink); border-color: var(--line); }
button.link { background: none; border: 0; color: var(--link); text-decoration: underline; font-weight: 400; padding: .4rem .25rem; }
button:disabled { opacity: .5; cursor: default; }
button.step { width: 2.75rem; padding: 0; font-size: 1.25rem; }

label { display: grid; gap: .25rem; font-weight: 600; min-width: 0; }
label.check { display: flex; align-items: center; gap: .5rem; font-weight: 400; min-height: 2.75rem; }
.search { flex: 1 1 14rem; }
label.check input { width: 1.25rem; height: 1.25rem; }
/* 16px stops iOS Safari from zooming the page when a field gets focus. */
input:not([type=checkbox]), textarea, select {
  width: 100%; font: inherit; font-size: 16px; font-weight: 400; color: var(--ink); background: var(--field);
  border: 1px solid var(--line); border-radius: 6px; padding: .55rem .65rem; min-height: 2.75rem;
}
textarea { resize: vertical; min-height: 5rem; }
.hint { font-size: .875rem; font-weight: 400; color: var(--muted); }
.fields-2 { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr) minmax(0, 1fr); gap: .75rem; }

.list-link { display: grid; gap: .1rem; text-decoration: none; color: inherit; background: var(--card); border: 1px solid var(--line); border-radius: 8px; padding: .7rem .9rem; min-height: 2.75rem; }
.list-link strong { color: var(--link); overflow-wrap: anywhere; }

.item-head { display: grid; grid-template-columns: 5.5rem minmax(0, 1fr); gap: .75rem; align-items: start; }
.item-head.no-image { grid-template-columns: minmax(0, 1fr); }
.item-image { width: 5.5rem; height: 5.5rem; object-fit: contain; background: var(--field); border: 1px solid var(--line); border-radius: 6px; }
.item.done { opacity: .75; }
.claim-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(13rem, 1fr)); gap: .75rem; }
.stepper { display: flex; align-items: center; gap: .5rem; }
.stepper output { min-width: 2rem; text-align: center; font-weight: 700; font-variant-numeric: tabular-nums; }
.note-box { border-top: 1px solid var(--line); padding-top: .75rem; display: grid; gap: .5rem; }

.toast {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(1rem + env(safe-area-inset-bottom));
  background: var(--ink); color: var(--bg); padding: .6rem .9rem; border-radius: 8px; max-width: min(92vw, 34rem); z-index: 10;
}
@media (max-width: 30rem) {
  .fields-2 { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .fields-2 > :first-child { grid-column: 1 / -1; }
}

.tight { gap: .3rem; }
.tabs { display: flex; flex-wrap: wrap; gap: .25rem; }
.tabs button[aria-pressed="true"] { background: var(--ink); color: var(--bg); border-color: var(--ink); }
label.inline { display: flex; align-items: center; gap: .5rem; }
label.inline select { width: auto; }
.group-head { border-bottom: 1px solid var(--line); padding-bottom: .25rem; }
.buy-row { grid-template-columns: 6.25rem minmax(0, 1fr); align-items: start; }
.buy-image { width: 6.25rem; height: 6.25rem; object-fit: contain; background: var(--field); border: 1px solid var(--line); border-radius: 6px; }
@media (max-width: 30rem) {
  .buy-row { grid-template-columns: 4.5rem minmax(0, 1fr); }
  .buy-image { width: 4.5rem; height: 4.5rem; }
}
.suggested { font-weight: 600; color: var(--warn-ink); background: var(--warn-bg); border-radius: 6px; padding: .15rem .5rem; justify-self: start; }
/* Dropdown menus in the top bar: My lists, Shared with me, the narrow-screen Menu, and the user menu (FEAT 23, BUG 04). */
.top-actions { flex: 1 1 auto; justify-content: flex-end; }
.site-menus { display: flex; flex-wrap: wrap; gap: .25rem; margin-right: auto; }
.dropdown { position: relative; }
.menu-button {
  min-height: 2.75rem; display: inline-flex; align-items: center; gap: .3rem; padding: .25rem .65rem;
  border: 1px solid var(--line); border-radius: 6px; font-weight: 600; font-size: .95rem; color: var(--ink);
  text-decoration: none; cursor: pointer; background: transparent;
}
summary.menu-button { list-style: none; }
summary.menu-button::-webkit-details-marker { display: none; }
summary.menu-button::after { content: "\25BE"; color: var(--muted); }
.dropdown .menu {
  position: absolute; left: 0; top: calc(100% + .25rem); z-index: 5; min-width: 14rem; max-width: min(22rem, 92vw);
  max-height: 70vh; overflow: auto; display: grid; background: var(--card); border: 1px solid var(--line);
  border-radius: 8px; padding: .25rem; box-shadow: 0 6px 18px rgb(0 0 0 / .15);
}
.user-menu .menu { left: auto; right: 0; }
.menu-item {
  display: flex; align-items: center; min-height: 2.75rem; padding: .25rem .6rem; border-radius: 6px;
  color: var(--link); text-decoration: none; overflow-wrap: anywhere;
}
.menu-item:hover, .menu-item:focus-visible { background: var(--bg); }
button.menu-item { justify-content: flex-start; text-align: left; width: 100%; text-decoration: none; font-weight: 400; }
.menu-heading { font-size: .8rem; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; padding: .5rem .6rem .1rem; }
.menu-group .menu-item { padding-left: 1.2rem; }
.menu-note { padding: .5rem .6rem; color: var(--muted); font-size: .9rem; }
.hamburger { display: none; margin-right: auto; }
@media (max-width: 48rem) {
  .site-menus { display: none; }
  .hamburger { display: block; }
}
html[data-site="test"] .top .menu-button { color: #fff; border-color: rgb(255 255 255 / .5); }
html[data-site="test"] .top .menu .menu-item { color: var(--link); }
/* The top bar and its menus stay in view while the page scrolls (FEAT 23). */
.top { position: sticky; top: 0; z-index: 10; }
button.danger { background: var(--error); color: var(--card); }
.danger-zone { border-color: var(--error); }

/* The test site gets a purple top bar and a label, so it cannot be mistaken for live (BUG 08). */
.site-label { font-size: .8rem; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; background: #fff; color: #4b2a7a; border-radius: 999px; padding: .1rem .6rem; }
html[data-site="test"] .top { background: #4b2a7a; border-bottom: 4px solid #f2c94c; }
html[data-site="test"] .top, html[data-site="test"] .top .brand, html[data-site="test"] .top a, html[data-site="test"] .top button.link { color: #fff; }
html[data-site="test"] .top .muted { color: #e6dcf5; }

/* The list page is full width, one row per item, with columns that line up (BUG 10). */
.page.wide { max-width: 80rem; }
.item-rows { display: grid; gap: .4rem; }
.item-row {
  display: grid; align-items: center; gap: .4rem .9rem; padding: .5rem .75rem;
  grid-template-columns: 4rem minmax(10rem, 2fr) minmax(0, 3fr) 6.5rem 8.5rem 17rem;
}
.item-row.owner { grid-template-columns: 4rem minmax(10rem, 2fr) minmax(0, 3fr) 6.5rem 8.5rem; }
.item-row.done { opacity: .75; }
.row-head { padding-top: 0; padding-bottom: 0; font-size: .8rem; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.item-row h3 { font-size: .95rem; }
.cell-title { display: grid; gap: .2rem; min-width: 0; }
.cell-desc { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.tile-image { width: 4rem; height: 4rem; display: block; background: var(--field); border: 1px solid var(--line); border-radius: 6px; overflow: hidden; }
.tile-image img { width: 100%; height: 100%; object-fit: contain; display: block; }
.status { flex-wrap: nowrap; }
.status select { width: auto; flex: 1 1 8rem; }
.status .units input { width: 4.5rem; }
/* On narrow screens each row folds into a small card. */
@media (max-width: 56rem) {
  .row-head { display: none; }
  .item-row, .item-row.owner { grid-template-columns: 4rem minmax(0, 1fr); align-items: start; }
  .item-row > .tile-image { grid-row: span 5; }
  .item-row > :not(.tile-image) { grid-column: 2; }
  .cell-desc:empty { display: none; }
}
