:root {
    --bg: #f7f5f2;
    --surface: #ffffff;
    --text: #26241f;
    --text-muted: #6b6559;
    --border: #e4e0d8;
    --accent: #3a6b52;
    --accent-contrast: #ffffff;
    --danger: #b64a3c;
    --priority-1: #4f8f63;
    --priority-2: #c98a2c;
    --priority-3: #c0392b;
    --radius: 12px;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #1c1b18;
        --surface: #26241f;
        --text: #f1efe9;
        --text-muted: #a49c8c;
        --border: #3a372f;
        --accent: #6fae8b;
        --accent-contrast: #12241a;
    }
}

* { box-sizing: border-box; }

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

.container {
    max-width: 720px;
    margin: 0 auto;
    padding: 0 12px 100px;
}

header.topbar {
    position: sticky;
    top: 0;
    z-index: 10;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: 10px 12px;
}

.topbar-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    max-width: 720px;
    margin: 0 auto;
    gap: 8px;
}

.topbar-row h1 {
    font-size: 1.1rem;
    margin: 0;
}

nav.tabs {
    display: flex;
    gap: 6px;
}

nav.tabs a {
    text-decoration: none;
    color: var(--text-muted);
    padding: 6px 10px;
    border-radius: 8px;
    font-size: 0.9rem;
}

/* Abmelden ist ein POST-Formular, soll aber wie die anderen Tabs aussehen */
nav.tabs form {
    margin: 0;
    display: flex;
}

nav.tabs button.tab-button {
    min-height: 0;
    border: none;
    background: none;
    color: var(--text-muted);
    padding: 6px 10px;
    border-radius: 8px;
    font-size: 0.9rem;
    cursor: pointer;
}

nav.tabs a.active {
    background: var(--accent);
    color: var(--accent-contrast);
}

button, .btn {
    font: inherit;
    min-height: 44px;
    padding: 8px 16px;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text);
    cursor: pointer;
}

button.primary {
    background: var(--accent);
    border-color: var(--accent);
    color: var(--accent-contrast);
    font-weight: 600;
}

button.danger {
    color: var(--danger);
    border-color: var(--danger);
}

button.icon {
    min-height: 36px;
    padding: 4px 10px;
    font-size: 0.85rem;
}

.week-nav {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 14px;
    margin: 14px 0;
}

.week-nav .week-label {
    font-weight: 600;
    text-align: center;
    min-width: 170px;
}

.day-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 12px;
    margin-bottom: 10px;
}

.day-card .day-label {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    font-size: 0.8rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.03em;
    margin-bottom: 6px;
}

.day-card .recipe-row {
    display: flex;
    align-items: center;
    gap: 8px;
}

.day-card .recipe-name {
    font-weight: 600;
    font-size: 1.05rem;
    flex: 1 1 auto;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.drag-handle {
    flex: 0 0 auto;
    cursor: grab;
    touch-action: none;
    padding: 6px 4px;
    color: var(--text-muted);
    font-size: 1.1rem;
    user-select: none;
    -webkit-user-select: none;
}

.drag-ghost {
    position: fixed;
    transform: translate(-50%, -50%);
    background: var(--accent);
    color: var(--accent-contrast);
    padding: 8px 14px;
    border-radius: 999px;
    font-size: 0.85rem;
    font-weight: 600;
    pointer-events: none;
    z-index: 200;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
}

.day-card.drag-over {
    outline: 2px dashed var(--accent);
    outline-offset: 2px;
}

.badge {
    display: inline-block;
    flex: 0 0 auto;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: none;
    letter-spacing: normal;
    padding: 2px 8px;
    border-radius: 999px;
    color: #fff;
}

.badge.priority-1 { background: var(--priority-1); }
.badge.priority-2 { background: var(--priority-2); }
.badge.priority-3 { background: var(--priority-3); }

.day-card details {
    margin-top: 8px;
}

.day-card summary {
    cursor: pointer;
    color: var(--text-muted);
    font-size: 0.9rem;
}

.day-card ul.ingredient-list {
    margin: 8px 0 0;
    padding-left: 18px;
    font-size: 0.92rem;
}

.day-card .prep-note {
    margin: 8px 0 0;
    font-size: 0.92rem;
    white-space: pre-line;
}

.day-card .actions-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 10px;
    flex-wrap: wrap;
}

.empty-day {
    color: var(--text-muted);
}

