/* Opskrifter - moderne, minimalistisk og responsivt.
   Alle mål i rem, farver/afstande som tokens på :root, flydende typografi med clamp(),
   mobile-first breakpoints (telefon < 48rem, tablet < 64rem), mørk tilstand efter systemvalg. */
:root {
    --bg: #f6f7f9;
    --surface: #ffffff;
    --surface-2: #f1f4f8;
    --text: #1c2430;
    --text-muted: #6b7684;
    --border: #e3e7ed;
    --primary: #0f766e;
    --primary-hover: #115e59;
    --primary-soft: #d9f1ee;
    --danger: #dc2626;
    --danger-soft: #fee2e2;
    --warn: #b45309;
    --warn-soft: #fef3c7;
    --success: #15803d;
    --success-soft: #dcfce7;
    --nav-bg: #111827;
    --nav-text: #d1d5db;
    --nav-active: #1f2937;
    --radius: 0.625rem;
    --radius-sm: 0.375rem;
    --shadow: 0 1px 2px rgba(16, 24, 40, 0.06), 0 1px 3px rgba(16, 24, 40, 0.08);
    --space-1: 0.25rem;
    --space-2: 0.5rem;
    --space-3: 0.75rem;
    --space-4: 1rem;
    --space-6: 1.5rem;
    --space-8: 2rem;
    --nav-width: 15rem;
    --font: 'Segoe UI', system-ui, -apple-system, 'Helvetica Neue', Arial, sans-serif;
    --fs-base: clamp(0.9375rem, 0.9rem + 0.2vw, 1.0625rem);
    --fs-h1: clamp(1.375rem, 1.1rem + 1.2vw, 2rem);
    --fs-h2: clamp(1.125rem, 1rem + 0.5vw, 1.375rem);
    --fs-small: 0.8125rem;
}
@media (prefers-color-scheme: dark) {
    :root {
        --bg: #0f141a;
        --surface: #171d25;
        --surface-2: #1f2731;
        --text: #e5e9ef;
        --text-muted: #94a0ae;
        --border: #2a3441;
        --primary: #2dd4bf;
        --primary-hover: #5eead4;
        --primary-soft: #134e4a;
        --danger: #f87171;
        --danger-soft: #450a0a;
        --warn: #fbbf24;
        --warn-soft: #422006;
        --success: #4ade80;
        --success-soft: #052e16;
        --nav-bg: #0b0f14;
        --nav-active: #1f2937;
        --shadow: none;
    }
}

*, *::before, *::after { box-sizing: border-box; }
html { font-size: 100%; -webkit-text-size-adjust: 100%; }
body {
    margin: 0;
    font-family: var(--font);
    font-size: var(--fs-base);
    line-height: 1.5;
    color: var(--text);
    background: var(--bg);
    display: flex;
    min-height: 100vh;
    min-height: 100dvh;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0 0 var(--space-3); font-weight: 600; line-height: 1.25; letter-spacing: -0.01em; }
h1 { font-size: var(--fs-h1); }
h2 { font-size: var(--fs-h2); }
h3 { font-size: 1rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.04em; font-size: 0.75rem; }
p { margin: 0 0 var(--space-3); }
.muted { color: var(--text-muted); }
.small { font-size: var(--fs-small); }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.prewrap { white-space: pre-wrap; }
.lead { font-size: 1.05em; max-width: 60rem; }
.plain-link { color: inherit; }
.plain-list { list-style: none; padding: 0; margin: var(--space-2) 0 0; }
.grow { flex: 1; }

