:root {
  --bg: #f7f5f1; --surface: #fff; --ink: #1c1a17; --muted: #6b665e; --line: #e6e1d8;
  --accent: #d6361f; --accent-ink: #fff; --chip: #efebe4;
  --radius: 12px; --font: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #151412; --surface: #1f1d1a; --ink: #f1ede6; --muted: #a39d93; --line: #34312c;
          --accent: #ff6a4d; --accent-ink: #1a0d09; --chip: #2a2824; }
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 15px/1.5 var(--font); }
a { color: inherit; }
.wrap { max-width: 1200px; margin: 0 auto; padding: 0 16px; }

.top { background: var(--surface); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5; }
.top-in { display: flex; align-items: center; justify-content: space-between; height: 56px; }
.logo { font-size: 20px; text-decoration: none; letter-spacing: -0.02em; }
.logo b { color: var(--accent); }
.top nav a { margin-left: 18px; text-decoration: none; color: var(--muted); }
.top nav a:hover { color: var(--ink); }

.hero { padding: 28px 0 12px; }
.hero h1 { margin: 0 0 4px; font-size: clamp(24px, 4vw, 34px); letter-spacing: -0.02em; line-height: 1.15; }
.hero p { margin: 0; color: var(--muted); }
.crumbs { padding-top: 16px; color: var(--muted); font-size: 13px; }

.filters { display: flex; flex-direction: column; gap: 10px; padding: 12px 0; }
.filters .row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.filters input[type=search], .filters select {
  font: inherit; color: inherit; background: var(--surface); border: 1px solid var(--line);
  border-radius: 10px; padding: 10px 12px; min-width: 0;
}
.filters input[type=search] { flex: 1 1 240px; }
.filters select { padding: 10px 8px; }

/* Dropdowns: a <details> whose summary looks like the selects next to it. */
.dd { position: relative; }
.dd summary { list-style: none; cursor: pointer; user-select: none; white-space: nowrap;
              background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; }
.dd summary::-webkit-details-marker { display: none; }
.dd summary::after { content: " ▾"; color: var(--muted); }
.dd summary.active { border-color: var(--ink); font-weight: 600; }
.dd .panel { position: absolute; top: calc(100% + 4px); left: 0; z-index: 10; min-width: 240px;
             max-width: calc(100vw - 32px); max-height: 360px; overflow-y: auto;
             background: var(--surface); border: 1px solid var(--line); border-radius: 10px;
             box-shadow: 0 10px 24px rgba(0,0,0,.14); padding: 6px; display: flex; flex-direction: column; gap: 2px; }
.dd.right .panel { left: auto; right: 0; }
.dd .panel .check { padding: 8px 6px; white-space: nowrap; }
/* Inside a panel a pill is a checkbox row. */
.panel .chip { display: flex; align-items: center; gap: 8px; width: 100%; text-align: left;
               background: none; border-radius: 6px; padding: 7px 8px; }
.panel .chip:hover { background: var(--chip); }
.panel .chip small { margin-left: auto; }
.panel .chip::before { content: ""; flex: none; width: 16px; height: 16px; border-radius: 4px;
                       border: 1.5px solid var(--muted); }
.panel .chip[aria-pressed="true"] { background: none; color: var(--ink); }
.panel .chip[aria-pressed="true"] small { color: var(--muted); opacity: 1; }
.panel .chip[aria-pressed="true"]::before { background: var(--accent); border-color: var(--accent);
  content: "✓"; color: #fff; font-size: 12px; line-height: 14px; text-align: center; }
.sort { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 14px; }
.group { display: flex; gap: 10px; align-items: baseline; min-width: 0; }
.group[hidden] { display: none; }
.glabel { font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); flex: 0 0 72px; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; min-width: 0; }
.chip { font: inherit; font-size: 14px; white-space: nowrap; border: 0; border-radius: 999px;
        padding: 6px 12px; background: var(--chip); color: var(--ink); cursor: pointer; }
