:root {
  --bg: #f9f6f1;
  --card: #ffffff;
  --accent: #c0441a;
  --accent-light: #fff1eb;
  --text: #1a1a1a;
  --text-muted: #6b6b6b;
  --border: #e8dfd4;
  --header-bg: #2b1a0f;
  --header-text: #f9f6f1;
  --tag-bg: #fef3e2;
  --tag-text: #92400e;
  --tag-active-bg: #c0441a;
  --tag-active-text: #ffffff;
  --radius: 10px;
  --shadow: 0 2px 8px rgba(0,0,0,0.08);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

/* ── HEADER ── */
header {
  background: var(--header-bg);
  color: var(--header-text);
  padding: 1.25rem 1.5rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 12px rgba(0,0,0,0.25);
}

header h1 {
  font-size: 1.4rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  flex-shrink: 0;
}

header h1 span { color: #e8956d; }

.header-meta {
  font-size: 0.8rem;
  color: #a0856e;
  flex-shrink: 0;
}

.search-wrap {
  flex: 1;
  min-width: 200px;
  max-width: 400px;
  margin-left: auto;
}

.search-wrap input {
  width: 100%;
  padding: 0.55rem 1rem;
  border: none;
  border-radius: 20px;
  background: rgba(255,255,255,0.12);
  color: var(--header-text);
  font-size: 0.9rem;
  outline: none;
  transition: background 0.2s;
}

.search-wrap input::placeholder { color: #a0856e; }
.search-wrap input:focus { background: rgba(255,255,255,0.2); }

/* ── ADMIN TLAČÍTKO V HLAVIČCE ── */
.admin-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  background: rgba(255,255,255,0.12);
  color: var(--header-text);
  border: none;
  border-radius: 20px;
  padding: 0.4rem 0.9rem;
  font-size: 0.88rem;
  font-family: inherit;
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
  transition: background 0.2s;
}
.admin-btn:hover { background: rgba(255,255,255,0.22); }

/* ── TAG FILTER ── */
.tag-filter {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  padding: 1rem 1.5rem 0.5rem;
}

.tag-filter .tag {
  background: var(--tag-bg);
  color: var(--tag-text);
  border: 1px solid #f0d8b8;
  border-radius: 20px;
  padding: 0.3rem 0.75rem;
  font-size: 0.78rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
}

.tag-filter .tag:hover { background: #fde8c8; }
.tag-filter .tag.active {
  background: var(--tag-active-bg);
  color: var(--tag-active-text);
  border-color: var(--tag-active-bg);
}

/* ── RECIPE GRID ── */
.recipe-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(270px, 1fr));
  gap: 1.25rem;
  padding: 1.25rem 1.5rem 2rem;
}

/* ── RECIPE CARD ── */
.recipe-card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  text-decoration: none;
  color: var(--text);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: transform 0.15s, box-shadow 0.15s;
  border: 1px solid var(--border);
}

.recipe-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 6px 20px rgba(0,0,0,0.12);
}

.card-img {
  height: 180px;
  overflow: hidden;
  background: #f0e8de;
  display: flex;
  align-items: center;
  justify-content: center;
}

.card-img img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.card-img .no-img {
  font-size: 3.5rem;
  opacity: 0.4;
}

.card-body {
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  flex: 1;
}

.card-body h2 {
  font-size: 1rem;
  font-weight: 600;
  line-height: 1.3;
}

.card-desc {
  font-size: 0.82rem;
  color: var(--text-muted);
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.card-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
  margin-top: auto;
  padding-top: 0.4rem;
}

.card-tags .tag, .recipe-tags .tag {
  background: var(--tag-bg);
  color: var(--tag-text);
  border-radius: 20px;
  padding: 0.2rem 0.6rem;
  font-size: 0.72rem;
  font-weight: 500;
}

.card-date {
  font-size: 0.72rem;
  color: #b0998a;
  margin-top: 0.25rem;
}

/* ── EMPTY STATE ── */
.empty-state {
  text-align: center;
  padding: 4rem 1.5rem;
  color: var(--text-muted);
  font-size: 1rem;
}

