:root {
  --bg: #F6F3EE;
  --card: #FFFFFF;
  --text: #1D1B19;
  --muted: #7A736B;
  --line: #E7E1D8;
  --chip: #EEE8DF;
  --accent: #D9542F;
  --accent-ink: #FFFFFF;
  --accent-soft: #FBE6DE;
  --good: #2F8F5B;
  --radius: 18px;
  --tabbar-h: 58px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #141312; --card: #1F1D1B; --text: #F2EFEA; --muted: #A39B91;
    --line: #2E2B28; --chip: #2A2724; --accent: #F06A43; --accent-soft: #3A221A;
  }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body {
  font: 17px/1.4 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}
main {
  max-width: 640px; margin: 0 auto;
  padding: calc(var(--safe-t) + 16px) 16px calc(var(--tabbar-h) + var(--safe-b) + 28px);
}
a { color: inherit; text-decoration: none; }
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }

h1 { font-size: 34px; line-height: 1.1; letter-spacing: -0.02em; margin: 8px 0 4px; font-weight: 750; }
h2 { font-size: 20px; margin: 26px 0 10px; letter-spacing: -0.01em; }
.sub { color: var(--muted); margin: 0 0 18px; font-size: 15px; }

/* Chips / segmented filters */
.chips { display: flex; gap: 8px; overflow-x: auto; padding: 2px 0 4px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: none; border: 0; background: var(--chip); padding: 8px 14px; border-radius: 999px;
  font-size: 15px; font-weight: 550;
}
.chip[aria-pressed="true"] { background: var(--text); color: var(--bg); }
.label { font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 18px 0 8px; font-weight: 600; }