/* NAVIGATION */
.sidebar {
    width: var(--nav-width);
    flex: 0 0 var(--nav-width);
    background: var(--nav-bg);
    color: var(--nav-text);
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
    height: 100dvh;
}
.sidebar-brand {
    display: flex; align-items: center; gap: var(--space-2);
    padding: var(--space-4) var(--space-4) var(--space-3);
    font-weight: 700; font-size: 1.125rem; color: #fff;
}
.brand-icon { font-size: 1.375rem; }
.nav-toggle { display: none; }
.nav-list { list-style: none; margin: 0; padding: 0 var(--space-2); }
.nav-list a {
    display: block; padding: 0.55rem var(--space-3); margin: 2px 0;
    color: var(--nav-text); border-radius: var(--radius-sm); font-size: 0.9375rem;
}
.nav-list a:hover { background: var(--nav-active); color: #fff; text-decoration: none; }
.nav-list a.active { background: var(--primary); color: #fff; }
.nav-sep { height: 1px; background: #374151; margin: var(--space-2) var(--space-3); }
.sidebar-foot { margin-top: auto; padding: var(--space-3) var(--space-4); font-size: 0.75rem; color: #6b7280; }

/* INDHOLD */
.content { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.content-header {
    padding: var(--space-4) var(--space-6) var(--space-3);
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    position: sticky; top: 0; z-index: 20;
}
.content-title-row { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); flex-wrap: wrap; }
.content-title-row h1 { margin: 0; }
.page-actions { display: flex; gap: var(--space-2); flex-wrap: wrap; align-items: center; }
.inline-form { display: inline; }
.toolbar { display: flex; align-items: center; gap: var(--space-3); flex-wrap: wrap; margin-top: var(--space-3); }
.content-body { padding: var(--space-6); flex: 1; }
/* LISTESIDE ("én side, ét scrollhjul", som Singularity): indholdet låses til skærmhøjden, så kun
   tabelboksen scroller lodret - dens thead er sticky i boksens kant (frosset titelrække), og den
   vandrette scrollbjælke ligger i skærmens bund. Rent CSS; kortet vokser ikke ud over sin tabel. */
.content:has(> .content-body.list-page) { height: 100vh; overflow: hidden; }
.content-body.list-page { display: flex; flex-direction: column; min-height: 0; overflow: hidden; padding-bottom: var(--space-4); }
.content-body.list-page > * { flex: 0 0 auto; }
.content-body.list-page > .card.table-scroll { flex: 0 1 auto; min-height: 10rem; overflow: auto; margin-bottom: 0; }
.content-body.list-page .flash-list { flex: 0 0 auto; }

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: var(--space-4) var(--space-6);
    margin-bottom: var(--space-4);
}
.card-image { padding: 0; overflow: hidden; }
.card-image img { display: block; width: 100%; height: auto; }
.empty-state { text-align: center; padding: var(--space-8); }

/* KNAPPER OG FELTER */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 0.35rem;
    padding: 0.5rem 0.9rem; font: inherit; font-size: 0.9rem; font-weight: 500;
    color: var(--text); background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius-sm); cursor: pointer; text-decoration: none; line-height: 1.2;
    white-space: nowrap; transition: background 0.12s, border-color 0.12s;
}
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); }
.btn-danger { color: var(--danger); border-color: var(--danger); background: transparent; }
.btn-danger:hover { background: var(--danger-soft); }
.btn-sm { padding: 0.3rem 0.6rem; font-size: 0.8125rem; }
.btn-block { width: 100%; }
.btn[disabled] { opacity: 0.5; cursor: not-allowed; }

input[type="text"], input[type="search"], input[type="number"], input[type="date"], input[type="file"], select, textarea {
    font: inherit; color: var(--text); background: var(--surface);
    border: 1px solid var(--border); border-radius: var(--radius-sm);
    padding: 0.5rem 0.65rem; width: 100%; max-width: 100%;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--primary-soft); border-color: var(--primary); }
textarea { resize: vertical; min-height: 4rem; }
label { display: block; font-size: 0.875rem; font-weight: 500; color: var(--text-muted); }
label > input, label > select, label > textarea { margin-top: 0.25rem; font-weight: 400; color: var(--text); }
label.inline { display: inline-flex; align-items: center; gap: 0.4rem; font-weight: 400; color: var(--text); }
label.inline input { width: auto; margin: 0; }
.input-sm { width: 6rem; }
.input-xs { width: 4rem; padding: 0.25rem 0.4rem; text-align: right; }
.search-input { max-width: 26rem; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-3) var(--space-4); }
.form-grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.form-grid .span-2 { grid-column: span 2; }
.form-row { display: flex; flex-wrap: wrap; gap: var(--space-3); align-items: center; margin: var(--space-3) 0; }
.form-row label { display: inline-flex; align-items: center; gap: 0.4rem; }
.form-row label input[type="text"] { width: 12rem; }
.unknown-ingredient { background: var(--warn-soft); border-color: var(--warn); }
.form-image-preview { width: 100%; height: auto; border-radius: var(--radius-sm); margin-bottom: var(--space-2); }