.empty-state .empty-icon { font-size: 3rem; margin-bottom: 1rem; }

/* ── RECIPE DETAIL ── */
.recept-header {
  display: flex;
  align-items: flex-start;
  gap: 1rem;
  flex-direction: column;
}

.back-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.85rem;
  color: #a0856e;
  text-decoration: none;
  padding: 0.5rem 0;
  margin-bottom: -0.25rem;
}

.back-btn:hover { color: var(--header-text); }

.recept-header h1 {
  font-size: 1.6rem;
  font-weight: 700;
  line-height: 1.2;
}

.recept-main {
  max-width: 800px;
  margin: 0 auto;
  padding: 1.5rem;
}

.recipe-images {
  display: flex;
  gap: 0.75rem;
  overflow-x: auto;
  margin-bottom: 1.5rem;
  border-radius: var(--radius);
  padding-bottom: 0.25rem;
}

.recipe-images img {
  height: 280px;
  border-radius: var(--radius);
  object-fit: cover;
  flex-shrink: 0;
  max-width: 100%;
}

.recipe-images img:only-child { width: 100%; height: auto; max-height: 400px; }

.recipe-meta {
  font-size: 0.88rem;
  color: var(--text-muted);
  margin-bottom: 0.75rem;
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
  align-items: center;
}

.recipe-meta a { color: var(--accent); text-decoration: none; }
.recipe-meta a:hover { text-decoration: underline; }

.recipe-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-bottom: 1.75rem;
}

.recipe-section {
  margin-bottom: 2rem;
}

.recipe-section h2 {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--accent);
  margin-bottom: 0.75rem;
  padding-bottom: 0.4rem;
  border-bottom: 2px solid var(--accent-light);
}

