/* ============================================================
   Madplanner – iOS-inspireret design
   ============================================================ */

:root {
    --accent:     #FF6B35;
    --accent-lt:  #FFF0EA;
    --bg:         #F2F2F7;
    --card-bg:    #FFFFFF;
    --text:       #1C1C1E;
    --text-sub:   #8E8E93;
    --border:     #E5E5EA;
    --nav-height: 83px;
    --top-height: 56px;
    --radius:     16px;
    --radius-sm:  10px;
    --shadow:     0 2px 12px rgba(0,0,0,.08);
    --font:       -apple-system, "SF Pro Display", system-ui, sans-serif;
    --green:      #34C759;
    --red:        #FF3B30;
    --blue:       #007AFF;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 16px; }

body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    -webkit-font-smoothing: antialiased;
    overscroll-behavior: none;
}

/* ── App-container ── */
.app-container {
    max-width: 600px;
    margin: 0 auto;
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
    position: relative;
}

/* ── Top bar ── */
.top-bar {
    position: sticky;
    top: 0;
    z-index: 100;
    height: var(--top-height);
    background: rgba(242,242,247,.92);
    backdrop-filter: saturate(180%) blur(20px);
    -webkit-backdrop-filter: saturate(180%) blur(20px);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    gap: 12px;
}

.top-bar-simple { justify-content: center; }

.page-title {
    font-size: 17px;
    font-weight: 600;
    letter-spacing: -0.3px;
}

.week-label {
    text-align: center;
    line-height: 1.2;
}
.week-num   { display: block; font-size: 15px; font-weight: 600; }
.week-dates { display: block; font-size: 12px; color: var(--text-sub); }

.icon-btn {
    width: 36px; height: 36px;
    border: none; background: none;
    font-size: 22px; font-weight: 300;
    color: var(--accent);
    cursor: pointer; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    transition: background .15s;
}
.icon-btn:active { background: var(--accent-lt); }

/* ── User bar ── */
.user-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 16px;
    background: var(--card-bg);
    border-bottom: 1px solid var(--border);
}
.user-name   { font-size: 14px; font-weight: 500; }
.logout-link { font-size: 13px; color: var(--accent); text-decoration: none; }

/* ── Main content ── */
.main-content {
    flex: 1;
    padding: 16px 16px calc(var(--nav-height) + 16px);
    overflow-y: auto;
}

/* ── Bottom nav ── */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 100%;
    max-width: 600px;
    height: var(--nav-height);
    background: rgba(255,255,255,.95);
    backdrop-filter: saturate(180%) blur(20px);
    -webkit-backdrop-filter: saturate(180%) blur(20px);
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: space-around;
    align-items: flex-start;
    padding: 8px 0 20px;
    z-index: 100;
}

.nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    text-decoration: none;
    color: var(--text-sub);
    flex: 1;
    transition: color .15s;
}
.nav-item.active { color: var(--accent); }

.nav-icon  { font-size: 22px; line-height: 1; }
.nav-label { font-size: 10px; font-weight: 500; }

/* ── Day section ── */
.day-section {
    margin-bottom: 24px;
    animation: fadeIn .3s ease;
}
.day-section.today .day-name { color: var(--accent); }

.day-header {
    display: flex;
    align-items: baseline;
    gap: 8px;
    margin-bottom: 10px;
}
.day-name { font-size: 20px; font-weight: 700; }
.day-date  { font-size: 14px; color: var(--text-sub); }

/* ── Recipe cards ── */
.recipe-cards {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.recipe-card {
    background: var(--card-bg);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
    transition: transform .15s, box-shadow .15s;
    border: 2px solid transparent;
}
.recipe-card.voted { border-color: var(--green); }
.recipe-card:active { transform: scale(.99); }

.card-image {
    width: 100%;
    height: 160px;
    background-size: cover;
    background-position: center;
    background-color: #F0E6DC;
}
.card-image-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-size: 40px;
    background: var(--accent-lt);
}

.gen-img-btn {
    font-size: 13px;
    padding: 4px 12px;
    border: 1.5px solid var(--accent);
    border-radius: 20px;
    background: white;
    color: var(--accent);
    cursor: pointer;
    font-family: var(--font);
}

.img-gen-status {
    text-align: center;
    padding: 10px 16px;
    color: var(--accent);
    font-size: 14px;
    font-weight: 500;
}

.card-body {
    padding: 14px 16px 16px;
}