.floating-actions {
    position: sticky;
    bottom: 0;
    padding: 12px 0;
    background: linear-gradient(to top, var(--bg) 70%, transparent);
}

/* Rezeptbibliothek */
.recipe-list-item {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 12px;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    cursor: pointer;
}

.recipe-list-item .meta {
    color: var(--text-muted);
    font-size: 0.85rem;
}

.ingredient-row {
    padding-bottom: 10px;
    margin-bottom: 10px;
    border-bottom: 1px dashed var(--border);
}

.ingredient-row .line2 {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    margin-top: 6px;
}

.ingredient-row .line2 input.qty { flex: 1 1 70px; min-width: 60px; }
.ingredient-row .line2 input.unit { flex: 1 1 70px; min-width: 60px; }
.ingredient-row .line2 select.priority { flex: 1 1 100px; }
.ingredient-row .line2 select.category { flex: 2 1 160px; }
.ingredient-row .line2 button.remove-ingredient { flex: 0 0 auto; }

.ingredient-row .line2 label.pantry-toggle {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 0.9rem;
    color: var(--text-muted);
    cursor: pointer;
    white-space: nowrap;
}

.ingredient-row .line2 label.pantry-toggle input {
    width: auto;
    margin: 0;
}

.pantry-hint {
    font-size: 0.85rem;
    margin: 0 0 8px;
}

/* Vorratszutaten im Wochenplan dezent markieren */
.ingredient-list .pantry-tag {
    color: var(--text-muted);
    font-size: 0.85em;
}

/* Einkaufsliste: Hinweis auf weggelassene Vorratszutaten */
.shopping-pantry {
    margin-top: 14px;
    color: var(--text-muted);
    font-size: 0.92rem;
}

/* Einstellungen: Vorratsliste */
.settings-section {
    margin-top: 28px;
}

.settings-section h2 {
    font-size: 1rem;
    margin: 0 0 6px;
}

.pantry-list {
    list-style: none;
    padding: 0;
    margin: 10px 0;
}

.pantry-list li {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 4px 0;
    border-bottom: 1px solid var(--border);
}

.pantry-add-row {
    display: flex;
    gap: 6px;
}

.pantry-add-row input { flex: 1; }
.pantry-add-row button { flex: 0 0 auto; }

input, select, textarea {
    font: inherit;
    padding: 8px;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text);
    width: 100%;
}

.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    display: flex;
    align-items: flex-end;
    justify-content: center;
    z-index: 100;
}

.modal-backdrop[hidden] {
    display: none;
}

@media (min-width: 700px) {
    .modal-backdrop { align-items: center; }
}

.modal {
    background: var(--surface);
    border-radius: var(--radius) var(--radius) 0 0;
    padding: 16px;
    width: 100%;
    max-width: 600px;
    max-height: 90vh;
    overflow-y: auto;
}

@media (min-width: 700px) {
    .modal { border-radius: var(--radius); }
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

/* Tag planen: kombiniertes Such-/Notizfeld */
.pick-list {
    margin-top: 10px;
}

.recipe-list-item.active {
    border-color: var(--accent);
    box-shadow: 0 0 0 1px var(--accent);
}

.pick-note-option {
    color: var(--text-muted);
}

.pick-note-option strong {
    color: var(--text);
    font-weight: 600;
}

.shopping-category h3 {
    margin: 14px 0 6px;
    font-size: 0.95rem;
    color: var(--accent);
}

.shopping-category ul {
    margin: 0;
    padding-left: 18px;
}

.error {
    color: var(--danger);
}

.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
}

.login-form {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
    width: 100%;
    max-width: 320px;
    text-align: center;
}

.login-form input {
    margin: 12px 0;
}

.login-form button {
    width: 100%;
}

.shopping-fallback textarea {
    height: 160px;
    font-family: monospace;
}

@media (min-width: 700px) {
    /* Eigene, breitere Container-Variante nur fuer den Wochenplaner: 7 echte
       Spalten brauchen mehr als die site-weiten 720px (.container), sonst
       werden Buttons/Badges abgeschnitten. Mobile Stapelansicht (<700px) und
       andere Seiten (Rezepte, Login) bleiben bei 720px unveraendert. */
    .container-planner {
        max-width: min(96vw, 1800px);
    }
    .week-grid {
        display: grid;
        grid-template-columns: repeat(7, 1fr);
        gap: 8px;
        align-items: start;
    }
    .week-grid .day-card {
        margin-bottom: 0;
        min-width: 0;
    }
}
