/* Faulkstrong Noms — "cave of fairy lights" theme */
:root {
  --bg: #13101b;
  --bg-2: #1a1524;
  --surface: #211b2e;
  --surface-2: #2b2340;
  --line: rgba(255, 255, 255, 0.09);
  --text: #f6f0e8;
  --muted: #b0a6c2;
  --faint: #7d7391;

  --red: #ff5468;
  --gold: #ffc94d;
  --green: #4fe08f;
  --blue: #5fb0ff;
  --pink: #ff6bd6;

  --accent: var(--gold);
  --veg: var(--green);
  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
  --display: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  --body: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background:
    radial-gradient(1200px 600px at 10% -10%, rgba(95, 176, 255, 0.10), transparent 60%),
    radial-gradient(900px 500px at 100% 0%, rgba(255, 107, 214, 0.08), transparent 60%),
    var(--bg);
  background-attachment: fixed;
  color: var(--text);
  font: 16px/1.45 var(--body);
  min-height: 100vh;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }

/* ---------- Fairy lights ---------- */
.lights { position: relative; height: 46px; overflow: hidden; pointer-events: none; }
.lights svg { position: absolute; left: 50%; transform: translateX(-50%); top: 0; height: 46px; width: 1600px; }
.lights .wire { fill: none; stroke: #2e3a2c; stroke-width: 2; }
.lights .bulb { animation: twinkle 3.2s ease-in-out infinite; }
@keyframes twinkle { 0%, 100% { opacity: 1; } 50% { opacity: 0.35; } }
@media (prefers-reduced-motion: reduce) { .lights .bulb { animation: none; } }

/* ---------- Hero ---------- */
.hero { max-width: 1100px; margin: 0 auto; padding: 0 14px; }
.hero img {
  display: block; width: 100%; height: auto; aspect-ratio: 16 / 9; max-height: 440px; object-fit: cover; object-position: 50% 70%;
  border-radius: var(--radius); box-shadow: var(--shadow); border: 1px solid var(--line);
}
.hero-text { padding: 14px 4px 10px; }
.eyebrow { margin: 0; color: var(--gold); font-size: 13px; letter-spacing: 0.12em; text-transform: uppercase; font-weight: 600; }
.hero h1 { margin: 2px 0 4px; font: 600 clamp(30px, 6vw, 46px)/1.05 var(--display); letter-spacing: -0.01em; }
.hero .dates { margin: 0; color: var(--muted); font-size: 15px; }
.hero.no-photo img { display: none; }
body:not([data-tab="plan"]) .hero img { display: none; }
@media (max-width: 640px) {
  .hero { padding: 0 10px; }
  .hero img { aspect-ratio: 4 / 3; object-position: 50% 80%; }
  .tabs { gap: 4px; padding: 8px 6px; }
  .tab { flex: 1 1 0; min-width: 0; padding: 8px 2px; font-size: 13px; gap: 3px; white-space: nowrap; }
  .tab .count { padding: 0 5px; font-size: 11px; }
  main { padding: 12px 10px 80px; }
}
body:not([data-tab="plan"]) .hero-text { padding: 2px 4px 8px; }
body:not([data-tab="plan"]) .hero h1 { font-size: 26px; }
body:not([data-tab="plan"]) .hero .eyebrow, body:not([data-tab="plan"]) .hero .dates { display: none; }

/* ---------- Tabs ---------- */
.tabs {
  position: sticky; top: 0; z-index: 10;
  display: flex; gap: 6px; justify-content: center;
  padding: 10px 12px;
  background: rgba(19, 16, 27, 0.86);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}
.tab {
  flex: 1; max-width: 200px;
  border: 1px solid var(--line); background: var(--surface);
  border-radius: 999px; padding: 9px 12px; font-weight: 600; font-size: 15px; color: var(--muted);
  display: flex; align-items: center; justify-content: center; gap: 6px;
}
.tab[aria-selected="true"] { background: var(--gold); color: #1b1408; border-color: transparent; }
.tab .count { font-size: 12px; background: rgba(0,0,0,.18); border-radius: 999px; padding: 1px 7px; }
.tab:not([aria-selected="true"]) .count { background: var(--surface-2); color: var(--text); }

main { max-width: 1100px; margin: 0 auto; padding: 16px 14px 80px; }

/* ---------- Generic bits ---------- */
.bar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.bar .summary { color: var(--muted); font-size: 15px; }
.bar .summary strong { color: var(--text); }
.btn {
  border: 1px solid var(--line); background: var(--surface-2); color: var(--text);
  border-radius: 999px; padding: 8px 14px; font-weight: 600; font-size: 14px;
  display: inline-flex; align-items: center; gap: 6px;
}
.btn:hover { border-color: rgba(255,255,255,.22); }
.btn.primary { background: var(--gold); color: #1b1408; border-color: transparent; }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--red); }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.muted { color: var(--muted); }
.veg-badge { color: var(--veg); font-weight: 600; }
.chip {
  border: 1px solid var(--line); background: var(--bg-2); border-radius: 999px;
  padding: 6px 12px; font-size: 14px; color: var(--text);
}
.chip:hover { border-color: var(--gold); }
input[type="text"], input[type="search"], input[type="number"], input[type="password"], select, textarea {
  width: 100%; background: var(--bg-2); border: 1px solid var(--line); border-radius: var(--radius-sm);
  padding: 10px 12px; font-size: 16px;
}
textarea { min-height: 110px; resize: vertical; }
label.field { display: block; margin-bottom: 12px; }
label.field > span { display: block; font-size: 13px; color: var(--muted); margin-bottom: 4px; }

/* ---------- Plan ---------- */
.days { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); }
.day { padding: 14px; position: relative; overflow: hidden; }
.day::before { content: ""; position: absolute; left: 0; top: 0; right: 0; height: 3px; background: var(--day-colour, var(--gold)); }
.day-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; margin-bottom: 10px; }
.day-head h2 { margin: 0; font: 600 21px/1.2 var(--display); }
.day-tag { font-size: 12px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: var(--day-colour, var(--gold)); }
.slot {
  display: block; width: 100%; text-align: left;
  background: var(--bg-2); border: 1px solid var(--line); border-radius: var(--radius-sm);
  padding: 9px 12px; margin-top: 8px; color: var(--text);
}
.slot:hover { border-color: rgba(255,255,255,.25); }
.slot .meal-label { display: block; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; color: var(--faint); }
.slot .meal-name { display: block; font-weight: 600; }
.slot .meal-sub { display: block; font-size: 13px; color: var(--muted); margin-top: 2px; }
.slot .meal-sub.veg { color: var(--veg); }
.slot.tbd { border-style: dashed; background: transparent; }
.slot.tbd .meal-name { color: var(--faint); font-weight: 500; }
.slot.out .meal-name { color: var(--pink); }
.slot.none .meal-name { color: var(--muted); font-weight: 500; }

/* ---------- Sheet (picker) ---------- */
dialog.sheet {
  border: 1px solid var(--line); background: var(--surface); color: var(--text);
  border-radius: 20px; padding: 0; width: min(620px, 100vw - 24px); max-height: min(86vh, 900px);
  box-shadow: var(--shadow);
}
dialog.sheet::backdrop { background: rgba(5, 3, 10, 0.65); backdrop-filter: blur(2px); }
@media (max-width: 640px) {
  dialog.sheet { width: 100vw; max-width: 100vw; margin: auto 0 0; border-radius: 20px 20px 0 0; max-height: 88vh; }
}
.sheet-inner { display: flex; flex-direction: column; max-height: inherit; }
.sheet-head { display: flex; align-items: center; gap: 10px; padding: 14px 16px 10px; border-bottom: 1px solid var(--line); }
.sheet-head h3 { margin: 0; font: 600 20px/1.2 var(--display); flex: 1; }
.sheet-head .icon-btn { border: 0; background: var(--surface-2); border-radius: 999px; width: 34px; height: 34px; font-size: 18px; line-height: 1; }
.sheet-body { overflow-y: auto; padding: 12px 16px 18px; }
.sheet-body h4 { margin: 16px 0 6px; font-size: 12px; text-transform: uppercase; letter-spacing: .08em; color: var(--faint); }
.quick { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.option {
  display: flex; width: 100%; align-items: center; gap: 10px; text-align: left;
  border: 1px solid transparent; background: var(--bg-2); border-radius: var(--radius-sm);
  padding: 10px 12px; margin-bottom: 6px; color: var(--text);
}
.option:hover { border-color: rgba(255,255,255,.2); }
.option.current { border-color: var(--gold); }
.option .opt-main { flex: 1; }
.option .opt-name { display: block; font-weight: 600; }
.option .opt-sub { display: block; font-size: 13px; color: var(--muted); }
.option .tag { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: #1b1408; background: var(--gold); border-radius: 999px; padding: 2px 8px; }

.sheet-foot {
  position: sticky; bottom: -18px; margin: 14px -16px -18px; padding: 12px 16px 16px;
  background: var(--surface); border-top: 1px solid var(--line);
}
.btn.veg-edit { justify-content: center; color: var(--veg); border-color: rgba(79, 224, 143, 0.4); }
.sheet-body > .btn.veg-edit { width: 100%; margin-bottom: 12px; }

/* The meal's dishes: main + extras, each with its portions */
.dish-box { padding: 12px 14px; margin-bottom: 12px; }
.dish-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 6px 0; flex-wrap: wrap; }
.dish-row + .dish-row { border-top: 1px solid var(--line); }
.dish-name { flex: 1 1 160px; }
.dish-serves { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: 14px; white-space: nowrap; }
.dish-serves input { width: 68px; padding: 6px 8px; }
.dish-serves .del { border: 0; background: none; color: var(--faint); font-size: 22px; padding: 0 2px; }
.dish-actions { margin-top: 10px; }
.dish-actions .btn { flex: 1 1 0; justify-content: center; margin: 0; }
.field-row { display: flex; gap: 12px; align-items: flex-end; flex-wrap: wrap; }
.field-row > .field:first-child { flex: 1 1 200px; }
.field.veg-toggle { flex-direction: row; display: flex; align-items: center; gap: 8px; color: var(--veg); font-weight: 600; padding-bottom: 12px; }
.field.veg-toggle input { width: 22px; height: 22px; accent-color: var(--green); }

/* ---------- Recipes ---------- */
.recipe-search { margin-bottom: 14px; }
.recipe-grid > div { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); align-items: start; }
.recipe-group { padding: 4px 0; }
.recipe-group h3 { margin: 0; padding: 10px 14px 6px; font: 600 18px/1.2 var(--display); display: flex; justify-content: space-between; align-items: baseline; }
.recipe-group h3 small { font: 500 13px var(--body); color: var(--faint); }
.recipe-row {
  display: flex; flex-direction: column; gap: 4px; width: 100%; text-align: left; color: var(--text);
  background: none; border: 0; border-top: 1px solid var(--line); padding: 10px 14px;
}
.recipe-row:hover { background: var(--bg-2); }
.recipe-name { font-weight: 600; }
.recipe-badges { display: flex; flex-wrap: wrap; gap: 6px; font-size: 12px; color: var(--muted); }
.badge { background: var(--bg-2); border: 1px solid var(--line); border-radius: 999px; padding: 1px 8px; }
.badge.veg { color: var(--veg); }
.badge.mine { color: var(--gold); border-color: rgba(255, 201, 77, 0.4); }
.badge.edited { color: var(--blue); border-color: rgba(95, 176, 255, 0.4); }
.btn.danger.ghost { color: var(--red); }

/* ---------- Ingredient editor ---------- */
.btn.edit-btn { color: var(--gold); border-color: rgba(255, 201, 77, 0.4); }
.small { font-size: 13px; }
.ed-row {
  display: grid; grid-template-columns: 1fr 140px 28px; gap: 8px; align-items: center;
  padding: 8px 0; border-top: 1px solid var(--line);
}
.ed-name { font-weight: 600; }
.ed-qty { display: flex; align-items: center; gap: 6px; }
.ed-qty input { padding: 8px 10px; min-width: 0; }
.ed-qty select { width: auto; padding: 8px; }
.ed-unit { color: var(--muted); font-size: 13px; min-width: 38px; }
.ed-staple { color: var(--faint); font-size: 13px; }
.ed-row .del { border: 0; background: none; color: var(--faint); font-size: 20px; }
.ed-add { margin-top: 10px; }
.ed-add-row { display: grid; grid-template-columns: 1fr 180px auto; gap: 8px; align-items: center; }
@media (max-width: 640px) {
  .ed-row { grid-template-columns: 1fr 120px 28px; }
  .ed-add-row { grid-template-columns: 1fr auto; }
  .ed-add-row > input[type="text"] { grid-column: 1 / -1; }
}

/* ---------- Shopping ---------- */
.shop-grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); align-items: start; }
.shop-section { padding: 6px 0 4px; }
.shop-section h3 {
  margin: 0; padding: 10px 14px 6px; font: 600 18px/1.2 var(--display);
  display: flex; justify-content: space-between; align-items: baseline;
}
.shop-section h3 small { font: 500 13px var(--body); color: var(--faint); }
.item { display: flex; align-items: flex-start; gap: 12px; padding: 10px 14px; border-top: 1px solid var(--line); cursor: pointer; }
.item input[type="checkbox"] {
  appearance: none; -webkit-appearance: none; flex: none; margin: 1px 0 0;
  width: 24px; height: 24px; border-radius: 7px; border: 2px solid var(--faint); background: transparent; cursor: pointer;
  display: grid; place-items: center;
}
.item input[type="checkbox"]:checked { background: var(--green); border-color: var(--green); }
.item input[type="checkbox"]:checked::after { content: "✓"; color: #08200f; font-weight: 800; font-size: 15px; line-height: 1; }
.item .item-main { flex: 1; min-width: 0; }
.item .item-name { font-weight: 600; }
.item .item-meta { font-size: 13px; color: var(--muted); }
.item .item-qty { font-weight: 700; color: var(--gold); white-space: nowrap; text-align: right; }
.item .item-qty small { display: block; font-weight: 500; color: var(--faint); font-size: 12px; }
.item.ticked .item-name, .item.ticked .item-qty { text-decoration: line-through; color: var(--faint); }
.item .del { border: 0; background: none; color: var(--faint); font-size: 18px; padding: 0 2px; }
.add-extra { display: flex; gap: 8px; padding: 10px 14px; border-top: 1px solid var(--line); }
.add-extra input { flex: 1; }
.quick-extras { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 14px 12px; }
.quick-extras .chip { font-size: 13px; padding: 4px 10px; }
details.pantry summary { cursor: pointer; list-style: none; }
details.pantry summary::-webkit-details-marker { display: none; }
details.pantry summary h3::after { content: "▸"; color: var(--faint); margin-left: 8px; }
details.pantry[open] summary h3::after { content: "▾"; }
.empty { padding: 28px 18px; text-align: center; color: var(--muted); }

/* ---------- Family ---------- */
.people { display: grid; gap: 10px; }
.person { padding: 12px 14px; display: grid; grid-template-columns: 1fr 120px 90px auto auto; gap: 10px; align-items: center; }
.person .veg-toggle { display: flex; align-items: center; gap: 6px; font-size: 14px; color: var(--muted); white-space: nowrap; }
.person .veg-toggle input { width: 20px; height: 20px; accent-color: var(--green); }
.person .del { border: 0; background: none; color: var(--faint); font-size: 20px; }
@media (max-width: 640px) {
  .person { grid-template-columns: 1fr 1fr; }
  .person .name { grid-column: 1 / -1; }
}
.info { padding: 14px 16px; margin-top: 16px; color: var(--muted); font-size: 14px; }
.info p { margin: 6px 0; }
.info strong { color: var(--text); }

/* ---------- Toast ---------- */
#toast {
  position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%) translateY(120px);
  background: var(--surface-2); border: 1px solid var(--line); color: var(--text);
  padding: 10px 16px; border-radius: 999px; box-shadow: var(--shadow); transition: transform .25s ease; z-index: 50;
  max-width: calc(100vw - 32px);
}
#toast.show { transform: translateX(-50%) translateY(0); }

/* ---------- Login ---------- */
.login-wrap { min-height: calc(100vh - 46px); display: grid; place-items: center; padding: 20px; }
.login-card { width: min(400px, 100%); padding: 28px 24px; text-align: center; }
.login-card h1 { margin: 4px 0 6px; font: 600 34px/1.1 var(--display); }
.login-card p { color: var(--muted); margin: 0 0 20px; }
.login-card form { display: grid; gap: 12px; }
.login-card .btn { justify-content: center; padding: 11px; font-size: 16px; }
.login-error { color: var(--red); min-height: 1.4em; font-size: 14px; }