.card-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 6px;
}

.cat-badge {
    font-size: 11px;
    font-weight: 600;
    padding: 3px 8px;
    border-radius: 20px;
    letter-spacing: .3px;
}
.cat-1, .cat-saved { background: #E8F5E9; color: #2E7D32; }
.cat-2             { background: #E3F2FD; color: #1565C0; }
.cat-3             { background: #FFF3E0; color: #E65100; }
.cat-search        { background: #EDE7F6; color: #4527A0; }

.cook-time  { font-size: 12px; color: var(--text-sub); margin-left: auto; }

.card-title { font-size: 17px; font-weight: 600; margin-bottom: 4px; line-height: 1.25; }
.card-desc  { font-size: 14px; color: var(--text-sub); line-height: 1.4; margin-bottom: 12px; }

.card-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
    flex-wrap: wrap;
}

/* ── Vote button ── */
.vote-btn {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 7px 14px;
    border-radius: 20px;
    border: 1.5px solid var(--border);
    background: #fff;
    font-size: 14px;
    cursor: pointer;
    transition: all .15s;
    font-family: var(--font);
}
.vote-btn.voted {
    background: var(--green);
    border-color: var(--green);
    color: #fff;
}
.vote-btn:active { transform: scale(.95); }
.vote-count { font-weight: 700; }

/* ── Star rating ── */
.star-rating { display: flex; gap: 4px; }
.star {
    background: none;
    border: none;
    font-size: 22px;
    cursor: pointer;
    color: #C7C7CC;
    transition: color .1s;
    padding: 0;
    font-family: var(--font);
}
.star.active, .star:hover { color: #FF9500; }

.rating-display { font-size: 14px; color: #FF9500; font-weight: 500; }
.rating-val     { color: var(--text-sub); margin-left: 4px; font-size: 13px; }

/* ── "Se opskrift" button ── */
.recipe-details-btn {
    display: block;
    width: 100%;
    padding: 10px;
    background: var(--accent-lt);
    color: var(--accent);
    border: none;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    text-align: center;
    font-family: var(--font);
    transition: background .15s;
}
.recipe-details-btn:active { background: #FFDDD0; }

/* ── Buttons ── */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 11px 20px;
    border-radius: var(--radius-sm);
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    border: none;
    font-family: var(--font);
    transition: opacity .15s, transform .1s;
    text-decoration: none;
}
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .5; cursor: default; }

.btn-primary  { background: var(--accent); color: #fff; }
.btn-outline  { background: #fff; color: var(--accent); border: 1.5px solid var(--accent); }
.btn-danger   { background: #FFE5E3; color: var(--red); border: none; }
.btn-full     { width: 100%; }
.btn-lg       { padding: 14px 28px; font-size: 17px; }
.btn-sm       { padding: 7px 14px; font-size: 13px; }

/* ── Generate bar ── */
.generate-bar {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

/* ── Empty states ── */
.empty-state {
    text-align: center;
    padding: 60px 20px;
}
.empty-icon { font-size: 56px; margin-bottom: 16px; }
.empty-state h2 { font-size: 22px; font-weight: 700; margin-bottom: 8px; }
.empty-state p  { color: var(--text-sub); margin-bottom: 24px; font-size: 15px; }

.empty-state-small { text-align: center; padding: 32px 0; color: var(--text-sub); }

/* ── Modal (opskrift) ── */
.modal { position: fixed; inset: 0; z-index: 200; }
.modal.hidden { display: none; }

.modal-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,.4);
}
.modal-sheet {
    position: absolute;
    bottom: 0; left: 50%;
    transform: translateX(-50%);
    width: 100%;
    max-width: 600px;
    background: var(--card-bg);
    border-radius: 20px 20px 0 0;
    max-height: 90dvh;
    overflow-y: auto;
    padding: 12px 20px 40px;
    animation: slideUp .3s ease;
}
.modal-handle {
    width: 36px; height: 4px;
    background: var(--border);
    border-radius: 2px;
    margin: 0 auto 16px;
}
.modal-close {
    position: absolute;
    top: 14px; right: 16px;
    background: var(--bg);
    border: none;
    width: 30px; height: 30px;
    border-radius: 50%;
    font-size: 14px;
    cursor: pointer;
    color: var(--text-sub);
    display: flex; align-items: center; justify-content: center;
}

.modal-image {
    width: calc(100% + 40px);
    margin: 0 -20px 20px;
    height: 200px;
    background-size: cover;
    background-position: center;
    background-color: var(--accent-lt);
}

.modal-title  { font-size: 22px; font-weight: 700; margin-bottom: 6px; }
.modal-meta   { font-size: 14px; color: var(--text-sub); margin-bottom: 20px; }

.modal-section       { margin-bottom: 20px; }
.modal-section-title { font-size: 13px; font-weight: 700; text-transform: uppercase;
                       letter-spacing: .5px; color: var(--text-sub); margin-bottom: 10px; }

.ingredient-list, .instructions-list {
    list-style: none;
}

.ingredient-list li {
    padding: 10px 0;
    border-bottom: 1px solid var(--border);
    font-size: 15px;
    display: flex;
    align-items: center;
    gap: 8px;
}
.ingredient-list li::before { content: '•'; color: var(--accent); font-size: 18px; }

.instructions-list li {
    padding: 10px 0 10px 36px;
    border-bottom: 1px solid var(--border);
    font-size: 15px;
    line-height: 1.5;
    position: relative;
}
.step-num {
    position: absolute;
    left: 0;
    top: 10px;
    width: 24px; height: 24px;
    background: var(--accent);
    color: #fff;
    border-radius: 50%;
    font-size: 12px;
    font-weight: 700;
    display: flex; align-items: center; justify-content: center;
}

/* ── Loading overlay ── */
.loading-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.5);
    z-index: 300;
    display: flex;
    align-items: center;
    justify-content: center;
}
.loading-overlay.hidden { display: none; }

.loading-box {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 32px 40px;
    text-align: center;
    box-shadow: 0 20px 60px rgba(0,0,0,.3);
    max-width: 280px;
}
.loading-box p     { font-size: 16px; font-weight: 600; margin-top: 16px; }
.loading-sub       { font-size: 13px; color: var(--text-sub); margin-top: 6px !important; font-weight: 400 !important; }

.spinner {
    width: 44px; height: 44px;
    border: 3px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    margin: 0 auto;
    animation: spin 1s linear infinite;
}

/* ── Login ── */
.login-body { background: var(--bg); display: flex; align-items: center; min-height: 100dvh; }

.login-container {
    width: 100%;
    max-width: 400px;
    margin: 0 auto;
    padding: 40px 24px 60px;
}

.login-logo { text-align: center; margin-bottom: 32px; }
.logo-icon   { font-size: 56px; display: block; margin-bottom: 8px; }
.login-title { font-size: 28px; font-weight: 700; }
.login-subtitle { font-size: 16px; color: var(--text-sub); margin-top: 4px; }

.tab-bar-login {
    display: flex;
    background: var(--border);
    border-radius: var(--radius-sm);
    padding: 3px;
    margin-bottom: 24px;
    gap: 3px;
}
.tab-btn {
    flex: 1;
    padding: 9px;
    border: none;
    background: transparent;
    font-size: 14px;
    font-weight: 500;
    border-radius: 8px;
    cursor: pointer;
    font-family: var(--font);
    color: var(--text-sub);
    transition: all .2s;
}
.tab-btn.active { background: var(--card-bg); color: var(--text); box-shadow: var(--shadow); }

.tab-panel { display: none; }
.tab-panel.active { display: block; }

.auth-form { display: flex; flex-direction: column; gap: 14px; }

/* ── Form groups ── */
.form-group { display: flex; flex-direction: column; gap: 6px; }
.form-group label { font-size: 13px; font-weight: 600; color: var(--text-sub); }
.form-group input {
    padding: 13px 16px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 16px;
    font-family: var(--font);
    background: var(--card-bg);
    outline: none;
    transition: border-color .15s;
}
.form-group input:focus { border-color: var(--accent); }

/* ── Alerts ── */
.alert {
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    font-size: 14px;
    margin-bottom: 16px;
}
.alert-error   { background: #FFE5E3; color: var(--red); }
.alert-success { background: #E8F5E9; color: #2E7D32; }

/* ── Settings ── */
.settings-form { display: flex; flex-direction: column; gap: 0; }
.settings-section {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 18px 16px;
    margin-bottom: 16px;
    box-shadow: var(--shadow);
}
.section-title { font-size: 16px; font-weight: 700; margin-bottom: 4px; }
.section-desc  { font-size: 13px; color: var(--text-sub); margin-bottom: 14px; }

.cuisine-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
}
.cuisine-option {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 10px 8px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all .15s;
}
.cuisine-option input { display: none; }
.cuisine-option.selected { border-color: var(--accent); background: var(--accent-lt); color: var(--accent); }

.checkbox-grid { display: flex; flex-direction: column; gap: 2px; }
.checkbox-option {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 0;
    border-bottom: 1px solid var(--border);
    cursor: pointer;
}
.checkbox-option:last-child { border-bottom: none; }
.checkbox-option input { width: 20px; height: 20px; accent-color: var(--accent); cursor: pointer; }
.checkbox-label { font-size: 15px; }

.textarea-input {
    width: 100%;
    padding: 12px 14px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 15px;
    font-family: var(--font);
    resize: vertical;
    outline: none;
    transition: border-color .15s;
}
.textarea-input:focus { border-color: var(--accent); }

.settings-footer { padding: 8px 0 0; }
.settings-note { text-align: center; font-size: 13px; color: var(--text-sub); margin-top: 10px; }

/* ── Search ── */
.search-box {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
    background: var(--card-bg);
    padding: 12px;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}
.search-input {
    flex: 1;
    padding: 10px 14px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 15px;
    font-family: var(--font);
    outline: none;
}
.search-input:focus { border-color: var(--accent); }

.count-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--accent);
    color: #fff;
    border-radius: 12px;
    padding: 1px 8px;
    font-size: 13px;
    font-weight: 700;
    margin-left: 8px;
}

/* ── History ── */
.history-intro { font-size: 14px; color: var(--text-sub); margin-bottom: 12px; }
.history-list  { display: flex; flex-direction: column; gap: 10px; }

.history-card {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 16px;
    box-shadow: var(--shadow);
    text-decoration: none;
    color: var(--text);
    display: flex;
    flex-direction: column;
    gap: 4px;
    position: relative;
    transition: transform .15s;
}
.history-card:active { transform: scale(.99); }

.history-week    { font-size: 16px; font-weight: 600; padding-right: 24px; }
.history-top-meal { font-size: 13px; color: var(--text-sub); }
.history-arrow   { position: absolute; right: 16px; top: 50%; transform: translateY(-50%);
                   color: var(--text-sub); font-size: 20px; }

.badge-current {
    display: inline-block;
    background: var(--accent);
    color: #fff;
    font-size: 11px;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 10px;
    margin-left: 8px;
    vertical-align: middle;
}

/* ── Grocery ── */
.grocery-body      { background: var(--bg); }
.grocery-container { max-width: 600px; margin: 0 auto; padding: 20px 16px 40px; }

.grocery-header { text-align: center; margin-bottom: 28px; }
.grocery-header h1 { font-size: 26px; font-weight: 700; }
.grocery-week      { font-size: 14px; color: var(--text-sub); margin-top: 4px; }

.grocery-section {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 16px;
    margin-bottom: 16px;
    box-shadow: var(--shadow);
}
.grocery-section h2 { font-size: 16px; font-weight: 700; margin-bottom: 12px; }

.meal-list { list-style: none; }
.meal-list li {
    padding: 8px 0;
    border-bottom: 1px solid var(--border);
    font-size: 15px;
    display: flex;
    align-items: center;
    gap: 8px;
}
.meal-list li::before { content: '🍽️'; font-size: 16px; }
.meal-list li:last-child { border-bottom: none; }

.ingredient-item {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 11px 0;
    border-bottom: 1px solid var(--border);
    cursor: pointer;
    transition: opacity .2s;
    -webkit-tap-highlight-color: transparent;
}
.ingredient-item:last-child { border-bottom: none; }
.ingredient-item.checked { opacity: .45; text-decoration: line-through; }

.check-box        { font-size: 18px; flex-shrink: 0; color: var(--accent); }
.ingredient-text  { font-size: 15px; flex: 1; }
.ingredient-meal  { font-size: 12px; color: var(--text-sub); flex-shrink: 0; }

.grocery-footer { text-align: center; margin-top: 20px; }
.grocery-tip    { font-size: 13px; color: var(--text-sub); margin-bottom: 12px; }
.grocery-empty  { text-align: center; color: var(--text-sub); padding: 40px 0; }

/* ── No meals for day ── */
.no-meals-day { color: var(--text-sub); font-size: 14px; padding: 12px 0; }

/* ── Dag-handlingsknapper ── */
.day-actions {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 4px;
}
.regen-day-btn,
.skip-day-btn {
    background: none;
    border: none;
    font-size: 18px;
    cursor: pointer;
    opacity: .5;
    padding: 4px 6px;
    border-radius: 8px;
    transition: opacity .15s, background .15s;
    -webkit-tap-highlight-color: transparent;
}
.regen-day-btn:hover,
.skip-day-btn:hover   { opacity: 1; background: var(--border); }
.skip-day-btn.active  { opacity: 1; }
.regen-day-btn:disabled { cursor: default; }

/* ── Skippet dag ── */
.day-skipped-section .day-header { opacity: .6; }

.day-skipped-placeholder {
    display: flex;
    align-items: center;
    gap: 12px;
    background: var(--border);
    border-radius: var(--radius);
    padding: 20px 18px;
    margin: 4px 0 8px;
    color: var(--text-sub);
}
.skip-icon { font-size: 24px; flex-shrink: 0; }
.skip-text { flex: 1; font-size: 15px; font-weight: 500; }
.btn-unskip {
    font-size: 13px;
    font-weight: 600;
    color: var(--accent);
    background: none;
    border: 1px solid var(--accent);
    border-radius: 20px;
    padding: 5px 12px;
    cursor: pointer;
    white-space: nowrap;
    -webkit-tap-highlight-color: transparent;
}

/* ── Skip-dialog ── */
.skip-dialog-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.5);
    z-index: 500;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    padding-bottom: env(safe-area-inset-bottom, 0);
}
.skip-dialog {
    background: var(--card-bg);
    border-radius: var(--radius) var(--radius) 0 0;
    padding: 24px 20px 32px;
    width: 100%;
    max-width: 480px;
    display: flex;
    flex-direction: column;
    gap: 14px;
}
.skip-dialog h3  { font-size: 17px; font-weight: 700; text-align: center; }
.skip-dialog p   { font-size: 14px; color: var(--text-sub); text-align: center; }
.skip-options    { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.skip-option-btn {
    background: var(--bg);
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 14px 10px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    color: var(--text);
    transition: border-color .15s, background .15s;
}
.skip-option-btn:hover { border-color: var(--accent); background: var(--accent-lt); color: var(--accent); }
.skip-cancel-btn {
    background: none;
    border: none;
    color: var(--text-sub);
    font-size: 15px;
    padding: 8px;
    cursor: pointer;
    text-align: center;
}

/* ── Admin: brugeradministration ── */
.admin-section     { border-left: 3px solid #7c3aed44; }
.admin-sub-title   { font-size: 15px; font-weight: 600; margin: 20px 0 12px; color: var(--text); }
.admin-user-list   { list-style: none; padding: 0; margin: 0 0 20px; display: flex; flex-direction: column; gap: 8px; }
.admin-user-item   {
    display: flex; align-items: center; justify-content: space-between;
    background: #f9f9f9; border-radius: 10px; padding: 12px 14px; gap: 12px;
}
.admin-user-info   { display: flex; flex-direction: column; gap: 2px; flex: 1; min-width: 0; }
.admin-user-name   { font-weight: 600; font-size: 15px; }
.admin-user-meta   { font-size: 12px; color: #888; }
.admin-user-you    { font-size: 12px; color: var(--accent); font-weight: 600; white-space: nowrap; }
.admin-delete-form { margin: 0; }
.btn-delete-user   {
    background: #fee2e2; color: #dc2626; border: none; border-radius: 8px;
    padding: 6px 12px; font-size: 13px; font-weight: 600; cursor: pointer; white-space: nowrap;
}
.btn-delete-user:hover { background: #fecaca; }
.admin-create-form { display: flex; flex-direction: column; gap: 12px; }

/* ── Animations ── */
@keyframes slideUp {
    from { transform: translateX(-50%) translateY(100%); }
    to   { transform: translateX(-50%) translateY(0); }
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ── Responsivt ── */

/* Tablet (600–1023px): 2 kort side om side */
@media (min-width: 600px) {
    .app-container { max-width: 800px; }
    .recipe-cards  { flex-direction: row; flex-wrap: wrap; }
    .recipe-card   { flex: 1 1 calc(50% - 8px); min-width: 220px; }
}

/* Desktop (900px+): 3 kort pr. dag, bredere layout */
@media (min-width: 900px) {
    .app-container { max-width: 1140px; }
    .main-content  { padding: 28px 32px calc(var(--nav-height) + 16px); }

    .recipe-cards              { display: grid !important; grid-template-columns: repeat(3, 1fr); gap: 16px; }
    .recipe-card               { min-width: 0; }

    .day-name      { font-size: 22px; }
    .generate-bar  { gap: 14px; }
    .user-bar      { padding: 10px 32px; }
    .top-bar       { padding: 0 24px; }
}

/* Lille skærm (iPhone SE m.fl.) */
@media (max-width: 380px) {
    .cuisine-grid { grid-template-columns: repeat(2, 1fr); }
    .card-image   { height: 130px; }
}

/* ── Antal personer – indstillinger ── */
.persons-setting {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 20px;
    padding: 8px 0;
}
.persons-btn {
    width: 44px; height: 44px;
    border-radius: 50%;
    border: 2px solid var(--accent);
    background: transparent;
    color: var(--accent);
    font-size: 22px;
    font-weight: 700;
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
}
.persons-display {
    text-align: center;
    min-width: 60px;
}
.persons-display span:first-child {
    display: block;
    font-size: 36px;
    font-weight: 700;
    color: var(--accent);
    line-height: 1;
}
.persons-label {
    font-size: 13px;
    color: var(--text-sub);
}

/* ── Antal personer – opskrift-modal ── */
.persons-adjuster {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--bg);
    border-radius: var(--radius-sm);
    padding: 10px 14px;
    margin-bottom: 20px;
}
.persons-adj-label {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-sub);
}
.persons-adj-controls {
    display: flex;
    align-items: center;
    gap: 14px;
    font-size: 18px;
    font-weight: 700;
}
.persons-adj-btn {
    width: 32px; height: 32px;
    border-radius: 50%;
    border: 2px solid var(--accent);
    background: transparent;
    color: var(--accent);
    font-size: 18px;
    font-weight: 700;
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
}

/* ── Tilbuds-panel (forsiden) ── */
.deals-panel {
    background: var(--card-bg);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    margin-bottom: 16px;
    overflow: hidden;
}
.deals-summary {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 16px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    list-style: none;
    user-select: none;
}
.deals-summary::-webkit-details-marker { display: none; }
.deals-count {
    margin-left: auto;
    font-size: 12px;
    font-weight: 500;
    color: var(--text-sub);
    background: var(--bg);
    border-radius: 20px;
    padding: 2px 8px;
}
.deals-store-group { border-top: 1px solid var(--border); }
.deals-store-group:first-child { border-top: 1px solid var(--border); }

.deals-store-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 16px;
    cursor: pointer;
    list-style: none;
    user-select: none;
    background: var(--bg);
    transition: background .15s;
    gap: 12px;
}
.deals-store-header > .deals-store-count {
    flex-shrink: 0;
    margin-left: auto;
}
.deals-store-title {
    display: flex;
    flex-direction: column;
    gap: 3px;
}
.deals-store-name {
    font-size: 13px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .4px;
    color: var(--text-sub);
}
.deals-store-desc {
    font-size: 12px;
    font-weight: 400;
    text-transform: none;
    letter-spacing: 0;
    color: var(--text-sub);
    opacity: .75;
}
.deals-store-header::-webkit-details-marker { display: none; }
.deals-store-header::after {
    content: '›';
    font-size: 16px;
    font-weight: 400;
    margin-left: 6px;
    transition: transform .2s;
}
.deals-store-group[open] > .deals-store-header::after {
    transform: rotate(90deg);
}
.deals-store-header:hover { background: var(--border); }
.deals-store-count {
    font-size: 11px;
    font-weight: 500;
    background: var(--border);
    border-radius: 20px;
    padding: 1px 7px;
}

.deals-grid {
    display: flex;
    flex-direction: column;
    max-height: 320px;
    overflow-y: auto;
}
.deal-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 16px;
    border-bottom: 1px solid var(--border);
    font-size: 13px;
    text-decoration: none;
    color: inherit;
}
.deal-item:last-child  { border-bottom: none; }
.deal-link-wrap        { text-decoration: none; color: inherit; display: contents; }
.deal-thumb {
    width: 40px; height: 40px;
    object-fit: cover;
    border-radius: 6px;
    flex-shrink: 0;
    background: var(--bg);
}
.deal-info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.deal-name  { font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.deal-meta  { font-size: 11px; color: var(--text-sub); }
.deal-price { display: flex; flex-direction: column; align-items: flex-end; gap: 2px; white-space: nowrap; flex-shrink: 0; }
.deal-new   { font-weight: 700; color: var(--accent); font-size: 14px; }
.deal-old   { color: var(--text-sub); text-decoration: line-through; font-size: 11px; }
.deal-pct   { font-size: 11px; font-weight: 600; color: var(--green); background: rgba(52,199,89,.12); border-radius: 8px; padding: 1px 5px; }

/* ── Butiksbadge på recipe-kort ── */
.deal-store-badge {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    font-size: 10px;
    font-weight: 600;
    color: var(--green);
    background: rgba(52,199,89,.12);
    border-radius: 20px;
    padding: 2px 7px;
    white-space: nowrap;
    margin-left: auto;
}

/* ── Tilbuds-badge i opskrift-ingredienser ── */
.deal-tag {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    margin-left: 8px;
    font-size: 11px;
    font-weight: 600;
    color: var(--accent);
    background: var(--accent-lt);
    border-radius: 20px;
    padding: 2px 8px;
    white-space: nowrap;
    vertical-align: middle;
}
.deal-tag s { color: var(--text-sub); font-weight: 400; font-size: 10px; }

/* ── Img-gen status ── */
.img-gen-status {
    text-align: center;
    font-size: 13px;
    color: var(--text-sub);
    padding: 6px 0;
}

/* ══════════════════════════════════════════
   DARK MODE
   ══════════════════════════════════════════ */
@media (prefers-color-scheme: dark) {
    :root {
        --bg:       #1C1C1E;
        --card-bg:  #2C2C2E;
        --text:     #F2F2F7;
        --text-sub: #8E8E93;
        --border:   #3A3A3C;
        --accent-lt:#3A1F0F;
    }

    body { background: var(--bg); color: var(--text); }

    .top-bar         { background: rgba(28,28,30,.92); border-bottom-color: var(--border); }
    .bottom-nav      { background: rgba(28,28,30,.92); border-top-color: var(--border); }
    .recipe-card     { background: var(--card-bg); }
    .modal-sheet     { background: var(--card-bg); }
    .modal-overlay   { background: rgba(0,0,0,.7); }
    .settings-section { background: var(--card-bg); }
    .checkbox-option { border-bottom-color: var(--border); }
    .cuisine-option  { background: var(--card-bg); border-color: var(--border); color: var(--text); }
    .cuisine-option.selected { background: var(--accent-lt); border-color: var(--accent); color: var(--accent); }
    .textarea-input  { background: var(--bg); color: var(--text); border-color: var(--border); }
    .search-input    { background: var(--bg); color: var(--text); border-color: var(--border); }
    .login-container { background: var(--card-bg); }
    .auth-form input { background: var(--bg); color: var(--text); border-color: var(--border); }
    .tab-bar-login   { background: var(--bg); }
    .user-bar        { background: var(--bg); border-bottom-color: var(--border); }
    .generate-bar    { background: var(--bg); }
    .day-header      { background: var(--bg); }
    .vote-btn        { background: var(--card-bg); border-color: var(--border); color: var(--text); }
    .btn-outline     { border-color: var(--accent); color: var(--accent); }
    .history-card    { background: var(--card-bg); border-color: var(--border); }
    .persons-adjuster { background: var(--bg); }
    .ingredient-list li, .instructions-list li { border-bottom-color: var(--border); }
    .loading-box     { background: var(--card-bg); }
    .alert-success   { background: #1a3a1a; color: #4ade80; }
    .alert-error     { background: #3a1a1a; color: #f87171; }
    .empty-state     { color: var(--text); }
    .card-image-placeholder { background: var(--accent-lt); }
    .deals-panel            { background: var(--card-bg); border-color: var(--border); }
    .deals-count            { background: var(--bg); }
    .deals-store-header     { background: var(--bg); }
    .deals-store-count      { background: var(--border); }
    .deal-item              { border-bottom-color: var(--border); }
    .deal-tag               { background: var(--accent-lt); }
    .day-skipped-placeholder { background: var(--border); }
    .skip-dialog            { background: var(--card-bg); }
    .skip-option-btn        { background: var(--bg); border-color: var(--border); color: var(--text); }
    .admin-user-item        { background: var(--card-bg); }
    .admin-user-meta        { color: var(--text-sub); }
    .btn-delete-user        { background: #3a1515; color: #f87171; }
    .btn-delete-user:hover  { background: #4a1a1a; }
}