/* FLASH */
.flash-list { margin-bottom: var(--space-4); }
.flash { padding: 0.6rem 0.9rem; border-radius: var(--radius-sm); margin-bottom: var(--space-2); font-size: 0.9rem; border: 1px solid transparent; }
.flash-success { background: var(--success-soft); color: var(--success); }
.flash-error { background: var(--danger-soft); color: var(--danger); }
.flash-warning { background: var(--warn-soft); color: var(--warn); }

/* BADGES */
.badge {
    display: inline-block; padding: 0.1rem 0.5rem; border-radius: 999px; font-size: 0.75rem; font-weight: 500;
    background: var(--primary-soft); color: var(--primary); vertical-align: middle;
}
.badge-tag { background: var(--surface-2); color: var(--text-muted); }
.badge-warn { background: var(--warn-soft); color: var(--warn); }

/* TABELLER */
table { width: 100%; border-collapse: collapse; font-size: 0.9375rem; }
th, td { padding: 0.55rem 0.7rem; text-align: left; border-bottom: 1px solid var(--border); vertical-align: top; }
th { font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--text-muted); font-weight: 600; white-space: nowrap; }
tbody tr:hover { background: var(--surface-2); }
tfoot td { border-bottom: none; border-top: 2px solid var(--border); }
.table-scroll, .card.table-scroll { padding: 0; overflow: auto; }   /* også i tablet-visning, ellers titter rækker frem over den frosne thead */
.table-scroll table { min-width: 40rem; }
.table-scroll thead th { position: sticky; top: 0; background: var(--surface); z-index: 5; }
.table-scroll.compact th, .table-scroll.compact td { padding: 0.4rem 0.6rem; }
.actions-cell { text-align: right; white-space: nowrap; }
.actions-cell .btn + .btn { margin-left: 0.25rem; }
.cell-wrap { white-space: normal; min-width: 14rem; }
.cell-clamp { white-space: normal; min-width: 14rem; max-width: 22rem; display: -webkit-box; -webkit-line-clamp: 2;
    -webkit-box-orient: vertical; overflow: hidden; }
.section-row td { background: var(--surface-2); font-weight: 600; color: var(--primary); font-size: 0.8125rem; text-transform: uppercase; letter-spacing: 0.04em; }
.ingredient-table td.amount { font-weight: 600; width: 5rem; }
.ingredient-table td.unit { width: 3rem; color: var(--text-muted); padding-left: 0; }
.kv td, .kv th { padding: 0.35rem 0.5rem; border-bottom: 1px solid var(--border); }
.kv td:first-child { color: var(--text-muted); }
.compact-table { font-size: 0.85rem; }
.compact-table td, .compact-table th { padding: 0.3rem 0.4rem; }
.shopping-table tr.ticked td { text-decoration: line-through; color: var(--text-muted); }
.shopping-table td.amount { font-weight: 600; }
.shopping-table td.unit { color: var(--text-muted); padding-left: 0; }

/* OPSKRIFT: LAYOUT */
.recipe-layout { display: grid; grid-template-columns: minmax(0, 1fr) minmax(16rem, 22rem); gap: var(--space-4); align-items: start; }
.recipe-side { position: sticky; top: 6.5rem; }
.recipe-meta { font-size: 0.9rem; }
.scale-form { display: flex; align-items: center; gap: var(--space-2); flex-wrap: wrap; margin-bottom: var(--space-3); }
.scale-form input { width: 4.5rem; text-align: center; }
.steps { padding-left: 1.5rem; margin: 0; }
.steps li { margin-bottom: 0.6rem; padding-left: 0.25rem; }
.steps li::marker { color: var(--primary); font-weight: 600; }

/* INDHOLDSFORTEGNELSE */
/* Masonry som Google Keep: små rækker (8px), hvert kort spænder efter sin højde (toc_masonry.js).
   Uden JavaScript falder layoutet tilbage til et almindeligt grid. */
