:root {
    --ink: #173d37;
    --ink-dark: #0f2925;
    --cream: #f8f4ec;
    --surface: #fffdf8;
    --gold: #f3bb52;
    --muted: #5e6963;
    --line: #d8ded7;
    --shadow: 0 10px 30px rgba(22, 50, 44, .14);
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    color: var(--ink);
    background: var(--cream);
}

* { box-sizing: border-box; }
body { margin: 0; min-width: 320px; background: var(--cream); }
button { font: inherit; }

.app { min-height: 100vh; }
.page { width: min(1180px, calc(100% - 48px)); margin: 0 auto; padding: 28px 0 40px; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 20px; margin-bottom: 28px; }
.resume-panel { display: flex; align-items: center; justify-content: space-between; gap: 20px; margin-bottom: 24px; padding: 18px 24px; border-radius: 18px; background: var(--surface); box-shadow: var(--shadow); }
.resume-panel p { margin: 6px 0 0; color: var(--muted); }
.brand { margin: 0; font: 700 clamp(2rem, 4vw, 3.35rem)/1.02 Georgia, serif; letter-spacing: -.04em; }
.eyebrow { margin: 0 0 7px; color: var(--muted); font-weight: 700; letter-spacing: .08em; text-transform: uppercase; font-size: .82rem; }

.recipe-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(245px, 1fr)); gap: 20px; }
.recipe-card { display: flex; min-height: 325px; padding: 0; border: 0; border-radius: 22px; overflow: hidden; background: var(--ink) center / contain no-repeat; box-shadow: var(--shadow); color: white; text-align: left; cursor: pointer; transition: transform .16s ease, box-shadow .16s ease; }
.recipe-card:hover, .recipe-card:focus-visible { transform: translateY(-4px); box-shadow: 0 16px 36px rgba(22, 50, 44, .23); outline: 4px solid var(--gold); outline-offset: 2px; }
.recipe-card__content { display: flex; flex: 1; flex-direction: column; justify-content: end; padding: 22px; background: linear-gradient(0deg, rgba(8, 25, 22, .95) 0%, rgba(8, 25, 22, .28) 62%, rgba(8, 25, 22, .05) 100%); }
.recipe-card__content h2 { margin: 0; font: 700 1.55rem/1.08 Georgia, serif; }
.recipe-card__meta, .chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.pill { display: inline-flex; align-items: center; min-height: 30px; padding: 4px 10px; border-radius: 999px; background: rgba(255, 255, 255, .18); font-size: .9rem; font-weight: 700; }

