:root {
  --bg: #f7f5f0;
  --surface: #ffffff;
  --surface-2: #f0ede6;
  --text: #22201c;
  --muted: #6f6a60;
  --border: #e2ddd2;
  --accent: #2f7d4f;
  --accent-ink: #ffffff;
  --accent-soft: #e2f1e7;
  --chart-bar: #2f7d4f;
  --photo-ph: url("data:image/svg+xml,%3Csvg%20xmlns%3D'http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg'%20viewBox%3D'0%200%2064%2064'%20fill%3D'none'%20stroke%3D'%23b9b2a5'%20stroke-width%3D'2.4'%20stroke-linecap%3D'round'%20stroke-linejoin%3D'round'%3E%3Ccircle%20cx%3D'32'%20cy%3D'32'%20r%3D'15'%2F%3E%3Ccircle%20cx%3D'32'%20cy%3D'32'%20r%3D'9.5'%2F%3E%3Cpath%20d%3D'M8%2013v9c0%202.5%201.6%204%203.5%204s3.5-1.5%203.5-4v-9M11.5%2013v38'%2F%3E%3Cpath%20d%3D'M55%2013c-3.5%202-5%208.5-5%2015.5h5V51'%2F%3E%3C%2Fsvg%3E");   /* checked for contrast against --surface (dataviz validator) */
  --warn: #a8660b;
  --warn-soft: #fbefd9;
  --danger: #b3372f;
  --danger-soft: #f8e1df;
  --radius: 12px;
  --shadow: 0 1px 2px rgb(0 0 0 / 6%), 0 4px 14px rgb(0 0 0 / 5%);
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #161513;
    --surface: #211f1c;
    --surface-2: #2b2925;
    --text: #ece8e0;
    --muted: #a29c90;
    --border: #3a3732;
    --accent: #5cbf83;
    --accent-ink: #0f1a13;
    --accent-soft: #1f3528;
    --chart-bar: #48a870;
    --photo-ph: url("data:image/svg+xml,%3Csvg%20xmlns%3D'http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg'%20viewBox%3D'0%200%2064%2064'%20fill%3D'none'%20stroke%3D'%235f5a52'%20stroke-width%3D'2.4'%20stroke-linecap%3D'round'%20stroke-linejoin%3D'round'%3E%3Ccircle%20cx%3D'32'%20cy%3D'32'%20r%3D'15'%2F%3E%3Ccircle%20cx%3D'32'%20cy%3D'32'%20r%3D'9.5'%2F%3E%3Cpath%20d%3D'M8%2013v9c0%202.5%201.6%204%203.5%204s3.5-1.5%203.5-4v-9M11.5%2013v38'%2F%3E%3Cpath%20d%3D'M55%2013c-3.5%202-5%208.5-5%2015.5h5V51'%2F%3E%3C%2Fsvg%3E");
    --warn: #e5a54a;
    --warn-soft: #3a2d17;
    --danger: #ef7b72;
    --danger-soft: #3d1f1c;
    --shadow: 0 1px 2px rgb(0 0 0 / 40%);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

h2 { font-size: 1.15rem; margin: 0; }
a { color: var(--accent); }
.muted { color: var(--muted); margin: 2px 0 0; font-size: 0.9rem; }
.count { color: var(--muted); font-weight: 500; font-size: 0.95rem; }

/* ---------- Top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; gap: 24px; flex-wrap: wrap;
  padding: 12px 24px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.brand { font-weight: 700; font-size: 1.15rem; white-space: nowrap; }
.tabs { display: flex; gap: 4px; overflow-x: auto; }
.tabs button {
  border: 0; background: none; color: var(--muted);
  padding: 8px 14px; border-radius: 999px; font: inherit; font-weight: 550; cursor: pointer; white-space: nowrap;
}
.tabs button:hover { background: var(--surface-2); color: var(--text); }
.tabs button[aria-selected="true"] { background: var(--accent-soft); color: var(--accent); }
.badge {
  display: inline-block; min-width: 20px; padding: 0 6px; margin-left: 4px;
  border-radius: 999px; background: var(--accent); color: var(--accent-ink); font-size: 0.75rem; text-align: center;
}

main { max-width: 1120px; margin: 0 auto; padding: 24px; }

/* ---------- Generic controls ---------- */
input, select, textarea, button { font: inherit; color: inherit; }
input, select, textarea {
  background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; min-width: 0;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
textarea { width: 100%; resize: vertical; }
button {
  border: 1px solid var(--border); background: var(--surface); border-radius: 8px; padding: 8px 14px; cursor: pointer;
}
button:hover { background: var(--surface-2); }
button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }
button.primary:hover { filter: brightness(1.07); }
button.primary:disabled { opacity: 0.6; cursor: progress; }
button.link { border: 0; background: none; color: var(--accent); padding: 8px 4px; }
button.icon { padding: 4px 9px; line-height: 1.2; }
button.danger:hover { background: var(--danger-soft); color: var(--danger); border-color: var(--danger-soft); }

.panel {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow);
}