.toc { display: grid; grid-template-columns: repeat(auto-fill, minmax(20rem, 1fr)); column-gap: var(--space-4); grid-auto-rows: 8px; align-items: start; }
.toc-section { margin-bottom: 1rem; }
.toc-head { display: flex; align-items: center; justify-content: space-between; width: 100%; background: none; border: none; padding: 0; cursor: pointer; text-align: left; color: inherit; font: inherit; }
.toc-head h2 { margin-bottom: 0; }
.toc-chevron { color: var(--text-muted); transition: transform 0.2s; }
.toc-section:not(.collapsed) .toc-head { margin-bottom: var(--space-2); }
.toc-section.collapsed .toc-list, .toc-section.collapsed .toc-more { display: none; }
.toc-section.collapsed .toc-chevron { transform: rotate(-90deg); }
.toc-item.clipped, .toc-item.no-match { display: none; }
.toc-more { margin-top: var(--space-2); background: none; border: none; color: var(--primary); cursor: pointer; font: inherit; font-size: 0.875rem; padding: 0.25rem; }
.toc-more:hover { text-decoration: underline; }
.toc-section { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: var(--space-4); }
.toc-section h2 { font-size: 1rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--primary); margin-bottom: var(--space-2); }
.toc-list { list-style: none; margin: 0; padding: 0; }
.toc-link { display: flex; gap: var(--space-3); align-items: center; padding: 0.45rem 0.25rem; border-radius: var(--radius-sm); color: inherit; }
.toc-link:hover { background: var(--surface-2); text-decoration: none; }
.toc-thumb { width: 3rem; height: 3rem; border-radius: var(--radius-sm); object-fit: cover; flex: 0 0 3rem; background: var(--surface-2); }
.toc-text { display: flex; flex-direction: column; min-width: 0; }
.toc-title { font-weight: 500; }
.toc-meta { font-size: 0.8125rem; }

/* SØGNING PÅ INGREDIENSER */
.pill-list { display: flex; flex-wrap: wrap; gap: 0.4rem; max-height: 22rem; overflow: auto; padding: var(--space-2) 0; }
.pill { display: inline-flex; align-items: center; gap: 0.3rem; padding: 0.25rem 0.7rem; border: 1px solid var(--border); border-radius: 999px; cursor: pointer; font-size: 0.875rem; color: var(--text); font-weight: 400; background: var(--surface); }
.pill input { display: none; }
.pill:hover { border-color: var(--primary); }
.pill-on { background: var(--primary); border-color: var(--primary); color: #fff; }
.pill-on .muted { color: rgba(255, 255, 255, 0.8); }

/* KOGEBOG / INDKØB */
.cookbook-cat { margin: var(--space-4) 0 var(--space-2); }
.check-row { display: flex; align-items: center; gap: var(--space-2); padding: 0.3rem 0; font-weight: 400; color: var(--text); font-size: 0.95rem; }
.check-row input[type="checkbox"] { width: auto; margin: 0; }
.shopping-picker { columns: 2; column-gap: var(--space-6); }
.shopping-picker h3 { break-after: avoid; }
.check-row { break-inside: avoid; }

[hidden] { display: none !important; }

.badge-organic { background: var(--success-soft); color: var(--success); }
button.badge { border: none; cursor: pointer; font: inherit; font-size: 0.75rem; }

.source-link { font-size: 0.875rem; font-weight: 500; }

/* ERSTATNINGSFORSLAG */
details.subst { display: inline-block; position: relative; vertical-align: middle; }
details.subst > summary { list-style: none; cursor: pointer; color: var(--primary); font-size: 0.85rem; padding: 0 0.3rem; border-radius: var(--radius-sm); }
details.subst > summary::-webkit-details-marker { display: none; }
details.subst[open] > summary { background: var(--primary-soft); }
.subst-pop { position: absolute; z-index: 20; left: 0; top: 1.5rem; width: min(22rem, 80vw); background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius); box-shadow: 0 6px 20px rgba(0,0,0,0.12); padding: var(--space-3); font-size: 0.875rem; font-weight: 400; }
.subst-pop ul { margin: 0.4rem 0 0; padding-left: 1.1rem; }
.subst-pop li { margin-bottom: 0.3rem; }

