:root {
  --bg: #f7f6f2;
  --card: #ffffff;
  --text: #1f2421;
  --muted: #6b716d;
  --line: #e3e1da;
  --accent: #2f7d4f;
  --accent-soft: #e2f1e7;
  --warn: #9a5b13;
  --warn-soft: #fbefdc;
  --radius: 12px;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #141715;
    --card: #1d211f;
    --text: #e8ebe9;
    --muted: #9aa29d;
    --line: #2d332f;
    --accent: #6cc58f;
    --accent-soft: #1f3a2a;
    --warn: #e6b169;
    --warn-soft: #3a2e1d;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0 auto;
  max-width: 760px;
  padding: 0 16px 32px;
  background: var(--bg);
  color: var(--text);
  line-height: 1.4;
}

a { color: var(--accent); }

.flash {
  margin: 12px 0 0;
  padding: 10px 14px;
  border-radius: var(--radius);
  background: var(--accent-soft);
}

/* Header: title, day navigation, VEG switch */
.top {
  position: sticky;
  top: 0;
  z-index: 1;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 16px;
  padding: 14px 0 12px;
  background: var(--bg);
}

.top h1 { margin: 0; font-size: 1.3rem; }
.top h1 a { color: var(--text); text-decoration: none; transition: color 0.15s; }
.top h1.veg a { color: var(--accent); }

.day-nav { display: flex; align-items: center; gap: 6px; flex: 1; }
.day { font-weight: 600; white-space: nowrap; }
.step {
  display: inline-grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--card);
  border: 1px solid var(--line);
  text-decoration: none;
  font-size: 1.2rem;
}
.wd-short { display: none; }

/* Collapse-all button, rightmost in the header */
.collapse-all {
  display: inline-grid;
  place-items: center;
  width: 32px;
  height: 32px;
  padding: 0;
  border-radius: 50%;
  background: var(--card);
  border: 1px solid var(--line);
  color: var(--muted);
  cursor: pointer;
}
.collapse-all:hover { color: var(--accent); }

/* Phones: "Obedy", the day, the VEG switch and collapse-all on one row */
@media (max-width: 420px) {
  .top { gap: 8px; }
  .day-nav { gap: 4px; }
  .step { width: 28px; height: 28px; font-size: 1.1rem; }
  .collapse-all { width: 26px; height: 26px; }
  .veg-toggle { gap: 6px; }
  .wd-long { display: none; }
  .wd-short { display: inline; }
}

.veg-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--muted);
  text-decoration: none;
}
.veg-toggle.on { color: var(--accent); }
.track {
  position: relative;
  width: 42px;
  height: 24px;
  border-radius: 12px;
  background: var(--line);
  transition: background 0.15s;
}
.veg-toggle.on .track { background: var(--accent); }
.knob {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  transition: left 0.15s;
}
.veg-toggle.on .knob { left: 21px; }

/* Restaurant cards: the restaurant's <details>, then its à la carte list */
.card {
  margin: 10px 0;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.restaurant > summary {
  padding: 12px 14px;
  cursor: pointer;
  list-style: none;
}
.restaurant > summary::-webkit-details-marker { display: none; }
.restaurant > summary::before {
  content: "▸";
  display: inline-block;
  width: 1em;
  color: var(--muted);
  transition: transform 0.15s;
}
.restaurant[open] > summary::before { transform: rotate(90deg); }

.name { font-weight: 650; font-size: 1.05rem; }

/* Favourite star (the forms it submits are empty) */
.fav-form { display: none; }
.star {
  padding: 0 4px 0 0;
  border: 0;
  background: none;
  color: var(--muted);
  font: inherit;
  font-size: 1.1rem;
  line-height: 1;
  cursor: pointer;
}
.star[aria-pressed=true] { color: #e0a100; }
.card.favorite { border-left: 3px solid #e0a100; }

.badge {
  display: inline-block;
  margin-left: 6px;
  padding: 1px 8px;
  border-radius: 10px;
  font-size: 0.8rem;
  background: var(--line);
  color: var(--muted);
}
.state-failed .badge, .badge.state-failed { background: var(--warn-soft); color: var(--warn); }

.restaurant:not(.state-ok) .name,
.veg-mode .no-veg .name { color: var(--muted); }

/* The veg preview in the summary disappears once the full menu is open */
.restaurant[open] .veg-preview { display: none; }
.veg-preview { margin-top: 8px; }

.body { padding: 0 14px 10px; }

/* À la carte: below the restaurant in the same card, opened by its own click */
.a-la-carte { padding: 0 14px 10px; }
.a-la-carte > summary { cursor: pointer; list-style: none; font-size: 0.9rem; color: var(--muted); }
.a-la-carte > summary::-webkit-details-marker { display: none; }
.a-la-carte > summary::before { content: "▸"; display: inline-block; margin-right: 0.3em; transition: transform 0.15s; }
.a-la-carte[open] > summary::before { transform: rotate(90deg); }
.a-la-carte .meals { margin-top: 4px; padding-left: 1em; }
/* VEG mode, restaurant collapsed: only the vegetarian à la carte dishes */
.a-la-carte .count-veg,
.veg-mode .restaurant:not([open]) + .a-la-carte .count-all,
.veg-mode .restaurant:not([open]) + .a-la-carte .meal:not(.veg),
.veg-mode .restaurant:not([open]) + .a-la-carte.no-veg-items { display: none; }
.veg-mode .restaurant:not([open]) + .a-la-carte .count-veg { display: inline; }
/* Without VEG a collapsed restaurant hides its à la carte too */
.menus:not(.veg-mode) .restaurant:not([open]) + .a-la-carte { display: none; }

.meals { margin: 0; padding: 0; list-style: none; }
.meal {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 7px 0;
  border-top: 1px solid var(--line);
}
.veg-preview .meal:first-child { border-top: 0; }
.meal-name { flex: 1; }
.price { white-space: nowrap; color: var(--muted); font-variant-numeric: tabular-nums; }

.kind {
  margin-right: 4px;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
}

.leaf {
  display: inline-grid;
  place-items: center;
  width: 18px;
  height: 18px;
  margin-left: 4px;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 0.7rem;
  font-weight: 800;
  vertical-align: 1px;
}

.message { margin: 4px 0; color: var(--muted); font-size: 0.9rem; }
.source { margin: 6px 0 0; font-size: 0.85rem; }
.empty { color: var(--muted); }

.bottom { margin-top: 24px; text-align: center; font-size: 0.9rem; }

/* Restaurant admin */
.add-form {
  display: grid;
  gap: 6px;
  padding: 14px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.add-form label { font-size: 0.85rem; color: var(--muted); }
.add-form input[type=url], .add-form input[type=text] {
  width: 100%;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
  font: inherit;
}
.add-form input[type=submit], .actions button, .actions .button {
  justify-self: start;
  padding: 8px 14px;
  border: 0;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  font: inherit;
  cursor: pointer;
}
.actions button, .actions .button { padding: 5px 10px; font-size: 0.85rem; background: var(--line); color: var(--text); }
.actions .button { display: inline-block; text-decoration: none; line-height: normal; }

.restaurant-list { margin: 16px 0 0; padding: 0; list-style: none; }
.restaurant-list li {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 8px;
  padding: 12px 0;
  border-top: 1px solid var(--line);
}
.restaurant-list .url { font-size: 0.8rem; word-break: break-all; }
.actions { display: flex; gap: 6px; align-items: start; }
.actions form { margin: 0; }
