:root {
  --bg: #fcfbf8;
  --paper: #ffffff;
  --panel: #f5f2ea;
  --line: #e7e2d6;
  --ink: #161513;
  --muted: #7a756b;
  --gold: #c19730;
  --gold-dark: #9c7a22;
  --gold-soft: #f7efd9;
  --gold-line: #e6d6a8;

  /* protein colours — muted to sit with the gold */
  --chicken: #d99a2b; --chicken-soft: #fbf0d8; --chicken-ink: #8a5f12;
  --beef:    #b8433a; --beef-soft:    #f8e2df; --beef-ink:    #8a2f28;
  --pork:    #cf6f92; --pork-soft:    #fae5ec; --pork-ink:    #9a3f63;
  --lamb:    #7f5cb6; --lamb-soft:    #ece5f6; --lamb-ink:    #573a87;
  --fish:    #3a7fbd; --fish-soft:    #e0ecf8; --fish-ink:    #22537f;
  --duck:    #8c6239; --duck-soft:    #f0e6da; --duck-ink:    #5f421f;
  --veg:     #4f9a5f; --veg-soft:     #e2f1e4; --veg-ink:     #2f6b3b;
  --other:   #7a756b; --other-soft:   #ecebe7; --other-ink:   #504c44;

  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 1px 2px rgba(22,21,19,.04), 0 8px 24px -12px rgba(22,21,19,.18);
  --font: 'Poppins', system-ui, -apple-system, 'Segoe UI', sans-serif;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font-family: var(--font); color: var(--ink); background: var(--bg); font-size: 15px; line-height: 1.55; }
