:root {
  --bg: #faf6f0;
  --surface: #ffffff;
  --surface-2: #f4ede3;
  --text: #2b2118;
  --muted: #7d6d5e;
  --border: #eadfd1;
  --accent: #e8590c;
  --accent-soft: #fde7d9;
  --accent-ink: #ffffff;
  --ok: #2f9e44;
  --ok-soft: #e3f4e6;
  --danger: #c92a2a;
  --shadow: 0 1px 2px rgba(60, 40, 20, .06), 0 4px 14px rgba(60, 40, 20, .06);
  --radius: 14px;
  --tabs-h: 64px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #181412;
    --surface: #231e1a;
    --surface-2: #2e2722;
    --text: #f4ece3;
    --muted: #a8988a;
    --border: #3a312a;
    --accent: #ff8c42;
    --accent-soft: #3d2618;
    --accent-ink: #1b1209;
    --ok: #51cf66;
    --ok-soft: #1d3322;
    --danger: #ff6b6b;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 4px 14px rgba(0, 0, 0, .25);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 17px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  padding-bottom: calc(var(--tabs-h) + env(safe-area-inset-bottom) + 16px);
  -webkit-tap-highlight-color: transparent;
}
body.bare { padding-bottom: 0; }
a { color: var(--accent); text-decoration: none; }
h1, h2, h3 { line-height: 1.2; margin: 0 0 .5em; }
h2 { font-size: 1.15rem; }
img { max-width: 100%; display: block; }

