:root {
    --bg: #faf7f2;
    --card: #ffffff;
    --ink: #2b2520;
    --muted: #8a7f74;
    --accent: #d2691e;
    --accent-dark: #b4561a;
    --line: #ece4d8;
    --ok: #3f8f4f;
    --radius: 14px;
    --shadow: 0 2px 10px rgba(0,0,0,.06);
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    background: var(--bg);
    color: var(--ink);
    line-height: 1.55;
}

.container { max-width: 1000px; margin: 0 auto; padding: 0 20px; }
.container.narrow { max-width: 560px; }
.muted { color: var(--muted); }
a { color: var(--accent-dark); }

/* Topbar */
.topbar { background: var(--card); border-bottom: 1px solid var(--line); }
.topbar-inner { display: flex; align-items: center; justify-content: space-between; padding: 14px 0; }
.brand { font-size: 1.3rem; font-weight: 700; text-decoration: none; color: var(--ink); }
.btn {
    background: var(--accent); color: #fff; padding: 8px 16px;
    border-radius: 999px; text-decoration: none; font-weight: 600; font-size: .95rem;
}
.btn:hover { background: var(--accent-dark); }
.btn.ghost { background: transparent; color: var(--accent-dark); border: 1px solid var(--line); }
.btn.ghost:hover { background: #fff; border-color: var(--accent); color: var(--accent-dark); }
.topbar-actions { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.badge {
    display: none; background: var(--accent); color: #fff; border-radius: 999px;
    padding: 0 7px; font-size: .75rem; font-weight: 700; margin-left: 2px;
}
.btn.ghost .badge { background: var(--accent); }

/* Dodaj do listy zakupów */
.add-shop { margin-bottom: 14px; font-size: .9rem; padding: 8px 14px; }
.add-shop.added { background: var(--ok); color: #fff; border-color: var(--ok); }

/* Lista zakupów */
.shop-tools { display: flex; flex-wrap: wrap; gap: 10px; margin: 18px 0 24px; }
.shop-group { margin-bottom: 22px; }
.shop-group h3 { margin: 0 0 8px; font-size: 1.05rem; color: var(--accent-dark); }
.shop-list { list-style: none; margin: 0; padding: 0; }
.shop-list li {
    display: flex; align-items: center; gap: 10px; padding: 10px 12px;
    border-bottom: 1px solid var(--line);
}
.shop-list li.done span { text-decoration: line-through; color: var(--muted); }
.shop-list label { display: flex; align-items: center; gap: 12px; flex: 1; cursor: pointer; }
.shop-list input { width: 22px; height: 22px; }
.shop-del { background: none; border: 0; color: var(--muted); font-size: 1.1rem; cursor: pointer; }
.shop-del:hover { color: #a32e1f; }

@media print {
    .no-print, .topbar, .shop-tools, .shop-del { display: none !important; }
    .shop-list input { -webkit-appearance: none; appearance: none; width: 16px; height: 16px; border: 1px solid #333; }
    body { background: #fff; }
}
@media (max-width: 560px) { .topbar-inner { flex-wrap: wrap; gap: 10px; } .btn, .btn.ghost { font-size: .85rem; padding: 7px 12px; } }

/* Filtry kategorii */
.filters {
    display: flex; flex-wrap: wrap; gap: 10px; padding: 24px 0 4px;
}
.chip {
    background: var(--card); border: 1px solid var(--line); color: var(--ink);
    border-radius: 999px; padding: 9px 16px; font-size: .95rem; font-weight: 600;
    cursor: pointer; transition: all .15s; display: inline-flex; align-items: center; gap: 7px;
}
.chip:hover { border-color: var(--accent); }
.chip.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.chip .cnt {
    background: rgba(0,0,0,.08); border-radius: 999px; padding: 1px 8px; font-size: .8rem;
}
.chip.active .cnt { background: rgba(255,255,255,.25); }
.no-results { text-align: center; padding: 40px 0; }

/* Plakietka kategorii na karcie */
.cat-badge {
    position: absolute; top: 10px; left: 10px;
    background: rgba(43,37,32,.78); color: #fff; backdrop-filter: blur(2px);
    font-size: .75rem; font-weight: 600; padding: 4px 10px; border-radius: 999px;
}

/* „Z lodówki" */
.ing-search {
    width: 100%; max-width: 420px; margin: 22px 0 14px; padding: 12px 16px;
    border: 1px solid var(--line); border-radius: 10px; font-size: 1rem;
}
.pantry { display: flex; flex-wrap: wrap; gap: 9px; margin-bottom: 18px; }
.pantry .chip { text-transform: capitalize; }
.fridge-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 16px; margin: 6px 0 18px; }
.only-ready { display: inline-flex; align-items: center; gap: 8px; font-size: .95rem; color: var(--ink); cursor: pointer; }
.only-ready input { width: 20px; height: 20px; }
.fridge-hint { padding: 30px 0; text-align: center; }
.miss { font-size: .82rem; margin: 6px 0 0; }
.miss.ok { color: var(--ok); font-weight: 600; }
.cat-badge.ready { background: var(--ok); }

/* Grid przepisów */
.grid {
    display: grid; gap: 20px; padding: 28px 0;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
}
.card {
    background: var(--card); border-radius: var(--radius); overflow: hidden;
    box-shadow: var(--shadow); text-decoration: none; color: var(--ink);
    transition: transform .15s, box-shadow .15s;
}
.card:hover { transform: translateY(-3px); box-shadow: 0 6px 18px rgba(0,0,0,.1); }
.card-img {
    position: relative;
    height: 150px; background: #f0e8dc center/cover no-repeat;
    display: flex; align-items: center; justify-content: center; font-size: 2.5rem;
}
.card-body { padding: 14px 16px; }
.card-body h3 { margin: 0 0 6px; font-size: 1.05rem; }
.card-body p { margin: 0; font-size: .85rem; }

/* Stany */
.empty { text-align: center; padding: 80px 20px; }
.alert { padding: 14px 18px; border-radius: 10px; margin: 20px 0; }
.alert.error { background: #fdecea; color: #a32e1f; border: 1px solid #f3c2bb; }

/* Import */
.import-form { display: flex; gap: 10px; margin: 24px 0; }
.import-form input {
    flex: 1; padding: 12px 14px; border: 1px solid var(--line);
    border-radius: 10px; font-size: 1rem;
}
.import-form button {
    background: var(--accent); color: #fff; border: 0; padding: 0 22px;
    border-radius: 10px; font-weight: 600; cursor: pointer;
}

/* Przepis */
.recipe { padding: 28px 0 60px; }
.recipe h1 { margin: 0 0 8px; font-size: 1.9rem; }
.meta { margin: 0 0 20px; font-size: .9rem; }
.hero { width: 100%; max-height: 360px; object-fit: cover; border-radius: var(--radius); margin-bottom: 24px; }

/* Oceny */
.rating { display: flex; flex-wrap: wrap; align-items: center; gap: 18px; margin: 0 0 22px; }
.rating-summary { display: flex; align-items: center; gap: 8px; }
.avg-stars { color: var(--accent); font-size: 1.2rem; letter-spacing: 2px; }
.avg-text { font-size: .92rem; color: var(--muted); }
.avg-text strong { color: var(--ink); }
.rating-input { display: flex; align-items: center; gap: 2px; }
.rating-input .label { font-size: .9rem; color: var(--muted); margin-right: 8px; }
.rating-input .star {
    background: none; border: 0; cursor: pointer; font-size: 1.7rem; line-height: 1;
    color: var(--line); transition: color .1s; padding: 2px;
}
.rating-input .star.on { color: var(--accent); }
.rating-input .star:hover { color: var(--accent-dark); }
.rating-thanks { margin-left: 10px; font-size: .9rem; color: var(--ok); font-weight: 600; }
.src-rating { font-size: .85rem; color: var(--muted); }

/* Ocena na karcie listy */
.card-rating { color: var(--accent); font-size: .85rem; letter-spacing: 1px; margin-top: 4px; }
.card-rating .cnt { color: var(--muted); letter-spacing: 0; }

.columns { display: grid; grid-template-columns: 300px 1fr; gap: 32px; align-items: start; }
@media (max-width: 760px) { .columns { grid-template-columns: 1fr; } }

/* Skalowanie porcji */
.servings { display: flex; align-items: center; gap: 10px; margin: 0 0 14px; }
.srv-label { font-size: .95rem; color: var(--muted); }
.srv-btn {
    width: 36px; height: 36px; border: 1px solid var(--line); background: #fff;
    border-radius: 8px; font-size: 1.3rem; line-height: 1; cursor: pointer; color: var(--ink);
}
.srv-btn:hover { border-color: var(--accent); color: var(--accent-dark); }
.srv-btn:disabled { opacity: .4; cursor: default; }
.srv-n { min-width: 2ch; text-align: center; font-size: 1.15rem; }

/* Składniki */
.ingredients h2, .cooking h2 { font-size: 1.2rem; margin: 0 0 14px; }
.ing-list { list-style: none; margin: 0; padding: 0; }
.ing-list li { padding: 7px 10px; border-radius: 8px; transition: background .2s; }
.ing-list li.active { background: #fbeede; box-shadow: inset 3px 0 0 var(--accent); }
.ing-list label { display: flex; gap: 10px; align-items: flex-start; cursor: pointer; }
.ing-list input:checked + span { text-decoration: line-through; color: var(--muted); }

/* Stepper */
.stepper { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 24px; }
.progress { height: 6px; background: var(--line); border-radius: 999px; overflow: hidden; margin-bottom: 18px; }
.progress-bar { height: 100%; width: 0; background: var(--accent); transition: width .25s; }
.step-counter { font-size: .85rem; color: var(--muted); margin: 0 0 4px; font-weight: 600; }
.step-section { margin: 0 0 8px; font-weight: 700; color: var(--accent-dark); }
.step-text { font-size: 1.25rem; min-height: 3em; margin: 0 0 18px; }

/* Składniki użyte w bieżącym kroku (z ilością) */
.step-ings {
    display: flex; flex-wrap: wrap; gap: 8px; align-items: center;
    margin: 0 0 18px; padding: 12px 14px;
    background: #fbeede; border-radius: 10px;
}
.step-ings.hidden { display: none; }
.step-ings-label { font-size: .8rem; font-weight: 700; color: var(--accent-dark); width: 100%; }
.ing-chip {
    background: #fff; border: 1px solid var(--line); border-radius: 999px;
    padding: 5px 12px; font-size: .95rem; font-weight: 600; color: var(--ink);
}

.step-timer { display: flex; align-items: center; gap: 14px; margin-bottom: 18px; }
.step-timer.hidden { display: none; }
.timer-btn {
    background: var(--accent); color: #fff; border: 0; padding: 10px 18px;
    border-radius: 999px; font-weight: 600; cursor: pointer;
}
.timer-btn.running { background: var(--accent-dark); }
.timer-display { font-variant-numeric: tabular-nums; font-size: 1.4rem; font-weight: 700; }
.timer-display.done { color: var(--ok); }

.step-nav { display: flex; justify-content: space-between; gap: 12px; }
.step-nav button {
    flex: 1; padding: 12px; border: 1px solid var(--line); background: #fff;
    border-radius: 10px; font-weight: 600; cursor: pointer; font-size: 1rem;
}
.step-nav .next { background: var(--accent); color: #fff; border-color: var(--accent); }
.step-nav button:disabled { opacity: .4; cursor: default; }
.hidden { display: none; }
.head-btns { display: flex; gap: 8px; }

/* Panel minutników */
.timers-panel {
    position: fixed; right: 16px; bottom: 16px; z-index: 9000; width: 250px;
    background: var(--card); border: 1px solid var(--line); border-radius: 14px;
    box-shadow: 0 8px 24px rgba(0,0,0,.18); padding: 10px; max-height: 70vh; overflow: auto;
}
.timers-head { font-weight: 700; font-size: .9rem; margin: 2px 4px 8px; color: var(--accent-dark); }
.timer { display: flex; align-items: center; gap: 8px; padding: 8px; border-radius: 10px; margin-bottom: 6px; background: var(--bg); }
.timer-info { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.timer-label { font-size: .75rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.timer-rem { font-size: 1.25rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.timer.done { background: #e6f4e8; }
.timer.done .timer-rem { color: var(--ok); }
.timer.done { animation: tflash 1s ease-in-out 3; }
@keyframes tflash { 50% { background: #bfe6c5; } }
.timer button {
    width: 34px; height: 34px; border: 1px solid var(--line); background: #fff;
    border-radius: 8px; cursor: pointer; font-size: 1rem; flex: 0 0 auto;
}
.timer button:hover { border-color: var(--accent); }
@media (max-width: 560px) { .timers-panel { left: 12px; right: 12px; width: auto; } }

/* Nagłówek steppera: licznik + przycisk pełnego ekranu */
.stepper-head { display: flex; align-items: center; justify-content: space-between; }
.fs-btn {
    background: transparent; border: 1px solid var(--line); color: var(--muted);
    border-radius: 10px; width: 44px; height: 44px; font-size: 1.2rem; cursor: pointer;
    flex: 0 0 auto;
}
.fs-btn:hover { color: var(--accent); border-color: var(--accent); }

/* ============================================================
   TABLETY — większe pola dotykowe, oba ułożenia ekranu
   ============================================================ */
@media (min-width: 600px) and (max-width: 1200px) {
    .container { max-width: 100%; padding: 0 28px; }

    /* Większe cele dotykowe */
    .btn { padding: 12px 22px; font-size: 1.05rem; }
    .step-nav button { padding: 18px; font-size: 1.15rem; min-height: 60px; }
    .timer-btn { padding: 14px 24px; font-size: 1.1rem; }
    .fs-btn { width: 52px; height: 52px; font-size: 1.4rem; }

    /* Składniki — wygodne do odhaczania palcem */
    .ing-list li { padding: 12px 12px; font-size: 1.1rem; }
    .ing-list input[type="checkbox"] { width: 26px; height: 26px; }

    .step-text { font-size: 1.5rem; }
    .card-img { height: 180px; }
    .chip { padding: 12px 20px; font-size: 1.05rem; }
}

/* Tablet w pionie — jedna kolumna, treść na pełną szerokość */
@media (max-width: 900px) and (orientation: portrait) {
    .columns { grid-template-columns: 1fr; gap: 24px; }
    .ingredients { order: 2; }
    .cooking { order: 1; }
    .step-text { font-size: 1.6rem; min-height: 2.5em; }
}

/* Tablet w poziomie — dwie kolumny, składniki obok kroków */
@media (min-width: 700px) and (max-width: 1200px) and (orientation: landscape) {
    .columns { grid-template-columns: 320px 1fr; }
    .step-text { font-size: 1.55rem; }
}

/* ============================================================
   TRYB PEŁNOEKRANOWY KROKU
   ============================================================ */
.stepper:fullscreen {
    background: var(--bg);
    padding: 6vh 8vw;
    display: flex;
    flex-direction: column;
    justify-content: center;
    box-shadow: none;
    border-radius: 0;
}
.stepper:fullscreen .progress { height: 10px; margin-bottom: 4vh; }
.stepper:fullscreen .step-counter { font-size: 1.4rem; }
.stepper:fullscreen .step-section { font-size: 1.8rem; }
.stepper:fullscreen .step-text {
    font-size: clamp(2rem, 5vw, 3.4rem);
    line-height: 1.4;
    min-height: auto;
    margin: 4vh 0;
    flex: 0 0 auto;
}
.stepper:fullscreen .step-ings { margin-bottom: 3vh; padding: 18px 22px; }
.stepper:fullscreen .step-ings-label { font-size: 1.2rem; }
.stepper:fullscreen .ing-chip { font-size: 1.4rem; padding: 10px 20px; }
.stepper:fullscreen .step-timer { margin-bottom: 4vh; }
.stepper:fullscreen .timer-btn { padding: 18px 34px; font-size: 1.5rem; }
.stepper:fullscreen .timer-display { font-size: 2.4rem; }
.stepper:fullscreen .step-nav button {
    padding: 26px; font-size: 1.6rem; min-height: 80px;
}
.stepper:fullscreen .fs-btn { width: 60px; height: 60px; font-size: 1.6rem; }

/* Wariant zapasowy, gdy Fullscreen API niedostępne (klasa nakładana z JS) */
.stepper.fs-fallback {
    position: fixed; inset: 0; z-index: 9999;
    background: var(--bg); padding: 6vh 8vw; border-radius: 0;
    display: flex; flex-direction: column; justify-content: center; overflow: auto;
}
.stepper.fs-fallback .step-text { font-size: clamp(2rem, 5vw, 3.4rem); line-height: 1.4; margin: 4vh 0; }
.stepper.fs-fallback .step-nav button { padding: 26px; font-size: 1.6rem; min-height: 80px; }
