/* Stonehouse Market: shop and staff pages. Phone first; "wide" starts at 700px. System fonts only, so nothing extra downloads. */
:root {
  --bg: #f6f4ef; --card: #fff; --ink: #1c1915; --ink2: #6a6259; --line: rgba(28, 25, 21, 0.1); --fill: rgba(28, 25, 21, 0.06);
  --accent: #a3263d; --accent-soft: rgba(163, 38, 61, 0.09); --ok: #3f6b2e; --bad: #b3261e;
  --pad: 20px; --tabs: calc(50px + env(safe-area-inset-bottom));
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 17px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif; -webkit-font-smoothing: antialiased; padding-bottom: var(--tabs); }
h1 { margin: 12px 0 8px; font-size: 34px; line-height: 1.12; letter-spacing: -0.025em; text-wrap: balance; }
h2 { margin: 36px 0 14px; font-size: 22px; line-height: 1.15; letter-spacing: -0.02em; }
p { margin: 0 0 10px; }
a { color: inherit; text-decoration: none; }
img, svg { display: block; flex: none; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
[hidden] { display: none !important; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.wrap { max-width: 1240px; margin: 0 auto; padding: 0 var(--pad); }
.narrow { max-width: 640px; }
.muted { color: var(--ink2); }
.small, small { font-size: 13px; }
small { margin-left: 6px; font-weight: 400; }
.ok { color: var(--ok); font-weight: 600; }
.warn { color: var(--bad); font-weight: 600; }
.error { color: var(--bad); font-size: 15px; }
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.row.top { align-items: flex-start; flex-wrap: nowrap; }
.between { justify-content: space-between; }
.grow { flex: 1 1 0; min-width: 0; }
.stack { display: flex; flex-direction: column; gap: 10px; }
.wide-only { display: none !important; }
.empty { padding: 48px 12px; text-align: center; color: var(--ink2); }
.notice, .alert { margin: 12px 0; padding: 12px 16px; border-radius: 14px; background: var(--card); font-size: 15px; }
.alert { box-shadow: inset 0 0 0 1.5px var(--bad); }
.notice a { text-decoration: underline; }
.back { display: inline-flex; align-items: center; gap: 2px; min-height: 44px; color: var(--accent); font-size: 15px; }
.lede { max-width: 52ch; }

/* buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 0 18px; border: 0; border-radius: 22px; background: var(--fill); font-size: 15px; font-weight: 600; white-space: nowrap; }
.btn.primary { background: var(--accent); color: #fff; }
.btn.dark { background: var(--ink); color: #fff; }
.btn.danger { background: var(--bad); color: #fff; }
.btn.big { width: 100%; min-height: 52px; border-radius: 14px; font-size: 17px; }
.btn.icon { width: 44px; padding: 0; font-size: 18px; }
.btn:disabled { opacity: 0.4; cursor: default; }
.count, .tab-icon b { min-width: 20px; height: 20px; padding: 0 6px; border-radius: 10px; background: var(--accent); color: #fff; font-size: 12px; font-weight: 600; line-height: 20px; text-align: center; }

/* top bar (desktop gets search and the bag here; phones use the tab bar) */
.bar { padding-top: env(safe-area-inset-top); }
.bar-in { display: flex; align-items: center; gap: 20px; height: 48px; }
.brand { display: flex; align-items: center; gap: 8px; font-size: 17px; font-weight: 700; letter-spacing: -0.015em; white-space: nowrap; }
.arch { color: var(--accent); }
.search { position: relative; display: flex; align-items: center; }
.wrap > .search { margin-bottom: 20px; }
.search svg { position: absolute; left: 14px; color: var(--ink2); pointer-events: none; }
.search input { width: 100%; height: 44px; padding: 0 16px 0 42px; border: 0; border-radius: 22px; background: var(--fill); font-size: 17px; -webkit-appearance: none; appearance: none; }
.admin .search input { background: var(--card); border-radius: 14px; height: 48px; }

/* tab bar */
.tabs, .admin-nav { position: fixed; z-index: 20; left: 0; right: 0; bottom: 0; display: flex; padding-bottom: env(safe-area-inset-bottom); background: var(--bg); border-top: 1px solid var(--line); }
.tabs a, .admin-nav a { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; height: 50px; padding-top: 5px; color: #6e665d; font-size: 10px; font-weight: 500; }
.tabs a[aria-current], .admin-nav a[aria-current] { color: var(--accent); }
.tab-icon { position: relative; }
.tab-icon b { position: absolute; top: -4px; left: 16px; }

/* product cards */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 24px 14px; }
.grid.rail { grid-template-columns: none; grid-auto-flow: column; grid-auto-columns: 44%; overflow-x: auto; scroll-snap-type: x mandatory; margin: 0 calc(var(--pad) * -1); padding: 0 var(--pad) 4px; scroll-padding: var(--pad); scrollbar-width: none; }
.card { display: grid; align-content: start; min-width: 0; scroll-snap-align: start; }
.card-photo, .tile, .product-photo, .thumb { position: relative; overflow: hidden; }
.card-photo { grid-area: 1 / 1; aspect-ratio: 1; border-radius: 16px; }
.card-photo img, .tile img, .product-photo img, .thumb img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.no-photo { position: absolute; inset: 0; display: grid; place-items: center; color: var(--ink2); }
.add { grid-area: 1 / 1; z-index: 1; align-self: end; justify-self: end; margin: 8px; width: 44px; height: 44px; display: grid; place-items: center; border: 0; border-radius: 22px; background: #fff; box-shadow: 0 1px 2px rgba(28, 25, 21, 0.14), 0 6px 16px rgba(28, 25, 21, 0.1); }
.sold-out { position: absolute; left: 8px; bottom: 8px; padding: 5px 10px; border-radius: 14px; background: rgba(28, 25, 21, 0.82); color: #fff; font-size: 13px; font-weight: 600; }
.card-photo:has(.sold-out) img { opacity: 0.45; }
.card-text { display: flex; flex-direction: column; gap: 2px; padding: 10px 2px 0; font-size: 15px; }
.card-text b { font-weight: 600; line-height: 1.3; }

/* home */
.headline { margin: 8px 0 0; font-size: 28px; max-width: 18em; }
.tiles { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.tile { aspect-ratio: 4 / 5; border-radius: 20px; display: flex; align-items: flex-end; padding: 14px 16px; font-size: 19px; font-weight: 600; letter-spacing: -0.01em; }
.tile span { position: relative; }
.tile .on-photo { color: #fff; }
.tile:has(.on-photo)::after { content: ""; position: absolute; inset: 0; background: linear-gradient(180deg, rgba(20, 14, 8, 0) 42%, rgba(20, 14, 8, 0.8)); }
.tile .on-photo { z-index: 1; }
.foot { margin-top: 48px; padding-bottom: 20px; }
.visit { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 16px 40px; padding: 28px 0 20px; border-top: 1px solid var(--line); }
.visit h2 { margin: 0 0 4px; font-size: 20px; }
.visit p { margin: 0; font-size: 15px; }

/* category + product */
.side { flex-direction: column; gap: 2px; }
.side a { display: flex; align-items: center; min-height: 44px; padding: 0 12px; border-radius: 10px; font-size: 16px; font-weight: 500; }
.side a[aria-current] { background: var(--fill); font-weight: 600; }
.with-side .grid { margin-top: 20px; }
.product { display: grid; gap: 20px; }
.product-photo { aspect-ratio: 4 / 3; border-radius: 20px; }
.product-info { display: flex; flex-direction: column; gap: 6px; }
.product-info h1 { margin: 0; font-size: 28px; }
.ar { font-size: 17px; margin: 0; align-self: flex-start; }
.price { font-size: 22px; font-weight: 600; margin: 6px 0; }
.price .muted { font-size: 15px; font-weight: 400; margin-left: 6px; }
.buy { display: flex; flex-direction: column; gap: 18px; margin-top: 12px; }
/* on a phone the Add button stays in reach above the tab bar; the shadow hides what scrolls behind it */
.buy > .btn { position: sticky; bottom: calc(var(--tabs) + 10px); box-shadow: 0 0 0 10px var(--bg); }
fieldset { margin: 0; padding: 0; border: 0; min-width: 0; }
legend { padding: 0; margin-bottom: 10px; font-size: 15px; font-weight: 600; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip input, .seg input { position: absolute; opacity: 0; }
.chip span { display: flex; align-items: center; min-height: 44px; padding: 0 16px; border-radius: 22px; border: 1px solid rgba(28, 25, 21, 0.16); background: var(--card); font-size: 15px; font-weight: 500; cursor: pointer; }
.chip input:checked + span { background: var(--ink); border-color: var(--ink); color: #fff; }
.chip input:focus-visible + span, .seg input:focus-visible + span { outline: 3px solid var(--accent); outline-offset: 2px; }
.qty-row { display: flex; align-items: center; justify-content: space-between; font-size: 15px; }
.stepper { display: flex; align-items: center; border-radius: 22px; background: var(--fill); }
.stepper button { width: 44px; height: 44px; display: grid; place-items: center; border: 0; background: none; }
.stepper output { min-width: 48px; text-align: center; font-size: 16px; font-weight: 600; white-space: nowrap; }

/* segmented control */
.seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 2px; padding: 2px; border-radius: 13px; background: rgba(28, 25, 21, 0.07); max-width: 460px; }
.seg span, .seg.links a { display: flex; align-items: center; justify-content: center; gap: 8px; height: 48px; border-radius: 11px; font-size: 16px; font-weight: 600; cursor: pointer; }
.seg input:checked + span, .seg.links a[aria-current] { background: #fff; box-shadow: 0 1px 2px rgba(28, 25, 21, 0.12), 0 2px 8px rgba(28, 25, 21, 0.08); }
.seg input:disabled + span { opacity: 0.4; cursor: default; }

/* grouped form rows, iOS Settings style */
.group, .list { border-radius: 14px; background: var(--card); overflow: hidden; }
.field, .list-row { display: flex; align-items: center; gap: 12px; min-height: 54px; margin: 0; padding: 4px 16px; border-bottom: 1px solid var(--line); }
.group > :last-child, .list > :last-child { border-bottom: 0; }
.field > span:first-child { flex: none; width: 112px; font-size: 15px; }
.field small { display: block; margin: 0; }
.field input, .field select, .field textarea { flex: 1; min-width: 0; min-height: 46px; padding: 0; border: 0; background: none; font-size: 17px; }
.field textarea { padding: 8px 0; resize: vertical; }
.field.stack { align-items: stretch; padding-top: 10px; }
.field.stack > span:first-child, .field.pick > span:first-child { width: auto; flex: 1; }
.field.pick input { flex: none; }
.field input[type="radio"] { width: 24px; height: 24px; min-height: 0; accent-color: var(--accent); }
.field[aria-invalid] > span:first-child { color: var(--bad); font-weight: 600; }
/* staff forms on a phone: the label sits above its box, so long text is never cut off */
.admin .field:not(.pick) { flex-direction: column; align-items: stretch; gap: 0; padding-top: 10px; }
.admin .field:not(.pick) > span:first-child { width: auto; }
.switch { flex: none; position: relative; width: 51px; height: 31px; min-height: 0 !important; padding: 0; border: 0; border-radius: 16px; background: rgba(28, 25, 21, 0.18); -webkit-appearance: none; appearance: none; cursor: pointer; transition: background 0.2s; }
.switch::after { content: ""; position: absolute; top: 2px; left: 2px; width: 27px; height: 27px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3); transition: left 0.2s; }
.switch:checked, .switch.on { background: #2fa84f; }
.switch:checked::after, .switch.on::after { left: 22px; }
.list-row form { display: flex; }
.list-row .row.grow { flex-wrap: nowrap; min-height: 60px; }
.list-row b { display: block; font-weight: 500; }
.thumb { flex: none; width: 52px; height: 52px; border-radius: 12px; background: var(--fill); }
.thumb.big { width: 96px; height: 96px; border-radius: 16px; }
.photo-field { display: flex; align-items: center; gap: 16px; }
.group-title { margin: 24px 4px 8px; font-size: 15px; font-weight: 600; color: var(--ink2); letter-spacing: 0; }

/* panels: bag, order, admin cards */
.panel { display: flex; flex-direction: column; gap: 14px; padding: 20px; border-radius: 20px; background: var(--card); box-shadow: 0 1px 2px rgba(28, 25, 21, 0.05); }
.panel h2 { margin: 0; }
.panel p { margin: 0; }
.lines { margin: 0; padding: 12px 0 0; list-style: none; border-top: 1px solid var(--line); display: flex; flex-direction: column; gap: 8px; }
.lines li { display: flex; gap: 10px; align-items: baseline; font-size: 16px; }
.lines li > b { flex: none; min-width: 48px; }
.lines li > span:last-child:not(:nth-child(2)) { margin-left: auto; }
.total-row { display: flex; justify-content: space-between; gap: 12px; margin: 0; padding-top: 12px; border-top: 1px solid var(--line); }
.pill { display: inline-flex; align-items: center; gap: 6px; min-height: 32px; padding: 0 12px 0 10px; border-radius: 16px; background: var(--accent-soft); color: var(--accent); font-size: 14px; font-weight: 600; }
.pill.dark { background: var(--ink); color: #fff; }
.round { display: grid; place-items: center; width: 40px; height: 40px; border-radius: 50%; background: var(--accent-soft); color: var(--accent); }
.steps { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 6px; margin: 0; padding: 0; list-style: none; font-size: 12px; color: var(--ink2); }
.steps li::before { content: ""; display: block; height: 4px; margin-bottom: 6px; border-radius: 2px; background: #e2ddd3; }
.steps .done { color: var(--ink); font-weight: 600; }
.steps .done::before { background: var(--ok); }
.order { display: flex; flex-direction: column; gap: 16px; padding-top: 28px; text-align: center; }
.order .panel { text-align: left; }
.order h1 { margin: 0; font-size: 30px; }
.big-check { align-self: center; display: grid; place-items: center; width: 64px; height: 64px; border-radius: 50%; background: var(--ok); color: #fff; }
.order svg { display: inline; vertical-align: -3px; }
.order .round svg, .big-check svg { display: block; }

/* bag */
.bag-line { display: flex; align-items: center; gap: 12px; padding: 12px; border-bottom: 1px solid var(--line); }
.bag-line .grow { display: flex; flex-direction: column; gap: 2px; font-size: 15px; }
.bag-line .end { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; font-size: 15px; font-weight: 600; }
.bag-foot { display: flex; flex-direction: column; gap: 10px; margin-top: 16px; }

/* checkout */
.checkout { display: grid; grid-template-columns: minmax(0, 1fr); gap: 28px; padding-bottom: 32px; }
.checkout section { display: flex; flex-direction: column; gap: 12px; }
.checkout h2 { margin: 24px 0 0; font-size: 20px; }
.checkout [data-when] { display: flex; flex-direction: column; gap: 12px; }
.checkout label[data-when] { flex-direction: row; }
.summary { display: flex; flex-direction: column; gap: 14px; padding: 20px; border-radius: 20px; background: var(--card); align-self: start; }
.summary h2 { margin: 0; }
.sum-line { display: flex; justify-content: space-between; gap: 12px; font-size: 15px; }
.sum-line.total { font-size: 19px; font-weight: 700; padding-top: 10px; border-top: 1px solid var(--line); }

.toast { position: fixed; z-index: 50; left: 50%; bottom: calc(var(--tabs) + 12px); transform: translateX(-50%); display: flex; align-items: center; gap: 12px; max-width: calc(100% - 32px); padding: 6px 6px 6px 18px; border-radius: 28px; background: rgba(28, 25, 21, 0.95); color: #fff; font-size: 15px; font-weight: 500; white-space: nowrap; box-shadow: 0 10px 30px rgba(20, 14, 8, 0.3); }
.toast a { display: flex; align-items: center; height: 44px; padding: 0 16px; border-radius: 22px; background: rgba(255, 255, 255, 0.16); font-weight: 600; }

/* staff pages */
.admin-main { max-width: 960px; margin: 0 auto; padding: calc(12px + env(safe-area-inset-top)) var(--pad) 32px; }
.admin-main > .seg { margin: 16px 0; }
.admin-main > .search { margin: 12px 0; max-width: 420px; }
.admin-main > form:last-child { margin-top: 16px; }
.admin-nav a .tab-icon b { left: 14px; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(340px, 100%), 1fr)); gap: 16px; align-items: start; }
.panel .name { font-size: 18px; }
.contact a { display: inline-flex; align-items: center; gap: 6px; min-height: 44px; color: var(--accent); font-size: 16px; }
details { margin-top: 4px; }
summary { display: inline-flex; align-items: center; min-height: 44px; color: var(--ink2); font-size: 15px; text-decoration: underline; cursor: pointer; }
.form { display: flex; flex-direction: column; gap: 14px; max-width: 640px; margin-top: 12px; }
.form .group-title { margin-bottom: -4px; }
.add-row { margin-top: 16px; }
.add-row input { flex: 1; min-width: 180px; height: 48px; padding: 0 16px; border: 0; border-radius: 14px; background: var(--card); font-size: 17px; }
.tiles-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 12px; }
.stat { font-size: 30px; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.saved { position: fixed; z-index: 50; top: calc(12px + env(safe-area-inset-top)); left: 50%; transform: translateX(-50%); margin: 0; padding: 10px 20px; border-radius: 22px; background: var(--ok); color: #fff; font-weight: 600; animation: fade 0.4s 2.4s forwards; }
@keyframes fade { to { opacity: 0; visibility: hidden; } }
.login { max-width: 400px; margin: 12vh auto 0; }
.login h1 { margin: 0; font-size: 28px; }
.login input { height: 52px; padding: 0 14px; border: 1px solid var(--line); border-radius: 12px; background: var(--bg); font-size: 17px; }

@media (min-width: 700px) {
  :root { --pad: 32px; --tabs: 0px; }
  .wide-only { display: flex !important; }
  .narrow-only { display: none !important; }
  h1 { font-size: 40px; margin-top: 32px; }
  h2 { margin-top: 56px; font-size: 28px; }
  .tabs { display: none; }
  .bar { position: sticky; top: 0; z-index: 20; background: var(--bg); border-bottom: 1px solid var(--line); }
  .bar-in { height: 68px; }
  .brand { font-size: 18px; }
  .bar .search { flex: 1; max-width: 460px; margin: 0 auto; }
  .grid, .grid.rail { grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); grid-auto-flow: row; gap: 32px 20px; overflow: visible; margin: 0; padding: 0; }
  .headline { margin-top: 28px; font-size: clamp(32px, 3.4vw, 44px); line-height: 1.06; letter-spacing: -0.03em; }
  .tiles { grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 16px; }
  .tile { aspect-ratio: 3 / 4; font-size: 22px; }
  .with-side { display: grid; grid-template-columns: 200px minmax(0, 1fr); gap: 40px; align-items: start; }
  .side { position: sticky; top: 100px; margin-top: 32px; }
  .product { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 48px; align-items: start; padding-top: 32px; }
  .product-photo { aspect-ratio: 1; }
  .buy > .btn { position: static; box-shadow: none; }
  .admin .field:not(.pick, .stack) { flex-direction: row; align-items: center; gap: 12px; padding-top: 4px; }
  .admin .field:not(.pick, .stack) > span:first-child { width: clamp(112px, 38%, 190px); }
  .checkout { grid-template-columns: minmax(0, 1fr) 380px; gap: 40px; }
  .summary { position: sticky; top: 100px; margin-top: 40px; }
  .toast { bottom: 28px; }
  body.admin { display: grid; grid-template-columns: 232px minmax(0, 1fr); min-height: 100vh; padding: 0; }
  .admin-nav { position: sticky; top: 0; height: 100vh; flex-direction: column; gap: 4px; padding: 20px 12px 16px; border-top: 0; border-right: 1px solid var(--line); }
  .admin-nav a { flex: none; flex-direction: row; gap: 12px; height: 48px; padding: 0 12px; border-radius: 12px; color: var(--ink); font-size: 17px; }
  .admin-nav a[aria-current] { background: var(--fill); font-weight: 600; }
  .admin-nav a[aria-current] svg { color: var(--accent); }
  .admin-nav .push { margin-top: auto; color: var(--ink2); }
  .admin-brand { flex-direction: column; padding: 0 12px 18px; font-size: 16px; letter-spacing: -0.01em; }
  .admin-main { margin: 0; padding: 8px 32px 48px; width: 100%; }
  body.admin:not(:has(.admin-nav)) { display: block; }
}
