:root {
  --accent: #5c0a0a;
  --accent-2: #7d1818;
  --accent-soft: #f7efee;
  --ink: #1d1a1a;
  --muted: #736b6a;
  --line: #e8e2e1;
  --bg: #faf8f7;
  --card: #ffffff;
  --ok: #2f6b3a;
  --ok-soft: #eaf3ec;
  --warn: #9a5a00;
  --warn-soft: #fbf1e3;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(30, 10, 10, .04), 0 6px 20px rgba(30, 10, 10, .04);
  --input: #ffffff;
  --line-soft: #f2eeed;
  --line-strong: #cfc5c4;
  --accent-line: #e3cfcd;
  --icon: #b9b0af;
  --track: #d9d2d1;
  --error: #a01818;
  --focus: rgba(92, 10, 10, .18);
  color-scheme: light;
}
/* Dark mode: charcoal and warm off-white with Catalyst red, matching the landing page */
:root[data-theme="dark"] {
  --accent: #d0352a;
  --accent-2: #e04b3f;
  --accent-soft: rgba(208, 53, 42, .14);
  --ink: #f2efea;
  --muted: #a39e98;
  --line: #2f2d2b;
  --bg: #171615;
  --card: #1e1d1c;
  --ok: #7cc48a;
  --ok-soft: rgba(124, 196, 138, .13);
  --warn: #e3a64f;
  --warn-soft: rgba(227, 166, 79, .14);
  --shadow: none;
  --input: #252322;
  --line-soft: #292725;
  --line-strong: #4a4643;
  --accent-line: rgba(208, 53, 42, .45);
  --icon: #6f6a66;
  --track: #3d3a37;
  --error: #ff6b5e;
  --focus: rgba(208, 53, 42, .35);
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, "Helvetica Neue", Arial, sans-serif;
  color: var(--ink); background: var(--bg); line-height: 1.45; font-size: 15px;
  -webkit-font-smoothing: antialiased;
}
[hidden] { display: none !important; }
h2 { font-size: 15px; letter-spacing: .02em; text-transform: uppercase; margin: 0 0 12px; color: var(--accent); }
h3 { font-size: 17px; margin: 0 0 10px; }
h4 { font-size: 13px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin: 0 0 6px; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.pad { padding: 10px 12px; margin: 0; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.between { justify-content: space-between; }
.stack { display: grid; gap: 12px; }

.boot { padding: 80px 20px; text-align: center; color: var(--muted); }

.brand { font-weight: 800; letter-spacing: .18em; color: var(--accent); font-size: 15px; }
.brand span { font-weight: 400; letter-spacing: .04em; color: var(--muted); margin-left: 6px; text-transform: none; }

/* Auth */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.auth-card { width: 100%; max-width: 380px; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 28px; box-shadow: var(--shadow); }
.auth-card .brand { margin-bottom: 20px; }
label { display: grid; gap: 6px; font-size: 13px; color: var(--muted); }
label.inline { display: inline-flex; align-items: center; gap: 8px; color: var(--ink); font-size: 14px; }
input[type=email], input[type=password], input[type=text], input[type=search], textarea, select {
  font: inherit; color: var(--ink); background: var(--input); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; width: 100%;
}
select { width: auto; padding: 8px 10px; cursor: pointer; }
input:focus, textarea:focus, select:focus { outline: 2px solid var(--focus); border-color: var(--accent-2); }
textarea { resize: vertical; min-height: 96px; line-height: 1.5; }

/* Buttons */
.btn { font: inherit; font-size: 14px; border: 1px solid var(--line); background: var(--card); color: var(--ink); border-radius: 10px; padding: 9px 14px; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; }
.btn:hover:not(:disabled) { border-color: var(--line-strong); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.btn.primary:hover:not(:disabled) { background: var(--accent-2); }
.btn.big { padding: 12px 22px; font-size: 15px; }
.btn.small { padding: 6px 10px; font-size: 12.5px; border-radius: 8px; }
.btn.ghost { background: transparent; }
.btn svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 2; }
.link { background: none; border: 0; padding: 0; color: var(--accent); font: inherit; font-size: 13px; cursor: pointer; text-decoration: underline; text-underline-offset: 2px; }
.msg { min-height: 1em; font-size: 13px; margin: 10px 0 0; color: var(--muted); }
.msg.error { color: var(--error); }
.msg.ok { color: var(--ok); }

/* Layout */
#app { max-width: 1180px; margin: 0 auto; padding: 0 16px 60px; }
.topbar { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; padding: 14px 2px; }
.topbar-left { font-size: 13px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.topbar-logo .logo { height: 64px; width: auto; display: block; }
.topbar-right { display: flex; gap: 14px; align-items: center; justify-content: flex-end; }
.save-state { font-size: 12px; color: var(--muted); }
.panel { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; margin-bottom: 14px; box-shadow: var(--shadow); }

/* Targets */
.target-grid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 10px; }
.target { background: var(--bg); border: 1px solid var(--line); border-radius: 12px; padding: 12px; gap: 6px; color: var(--ink); }
.target-label { font-weight: 600; font-size: 13.5px; }
.target select { font-size: 18px; font-weight: 700; padding: 6px 10px; width: 100%; }
.target-guide { font-size: 11.5px; color: var(--muted); }
.meal-setup { display: flex; gap: 16px; align-items: center; flex-wrap: wrap; margin-top: 14px; }
.snack-toggles { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.chip { display: inline-flex; flex-direction: row; align-items: center; gap: 6px; padding: 6px 10px; border: 1px solid var(--line); border-radius: 999px; font-size: 12.5px; color: var(--ink); cursor: pointer; background: var(--card); }
.chip input { margin: 0; accent-color: var(--accent); }
.chip.on { background: var(--accent-soft); border-color: var(--accent-line); color: var(--accent); }

/* Food lists */
.collapsible > summary { list-style: none; cursor: pointer; display: flex; align-items: baseline; gap: 12px; }
.collapsible > summary::-webkit-details-marker { display: none; }
.collapsible > summary h2 { margin: 0; }
.collapsible > summary::after { content: "Hide"; margin-left: auto; font-size: 12px; color: var(--muted); }
.collapsible:not([open]) > summary::after { content: "Show"; }
.collapsible[open] > summary { margin-bottom: 12px; }
input.search { margin: 0 0 8px; max-width: 260px; padding: 5px 10px; font-size: 13px; }
.food-tables { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 10px; }
.food-card { border: 1px solid var(--line); border-radius: 12px; overflow: hidden; background: var(--card); display: flex; flex-direction: column; }
.food-card-head { padding: 6px 10px; border-bottom: 1px solid var(--line); background: var(--bg); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.food-card-head strong { font-size: 12.5px; }
.food-scroll { max-height: 205px; overflow-y: auto; }
.food { display: grid; grid-template-columns: 1fr auto auto; align-items: center; gap: 2px; padding: 6px 4px 6px 10px; border-bottom: 1px solid var(--line-soft); }
.food:last-child { border-bottom: 0; }
.food-main { display: grid; gap: 1px; min-width: 0; }
.food-name { font-size: 13px; font-weight: 600; }
.food-meta { font-size: 11.5px; color: var(--muted); }
.tag { display: inline-block; font-size: 9.5px; font-weight: 700; color: var(--ok); background: var(--ok-soft); border-radius: 4px; padding: 0 4px; vertical-align: 1px; }
.ico { width: 30px; height: 30px; display: grid; place-items: center; border: 0; background: none; border-radius: 8px; cursor: pointer; color: var(--icon); }
.ico:hover { background: var(--bg); color: var(--muted); }
.ico svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; }
.food.is-fav { background: var(--accent-soft); }
.food.is-fav .fav { color: var(--accent); }
.food.is-fav .fav svg { fill: currentColor; }
.food.is-ban .food-main { opacity: .4; text-decoration: line-through; }
.food.is-ban .ban { color: var(--error); }

/* Plan */
.plan { margin-top: 6px; }
.day-totals { display: grid; gap: 10px; }
.totals-sub { font-size: 13.5px; color: var(--muted); }
.tallies { display: flex; gap: 6px; flex-wrap: wrap; }
.tally { font-size: 16px; padding: 7px 14px; border-radius: 999px; font-weight: 700; }
.tally.ok { background: var(--ok-soft); color: var(--ok); }
.tally.off { background: var(--warn-soft); color: var(--warn); }
.meal { padding: 16px 18px; }
.meal.is-locked { border-color: var(--accent-line); }
.meal-head { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; margin-bottom: 8px; }
.meal-name { font-weight: 700; font-size: 15px; }
.meal-title { color: var(--muted); font-size: 14px; margin-top: 2px; }
.badge { font-size: 11px; font-weight: 700; color: var(--accent); background: var(--accent-soft); border-radius: 6px; padding: 1px 6px; margin-left: 4px; vertical-align: 1px; }
.lock-btn.on { color: var(--accent); border-color: var(--accent-line); background: var(--accent-soft); }
.items { list-style: none; margin: 0; padding: 0; }
.item { display: grid; grid-template-columns: 1fr auto; gap: 6px 12px; align-items: center; padding: 10px 0; border-top: 1px solid var(--line-soft); }
.item.is-locked .item-name::after { content: " · locked"; font-size: 11.5px; color: var(--accent); font-weight: 600; }
.item-name { font-weight: 600; font-size: 14px; }
.qty { color: var(--accent); margin-right: 4px; }
.amt { font-weight: 500; color: var(--muted); margin-left: 4px; }
.fav-dot { color: var(--accent); font-size: 12px; }
.item-macros { font-size: 12px; color: var(--muted); margin-top: 2px; }
.item-actions { display: flex; gap: 4px; flex-wrap: wrap; justify-content: flex-end; }
.swap-list { grid-column: 1 / -1; border: 1px solid var(--line); border-radius: 10px; max-height: 260px; overflow-y: auto; background: var(--bg); }
.swap-opt { display: flex; justify-content: space-between; gap: 10px; width: 100%; text-align: left; font: inherit; font-size: 13px; padding: 9px 12px; border: 0; border-bottom: 1px solid var(--line); background: transparent; cursor: pointer; }
.swap-opt:last-child { border-bottom: 0; }
.swap-opt:hover { background: var(--card); }
.free { font-size: 13px; color: var(--muted); margin: 10px 0 0; }
.free strong { color: var(--ink); font-weight: 600; }
.meal-foot { margin-top: 12px; display: flex; gap: 6px; flex-wrap: wrap; }
.recipe { margin-top: 14px; padding: 16px; border-radius: 12px; background: var(--bg); border: 1px solid var(--line); }
.recipe-cols { display: grid; grid-template-columns: 1fr 1.6fr; gap: 20px; }
.recipe ul, .recipe ol { margin: 0; padding-left: 18px; font-size: 14px; }
.recipe li { margin-bottom: 4px; }
.tip { font-size: 13.5px; margin: 12px 0 0; }


/* Responsive */
@media (max-width: 1000px) {
  .food-tables { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 760px) {
  body { font-size: 14.5px; }
  .target-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .food-tables { grid-template-columns: 1fr; }
  .food-scroll { max-height: 150px; }
  .item { grid-template-columns: 1fr; }
  .item-actions { justify-content: flex-start; }
  .recipe-cols { grid-template-columns: 1fr; }
  .tally { font-size: 14px; padding: 6px 11px; }
}
@media (max-width: 420px) {
  .target-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* Swap toggles */
.swap-toggles { display: flex; gap: 10px 22px; flex-wrap: wrap; margin-top: 14px; }
.switch { display: inline-flex; flex-direction: row; align-items: center; gap: 10px; font-size: 13.5px; color: var(--ink); cursor: pointer; }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch .track { width: 36px; height: 20px; border-radius: 999px; background: var(--track); position: relative; transition: background .15s; flex: none; }
.switch .knob { position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(0,0,0,.2); transition: left .15s; }
.switch.on .track { background: var(--accent); }
.switch.on .knob { left: 18px; }
.switch input:focus-visible + .track { outline: 2px solid var(--focus); outline-offset: 2px; }
.switch.disabled { cursor: not-allowed; opacity: .55; }
.effective { margin: 10px 0 0; font-size: 13px; color: var(--muted); }
.effective strong { color: var(--accent); font-weight: 600; }

/* Calendar */
.days-layout { display: block; }
.day-side { max-width: 46%; }
/* Calendar sits in the top-right corner of the Planning panel, level with the title */
@media (min-width: 761px) {
  .days.collapsible { position: relative; }
  .days.collapsible[open] { min-height: 350px; }
  .days .calendar { position: absolute; top: 44px; right: 18px; width: min(50%, 560px); }
  .days .cal-day { height: 34px; }
}
.cal-head { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.cal-head strong { min-width: 130px; text-align: center; font-size: 14px; }
.cal-head .link { margin-left: auto; }
.cal-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 3px; }
.cal-dow { font-size: 11px; color: var(--muted); text-align: center; padding: 2px 0; }
.cal-day { height: 32px; border: 1px solid var(--line); background: var(--card); color: var(--ink); border-radius: 7px; cursor: pointer; font: inherit; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px; padding: 2px; }
.cal-day:hover { border-color: var(--line-strong); }
.cal-num { font-size: 12px; font-weight: 600; line-height: 1; }
.cal-kcal { font-size: 8.5px; color: var(--accent); line-height: 1; }
.cal-day.has { background: var(--accent-soft); border-color: var(--accent-line); }
.cal-day.today .cal-num { color: var(--accent); text-decoration: underline; text-underline-offset: 3px; }
.cal-day.sel { outline: 2px solid var(--accent); outline-offset: -1px; }
.day-side { display: grid; gap: 6px; align-content: start; justify-items: start; }
.day-title { font-size: 17px; font-weight: 700; }
.day-side p { margin: 0; }
.field-label { display: block; font-size: 13.5px; font-weight: 600; color: var(--ink); margin: 4px 0 6px; }
.count { text-align: right; margin: 2px 0 0; }
.prefs-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; padding-top: 6px; }
.prefs.collapsible[open] > summary { margin-bottom: 18px; }
.prefs .field-label { margin-bottom: 8px; }
.field-label { margin-top: 0; }
.generate-bar { display: flex; justify-content: flex-end; align-items: center; gap: 16px; margin: 4px 0 14px; }
.generate-bar .msg { margin: 0; flex: 1; text-align: right; }
.meal-actions { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.meal-msg { margin: 0 0 6px; }
.copied { font-size: 12px; color: var(--accent); font-weight: 600; margin-top: 2px; }
@media (max-width: 760px) {
  .days-layout { grid-template-columns: 1fr; }
  .prefs-grid { grid-template-columns: 1fr; gap: 10px; }
  .generate-bar { flex-direction: column-reverse; align-items: stretch; }
  .generate-bar .msg { text-align: left; }
}

/* Theme toggle */
.theme-toggle { display: inline-flex; align-items: center; gap: 6px; font: inherit; font-size: 12.5px; color: var(--ink); background: var(--card); border: 1px solid var(--line); border-radius: 999px; padding: 5px 11px; cursor: pointer; }
.theme-toggle:hover { border-color: var(--line-strong); }
.theme-toggle svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 2; }
/* Free veg line in savoury meals */
.veg-row .item-name { font-weight: 600; }
.veg-row .amt { color: var(--muted); }
@media (max-width: 760px) {
  .day-side { max-width: none; margin-bottom: 14px; }
}

/* Breakfast / Dinner toggle: both sides are choices, so the track stays neutral */
.switch.two-sided .track, .switch.two-sided.on .track { background: var(--accent); }
.switch.two-sided .side { color: var(--muted); }
.switch.two-sided .side.active { color: var(--ink); font-weight: 600; }

/* Logo: maroon version in light mode, white version in dark mode */
.logo-dark { display: none !important; }
:root[data-theme="dark"] .logo-light { display: none !important; }
:root[data-theme="dark"] .logo-dark { display: block !important; }
.auth-logo { display: grid; justify-items: center; gap: 6px; margin-bottom: 22px; }
.auth-logo .logo { height: 120px; width: auto; display: block; }
.auth-sub { font-size: 12px; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); }
@media (max-width: 760px) {
  .topbar-left { display: none; }
  .topbar { grid-template-columns: auto 1fr; }
  .topbar-logo .logo { height: 48px; }
}