/* DANSK / ORIGINAL */
.lang-switch { display: inline-flex; border: 1px solid var(--border); border-radius: 999px; padding: 0.2rem; margin-bottom: var(--space-3); background: var(--surface); }
.lang-tab { border: none; background: none; padding: 0.3rem 0.9rem; border-radius: 999px; cursor: pointer; font: inherit; font-size: 0.875rem; color: var(--text-muted); }
.lang-tab.active { background: var(--primary); color: #fff; }
.orig-ingredients { padding-left: 1.2rem; margin: 0; }
.orig-ingredients li { margin-bottom: 0.25rem; }

/* OPRINDELIG MÆNGDE (opskriftsformular) */
.orig-amount { font-size: 0.75rem; color: var(--warn); margin-top: 0.15rem; white-space: nowrap; }
.orig-reset { border: none; background: none; color: var(--primary); cursor: pointer; padding: 0 0.2rem; font-size: 0.85rem; }

/* INDKØBSLISTE */
.toolbar-row { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2) var(--space-4); margin-top: var(--space-2); }
.inline-label { display: inline-flex; align-items: center; gap: 0.4rem; }
.inline-label select { width: auto; margin: 0; }
.add-item-form { display: flex; flex-wrap: wrap; gap: var(--space-2); align-items: center; }
.add-item-form select { width: auto; }
.add-item-form .input-sm { width: 6rem; flex: 0 0 6rem; }
.add-item-form .grow { flex: 2 1 14rem; min-width: 12rem; }
.add-item-form input[name="note"] { width: 12rem; }
.add-item-form .check-row { white-space: nowrap; }
details.card > summary { cursor: pointer; list-style: none; }
details.card > summary::-webkit-details-marker { display: none; }
details.card > summary::before { content: '▸ '; color: var(--text-muted); }
details.card[open] > summary::before { content: '▾ '; }
.inline-h2 { display: inline; }
.chip-row { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2); margin-bottom: var(--space-4); }
.chip { display: inline-flex; align-items: center; gap: 0.4rem; padding: 0.2rem 0.3rem 0.2rem 0.75rem; border: 1px solid var(--border); border-radius: 999px; background: var(--surface); font-size: 0.875rem; }
.chip-x { border: none; background: none; color: var(--text-muted); cursor: pointer; font-size: 1rem; line-height: 1; padding: 0.1rem 0.35rem; border-radius: 999px; }
.chip-x:hover { background: var(--danger-soft); color: var(--danger); }
.table-scroll-x { overflow-x: auto; }
.shopping-table td { vertical-align: middle; }
.shopping-table select, .shopping-table input[type="text"] { padding: 0.25rem 0.4rem; }
.shopping-table .item-unit { width: 4.5rem; }
.shopping-table .item-note { min-width: 8rem; }
.shopping-table .item-location { min-width: 9rem; }
.shopping-table input[type="checkbox"] { width: 1.15rem; height: 1.15rem; }
.shopping-table tr.ticked td { text-decoration: line-through; color: var(--text-muted); }
.shopping-table tr.ticked input, .shopping-table tr.ticked select { opacity: 0.6; }
tr.saving, li.saving { opacity: 0.7; }
tr.save-error td, li.save-error { background: var(--danger-soft); }
.shop-mode { padding-top: var(--space-2); }
.shop-group { margin: var(--space-4) 0 var(--space-1); font-size: 0.8125rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--primary); }
.shop-list { list-style: none; margin: 0; padding: 0; }
.shop-list li { border-bottom: 1px solid var(--border); }
.shop-list label { display: flex; align-items: center; gap: var(--space-3); padding: 0.7rem 0.25rem; font-size: 1.0625rem; font-weight: 400; color: var(--text); cursor: pointer; }
.shop-list input[type="checkbox"] { width: 1.5rem; height: 1.5rem; flex: 0 0 auto; margin: 0; }
.shop-amount { min-width: 5rem; font-weight: 600; white-space: nowrap; }
.shop-list li.ticked label { color: var(--text-muted); text-decoration: line-through; }

/* PRISGRAF */
.price-chart { margin-bottom: var(--space-3); }
.price-svg { width: 100%; height: auto; }
.price-svg .grid { stroke: var(--border); stroke-width: 1; }
.price-svg .line { fill: none; stroke: var(--primary); stroke-width: 2; }
.price-svg .dot { fill: var(--primary); }
.price-svg .line.organic { stroke: var(--success); }
.price-svg .dot.organic { fill: var(--success); }
.price-svg .line.conventional { stroke: var(--text-muted); stroke-dasharray: 4 3; }
.price-svg .dot.conventional { fill: var(--text-muted); }
.chart-legend { display: flex; align-items: center; gap: 0.4rem; color: var(--text-muted); margin-top: 0.25rem; }
.chart-legend .key { display: inline-block; width: 0.9rem; height: 0.2rem; border-radius: 2px; margin-left: 0.5rem; }
.chart-legend .key.organic { background: var(--success); }
.chart-legend .key.conventional { background: var(--text-muted); }
.price-svg .lbl { font-size: 9px; fill: var(--text-muted); font-family: var(--font); }

