:root {
  --brand:#4f46e5; --brand-d:#4338ca; --brand-soft:#eef2ff; --accent:#06b6d4;
  --blue:var(--brand); --blue-d:var(--brand-d);
  --bg:#f4f5fb; --card:#fff; --ink:#18181b; --muted:#6b7280; --line:#e5e7eb;
  --ok:#15803d; --warn:#b45309; --bad:#b91c1c;
  --radius:16px; --shadow:0 1px 2px #1118270d, 0 8px 24px -8px #1118271a;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { scroll-behavior: smooth; }
body {
  font-family: Inter, system-ui, -apple-system, 'Segoe UI', sans-serif; line-height: 1.5; margin: 0; color: var(--ink);
  background: radial-gradient(900px 400px at 10% -10%, #c7d2fe55, transparent), radial-gradient(700px 400px at 95% 0%, #a5f3fc55, transparent), var(--bg);
  background-attachment: fixed; -webkit-font-smoothing: antialiased;
}
main { max-width: 1000px; margin: 0 auto; padding: 2rem 1rem 4rem; }
h1 { margin: 0; font-size: 2rem; letter-spacing: -.02em; }
h2 { margin: 0 0 .8rem; font-size: 1.3rem; letter-spacing: -.01em; }
h3 { margin: 1.4rem 0 .5rem; font-size: 1rem; }
a { color: var(--brand); }

section {
  background: var(--card); border: 1px solid #ffffffb0; border-radius: var(--radius); padding: 1.4rem 1.6rem; margin: 1.1rem 0;
  box-shadow: var(--shadow); animation: rise .35s ease both;
}
@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { section { animation: none; } html { scroll-behavior: auto; } }

.top { display: flex; align-items: center; gap: .8rem; flex-wrap: wrap; }
.top h1 { background: linear-gradient(90deg, var(--brand), var(--accent)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.tagline { margin: .3rem 0 1rem; max-width: 60ch; }

/* form controls */
input, button { font: inherit; padding: .65rem .9rem; border-radius: 10px; border: 1px solid var(--line); background: #fff; color: var(--ink); }
input:focus-visible, button:focus-visible, .recipe:focus-visible { outline: 3px solid #c7d2fe; outline-offset: 1px; border-color: var(--brand); }
#goal { width: 100%; margin-bottom: .7rem; font-size: 1.05rem; padding: .85rem 1rem; }
#servings { width: 5rem; }
#goal-form label { display: inline-flex; align-items: center; gap: .5rem; margin-right: .5rem; color: var(--muted); font-size: .92rem; }
input[type=file] { width: 100%; padding: .7rem; border-style: dashed; border-width: 2px; background: var(--brand-soft); cursor: pointer; }
input[type=checkbox] { accent-color: var(--brand); }

button { background: var(--brand); color: #fff; border: 0; cursor: pointer; font-weight: 600; transition: background .15s, transform .1s, box-shadow .15s; box-shadow: 0 2px 6px -2px #4f46e566; }
button:hover { background: var(--brand-d); }
button:active { transform: translateY(1px); }
button:disabled { background: #d1d5db; box-shadow: none; cursor: not-allowed; transform: none; }
button.secondary { background: #eef0f4; color: var(--ink); box-shadow: none; } button.secondary:hover { background: #e2e5ec; }
button.danger { background: var(--bad); box-shadow: 0 2px 6px -2px #b91c1c66; } button.danger:hover { background: #991b1b; }
button.small { padding: .3rem .7rem; font-size: .85rem; }
#approve-btn, #open-all { padding: .8rem 1.4rem; font-size: 1.02rem; }

.muted { color: var(--muted); font-size: .92rem; }
.error { background: #fef2f2; color: #991b1b; padding: .75rem 1rem; border-radius: 10px; border: 1px solid #fecaca; }
.note { background: #ecfdf5; color: #065f46; padding: .6rem .9rem; border-radius: 10px; border: 1px solid #a7f3d0; }

.recipe { border: 1px solid var(--line); border-radius: 12px; padding: 1rem 1.1rem; margin: .7rem 0; cursor: pointer; display: grid; gap: .2rem; transition: border-color .15s, box-shadow .15s, transform .15s; }
.recipe:hover { border-color: var(--brand); background: var(--brand-soft); box-shadow: 0 6px 18px -8px #4f46e566; transform: translateY(-1px); }
.recipe small { color: var(--muted); }
#ing-list { padding-left: 1.2rem; columns: 2 220px; column-gap: 2rem; }
#ing-list li { padding: .15rem 0; break-inside: avoid; }
#preview { display: block; max-width: 240px; max-height: 180px; border-radius: 12px; margin: .8rem 0; box-shadow: var(--shadow); }

/* badges */
.badge { display: inline-block; border-radius: 999px; padding: .1rem .65rem; font-size: .75rem; white-space: nowrap; font-weight: 600; }
.badge.warn { background: #fef3c7; color: #92400e; }
.badge.bad { background: #fee2e2; color: #991b1b; }
.badge.ok { background: #dcfce7; color: #166534; }
.badge.info { background: #e0e7ff; color: #3730a3; }
.badge.store { color: #fff; }
.badge.store.freshmart { background: #1b7f4b; } .badge.store.valuegrocer { background: #c8102e; } .badge.store.quickbasket { background: #0f1b33; }

/* checklist */
.checklist { list-style: none; padding: 0; margin: 0 0 1.2rem; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.checklist:empty { display: none; }
.checklist li { display: flex; gap: .7rem; align-items: flex-start; padding: .7rem .9rem; border-bottom: 1px solid var(--line); transition: background .15s; }
.checklist li:last-child { border-bottom: 0; }
.checklist li:hover { background: #fafafe; }
.checklist input { width: 1.2rem; height: 1.2rem; margin-top: .2rem; padding: 0; flex: none; }
.checklist .qty { color: var(--muted); } .checklist small { display: block; color: var(--muted); }

/* live view */
.live-head { display: flex; justify-content: space-between; align-items: center; gap: 1rem; }
.progress { height: 10px; background: #e5e7eb; border-radius: 99px; overflow: hidden; margin: .6rem 0 1.2rem; }
#progress-bar { height: 100%; width: 0; background: linear-gradient(90deg, var(--brand), var(--accent)); border-radius: 99px; transition: width .4s ease; }
.store-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: .8rem; margin-bottom: 1.2rem; }
.store-card { border: 1px solid var(--line); border-top: 5px solid var(--line); border-radius: 12px; padding: .8rem 1rem; background: #fff; box-shadow: var(--shadow); }
.store-card.freshmart { border-top-color: #1b7f4b; } .store-card.valuegrocer { border-top-color: #c8102e; } .store-card.quickbasket { border-top-color: #0f1b33; }
.store-card .sname { font-weight: 700; } .store-card .stotal { font-size: 1.7rem; font-weight: 800; font-variant-numeric: tabular-nums; letter-spacing: -.02em; } .store-card .sprog { color: var(--muted); font-size: .85rem; }
.grid-live { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 1rem; }
.tile { background: #0f172a; border-radius: 12px; overflow: hidden; display: flex; flex-direction: column; box-shadow: 0 10px 24px -10px #0f172a88; border: 1px solid #1e293b; }
.tile .label { color: #e2e8f0; font-size: .82rem; padding: .45rem .7rem .45rem 2.9rem; background: #1e293b; min-height: 2.2rem; position: relative; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tile .label::before { content: ""; position: absolute; left: .7rem; top: 50%; width: 9px; height: 9px; margin-top: -4.5px; border-radius: 50%; background: #f87171; box-shadow: 14px 0 0 #fbbf24, 28px 0 0 #4ade80; }
.tile .screen { position: relative; width: 100%; aspect-ratio: 3 / 2; overflow: hidden; background: #334155; }
/* The store page renders at 900x600 (like the original browser viewport) and is scaled down to the tile. */
.tile iframe { position: absolute; top: 0; left: 0; width: 900px; height: 600px; border: 0; background: #fff; transform-origin: 0 0; pointer-events: none; }
.log { background: #0b1220; color: #cbd5e1; font: .78rem/1.6 ui-monospace, Menlo, monospace; padding: .8rem 1rem; border-radius: 12px; max-height: 260px; overflow: auto; }
.log div.blocked { color: #fca5a5; font-weight: 700; } .log div.error { color: #fcd34d; } .log .ts { color: #64748b; }

/* results */
.item { border: 1px solid var(--line); border-radius: 14px; padding: 1rem 1.2rem; margin: .8rem 0; background: #fff; transition: box-shadow .15s; }
.item:hover { box-shadow: var(--shadow); }
.item.low { border-color: #fca5a5; background: #fffafa; } .item.medium { border-color: #fcd34d; background: #fffdf5; }
.item h4 { margin: 0 0 .5rem; font-size: 1.05rem; display: flex; gap: .6rem; align-items: baseline; flex-wrap: wrap; text-transform: capitalize; }
.item h4 small { color: var(--muted); font-weight: 400; text-transform: none; }
.pick { display: grid; grid-template-columns: 1fr auto; gap: .2rem 1rem; }
.pick .name a { font-weight: 700; text-decoration: none; } .pick .name a:hover { text-decoration: underline; }
.pick .price { text-align: right; font-weight: 800; font-size: 1.25rem; font-variant-numeric: tabular-nums; }
.pick .meta { color: var(--muted); font-size: .88rem; }
.pick .meta:nth-child(even) { text-align: right; }
.flag { margin-top: .6rem; font-size: .9rem; } .flag label { cursor: pointer; font-weight: 600; }
.flag.low { color: var(--bad); } .flag.medium { color: var(--warn); }
.alts { margin-top: .6rem; font-size: .88rem; } .alts button { margin: .25rem .3rem .25rem 0; text-align: left; }
.notfound { color: var(--bad); font-weight: 600; }
table.totals { width: 100%; border-collapse: collapse; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.totals th { background: #f9fafb; font-size: .82rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.totals th, .totals td { padding: .6rem .8rem; border-bottom: 1px solid var(--line); text-align: left; }
.totals .best { background: #ecfdf5; font-weight: 600; } .totals td.num { text-align: right; font-variant-numeric: tabular-nums; }
.basket-bar {
  position: sticky; bottom: 12px; z-index: 5; margin-top: 1.4rem; padding: 1rem 1.2rem; border-radius: 14px;
  display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap;
  background: #eef2ffee; backdrop-filter: blur(8px); border: 1px solid #c7d2fe; box-shadow: 0 10px 30px -10px #4f46e599;
}
.basket-bar strong { font-size: 1.6rem; letter-spacing: -.02em; }
.savings { margin-top: .2rem; color: var(--ok); font-weight: 600; font-size: .92rem; }
.best-pick { font-size: .72rem; }
.links { padding-left: 1.1rem; font-size: .9rem; }
.leftovers { list-style: none; padding: 0; } .leftovers li { padding: .45rem 0; border-bottom: 1px solid var(--line); }
.idea { border: 1px solid var(--line); border-radius: 12px; padding: .9rem 1.1rem; margin: .7rem 0; display: flex; justify-content: space-between; gap: 1rem; align-items: center; flex-wrap: wrap; transition: box-shadow .15s; }
.idea:hover { box-shadow: var(--shadow); }

/* "How to make it" */
details.method { border: 1px solid #c7d2fe; background: var(--brand-soft); border-radius: 12px; padding: .2rem 1.1rem; margin: .8rem 0 1rem; }
details.method summary { cursor: pointer; font-weight: 700; padding: .7rem 0; color: var(--brand-d); }
details.method[open] summary { border-bottom: 1px solid #c7d2fe; margin-bottom: .6rem; }
details.method h4 { margin: .2rem 0; font-size: 1.05rem; }
.steps-list { padding-left: 1.4rem; margin: .5rem 0 .8rem; }
.steps-list li { padding: .3rem 0 .3rem .3rem; }
.steps-list li::marker { color: var(--brand); font-weight: 700; }

/* progress steps */
.steps { position: sticky; top: 0; z-index: 10; margin: .8rem -1rem 0; padding: .6rem 1rem; background: #f4f5fbd9; backdrop-filter: blur(10px); border-bottom: 1px solid #e5e7eb80; }
.steps ol { list-style: none; margin: 0 auto; padding: 0; max-width: 1000px; display: flex; align-items: center; }
.steps li { display: flex; align-items: center; gap: .45rem; color: #9ca3af; font-size: .85rem; font-weight: 600; flex: 1; white-space: nowrap; }
.steps li:last-child { flex: none; }
.steps li:not(:last-child)::after { content: ""; flex: 1; height: 2px; margin: 0 .6rem; background: #e5e7eb; border-radius: 2px; transition: background .3s; }
.steps .dot { width: 1.6rem; height: 1.6rem; border-radius: 50%; display: grid; place-items: center; font-size: .78rem; background: #e5e7eb; color: #6b7280; flex: none; transition: all .25s; }
.steps li.done { color: var(--ok); } .steps li.done .dot { background: #22c55e; color: #fff; } .steps li.done .dot { font-size: 0; } .steps li.done .dot::before { content: "✓"; font-size: .8rem; }
.steps li.done::after { background: #22c55e; }
.steps li.active { color: var(--brand); } .steps li.active .dot { background: var(--brand); color: #fff; box-shadow: 0 0 0 4px #c7d2fe; }

/* hero + example chips */
.hero { padding: 1.4rem 0 .4rem; }
.hero-title { margin: 0; font-size: clamp(1.7rem, 4.5vw, 2.6rem); line-height: 1.15; letter-spacing: -.03em; max-width: 24ch; }
.hero-title span { background: linear-gradient(90deg, var(--brand), var(--accent)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.hero .tagline { font-size: 1.02rem; margin-top: .8rem; }
.chips { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; margin-top: 1rem; }
button.chip { background: var(--brand-soft); color: var(--brand-d); border: 1px solid #c7d2fe; border-radius: 999px; padding: .4rem .9rem; font-size: .9rem; font-weight: 600; box-shadow: none; }
button.chip:hover { background: #e0e7ff; transform: translateY(-1px); }

@media (max-width: 600px) {
  .steps .step-label { display: none; } .steps li.active .step-label { display: inline; }
  main { padding: 1.2rem .7rem 3rem; }
  section { padding: 1.1rem; }
  .pick { grid-template-columns: 1fr; } .pick .price, .pick .meta:nth-child(even) { text-align: left; }
}

.small { font-size: .8rem; }
footer.lodge { margin: 2rem 0 1rem; text-align: center; font-size: .82rem; color: #64748b; }
footer.lodge a { color: inherit; }
