/* Familien-Dashboard – mobile first */
:root {
    --green: #2f6f4f;
    --green-dark: #24573e;
    --green-light: #e7f2ec;
    --bg: #f6f5f1;
    --card: #ffffff;
    --text: #1f2421;
    --muted: #6b716d;
    --border: #dfdeda;
    --danger: #b3261e;
    --radius: 12px;
    --shadow: 0 1px 2px rgba(0, 0, 0, .06), 0 2px 8px rgba(0, 0, 0, .04);
    --tabbar-h: 64px;
    color-scheme: light;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
    margin: 0;
    font: 16px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    padding-bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 16px);
}
body.plain { padding-bottom: 0; }
a { color: var(--green); }
img { max-width: 100%; }
h1 { font-size: 1.6rem; margin: .4em 0 .5em; line-height: 1.2; }
h2 { font-size: 1.15rem; margin: 0 0 .5em; }
h3 { font-size: 1rem; margin: 1em 0 .4em; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }

/* ---------- Layout */
.container { max-width: 960px; margin: 0 auto; padding: 0 16px; }
.container.narrow { max-width: 420px; }
.topbar {
    position: sticky; top: 0; z-index: 10;
    display: flex; align-items: center; justify-content: space-between;
    background: var(--green); color: #fff;
    padding: calc(10px + env(safe-area-inset-top)) 16px 10px;
}
.brand { color: #fff; font-weight: 700; text-decoration: none; font-size: 1.1rem; }
.topnav { display: none; gap: 4px; }
.topnav a { color: #fff; text-decoration: none; padding: 6px 12px; border-radius: 8px; opacity: .85; }
.topnav a.active, .topnav a:hover { background: rgba(255, 255, 255, .18); opacity: 1; }

.tabbar {
    position: fixed; bottom: 0; left: 0; right: 0; z-index: 10;
    display: flex; background: #fff; border-top: 1px solid var(--border);
    padding-bottom: env(safe-area-inset-bottom);
}
.tabbar a {
    flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
    height: var(--tabbar-h); color: var(--muted); text-decoration: none; font-size: .75rem;
}
.tabbar a.active { color: var(--green); font-weight: 600; }
.tab-icon { font-size: 1.35rem; line-height: 1.2; }

@media (min-width: 760px) {
    .topnav { display: flex; }
    .tabbar { display: none; }
    body { padding-bottom: 40px; }
}

.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.back { margin: 12px 0 0; }
.back a { text-decoration: none; }
.card {
    background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
    padding: 16px; margin: 12px 0;
}
.stack { display: flex; flex-direction: column; gap: 12px; }
.stack > .card { margin: 0; }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; align-items: end; }
.row.four { grid-template-columns: 1fr 1fr; }
@media (min-width: 600px) { .row.four { grid-template-columns: repeat(4, 1fr); } }
.actions { display: flex; flex-wrap: wrap; gap: 8px; margin: 16px 0; align-items: center; }
.actions form { margin: 0; }
.sticky-actions {
    position: sticky; bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom));
    background: var(--bg); padding: 10px 0; margin: 0; z-index: 5;
}
@media (min-width: 760px) { .sticky-actions { bottom: 0; } }
.empty { text-align: center; padding: 28px 16px; }

/* ---------- Forms */
label { display: flex; flex-direction: column; gap: 4px; font-weight: 600; font-size: .9rem; }
label.checkbox { flex-direction: row; align-items: center; gap: 8px; font-weight: 400; }
input[type=text], input[type=password], input[type=url], input[type=number], input[type=search], input[type=date], select, textarea {
    width: 100%; font: inherit; font-weight: 400; color: inherit;
    padding: 10px 12px; border: 1px solid var(--border); border-radius: 10px; background: #fff;
    min-height: 44px;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--green); outline-offset: -1px; border-color: var(--green); }
textarea { resize: vertical; }
input[type=checkbox], input[type=radio] { width: 20px; height: 20px; accent-color: var(--green); flex: none; }