.section-head { margin: 8px 0 14px; }
.section-head.with-control { display: flex; justify-content: space-between; align-items: end; gap: 16px; flex-wrap: wrap; margin-top: 36px; }
.slider { display: flex; align-items: center; gap: 10px; font-size: 0.9rem; color: var(--muted); }
.slider input { accent-color: var(--accent); padding: 0; border: 0; }

.toolbar { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin: 20px 0 12px; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  border-radius: 999px; padding: 4px 12px; font-size: 0.88rem; background: var(--surface); border: 1px solid var(--border);
}
.chip.active { background: var(--accent-soft); color: var(--accent); border-color: transparent; font-weight: 600; }
.chip .x { margin-left: 6px; opacity: 0.6; }

.add-form { display: grid; grid-template-columns: 2fr 90px 1fr 120px 150px auto; gap: 8px; }
#shopping-form { grid-template-columns: 2fr 90px 1fr auto; }
.inline-form { display: flex; gap: 8px; margin-top: 12px; }
.form-actions { display: flex; gap: 8px; align-items: center; margin-top: 8px; }

/* ---------- Pantry ---------- */
.location-group { margin-bottom: 20px; }
.location-group h3 {
  font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); margin: 0 0 8px;
}
.pantry-table { list-style: none; margin: 0; padding: 0; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.pantry-row { display: grid; grid-template-columns: 1fr auto auto auto; gap: 12px; align-items: center; padding: 8px 12px; border-top: 1px solid var(--border); }
.pantry-row:first-child { border-top: 0; }
.pantry-row.empty .item-name { color: var(--muted); text-decoration: line-through; }
.item-name { font-weight: 550; }
.qty-control { display: flex; align-items: center; gap: 4px; }
.qty-control input { width: 72px; text-align: right; padding: 4px 6px; }
.qty-control .unit { color: var(--muted); min-width: 56px; font-size: 0.9rem; }
.staples { margin-top: 24px; }
.staples summary { cursor: pointer; font-weight: 600; }

/* ---------- Recipe cards ---------- */
.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 16px; }
.card {
  display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); cursor: pointer; transition: transform 0.12s;
}
.card:hover { transform: translateY(-2px); }
.card:focus-visible { outline: 2px solid var(--accent); }
.card-img { aspect-ratio: 16 / 10; background: var(--surface-2) center / cover no-repeat; display: grid; place-items: center; font-size: 2.2rem; }
.card-body { padding: 12px 14px 14px; display: flex; flex-direction: column; gap: 6px; flex: 1; }
.card-title { font-weight: 650; line-height: 1.3; }
.credit { font-size: 0.8rem; color: var(--muted); }
.meter { height: 6px; background: var(--surface-2); border-radius: 999px; overflow: hidden; }
.meter > span { display: block; height: 100%; background: var(--accent); }
.card-stats { display: flex; justify-content: space-between; font-size: 0.82rem; color: var(--muted); }
.missing-tags { display: flex; flex-wrap: wrap; gap: 4px; }
.tag { font-size: 0.78rem; padding: 2px 8px; border-radius: 999px; background: var(--danger-soft); color: var(--danger); }
.tag.low { background: var(--warn-soft); color: var(--warn); }
.card-actions { margin-top: auto; padding-top: 6px; display: flex; gap: 6px; }
.card-actions button { font-size: 0.85rem; padding: 6px 10px; }

.empty-state {
  grid-column: 1 / -1; text-align: center; padding: 32px 16px; color: var(--muted);
  border: 1px dashed var(--border); border-radius: var(--radius);
}
.empty-state button { margin-top: 10px; }

/* ---------- Import ---------- */
.import-results { list-style: none; padding: 0; margin: 10px 0 0; font-size: 0.9rem; }
.import-results li { padding: 6px 10px; border-radius: 8px; margin-top: 4px; }
.import-results .ok { background: var(--accent-soft); }
.import-results .fail { background: var(--danger-soft); color: var(--danger); }
.manual-form { display: flex; flex-direction: column; gap: 8px; margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--border); }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.three-col { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; }

/* ---------- Shopping ---------- */
.shopping-list { list-style: none; padding: 0; margin: 16px 0; }
.shopping-list li {
  display: flex; align-items: center; gap: 12px; padding: 10px 14px; background: var(--surface);
  border: 1px solid var(--border); border-radius: 10px; margin-bottom: 6px;
}
.shopping-list li.done .s-name { text-decoration: line-through; color: var(--muted); }
.shopping-list input[type="checkbox"] { width: 18px; height: 18px; accent-color: var(--accent); }
.s-main { flex: 1; }
.s-for { font-size: 0.8rem; color: var(--muted); }
.stock-bar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.stock-bar span { flex: 1; font-weight: 550; }