/* Suggestion card */
.suggest {
  margin-top: 20px; background: var(--card); border-radius: 24px; padding: 22px;
  box-shadow: 0 1px 0 var(--line), 0 10px 30px -18px rgba(0,0,0,.35);
}
.suggest .kicker { color: var(--accent); font-weight: 650; font-size: 14px; letter-spacing: .02em; }
.suggest h3 { font-size: 28px; line-height: 1.15; margin: 6px 0 10px; letter-spacing: -0.02em; }
.meta { display: flex; flex-wrap: wrap; gap: 6px 12px; color: var(--muted); font-size: 15px; }
.meta span { white-space: nowrap; }
.preview { margin: 14px 0 0; padding: 0; list-style: none; color: var(--muted); font-size: 15px; }
.preview li { padding: 2px 0; }
.actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 20px; }
.btn {
  border: 0; border-radius: 14px; padding: 14px 16px; font-weight: 650; font-size: 16px;
  background: var(--chip); display: inline-flex; align-items: center; justify-content: center; gap: 8px;
}
.btn.primary { background: var(--accent); color: var(--accent-ink); }
.btn.ghost { background: transparent; color: var(--accent); padding-left: 0; padding-right: 0; }
.btn.danger { background: transparent; color: #C93A2A; width: 100%; margin-top: 8px; }
.btn.block { width: 100%; }
.btn { white-space: nowrap; }
.btn:disabled { opacity: .45; }
.btn:active { transform: scale(.98); }
.empty { text-align: center; color: var(--muted); padding: 40px 10px; }
.empty .btn { margin-top: 14px; }

/* Search + list */
.search {
  width: 100%; border: 0; background: var(--chip); border-radius: 12px; padding: 11px 14px;
  font-size: 17px; margin: 6px 0 12px; outline: none;
}
.list { margin-top: 14px; background: var(--card); border-radius: var(--radius); overflow: hidden; }
.row { display: flex; align-items: center; gap: 12px; padding: 13px 16px; border-bottom: 1px solid var(--line); }
.row:last-child { border-bottom: 0; }
.row .grow { flex: 1; min-width: 0; }
.row .name { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row .small { color: var(--muted); font-size: 14px; }
.dot { width: 10px; height: 10px; border-radius: 50%; flex: none; }
.dot.breakfast { background: #E5A73B; } .dot.lunch { background: #5BA36B; }
.dot.dinner { background: #D9542F; } .dot.snack { background: #8A7BD1; }
.star { border: 0; background: none; padding: 4px; color: var(--line); font-size: 22px; line-height: 1; }
.star.on { color: #E5A73B; }
.footer-links { text-align: center; margin-top: 22px; font-size: 14px; color: var(--muted); }
.footer-links a, .footer-links button { color: var(--accent); background: none; border: 0; padding: 0; font-size: 14px; }

/* Recipe detail */
.topbar { display: flex; align-items: center; justify-content: space-between; margin: -4px 0 4px; }
.topbar .right { display: flex; gap: 6px; align-items: center; }
.pill { display: inline-block; background: var(--chip); border-radius: 999px; padding: 3px 10px; font-size: 13px; color: var(--muted); }
.pills { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.card { background: var(--card); border-radius: var(--radius); padding: 6px 16px; }
.check { display: flex; gap: 12px; align-items: flex-start; padding: 11px 0; border-bottom: 1px solid var(--line); }
.check:last-child { border-bottom: 0; }
.check input { appearance: none; width: 22px; height: 22px; border-radius: 50%; border: 2px solid var(--line); flex: none; margin: 1px 0 0; }
.check input:checked { background: var(--good); border-color: var(--good); box-shadow: inset 0 0 0 3px var(--card); }
.check input:checked + span { color: var(--muted); text-decoration: line-through; }
.steps { counter-reset: step; }
.step { display: flex; gap: 14px; padding: 13px 0; border-bottom: 1px solid var(--line); }
.step:last-child { border-bottom: 0; }
.step::before {
  counter-increment: step; content: counter(step); flex: none; width: 28px; height: 28px; border-radius: 50%;
  background: var(--accent-soft); color: var(--accent); font-weight: 700; font-size: 14px;
  display: grid; place-items: center;
}
.step.done { color: var(--muted); }
.step.done::before { content: "✓"; background: var(--chip); color: var(--good); }
.notes { white-space: pre-wrap; padding: 12px 0; color: var(--muted); }
.toggle { display: flex; align-items: center; justify-content: space-between; padding: 12px 0; }
.switch { appearance: none; width: 50px; height: 30px; border-radius: 999px; background: var(--line); position: relative; transition: background .2s; flex: none; margin: 0; }
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 50%; background: #fff; transition: transform .2s; box-shadow: 0 1px 3px rgba(0,0,0,.25); }
.switch:checked { background: var(--good); }
.switch:checked::after { transform: translateX(20px); }

/* Form */
.field { display: block; margin-bottom: 14px; }
.field > span { display: block; font-size: 13px; color: var(--muted); font-weight: 600; margin: 0 0 6px 4px; text-transform: uppercase; letter-spacing: .05em; }
.field input, .field textarea, .field select {
  width: 100%; border: 1px solid var(--line); background: var(--card); border-radius: 12px; padding: 12px 14px;
  font-size: 17px; outline: none;
}
.field textarea { min-height: 120px; resize: vertical; line-height: 1.45; }
.field input:focus, .field textarea:focus, .field select:focus { border-color: var(--accent); }
.field small { display: block; color: var(--muted); font-size: 13px; margin: 6px 0 0 4px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.err { color: #C93A2A; font-size: 15px; margin: 0 0 12px; }

/* Tab bar */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  display: flex; justify-content: space-around;
  padding: 6px 8px calc(6px + var(--safe-b));
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: saturate(180%) blur(18px); -webkit-backdrop-filter: saturate(180%) blur(18px);
  border-top: 1px solid var(--line);
}
.tabbar a { display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: 11px; font-weight: 600; color: var(--muted); padding: 4px 18px; }
.tabbar svg { width: 26px; height: 26px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.tabbar a.active { color: var(--accent); }

/* Toast */
.toast {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(var(--tabbar-h) + var(--safe-b) + 16px); z-index: 20;
  background: var(--text); color: var(--bg); padding: 11px 16px; border-radius: 14px; font-size: 15px;
  display: flex; gap: 14px; align-items: center; box-shadow: 0 8px 24px rgba(0,0,0,.25); max-width: calc(100% - 32px);
}
.toast[hidden] { display: none; }
.toast button { background: none; border: 0; color: var(--accent); font-weight: 700; padding: 0; }

.loading { color: var(--muted); padding: 40px 0; text-align: center; }

/* Banners (install hint, backup reminder) */
.banner {
  display: flex; gap: 12px; align-items: flex-start; background: var(--accent-soft); color: var(--text);
  border-radius: 16px; padding: 14px 14px 14px 16px; margin: 4px 0 16px; font-size: 15px; line-height: 1.4;
}
.banner > div { flex: 1; }
.banner-x { border: 0; background: none; color: var(--muted); font-size: 16px; padding: 2px 4px; }
.btn.small { padding: 8px 12px; font-size: 14px; border-radius: 10px; flex: none; }

/* Header row with language switch */
.topline { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.topline h1 { margin-bottom: 4px; }
.lang { display: inline-flex; background: var(--chip); border-radius: 999px; padding: 3px; flex: none; }
.lang button { border: 0; background: none; font-size: 13px; font-weight: 700; padding: 5px 10px; border-radius: 999px; color: var(--muted); letter-spacing: .04em; }
.lang button[aria-pressed="true"] { background: var(--card); color: var(--text); box-shadow: 0 1px 3px rgba(0,0,0,.12); }

/* "New version" bar */
.update-bar {
  position: fixed; left: 12px; right: 12px; top: calc(env(safe-area-inset-top, 0px) + 10px); z-index: 30;
  max-width: 616px; margin: 0 auto; display: flex; align-items: center; justify-content: space-between; gap: 12px;
  background: var(--text); color: var(--bg); border-radius: 14px; padding: 12px 14px; font-size: 15px;
  box-shadow: 0 8px 24px rgba(0,0,0,.25);
}
.update-bar button { border: 0; background: var(--accent); color: #fff; font-weight: 700; border-radius: 10px; padding: 7px 12px; }