/* INGREDIENSREDIGERING I OPSKRIFT */
.ingredient-edit-table th, .ingredient-edit-table td { padding: 0.25rem 0.3rem; border-bottom: none; }
.ingredient-edit-table td.drag { color: var(--text-muted); cursor: default; width: 1.5rem; }
.ingredient-edit-table input, .ingredient-edit-table select { padding: 0.4rem 0.5rem; }
.ingredient-edit-table td:nth-child(2) { width: 6rem; }
.ingredient-edit-table td:nth-child(3) { width: 9rem; }
.ingredient-edit-table td:nth-child(6) { width: 8rem; }

/* KOLONNEFILTRE (table_filter.js) */
th.tf-th { cursor: pointer; user-select: none; }
th.tf-th:hover { background: var(--surface-2); }
.tf-th-inner { display: inline-flex; align-items: center; gap: 4px; }
.tf-sort-ind { font-size: 10px; color: var(--primary); white-space: nowrap; }
.tf-btn { display: inline-flex; align-items: center; justify-content: center; width: 20px; height: 20px; margin-left: 2px; padding: 0; border: none; border-radius: 4px; background: transparent; color: var(--text-muted); cursor: pointer; vertical-align: middle; }
.tf-btn:hover { background: var(--surface-2); color: var(--text); }
.tf-btn.active { color: #fff; background: var(--primary); }
.tf-btn svg { width: 12px; height: 12px; fill: currentColor; }
.tf-panel { position: absolute; z-index: 200; display: none; width: 260px; max-width: calc(100vw - 1rem); padding: 10px; box-sizing: border-box; background: var(--surface); border: 1px solid var(--border); border-radius: 6px; box-shadow: 0 6px 20px rgba(0, 0, 0, 0.18); font-size: 13px; font-weight: normal; color: var(--text); text-align: left; text-transform: none; letter-spacing: 0; }
.tf-panel.open { display: block; }
.tf-panel-title { font-weight: 600; color: var(--text-muted); font-size: 12px; margin: 0 0 8px; }
.tf-sort-row { display: flex; gap: 6px; margin-bottom: 8px; }
.tf-sort-row button, .tf-foot button { flex: 1; padding: 6px 8px; font-size: 12px; border: 1px solid var(--border); border-radius: 4px; background: var(--surface-2); color: var(--text); cursor: pointer; }
.tf-sort-row button:hover, .tf-foot button:hover { background: var(--border); }
.tf-sort-row button.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.tf-panel input[type="search"] { width: 100%; padding: 7px 8px; margin: 0 0 8px; font-size: 13px; }
.tf-values { max-height: 240px; overflow-y: auto; border: 1px solid var(--border); border-radius: 4px; padding: 4px 6px; margin-bottom: 8px; }
.tf-values label { display: flex; align-items: center; gap: 6px; padding: 3px 0; cursor: pointer; font-weight: normal; color: var(--text); }
.tf-values label.tf-all { border-bottom: 1px solid var(--border); margin-bottom: 3px; padding-bottom: 5px; font-weight: 600; }
.tf-values label input { width: auto; margin: 0; }
.tf-values .tf-count { margin-left: auto; color: var(--text-muted); font-size: 11px; }
.tf-values label.tf-dim { color: var(--text-muted); }
.tf-foot { display: flex; gap: 6px; }
.tf-hidden { display: none !important; }
.tf-status { display: inline-flex; align-items: center; gap: 10px; font-size: 12px; color: var(--text-muted); white-space: nowrap; flex-wrap: wrap; }
.tf-status .tf-search { width: 16rem; max-width: 60vw; padding: 0.5rem 0.65rem; margin: 0; font-size: 0.9rem; }
.tf-status .tf-clear { padding: 0.45rem 0.75rem; font-size: 12px; font-weight: 600; border: 1px solid var(--warn); border-radius: 4px; background: var(--warn-soft); color: var(--warn); cursor: pointer; white-space: nowrap; }
.tf-status .tf-clear.inactive { background: var(--surface-2); color: var(--text-muted); border-color: var(--border); cursor: default; }
.tf-status-auto { margin: 0 0 8px; }
.tf-empty-row td { text-align: center; color: var(--text-muted); padding: 20px; }

/* TABLET */
@media (max-width: 64rem) {
    :root { --nav-width: 12rem; }
    .content-body { padding: var(--space-4); }
    .content-header { padding: var(--space-3) var(--space-4); }
    .card { padding: var(--space-3) var(--space-4); }
    .recipe-layout { grid-template-columns: minmax(0, 1fr) minmax(14rem, 18rem); }
    .form-grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* TELEFON */
@media (max-width: 48rem) {
    body { flex-direction: column; }
    .sidebar { width: 100%; flex: 0 0 auto; height: auto; position: sticky; top: 0; z-index: 30; }
    .sidebar-brand { padding: var(--space-3) var(--space-4); }
    .nav-toggle { display: inline-flex; margin-left: auto; background: none; border: 1px solid #374151; color: #fff; border-radius: var(--radius-sm); padding: 0.3rem 0.6rem; font: inherit; cursor: pointer; }
    .nav-list { display: none; padding-bottom: var(--space-2); }
    .sidebar.open .nav-list { display: block; }
    .sidebar-foot { display: none; }
    .content-header { position: static; }
    .content-title-row { flex-direction: column; align-items: stretch; }
    .page-actions { justify-content: flex-start; }
    .content-body { padding: var(--space-3); }
    /* Listeside på telefon: menulinjen øverst + indholdet fylder præcis skærmen, så kun tabellen
       scroller (ikke også siden). En åben menu scroller selv, hvis den er højere end skærmen. */
    body:has(.content-body.list-page) { height: 100dvh; overflow: hidden; }
    .content:has(> .content-body.list-page) { flex: 1 1 auto; min-height: 0; height: auto; overflow: hidden; }
    .content-body.list-page > .card.table-scroll { flex: 0 1 auto; min-height: 8rem; }
    .sidebar.open { max-height: 100dvh; overflow-y: auto; }
    .recipe-layout { grid-template-columns: minmax(0, 1fr); }
    .recipe-side { position: static; }
    .form-grid, .form-grid-4 { grid-template-columns: minmax(0, 1fr); }
    .form-grid .span-2 { grid-column: span 1; }
    .toc { grid-template-columns: minmax(0, 1fr); }
    .shopping-picker { columns: 1; }
    .add-item-form input[name="note"], .add-item-form .grow { width: 100%; flex: 1 1 100%; }
    .add-item-form .input-sm { flex: 1 1 0; }
    .toolbar-row .grow { display: none; }
    .ingredient-edit-table, .ingredient-edit-table tbody, .ingredient-edit-table tr, .ingredient-edit-table td { display: block; width: auto; }
    .ingredient-edit-table thead { display: none; }
    .ingredient-edit-table tr { border: 1px solid var(--border); border-radius: var(--radius-sm); padding: var(--space-2); margin-bottom: var(--space-2); display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-2); }
    .ingredient-edit-table td.drag { display: none; }
    .ingredient-edit-table td:nth-child(4), .ingredient-edit-table td:nth-child(5), .ingredient-edit-table td.actions-cell { grid-column: span 2; }
    .ingredient-edit-table td:nth-child(2), .ingredient-edit-table td:nth-child(3), .ingredient-edit-table td:nth-child(6) { width: auto; }
    .scale-form .btn-sm { padding: 0.35rem 0.5rem; }
    table { font-size: 0.875rem; }
    th, td { padding: 0.45rem 0.5rem; }
    .cell-wrap { min-width: 10rem; }
}

/* PRINT (browserens egen udskrift; PDF laves via LaTeX) */
@media print {
    body { display: block; background: #fff; color: #000; }
    .sidebar, .page-actions, .scale-form, .flash-list, .nav-toggle, .tf-btn, .tf-status { display: none !important; }
    .content-header { position: static; border: none; }
    .card { box-shadow: none; border-color: #ccc; break-inside: avoid; }
    .recipe-layout { grid-template-columns: 1fr; }
    a { color: inherit; }
}

.shopping-table tr.best-match td { background: var(--success-soft); }
.shopping-table tr.no-match td { color: var(--text-muted); }

/* LOGIN / BRUGERE */
body.no-nav .content { margin-left: 0; }
.auth-card { max-width: 26rem; }
.auth-card form { display: flex; flex-direction: column; gap: var(--space-3); margin: var(--space-3) 0; }
.nav-logout button { display: block; background: none; border: none; color: var(--nav-text); font: inherit; font-size: 0.9375rem;
    cursor: pointer; padding: 0.55rem var(--space-3); margin: 2px 0; width: 100%; text-align: left; border-radius: var(--radius-sm); }
.nav-logout button:hover { background: var(--nav-active); }
.nav-logout button:hover { color: #fff; }
.input-pw { width: 11rem; }

/* FOKUS, TRÆK, TOUCH */
a:focus-visible, button:focus-visible, .btn:focus-visible, summary:focus-visible, input[type="checkbox"]:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.ingredient-edit-table td.drag { cursor: grab; user-select: none; }
.ingredient-edit-table tr.dragging { opacity: 0.5; }
@media (pointer: coarse) {
    .shopping-table input[type="checkbox"] { width: 1.6rem; height: 1.6rem; }
    .btn-sm { min-height: 2.25rem; min-width: 2.25rem; }
    details.subst > summary { padding: 0.25rem 0.5rem; }
}

.preline { white-space: pre-line; }

/* INGREDIENSER: sammenlægning og navngivning */
.merge-form { display: flex; flex-direction: column; gap: var(--space-2); }
.naming-help summary { cursor: pointer; color: var(--primary); }
.naming-help ol { margin: var(--space-2) 0 0; padding-left: 1.2rem; }

/* KOST */
.diet-filter { flex-wrap: wrap; gap: 0.4rem; margin-top: var(--space-2); }
.chip-btn { border: 1px solid var(--border); background: var(--surface); color: var(--text); border-radius: 999px;
    padding: 0.3rem 0.8rem; font: inherit; font-size: 0.85rem; cursor: pointer; }
.chip-btn.active { background: var(--primary); border-color: var(--primary); color: #fff; }
.badge.diet-0 { background: var(--success-soft); color: var(--success); }
.badge.diet-1 { background: #e8f5e0; color: #3f6212; }
.badge.diet-2 { background: #e0f2fe; color: #0369a1; }
.badge.diet-3 { background: #fef3c7; color: #92400e; }
.badge.diet-4 { background: var(--danger-soft); color: var(--danger); }
@media (prefers-color-scheme: dark) {
    .badge.diet-1 { background: #1a2e05; color: #bef264; }
    .badge.diet-2 { background: #082f49; color: #7dd3fc; }
    .badge.diet-3 { background: #422006; color: #fcd34d; }
}
.inline-form-row { display: flex; flex-wrap: wrap; align-items: flex-end; gap: var(--space-2); margin: var(--space-2) 0; }

/* INDKØB FRA OPSKRIFT + HANDLETILSTAND */
.delete-recipe-btn { margin-top: var(--space-2); }
.shop-dialog { border: none; border-radius: var(--radius); padding: 0; width: min(36rem, 94vw); max-height: 88vh;
    background: var(--surface); color: var(--text); box-shadow: 0 20px 50px rgba(0,0,0,0.25); }
.shop-dialog::backdrop { background: rgba(15, 23, 42, 0.45); }
.shop-dialog form { display: flex; flex-direction: column; gap: var(--space-2); padding: var(--space-4); max-height: 88vh; }
.dialog-head, .dialog-foot { display: flex; align-items: center; justify-content: space-between; gap: var(--space-2); }
.dialog-foot { justify-content: flex-end; border-top: 1px solid var(--border); padding-top: var(--space-3); }
.shop-pick { list-style: none; margin: 0; padding: 0; overflow-y: auto; flex: 1; min-height: 6rem; }
.shop-pick .check-row { padding: 0.45rem 0.2rem; border-bottom: 1px solid var(--border); }
.shop-pick input[type="checkbox"] { width: 1.3rem; height: 1.3rem; }
.shop-pick-section { font-size: 0.8125rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--primary); margin-top: var(--space-2); font-weight: 600; }
.new-list-name { max-width: 20rem; }
.shop-list.basket li label { opacity: 0.6; }
.snackbar { position: fixed; left: 50%; bottom: 1.25rem; transform: translateX(-50%); z-index: 50; display: flex; align-items: center;
    gap: var(--space-4); background: #1f2937; color: #fff; padding: 0.7rem 1rem; border-radius: var(--radius); box-shadow: var(--shadow);
    max-width: calc(100vw - 2rem); }
.snackbar button { background: none; border: none; color: #5eead4; font: inherit; font-weight: 600; cursor: pointer; padding: 0.3rem 0.5rem; }