/* ---------- Recipe dialog ---------- */
dialog {
  border: 0; border-radius: 16px; padding: 0; width: min(860px, calc(100vw - 32px)); max-height: calc(100vh - 48px);
  background: var(--surface); color: var(--text); box-shadow: 0 20px 60px rgb(0 0 0 / 30%);
}
dialog::backdrop { background: rgb(0 0 0 / 45%); }
.detail-hero { height: 240px; background: var(--surface-2) center / cover no-repeat; position: relative; }
.detail-close { position: absolute; top: 12px; right: 12px; border-radius: 999px; background: var(--surface); }
.detail-body { padding: 20px 24px 24px; }
.detail-body h2 { font-size: 1.5rem; line-height: 1.25; }
.credit-box {
  display: flex; flex-wrap: wrap; align-items: center; gap: 6px 14px; margin: 12px 0 16px; padding: 10px 14px;
  background: var(--surface-2); border-radius: 10px; font-size: 0.9rem;
}
.credit-box strong { font-weight: 650; }
.credit-box a { font-weight: 600; margin-left: auto; }
.meta-row { display: flex; flex-wrap: wrap; gap: 16px; color: var(--muted); font-size: 0.9rem; margin-bottom: 16px; }
.detail-cols { display: grid; grid-template-columns: 1fr 1.4fr; gap: 28px; }
.detail-cols h3 { font-size: 1rem; margin: 0 0 8px; }
.ing-list { list-style: none; padding: 0; margin: 0; }
.ing-list li { display: grid; grid-template-columns: 22px 1fr; gap: 6px; padding: 5px 0; border-bottom: 1px solid var(--border); font-size: 0.92rem; }
.ing-list li.header { display: block; font-weight: 650; border: 0; padding-top: 12px; }
.ing-list .why { display: block; font-size: 0.78rem; color: var(--muted); }
.st-have .dot { color: var(--accent); }
.st-staple .dot { color: var(--accent); opacity: 0.7; }
.st-low .dot { color: var(--warn); }
.st-missing .dot { color: var(--danger); }
.st-optional .dot { color: var(--muted); }
.steps { padding-left: 22px; margin: 0; }
.steps li { margin-bottom: 10px; }
.steps li.step-section { list-style: none; margin-left: -22px; font-weight: 650; margin-top: 16px; }
.detail-actions { display: flex; gap: 8px; margin: 0 0 16px; flex-wrap: wrap; }

/* ---------- Toast ---------- */
.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); z-index: 50;
  background: var(--text); color: var(--bg); padding: 10px 18px; border-radius: 999px; box-shadow: var(--shadow); font-size: 0.92rem;
}

@media (max-width: 720px) {
  .topbar { padding: 10px 16px; gap: 8px; }
  main { padding: 16px; }
  .add-form, #shopping-form { grid-template-columns: 1fr 1fr; }
  .add-form input[name="name"], #shopping-form button { grid-column: 1 / -1; }
  .detail-cols, .two-col, .three-col { grid-template-columns: 1fr; }
  .detail-hero { height: 180px; }
  .detail-body { padding: 16px; }
}

/* ---------- Blocked-site import help ---------- */
.blocked-help { margin-top: 14px; border-top: 1px solid var(--border); padding-top: 12px; }
.blocked-help summary { cursor: pointer; color: var(--accent); font-weight: 550; }
.blocked-body { display: grid; grid-template-columns: 1fr 1.4fr; gap: 24px; margin-top: 12px; }
.blocked-body h3 { font-size: 0.95rem; margin: 0 0 4px; }
.blocked-body form { display: flex; flex-direction: column; gap: 8px; }
.blocked-body form button { align-self: flex-start; }
.bookmarklet {
  display: inline-block; margin-top: 10px; padding: 8px 14px; border-radius: 8px; border: 1px dashed var(--accent);
  background: var(--accent-soft); color: var(--accent); font-weight: 650; text-decoration: none; cursor: grab;
}
kbd { font: 0.8rem ui-monospace, monospace; padding: 1px 5px; border: 1px solid var(--border); border-radius: 4px; background: var(--surface-2); }
@media (max-width: 720px) { .blocked-body { grid-template-columns: 1fr; } }

/* ---------- Time filter ---------- */
.filter-bar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin: 0 0 18px; }
.filter-label { font-size: 0.85rem; font-weight: 600; color: var(--muted); }
.time-hidden-note { font-size: 0.82rem; }