.ingredients {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.ingredients li {
  display: flex;
  gap: 0.5rem;
  font-size: 0.95rem;
  padding: 0.4rem 0;
  border-bottom: 1px solid var(--border);
}

.ingredients li:last-child { border-bottom: none; }

.ing-amount {
  font-weight: 600;
  min-width: 70px;
  color: var(--accent);
  flex-shrink: 0;
}

.instructions {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.instructions li {
  display: flex;
  gap: 1rem;
  font-size: 0.95rem;
  line-height: 1.6;
}

.step-num {
  background: var(--accent);
  color: white;
  border-radius: 50%;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  font-weight: 700;
  flex-shrink: 0;
  margin-top: 2px;
}

/* ── ADMIN ── */
.admin-wrap {
  max-width: 700px;
  margin: 0 auto;
  padding: 1.5rem;
}

.admin-wrap h2 {
  font-size: 1.05rem;
  font-weight: 700;
  margin-bottom: 1rem;
  color: var(--accent);
}

.admin-form-box {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  margin-bottom: 2rem;
  box-shadow: var(--shadow);
}

.admin-form-box input[type="url"],
.admin-form-box textarea {
  width: 100%;
  padding: 0.65rem 0.9rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 0.9rem;
  background: var(--bg);
  color: var(--text);
  margin-bottom: 0.75rem;
  outline: none;
  transition: border-color 0.15s;
}

.admin-form-box input:focus,
.admin-form-box textarea:focus { border-color: var(--accent); }

.admin-form-box textarea {
  height: 70px;
  resize: vertical;
}

.btn-primary {
  background: var(--accent);
  color: white;
  border: none;
  border-radius: 6px;
  padding: 0.65rem 1.5rem;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
}

.btn-primary:hover { background: #a83818; }
.btn-primary:disabled { background: #ccc; cursor: not-allowed; }

.queue-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.queue-item {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.9rem 1.1rem;
  display: flex;
  align-items: flex-start;
  gap: 0.9rem;
  box-shadow: var(--shadow);
}

.queue-status {
  font-size: 1.2rem;
  flex-shrink: 0;
  margin-top: 2px;
}

.queue-body { flex: 1; min-width: 0; }

.queue-url {
  font-size: 0.82rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 0.2rem;
}

.queue-note {
  font-size: 0.8rem;
  color: #999;
  font-style: italic;
}

.queue-date {
  font-size: 0.75rem;
  color: #bbb;
  flex-shrink: 0;
  white-space: nowrap;
}

.status-pending .queue-status::before { content: "⏳"; }
.status-done .queue-status::before { content: "✅"; }
.status-error .queue-status::before { content: "❌"; }

.status-done { opacity: 0.65; }

.flash {
  padding: 0.75rem 1rem;
  border-radius: 6px;
  font-size: 0.88rem;
  margin-bottom: 1rem;
  display: none;
}

.flash.success { background: #d1fae5; color: #065f46; display: block; }
.flash.error { background: #fee2e2; color: #991b1b; display: block; }

/* ── ADMIN: TABS ── */
.input-tabs {
  display: flex;
  gap: 0.3rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}

.tab-btn {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.4rem 0.85rem;
  font-size: 0.82rem;
  font-weight: 500;
  cursor: pointer;
  color: var(--text-muted);
  transition: all 0.15s;
}

.tab-btn.active {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
}

.tab-btn:hover:not(.active) {
  background: var(--accent-light);
  border-color: #f5c9b3;
}

.tab-panel textarea {
  width: 100%;
  height: 160px;
  resize: vertical;
  padding: 0.65rem 0.9rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 0.9rem;
  background: var(--bg);
  color: var(--text);
  outline: none;
  font-family: inherit;
  transition: border-color 0.15s;
}

.tab-panel textarea:focus { border-color: var(--accent); }

/* ── ADMIN: SOUBOR / OBRÁZEK ── */
.file-label {
  display: block;
  cursor: pointer;
}

.file-label input[type="file"] { display: none; }

.file-label span {
  display: block;
  border: 2px dashed var(--border);
  border-radius: 8px;
  padding: 1.25rem;
  text-align: center;
  font-size: 0.85rem;
  color: var(--text-muted);
  transition: all 0.15s;
}

.file-label:hover span, .file-label.has-file span {
  border-color: var(--accent);
  background: var(--accent-light);
  color: var(--accent);
}

.paste-area {
  border: 2px dashed var(--border);
  border-radius: 8px;
  padding: 1.25rem;
  text-align: center;
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-top: 0.5rem;
  transition: all 0.15s;
  cursor: default;
}

.paste-area.drag-over, .paste-area:focus-within {
  border-color: var(--accent);
  background: var(--accent-light);
}

#imagePreview img {
  max-width: 100%;
  max-height: 200px;
  border-radius: 6px;
  margin-top: 0.5rem;
  display: block;
}

.clear-btn {
  background: none;
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0.25rem 0.6rem;
  font-size: 0.78rem;
  cursor: pointer;
  color: var(--text-muted);
  margin-top: 0.4rem;
  transition: all 0.15s;
}

.clear-btn:hover { border-color: #ef4444; color: #ef4444; }

/* ── ADMIN: FLASH INLINE ── */
.form-actions {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  flex-wrap: wrap;
  margin-top: 0.25rem;
}

.flash-inline {
  font-size: 0.85rem;
  font-weight: 600;
  opacity: 0;
  transition: opacity 0.25s;
}

.flash-inline.success { color: #059669; opacity: 1; }
.flash-inline.error   { color: #dc2626; opacity: 1; }

/* ── ADMIN: QUEUE URL ODKAZ ── */
.queue-url a {
  color: var(--accent);
  text-decoration: none;
  word-break: break-all;
  font-size: 0.82rem;
}

.queue-url a:hover { text-decoration: underline; }

.pending-count {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--accent);
}

/* ── LOG STRÁNKA ── */
.log-wrap {
  max-width: 800px;
  margin: 0 auto;
  padding: 1.5rem;
}

.log-wrap > h2 {
  font-size: 1.05rem;
  font-weight: 700;
  margin-bottom: 1.25rem;
  color: var(--accent);
}

.log-nav {
  display: flex;
  gap: 0.75rem;
  align-items: center;
  margin-left: auto;
}

.log-cards {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.log-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-left: 4px solid #ccc;
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
}

.log-card.status-done    { border-left-color: #10b981; }
.log-card.status-pending { border-left-color: #f59e0b; }
.log-card.status-error   { border-left-color: #ef4444; }
.log-card.status-deleted { border-left-color: #9ca3af; opacity: 0.6; }

/* Hlavička karty: název + odznak */
.log-card-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.75rem;
}

.log-card-title {
  font-size: 1rem;
  font-weight: 600;
  line-height: 1.35;
  flex: 1;
  min-width: 0;
}

.log-card-title a {
  color: var(--text);
  text-decoration: none;
}

.log-card-title a:hover { color: var(--accent); }

.log-card-title.is-url {
  font-size: 0.82rem;
  font-weight: 400;
  color: var(--text-muted);
  word-break: break-all;
}

.log-card-title.is-url a { color: var(--accent); }

.log-badge {
  font-size: 0.71rem;
  font-weight: 700;
  padding: 0.22rem 0.65rem;
  border-radius: 20px;
  white-space: nowrap;
  flex-shrink: 0;
  letter-spacing: 0.02em;
}

.status-done    .log-badge { background: #d1fae5; color: #065f46; }
.status-pending .log-badge { background: #fef3c7; color: #92400e; }
.status-error   .log-badge { background: #fee2e2; color: #991b1b; }
.status-deleted .log-badge { background: #f3f4f6; color: #6b7280; }

/* Patička karty: zdroj + datum + tlačítko */
.log-card-foot {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.log-source-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--accent);
  text-decoration: none;
  padding: 0.35rem 0.85rem;
  background: var(--accent-light);
  border: 1px solid #f5c9b3;
  border-radius: 5px;
  transition: background 0.15s;
  white-space: nowrap;
}

.log-source-btn:hover { background: #fde0d0; }

.log-card-meta {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.log-card-dates {
  font-size: 0.75rem;
  color: var(--text-muted);
  line-height: 1.5;
  text-align: right;
}

.log-processed-date { color: #059669; display: block; }

.log-btn {
  padding: 0.3rem 0.7rem;
  border-radius: 5px;
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: background 0.15s;
  white-space: nowrap;
}

.log-btn.delete  { background: #fee2e2; color: #991b1b; }
.log-btn.delete:hover  { background: #fecaca; }
.log-btn.restore { background: #d1fae5; color: #065f46; }
.log-btn.restore:hover { background: #a7f3d0; }
.log-btn:disabled { opacity: 0.5; cursor: not-allowed; }

@media (max-width: 600px) {
  .log-card { padding: 0.85rem 1rem; }
  .log-card-foot { flex-direction: column; align-items: flex-start; }
  .log-card-meta { width: 100%; justify-content: space-between; }
  .log-card-dates { text-align: left; }
}

/* ── RECIPE SOURCE ── */
.recipe-source {
  margin-top: 2rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--border);
}

.source-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.65rem 1.25rem;
  background: var(--accent-light);
  color: var(--accent);
  border: 1px solid #f5c9b3;
  border-radius: 6px;
  font-size: 0.88rem;
  font-weight: 600;
  text-decoration: none;
  transition: background 0.15s, border-color 0.15s;
}

.source-btn:hover {
  background: #fde0d0;
  border-color: var(--accent);
}

/* ── PIN MODAL ── */
.pin-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.62);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 500;
}
.pin-modal {
  background: #fff;
  border-radius: 1rem;
  padding: 2rem 2rem 1.5rem;
  width: min(340px, 92vw);
  box-shadow: 0 8px 32px rgba(0,0,0,0.22);
  text-align: center;
}
.pin-modal h3 {
  margin: 0 0 .3rem;
  font-size: 1.2rem;
  color: var(--text);
}
.pin-subtitle {
  color: #888;
  font-size: .88rem;
  margin: 0 0 1.25rem;
}
.pin-input {
  display: block;
  width: 100%;
  box-sizing: border-box;
  font-size: 1.8rem;
  letter-spacing: .6rem;
  text-align: center;
  padding: .5rem 1rem;
  border: 2px solid #e5e7eb;
  border-radius: .6rem;
  outline: none;
  transition: border-color .2s;
}
.pin-input:focus { border-color: var(--accent); }
.pin-error {
  color: #c0441a;
  font-size: .85rem;
  min-height: 1.3em;
  margin-top: .6rem;
}
.pin-actions {
  display: flex;
  gap: .75rem;
  margin-top: 1.25rem;
}
.pin-btn {
  flex: 1;
  padding: .6rem 1rem;
  border: none;
  border-radius: .5rem;
  font-size: .95rem;
  font-family: inherit;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s;
}
.pin-btn.primary { background: var(--accent); color: #fff; }
.pin-btn.primary:hover { background: #c0441a; }
.pin-btn.cancel { background: #f3f4f6; color: #555; }
.pin-btn.cancel:hover { background: #e5e7eb; }
.pin-btn:disabled { opacity: .5; cursor: not-allowed; }

/* ── RESPONSIVE ── */

/* Tablet (do 900px) — 2 sloupce karet */
@media (max-width: 900px) {
  .recipe-grid {
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 1rem;
    padding: 1rem 1.25rem 2rem;
  }
}

/* Mobil (do 600px) */
@media (max-width: 600px) {

  /* Header */
  header {
    padding: 0.85rem 1rem;
    gap: 0.5rem;
    flex-wrap: wrap;
  }

  header h1 { font-size: 1.15rem; }

  .header-meta { display: none; }

  .search-wrap {
    order: 3;
    flex: none;
    width: 100%;
    max-width: none;
    margin-left: 0;
    margin-top: 0.1rem;
  }

  .search-wrap input {
    font-size: 1rem; /* zabrání zoomu na iOS */
    padding: 0.6rem 1rem;
  }

  .admin-btn {
    margin-left: auto;
    font-size: .82rem;
    padding: 0.35rem 0.75rem;
  }

  /* Tag filter */
  .tag-filter {
    padding: 0.75rem 1rem 0.25rem;
    gap: 0.4rem;
    overflow-x: auto;
    flex-wrap: nowrap;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }

  .tag-filter::-webkit-scrollbar { display: none; }

  .tag-filter .tag {
    flex-shrink: 0;
    padding: 0.45rem 0.9rem;
    font-size: 0.82rem;
  }

  /* Grid */
  .recipe-grid {
    grid-template-columns: 1fr;
    padding: 0.75rem 1rem 2rem;
    gap: 0.75rem;
  }

  .card-img { height: 200px; }

  /* Recipe detail — header */
  .recept-header {
    padding: 0.85rem 1rem;
    gap: 0.4rem;
  }

  .recept-header h1 { font-size: 1.25rem; }

  .back-btn { font-size: 0.82rem; }

  /* Recipe detail — obsah */
  .recept-main { padding: 0.9rem 1rem 2rem; }

  /* Fotky přes celou šířku */
  .recipe-images {
    margin-left: -1rem;
    margin-right: -1rem;
    border-radius: 0;
    gap: 0;
  }

  .recipe-images img {
    height: 240px;
    border-radius: 0;
    min-width: 100%;
  }

  .recipe-images img:only-child {
    height: auto;
    max-height: 300px;
  }

  /* Tlačítko zdroj — přes celou šířku */
  .source-btn {
    display: flex;
    justify-content: center;
    width: 100%;
    padding: 0.9rem;
    font-size: 0.95rem;
  }

  /* Ingredience — větší množství sloupec */
  .ing-amount { min-width: 80px; }

  /* Admin */
  .admin-wrap { padding: 1rem; }

  .admin-form-box { padding: 1rem; }

  .admin-form-box input[type="url"],
  .admin-form-box textarea {
    font-size: 1rem; /* zabrání zoomu na iOS */
  }

  .btn-primary {
    width: 100%;
    padding: 0.85rem;
    font-size: 0.95rem;
  }

  .queue-date { display: none; }
}

