/* Grundgerüst – das endgültige Design folgt in Etappe 6. */
:root {
    --color-bg: #f3f6fb;
    --color-surface: #ffffff;
    --color-text: #1b2433;
    --color-muted: #5b6678;
    --color-primary: #1e63d6;
    --color-error: #c62828;
    --radius: 16px;
}

* { box-sizing: border-box; }

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

.app-header {
    position: sticky;
    top: 0;
    z-index: 10;
    padding: 14px 16px;
    padding-top: calc(14px + env(safe-area-inset-top));
    background: var(--color-primary);
    color: #fff;
}

.app-title { font-size: 1.25rem; font-weight: 700; }

.app-content { max-width: 720px; margin: 0 auto; padding: 16px; }

/* FocusOnNavigate setzt nach jedem Seitenwechsel den Fokus auf die h1 (für Screenreader) – ohne sichtbaren Rahmen. */
h1:focus { outline: none; }

.competition-tabs {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 8px;
}

.competition-tab {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    min-height: 96px;
    padding: 10px 4px;
    border: 3px solid transparent;
    border-radius: var(--radius);
    background: var(--color-surface);
    color: var(--color-text);
    font: inherit;
    font-size: 0.8rem;
    font-weight: 600;
    text-align: center;
    cursor: pointer;
}

.competition-tab.active { border-color: var(--color-primary); }

.competition-tab img { width: 56px; height: 56px; object-fit: contain; }

.panel {
    margin-top: 16px;
    padding: 16px;
    border-radius: var(--radius);
    background: var(--color-surface);
}

.panel h1 { margin: 0 0 8px; font-size: 1.4rem; }

.message { padding: 16px; color: var(--color-muted); }

.message-error {
    border-radius: var(--radius);
    background: #fdecea;
    color: var(--color-error);
}

.btn {
    display: inline-block;
    min-height: 48px;
    padding: 12px 20px;
    border: 0;
    border-radius: 12px;
    background: var(--color-primary);
    color: #fff;
    font: inherit;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
}

.loading-progress {
    position: absolute;
    display: block;
    width: 8rem;
    height: 8rem;
    inset: 20vh 0 auto 0;
    margin: 0 auto;
}

.loading-progress circle {
    fill: none;
    stroke: #e0e0e0;
    stroke-width: 0.6rem;
    transform-origin: 50% 50%;
    transform: rotate(-90deg);
}

.loading-progress circle:last-child {
    stroke: var(--color-primary);
    stroke-dasharray: calc(3.141 * var(--blazor-load-percentage, 0%) * 0.8), 500%;
    transition: stroke-dasharray 0.05s ease-in-out;
}

.loading-progress-text {
    position: absolute;
    text-align: center;
    font-weight: bold;
    inset: calc(20vh + 3.25rem) 0 auto 0;
}

.loading-progress-text:after { content: var(--blazor-load-percentage-text, "Lade …"); }

#blazor-error-ui {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    z-index: 1000;
    padding: 12px 16px;
    background: #fff3cd;
    box-shadow: 0 -1px 4px rgba(0, 0, 0, 0.2);
}

#blazor-error-ui .dismiss { position: absolute; right: 16px; top: 12px; cursor: pointer; }

