:root {
  --white: #ffffff;
  --cream: #F5EFE6;
  --cream-line: #E8DCCB;
  --field-line: #D9CDBC;
  --blue: #185FA5;
  --blue-dark: #0C447C;
  --blue-soft: #E6F1FB;
  --blue-line: #B5D4F4;
  --terra: #C2603A;
  --terra-text: #A84E2B;
  --terra-dark: #8E3F21;
  --terra-soft: #FBEDE6;
  --text: #2B2A28;
  --muted: #6B6560;
  --danger: #A32D2D;
  --serif: Lora, Georgia, serif;
  --sans: Inter, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --radius: 16px;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--white);
  color: var(--text);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.5;
}
a { color: var(--blue); text-decoration: none; }
a:hover { color: var(--blue-dark); }
img { max-width: 100%; display: block; }
button, input, select, textarea { font: inherit; color: inherit; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
:focus-visible { outline: 3px solid var(--blue-line); outline-offset: 2px; }

.page {
  max-width: 760px;
  margin: 0 auto;
  padding: 0 20px calc(110px + env(safe-area-inset-bottom));
}

/* ---------- typografie ---------- */
.h1 { margin: 0; font-family: var(--serif); font-weight: 600; font-size: 30px; line-height: 1.2; color: var(--blue-dark); }
.h2 { margin: 0 0 12px; font-family: var(--serif); font-weight: 600; font-size: 20px; color: var(--blue-dark); }
.h2 small { font-family: var(--sans); font-weight: 400; font-size: 13px; color: var(--muted); margin-left: 6px; }
.sub { margin: 4px 0 0; color: var(--muted); font-size: 15px; }
.rule { margin-top: 10px; width: 56px; height: 3px; border-radius: 2px; background: var(--terra); }
.hint { color: var(--muted); font-size: 14px; }
.empty { color: var(--muted); }
.count { color: var(--muted); font-size: 14px; margin: 0 0 12px; }
code { background: var(--cream); padding: 1px 6px; border-radius: 6px; font-size: .9em; }

.top { padding: 24px 0 16px; }
.back { display: inline-flex; align-items: center; gap: 6px; min-height: 44px; margin-bottom: 4px; font-weight: 500; }

.flash { margin: 16px 0 0; padding: 12px 16px; border-radius: 12px; background: var(--blue-soft); color: var(--blue-dark); }
.errors { margin: 0 0 16px; padding: 12px 16px; border-radius: 12px; background: #FCEBEB; color: var(--danger); }
.errors p { margin: 4px 0; }

/* ---------- vyhledávání ---------- */
.search {
  display: flex; align-items: center; gap: 10px;
  height: 52px; padding: 0 16px; margin-bottom: 20px;
  border: 1.5px solid var(--blue-line); border-radius: 14px; color: var(--blue);
}
.search:focus-within { border-color: var(--blue); }
.search input { flex: 1; min-width: 0; border: 0; outline: none; background: transparent; font-size: 16px; color: var(--text); }

/* ---------- dlaždice ---------- */
.tiles { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
@media (min-width: 640px) { .tiles { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.tile {
  position: relative;
  display: flex; flex-direction: column; gap: 8px;
  min-height: 128px; padding: 18px 16px 16px;
  background: var(--cream); border-radius: var(--radius);
  border-bottom: 4px solid var(--blue); color: var(--blue-dark);
  transition: transform .12s ease;
}
.tile:active { transform: scale(.98); }
.tile--terra { border-bottom-color: var(--terra); }
.tile-icon { color: var(--blue); }
.tile--terra .tile-icon { color: var(--terra-text); }
.tile-name { font-family: var(--serif); font-weight: 600; font-size: 19px; line-height: 1.2; }
.tile-desc { font-size: 13px; color: var(--muted); }
.tile-count { position: absolute; top: 14px; right: 14px; min-width: 26px; padding: 2px 8px; border-radius: 12px; background: var(--white); font-size: 12px; font-weight: 600; text-align: center; color: var(--blue-dark); }

/* ---------- řádky podkategorií ---------- */
.rows { display: flex; flex-direction: column; gap: 12px; }
.row {
  display: flex; align-items: center; gap: 16px; padding: 20px 18px;
  background: var(--cream); border-radius: var(--radius);
  border-bottom: 4px solid var(--blue); color: var(--blue-dark);
}
.row--terra { border-bottom-color: var(--terra); }
.row-icon { color: var(--blue); display: flex; }
.row--terra .row-icon { color: var(--terra-text); }
.row-name { flex: 1; font-family: var(--serif); font-weight: 600; font-size: 21px; }
.row--all { background: transparent; border: 1.5px dashed var(--blue-line); color: var(--blue); }
.row--all .row-name { font-family: var(--sans); font-size: 17px; }

/* ---------- karty receptů ---------- */
.section { margin-top: 28px; }
.cards { display: grid; gap: 12px; }
@media (min-width: 640px) { .cards { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.card {
  display: flex; gap: 14px; align-items: center; padding: 10px;
  border: 1px solid var(--cream-line); border-radius: 14px; color: var(--text);
}
.card:hover { border-color: var(--blue-line); color: var(--text); }
.card-img { width: 80px; height: 80px; flex-shrink: 0; border-radius: 10px; object-fit: cover; background: var(--cream-line); }
.card-img--empty { display: flex; align-items: center; justify-content: center; color: var(--terra-text); background: var(--cream); }
.card-body { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.card-title { font-weight: 600; font-size: 16px; color: var(--blue-dark); }
.card-meta { font-size: 13px; color: var(--muted); }
.badge { align-self: flex-start; font-size: 12px; padding: 2px 8px; border-radius: 6px; background: var(--blue-soft); color: var(--blue-dark); }
.badge--terra { background: var(--terra-soft); color: var(--terra-dark); }

/* ---------- detail receptu ---------- */
.recipe-page .page { padding-left: 0; padding-right: 0; }
.hero { position: relative; background: var(--cream-line); }
.gallery { display: flex; overflow-x: auto; scroll-snap-type: x mandatory; scrollbar-width: none; }
.gallery::-webkit-scrollbar { display: none; }
.gallery-item { flex: 0 0 100%; scroll-snap-align: start; }
.gallery img { width: 100%; height: min(62vw, 440px); object-fit: cover; }
.hero-empty { height: 180px; display: flex; align-items: center; justify-content: center; color: var(--terra-text); background: var(--cream); }
.hero-back {
  position: absolute; top: 16px; left: 16px; width: 44px; height: 44px; border-radius: 22px;
  display: flex; align-items: center; justify-content: center; background: var(--white); color: var(--blue);
  box-shadow: 0 1px 4px rgba(0,0,0,.15);
}
.hero-count { position: absolute; bottom: 12px; right: 12px; font-size: 12px; padding: 4px 10px; border-radius: 12px; background: var(--white); }
.recipe { padding: 20px 20px 0; }
.crumb { margin: 0 0 6px; font-size: 13px; font-weight: 500; color: var(--terra-text); }
.recipe-title { font-size: 28px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.chip { display: inline-flex; align-items: center; gap: 5px; font-size: 13px; padding: 4px 10px; border-radius: 8px; background: var(--cream); }
.chip--terra { background: var(--terra-soft); color: var(--terra-dark); }
.actions { display: flex; gap: 10px; margin-top: 18px; }
.actions .btn--primary { flex: 1; }

.extra { margin-top: 20px; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.extra > div { padding: 12px 14px; border-radius: 12px; border: 1px solid var(--blue-line); display: flex; flex-direction: column; }
.extra-label { font-size: 12px; color: var(--muted); }
.extra-value { font-weight: 600; color: var(--blue-dark); }

.ingredients { margin-top: 24px; padding: 18px; background: var(--cream); border-radius: var(--radius); }
.ingredients ul { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.ingredients label { display: flex; gap: 12px; align-items: flex-start; min-height: 32px; cursor: pointer; }
.ingredients input { width: 20px; height: 20px; margin-top: 2px; flex-shrink: 0; accent-color: var(--blue); }
.ingredients input:checked + span { text-decoration: line-through; color: var(--muted); }
.ing-group { margin-top: 8px; font-weight: 600; color: var(--terra-dark); }

.steps { margin-top: 26px; }
.steps ol { list-style: none; counter-reset: s; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 18px; }
.steps li { counter-increment: s; display: flex; gap: 14px; }
.steps li::before {
  content: counter(s); flex-shrink: 0; width: 32px; height: 32px; border-radius: 16px;
  display: flex; align-items: center; justify-content: center;
  background: var(--blue); color: var(--white); font-weight: 600; font-size: 15px;
}
.steps p { margin: 4px 0 0; line-height: 1.6; }
.steps li.is-current p { background: var(--blue-soft); border-radius: 8px; padding: 6px 10px; margin: 0; }

.notes { margin-top: 26px; padding: 16px 18px; border: 1px solid var(--cream-line); border-radius: var(--radius); }
.notes p { margin: 0; }
.handwriting { margin-top: 26px; }
.hw-list { display: flex; gap: 10px; flex-wrap: wrap; }
.hw-list img { width: 120px; height: 150px; object-fit: cover; border-radius: 10px; border: 1px dashed var(--terra); }
.tags { margin-top: 22px; display: flex; flex-wrap: wrap; gap: 8px; }
.tag { font-size: 13px; padding: 6px 12px; border-radius: 16px; border: 1px solid var(--blue-line); color: var(--blue-dark); }
.byline { margin-top: 24px; font-size: 13px; color: var(--muted); }

/* ---------- režim vaření ---------- */
.cook-bar { position: fixed; left: 0; right: 0; bottom: 0; padding: 12px 20px calc(12px + env(safe-area-inset-bottom)); background: var(--white); border-top: 1px solid var(--cream-line); z-index: 20; }
.cook-bar .btn { width: 100%; max-width: 720px; margin: 0 auto; }
body.cooking { font-size: 20px; }
body.cooking .bottom-nav, body.cooking .actions, body.cooking .tags, body.cooking .byline, body.cooking .hero { display: none; }
body.cooking .recipe { padding-top: 28px; }
body.cooking .recipe-title { font-size: 34px; }
body.cooking .ingredients label { min-height: 44px; }
body.cooking .ingredients input { width: 26px; height: 26px; }
body.cooking .steps li { cursor: pointer; }
body.cooking .steps li::before { width: 40px; height: 40px; border-radius: 20px; font-size: 18px; }

/* ---------- tlačítka ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 50px; padding: 0 18px; border-radius: 14px;
  border: 1.5px solid var(--blue-line); background: var(--white); color: var(--blue);
  font-size: 16px; font-weight: 600; cursor: pointer;
}
.btn:hover { border-color: var(--blue); }
.btn--primary { background: var(--blue); border-color: var(--blue); color: var(--white); }
.btn--primary:hover { background: var(--blue-dark); color: var(--white); }
.btn--icon { width: 50px; padding: 0; }
.btn--block { width: 100%; }
.btn--big { min-height: 56px; font-size: 17px; }
.btn--danger { border-color: #F7C1C1; color: var(--danger); }
.btn[disabled] { opacity: .7; cursor: wait; }

/* ---------- formuláře ---------- */
.form { display: flex; flex-direction: column; gap: 18px; margin-bottom: 28px; }
.form .h2 { margin: 8px 0 0; }
.field { display: flex; flex-direction: column; gap: 8px; border: 0; padding: 0; margin: 0; }
.field > span { font-size: 15px; font-weight: 600; }
.field input, .field select, .field textarea {
  width: 100%; min-height: 50px; padding: 12px 14px;
  border: 1.5px solid var(--field-line); border-radius: 12px; background: var(--white); font-size: 16px;
}
.field textarea { line-height: 1.5; resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus { outline: none; border-color: var(--blue); }
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.extra-fields { border: 0; margin: 0; padding: 16px; border-radius: var(--radius); background: var(--cream); }
.extra-fields legend { float: left; width: 100%; margin-bottom: 12px; font-weight: 600; color: var(--terra-dark); }
.extra-fields.is-hidden { display: none; }
.extra-fields .field > span { font-size: 13px; font-weight: 500; color: var(--muted); }

.upload {
  position: relative; display: flex; align-items: center; gap: 14px; padding: 18px;
  border: 1.5px dashed var(--blue); border-radius: 14px; background: var(--blue-soft); color: var(--blue-dark); cursor: pointer;
}
.upload b { display: block; }
.upload small { display: block; font-size: 13px; color: var(--muted); }
.upload input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.upload--terra { border-color: var(--terra); background: var(--terra-soft); color: var(--terra-dark); }
.previews { display: flex; flex-wrap: wrap; gap: 8px; }
.previews img { width: 76px; height: 76px; object-fit: cover; border-radius: 10px; }
.photo-admin { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.pa-item { display: flex; flex-direction: column; gap: 4px; font-size: 13px; }
.pa-item img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 10px; }
.pa-opt { display: flex; align-items: center; gap: 6px; min-height: 32px; }
.pa-del { color: var(--danger); }
.danger-zone { margin-top: 8px; }

.panel { padding: 16px 18px; border-radius: var(--radius); background: var(--cream); margin-bottom: 24px; }
.checks { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.checks .ok span { color: #3B6D11; }
.checks .bad { color: var(--danger); font-weight: 600; }

/* ---------- spodní navigace ---------- */
.bottom-nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  display: flex; justify-content: space-around; align-items: center;
  height: calc(72px + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom);
  background: var(--white); border-top: 1px solid var(--cream-line);
}
.bottom-nav a { display: flex; flex-direction: column; align-items: center; gap: 2px; min-width: 72px; font-size: 12px; color: var(--muted); }
.bottom-nav a span { max-width: 90px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bottom-nav a.is-active { color: var(--blue); font-weight: 600; }
.bottom-nav .nav-add { min-width: 0; width: 56px; height: 56px; border-radius: 28px; justify-content: center; background: var(--blue); color: var(--white); }

/* ---------- zvětšení fotky ---------- */
.lightbox { position: fixed; inset: 0; z-index: 50; background: rgba(20,20,19,.92); display: flex; align-items: center; justify-content: center; padding: 16px; }
.lightbox img { max-width: 100%; max-height: 100%; object-fit: contain; border-radius: 6px; }
.lightbox button { position: absolute; top: 16px; right: 16px; width: 48px; height: 48px; border-radius: 24px; border: 0; background: var(--white); color: var(--text); cursor: pointer; }

/* ---------- tisk ---------- */
@media print {
  body { font-size: 12pt; }
  .bottom-nav, .no-print, .hero-back, .hero-count, .cook-bar, .flash { display: none !important; }
  .page { padding: 0; max-width: none; }
  .gallery { overflow: visible; }
  .gallery-item { display: none; }
  .gallery-item:first-child { display: block; }
  .gallery img { height: 7cm; width: auto; max-width: 100%; }
  .ingredients { background: none; border: 1px solid #ccc; }
  .ingredients input { display: none; }
  .steps li::before { background: none; color: #000; border: 1px solid #000; }
  a { color: inherit; }
}