a { color: var(--gold-dark); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { font-weight: 600; line-height: 1.2; margin: 0 0 .4em; letter-spacing: -.01em; }
h1 { font-size: 1.85rem; }
h2 { font-size: 1.25rem; }
h3 { font-size: 1rem; }
p { margin: 0 0 .8em; }
main { max-width: 1060px; margin: 0 auto; padding: 28px 22px 90px; }

/* header */
.top { display: flex; align-items: center; gap: 24px; padding: 12px 24px; background: var(--paper); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5; }
.brand { display: flex; align-items: center; }
.brand img { height: 44px; width: auto; display: block; }
.top nav { display: flex; gap: 2px; margin-left: auto; overflow-x: auto; }
.top nav a { padding: 8px 15px; border-radius: 999px; color: var(--muted); font-weight: 500; white-space: nowrap; position: relative; }
.top nav a.on { color: var(--ink); background: var(--gold-soft); }
.top nav a:hover { text-decoration: none; color: var(--ink); }
@media (max-width: 640px) {
  .top { flex-wrap: wrap; gap: 10px; padding: 10px 14px; }
  .brand img { height: 36px; }
  .top nav { margin-left: 0; width: 100%; }
  .top nav a { padding: 6px 12px; font-size: .92rem; }
  main { padding: 20px 14px 90px; }
  h1 { font-size: 1.5rem; }
}

/* generic */
.flash { background: var(--gold-soft); color: var(--gold-dark); border: 1px solid var(--gold-line); padding: 10px 16px; border-radius: var(--radius-sm); margin-bottom: 20px; font-weight: 500; }
.err { color: #b3261e; font-weight: 500; }
.muted { color: var(--muted); }
.small { font-size: .88rem; }
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.spread { justify-content: space-between; }
.btn { font-family: var(--font); font-size: .93rem; font-weight: 500; border: 1px solid var(--line); background: var(--paper); color: var(--ink); padding: 9px 18px; border-radius: 999px; cursor: pointer; transition: background .12s, border-color .12s; }
.btn:hover { background: var(--panel); border-color: #d9d3c4; text-decoration: none; }
.btn-primary { background: var(--ink); border-color: var(--ink); color: #fff; }
.btn-primary:hover { background: #2a2825; border-color: #2a2825; }
.btn-gold { background: var(--gold); border-color: var(--gold); color: #fff; }
.btn-gold:hover { background: var(--gold-dark); border-color: var(--gold-dark); }
.btn-sm { padding: 6px 13px; font-size: .84rem; }
.btn-danger { color: #b3261e; }
.btn[disabled] { opacity: .5; cursor: default; }
input[type=text], input[type=number], input[type=password], input[type=url], select, textarea {
  font-family: var(--font); font-size: .95rem; padding: 9px 13px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--paper); color: var(--ink); width: 100%;
}
input:focus, select:focus, textarea:focus { border-color: var(--gold); outline: none; box-shadow: 0 0 0 3px var(--gold-soft); }
textarea { min-height: 90px; resize: vertical; }
label { display: block; font-weight: 500; margin-bottom: 14px; }
label > input, label > select, label > textarea { margin-top: 5px; font-weight: 400; }
.field-help { color: var(--muted); font-weight: 400; font-size: .85rem; display: block; margin-top: 3px; }
:focus-visible { outline: 3px solid var(--gold-line); outline-offset: 2px; }

.panel { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px 22px; margin-bottom: 20px; }
.section { margin-bottom: 40px; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.section-head h2 { position: relative; padding-left: 14px; }
.section-head h2::before { content: ''; position: absolute; left: 0; top: .2em; bottom: .2em; width: 4px; border-radius: 2px; background: var(--gold); }

/* chips */
.chip { display: inline-block; font-size: .76rem; font-weight: 600; padding: 3px 10px; border-radius: 999px; background: var(--other-soft); color: var(--other-ink); }
.chip.p-chicken { background: var(--chicken-soft); color: var(--chicken-ink); }
.chip.p-beef { background: var(--beef-soft); color: var(--beef-ink); }
.chip.p-pork { background: var(--pork-soft); color: var(--pork-ink); }
.chip.p-lamb { background: var(--lamb-soft); color: var(--lamb-ink); }
.chip.p-fish { background: var(--fish-soft); color: var(--fish-ink); }
.chip.p-duck { background: var(--duck-soft); color: var(--duck-ink); }
.chip.p-veg  { background: var(--veg-soft);  color: var(--veg-ink); }
.chip.tag { background: var(--paper); border: 1px solid var(--line); color: var(--muted); font-weight: 500; }
.meta { font-size: .85rem; color: var(--muted); }
.stars { color: var(--gold); letter-spacing: 1px; }

/* recipe cards */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 14px; }
.rcard { display: flex; gap: 12px; background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px 16px 16px; position: relative; box-shadow: var(--shadow); overflow: hidden; }
.rcard::before { content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 5px; background: var(--other); }
.rcard.p-chicken::before { background: var(--chicken); }
.rcard.p-beef::before { background: var(--beef); }
.rcard.p-pork::before { background: var(--pork); }
.rcard.p-lamb::before { background: var(--lamb); }
.rcard.p-fish::before { background: var(--fish); }
.rcard.p-duck::before { background: var(--duck); }
.rcard.p-veg::before { background: var(--veg); }
.rcard.picked { border-color: var(--gold); box-shadow: 0 0 0 3px var(--gold-soft), var(--shadow); }
.rcard-body { flex: 1; min-width: 0; padding-left: 4px; }
.rcard-title { font-weight: 600; color: var(--ink); display: block; font-size: 1rem; line-height: 1.3; }
.rcard-sub { color: var(--muted); font-size: .85rem; margin: 3px 0 10px; }
.rcard-meta { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.pick { margin: 0; display: flex; align-items: flex-start; padding-top: 2px; }
.pick input { position: absolute; opacity: 0; }
.pick span { width: 24px; height: 24px; border-radius: 8px; border: 2px solid #cfc9bb; display: inline-block; background: var(--paper); position: relative; transition: background .12s, border-color .12s; }
.pick input:checked + span { background: var(--gold); border-color: var(--gold); }
.pick input:checked + span::after { content: ''; position: absolute; left: 7px; top: 3px; width: 6px; height: 11px; border: solid #fff; border-width: 0 2.5px 2.5px 0; transform: rotate(45deg); }
.pick input:focus-visible + span { outline: 3px solid var(--gold-line); }

/* this week: menu board */
.board { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 14px; margin-bottom: 14px; }
.slot { border-radius: var(--radius); padding: 18px 18px 16px; background: var(--paper); border: 1px solid var(--line); box-shadow: var(--shadow); min-height: 130px; display: flex; flex-direction: column; justify-content: space-between; position: relative; overflow: hidden; }
.slot::before { content: ''; position: absolute; left: 0; right: 0; top: 0; height: 6px; background: var(--other); }
.slot.p-chicken::before { background: var(--chicken); } .slot.p-beef::before { background: var(--beef); } .slot.p-pork::before { background: var(--pork); }
.slot.p-lamb::before { background: var(--lamb); } .slot.p-fish::before { background: var(--fish); } .slot.p-duck::before { background: var(--duck); } .slot.p-veg::before { background: var(--veg); }
.slot a { color: var(--ink); font-weight: 600; font-size: 1.02rem; line-height: 1.3; }
.slot-actions { display: flex; gap: 8px; margin-top: 12px; }
.slot.empty { background: var(--panel); color: var(--muted); border: 1px dashed #d9d3c4; box-shadow: none; align-items: center; justify-content: center; text-align: center; }
.slot.empty::before { display: none; }

.sticky-bar { position: sticky; bottom: 0; background: var(--bg); border-top: 1px solid var(--line); padding: 12px 0; margin-top: 16px; display: flex; gap: 12px; align-items: center; }
.count-pill { font-weight: 600; color: var(--gold-dark); }

/* shopping */
.shop-list { list-style: none; padding: 0; margin: 0; background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.shop-item { display: grid; grid-template-columns: 28px 1fr auto; gap: 12px; align-items: center; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.shop-item:last-child { border-bottom: 0; }
.shop-item.done { background: var(--bg); }
.shop-item.done .shop-name { text-decoration: line-through; color: var(--muted); }
.shop-name { font-weight: 500; }
.shop-sub { color: var(--muted); font-size: .84rem; }
.shop-item input[type=checkbox] { width: 20px; height: 20px; accent-color: var(--gold); }
.tesco { display: inline-flex; align-items: center; gap: 6px; padding: 6px 13px; border-radius: 999px; background: #edf1fb; color: #1f3a93; font-weight: 600; font-size: .8rem; white-space: nowrap; }
.tesco:hover { background: #dde5f8; text-decoration: none; }
.tesco.custom { background: var(--gold-soft); color: var(--gold-dark); }
.pantry-list { columns: 2; column-gap: 24px; padding-left: 18px; }
@media (max-width: 560px) { .pantry-list { columns: 1; } .shop-item { grid-template-columns: 26px 1fr; padding: 12px 12px; } .shop-item .tesco { grid-column: 2; justify-self: start; } }

/* recipe page */
.recipe-head { padding: 26px 26px 22px 30px; border-radius: var(--radius); background: var(--paper); border: 1px solid var(--line); box-shadow: var(--shadow); margin-bottom: 22px; position: relative; overflow: hidden; }
.recipe-head::before { content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 8px; background: var(--other); }
.recipe-head.p-chicken::before { background: var(--chicken); } .recipe-head.p-beef::before { background: var(--beef); } .recipe-head.p-pork::before { background: var(--pork); }
.recipe-head.p-lamb::before { background: var(--lamb); } .recipe-head.p-fish::before { background: var(--fish); } .recipe-head.p-duck::before { background: var(--duck); } .recipe-head.p-veg::before { background: var(--veg); }
.recipe-head h1 { margin-bottom: 2px; }
.recipe-head .sub { color: var(--muted); margin-bottom: 12px; }
.recipe-cols { display: grid; grid-template-columns: 300px 1fr; gap: 30px; }
@media (max-width: 760px) { .recipe-cols { grid-template-columns: 1fr; } }
.ing-list { list-style: none; padding: 0; margin: 0 0 18px; }
.ing-list li { display: flex; justify-content: space-between; gap: 10px; padding: 7px 0; border-bottom: 1px solid var(--line); }
.ing-list li b { font-weight: 600; white-space: nowrap; color: var(--gold-dark); }
.steps { counter-reset: step; list-style: none; padding: 0; margin: 0; }
.steps li { display: grid; grid-template-columns: 40px 1fr; gap: 14px; padding: 16px 0; border-bottom: 1px solid var(--line); }
.steps li::before { counter-increment: step; content: counter(step); width: 36px; height: 36px; border-radius: 50%; background: var(--gold-soft); color: var(--gold-dark); font-weight: 700; display: flex; align-items: center; justify-content: center; border: 1px solid var(--gold-line); }
.steps h3 { margin-bottom: 4px; }
.steps p { margin: 0; }
.steps li.done { opacity: .4; }
.steps li.done::before { background: var(--gold); color: #fff; content: '✓'; }
.cook-mode .steps li { cursor: pointer; }
.people-toggle { display: inline-flex; border: 1px solid var(--line); border-radius: 999px; overflow: hidden; background: var(--paper); }
.people-toggle a, .people-toggle button { padding: 6px 14px; font-family: var(--font); font-weight: 500; background: transparent; border: 0; cursor: pointer; color: var(--muted); font-size: .9rem; }
.people-toggle .on { background: var(--ink); color: #fff; }
.people-toggle a:hover { text-decoration: none; }
.rate { display: inline-flex; gap: 2px; }
.rate button { background: none; border: 0; font-size: 1.5rem; cursor: pointer; color: #dcd6c8; padding: 0 2px; line-height: 1; }
.rate button.on { color: var(--gold); }

/* filters */
.filters { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 18px; }
.filters a { padding: 6px 13px; border-radius: 999px; border: 1px solid var(--line); background: var(--paper); color: var(--muted); font-size: .86rem; font-weight: 500; }
.filters a.on { background: var(--ink); color: #fff; border-color: var(--ink); }
.filters a:hover { text-decoration: none; border-color: var(--gold); color: var(--ink); }
.filters a.on:hover { color: #fff; }

/* tables */
table { border-collapse: collapse; width: 100%; font-size: .92rem; }
th, td { text-align: left; padding: 9px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-weight: 600; color: var(--muted); font-size: .84rem; }

/* login */
.login-body { display: flex; align-items: center; justify-content: center; min-height: 100vh; margin: 0; background: var(--bg); }
.login-box { background: var(--paper); border: 1px solid var(--line); padding: 36px 32px 28px; border-radius: var(--radius); width: min(380px, 90vw); box-shadow: var(--shadow); text-align: center; }
.login-box img { width: 240px; max-width: 80%; margin: 0 auto 22px; display: block; }
.login-box label { text-align: left; }
.login-box .btn { width: 100%; }

/* misc */
.legend { display: flex; gap: 10px; flex-wrap: wrap; margin: 6px 0 18px; }
details summary { cursor: pointer; font-weight: 500; color: var(--gold-dark); }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
@media (max-width: 700px) { .two-col { grid-template-columns: 1fr; } }
code { font-size: .85em; }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
@media print { .top, .sticky-bar, .btn, .filters { display: none !important; } main { padding: 0; } body { background: #fff; } }