/* ---------- Kopfzeile ---------- */
.app-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.app-title { color: #fff; text-decoration: none; }
.app-header-nav { display: flex; align-items: center; gap: 8px; }
.header-link {
    display: inline-flex;
    align-items: center;
    min-height: 40px;
    padding: 6px 12px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.18);
    color: #fff;
    font-weight: 600;
    text-decoration: none;
    max-width: 40vw;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ---------- Formulare ---------- */
.panel-narrow { max-width: 420px; margin-left: auto; margin-right: auto; }
.panel h2 { margin: 0 0 12px; font-size: 1.2rem; }
.field { display: block; margin-bottom: 14px; }
.field > span { display: block; margin-bottom: 4px; font-weight: 600; }
.field > small { display: block; margin-top: 4px; color: var(--color-muted); }
.input {
    width: 100%;
    min-height: 48px;
    padding: 10px 12px;
    border: 2px solid #c9d2e0;
    border-radius: 12px;
    background: #fff;
    color: var(--color-text);
    font: inherit;
}
.input:focus { outline: none; border-color: var(--color-primary); }
.input-pin { letter-spacing: 0.5em; font-size: 1.4rem; text-align: center; }
.input-code { letter-spacing: 0.15em; text-transform: uppercase; }
.form-error, .form-success { margin: 0 0 14px; padding: 10px 12px; border-radius: 12px; font-weight: 600; }
.form-error { background: #fdecea; color: var(--color-error); }
.form-success { background: #e6f6ec; color: #17693a; }
.hint { color: var(--color-muted); }
.hint a { color: var(--color-primary); font-weight: 600; }
.inline-form { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 10px; margin-bottom: 14px; }
.inline-form .field { flex: 1 1 110px; margin-bottom: 0; }

/* ---------- Schaltflächen ---------- */
.btn:disabled { opacity: 0.6; cursor: default; }
.btn-block { display: block; width: 100%; }
.btn-secondary { background: #e4eaf4; color: var(--color-text); }
.btn-danger { background: var(--color-error); }
.btn-small { min-height: 40px; padding: 8px 14px; font-size: 0.9rem; }

/* ---------- Listen ---------- */
.list { list-style: none; margin: 0; padding: 0; }
.list-item {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px 12px;
    padding: 12px 0;
    border-top: 1px solid #e3e8f0;
}
.list-main { flex: 1 1 200px; min-width: 0; }
.list-main small { display: block; margin-top: 2px; color: var(--color-muted); }
.list-title { font-weight: 700; }
.list-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.list-extra { flex: 1 1 100%; margin: 4px 0 0; }
.code { font-family: ui-monospace, Consolas, monospace; font-size: 1.15rem; font-weight: 700; letter-spacing: 0.08em; }
.code-inactive { color: var(--color-muted); text-decoration: line-through; }
.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 0.75rem; font-weight: 700; }
.badge-ok { background: #e6f6ec; color: #17693a; }
.badge-warn { background: #fff1d6; color: #8a5200; }
.badge-neutral { background: #e4eaf4; color: #3c4a61; }

/* ---------- Saisons und Kartenlisten ---------- */
.competition-tab img { width: 72px; height: 72px; border-radius: 10px; }
.season-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; margin: 12px 0; }
.season-card {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-height: 84px;
    padding: 14px;
    border-radius: var(--radius);
    background: #eaf1fd;
    color: var(--color-text);
    text-decoration: none;
}
.season-card:hover, .season-card:focus-visible { background: #d9e6fb; }
.season-name { font-size: 1.25rem; font-weight: 700; }
.season-count { color: var(--color-muted); font-size: 0.9rem; }
.admin-box { margin-top: 16px; padding-top: 14px; border-top: 1px dashed #c9d2e0; }

.page-header { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.page-header img { width: 48px; height: 48px; border-radius: 8px; object-fit: contain; background: #fff; }
.page-header-text { flex: 1 1 auto; min-width: 0; }
/* Knöpfe im Seitenkopf nie umbrechen; wird es zu eng (Handy, Admin mit "Neuer Tausch" + "Verwalten"),
   rutschen sie in eine eigene Zeile, statt den Titel zusammenzudrücken. */
.page-header { flex-wrap: wrap; row-gap: 10px; }
.page-header-text { flex-basis: 110px; }
.page-header > .btn { white-space: nowrap; }
.page-header h1 { margin: 0; font-size: 1.35rem; }
.page-header-text span { color: var(--color-muted); font-size: 0.9rem; }
.back-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 44px;
    height: 44px;
    border-radius: 50%;
    background: var(--color-surface);
    color: var(--color-primary);
    font-size: 1.8rem;
    line-height: 1;
    text-decoration: none;
}

.toolbar { margin-bottom: 12px; }
.card-list { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: 1fr; gap: 8px; }
.card-row {
    display: flex;
    align-items: center;
    gap: 12px;
    min-height: 60px;
    padding: 8px 12px;
    border-radius: 14px;
    background: var(--color-surface);
}
.card-number {
    flex: 0 0 auto;
    min-width: 46px;
    padding: 6px 8px;
    border-radius: 10px;
    background: #eaf1fd;
    color: var(--color-primary);
    font-weight: 700;
    text-align: center;
}
.card-text { flex: 1 1 auto; min-width: 0; }
.card-name { display: block; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card-text small { display: block; color: var(--color-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.badge-special { background: #efe3ff; color: #5b2aa8; }
.badge-error { background: #fdecea; color: var(--color-error); }

/* ---------- Import ---------- */
.file-picker { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; margin: 12px 0; cursor: pointer; }
.file-picker input[type=file] { position: absolute; width: 1px; height: 1px; opacity: 0; }
.file-picker:focus-within .btn { outline: 3px solid var(--color-primary); outline-offset: 2px; }
.file-name { color: var(--color-muted); word-break: break-all; }
.summary { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0; }
.summary .badge { font-size: 0.9rem; padding: 4px 12px; }
.error-list { margin: 8px 0 0; padding-left: 20px; font-weight: 400; }
.form-error p { margin: 0; }
.table-scroll { overflow-x: auto; margin: 12px 0; border: 1px solid #e3e8f0; border-radius: 12px; }
.table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
.table th, .table td { padding: 8px 10px; text-align: left; white-space: nowrap; border-bottom: 1px solid #e3e8f0; }
.table th { background: #f3f6fb; font-weight: 700; }
.table tr:last-child td { border-bottom: 0; }
.button-row { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 12px; }

/* ---------- Desktop-Ansicht ---------- */
@media (min-width: 900px) {
    .app-content { max-width: 1100px; padding: 24px; }
    .app-header { padding-left: 24px; padding-right: 24px; }
    .competition-tabs { gap: 16px; }
    .competition-tab { flex-direction: row; justify-content: center; gap: 14px; font-size: 1.05rem; min-height: 104px; }
    .season-grid { grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 14px; }
    .card-list { grid-template-columns: repeat(auto-fill, minmax(330px, 1fr)); gap: 10px; }
    .toolbar { max-width: 420px; }
    .header-link { max-width: 260px; }
}

/* ---------- Bestand ---------- */
.progress-box { margin-bottom: 12px; padding: 12px 14px; border-radius: var(--radius); background: var(--color-surface); }
.progress-text { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 8px; }
.progress-text strong { font-size: 1.3rem; }
.progress-text span { color: var(--color-muted); }
/* ---------- Benachrichtigungen ("Mein Konto"): sichtbar ist nur der Teil zum aktuellen Zustand (push.js) ---------- */
[class*="push-zeige-"] { display: none; }
html.push-bereit .push-zeige-bereit,
html.push-laedt .push-zeige-laedt,
html.push-aktiv .push-zeige-aktiv,
html.push-blockiert .push-zeige-blockiert,
html.push-ios-hinweis .push-zeige-ios-hinweis,
html.push-nicht-unterstuetzt .push-zeige-nicht-unterstuetzt,
html.push-kein-https .push-zeige-kein-https,
html.push-aus .push-zeige-aus { display: block; }
.push-panel ol { margin: 8px 0 0; padding-left: 22px; }

.download-links { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 12px; padding-top: 12px; border-top: 1px solid #e4eaf4; }
.download-title { display: inline-flex; align-items: center; gap: 8px; margin-right: 4px; font-weight: 700; color: var(--color-text); }
/* Kleines Excel-Symbol (grünes Kästchen mit X), ohne Bilddatei. */
.excel-icon {
    display: inline-flex; align-items: center; justify-content: center;
    width: 24px; height: 24px; border-radius: 5px;
    background: #1d6f42; color: #fff; font-size: 0.85rem; font-weight: 800; font-family: Arial, sans-serif;
}
.btn-excel { display: inline-flex; align-items: center; gap: 6px; background: #e8f3ec; color: #1d6f42; border: 2px solid #1d6f42; font-weight: 700; text-decoration: none; }
.btn-excel:hover, .btn-excel:focus-visible { background: #1d6f42; color: #fff; }
@media (max-width: 640px) {
    /* Handy: Überschrift oben, darunter die drei Knöpfe gleich breit in einer Reihe. */
    .download-title { flex-basis: 100%; }
    .download-links .btn-excel { flex: 1 1 0; justify-content: center; }
}
.progress-bar { height: 14px; border-radius: 999px; background: #e4eaf4; overflow: hidden; }
.progress-fill { height: 100%; border-radius: 999px; background: #22a55b; transition: width 0.2s ease; }

.toolbar { display: flex; flex-direction: column; gap: 10px; max-width: none; }
.filter-chips { display: flex; gap: 8px; }
.chip {
    flex: 1 1 0;
    min-height: 44px;
    padding: 6px 10px;
    border: 2px solid transparent;
    border-radius: 999px;
    background: var(--color-surface);
    color: var(--color-text);
    font: inherit;
    font-weight: 600;
    cursor: pointer;
}
.chip.active { background: var(--color-primary); color: #fff; }
.chip-count { opacity: 0.75; font-weight: 400; }

.card-row { flex-direction: column; align-items: stretch; gap: 6px; border: 2px solid transparent; }
.card-row.owned { border-color: #bfe6cf; background: #f4fbf6; }
.card-main { display: flex; align-items: center; gap: 12px; min-width: 0; }
.card-text small .badge { margin-left: 4px; }
.check-button {
    flex: 0 0 48px;
    width: 48px;
    height: 48px;
    border: 3px solid #b9c4d6;
    border-radius: 14px;
    background: #fff;
    color: #fff;
    font-size: 1.6rem;
    font-weight: 700;
    line-height: 1;
    cursor: pointer;
}
.check-button.checked { border-color: #22a55b; background: #22a55b; }
.card-duplicates { display: flex; align-items: center; gap: 8px; padding-left: 58px; }
.duplicate-text { flex: 1 1 auto; color: var(--color-muted); font-size: 0.9rem; }
.duplicate-text.has-duplicates { color: #8a5200; font-weight: 700; }
.step-button {
    flex: 0 0 48px;
    width: 48px;
    height: 40px;
    border: 0;
    border-radius: 12px;
    background: #e4eaf4;
    color: var(--color-text);
    font-size: 1.4rem;
    font-weight: 700;
    line-height: 1;
    cursor: pointer;
}
.step-button:disabled { opacity: 0.4; cursor: default; }
.toast { position: sticky; top: 76px; z-index: 5; }

@media (min-width: 900px) {
    .toolbar { flex-direction: row; align-items: center; }
    .filter-chips { flex: 0 0 auto; }
    .chip { flex: 0 0 auto; padding: 6px 18px; }
    .toolbar .input { max-width: 380px; }
}

.toolbar-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
select.input { appearance: auto; }
@media (max-width: 420px) { .toolbar-fields { grid-template-columns: 1fr; } }
@media (min-width: 900px) {
    .toolbar-fields { flex: 1 1 auto; grid-template-columns: minmax(200px, 340px) minmax(200px, 280px); }
    .toolbar .toolbar-fields .input { max-width: none; }
}

/* ---------- Kopfzeile: Tausch-Markierung ---------- */
.app-title { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.header-link { position: relative; flex: 0 0 auto; }
.header-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 22px;
    height: 22px;
    margin-left: 6px;
    padding: 0 6px;
    border-radius: 999px;
    background: #ffcc00;
    color: #3a2c00;
    font-size: 0.8rem;
    font-weight: 800;
}
@media (max-width: 640px) {
    /* Auf dem Handy bleibt nur der Ball als Titel, damit das Menü Platz hat. */
    .app-title-text { display: none; }
    .app-title { font-size: 1.6rem; }
    .app-header-nav { gap: 6px; min-width: 0; }
    .header-link { padding: 6px 10px; font-size: 0.9rem; }
}
/* "Meine Tausche" samt gelber Zahl nie abschneiden; kürzen darf sich notfalls nur der eigene Name. */
.header-link:first-child { max-width: none; }
.header-link.header-user { flex: 0 1 auto; min-width: 0; }

/* ---------- Wer hat was? ---------- */
.partner-list { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: 1fr; gap: 10px; }
.partner-card {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    border-radius: var(--radius);
    background: var(--color-surface);
    color: var(--color-text);
    text-decoration: none;
}
.partner-card.no-match { opacity: 0.7; }
.avatar {
    flex: 0 0 48px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: 48px;
    border-radius: 50%;
    background: var(--color-primary);
    color: #fff;
    font-size: 1.3rem;
    font-weight: 700;
}
.partner-text { flex: 1 1 auto; min-width: 0; }
.partner-text strong { display: block; font-size: 1.1rem; }
.partner-facts { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; }
.fact { padding: 2px 10px; border-radius: 999px; background: #e4eaf4; font-size: 0.85rem; }
.fact-get { background: #e6f6ec; color: #17693a; }
.fact-give { background: #fff1d6; color: #8a5200; }
.chevron { color: var(--color-muted); font-size: 1.6rem; }
.legend { margin-top: 12px; font-size: 0.9rem; }

/* ---------- Tausch anbieten ---------- */
.trade-columns { display: grid; grid-template-columns: 1fr; gap: 0; }
.trade-side h2, .trade-section h2 { display: flex; align-items: baseline; gap: 8px; }
.count { color: var(--color-muted); font-size: 0.9rem; font-weight: 400; }
.trade-side-get { border-top: 5px solid #22a55b; }
.trade-side-give { border-top: 5px solid #f0a020; }
.select-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }

/* Bei vielen Doppelten scrollt jede Liste für sich; Überschrift ("Du bekommst"/"Du gibst") und der
   Knopf "Tausch anbieten" bleiben dabei sichtbar. Auf dem Handy passen so beide Listen auf den Bildschirm. */
.trade-side .select-list {
    /* 410px = Kopfzeile, Seitenkopf, beide Überschriften und der Knopf unten. */
    max-height: max(180px, calc((100vh - 410px) / 2));
    max-height: max(180px, calc((100dvh - 410px) / 2));
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: 2px 4px 2px 0;
    border-top: 1px solid #e4eaf4;
    border-bottom: 1px solid #e4eaf4;
    padding-top: 8px;
    padding-bottom: 8px;
}
.select-card {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    min-height: 56px;
    padding: 8px 10px;
    border: 2px solid #dfe5ee;
    border-radius: 14px;
    background: #fff;
    color: var(--color-text);
    font: inherit;
    text-align: left;
    cursor: pointer;
}
.select-card.selected { border-color: var(--color-primary); background: #eaf1fd; }
.select-mark {
    flex: 0 0 32px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: 32px;
    border: 2px solid #b9c4d6;
    border-radius: 50%;
    color: #fff;
    font-weight: 700;
}
.select-card.selected .select-mark { border-color: var(--color-primary); background: var(--color-primary); }
.plain-card-list { list-style: none; margin: 12px 0 0; padding: 0; display: grid; gap: 6px; }
.plain-card-list small { color: var(--color-muted); }
details.panel summary { cursor: pointer; font-weight: 600; }
.action-bar {
    position: sticky;
    bottom: 0;
    margin: 16px -16px 0;
    padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
    background: rgba(243, 246, 251, 0.95);
    border-top: 1px solid #dfe5ee;
}
.action-bar .form-error { margin-bottom: 10px; }

/* ---------- Meine Tausche ---------- */
.trade-section { margin-bottom: 20px; }
.trade-section h2 { margin: 0; font-size: 1.2rem; }
.trade-section > .hint { margin: 2px 0 10px; font-size: 0.9rem; }
.trade-grid { display: grid; grid-template-columns: 1fr; gap: 12px; }
.trade-card { padding: 14px; border-radius: var(--radius); background: var(--color-surface); border-left: 6px solid #b9c4d6; }
.trade-card.status-angeboten { border-left-color: var(--color-primary); }
.trade-card.status-akzeptiert { border-left-color: #f0a020; }
.trade-card.status-abgeschlossen { border-left-color: #22a55b; }
.trade-card-header { display: flex; align-items: center; gap: 10px; }
.trade-card-header img { width: 36px; height: 36px; border-radius: 6px; object-fit: contain; }
.trade-card-header strong { display: block; font-size: 1.1rem; }
.trade-card-header small { color: var(--color-muted); }
.trade-status { margin: 10px 0; font-weight: 600; }
.trade-cards { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.trade-cards-side { padding: 8px 10px; border-radius: 12px; min-width: 0; }
.trade-cards-get { background: #e6f6ec; }
.trade-cards-give { background: #fff1d6; }
.trade-cards-side h3 { margin: 0 0 6px; font-size: 0.85rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--color-muted); }
.trade-cards-side ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; font-size: 0.9rem; }
.trade-cards-side li { display: flex; align-items: center; gap: 6px; min-width: 0; }
.trade-cards-side li span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.trade-cards-side .card-number { min-width: 0; padding: 2px 6px; font-size: 0.8rem; background: rgba(255, 255, 255, 0.7); }
.trade-cards-side .hint { margin: 0; }
.confirm-state { display: flex; gap: 14px; margin: 10px 0 0; color: var(--color-muted); font-weight: 600; }
.confirm-state .done { color: #17693a; }
.btn-success { background: #22a55b; }

@media (min-width: 900px) {
    .partner-list { grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); }
    .trade-columns { grid-template-columns: 1fr 1fr; gap: 16px; }
    .trade-columns .panel { margin-top: 0; }
    /* Nebeneinander ist mehr Höhe da: die Listen füllen den Bildschirm bis zum Knopf unten. */
    .trade-side .select-list { max-height: max(300px, calc(100vh - 380px)); max-height: max(300px, calc(100dvh - 380px)); }
    .trade-grid { grid-template-columns: repeat(auto-fill, minmax(420px, 1fr)); }
    .action-bar { margin: 16px 0 0; border-radius: var(--radius); border: 1px solid #dfe5ee; }
    .action-bar .btn { max-width: 480px; margin: 0 auto; }
}

/* Lange Texte dürfen Listen nicht breiter als den Bildschirm machen. */
.card-list, .partner-list, .select-list, .trade-grid, .trade-columns { grid-template-columns: minmax(0, 1fr); }
.card-row, .card-main, .trade-card, .panel { min-width: 0; }
html, body { overflow-x: clip; }
@media (min-width: 900px) {
    .card-list { grid-template-columns: repeat(auto-fill, minmax(330px, 1fr)); }
    .partner-list { grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); }
    .trade-grid { grid-template-columns: repeat(auto-fill, minmax(420px, 1fr)); }
    .trade-columns { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
}

/* ---------- Fixierter Bereich über der Kartenliste ---------- */
:root { --app-header-height: 64px; }
.app-header {
    box-sizing: content-box;
    height: var(--app-header-height);
    padding-top: env(safe-area-inset-top);
    padding-bottom: 0;
}
.toolbar-fields { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }

/* Smartphone: Titel und Fortschritt scrollen mit, nur Filter und Suche bleiben stehen (sonst bliebe zu wenig Platz für die Liste). */
.sticky-area .toolbar {
    position: sticky;
    top: calc(var(--app-header-height) + env(safe-area-inset-top));
    z-index: 5;
    margin: 0 -16px 12px;
    padding: 10px 16px;
    background: var(--color-bg);
    box-shadow: 0 6px 8px -8px rgba(20, 40, 80, 0.35);
}
.sticky-area { display: contents; }
.sticky-area .toolbar .form-error { margin: 0; }

/* Desktop: der ganze Bereich (Titel, Fortschritt, Filter) bleibt stehen, darunter scrollt die Liste. */
@media (min-width: 900px) {
    .sticky-area {
        display: block;
        position: sticky;
        top: calc(var(--app-header-height) + env(safe-area-inset-top));
        z-index: 5;
        margin: -24px -24px 14px;
        padding: 20px 24px 12px;
        background: var(--color-bg);
        box-shadow: 0 6px 8px -8px rgba(20, 40, 80, 0.35);
    }
    .sticky-area .toolbar { position: static; margin: 0; padding: 0; box-shadow: none; }
    .sticky-area .progress-box { margin-bottom: 12px; }
    .sticky-area .toolbar-fields { grid-template-columns: minmax(200px, 340px) minmax(200px, 280px); }
}