.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    min-height: 44px; padding: 8px 16px; border-radius: 10px;
    border: 1px solid var(--border); background: #fff; color: var(--text);
    font: inherit; font-weight: 600; text-decoration: none; cursor: pointer;
}
.btn:hover { border-color: var(--green); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--green); border-color: var(--green); color: #fff; }
.btn-primary:hover { background: var(--green-dark); }
.btn-danger { color: var(--danger); }
.btn-danger:hover { border-color: var(--danger); }
.btn-small { min-height: 36px; min-width: 36px; padding: 4px 10px; font-size: .9rem; }
.btn-ghost { border-color: transparent; background: transparent; color: var(--muted); }

.flash { padding: 12px 14px; border-radius: 10px; margin: 12px 0; background: var(--green-light); border: 1px solid #bfdccb; }
.flash-error { background: #fdecea; border-color: #f3c3bf; color: #7a1a14; }

.login-card { margin-top: 15vh; }
.logout-form { margin: 16px 0; }

/* ---------- Chips & tags */
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0; }
.chip {
    display: inline-flex; align-items: center; gap: 4px;
    padding: 6px 12px; border-radius: 999px; border: 1px solid var(--border);
    background: #fff; color: var(--text); text-decoration: none; font: inherit; font-size: .9rem; cursor: pointer;
}
.chip.active { background: var(--green); border-color: var(--green); color: #fff; }
.chip.active .muted { color: #d5e9de; }
.chips.small .chip { padding: 3px 10px; font-size: .8rem; }
.tags { display: flex; flex-wrap: wrap; gap: 4px; margin: 6px 0; }
.tag { font-size: .75rem; padding: 2px 8px; border-radius: 999px; background: var(--green-light); color: var(--green-dark); text-decoration: none; }
.meta { display: flex; flex-wrap: wrap; gap: 4px 12px; color: var(--muted); font-size: .85rem; }
.badge { font-size: .7rem; background: var(--green); color: #fff; padding: 2px 8px; border-radius: 999px; vertical-align: middle; }

/* ---------- Recipes */
.searchbar { display: flex; gap: 8px; margin: 8px 0; }
.recipe-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 12px; margin: 12px 0; }
@media (min-width: 600px) { .recipe-grid { grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); } }
.recipe-card {
    display: flex; flex-direction: column; background: var(--card); border-radius: var(--radius);
    box-shadow: var(--shadow); overflow: hidden; color: inherit; text-decoration: none;
}
.recipe-card img, .photo-placeholder { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; display: block; }
.photo-placeholder { display: flex; align-items: center; justify-content: center; font-size: 2.5rem; background: var(--green-light); }
.recipe-card-body { padding: 10px 12px 12px; display: flex; flex-direction: column; gap: 4px; }

.recipe-photo { width: 100%; max-height: 360px; object-fit: cover; border-radius: var(--radius); margin-top: 12px; }
.description { font-size: 1.05rem; }
.section-head { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 8px; }
.section-head h2 { margin: 0; }
.portion-control { flex-direction: row; align-items: center; gap: 6px; font-weight: 400; }
.portion-control input { width: 64px; text-align: center; padding: 6px; min-height: 36px; }
.ingredients { list-style: none; padding: 0; margin: 12px 0 0; }
.ingredients li { display: grid; grid-template-columns: 7.5em 1fr; gap: 8px; padding: 7px 0; border-bottom: 1px solid var(--border); }
.ingredients li:last-child { border-bottom: 0; }
.qty { font-weight: 600; text-align: right; }
.nutrition { width: 100%; border-collapse: collapse; font-size: .9rem; }
.nutrition th, .nutrition td { text-align: left; padding: 6px 4px; border-bottom: 1px solid var(--border); }
.nutrition thead th { color: var(--muted); font-weight: 400; }
.instructions { white-space: normal; }

.form-photo { max-width: 240px; border-radius: 10px; }
.ingredient-rows { display: flex; flex-direction: column; gap: 10px; }
.ingredient-head { display: none; }
.ingredient-row {
    display: grid; grid-template-columns: 5.5em 5.5em 1fr; gap: 6px;
    padding-bottom: 10px; border-bottom: 1px dashed var(--border);
}
.ingredient-row input[name="ing_note[]"] { grid-column: 1 / 3; }
.row-buttons { display: flex; gap: 4px; justify-content: flex-end; }
@media (min-width: 760px) {
    .ingredient-head, .ingredient-row { display: grid; grid-template-columns: 6em 6em 1fr 12em auto; gap: 6px; }
    .ingredient-head { color: var(--muted); font-size: .8rem; }
    .ingredient-row { border-bottom: 0; padding-bottom: 0; }
    .ingredient-row input[name="ing_note[]"] { grid-column: auto; }
}

/* ---------- Week plan */
.week-nav { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin: 8px 0 12px; }
.week-label { text-align: center; display: flex; flex-direction: column; }
.week { display: flex; flex-direction: column; gap: 10px; }
.day { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 12px 14px; scroll-margin-top: 70px; }
.day.today { outline: 2px solid var(--green); }
.day.past { opacity: .7; }
.day h2 { font-size: 1rem; margin-bottom: 6px; }
.slots { display: flex; flex-direction: column; gap: 6px; }
.slot { display: grid; grid-template-columns: 4.2em 1fr auto; align-items: center; gap: 8px; min-height: 44px; }
.slot-label { color: var(--muted); font-size: .85rem; }
.slot-main { display: flex; align-items: center; gap: 10px; color: inherit; text-decoration: none; font-weight: 600; min-height: 44px; }
.slot-main img { width: 44px; height: 44px; object-fit: cover; border-radius: 8px; flex: none; }
.slot-main.free { font-style: italic; font-weight: 400; }
.slot-main.add { color: var(--green); font-weight: 400; border: 1px dashed var(--border); border-radius: 10px; padding: 0 12px; grid-column: 2 / 4; }
.slot-edit { color: var(--muted); text-decoration: none; padding: 8px 10px; font-size: 1.1rem; }
@media (min-width: 900px) {
    .week { display: grid; grid-template-columns: repeat(7, 1fr); gap: 8px; }
    .day { padding: 10px; }
    .slot { grid-template-columns: 1fr auto; }
    .slot-label { grid-column: 1 / 3; }
    .slot-main.add { grid-column: 1 / 3; }
    .slot-main { font-size: .9rem; }
}

.choice-list { display: flex; flex-direction: column; max-height: 50vh; overflow-y: auto; border: 1px solid var(--border); border-radius: 10px; }
.choice { flex-direction: row; align-items: center; gap: 10px; padding: 10px 12px; border-bottom: 1px solid var(--border); font-weight: 400; cursor: pointer; }
.choice:last-child { border-bottom: 0; }
.choice:has(input:checked) { background: var(--green-light); font-weight: 600; }

.slot-filter { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.proposal-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 8px; }
.proposal-list li { display: flex; align-items: center; gap: 8px; background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 8px 12px; }
.proposal-take { flex: 1; flex-direction: row; align-items: center; gap: 10px; font-weight: 400; cursor: pointer; }
.proposal-take img { width: 44px; height: 44px; object-fit: cover; border-radius: 8px; }
.proposal-when { color: var(--muted); font-size: .85rem; min-width: 6.5em; }
.proposal-name { font-weight: 600; }

/* ---------- Shopping list */
.generate-box { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.add-item { display: flex; gap: 8px; margin: 12px 0; }
.shopping-list { list-style: none; padding: 0; margin: 0; background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); }
.shopping-list li { display: flex; align-items: center; gap: 4px; padding: 2px 6px 2px 14px; border-bottom: 1px solid var(--border); }
.shopping-list li:last-child { border-bottom: 0; }
.shopping-list form { margin: 0; }
.check-form { flex: 1; }
.check-form label { flex-direction: row; align-items: center; gap: 12px; font-weight: 400; font-size: 1rem; min-height: 48px; cursor: pointer; }
.shopping-list li.checked .item-text { text-decoration: line-through; color: var(--muted); }
