/* Supermarket signage: solid aisle signs and shelf-ticket prices carry the look; everything else stays quiet. */
@font-face {
  font-family: Archivo;
  src: url("fonts/archivo.woff2") format("woff2");
  font-weight: 100 900;
  font-stretch: 62% 125%;
  font-display: swap;
}

:root {
  color-scheme: light dark;
  --ground: light-dark(#e9eeea, #0c1712);
  --surface: light-dark(#ffffff, #15231c);
  --ink: light-dark(#10291f, #e6efe9);
  --soft: light-dark(#4d6258, #a3b5ab);
  --line: light-dark(#ccd6d0, #2c3e35);
  --edge: light-dark(#7b8e84, #6d8378); /* control outlines: 3:1 on both grounds */
  --primary: light-dark(#0a6b3d, #7ed6a3);
  --on-primary: light-dark(#ffffff, #0c1712);
  --red: light-dark(#c8102e, #ff8d95);
  --ticket: #ffd400;
  --on-ticket: #10291f;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--ground); color: var(--ink); font: 400 1rem/1.4 Archivo, system-ui, sans-serif; }
h1, h2, h3, p, ul { margin: 0; padding: 0; }
ul { list-style: none; }
small { display: block; color: var(--soft); font-size: .875rem; overflow-wrap: anywhere; }
a { color: var(--primary); text-underline-offset: .2em; }
code { font: inherit; font-weight: 700; letter-spacing: .04em; user-select: all; }
:focus-visible { outline: 3px solid var(--primary); outline-offset: 2px; }

/* Controls */
button, input, select, textarea { font: inherit; color: inherit; }
button { min-height: 44px; padding: .5rem .95rem; border: 1px solid var(--edge); border-radius: 10px; background: var(--surface); font-weight: 600; cursor: pointer; }
button:hover { border-color: var(--ink); }
button:disabled { opacity: .45; cursor: default; }
button.primary { background: var(--primary); border-color: var(--primary); color: var(--on-primary); }
button.quiet { border-color: transparent; background: none; color: var(--primary); padding-inline: .6rem; }
button.quiet:hover { text-decoration: underline; text-underline-offset: .2em; }
button.danger { border-color: transparent; background: none; color: var(--red); padding-inline: .6rem; }
button.danger:hover { text-decoration: underline; text-underline-offset: .2em; }
button.text { flex: 1; min-width: 0; padding: .5rem 0; border: 0; border-radius: 4px; background: none; text-align: left; font-weight: 400; }
button.step { width: 44px; padding: 0; font-size: 1.15rem; border-color: transparent; background: none; }
button.step:hover { background: var(--ground); }
input:not([type=checkbox]), select, textarea { width: 100%; min-width: 0; min-height: 44px; padding: .5rem .75rem; border: 1px solid var(--edge); border-radius: 10px; background: var(--surface); }
textarea { resize: vertical; display: block; }
::placeholder { color: var(--soft); opacity: 1; }
input[type=checkbox] { width: 22px; height: 22px; margin: 0; accent-color: var(--primary); flex: none; cursor: pointer; }
.name { font-weight: 600; overflow-wrap: anywhere; }

/* Sign-in: the one full-size sign */
#signin { max-width: 34rem; margin: 12vh auto 0; padding: 1.25rem; }
#signin h1 { padding: 1.1rem 1.25rem; border-radius: 6px; background: #0a6b3d; color: #fff; font-size: clamp(2.25rem, 10vw, 4rem); line-height: 1; font-weight: 800; font-stretch: 110%; letter-spacing: -.02em; }
#signin p { margin: 1.25rem 0; font-size: 1.125rem; max-width: 30rem; }

/* Shell: text rail on desktop, text bar on a phone */
#shell main { padding: 1rem 1rem 6.5rem; }
#shell main > header { display: flex; align-items: center; justify-content: space-between; margin-bottom: .75rem; }
#title { font-size: 2rem; line-height: 1.1; font-weight: 800; font-stretch: 112%; letter-spacing: -.02em; }
#nav { position: fixed; z-index: 1100; inset: auto 0 0; display: flex; padding-bottom: env(safe-area-inset-bottom); background: var(--surface); border-top: 1px solid var(--line); }
#nav a { flex: 1; display: grid; place-items: center; min-height: 56px; color: inherit; text-decoration: none; font-weight: 600; font-stretch: 75%; }
#nav a[aria-current] { background: var(--ink); color: var(--ground); }
#nav a:focus-visible { outline-offset: -4px; }

/* Adding and filtering */
.add, .filters, .bulk, .inline, .actions { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }
.add { margin-bottom: .75rem; }
.add > input, .add > textarea { flex: 1 1 16rem; width: auto; }
.add > select { flex: 0 1 11rem; width: auto; }
.filters { margin-bottom: 1rem; }
.filters > input { flex: 1 1 10rem; max-width: 18rem; width: auto; }
.filters > select { flex: 0 1 12rem; width: auto; }
.tabs { display: flex; gap: 0; border: 1px solid var(--edge); border-radius: 10px; overflow: hidden; }
.tabs button { border: 0; border-radius: 0; background: none; padding-inline: .8rem; }
.tabs button[aria-pressed=true] { background: var(--ink); color: var(--ground); }
.tabs button:focus-visible { outline-offset: -4px; }
.bulk { position: sticky; top: .5rem; z-index: 5; margin-bottom: 1rem; padding: .6rem .75rem; border: 2px solid var(--ink); border-radius: 10px; background: var(--surface); }
.bulk select { width: auto; }

/* The aisle board */
.board { columns: 21rem; column-gap: 1rem; }
.board > .empty { column-span: all; }
.aisle { break-inside: avoid; margin-bottom: 1rem; border-radius: 6px; background: var(--surface); overflow: clip; --aisle: #4f5b57; }
.aisle[data-category=groceries] { --aisle: #0a6b3d; }
.aisle[data-category=household] { --aisle: #1f5fbf; }
.aisle[data-category=pharmacy] { --aisle: #b3266b; }
.aisle[data-category=tech] { --aisle: #4b3fa8; }
.aisle h2 { display: flex; justify-content: space-between; align-items: baseline; gap: 1rem; padding: .7rem .9rem .75rem; background: var(--aisle); color: #fff; font-size: 1.6rem; line-height: 1.05; font-weight: 800; font-stretch: 110%; letter-spacing: -.015em; }
.aisle-end { display: inline-flex; align-items: baseline; gap: .6rem; }
button.aisle-edit { min-height: auto; padding: .15rem .35rem; border: 0; background: none; color: #fff; font-size: .875rem; font-weight: 600; font-stretch: 100%; opacity: .85; }
button.aisle-edit:hover { opacity: 1; text-decoration: underline; }
.swatch { width: 14px; height: 14px; border-radius: 50%; flex: none; }
.aisle .count { font-stretch: 75%; font-variant-numeric: tabular-nums; }
.aisle.plain h2 { background: none; color: inherit; border-bottom: 2px solid var(--ink); }
.aisle li, .rows li { display: flex; align-items: center; gap: .35rem; min-height: 52px; border-bottom: 1px solid var(--line); }
.aisle li { padding-right: .75rem; }
.aisle li:last-child, .rows li:last-child { border-bottom: 0; }
.aisle.plain li { padding-left: .9rem; }
.tick { display: grid; place-items: center; align-self: stretch; width: 48px; min-height: 48px; flex: none; cursor: pointer; }
.done .name { text-decoration: line-through; color: var(--soft); font-weight: 400; }
.low { box-shadow: inset 5px 0 var(--ticket); }
.low output { font-weight: 800; }
output { min-width: 1.75rem; text-align: center; font-variant-numeric: tabular-nums; }

/* Shelf tickets */
.ticket { display: inline-flex; align-items: flex-start; flex: none; padding: .2rem .4rem .25rem; border: 1px solid var(--edge); border-radius: 2px; background: var(--surface); font-size: 1.75rem; line-height: .9; font-weight: 800; font-stretch: 68%; font-variant-numeric: tabular-nums; }
.ticket sup { font-size: .5em; line-height: 1.15; vertical-align: baseline; font-weight: 700; }
.ticket.deal { background: var(--ticket); border-color: var(--ticket); color: var(--on-ticket); }

/* Prices */
.lead { max-width: 44rem; margin-bottom: .75rem; }
.prices { background: var(--surface); border-radius: 6px; }
.price-row { display: grid; grid-template-columns: minmax(11rem, 1fr) 9.5rem minmax(0, 2.6fr); gap: .25rem 1.25rem; align-items: center; padding: .65rem .9rem; border-bottom: 1px solid var(--line); }
.price-row:last-child { border-bottom: 0; }
.price-row .text { width: 100%; font-weight: 600; }
.target { display: flex; align-items: center; gap: .35rem; white-space: nowrap; font-size: .875rem; color: var(--soft); }
.target input { color: var(--ink); }
.offers { display: flex; flex-wrap: wrap; gap: .4rem; }
.offer-wrap { display: inline-flex; align-items: center; gap: .35rem; max-width: 100%; }
.offer-wrap a { padding: .7rem .25rem; font-size: .875rem; }
.offer { display: flex; align-items: center; gap: .55rem; min-width: 0; padding: .3rem .6rem .3rem .3rem; border: 2px solid transparent; background: none; text-align: left; line-height: 1.2; }
.offer small { max-width: 13rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 400; }
.offer:hover { border-color: var(--edge); }
.offer[aria-pressed=true] { border-color: var(--primary); }
.when { grid-column: 3; }

/* Tasks and shops: a list to pick from beside what was picked */
.split { display: grid; gap: 1rem; align-items: start; }
.pane { min-width: 0; padding: 1rem; border-radius: 6px; background: var(--surface); }
.pane > header { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: .25rem 1rem; margin-bottom: .5rem; }
.pane h2 { font-size: 1.5rem; line-height: 1.1; font-weight: 800; font-stretch: 110%; letter-spacing: -.015em; overflow-wrap: anywhere; }
.field.inline > span { flex: none; }
.pane > .field.inline { margin-bottom: 1rem; }
.pane > .field.inline select { width: auto; }
.pick { display: flex; flex-wrap: wrap; gap: .25rem; }
.pick button[aria-pressed] { flex: 1 1 10rem; border-color: transparent; background: none; text-align: left; overflow-wrap: anywhere; }
.pick button[aria-pressed=true] { background: var(--ink); color: var(--ground); }
.pick button[aria-pressed=true] small { color: inherit; }
.pick small { font-weight: 400; }
.rows .child { padding-left: 2.25rem; }
.found:not(:empty) { margin-bottom: 1rem; padding: 0 1rem; border: 2px solid var(--ink); border-radius: 6px; background: var(--surface); }
.map { height: 60vh; min-height: 20rem; border-radius: 6px; background: var(--line); z-index: 0; isolation: isolate; }
.map.leaflet-container { font: inherit; font-size: .8rem; }
.pin { border: 3px solid #fff; border-radius: 50%; background: #0a6b3d; box-shadow: 0 0 0 2px #10291f; }
.fence { stroke: #0a6b3d; fill: #0a6b3d; stroke-width: 2; }
.fence.off { stroke: #4f5b57; fill: #4f5b57; stroke-dasharray: 5 5; }

/* Settings */
.setting { display: grid; gap: .5rem 2rem; padding: 1.25rem 0; border-top: 2px solid var(--ink); }
.setting h2 { font-size: 1.25rem; font-weight: 800; font-stretch: 108%; }
.setting small { max-width: 38rem; }
.stack { display: grid; gap: .5rem; justify-items: start; min-width: 0; }
.stack > ul, .stack > fieldset { width: 100%; }
.setting .rows li > .name { flex: 1; }
.indent { display: grid; gap: .25rem; margin-left: 2.1rem; }
fieldset { margin: .5rem 0 0; padding: 0; border: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(12rem, 1fr)); gap: 0 1rem; }
legend { padding: 0; font-weight: 700; }
.toggle { display: flex; align-items: flex-start; gap: .75rem; min-height: 44px; padding: .6rem 0; cursor: pointer; }
.page-shops > div > .toggle { max-width: 44rem; margin-bottom: .5rem; }

/* Editors slide in at the side and leave the page visible */
.field { display: grid; gap: .25rem; align-content: start; }
.field > span { font-weight: 600; }
.field.inline { display: flex; align-items: center; gap: .75rem; }
.field.checkbox { grid-template-columns: auto 1fr; align-items: center; gap: .75rem; min-height: 44px; }
.field.checkbox input { order: -1; }
dialog.sheet { width: min(30rem, 100vw); max-width: none; height: 100dvh; max-height: none; margin: 0 0 0 auto; padding: 0; border: 0; background: var(--surface); color: inherit; }
dialog.sheet::backdrop { background: rgb(16 41 31 / .45); }
.sheet form { display: flex; flex-direction: column; min-height: 100%; padding: 0 1.25rem; }
.sheet form > header { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: 1rem 0 .75rem; }
.sheet h2 { font-size: 1.6rem; line-height: 1.1; font-weight: 800; font-stretch: 110%; letter-spacing: -.015em; overflow-wrap: anywhere; }
.sheet h3 { font-size: 1rem; }
.note { margin-bottom: 1rem; color: var(--soft); }
.fields { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem .75rem; }
.fields .field { grid-column: 1 / -1; min-width: 0; }
.fields .half { grid-column: auto; }
.subpanel { margin-top: 1.5rem; padding-top: 1rem; border-top: 2px solid var(--ink); }
.subpanel li { display: flex; align-items: center; gap: .5rem; }
.subpanel li a { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.subpanel .inline { flex-wrap: nowrap; margin-top: .5rem; }
.subpanel .inline button { flex: none; }
.error { margin-top: 1rem; color: var(--red); font-weight: 600; }
.error:empty { display: none; }
.sheet footer { position: sticky; bottom: 0; display: flex; justify-content: space-between; margin-top: auto; padding: 1rem 0 calc(1rem + env(safe-area-inset-bottom)); background: var(--surface); }

.empty { padding: 2rem 0; max-width: 36rem; }
#loading { padding: 2rem 1rem; color: var(--soft); }
.empty h2 { margin-bottom: .5rem; font-size: 1.5rem; font-weight: 800; font-stretch: 110%; }
.empty p { color: var(--soft); }
.empty p + button { margin-top: 1rem; }
.aisle .empty, .pane .empty { padding: 1rem 0; }

#toast { position: fixed; z-index: 1200; left: 50%; bottom: calc(72px + env(safe-area-inset-bottom)); translate: -50% 0; display: flex; align-items: center; gap: .5rem; width: max-content; max-width: calc(100vw - 2rem); padding: .35rem .35rem .35rem 1rem; border-radius: 10px; background: var(--ink); color: var(--ground); }
#toast:empty { display: none; }
#toast span { padding: .5rem .65rem .5rem 0; }
#toast button { border: 0; background: none; color: light-dark(#ffd400, #0a6b3d); }

@media (min-width: 900px) {
  #shell { display: grid; grid-template-columns: 12.5rem minmax(0, 1fr); max-width: 96rem; }
  #shell main { padding: 1.5rem 2rem 4rem 1rem; }
  #nav { position: sticky; top: 0; height: 100vh; flex-direction: column; gap: .15rem; padding: 1.6rem 1rem; background: none; border: 0; z-index: 1; }
  #nav a { flex: none; min-height: 46px; justify-items: start; padding: 0 .85rem; border-radius: 6px; font-size: 1.125rem; font-stretch: 100%; }
  #nav a:not([aria-current]):hover { background: var(--line); }
  #title { font-size: 2.5rem; }
  .split { grid-template-columns: 15rem minmax(0, 1fr); }
  .split.wide { grid-template-columns: 22rem minmax(0, 1fr); }
  .pick { flex-direction: column; align-items: stretch; }
  .pick button[aria-pressed] { flex: none; }
  .pick .quiet { text-align: left; padding-inline: .95rem; }
  .map { position: sticky; top: 1rem; height: calc(100vh - 2rem); max-height: 46rem; }
  .setting { grid-template-columns: 14rem minmax(0, 44rem); }
  #toast { bottom: 1.5rem; }
}

@media (max-width: 760px) {
  .price-row { grid-template-columns: minmax(0, 1fr) 8.5rem; }
  .offers, .when { grid-column: 1 / -1; }
  .tabs { width: 100%; }
  .tabs button { flex: 1; padding-inline: .4rem; }
  .add > textarea { flex-basis: 100%; }
  .add > select { flex: 1 1 8rem; }
  .filters > input, .filters > select { flex: 1 1 6rem; max-width: none; }
  .filters > .quiet { padding-inline: .25rem; }
}

@media (prefers-reduced-motion: no-preference) {
  dialog.sheet[open] { animation: slide .18s ease-out; }
  @keyframes slide { from { transform: translateX(2rem); opacity: 0; } }
}