.chip small { color: var(--muted); }
.chip.zero:not([aria-pressed="true"]) { opacity: .45; }
.chip[aria-pressed="true"] { background: var(--ink); color: var(--bg); }
.chip[aria-pressed="true"] small { color: inherit; opacity: .7; }
.checks { display: flex; gap: 16px; flex-wrap: wrap; }
.check { display: flex; align-items: center; gap: 6px; cursor: pointer; }
.link { font: inherit; background: none; border: 0; color: var(--accent); cursor: pointer; padding: 0; text-decoration: underline; }
.link[hidden] { display: none; }
.count { color: var(--muted); font-size: 13px; margin: 4px 0 10px; }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 12px; padding-bottom: 20px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); position: relative; }
.card .img { border-radius: var(--radius) var(--radius) 0 0; }
.card-link { display: flex; flex-direction: column; height: 100%; text-decoration: none; }
.card:hover { border-color: var(--muted); }
.img { position: relative; aspect-ratio: 1; background: #fff; overflow: hidden; }
/* Absolutely positioned, so a tall or wide photo can never stretch the square. */
.img .noimg { position: absolute; inset: 0; display: grid; place-items: center; color: var(--muted); font-size: 13px; }
.img img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; padding: 14px; }
.label { position: absolute; left: 8px; top: 8px; background: var(--accent); color: var(--accent-ink);
         font-weight: 700; font-size: 13px; line-height: 1.3; padding: 3px 8px; border-radius: 6px;
         max-width: calc(100% - 16px); z-index: 1; }
.loyalty { position: absolute; left: 8px; bottom: 8px; background: var(--surface); color: var(--ink);
           border: 1px solid var(--line); font-size: 12px; font-weight: 600; padding: 2px 7px; border-radius: 6px; z-index: 1; }