/* ---------- Cooked it ---------- */
.cook-panel { border: 1px solid var(--border); border-radius: 12px; padding: 14px 16px; margin: 0 0 18px; background: var(--surface-2); }
.cook-panel h3 { margin: 0 0 4px; font-size: 1rem; }
.cook-rows { list-style: none; padding: 0; margin: 12px 0; }
.cook-row { display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; align-items: center; padding: 8px 0; border-top: 1px solid var(--border); }
.cook-row:first-child { border-top: 0; }
.cook-row .c-name { font-weight: 600; }
.cook-row .c-sub { grid-column: 1 / -1; font-size: 0.8rem; color: var(--muted); }
.cook-row .c-sub.warn { color: var(--warn); }
.cook-amount { display: flex; align-items: center; gap: 6px; font-size: 0.88rem; color: var(--muted); }
.cook-amount input { width: 80px; text-align: right; padding: 4px 6px; }
.cook-actions { display: flex; gap: 8px; justify-content: flex-end; }
.toast button { margin-left: 12px; padding: 2px 10px; border-radius: 999px; border: 0; background: var(--accent); color: var(--accent-ink); font-weight: 600; }
@media (max-width: 720px) { .cook-row { grid-template-columns: 1fr; } }

/* ---------- Expiry dates ---------- */
.badge.warn { background: var(--warn); }
.expiry-quick { grid-column: 1 / -1; display: flex; flex-wrap: wrap; align-items: center; gap: 6px; font-size: 0.85rem; color: var(--muted); }
.expiry-quick .chip { font-size: 0.8rem; padding: 2px 10px; }
.item-main { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; min-width: 0; }
.exp-pill { display: inline-block; font-size: 0.75rem; padding: 1px 8px; border-radius: 999px; background: var(--surface-2); color: var(--muted); white-space: nowrap; font-weight: 500; }
.exp-pill.soon { background: var(--warn-soft); color: var(--warn); }
.exp-pill.expired { background: var(--danger-soft); color: var(--danger); }
.exp-text.soon { color: var(--warn); }
.exp-text.expired { color: var(--danger); }
.exp-input { padding: 4px 6px; font-size: 0.85rem; color: var(--muted); width: 140px; }
.use-soon { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-bottom: 16px; border-color: var(--warn-soft); }
.use-soon .muted { margin: 0 0 0 4px; }
.uses-up { font-size: 0.8rem; color: var(--warn); font-weight: 550; }
.st-expired .dot { color: var(--danger); }
@media (max-width: 720px) {
  .pantry-row { grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "main del" "exp qty"; row-gap: 6px; }
  .pantry-row .item-main { grid-area: main; }
  .pantry-row [data-remove] { grid-area: del; justify-self: end; }
  .pantry-row .exp-input { grid-area: exp; width: 100%; max-width: 150px; }
  .pantry-row .qty-control { grid-area: qty; }
  .pantry-row .qty-control .unit { min-width: 0; }
}