.top {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 8px;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}
.top h1 { font-size: 1.35rem; margin: 0; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
main { max-width: 720px; margin: 0 auto; padding: 4px 16px 16px; }

.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  display: flex; justify-content: space-around;
  height: calc(var(--tabs-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  background: var(--surface);
  border-top: 1px solid var(--border);
}
.tabs a {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  color: var(--muted); font-size: .72rem; font-weight: 600;
}
.tabs a span { font-size: 1.45rem; line-height: 1; filter: grayscale(.6); opacity: .75; }
.tabs a.active { color: var(--accent); }
.tabs a.active span { filter: none; opacity: 1; }

.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 44px; height: 44px; border-radius: 12px; border: 0;
  background: transparent; color: var(--text); font-size: 1.3rem; cursor: pointer;
}
.icon-btn:active { background: var(--surface-2); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 46px; padding: 0 18px; border-radius: 12px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
  font: inherit; font-weight: 600; cursor: pointer; text-align: center;
}
.btn:active { transform: scale(.98); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.ok { background: var(--ok); border-color: var(--ok); color: #fff; }
.btn.danger { color: var(--danger); }
.btn.small { min-height: 36px; padding: 0 12px; font-size: .9rem; border-radius: 10px; }
.btn.block { width: 100%; }
.btn[disabled] { opacity: .5; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.row.end { justify-content: flex-end; }
.grow { flex: 1; }
.muted { color: var(--muted); }
.small { font-size: .88rem; }
.center { text-align: center; }
.hidden { display: none !important; }

input[type=text], input[type=password], input[type=url], input[type=number], input[type=search], input[type=date], select, textarea {
  width: 100%; min-height: 48px; padding: 10px 14px;
  border: 1px solid var(--border); border-radius: 12px;
  background: var(--surface); color: var(--text); font: inherit;
}
textarea { min-height: 120px; resize: vertical; line-height: 1.5; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: transparent; }
label { display: block; font-weight: 600; margin: 14px 0 6px; }
label.inline { display: flex; align-items: center; gap: 10px; font-weight: 500; margin: 10px 0; }
input[type=checkbox] { width: 22px; height: 22px; accent-color: var(--accent); }
.hint { color: var(--muted); font-size: .86rem; margin-top: 4px; }

.card {
  background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 16px; margin-bottom: 14px;
}
.flash {
  max-width: 688px; margin: 6px auto 8px; padding: 12px 16px; border-radius: 12px;
  background: var(--ok-soft); color: var(--text); font-weight: 500;
}
.error { background: #ffe3e3; color: #8a1c1c; padding: 12px 16px; border-radius: 12px; margin: 8px 0 12px; }
@media (prefers-color-scheme: dark) { .error { background: #3b1d1d; color: #ffc9c9; } }

.chips { display: flex; gap: 8px; overflow-x: auto; padding: 2px 0 10px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: none; display: inline-flex; align-items: center; gap: 4px;
  min-height: 36px; padding: 0 14px; border-radius: 999px;
  background: var(--surface-2); color: var(--text); border: 1px solid transparent;
  font: inherit; font-size: .92rem; font-weight: 500; cursor: pointer; white-space: nowrap;
}
.chip.active { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
.tag { display: inline-block; font-size: .78rem; padding: 2px 9px; border-radius: 999px; background: var(--surface-2); color: var(--muted); margin: 0 4px 4px 0; }

/* --- shopping list --- */
.add-bar { display: flex; gap: 8px; margin-bottom: 10px; }
.add-bar input { flex: 1; }
.add-bar .btn { flex: none; width: 52px; padding: 0; font-size: 1.5rem; }
.status-bar { display: flex; align-items: center; gap: 8px; min-height: 28px; font-size: .82rem; color: var(--muted); margin: 0 2px 6px; }
.status-bar .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ok); flex: none; }
.status-bar .dot.off { background: var(--danger); }
.wake { margin-left: auto; border: 0; background: none; color: var(--muted); font: inherit; cursor: pointer; padding: 4px 0; }
.wake.on { color: var(--accent); font-weight: 600; }

.group { margin-bottom: 14px; }
.group h3 { font-size: .82rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin: 0 4px 6px; font-weight: 700; }
.items { list-style: none; margin: 0; padding: 0; background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.item { display: flex; align-items: center; min-height: 60px; border-top: 1px solid var(--border); user-select: none; -webkit-user-select: none; }
.item:first-child { border-top: 0; }
.item .tap { flex: 1; display: flex; align-items: center; gap: 14px; padding: 10px 6px 10px 16px; min-width: 0; cursor: pointer; }
.box {
  flex: none; width: 28px; height: 28px; border-radius: 9px; border: 2px solid var(--border);
  display: flex; align-items: center; justify-content: center; color: transparent; font-weight: 800; transition: all .12s;
}
.item .text { min-width: 0; }
.item .name { font-size: 1.08rem; font-weight: 600; overflow-wrap: anywhere; }
.item .amount { color: var(--accent); font-weight: 700; margin-left: 6px; white-space: nowrap; }
.item .meta { font-size: .8rem; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item .more { flex: none; width: 48px; height: 60px; border: 0; background: none; color: var(--muted); font-size: 1.25rem; cursor: pointer; }
.item.checked .box { background: var(--ok); border-color: var(--ok); color: #fff; }
.item.checked .name { text-decoration: line-through; color: var(--muted); font-weight: 500; }
.item.checked .amount { color: var(--muted); }
.item.pending .box { opacity: .6; }
.done-head { display: flex; align-items: center; gap: 8px; margin: 22px 4px 8px; }
.done-head h3 { margin: 0; flex: 1; }
.empty { text-align: center; color: var(--muted); padding: 40px 16px; }
.empty .big { font-size: 3rem; margin-bottom: 6px; }

dialog {
  border: 0; border-radius: 20px; padding: 20px; width: min(92vw, 520px); max-height: 86vh;
  background: var(--surface); color: var(--text); box-shadow: 0 10px 40px rgba(0, 0, 0, .3);
}
dialog::backdrop { background: rgba(20, 12, 6, .45); }
dialog h2 { margin-bottom: 4px; }
dialog .actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 18px; flex-wrap: wrap; }
.checklist { list-style: none; padding: 0; margin: 10px 0 0; max-height: 50vh; overflow-y: auto; }
.checklist li { border-top: 1px solid var(--border); }
.checklist label { display: flex; gap: 12px; align-items: center; margin: 0; padding: 10px 2px; font-weight: 500; }
.checklist .amt { color: var(--accent); font-weight: 700; white-space: nowrap; margin-left: auto; padding-left: 8px; }

.toast {
  position: fixed; left: 50%; bottom: calc(var(--tabs-h) + env(safe-area-inset-bottom) + 14px);
  transform: translateX(-50%) translateY(20px); opacity: 0; transition: all .2s; z-index: 50;
  background: var(--text); color: var(--bg); padding: 12px 18px; border-radius: 12px; font-weight: 600;
  max-width: calc(100vw - 32px); pointer-events: none;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* --- recipes --- */
.search-row { display: flex; gap: 8px; margin-bottom: 10px; }
.search-row input { flex: 1; }
.search-row select { width: auto; flex: 0 1 auto; max-width: 40%; }
.recipe-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 12px; }
.recipe-card { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; color: var(--text); display: flex; flex-direction: column; }
.recipe-card .ph { aspect-ratio: 4/3; background: var(--surface-2); display: flex; align-items: center; justify-content: center; font-size: 2.6rem; overflow: hidden; }
.recipe-card .ph img { width: 100%; height: 100%; object-fit: cover; }
.recipe-card .body { padding: 10px 12px 12px; }
.recipe-card .title { font-weight: 700; line-height: 1.25; margin-bottom: 4px; }
.recipe-card .meta { font-size: .8rem; color: var(--muted); }
.fab {
  position: fixed; right: 16px; bottom: calc(var(--tabs-h) + env(safe-area-inset-bottom) + 16px); z-index: 15;
  height: 56px; padding: 0 22px; border-radius: 28px; background: var(--accent); color: var(--accent-ink);
  display: flex; align-items: center; gap: 6px; font-weight: 700; box-shadow: 0 6px 20px rgba(232, 89, 12, .35);
}
.hero { margin: 0 -16px 14px; aspect-ratio: 16/9; overflow: hidden; background: var(--surface-2); }
.hero img { width: 100%; height: 100%; object-fit: cover; }
@media (min-width: 752px) { .hero { margin: 0 0 14px; border-radius: var(--radius); } }
.facts { display: flex; gap: 16px; flex-wrap: wrap; color: var(--muted); font-size: .92rem; margin-bottom: 12px; }
.stepper { display: inline-flex; align-items: center; gap: 4px; background: var(--surface-2); border-radius: 12px; padding: 3px; }
.stepper button { width: 40px; height: 40px; border: 0; border-radius: 10px; background: var(--surface); color: var(--text); font-size: 1.3rem; cursor: pointer; }
.stepper output { min-width: 64px; text-align: center; font-weight: 700; }
.ing-list { list-style: none; padding: 0; margin: 8px 0 0; }
.ing-list li { display: flex; gap: 10px; padding: 9px 0; border-top: 1px solid var(--border); }
.ing-list li:first-child { border-top: 0; }
.ing-list .q { flex: none; min-width: 84px; font-weight: 700; color: var(--accent); }
.ing-list .h { font-weight: 700; padding-top: 14px; color: var(--muted); font-size: .85rem; text-transform: uppercase; letter-spacing: .04em; }
.ing-list .note { color: var(--muted); }
.steps { padding-left: 0; margin: 8px 0 0; list-style: none; counter-reset: step; }
.steps li { position: relative; padding: 10px 0 10px 44px; border-top: 1px solid var(--border); }
.steps li:first-child { border-top: 0; }
.steps li.step::before {
  counter-increment: step; content: counter(step);
  position: absolute; left: 0; top: 10px; width: 30px; height: 30px; border-radius: 50%;
  background: var(--accent-soft); color: var(--accent); font-weight: 800; display: flex; align-items: center; justify-content: center;
}
.steps li.sub { padding-left: 0; font-weight: 700; color: var(--muted); }
.actions-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 14px 0; }
.mode-tabs { display: flex; gap: 6px; background: var(--surface-2); padding: 4px; border-radius: 14px; margin-bottom: 14px; }
.mode-tabs a { flex: 1; text-align: center; padding: 10px 6px; border-radius: 10px; color: var(--muted); font-weight: 600; font-size: .92rem; }
.mode-tabs a.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.thumb { width: 96px; height: 72px; object-fit: cover; border-radius: 10px; }

/* --- week --- */
.week-nav { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; }
.week-nav .label { flex: 1; text-align: center; font-weight: 700; }
.day { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); padding: 12px 14px; margin-bottom: 10px; }
.day.today { outline: 2px solid var(--accent); }
.day-head { display: flex; align-items: center; gap: 8px; }
.day-head .d { font-weight: 700; flex: 1; }
.day-head .d small { color: var(--muted); font-weight: 500; margin-left: 6px; }
.entry { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-top: 1px solid var(--border); }
.entry:first-of-type { border-top: 0; }
.entry .t { flex: 1; min-width: 0; font-weight: 600; }
.entry .t a { color: var(--text); }
.entry .badge { font-size: .74rem; color: var(--ok); font-weight: 700; }
.entry form { margin: 0; }

/* --- what to cook --- */
.pick { text-align: center; }
.pick .ph { aspect-ratio: 4/3; border-radius: var(--radius); overflow: hidden; background: var(--surface-2); display: flex; align-items: center; justify-content: center; font-size: 4rem; margin-bottom: 12px; }
.pick .ph img { width: 100%; height: 100%; object-fit: cover; }
.pick h2 { font-size: 1.5rem; }
.idea { border-top: 1px solid var(--border); padding-top: 12px; margin-top: 12px; }
.idea:first-child { border-top: 0; margin-top: 0; padding-top: 0; }

/* --- login --- */
.login { max-width: 420px; margin: 0 auto; padding: calc(40px + env(safe-area-inset-top)) 20px 40px; }
.login .logo { font-size: 3.4rem; text-align: center; }
.login h1 { text-align: center; margin-bottom: 4px; }
.members { display: flex; flex-wrap: wrap; gap: 8px; }
.members input { display: none; }
.members label { margin: 0; }
.members span { display: inline-flex; min-height: 44px; align-items: center; padding: 0 16px; border-radius: 999px; background: var(--surface-2); font-weight: 600; cursor: pointer; border: 2px solid transparent; }
.members input:checked + span { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }

/* --- rohlik --- */
.rl-item { display: flex; gap: 12px; align-items: center; padding: 12px 0; border-top: 1px solid var(--border); }
.rl-item:first-child { border-top: 0; }
.rl-item img, .rl-item .noimg { width: 56px; height: 56px; object-fit: contain; border-radius: 10px; background: #fff; flex: none; }
.rl-item .noimg { background: var(--surface-2); display: flex; align-items: center; justify-content: center; font-size: 1.5rem; }
.rl-item .info { flex: 1; min-width: 0; }
.rl-item .what { font-size: .8rem; color: var(--muted); }
.rl-item .prod { font-weight: 600; }
.rl-results { list-style: none; padding: 0; margin: 10px 0 0; max-height: 55vh; overflow-y: auto; }
.rl-results li { display: flex; gap: 12px; align-items: center; padding: 10px 4px; border-top: 1px solid var(--border); cursor: pointer; }
.rl-results li:active { background: var(--surface-2); }
.rl-results img { width: 52px; height: 52px; object-fit: contain; background: #fff; border-radius: 8px; flex: none; }
.qty { display: inline-flex; align-items: center; gap: 2px; }
.qty button { width: 34px; height: 34px; border-radius: 9px; border: 1px solid var(--border); background: var(--surface); color: var(--text); font-size: 1.1rem; }
.qty output { min-width: 26px; text-align: center; font-weight: 700; }
pre { white-space: pre-wrap; word-break: break-word; background: var(--surface-2); padding: 10px; border-radius: 10px; font-size: .8rem; }
