/* ============================================================
   Motyw „Bento" — jasny, ciepły, modularna siatka kafelków.
   Tokeny wg bento.md.
   ============================================================ */

@font-face {
  font-family: "Inter"; font-style: normal; font-weight: 400; font-display: swap;
  src: url("/static/fonts/inter-latin-ext-400.woff2") format("woff2");
}
@font-face {
  font-family: "Inter"; font-style: normal; font-weight: 600; font-display: swap;
  src: url("/static/fonts/inter-latin-ext-600.woff2") format("woff2");
}
@font-face {
  font-family: "Inter"; font-style: normal; font-weight: 700; font-display: swap;
  src: url("/static/fonts/inter-latin-ext-700.woff2") format("woff2");
}
@font-face {
  font-family: "Inter"; font-style: normal; font-weight: 800; font-display: swap;
  src: url("/static/fonts/inter-latin-ext-800.woff2") format("woff2");
}
@font-face {
  font-family: "JetBrains Mono"; font-style: normal; font-weight: 500; font-display: swap;
  src: url("/static/fonts/jetbrains-mono-latin-ext-500.woff2") format("woff2");
}

:root {
  /* Kolory (bento.md) */
  --primary: #FAD4C0;
  --secondary: #80A1C1;
  --success: #16A34A;
  --warning: #D97706;
  --danger: #DC2626;
  --surface: #FFF5E6;
  --text: #111827;

  /* Pochodne robocze */
  --bg: #FFF5E6;
  --panel: #FFFDF9;
  --panel-2: #FBEFE0;
  --muted: #7C7266;
  --border: #EFE0CE;
  --border-strong: #E3CDB4;
  --accent: #5F84A8;          /* przyciemniony secondary — pod przyciski/linki */
  --accent-ink: #ffffff;
  --heart: #E5556F;

  /* Zaokrąglenia i odstępy (bento.md) */
  --r-sm: 4px;
  --r-md: 8px;
  --r-lg: 16px;
  --s-1: 4px; --s-2: 8px; --s-3: 12px; --s-4: 16px; --s-5: 24px; --s-6: 32px;

  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, "Cascadia Code", Consolas, monospace;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  color: var(--text);
  background:
    radial-gradient(1000px 500px at 85% -10%, rgba(250,212,192,.55), transparent 60%),
    radial-gradient(900px 500px at 0% 0%, rgba(128,161,193,.20), transparent 55%),
    var(--bg);
  min-height: 100vh;
  line-height: 1.5;
}

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

/* ---------- Topbar ---------- */
.topbar {
  display: flex; align-items: center; gap: var(--s-4);
  padding: var(--s-3) var(--s-5); background: rgba(255,253,249,.85);
  backdrop-filter: blur(6px);
  border-bottom: 1px solid var(--border); flex-wrap: wrap;
  position: sticky; top: 0; z-index: 40;
}
.topbar .brand {
  font-weight: 800; font-size: 1.2rem; color: var(--text); letter-spacing: -.01em;
}
.topbar .brand:hover { text-decoration: none; }
.topbar nav { display: flex; gap: var(--s-2); flex-wrap: wrap; }
.topbar nav a {
  color: var(--muted); padding: 6px 10px; border-radius: var(--r-md); font-weight: 600;
  font-size: .92rem;
}
.topbar nav a:hover { color: var(--text); background: var(--panel-2); text-decoration: none; }
.spacer { flex: 1; }
.muted { color: var(--muted); }

.container { max-width: 1180px; margin: 0 auto; padding: var(--s-5) var(--s-5) 64px; }

h1 { font-size: 2rem; font-weight: 800; letter-spacing: -.02em; margin: 0 0 var(--s-4); }
h2 { font-size: 1.25rem; font-weight: 700; margin: var(--s-6) 0 var(--s-3); }
h3 { font-size: 1.05rem; font-weight: 700; margin: 0 0 var(--s-2); }

/* Etykiety monospace (label-caps z bento.md) */
.label-caps, .chip, .meta-item, th {
  font-family: var(--mono); text-transform: uppercase; letter-spacing: .06em; font-size: .72rem;
}

