:root {
  --ink: #17201d;
  --muted: #68726e;
  --paper: #f5f7f4;
  --surface: #ffffff;
  --line: #dce3df;
  --green: #173f35;
  --mint: #dff2e9;
  --lime: #d7f06a;
  --shadow: 0 10px 30px rgba(23, 63, 53, 0.08);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--paper);
}

* { box-sizing: border-box; }
body { margin: 0; min-width: 320px; background: var(--paper); }
button, input { font: inherit; }
button { cursor: pointer; }
.app-shell { min-height: 100dvh; padding-bottom: calc(82px + env(safe-area-inset-bottom)); }
.topbar { display: flex; align-items: center; gap: 12px; padding: max(18px, env(safe-area-inset-top)) 20px 14px; background: var(--surface); border-bottom: 1px solid var(--line); }
.topbar .quiet-button { margin-left: auto; }
.brand-mark { width: 42px; height: 42px; border-radius: 14px; display: grid; place-items: center; background: var(--green); color: var(--lime); font-weight: 900; font-size: 1.25rem; }
.topbar h1, .section-heading h2 { margin: 0; letter-spacing: -0.035em; }
.topbar h1 { font-size: 1.25rem; }
.eyebrow { margin: 0 0 2px; color: var(--muted); font-size: .76rem; font-weight: 750; letter-spacing: .06em; text-transform: uppercase; }
.content { width: min(100%, 760px); margin: 0 auto; padding: 22px 16px 28px; }
.section-heading { display: grid; grid-template-columns: 1fr 42px 42px; gap: 8px; align-items: center; margin-bottom: 18px; }
.section-heading.simple { grid-template-columns: 1fr auto; }
.section-heading h2 { font-size: clamp(1.8rem, 7vw, 2.45rem); }
.icon-button { width: 42px; height: 42px; border: 1px solid var(--line); border-radius: 13px; background: var(--surface); color: var(--green); font-size: 1.65rem; }
.portion-card { display: flex; align-items: center; justify-content: space-between; gap: 18px; padding: 16px; margin-bottom: 16px; border-radius: 18px; background: var(--green); color: white; box-shadow: var(--shadow); }
.portion-card span { display: grid; gap: 3px; }
.portion-card small { color: #bed1ca; font-size: .78rem; }
.portion-card input { width: 72px; height: 50px; border: 0; border-radius: 13px; background: white; color: var(--green); text-align: center; font-size: 1.35rem; font-weight: 850; }
.day-list { display: grid; gap: 10px; }
.day-card { display: grid; grid-template-columns: 61px 1fr; min-height: 82px; overflow: hidden; border: 1px solid var(--line); border-radius: 18px; background: var(--surface); box-shadow: 0 4px 14px rgba(23, 63, 53, .035); }
.day-date { display: grid; align-content: center; justify-items: center; gap: 2px; background: var(--mint); color: var(--green); }
.day-date strong { font-size: 1rem; }
.day-date span { font-size: .72rem; }
.meal-select { display: grid; align-content: center; gap: 5px; width: 100%; padding: 14px 16px; text-align: left; border: 0; background: transparent; color: var(--ink); }
.meal-select span { font-size: 1rem; font-weight: 760; }
.meal-select small { color: var(--muted); font-size: .8rem; }
.primary-action { display: flex; align-items: center; justify-content: space-between; width: 100%; min-height: 56px; margin-top: 18px; padding: 0 18px; border: 0; border-radius: 17px; background: var(--lime); color: #18362f; font-weight: 850; box-shadow: var(--shadow); }
.primary-action span { font-size: 1.4rem; }
.screen { display: none; }
.screen.active { display: block; animation: rise .22s ease-out; }
.hidden { display: none !important; }
.quiet-button { min-height: 38px; padding: 0 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); color: var(--green); font-size: .78rem; font-weight: 800; }
.round-add { width: 46px; height: 46px; border: 0; border-radius: 15px; background: var(--lime); color: var(--green); font-size: 1.75rem; }
.search-field { display: flex; align-items: center; gap: 10px; min-height: 52px; padding: 0 15px; margin-bottom: 16px; border: 1px solid var(--line); border-radius: 16px; background: var(--surface); }
.search-field input { width: 100%; border: 0; outline: 0; background: transparent; font-size: 1rem; }
.recipe-list { display: grid; gap: 10px; }
.recipe-card { display: grid; grid-template-columns: 48px 1fr auto; gap: 13px; align-items: center; padding: 14px; border: 1px solid var(--line); border-radius: 17px; background: var(--surface); }
.recipe-letter { display: grid; place-items: center; width: 48px; height: 48px; border-radius: 14px; background: var(--mint); color: var(--green); font-size: 1.15rem; font-weight: 900; }
.recipe-card h3, .recipe-card p { margin: 0; }
.recipe-card h3 { font-size: 1rem; }
.recipe-card p { margin-top: 3px; color: var(--muted); font-size: .83rem; }
.recipe-card small { display: block; margin-top: 6px; color: var(--muted); font-size: .72rem; }
.recipe-actions { display: flex; gap: 6px; }
.recipe-action { min-width: 42px; min-height: 42px; padding: 0 10px; border: 1px solid var(--line); border-radius: 12px; background: var(--paper); color: var(--green); font-size: .78rem; font-weight: 800; }
.summary-strip { display: grid; grid-template-columns: repeat(3,1fr); gap: 1px; overflow: hidden; margin-bottom: 18px; border-radius: 17px; background: var(--line); }
.summary-strip div { display: grid; justify-items: center; gap: 2px; padding: 13px 4px; background: var(--surface); }
.summary-strip strong { color: var(--green); font-size: 1.2rem; }
.summary-strip span { color: var(--muted); font-size: .7rem; }
.shopping-list { display: grid; gap: 20px; }
.shopping-group h3 { margin: 0 0 8px; color: var(--muted); font-size: .76rem; letter-spacing: .08em; text-transform: uppercase; }
.shopping-row { display: grid; grid-template-columns: 25px 1fr auto; gap: 10px; align-items: center; min-height: 52px; padding: 8px 12px; margin-bottom: 6px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); }
.shopping-row input { width: 20px; height: 20px; accent-color: var(--green); }
.shopping-row span { font-size: .92rem; }
.shopping-row strong { color: var(--green); font-size: .9rem; }
.shopping-row.checked span, .shopping-row.checked strong { color: #9ba39f; text-decoration: line-through; }
.stock-note { padding: 16px; margin-top: 20px; border-radius: 18px; background: var(--mint); }
.stock-note h3, .stock-note p { margin: 0; }
.stock-note p { margin-top: 5px; color: #476158; font-size: .83rem; }
.stock-note textarea { width: 100%; margin-top: 12px; padding: 12px; resize: vertical; border: 1px solid #c1dacf; border-radius: 12px; background: rgba(255,255,255,.78); font: inherit; font-size: .9rem; }
.output-grid { display: grid; gap: 13px; }
.output-card { display: grid; grid-template-columns: 52px 1fr; gap: 14px; padding: 17px; border: 1px solid var(--line); border-radius: 20px; background: var(--surface); box-shadow: var(--shadow); }
.output-card.accent { background: var(--green); color: white; }
.output-icon { display: grid; place-items: center; width: 52px; height: 52px; border-radius: 15px; background: var(--mint); color: var(--green); font-size: 1.35rem; font-weight: 900; }
.output-card h3, .output-card p { margin: 0; }
.output-card p { margin-top: 5px; color: var(--muted); font-size: .82rem; line-height: 1.45; }
.output-card.accent p { color: #bfd0ca; }
.secondary-action { grid-column: 1 / -1; min-height: 48px; border: 1px solid var(--line); border-radius: 14px; background: var(--paper); color: var(--green); font-weight: 850; }
.output-card.accent .secondary-action { border-color: var(--lime); background: var(--lime); }
.app-dialog { width: min(calc(100% - 24px),540px); max-height: min(82dvh,720px); margin: auto auto 0; padding: 18px; border: 0; border-radius: 24px 24px 0 0; background: var(--paper); color: var(--ink); }
.app-dialog::backdrop { background: rgba(8,25,20,.55); backdrop-filter: blur(2px); }
.dialog-head { display: flex; justify-content: space-between; gap: 15px; align-items: center; margin-bottom: 16px; }
.dialog-head h2 { margin: 0; }
.dialog-close { width: 42px; height: 42px; border: 0; border-radius: 13px; background: var(--surface); color: var(--green); font-size: 1.5rem; }
.meal-options { display: grid; gap: 8px; overflow-y: auto; max-height: 62dvh; }
.meal-option { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 68px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 15px; background: var(--surface); color: var(--ink); text-align: left; }
.meal-option span { display: grid; gap: 4px; }
.meal-option small { color: var(--muted); }
.meal-option.selected { border-color: var(--green); background: var(--mint); }
.meal-option b { color: var(--green); }
.field { display: grid; gap: 7px; margin-bottom: 14px; color: var(--green); font-size: .8rem; font-weight: 800; }
.field input, .field textarea { width: 100%; padding: 12px; border: 1px solid var(--line); border-radius: 13px; background: var(--surface); color: var(--ink); font: inherit; font-size: 1rem; font-weight: 450; }
.field small { color: var(--muted); font-size: .7rem; font-weight: 500; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.form-actions { display: grid; grid-template-columns: auto 1fr; gap: 10px; align-items: end; }
.form-actions .primary-action { margin-top: 0; }
.danger-action { min-height: 56px; padding: 0 16px; border: 1px solid #d9aaa4; border-radius: 17px; background: #fff3f1; color: #8b2921; font-weight: 800; }
.empty-state { display: grid; justify-items: center; gap: 5px; padding: 40px 20px; color: var(--muted); text-align: center; }
.toast { position: fixed; z-index: 30; left: 50%; bottom: 92px; max-width: calc(100% - 32px); padding: 11px 16px; border-radius: 13px; background: var(--ink); color: white; opacity: 0; transform: translate(-50%,15px); pointer-events: none; transition: .2s ease; font-size: .84rem; font-weight: 700; }
.toast.show { opacity: 1; transform: translate(-50%,0); }
@keyframes rise { from { opacity: 0; transform: translateY(5px); } }
.bottom-nav { position: fixed; z-index: 10; left: 0; right: 0; bottom: 0; display: grid; grid-template-columns: repeat(4, 1fr); padding: 8px 8px calc(8px + env(safe-area-inset-bottom)); background: rgba(255,255,255,.96); border-top: 1px solid var(--line); backdrop-filter: blur(14px); }
.nav-item { display: grid; justify-items: center; gap: 3px; min-height: 55px; padding: 6px 2px; border: 0; border-radius: 13px; background: transparent; color: var(--muted); font-size: .68rem; font-weight: 720; }
.nav-item span { font-size: 1.25rem; line-height: 1; }
.nav-item.active { background: var(--mint); color: var(--green); }

@media (min-width: 720px) {
  .content { padding: 34px 24px; }
  .day-list { grid-template-columns: 1fr 1fr; }
  .day-card:last-child { grid-column: 1 / -1; }
}

@media (max-width: 480px) {
  .recipe-card { grid-template-columns: 48px 1fr; }
  .recipe-actions { grid-column: 2; }
  .form-actions { grid-template-columns: 1fr; }
}

@media print {
  .topbar, .bottom-nav, .primary-action, .icon-button, .portion-card, .quiet-button, .stock-note textarea { display: none !important; }
  .app-shell { padding: 0; }
  .content { width: 100%; padding: 0; }
  body { background: white; }
  body[data-print="plan"] .screen, body[data-print="shopping"] .screen { display: none !important; }
  body[data-print="plan"] #screen-plan, body[data-print="shopping"] #screen-shopping { display: block !important; }
  .day-card, .shopping-row, .stock-note { break-inside: avoid; box-shadow: none; }
}

.copy-week { margin-bottom: 14px; }
.copy-week:disabled { opacity: .45; cursor: default; }
.day-portions { grid-column: 2; display: flex; align-items: center; gap: 12px; padding: 0 16px 12px; color: var(--muted); font-size: .8rem; }
.day-portions input { width: 76px; padding: 8px; border: 1px solid var(--line); border-radius: 9px; background: white; color: var(--green); }
.day-date { grid-row: 1 / 3; }
.meal-select { min-width: 0; overflow-wrap: anywhere; }
@media print { .day-portions input { border: 0; padding: 0; } }
/* Recipe editor and backup controls follow the existing kitchen palette. */
.ingredients-editor { border: 0; padding: 0; margin: 20px 0; min-width: 0; }
.ingredients-editor legend { font-weight: 800; margin-bottom: 12px; color: var(--green); }
.ingredient-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; padding: 14px; margin-bottom: 12px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); }
.ingredient-row .field { margin: 0; min-width: 0; }
.ingredient-name, .ingredient-category { grid-column: 1 / -1; }
.ingredient-row select { width: 100%; min-width: 0; padding: 12px 6px; border: 1px solid var(--line); border-radius: 13px; background: white; color: var(--ink); font: inherit; font-size: .9rem; }
.remove-ingredient { grid-column: 1 / -1; justify-self: end; }
.recipe-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.error-message { color: #9c2828; font-size: .9rem; line-height: 1.5; }
.error-message:empty { display: none; }
#storage-error { padding: 14px; border: 1px solid #dcaaaa; border-radius: 12px; background: #fff1f1; }
.backup-file, #backup-status { grid-column: 1 / -1; margin: 0; overflow-wrap: anywhere; }
.backup-file input { max-width: 100%; font-size: .85rem; }
.restore-actions { display: flex; justify-content: flex-end; gap: 12px; }
.restore-actions button { padding: 10px 16px; }
#recover-backup:disabled { opacity: .45; cursor: default; }
#recipe-dialog { overflow-y: auto; }
#recipe-view-dialog { overflow-y: auto; overflow-wrap: anywhere; }
#recipe-view-dialog .dialog-head { align-items: flex-start; }
#recipe-view-dialog .dialog-close { flex-shrink: 0; }
.recipe-view-ingredients { list-style: none; padding: 0; margin: 12px 0 24px; }
.recipe-view-ingredients li { display: flex; justify-content: space-between; gap: 18px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.recipe-view-ingredients strong { flex-shrink: 0; }
.recipe-view-allergens { line-height: 1.6; }
.recipe-view-button { background: var(--green); color: white; }
@media print { #storage-error, #restore-dialog { display: none !important; } }
.output-preview { grid-column: 1 / -1; min-width: 0; }
.output-preview summary { cursor: pointer; color: var(--green); font-weight: 750; padding: 12px 0; }
.paper-preview { margin-top: 10px; padding: 18px; border: 1px solid var(--line); background: white; color: #17201d; overflow-x: auto; }
.print-help { color: var(--muted); font-size: .9rem; line-height: 1.5; }
#print-document { display: none; }
.print-heading { border-bottom: 2px solid #173f35; padding-bottom: 12px; margin-bottom: 18px; }
.print-heading h1 { font-size: 1.8rem; line-height: 1.2; margin: 3px 0 8px; }
.print-heading p { margin: 0; }
.print-heading .print-week { font-weight: 700; }
.print-table { width: 100%; border-collapse: collapse; table-layout: fixed; margin: 10px 0 18px; font-size: .9rem; }
.print-table th, .print-table td { padding: 10px 8px; border-bottom: 1px solid #b8c3be; text-align: left; vertical-align: top; overflow-wrap: anywhere; }
.print-table thead th { background: #eef2ef; font-weight: 750; }
.print-table th small { display: block; font-weight: 400; margin-top: 4px; }
.print-table td p { margin: 6px 0 0; }
.menu-table th:nth-child(1) { width: 19%; }
.menu-table th:nth-child(2) { width: 38%; }
.menu-table th:nth-child(3) { width: 12%; }
.menu-table th:nth-child(4) { width: 31%; }
.print-footnote { font-size: .82rem; line-height: 1.5; }
.print-shopping-group h2, .print-notes h2 { font-size: 1rem; margin: 20px 0 8px; }
.print-table .check-column { width: 75px; }
.print-table .amount-column { width: 105px; text-align: right; }
.paper-checkbox { display: inline-flex; align-items: center; justify-content: center; width: 17px; height: 17px; border: 1px solid #333; color: #111; line-height: 1; }
.preserve-lines { white-space: pre-wrap; overflow-wrap: anywhere; }
.no-cooking .day-date { background: #e9ecea; color: #59625d; }
.no-cooking .day-portions { opacity: .55; }
.allergen-line { color: #173f35 !important; font-weight: 650; }
@media (max-width: 520px) { .paper-preview { padding: 10px; } .paper-preview .menu-table { min-width: 540px; } }
@page { size: A4 portrait; margin: 15mm 13mm; }
@media print {
  body > :not(#print-document) { display: none !important; }
  #print-document { display: block !important; color: #111; background: white; font-family: Arial, sans-serif; font-size: 11pt; }
  .print-heading h1 { font-size: 24pt; }
  .print-table { font-size: 10pt; line-height: 1.4; }
  .print-table th, .print-table td { padding: 9pt 6pt; }
  .print-table thead { display: table-header-group; }
  .print-table tr { break-inside: avoid; }
  .print-shopping-group h2, .print-notes h2 { break-after: avoid; }
  .print-footnote { font-size: 9pt; }
  .print-notes p { orphans: 3; widows: 3; }
  .print-heading { break-inside: avoid; }
}