.button { display: inline-flex; min-height: 64px; align-items: center; justify-content: center; gap: 10px; border: 0; border-radius: 16px; padding: 12px 22px; background: var(--ink); color: #fff; font-weight: 800; cursor: pointer; box-shadow: 0 3px 0 rgba(0, 0, 0, .14); }
.button:hover, .button:focus-visible { background: var(--ink-dark); outline: 4px solid var(--gold); outline-offset: 3px; }
.button--gold { background: var(--gold); color: #20251f; }
.button--gold:hover, .button--gold:focus-visible { background: #f7cb77; }
.button--ghost { background: transparent; color: var(--ink); border: 2px solid var(--ink); box-shadow: none; }
.button:disabled { opacity: .38; cursor: not-allowed; }

.back-button { min-width: 64px; padding: 12px 16px; }
.hero { position: relative; min-height: 285px; display: flex; align-items: end; border-radius: 24px; overflow: hidden; background: var(--ink); box-shadow: var(--shadow); color: white; background-size: cover; background-position: center; }
.hero::before { content: ""; position: absolute; inset: 0; background: linear-gradient(90deg, rgba(8, 27, 23, .93), rgba(8, 27, 23, .24)); }
.hero__body { position: relative; width: min(700px, 100%); padding: 32px; }
.hero h1 { margin: 0; font: 700 clamp(2rem, 5vw, 4rem)/.98 Georgia, serif; letter-spacing: -.045em; }
.hero p { margin: 14px 0 0; font-size: 1.06rem; line-height: 1.45; }
.detail-layout { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(290px, .8fr); gap: 28px; margin-top: 28px; }
.panel { padding: 26px; border-radius: 22px; background: var(--surface); box-shadow: var(--shadow); }
.panel h2 { margin: 0; font: 700 1.9rem Georgia, serif; }
.ingredient-group + .ingredient-group { margin-top: 28px; }
.ingredient-group h3 { margin: 0 0 12px; color: var(--muted); font-size: 1rem; text-transform: uppercase; letter-spacing: .06em; }
.ingredient-list { list-style: none; padding: 0; margin: 0; }
.ingredient-list li { display: grid; grid-template-columns: minmax(66px, auto) 1fr; gap: 12px; align-items: baseline; padding: 11px 0; border-bottom: 1px solid var(--line); font-size: 1.08rem; }
.ingredient-list li:last-child { border-bottom: 0; }
.ingredient-amount { font-weight: 800; color: var(--ink); }
.summary { display: grid; gap: 13px; margin: 22px 0; }
.summary__row { display: flex; justify-content: space-between; gap: 16px; padding-bottom: 12px; border-bottom: 1px solid var(--line); }
.summary__row span { color: var(--muted); }
.full-width { width: 100%; }

.cook-page { min-height: 100vh; display: grid; grid-template-rows: auto 1fr auto; background: var(--cream); }
.cook-header, .cook-controls { width: min(1100px, calc(100% - 48px)); margin: 0 auto; display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.cook-header { padding: 20px 0; }
.progress { flex: 1; max-width: 350px; height: 13px; overflow: hidden; border-radius: 99px; background: #d7dfd7; }
.progress > span { display: block; height: 100%; border-radius: inherit; background: var(--gold); }
.font-controls { display: flex; gap: 8px; }
.font-control { min-width: 56px; min-height: 56px; border: 2px solid var(--ink); border-radius: 14px; background: var(--surface); color: var(--ink); font-weight: 900; cursor: pointer; }
.font-control:hover, .font-control:focus-visible { outline: 4px solid var(--gold); outline-offset: 2px; }
.font-control:disabled { opacity: .4; cursor: not-allowed; }
.step { width: min(950px, calc(100% - 48px)); align-self: center; margin: 0 auto; padding: 10px 0 20px; }
.step__image { height: min(37vh, 305px); border-radius: 24px; background: var(--ink) center / cover no-repeat; box-shadow: var(--shadow); }
.step__image--button { position: relative; display: block; width: 100%; border: 0; cursor: pointer; }
.step__image--button:focus-visible { outline: 4px solid var(--gold); outline-offset: 3px; }
.step__image-hint { position: absolute; top: 14px; right: 14px; padding: 10px 14px; border-radius: 999px; background: rgba(8, 25, 22, .8); color: white; font-weight: 700; }
.image-viewer { position: fixed; z-index: 20; inset: 0; display: flex; align-items: center; justify-content: center; padding: 20px; background: rgba(0, 0, 0, .94); }
.image-viewer img { display: block; max-width: 100%; max-height: 100%; object-fit: contain; }
.image-viewer__close { position: absolute; top: max(16px, env(safe-area-inset-top)); right: max(16px, env(safe-area-inset-right)); width: 60px; height: 60px; border: 2px solid white; border-radius: 50%; background: rgba(0, 0, 0, .75); color: white; font-size: 2.5rem; line-height: 1; cursor: pointer; }
.image-viewer__close:focus-visible { outline: 4px solid var(--gold); outline-offset: 3px; }
.step__content { margin: -28px 24px 0; position: relative; padding: 28px clamp(20px, 4vw, 42px); border-radius: 22px; background: var(--surface); box-shadow: var(--shadow); }
.step__number { margin: 0 0 6px; color: var(--muted); font-weight: 800; }
.step h1 { margin: 0 0 20px; font: 700 clamp(2rem, 4vw, 3.4rem)/1 Georgia, serif; letter-spacing: -.04em; }
.step__content > p:not(.step__number) { margin: 0 0 14px; font-size: clamp(calc(1.1rem * var(--step-font-scale, 1)), calc(1.8vw * var(--step-font-scale, 1)), calc(1.35rem * var(--step-font-scale, 1))); line-height: 1.42; }
.step__content > p.highlighted { margin: 20px 0; padding: .8em 1em; border-radius: 14px; background: #f8d45f; color: #3a3214; font-weight: 750; box-shadow: inset 0 0 0 1px rgba(94, 72, 10, .18); }
.step__content > p:last-child { margin-bottom: 0; }
.cook-controls { padding: 20px 0 max(22px, env(safe-area-inset-bottom)); }
.cook-controls .button { min-width: 145px; }
.ingredients-modal { position: fixed; z-index: 10; inset: 0; display: grid; place-items: center; padding: 28px; background: rgba(8, 28, 24, .68); }
.ingredients-modal__dialog { width: min(650px, 100%); max-height: min(78vh, 700px); overflow: auto; padding: 26px; border-radius: 24px; background: var(--surface); box-shadow: 0 20px 60px rgba(0, 0, 0, .35); }
.ingredients-modal__header { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding-bottom: 16px; border-bottom: 1px solid var(--line); }
.ingredients-modal__header h2 { margin: 0; font: 700 2rem Georgia, serif; }
.modal-close { display: grid; width: 56px; height: 56px; place-items: center; flex: 0 0 auto; border: 2px solid var(--ink); border-radius: 50%; background: transparent; color: var(--ink); font-size: 2rem; line-height: 1; cursor: pointer; }
.modal-close:hover, .modal-close:focus-visible { outline: 4px solid var(--gold); outline-offset: 2px; }

.empty, .loading-screen { min-height: 62vh; display: grid; place-content: center; justify-items: center; gap: 16px; padding: 30px; text-align: center; }
.empty { color: var(--muted); }
.empty h1 { color: var(--ink); font: 700 2.3rem Georgia, serif; }
.loader { width: 38px; height: 38px; border: 5px solid #d6ded7; border-top-color: var(--ink); border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 720px) {
    .page, .cook-header, .cook-controls, .step { width: min(100% - 28px, 1180px); }
    .page { padding-top: 18px; }
    .detail-layout { grid-template-columns: 1fr; }
    .hero { min-height: 330px; }
    .hero__body { padding: 24px; }
    .recipe-grid { grid-template-columns: 1fr; }
    .resume-panel { flex-wrap: wrap; }
    .recipe-card { min-height: 260px; }
    .cook-controls .button { min-width: 0; flex: 1; }
    .cook-header .button { min-height: 54px; }
    .font-control { min-width: 50px; min-height: 50px; }
    .ingredients-modal { padding: 14px; }
    .ingredients-modal__dialog { max-height: 86vh; padding: 20px; }
    .step__content { margin-inline: 10px; }
}