/* ---------- Przyciski / pola ---------- */
input, select, textarea, button { font: inherit; }
input, select, textarea {
  background: #fff; color: var(--text); border: 1px solid var(--border-strong);
  border-radius: var(--r-md); padding: 9px 11px; width: 100%;
}
textarea { resize: vertical; min-height: 72px; }
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--secondary); box-shadow: 0 0 0 3px rgba(128,161,193,.25);
}
.btn, button {
  display: inline-flex; align-items: center; gap: 6px; justify-content: center;
  background: var(--accent); color: var(--accent-ink); border: 0; border-radius: var(--r-md);
  padding: 9px 16px; cursor: pointer; font-weight: 600; width: auto;
}
.btn:hover, button:hover { filter: brightness(1.06); text-decoration: none; }
.btn.ghost, button.ghost {
  background: #fff; color: var(--text); border: 1px solid var(--border-strong);
}
.btn.ghost:hover, button.ghost:hover { background: var(--panel-2); filter: none; }
.btn.danger, button.danger { background: var(--danger); }
.btn.sm { padding: 6px 10px; font-size: .88rem; }
.btn.icon { padding: 7px 10px; }
.btn-row { display: flex; gap: var(--s-2); flex-wrap: wrap; align-items: center; }

/* ---------- Chipy / badge ---------- */
.chip {
  display: inline-flex; align-items: center; gap: 5px; padding: 4px 9px; border-radius: 999px;
  background: var(--primary); color: #7a3d24; font-weight: 500; white-space: nowrap;
}
.chip.blue { background: rgba(128,161,193,.25); color: #2f4f6b; }
.chip.soft { background: var(--panel-2); color: var(--muted); }

/* ============================================================
   Siatka BENTO (kafelki)
   ============================================================ */
.bento {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  grid-auto-rows: 1fr;
  gap: var(--s-4);
}
.card {
  background: var(--panel); border: 1px solid var(--border);
  border-radius: var(--r-lg); overflow: hidden;
  box-shadow: 0 1px 2px rgba(80,55,30,.04), 0 8px 22px -14px rgba(80,55,30,.25);
  transition: transform .12s ease, box-shadow .12s ease;
}
.card:hover { transform: translateY(-3px); box-shadow: 0 14px 30px -14px rgba(80,55,30,.35); }

/* ---------- Kafelek przepisu ---------- */
a.recipe-card { display: flex; flex-direction: column; color: inherit; height: 100%; }
a.recipe-card:hover { text-decoration: none; }
.recipe-card .thumb {
  position: relative; aspect-ratio: 4 / 3; background: var(--panel-2);
  display: flex; align-items: center; justify-content: center; overflow: hidden;
}
.recipe-card .thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.recipe-card .thumb .noimg { font-size: 2.6rem; opacity: .5; }
.recipe-card .fav-flag {
  position: absolute; top: 10px; right: 10px; font-size: 1rem; line-height: 1;
  background: rgba(255,255,255,.9); border-radius: 999px; width: 30px; height: 30px;
  display: flex; align-items: center; justify-content: center; box-shadow: 0 2px 6px rgba(0,0,0,.15);
}
.recipe-card .body { padding: var(--s-3) var(--s-4) var(--s-4); display: flex; flex-direction: column; gap: 8px; flex: 1; }
.recipe-card .title { font-weight: 700; font-size: 1.05rem; line-height: 1.25; }
.recipe-card .metarow { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; color: var(--muted); margin-top: auto; }
.recipe-card .metarow .meta-item { display: inline-flex; align-items: center; gap: 4px; }
.stars-inline { color: #E7A83a; letter-spacing: 1px; font-size: .9rem; }
.stars-inline .off { color: var(--border-strong); }

/* Kafelek „duży" — nadaje siatce rytm bento */
.card.big { grid-column: span 2; grid-row: span 2; }
.card.big .thumb { aspect-ratio: auto; height: 100%; min-height: 240px; }
.card.wide { grid-column: span 2; }
@media (max-width: 560px) {
  .card.big, .card.wide { grid-column: auto; grid-row: auto; }
  .card.big .thumb { aspect-ratio: 4/3; min-height: 0; }
}

/* ---------- Kafelki statystyk (dashboard) ---------- */
.stat { padding: var(--s-4); display: flex; flex-direction: column; gap: 6px; }
.stat .k { font-family: var(--mono); text-transform: uppercase; letter-spacing: .06em; font-size: .7rem; color: var(--muted); }
.stat .v { font-size: 2.4rem; font-weight: 800; line-height: 1; letter-spacing: -.02em; }
.stat.accent { background: linear-gradient(160deg, var(--primary), #ffe7d6); border-color: var(--border-strong); }
.stat.blue { background: linear-gradient(160deg, rgba(128,161,193,.28), rgba(128,161,193,.12)); }
.cat-list { display: flex; flex-direction: column; gap: 6px; }
.cat-list a { display: flex; justify-content: space-between; padding: 6px 8px; border-radius: var(--r-sm); color: var(--text); }
.cat-list a:hover { background: var(--panel-2); text-decoration: none; }
.cat-list .n { font-family: var(--mono); color: var(--muted); font-size: .8rem; }

/* ---------- Pasek filtrów ---------- */
.toolbar { display: flex; justify-content: space-between; align-items: center; gap: var(--s-3); flex-wrap: wrap; margin-bottom: var(--s-4); }
.filters {
  display: grid; grid-template-columns: 2fr repeat(4, 1fr) auto; gap: var(--s-3);
  align-items: end; background: var(--panel); padding: var(--s-4); border-radius: var(--r-lg);
  border: 1px solid var(--border); margin-bottom: var(--s-5);
}
.filter-actions { display: flex; gap: 8px; align-items: center; }
.filters label { display: flex; flex-direction: column; gap: 5px; font-size: .78rem; color: var(--muted); font-weight: 600; }
.filters .check { flex-direction: row; align-items: center; gap: 8px; }
.filters .check input { width: auto; }
@media (max-width: 820px) { .filters { grid-template-columns: 1fr 1fr; } }

/* ---------- Edytor słownika składników ---------- */
.pantry-head, .pantry-row {
  display: grid; gap: 8px; align-items: center;
  /* Stałe szerokości = kolumny równe w nagłówku i we wszystkich wierszach (niezależnie od treści przycisków). */
  grid-template-columns: minmax(0, 1fr) 58px 56px 82px 116px 78px 64px 16px;
}
/* Kompaktowe wiersze — więcej składników na ekranie. */
.pantry-row input, .pantry-row select, .pantry-row .btn { padding-top: 5px; padding-bottom: 5px; }
.pantry-row .basis, .pantry-row .unit { padding: 5px 4px; }
/* Przyciski wypełniają swoją (stałą) kolumnę → równe krawędzie między wierszami. */
.pantry-row > .btn { width: 100%; padding-left: 4px; padding-right: 4px; white-space: nowrap; }
.pantry-filter { display: flex; align-items: center; gap: 12px; margin-bottom: 8px; }
.pantry-filter #pantry-filter { flex: 1; max-width: 420px; }
.pantry-filter #pantry-count { font-size: .8rem; white-space: nowrap; }
.pantry-head { padding: 4px 4px 0; }
.pantry-head span { font-family: var(--mono); text-transform: uppercase; letter-spacing: .05em; font-size: .68rem; color: var(--muted); }
.pantry-list { display: flex; flex-direction: column; gap: 3px; margin-top: 4px; }
.pantry-row { padding: 3px 6px; border-radius: var(--r-md); }
.pantry-row.saved { background: rgba(22,163,74,.10); }
.saved-flag { color: var(--success); font-weight: 800; }
@media (max-width: 640px) {
  .pantry-head { display: none; }
  .pantry-row { grid-template-columns: 1fr 1fr; }
  .pantry-row input[name="name"] { grid-column: span 2; }
}

.tag-cloud { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin: -8px 0 20px; }
.tag-cloud .chip { text-decoration: none; }
.tag-cloud .chip:hover { filter: brightness(0.97); }

.empty { text-align: center; padding: 60px 20px; color: var(--muted); }
.empty .big { font-size: 3rem; }

/* ============================================================
   Szczegóły przepisu
   ============================================================ */
.detail-head { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); gap: var(--s-5); align-items: start; }
@media (max-width: 820px) { .detail-head { grid-template-columns: 1fr; } }
.detail-photo { border-radius: var(--r-lg); overflow: hidden; background: var(--panel-2); aspect-ratio: 4/3; display: flex; align-items: center; justify-content: center; border: 1px solid var(--border); }
.detail-photo img { width: 100%; height: 100%; object-fit: cover; }
.detail-photo .noimg { font-size: 4rem; opacity: .45; }
.detail-meta { display: flex; flex-direction: column; gap: var(--s-3); }
.meta-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: var(--s-2); }
.meta-box { background: var(--panel); border: 1px solid var(--border); border-radius: var(--r-md); padding: 10px 12px; }
.meta-box .k { font-family: var(--mono); text-transform: uppercase; letter-spacing: .05em; font-size: .64rem; color: var(--muted); }
.meta-box .v { font-weight: 700; font-size: 1.05rem; margin-top: 2px; }
.tags-row { display: flex; gap: 6px; flex-wrap: wrap; }

.two-col { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr); gap: var(--s-5); margin-top: var(--s-6); align-items: start; }
@media (max-width: 820px) { .two-col { grid-template-columns: 1fr; } }
.panel { background: var(--panel); border: 1px solid var(--border); border-radius: var(--r-lg); padding: var(--s-5); }

/* Składniki + przelicznik porcji */
.servings-ctrl { display: flex; align-items: center; gap: 10px; margin-bottom: var(--s-3); }
.servings-ctrl input { width: 72px; text-align: center; }
.ingredients { list-style: none; margin: 0; padding: 0; }
.ingredients li { display: flex; gap: 10px; padding: 9px 4px; border-bottom: 1px dashed var(--border); }
.ingredients li:last-child { border-bottom: 0; }
.ingredients .amt { font-family: var(--mono); font-weight: 500; color: var(--accent); min-width: 84px;
  display: flex; flex-direction: column; line-height: 1.2; }
.ingredients .amt .g { font-weight: 600; }
.ingredients .amt .msr { font-size: .72rem; color: var(--muted); font-weight: 400; }
.ingredients .nm { flex: 1; }
.ingredients .nt { color: var(--muted); font-size: .85rem; }

.steps { list-style: none; margin: 0; padding: 0; counter-reset: step; display: flex; flex-direction: column; gap: var(--s-3); }
.steps li { counter-increment: step; display: grid; grid-template-columns: 34px 1fr; gap: 12px; }
.steps li::before {
  content: counter(step); grid-row: span 2;
  width: 34px; height: 34px; border-radius: 50%; background: var(--primary); color: #7a3d24;
  display: flex; align-items: center; justify-content: center; font-weight: 800; font-family: var(--mono);
}

/* Serce ulubionych + gwiazdki (HTMX) */
.fav-btn { background: #fff; border: 1px solid var(--border-strong); color: var(--heart); }
.fav-btn.on { background: var(--heart); color: #fff; border-color: var(--heart); }
.rating { display: inline-flex; gap: 2px; }
.rating button {
  background: none; border: 0; padding: 0 2px; font-size: 1.6rem; line-height: 1; cursor: pointer;
  color: var(--border-strong);
}
.rating button.on { color: #E7A83a; }
.rating button:hover { filter: none; transform: scale(1.1); }

/* ============================================================
   Formularz przepisu
   ============================================================ */
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: var(--s-3); }
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: var(--s-3); }
.field > label { font-weight: 600; font-size: .85rem; }
.form-section { margin-top: var(--s-5); }
.row-list { display: flex; flex-direction: column; gap: 8px; }
.ing-row { display: grid; grid-template-columns: 58px 96px 56px 78px 1fr 1fr 32px 32px; gap: 6px; align-items: center; }
.ing-row .basis, .ing-row .unit { padding: 9px 4px; }
.step-row { display: grid; grid-template-columns: 1fr 36px; gap: 8px; align-items: start; }
@media (max-width: 720px) { .ing-row { grid-template-columns: 1fr 1fr; } .ing-row .nm, .ing-row .nt { grid-column: span 2; } }
.mini-del { background: var(--panel-2); color: var(--danger); border: 1px solid var(--border); padding: 8px; }
.mini-del:hover { background: #fbe3e3; filter: none; }
/* Link „⚖ miary" w wierszu składnika — wygląd jak mini-przycisk. */
.mini-msr { display: inline-flex; align-items: center; justify-content: center; padding: 8px;
  background: var(--panel-2); color: var(--secondary); border: 1px solid var(--border);
  border-radius: var(--r-sm); text-decoration: none; font-size: 1rem; }
.mini-msr:hover { background: var(--primary); }

/* ---------- Miary domowe (edytor spiżarni) — przycisk w wierszu + rozwijany panel ---------- */
.msr-toggle { white-space: nowrap; }
.msr-toggle.on { background: var(--primary); border-color: var(--primary); }
.m-editor { grid-column: 1 / -1; display: flex; flex-wrap: wrap; align-items: center; gap: 8px;
  margin-top: 6px; padding: 8px 0 2px; border-top: 1px dashed var(--border); }
.m-editor[hidden] { display: none; }  /* atrybut hidden musi wygrać nad display:flex powyżej */
.m-editor-lbl { font-size: .78rem; color: var(--muted); }
.m-list { display: flex; flex-wrap: wrap; gap: 8px; }

/* ---------- Podpowiedzi tagów ze słownika ---------- */
.tag-suggest { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 8px; }
.chip-btn { background: var(--panel-2); border: 1px solid var(--border); color: var(--secondary);
  border-radius: 999px; padding: 3px 10px; font-size: .82rem; cursor: pointer; line-height: 1.3; }
.chip-btn:hover { background: var(--primary); filter: none; }
.chip-btn.active { background: var(--secondary); border-color: var(--secondary); color: #fff; }

/* ---------- Informacje (notatki kulinarne) ---------- */
.note-list { display: flex; flex-direction: column; gap: 12px; margin-top: 14px; }
.note-card { background: var(--panel); border: 1px solid var(--border); border-radius: var(--r-lg); padding: 16px; }
.note-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.note-head h3 { margin: 0; }
.note-actions { display: flex; gap: 6px; flex-shrink: 0; }
.note-body { white-space: pre-wrap; margin-top: 8px; color: var(--text); line-height: 1.55; }
.note-card .tags-row { margin-top: 10px; }

/* ---------- Edytor kategorii (hierarchia) ---------- */
.cat-add { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.cat-add input[name="name"] { flex: 1; min-width: 180px; }
.cat-parent { display: inline-flex; align-items: center; gap: 6px; font-size: .85rem; color: var(--muted); white-space: nowrap; }
.cat-parent select { width: auto; min-width: 150px; padding: 7px 6px; }
.cat-list { display: flex; flex-direction: column; gap: 5px; margin-top: 8px; }
.cat-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px;
  margin-left: calc(var(--depth, 0) * 26px); padding: 3px 0; }
.cat-row input[name="name"] { flex: 1; min-width: 160px; padding: 6px 10px; }
.cat-row .btn { padding-top: 6px; padding-bottom: 6px; }
.cat-branch { color: var(--muted); font-family: var(--mono); }
.cat-count { font-size: .78rem; white-space: nowrap; }
.m-row { display: inline-flex; align-items: center; gap: 4px; background: var(--panel-2);
  border: 1px solid var(--border); border-radius: var(--r-sm); padding: 3px 4px 3px 6px; }
.m-row .m-name { min-width: 120px; width: auto; padding: 4px; font-size: .82rem; }
.m-row .m-grams { width: 44px; text-align: right; padding: 4px; font-size: .82rem; }
.m-row .m-unit { color: var(--muted); font-size: .78rem; }
.m-row .mini-del { padding: 2px 6px; font-size: .8rem; line-height: 1; }
.btn.xs { padding: 4px 8px; font-size: .78rem; }

/* ---------- Logowanie ---------- */
.card-login {
  max-width: 380px; margin: 12vh auto; background: var(--panel); border: 1px solid var(--border);
  border-radius: var(--r-lg); padding: var(--s-6); box-shadow: 0 20px 50px -20px rgba(80,55,30,.4);
}
.card-login h1 { text-align: center; font-size: 1.6rem; }
.card-login label { display: block; margin-bottom: var(--s-3); font-weight: 600; font-size: .9rem; }
.card-login label input { margin-top: 6px; }
.card-login button { width: 100%; margin-top: var(--s-2); padding: 11px; }
.error { color: var(--danger); margin-bottom: var(--s-3); font-weight: 600; }
.brand-hero { text-align: center; font-size: 2.4rem; margin-bottom: 6px; }