.body { padding: 10px 12px 12px; display: flex; flex-direction: column; gap: 2px; flex: 1; }
.shop { font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.card h3 { font-size: 14px; font-weight: 500; margin: 0; line-height: 1.35;
           display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.brand { font-weight: 700; }
.price { margin-top: auto; padding-top: 6px; }
.price strong { font-size: 17px; }
.price s { color: var(--muted); font-size: 13px; margin-left: 4px; }
.per { font-size: 13px; color: var(--muted); margin-left: 2px; }
.measure { font-size: 12px; color: var(--muted); }
.unit { font-size: 12px; color: var(--accent); font-weight: 600; }
.vars { margin-top: 8px; border-top: 1px solid var(--line); padding-top: 6px; font-size: 13px; }
.vars summary { cursor: pointer; color: var(--accent); font-weight: 600; list-style: none; }
.vars summary::-webkit-details-marker { display: none; }
.vars summary::after { content: " ▾"; }
.vars[open] summary::after { content: " ▴"; }
/* The open list floats over the cards below, so opening it never changes the row's height. */
.vars ul { list-style: none; margin: 0; padding: 8px 12px; display: flex; flex-direction: column; gap: 4px;
           position: absolute; left: -1px; right: -1px; top: calc(100% - 6px); z-index: 3;
           background: var(--surface); border: 1px solid var(--line); border-top: 0;
           border-radius: 0 0 var(--radius) var(--radius); box-shadow: 0 8px 16px rgba(0,0,0,.12);
           max-height: 320px; overflow-y: auto; }
.vars li { display: flex; justify-content: space-between; gap: 8px; }
.vars li a { color: var(--ink); text-decoration: none; }
.vars li a:hover { text-decoration: underline; }
.vars li span { color: var(--muted); white-space: nowrap; }
.until.soon { color: var(--ink); font-weight: 600; }
.until { font-size: 12px; color: var(--muted); }

.add { position: absolute; right: 8px; top: 8px; z-index: 2; width: 34px; height: 34px; border-radius: 50%;
       border: 1px solid var(--line); background: var(--surface); color: var(--ink); font-size: 20px; line-height: 1;
       cursor: pointer; box-shadow: 0 1px 4px rgba(0,0,0,.12); }
.add:hover { border-color: var(--ink); }
.add.on { background: var(--ink); color: var(--bg); border-color: var(--ink); font-size: 16px; }
.fab { position: fixed; right: 16px; bottom: 16px; z-index: 20; display: flex; align-items: center; gap: 8px;
       font: inherit; font-weight: 600; padding: 12px 18px; border-radius: 999px; border: 0; cursor: pointer;
       background: var(--accent); color: var(--accent-ink); box-shadow: 0 6px 18px rgba(0,0,0,.22); }
.fab b { background: var(--accent-ink); color: var(--accent); border-radius: 999px; padding: 0 8px; font-size: 13px; }
.fab.empty { background: var(--surface); color: var(--ink); border: 1px solid var(--line); }
.fab.empty b { background: var(--chip); color: var(--muted); }
.listpanel { position: fixed; z-index: 30; right: 16px; bottom: 76px; width: min(420px, calc(100vw - 32px));
             max-height: min(70vh, 640px); overflow-y: auto; background: var(--surface); color: var(--ink);
             border: 1px solid var(--line); border-radius: 14px; box-shadow: 0 16px 40px rgba(0,0,0,.25); padding: 12px 16px; }
.listpanel[hidden] { display: none; }
.listpanel header { display: flex; justify-content: space-between; align-items: center; position: sticky; top: -12px;
                    background: var(--surface); padding: 4px 0 8px; }
.listpanel h2 { font-size: 18px; margin: 0; }
.listpanel h3 { font-size: 14px; margin: 14px 0 6px; text-transform: uppercase; letter-spacing: .04em; }
.listpanel h3 small { text-transform: none; letter-spacing: 0; color: var(--muted); font-weight: 500; }
.listpanel ul { list-style: none; margin: 0; padding: 0; }
.listpanel li { display: flex; gap: 8px; justify-content: space-between; padding: 8px 0; border-top: 1px solid var(--line); }
.listpanel li.past { opacity: .55; }
.listpanel .li-main { min-width: 0; font-size: 14px; }
.listpanel .li-main a { color: inherit; text-decoration: none; }
.listpanel .muted { color: var(--muted); font-size: 12px; }
.listpanel .small { font-size: 11px; }
.listpanel .pill { background: var(--accent); color: var(--accent-ink); border-radius: 4px; padding: 0 5px; font-weight: 600; }
.listpanel .qty { display: flex; align-items: center; gap: 4px; flex: none; }
.listpanel .qty button, .listpanel footer button, .listpanel .x { font: inherit; border: 1px solid var(--line);
       background: var(--surface); color: var(--ink); border-radius: 6px; padding: 2px 8px; cursor: pointer; }
.listpanel .qty span { min-width: 18px; text-align: center; font-size: 14px; }
.listpanel .rm { color: var(--muted); }
.listpanel footer { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 12px; }
.listpanel .danger { color: var(--accent); }
@media (max-width: 640px) { .listpanel { right: 8px; left: 8px; width: auto; bottom: 72px; max-height: 75vh; } }
.more { display: block; margin: 0 auto 32px; font: inherit; padding: 10px 22px; border-radius: 999px;
        border: 1px solid var(--line); background: var(--surface); color: var(--ink); cursor: pointer; }
.more[hidden] { display: none; }
.empty { color: var(--muted); padding: 40px 0; text-align: center; grid-column: 1 / -1; }

.prose { max-width: 680px; padding: 24px 0; }
.foot { color: var(--muted); font-size: 13px; padding-top: 12px; padding-bottom: 32px; border-top: 1px solid var(--line); }

@media (max-width: 640px) {
  .group { flex-direction: column; align-items: stretch; gap: 4px; }
  .glabel { flex: none; }
  .group .chips { flex-wrap: nowrap; overflow-x: auto; max-width: 100%; padding-bottom: 2px; }
  .filters select { flex: 1 1 40%; min-width: 0; }
  /* Panels span the filter row instead of hanging off their button, so they stay on screen. */
  .filters .row { position: relative; }
  .dd { position: static; flex: 1 1 30%; }
  .dd summary { text-align: center; overflow: hidden; text-overflow: ellipsis; }
  .dd .panel, .dd.right .panel { left: 0; right: 0; min-width: 0; max-width: none; }
  .grid { grid-template-columns: repeat(2, 1fr); gap: 8px; }
}