/* ---------- Saved & Want to cook ---------- */
.card-img { position: relative; }
.star-btn {
  position: absolute; top: 8px; right: 8px; width: 34px; height: 34px; padding: 0; border-radius: 999px;
  font-size: 1.15rem; line-height: 1; background: rgb(255 255 255 / 88%); color: #6f6a60; border: 0; box-shadow: var(--shadow);
}
.star-btn:hover { background: #fff; }
.star-btn.on { color: #d49a00; }
.card-actions { flex-wrap: wrap; }
.card-actions:empty { display: none; }
button.on-list { background: var(--accent-soft); color: var(--accent); border-color: transparent; font-weight: 600; }
.cooklist { list-style: none; padding: 0; margin: 0 0 20px; display: flex; flex-direction: column; gap: 10px; }
.cook-item {
  display: grid; grid-template-columns: 96px 1fr auto; gap: 14px; align-items: center; padding: 10px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow);
}
.ci-img { width: 96px; height: 72px; border-radius: 8px; background: var(--surface-2) center / cover no-repeat; display: grid; place-items: center; font-size: 1.6rem; cursor: pointer; }
.ci-body { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.ci-title { font-weight: 650; cursor: pointer; }
.ci-title:hover { color: var(--accent); }
.ci-status { font-size: 0.85rem; color: var(--danger); }
.ci-status.ready { color: var(--accent); font-weight: 600; }
.ci-actions { display: flex; gap: 6px; align-items: center; }
.cooklist-shopping h3 { margin: 0 0 8px; font-size: 1rem; }
.need-list { list-style: none; padding: 0; margin: 0 0 12px; }
.need-list li { display: flex; flex-direction: column; padding: 6px 0; border-top: 1px solid var(--border); font-size: 0.92rem; }
.need-list li:first-child { border-top: 0; }
.need-list .muted { font-size: 0.8rem; margin: 0; }
@media (max-width: 720px) {
  .cook-item { grid-template-columns: 72px 1fr; }
  .ci-img { width: 72px; height: 60px; }
  .ci-actions { grid-column: 1 / -1; justify-content: flex-end; }
}
@media (prefers-color-scheme: dark) {
  .star-btn { background: rgb(33 31 28 / 88%); color: #cfc9bd; }
  .star-btn:hover { background: #2b2925; }
  .star-btn.on { color: #f2c94c; }
}

/* ---------- Sign-in ---------- */
body.signed-out .topbar, body.signed-out main { display: none; }
.login-screen { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; }
.login-card {
  width: min(420px, 100%); text-align: center; background: var(--surface); border: 1px solid var(--border);
  border-radius: 18px; padding: 36px 28px 28px; box-shadow: var(--shadow);
}
.login-logo { font-size: 2.6rem; }
.login-card h1 { margin: 4px 0 6px; font-size: 1.7rem; }
.login-buttons { display: flex; flex-direction: column; gap: 10px; margin: 24px 0 18px; }
.login-btn {
  display: flex; align-items: center; justify-content: center; gap: 10px; padding: 11px 16px; border-radius: 8px;
  border: 1px solid #dadce0; background: #fff; color: #1f1f1f; font-weight: 600; text-decoration: none;
}
.login-btn:hover { background: #f6f8fa; }
.login-btn.microsoft { border-color: #8c8c8c; border-radius: 0; }
.login-error { background: var(--danger-soft); color: var(--danger); padding: 8px 12px; border-radius: 8px; margin: 16px 0 0; font-size: 0.9rem; }
.login-note { font-size: 0.8rem; color: var(--muted); margin: 0; }

.account { margin-left: auto; display: flex; align-items: center; }
.local-chip { font-size: 0.78rem; color: var(--muted); border: 1px dashed var(--border); border-radius: 999px; padding: 3px 10px; cursor: help; white-space: nowrap; }
.account-menu { position: relative; }
.account-menu summary { list-style: none; cursor: pointer; border-radius: 999px; }
.account-menu summary::-webkit-details-marker { display: none; }
.account-menu summary img, .avatar-initial { width: 32px; height: 32px; border-radius: 999px; display: grid; place-items: center; object-fit: cover; }
.avatar-initial { background: var(--accent); color: var(--accent-ink); font-weight: 700; }
.account-pop {
  position: absolute; right: 0; top: calc(100% + 8px); z-index: 20; min-width: 220px; padding: 14px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px; box-shadow: 0 10px 30px rgb(0 0 0 / 15%);
}
.account-name { font-weight: 650; }
.account-via { font-size: 0.8rem; margin-bottom: 10px; }
.account-pop button { width: 100%; }

/* ---------- Add / edit recipe ---------- */
.panel-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 8px; }
.segmented { display: inline-flex; background: var(--surface-2); border-radius: 999px; padding: 3px; }
.segmented button { border: 0; background: none; border-radius: 999px; padding: 6px 14px; font-weight: 550; color: var(--muted); }
.segmented button[aria-selected="true"] { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.recipe-form { display: flex; flex-direction: column; gap: 10px; margin-top: 10px; }
.field { display: flex; flex-direction: column; gap: 4px; font-size: 0.85rem; font-weight: 600; color: var(--muted); }
.field em { font-style: normal; font-weight: 400; }
.field input, .field textarea { font-weight: 400; color: var(--text); }
.four-col { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.locked-credit { background: var(--surface-2); padding: 8px 12px; border-radius: 8px; }
@media (max-width: 720px) {
  .four-col { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 720px) {
  .brand { order: 1; }
  .account { order: 2; }
  .tabs { order: 3; width: 100%; }
}

/* ---------- Guest page ---------- */
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
a.brand { color: inherit; text-decoration: none; }
.guest-chip { font-size: 0.75rem; font-weight: 650; text-transform: uppercase; letter-spacing: 0.05em; color: var(--accent); background: var(--accent-soft); border-radius: 999px; padding: 3px 10px; }
.link-btn { font-weight: 600; text-decoration: none; padding: 7px 14px; border: 1px solid var(--border); border-radius: 8px; color: var(--text); white-space: nowrap; }
.link-btn:hover { background: var(--surface-2); }
.guest-hero { margin-bottom: 28px; }
.guest-hero h1 { margin: 0; font-size: 1.6rem; }
.guest-add { display: grid; grid-template-columns: 1fr auto; gap: 8px; margin: 16px 0 12px; }
.guest-add input { font-size: 1rem; padding: 10px 12px; }
.guest-chips { margin-bottom: 10px; }
.quick-add { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; font-size: 0.85rem; }
.quick-add .chip { font-size: 0.8rem; padding: 2px 10px; }
.guest-options { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 22px; margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--border); font-size: 0.9rem; }
.check { display: flex; align-items: center; gap: 8px; cursor: pointer; }
.check input { width: 16px; height: 16px; accent-color: var(--accent); }
button.tag { border: 0; font: inherit; font-size: 0.78rem; cursor: pointer; }
button.tag:hover { filter: brightness(0.95); text-decoration: line-through; }
.method-box { background: var(--surface-2); border-radius: 12px; padding: 16px; align-self: start; }
.method-box p { margin: 0 0 14px; }
.primary-link {
  display: inline-block; background: var(--accent); color: var(--accent-ink); font-weight: 650; text-decoration: none;
  padding: 9px 16px; border-radius: 8px; white-space: nowrap;
}
.primary-link:hover { filter: brightness(1.07); }
button.inline-add { padding: 0; font-size: inherit; }
.guest-cta { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-top: 36px; }
.guest-cta p { margin: 2px 0 0; }
.guest-link { display: inline-block; margin: 0 0 16px; font-weight: 600; }
.local-links { display: flex; align-items: center; gap: 10px; }
.local-links a { font-size: 0.82rem; font-weight: 600; }
@media (max-width: 720px) {
  body.guest .topbar { flex-wrap: nowrap; }
  .guest-hero h1 { font-size: 1.35rem; }
}
@media (max-width: 720px) {
  .guest-chip { order: 1; }
}

.small-note { font-size: 0.8rem; margin-top: 8px; }
.small-note .link { padding: 0; font-size: inherit; }

/* ---------- Dietary filter ---------- */
.diet-check { margin: 10px 0 4px; font-weight: 550; }
.diet-note { font-size: 0.88rem; color: var(--muted); background: var(--surface-2); border-radius: 8px; padding: 8px 12px; margin: 0 0 14px; }
.diet-note .link { padding: 0; font-size: inherit; }
.diet-warning { background: var(--warn-soft); color: var(--warn); border-radius: 8px; padding: 8px 12px; font-weight: 550; margin: 8px 0 0; }
.diet-line { display: block; color: var(--warn); }
.chip.skipped { text-decoration: line-through; opacity: 0.6; }
.diet-info { margin: 10px 0 0; font-size: 0.85rem; }
#diet-skip { margin-top: 10px; }
@media (min-width: 721px) {
  .topbar { flex-wrap: nowrap; }
  .tabs { flex: 1 1 auto; min-width: 0; }
  .account { flex: 0 0 auto; }
}
.tabs { scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
@media (max-width: 1280px) {
  .topbar { gap: 14px; }
  .tabs button { padding: 7px 10px; }
}

/* ---------- Shared library ---------- */
.lib-chip, .admin-chip { font-size: 0.7rem; font-weight: 650; text-transform: uppercase; letter-spacing: 0.05em; vertical-align: middle; border-radius: 999px; padding: 2px 8px; }
.lib-chip { background: var(--accent-soft); color: var(--accent); }
.admin-chip { background: var(--warn-soft); color: var(--warn); }
.admin-section { margin-top: 40px; padding-top: 8px; border-top: 1px solid var(--border); }
.admin-section .panel h3, .admin-sub { margin: 0 0 4px; font-size: 1rem; }
.admin-sub { margin-top: 24px; }
.from-accounts { list-style: none; padding: 0; margin: 12px 0 0; display: flex; flex-direction: column; gap: 6px; }
.from-accounts li { display: grid; grid-template-columns: 56px 1fr auto; gap: 12px; align-items: center; padding: 8px 10px; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; }
.fa-img { width: 56px; height: 42px; border-radius: 6px; background: var(--surface-2) center / cover no-repeat; }
.fa-title { font-weight: 600; }
.fa-title a { color: inherit; }
.from-accounts .muted { font-size: 0.82rem; margin: 0; }
.tag.in-lib { background: var(--accent-soft); color: var(--accent); }
button.on-list:disabled { opacity: 1; cursor: default; }
@media (max-width: 720px) {
  .from-accounts li { grid-template-columns: 1fr auto; }
  .fa-img { display: none; }
}

/* ---------- Sharing ---------- */
.share-panel { margin-top: 18px; }
.share-panel summary { cursor: pointer; font-weight: 650; }
.share-panel summary .muted { font-weight: 400; font-size: 0.88rem; }
.share-body { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 28px; margin-top: 12px; }
.share-body section h3 { margin: 0 0 4px; font-size: 0.98rem; }
.share-body > .small-note { grid-column: 1 / -1; margin: 0; }
.share-links { list-style: none; padding: 0; margin: 10px 0; display: flex; flex-direction: column; gap: 6px; }
.share-links li { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); }
.share-links li.muted { border-style: dashed; }
.sl-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.sl-main .muted { font-size: 0.8rem; margin: 0; }
.share-links .link-btn { padding: 6px 12px; font-size: 0.9rem; }
.share-form { display: grid; grid-template-columns: 1fr auto auto; gap: 8px; }
.toolbar-right { display: flex; gap: 8px; align-items: center; }
.select-bar {
  position: sticky; top: 64px; z-index: 4; display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 10px 14px;
  margin: -4px 0 14px; background: var(--surface); border: 1px solid var(--accent); border-radius: 12px; box-shadow: var(--shadow);
}
.select-bar #select-count { font-weight: 650; margin-right: auto; }
.card.selected { outline: 3px solid var(--accent); outline-offset: -1px; }
.select-box {
  position: absolute; top: 8px; left: 8px; width: 26px; height: 26px; border-radius: 6px; display: grid; place-items: center;
  background: rgb(255 255 255 / 92%); border: 2px solid var(--accent); color: #fff; font-weight: 800; font-size: 0.9rem;
}
.select-box.on { background: var(--accent); }
.shared-badge {
  position: absolute; left: 8px; bottom: 8px; font-size: 0.72rem; font-weight: 700; padding: 2px 8px; border-radius: 999px;
  background: rgb(255 255 255 / 92%); color: var(--accent);
}
.lib-switch { margin-bottom: 18px; }
@media (max-width: 720px) {
  .share-body { grid-template-columns: 1fr; }
  .share-form { grid-template-columns: 1fr; }
  .share-links li { flex-wrap: wrap; }
  .select-bar { top: 104px; }
}
.share-toolbar { margin: 14px 0 0; }
.share-toolbar input { width: 100%; max-width: 360px; }
.ing-list li.plain .dot { color: var(--muted); }
.toast .toast-link { margin-left: 12px; color: var(--accent-ink); background: var(--accent); padding: 2px 10px; border-radius: 999px; font-weight: 600; text-decoration: none; }

/* ---------- Cuisine filter ---------- */
.cuisine-filter { margin: 0 0 12px; }
.chip-count { opacity: 0.6; font-size: 0.8em; margin-left: 2px; }
.cuisine-tag { display: inline-block; font-size: 0.72rem; font-weight: 650; padding: 1px 7px; border-radius: 999px; background: var(--surface-2); color: var(--text); margin-right: 2px; }
@media (max-width: 1280px) {
  .brand { font-size: 1.05rem; }
  .tabs { gap: 2px; }
  .tabs button { padding: 6px 8px; font-size: 0.93rem; }

}

/* Footer link + privacy policy page */
.site-footer { text-align: center; padding: 8px 16px 28px; font-size: 0.85rem; }
.site-footer a { color: var(--muted); }
body.signed-out .site-footer { display: none; }
.policy { max-width: 760px; margin: 0 auto; line-height: 1.6; }
.policy h1 { margin: 0 0 4px; }
.policy h2 { font-size: 1.15rem; margin: 1.6em 0 0.4em; }
.policy ul { padding-left: 1.3em; }

/* Account deletion */
.account-pop .account-delete { margin-top: 8px; border: 0; background: none; color: var(--danger); font-size: 0.85rem; padding: 4px; }
.account-pop .account-delete:hover { text-decoration: underline; }
#delete-account-dialog { width: min(480px, calc(100vw - 32px)); }
.delete-account { padding: 22px 24px; }
.delete-account h2 { margin: 0 0 10px; font-size: 1.3rem; }
.delete-account label { display: block; margin: 14px 0 6px; }
.delete-account input { width: 100%; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 18px; flex-wrap: wrap; }
button.danger-solid { background: var(--danger); border-color: var(--danger); color: var(--surface); font-weight: 600; }
button.danger-solid:disabled { opacity: 0.45; cursor: not-allowed; }
.login-notice { background: var(--surface-2); border-radius: 8px; padding: 8px 12px; margin: 0 0 12px; font-size: 0.9rem; }

/* Cookie consent (only shown when Google Analytics is configured) */
.site-footer button.link { color: var(--muted); font-size: inherit; padding: 0; margin-left: 14px; text-decoration: underline; }
.inline-link { padding: 0 !important; font-size: inherit; text-decoration: underline; }
.consent-banner {
  position: fixed; left: 50%; bottom: 16px; transform: translateX(-50%); z-index: 1000;
  width: min(760px, calc(100vw - 32px)); display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
  padding: 14px 18px; background: var(--surface); color: var(--text); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: 0 10px 34px rgb(0 0 0 / 18%);
}
.consent-banner[hidden] { display: none; }
.consent-banner p { margin: 0; flex: 1 1 320px; font-size: 0.92rem; line-height: 1.45; }
.consent-actions { display: flex; gap: 10px; }
.consent-actions button { min-width: 104px; font-weight: 600; }
@media (max-width: 520px) {
  .consent-actions { width: 100%; }
  .consent-actions button { flex: 1; }
}

/* Admin: users list */
.admin-users .panel-head input { max-width: 260px; }
.table-wrap { overflow-x: auto; margin-top: 8px; }
.users-table { width: 100%; min-width: 620px; border-collapse: collapse; font-size: 0.92rem; }
.users-table th { text-align: left; font-weight: 600; color: var(--muted); font-size: 0.8rem; text-transform: uppercase; letter-spacing: .03em; padding: 6px 10px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.users-table td { padding: 10px; border-bottom: 1px solid var(--border); vertical-align: top; }
.users-table tr:last-child td { border-bottom: 0; }
.users-table .num { text-align: right; }
.users-table .muted { font-size: 0.8rem; }
.u-name { font-weight: 600; }
.u-email { overflow-wrap: anywhere; }
.u-tag { background: var(--accent-soft); color: var(--accent); font-weight: 600; }

/* Admin: visitor counts */
.visit-tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; margin: 6px 0 16px; }
.visit-tile { background: var(--surface-2); border-radius: 10px; padding: 10px 14px; font-size: 0.85rem; }
.visit-num { font-size: 1.7rem; font-weight: 700; line-height: 1.2; color: var(--text); font-variant-numeric: tabular-nums; }
.visit-chart-wrap { position: relative; margin: 0 0 10px; }
.visit-chart-wrap figcaption { font-weight: 600; font-size: 0.9rem; margin-bottom: 8px; }
.visit-chart { display: grid; grid-template-columns: auto 1fr; gap: 8px; }
.vc-axis { display: flex; flex-direction: column; justify-content: space-between; height: 160px; font-size: 0.75rem; color: var(--muted); text-align: right; font-variant-numeric: tabular-nums; }
.vc-axis span { line-height: 1; transform: translateY(-1px); }
.vc-plot { position: relative; min-width: 0; }
.vc-grid { position: absolute; inset: 0 0 auto 0; height: 160px; display: flex; flex-direction: column; justify-content: space-between; pointer-events: none; }
.vc-grid i { display: block; border-top: 1px dashed var(--border); }
.vc-grid i:last-child { border-top: 1px solid var(--border); }
.vc-bars { position: relative; height: 160px; display: grid; grid-template-columns: repeat(var(--n), 1fr); gap: 2px; align-items: end; }
.vc-col { height: 100%; display: flex; align-items: flex-end; justify-content: center; cursor: default; border-radius: 4px 4px 0 0; outline: none; }
.vc-col.hover, .vc-col:focus-visible { background: color-mix(in srgb, var(--chart-bar) 10%, transparent); }
.vc-bar { width: 100%; max-width: 22px; min-height: 0; background: var(--chart-bar); border-radius: 4px 4px 0 0; }
.vc-x { display: grid; grid-template-columns: repeat(var(--n, 30), 1fr); margin-top: 4px; font-size: 0.72rem; color: var(--muted); }
.vc-x span { white-space: nowrap; overflow: visible; text-align: left; }
.visit-tip { position: absolute; top: 18px; z-index: 5; background: var(--surface); color: var(--text); border: 1px solid var(--border); border-radius: 8px; padding: 6px 10px; font-size: 0.82rem; box-shadow: 0 6px 20px rgb(0 0 0 / 14%); pointer-events: none; white-space: nowrap; }
.visit-table-toggle { margin: 4px 0 14px; font-size: 0.88rem; }
.visit-table-toggle summary { cursor: pointer; color: var(--accent); }
.visit-lists { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; }
.visit-lists h4 { margin: 0 0 6px; font-size: 0.9rem; }
.visit-lists ul { list-style: none; margin: 0; padding: 0; }
.visit-lists li { display: flex; justify-content: space-between; gap: 12px; padding: 5px 0; border-bottom: 1px solid var(--border); font-size: 0.9rem; }
.visit-lists li:last-child { border-bottom: 0; }
.admin-visits .chips { margin: 0; }

/* Admin tab */
#tab-admin > .panel { margin-bottom: 18px; }
#tab-admin .admin-library-head { margin-top: 28px; }

/* Recipe photos: the photo (--photo, set by bgStyle() in the page scripts) sits on top of a
   placeholder. If the photo is missing, or the recipe's site blocks it from showing on other
   websites, the placeholder shows instead of a blank box. */
.card-img, .detail-hero, .fa-img, .ci-img {
  background-color: var(--surface-2);
  background-image: var(--photo, none), var(--photo-ph);
  background-size: cover, auto 46%;
  background-position: center, center;
  background-repeat: no-repeat, no-repeat;
}
.detail-hero { background-size: cover, auto 38%; }
