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

:root {
    --green:   #16a34a;
    --green-d: #15803d;
    --green-l: #dcfce7;
    --bg:      #fafaf9;
    --surface: #ffffff;
    --border:  #e5e7eb;
    --text:    #1a1a1a;
    --muted:   #6b7280;
    --radius:  10px;
}

body { font-family: system-ui, -apple-system, sans-serif; background: var(--bg); color: var(--text); margin: 0; font-size: 16px; }

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

/* ── Layout ── */
.site-header { background: var(--surface); border-bottom: 1px solid var(--border); padding: .8rem 1.5rem; display: flex; align-items: center; gap: 1rem; position: sticky; top: 0; z-index: 50; }
.site-header .logo { font-weight: 700; font-size: 1.1rem; color: var(--green); text-decoration: none; flex: none; }
.site-header .logo:hover { text-decoration: none; }
.search-form { flex: 1; display: flex; gap: .5rem; max-width: 480px; }
.search-form input { flex: 1; padding: .45rem .8rem; border: 1px solid var(--border); border-radius: 6px; font-size: .9rem; background: var(--bg); }
.search-form button { background: var(--green); color: #fff; border: none; padding: .45rem .9rem; border-radius: 6px; cursor: pointer; font-size: .9rem; }
.header-nav { display: flex; gap: .8rem; align-items: center; font-size: .85rem; margin-left: auto; }
.header-nav a { color: var(--muted); }
.header-nav a:hover { color: var(--text); text-decoration: none; }

.container { max-width: 1100px; margin: 0 auto; padding: 1.5rem 1.2rem; }

/* ── Category pills ── */
.cat-pills { display: flex; gap: .5rem; flex-wrap: wrap; margin-bottom: 1.5rem; }
.cat-pill { display: inline-block; padding: .3rem .8rem; border-radius: 99px; background: var(--surface); border: 1px solid var(--border); font-size: .82rem; color: var(--muted); text-decoration: none; white-space: nowrap; }
.cat-pill:hover { border-color: var(--green); color: var(--green); text-decoration: none; }
.cat-pill.active { background: var(--green); border-color: var(--green); color: #fff; }

/* ── Recipe grid ── */
.recipe-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 1.2rem; }
.recipe-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; text-decoration: none; color: inherit; display: flex; flex-direction: column; transition: box-shadow .15s, transform .15s; }
.recipe-card:hover { box-shadow: 0 4px 16px rgba(0,0,0,.1); transform: translateY(-2px); text-decoration: none; }
.recipe-card .card-img { aspect-ratio: 4/3; background: #f0fdf4; display: flex; align-items: center; justify-content: center; font-size: 3rem; overflow: hidden; }
.recipe-card .card-img img { width: 100%; height: 100%; object-fit: cover; }
.recipe-card .card-body { padding: .9rem 1rem; flex: 1; display: flex; flex-direction: column; }
.recipe-card h3 { margin: 0 0 .3rem; font-size: .98rem; font-weight: 600; line-height: 1.3; }
.recipe-card .card-meta { margin-top: auto; font-size: .78rem; color: var(--muted); display: flex; gap: .6rem; flex-wrap: wrap; margin-top: .5rem; }
.recipe-card .cat-badge { background: var(--green-l); color: var(--green-d); border-radius: 99px; padding: .1rem .5rem; font-size: .75rem; font-weight: 500; }
.rating-badge { color: #f59e0b; letter-spacing: -.05em; }
.recipe-rating { color: #f59e0b; font-weight: 600; }

/* ── Star picker (admin form) ── */
.star-picker { display: flex; align-items: center; gap: .2rem; padding: .25rem 0; }
.star-picker input[type=radio] { display: none; }
.star-btn { font-size: 2rem; color: #d1d5db; cursor: pointer; line-height: 1; transition: color .1s; user-select: none; }
.star-btn.lit { color: #f59e0b; }
.star-none-btn { font-size: .83rem; color: var(--muted); cursor: pointer; margin-left: .7rem; padding: .2rem .55rem; border: 1px solid var(--border); border-radius: 5px; }
.star-none-btn:hover { border-color: var(--green); color: var(--text); }

.empty-state { text-align: center; padding: 4rem 1rem; color: var(--muted); }
.empty-state p { font-size: 1rem; margin-top: .5rem; }

/* ── Recipe detail ── */
.recipe-hero { max-height: 340px; overflow: hidden; border-radius: var(--radius); margin-bottom: 1.5rem; }
.recipe-hero img { width: 100%; height: 340px; object-fit: cover; display: block; }
.recipe-title-row { display: flex; align-items: flex-start; gap: 1rem; flex-wrap: wrap; margin-bottom: 1rem; }
.recipe-title-row h1 { margin: 0; flex: 1; font-size: 1.8rem; line-height: 1.2; }
.export-btns { display: flex; gap: .4rem; flex-shrink: 0; }
.btn-export { padding: .35rem .75rem; border: 1px solid var(--border); border-radius: 6px; font-size: .8rem; color: var(--muted); background: var(--surface); text-decoration: none; }
.btn-export:hover { border-color: var(--green); color: var(--green); text-decoration: none; }
.recipe-meta { display: flex; gap: 1.5rem; flex-wrap: wrap; font-size: .88rem; color: var(--muted); margin-bottom: 1rem; }
.recipe-meta span { display: flex; align-items: center; gap: .3rem; }
.recipe-desc { color: #374151; line-height: 1.6; margin-bottom: 1.5rem; }
.recipe-body { display: grid; grid-template-columns: 300px 1fr; gap: 2.5rem; }
@media (max-width: 720px) { .recipe-body { grid-template-columns: 1fr; } }
.ingredients-box { background: var(--green-l); border-radius: var(--radius); padding: 1.2rem 1.4rem; }
.ingredients-box h2 { margin: 0 0 .8rem; font-size: 1rem; color: var(--green-d); }
.ingredients-box ul { margin: 0; padding: 0; list-style: none; }
.ingredients-box li { padding: .35rem 0; border-bottom: 1px solid rgba(0,0,0,.06); font-size: .92rem; display: flex; gap: .5rem; }
.ingredients-box li:last-child { border-bottom: none; }
.ing-qty { font-weight: 600; white-space: nowrap; }
.steps-box h2 { margin: 0 0 .8rem; font-size: 1rem; color: var(--green-d); }
.steps-box ol { margin: 0; padding-left: 1.4rem; }
.steps-box li { margin-bottom: 1rem; line-height: 1.6; font-size: .95rem; }
.back-link { display: inline-block; margin-bottom: 1.2rem; font-size: .85rem; color: var(--muted); }
.back-link:hover { color: var(--text); }

/* ── Menu detail ── */
.menu-header h1 { margin: 0 0 .3rem; }
.menu-date { color: var(--muted); font-size: .9rem; margin-bottom: .8rem; }
.menu-recipes { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: .8rem; margin-bottom: 2rem; }
.menu-recipe-card { background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: .8rem; font-size: .88rem; }
.menu-recipe-card a { font-weight: 600; }
.prep-timeline h2 { font-size: 1rem; color: var(--green-d); margin-bottom: .8rem; }
.prep-day-label { font-size: .78rem; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; margin: .9rem 0 .3rem; }
.prep-day-label:first-of-type { margin-top: 0; }
.prep-list { list-style: none; margin: 0 0 .5rem; padding: 0; }
.prep-list li { display: flex; gap: 1rem; padding: .6rem 0; border-bottom: 1px solid var(--border); font-size: .9rem; }
.prep-list li:last-child { border-bottom: none; }
.prep-time { font-weight: 700; color: var(--green); min-width: 55px; }

/* ── Admin ── */
.admin-header { display: flex; align-items: center; gap: 1rem; margin-bottom: 1.5rem; flex-wrap: wrap; }
.admin-header h1 { margin: 0; flex: 1; font-size: 1.3rem; }
.btn { display: inline-flex; align-items: center; gap: .3rem; padding: .45rem 1rem; border-radius: 6px; border: none; cursor: pointer; font-size: .88rem; text-decoration: none; font-weight: 500; }
.btn:hover { text-decoration: none; }
.btn-primary { background: var(--green); color: #fff; }
.btn-primary:hover { background: var(--green-d); }
.btn-secondary { background: var(--surface); border: 1px solid var(--border); color: var(--text); }
.btn-danger { background: #dc2626; color: #fff; }
.btn-sm { padding: .25rem .6rem; font-size: .78rem; }
table.admin-table { width: 100%; border-collapse: collapse; background: var(--surface); border-radius: var(--radius); overflow: hidden; box-shadow: 0 1px 4px rgba(0,0,0,.07); margin-bottom: 2rem; }
table.admin-table th, table.admin-table td { padding: .65rem 1rem; text-align: left; font-size: .88rem; border-bottom: 1px solid var(--border); }
table.admin-table th { background: #f9fafb; font-weight: 600; border-bottom: 2px solid var(--border); }
table.admin-table tr:last-child td { border-bottom: none; }
.actions { display: flex; gap: .4rem; }
form.inline { display: inline; }
.msg { background: #d1fae5; border: 1px solid #6ee7b7; border-radius: 6px; padding: .6rem 1rem; margin-bottom: 1rem; font-size: .9rem; }

/* ── Forms ── */
.form-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.5rem; max-width: 780px; }
.form-section { margin-bottom: 1.5rem; }
.form-section h2 { font-size: .95rem; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; margin: 0 0 .8rem; border-bottom: 1px solid var(--border); padding-bottom: .4rem; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: .8rem 1rem; }
.form-grid.cols-3 { grid-template-columns: 1fr 1fr 1fr; }
@media (max-width: 560px) { .form-grid { grid-template-columns: 1fr; } .form-grid.cols-3 { grid-template-columns: 1fr; } }
.field { display: flex; flex-direction: column; gap: .3rem; }
.field label { font-size: .85rem; font-weight: 500; color: #374151; }
.field input, .field select, .field textarea { padding: .5rem .7rem; border: 1px solid var(--border); border-radius: 6px; font-size: .9rem; background: var(--bg); font-family: inherit; }
.field textarea { resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus { outline: 2px solid var(--green); outline-offset: 1px; border-color: var(--green); }
.field.full { grid-column: 1/-1; }
.image-preview { max-width: 200px; max-height: 140px; border-radius: 6px; margin-top: .4rem; object-fit: cover; }

/* Ingredients / steps rows */
.rows-container { display: flex; flex-direction: column; gap: .5rem; }
.ing-row, .step-row, .prep-row { display: flex; gap: .5rem; align-items: center; }
.ing-row input { padding: .4rem .6rem; border: 1px solid var(--border); border-radius: 6px; font-size: .88rem; background: var(--bg); }
.ing-row .qty  { width: 80px; flex: none; }
.ing-row .unit { width: 80px; flex: none; }
.ing-row .name { flex: 1; }
.step-row .step-num { font-weight: 700; color: var(--green); min-width: 24px; text-align: right; flex: none; }
.step-row textarea { flex: 1; padding: .4rem .6rem; border: 1px solid var(--border); border-radius: 6px; font-size: .88rem; background: var(--bg); font-family: inherit; resize: vertical; min-height: 56px; }
.prep-row select { width: 130px; flex: none; padding: .4rem .5rem; border: 1px solid var(--border); border-radius: 6px; font-size: .88rem; background: var(--bg); font-family: inherit; }
.prep-row input[type=time] { width: 100px; flex: none; padding: .4rem .6rem; border: 1px solid var(--border); border-radius: 6px; font-size: .88rem; background: var(--bg); }
.prep-row input[type=text] { flex: 1; padding: .4rem .6rem; border: 1px solid var(--border); border-radius: 6px; font-size: .88rem; background: var(--bg); }
.btn-remove { background: none; border: 1px solid #fca5a5; color: #dc2626; border-radius: 5px; padding: .3rem .5rem; cursor: pointer; font-size: .82rem; flex: none; }
.btn-remove:hover { background: #fee2e2; }
.btn-add-row { background: none; border: 1px dashed var(--green); color: var(--green); border-radius: 6px; padding: .4rem .9rem; cursor: pointer; font-size: .85rem; margin-top: .4rem; }
.btn-add-row:hover { background: var(--green-l); }
.form-actions { display: flex; gap: .6rem; margin-top: 1.5rem; }

/* Recipe checkboxes in menu form */
.recipe-checklist { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: .4rem; }
.recipe-check-item { display: flex; align-items: center; gap: .5rem; padding: .4rem .6rem; border: 1px solid var(--border); border-radius: 6px; font-size: .85rem; cursor: pointer; }
.recipe-check-item:hover { border-color: var(--green); background: var(--green-l); }
.recipe-check-item input { margin: 0; }

/* ── Login ── */
.login-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; }
.login-box { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 2.5rem; max-width: 380px; width: 100%; }
.login-box h1 { margin: 0 0 1.5rem; font-size: 1.4rem; text-align: center; }
.login-box label { display: block; font-size: .85rem; font-weight: 500; margin-bottom: 1rem; }
.login-box input[type=text], .login-box input[type=password] { display: block; width: 100%; margin-top: .3rem; padding: .5rem .7rem; border: 1px solid var(--border); border-radius: 6px; font-size: .95rem; }
.login-box .remember-row { display: flex; align-items: center; gap: .5rem; font-size: .85rem; margin-bottom: .8rem; }
.login-box .remember-row input { width: auto; margin: 0; }
.btn-login { width: 100%; background: var(--green); color: #fff; border: none; padding: .6rem; border-radius: 6px; font-size: 1rem; font-weight: 600; cursor: pointer; }
.btn-login:hover { background: var(--green-d); }
.error { background: #fee2e2; color: #991b1b; border-radius: 6px; padding: .6rem .9rem; font-size: .88rem; margin-bottom: 1rem; }

/* ── Mobile ── */
@media (max-width: 600px) {
    /* Header: search wraps to full-width second row */
    .site-header { flex-wrap: wrap; padding: .65rem 1rem; gap: .4rem .8rem; }
    .search-form { order: 3; flex: 0 0 100%; max-width: 100%; }
    .header-nav { margin-left: 0; }

    /* Less container padding */
    .container { padding: 1rem .85rem; }

    /* Recipe detail title */
    .recipe-title-row h1 { font-size: 1.45rem; }

    /* Form card */
    .form-card { padding: 1.1rem .9rem; }

    /* Prep-row: [dag select + time + delete] on row 1, [description] on row 2 */
    .prep-row { flex-wrap: wrap; }
    .prep-row select { flex: 1; width: auto; order: 1; }
    .prep-row input[type=time] { width: 90px; order: 2; }
    .prep-row .btn-remove { order: 3; }
    .prep-row input[type=text] { flex: 0 0 100%; order: 4; }

    /* Ingredient rows: tighter fixed columns so name gets more room */
    .ing-row .qty  { width: 58px; }
    .ing-row .unit { width: 58px; }

    /* Admin table: horizontal scroll instead of overflow */
    table.admin-table { display: block; overflow-x: auto; -webkit-overflow-scrolling: touch; white-space: nowrap; }
    table.admin-table th, table.admin-table td { white-space: normal; }
}
