:root {
  --bg: #faf7f2;
  --surface: #ffffff;
  --text: #1f1a17;
  --muted: #6b625b;
  --border: #e7dfd6;
  --accent: #b5532f;
  --accent-text: #ffffff;
  --accent-soft: #f6e6dc;
  --done: #a39a92;
  --warn-bg: #fdf3d8;
  --warn-text: #6b4e00;
  --star: #d9902a;
  --shadow: 0 1px 2px rgb(60 40 20 / 0.06), 0 2px 8px rgb(60 40 20 / 0.05);
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --radius: 14px;
  --gutter: 16px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #171412;
    --surface: #221e1b;
    --text: #f1ece6;
    --muted: #a39a92;
    --border: #36302b;
    --accent: #e58a63;
    --accent-text: #1a110c;
    --accent-soft: #3b2a21;
    --done: #6e665f;
    --warn-bg: #3a3017;
    --warn-text: #f0d68c;
    --star: #f0b14d;
    --shadow: none;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #171412; --surface: #221e1b; --text: #f1ece6; --muted: #a39a92; --border: #36302b;
  --accent: #e58a63; --accent-text: #1a110c; --accent-soft: #3b2a21; --done: #6e665f;
  --warn-bg: #3a3017; --warn-text: #f0d68c; --star: #f0b14d; --shadow: none; color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 var(--sans);
  -webkit-tap-highlight-color: transparent;
}
a { color: var(--accent); }
button { font: inherit; color: inherit; }
h1, h2, h3 { font-family: var(--serif); font-weight: 600; line-height: 1.2; margin: 0; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.muted { color: var(--muted); }
.loading, .notfound { padding: 40vh var(--gutter) 0; text-align: center; color: var(--muted); }
.notfound .btn { margin-top: 12px; }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- Seznam ---------- */
.list-header {
  position: sticky; top: 0; z-index: 10;
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
  padding-top: env(safe-area-inset-top);
}
.list-header__inner { max-width: 960px; margin: 0 auto; padding: 10px var(--gutter) 10px; }
/* Název a vyhledávání v jednom řádku – hlavička zabere co nejméně místa. */
.list-header__top { display: flex; align-items: center; gap: 14px; }
.brand { font-size: 1.4rem; flex: none; }
@media (max-width: 399px) { .brand { font-size: 1.2rem; } }

.search {
  flex: 1; min-width: 0;
  display: flex; align-items: center; gap: 8px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
  padding: 0 12px; box-shadow: var(--shadow);
}
.search:focus-within { border-color: var(--accent); }
.search svg { width: 20px; height: 20px; flex: none; fill: none; stroke: var(--muted); stroke-width: 2; stroke-linecap: round; }
.search input {
  flex: 1; min-width: 0; border: 0; background: none; outline: none;
  font: inherit; font-size: 17px; color: var(--text); padding: 9px 0;
}
.search input::placeholder { color: var(--muted); }

/* Jeden řádek filtrů: osobní přepínače | výběr druhu jídla a suroviny. */
.filters {
  display: flex; align-items: center; gap: 8px; margin-top: 10px;
  overflow-x: auto; scrollbar-width: none;
}
.filters::-webkit-scrollbar { display: none; }
.filters__sep { flex: none; width: 1px; height: 22px; background: var(--border); }
.chip {
  flex: none; border: 1px solid var(--border); background: var(--surface);
  border-radius: 999px; padding: 6px 13px; font-size: 14px; cursor: pointer; white-space: nowrap;
}
.chip[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.chip--fav, .chip--grill { display: inline-flex; gap: 6px; }
.chip--fav[aria-pressed="false"], .chip--grill[aria-pressed="false"] { color: var(--star); }
/* Na úzkém displeji jen ikony, aby se řádek vešel bez posouvání. */
@media (max-width: 559px) {
  .chip__label { display: none; }
  .chip--fav, .chip--grill { padding-inline: 11px; }
}

/* Výběr se smí zúžit – dlouhý název kategorie se zkrátí, aby se řádek vešel. */
.pick { display: inline-flex; flex: 0 1 auto; min-width: 0; }
.pick__open { display: inline-flex; align-items: center; gap: 4px; flex: 0 1 auto; min-width: 0; }
.pick__text { min-width: 0; max-width: 9.5em; overflow: hidden; text-overflow: ellipsis; }
.pick--active .pick__caret { display: none; }
@media (max-width: 559px) { .pick__text { max-width: 6em; } }
.pick__caret { font-size: 11px; opacity: .7; }
.pick__open[aria-expanded="true"] { border-color: var(--accent); }
.pick--active .pick__open { background: var(--accent); border-color: var(--accent); color: var(--accent-text); border-radius: 999px 0 0 999px; padding-right: 9px; }
.pick__clear {
  background: var(--accent); border-color: var(--accent); color: var(--accent-text);
  border-radius: 0 999px 999px 0; border-left: 1px solid color-mix(in srgb, var(--accent-text) 30%, transparent);
  padding: 6px 11px 6px 9px; font-size: 12px;
}

.menu {
  margin-top: 10px; padding: 12px; max-height: min(50vh, 360px); overflow-y: auto;
  background: var(--surface); border: 1px solid var(--border); border-radius: 14px;
  box-shadow: 0 8px 24px rgb(0 0 0 / 0.12);
}
.menu__title { margin: 0 0 8px; font-size: 12px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.menu__items { display: flex; flex-wrap: wrap; gap: 8px; }

.results { max-width: 960px; margin: 0 auto; padding: 8px var(--gutter) calc(32px + env(safe-area-inset-bottom)); }
.count { color: var(--muted); font-size: 14px; margin: 6px 2px 10px; }
.cards { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
@media (min-width: 720px) { .cards { grid-template-columns: 1fr 1fr; } }

.card {
  display: flex; flex-direction: column; gap: 2px; height: 100%;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 12px 14px; color: inherit; text-decoration: none; box-shadow: var(--shadow);
}
.card:hover { border-color: color-mix(in srgb, var(--accent) 45%, var(--border)); }
.card:active { transform: scale(0.99); }
.card__title { font-family: var(--serif); font-size: 1.12rem; font-weight: 600; }
.card__meta { font-size: 13px; color: var(--muted); display: flex; flex-wrap: wrap; align-items: center; gap: 0 6px; }
.card__hits { font-size: 13px; color: var(--accent); }
.star { color: var(--star); font-size: 0.9em; }
.dot { width: 7px; height: 7px; border-radius: 50%; background: var(--star); display: inline-block; }
.empty { text-align: center; color: var(--muted); padding: 40px 0; }

.btn {
  display: inline-block; border: 1px solid var(--accent); background: var(--accent); color: var(--accent-text);
  border-radius: 10px; padding: 8px 14px; cursor: pointer; text-decoration: none; font-size: 15px;
}
.btn--ghost { background: none; color: var(--accent); border-color: var(--border); }

/* ---------- Detail receptu ---------- */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 8px;
  padding: calc(8px + env(safe-area-inset-top)) 8px 8px;
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid transparent; transition: border-color .2s;
}
.topbar--titled { border-bottom-color: var(--border); }
.topbar__title {
  flex: 1; min-width: 0; font-family: var(--serif); font-weight: 600; font-size: 1.05rem;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; opacity: 0; transition: opacity .2s;
}
.topbar--titled .topbar__title { opacity: 1; }

.icon-btn {
  width: 40px; height: 40px; flex: none; display: grid; place-items: center;
  border: 0; border-radius: 50%; background: none; color: var(--text); cursor: pointer; font-size: 20px;
}
.icon-btn:hover { background: var(--accent-soft); }
.icon-btn svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.icon-btn--small { width: 32px; height: 32px; border: 1px solid var(--border); background: var(--surface); font-size: 18px; }
.icon-btn:disabled { opacity: .4; cursor: default; }
.fav[aria-pressed="true"] svg { fill: var(--star); stroke: var(--star); }

.recipe { max-width: 960px; margin: 0 auto; padding: 4px var(--gutter) calc(40px + env(safe-area-inset-bottom)); }
.recipe__head { margin-bottom: 16px; }
.eyebrow { margin: 0 0 4px; font-size: 13px; letter-spacing: .06em; text-transform: uppercase; color: var(--accent); font-weight: 600; }
.recipe h1 { font-size: clamp(1.8rem, 6vw, 2.5rem); }
.tags { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0 0; }
.tag { font-size: 13px; padding: 2px 9px; border-radius: 999px; background: var(--accent-soft); }
.review { margin: 12px 0 0; padding: 10px 12px; border-radius: 10px; background: var(--warn-bg); color: var(--warn-text); font-size: 14px; }

.tabs { display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none; border-bottom: 1px solid var(--border); margin-bottom: 16px; }
.tabs button {
  flex: none; border: 0; background: none; padding: 10px 12px; cursor: pointer; color: var(--muted);
  border-bottom: 2px solid transparent; margin-bottom: -1px; font-weight: 500;
}
.tabs button[aria-selected="true"] { color: var(--text); border-bottom-color: var(--accent); }

.recipe__body { display: grid; gap: 16px; }
@media (min-width: 820px) {
  .recipe__body { grid-template-columns: minmax(280px, 2fr) 3fr; align-items: start; }
  .ingredients { position: sticky; top: 72px; max-height: calc(100vh - 88px); overflow: auto; }
}

.block { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); }
.notes, .recipe > .block { margin-top: 16px; }
.block h2 { font-size: 1.3rem; }
.block h3 { font-family: var(--sans); font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 16px 0 4px; }
.block__head { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; margin-bottom: 6px; }

.scale { display: flex; align-items: center; gap: 8px; font-size: 15px; }
.seg { gap: 0; border: 1px solid var(--border); border-radius: 9px; overflow: hidden; }
.seg button { border: 0; background: var(--surface); padding: 5px 10px; cursor: pointer; font-size: 14px; }
.seg button + button { border-left: 1px solid var(--border); }
.seg button[aria-pressed="true"] { background: var(--accent); color: var(--accent-text); }

.ing-list { list-style: none; margin: 0; padding: 0; }
.ing-list li { border-bottom: 1px solid var(--border); }
.ing-list li:last-child { border-bottom: 0; }
.ing-list label { display: flex; gap: 12px; align-items: flex-start; padding: 9px 0; cursor: pointer; }
.ing-list input { width: 20px; height: 20px; margin: 2px 0 0; flex: none; accent-color: var(--accent); }
.ing-list b { font-weight: 650; }
.ing-list li.done span { color: var(--done); text-decoration: line-through; }

.step-list { list-style: none; counter-reset: step; margin: 8px 0 0; padding: 0; display: grid; gap: 4px; }
.step-list li {
  counter-increment: step; position: relative; padding: 10px 10px 10px 46px; border-radius: 10px;
  cursor: pointer; user-select: none; -webkit-user-select: none;
}
.step-list li:hover { background: var(--accent-soft); }
.step-list li::before {
  content: counter(step); position: absolute; left: 8px; top: 8px;
  width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center;
  background: var(--accent-soft); color: var(--accent); font-weight: 700; font-size: 14px;
}
.step-list li.done { color: var(--done); }
.step-list li.done::before { content: "✓"; background: var(--border); color: var(--done); }

.notes ul, .sources { margin: 8px 0 0; padding-left: 20px; }
.notes li, .sources li { margin: 4px 0; }
.empty-variant { color: var(--muted); text-align: center; padding: 24px 0; }

.recipe__tools { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; margin-top: 20px; }
.update-banner {
  position: fixed; z-index: 20; left: 50%; transform: translateX(-50%);
  bottom: calc(16px + env(safe-area-inset-bottom)); width: max-content; max-width: calc(100% - 32px);
  display: flex; align-items: center; gap: 12px; padding: 10px 10px 10px 16px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 14px;
  box-shadow: 0 4px 20px rgb(0 0 0 / 0.18); font-size: 15px;
}
.switch { display: flex; align-items: center; gap: 8px; font-size: 15px; cursor: pointer; }
.switch input { width: 18px; height: 18px; accent-color: var(--accent); }
