/* ============================================================
   LBZ Checkup – Dynamischer Antrags-Assistent
   Design basierend auf dem offiziellen LBZ-Styleguide
   (Schwarz #0D0D0B · Gelb #FFCE00 · Inter)
   ============================================================ */

:root {
    --black: #0d0d0b;
    --yellow: #ffce00;
    --yellow-dark: #e6b800;
    --ink: #1d1d1f;
    --ink-2: #3a3a3c;
    --muted: #6e6e73;
    --bg: #dbdbdb;
    --card: #ffffff;
    --line: rgba(0, 0, 0, 0.08);
    --line-strong: rgba(0, 0, 0, 0.18);
    --red: #d70015;
    --radius-s: 8px;
    --radius: 14px;
    --radius-l: 20px;
    --ease: cubic-bezier(0.4, 0, 0.2, 1);
    --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

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

html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }

body {
    font-family: var(--font);
    color: var(--ink);
    background: var(--bg);
    background-image:
        radial-gradient(1100px 560px at 88% -8%, rgba(255, 206, 0, 0.13), transparent 60%),
        radial-gradient(900px 480px at -8% 28%, rgba(255, 206, 0, 0.07), transparent 55%);
    background-attachment: fixed;
    min-height: 100vh;
    font-size: 16px;
    line-height: 1.5;
}

body.no-scroll { overflow: hidden; }

::selection { background: var(--yellow); color: var(--black); }

/* ---------------- Topbar ---------------- */

.topbar {
    position: sticky;
    top: 0;
    z-index: 50;
    background: rgba(255, 255, 255, 0.92);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    border-bottom: 1px solid var(--line);
}

.topbar-inner {
    max-width: 1180px;
    margin: 0 auto;
    padding: 12px 20px;
    display: flex;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
}

.brand { display: flex; align-items: center; gap: 12px; text-decoration: none; color: inherit; }

.brand-logo { height: 30px; width: auto; }

.brand-name { font-size: 18px; font-weight: 600; letter-spacing: -0.02em; }

.brand-name::after {
    content: '';
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--yellow);
    margin-left: 7px;
    vertical-align: 2px;
}

.brand-tag { color: var(--muted); font-size: 12.5px; font-weight: 600; }

.topbar-actions { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

.autosave-note { color: var(--muted); font-size: 12px; margin-right: 4px; white-space: nowrap; }

/* ---------------- Fortschritt ---------------- */

.progress-shell { position: relative; height: 26px; background: #fff; border-top: 1px solid var(--line); }

.progress-bar {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, var(--yellow), #ffe566);
    transition: width 0.45s var(--ease);
}

.progress-meta {
    position: absolute;
    right: 14px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 12px;
    font-weight: 600;
    color: var(--muted);
}

/* ---------------- Buttons ---------------- */

.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    border: 1.5px solid transparent;
    border-radius: 999px;
    padding: 9px 18px;
    font: inherit;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.16s var(--ease);
    text-decoration: none;
    white-space: nowrap;
}

.btn-primary { background: var(--black); color: #fff; }
.btn-primary:hover { transform: translateY(-1px); }

.btn-accent { background: var(--yellow); color: var(--black); }
.btn-accent:hover { background: var(--yellow-dark); transform: translateY(-1px); }

.btn-ghost { background: #fff; border-color: var(--line-strong); color: var(--ink); }
.btn-ghost:hover { border-color: var(--black); }

.btn-danger { color: var(--red); border-color: rgba(215, 0, 21, 0.35); }
.btn-danger:hover { background: rgba(215, 0, 21, 0.06); border-color: var(--red); }

.btn-danger-solid { background: var(--red); color: #fff; }
.btn-danger-solid:hover { background: #b30012; }

.btn-sm { padding: 6px 14px; font-size: 12.5px; }

/* Einheitlicher Fokus-Ring statt Chromium-Blau (als outline, kein Box-Shadow) */
.seg-btn:focus-visible,
.btn:focus-visible,
.check:focus-visible,
.nav-item:focus-visible,
.module-head:focus-visible,
.file-picker:focus-visible {
    outline: 3px solid rgba(255, 206, 0, 0.55);
    outline-offset: 2px;
}

/* ---------------- Banner ---------------- */

.banner { max-width: 1180px; margin: 18px auto 0; padding: 14px 18px; border-radius: 12px; font-size: 13.5px; font-weight: 600; }

.banner[hidden] { display: none; }

.banner-error { background: #ffe9eb; color: #8c0011; border: 1px solid #ffb3bc; }

/* ---------------- Layout ---------------- */

.layout {
    max-width: 1180px;
    margin: 26px auto 60px;
    padding: 0 20px;
    display: grid;
    grid-template-columns: 264px minmax(0, 1fr);
    gap: 26px;
    align-items: start;
}

.sidebar { position: sticky; top: 112px; }

.sidenav { display: flex; flex-direction: column; gap: 6px; }

.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 10px 12px;
    border: 0;
    background: transparent;
    border-radius: 12px;
    cursor: pointer;
    font: inherit;
    text-align: left;
    color: var(--ink-2);
    transition: all 0.16s var(--ease);
}

.nav-item:hover { background: #fff; }

.nav-item.active { background: var(--black); color: #fff; }

.nav-num {
    width: 24px;
    height: 24px;
    flex: 0 0 24px;
    border-radius: 8px;
    background: #e8e8ec;
    display: grid;
    place-items: center;
    font-size: 12px;
    font-weight: 700;
}

.nav-item.active .nav-num { background: var(--yellow); color: var(--black); }

.nav-label {
    font-size: 14px;
    font-weight: 500;
    flex: 1;
    min-width: 0;
    white-space: normal;
    overflow-wrap: break-word;
    word-break: break-word;
    line-height: 1.3;
}

.nav-count {
    font-size: 11.5px;
    font-weight: 700;
    color: var(--muted);
    background: #f0f0f2;
    padding: 2px 7px;
    border-radius: 999px;
}

.nav-item.active .nav-count { background: rgba(255, 255, 255, 0.16); color: #fff; }

/* ---------------- Hero ---------------- */

.hero {
    background: linear-gradient(135deg, #171716 0%, #0d0d0b 62%, #2b2608 135%);
    border-radius: var(--radius-l);
    padding: 44px 48px;
    color: #fff;
    position: relative;
    overflow: hidden;
    margin-bottom: 26px;
}

.hero::before {
    content: '';
    position: absolute;
    inset: 0;
    background: radial-gradient(640px 260px at 92% -18%, rgba(255, 206, 0, 0.38), transparent 70%);
    pointer-events: none;
}

.hero::after {
    content: '';
    position: absolute;
    left: 0;
    right: 0;
    top: 0;
    height: 4px;
    background: linear-gradient(90deg, var(--yellow), #ffe566);
}

.hero-kicker {
    font-weight: 800;
    letter-spacing: 3px;
    text-transform: uppercase;
    font-size: 12px;
    color: var(--yellow);
}

.hero-title {
    font-size: clamp(22px, 3vw, 34px);
    font-weight: 800;
    letter-spacing: -0.02em;
    line-height: 1.2;
    margin: 10px 0 12px;
    max-width: 900px;
}

.hero-desc { color: rgba(255, 255, 255, 0.75); max-width: 780px; }

.hero-chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 22px; position: relative; }

.chip {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.16);
    color: #fff;
    padding: 6px 13px;
    border-radius: 999px;
    font-size: 12.5px;
    font-weight: 600;
}

.chip-yellow { background: var(--yellow); color: var(--black); border-color: transparent; font-weight: 700; }

/* ---------------- Abschnitt-Karten ---------------- */

.section {
    background: var(--card);
    border-radius: var(--radius-l);
    border: 1px solid var(--line);
    margin-bottom: 22px;
    overflow: hidden;
    scroll-margin-top: 120px;
}

.section-head {
    display: flex;
    gap: 16px;
    align-items: flex-start;
    padding: 22px 28px;
    border-bottom: 1px solid var(--line);
    background: linear-gradient(180deg, #fdfdfd, #fafafa);
    flex-wrap: wrap;
}

.sec-num {
    width: 38px;
    height: 38px;
    flex: 0 0 38px;
    border-radius: 12px;
    background: var(--black);
    color: var(--yellow);
    display: grid;
    place-items: center;
    font-weight: 800;
    font-size: 17px;
}

.sec-titles { flex: 1; min-width: 200px; }

.sec-titles h2 { font-size: 20px; font-weight: 600; letter-spacing: -0.01em; }

.sec-titles p { color: var(--muted); font-size: 13.5px; margin-top: 4px; max-width: 720px; }

.sec-insurers { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }

.section-body { padding: 26px 28px 30px; }

/* ---------------- Felder ---------------- */

.field { margin-bottom: 32px; }

/* Trennlinie über jeder Frage außer der ersten eines Blocks */
.field:not(:first-child) {
    border-top: 1.5px solid #7d7d7d;
    padding-top: 30px;
}

.section-body > .field:last-child,
.subcard-body .field:last-child { margin-bottom: 0; }

.field-label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 400;
    font-size: 16px;
    margin-bottom: 8px;
}

/* Grüner Check-Haken für beantwortete Fragen */
.check-done {
    display: inline-grid;
    place-items: center;
    width: 18px;
    height: 18px;
    flex: 0 0 18px;
    border-radius: 50%;
    background: #2ea043;
    color: #fff;
    font-size: 11px;
    font-weight: 800;
    animation: check-pop 0.28s var(--ease);
}

.check-done[hidden] { display: none; }

@keyframes check-pop {
    from { transform: scale(0.4); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

.nav-done {
    display: inline-grid;
    place-items: center;
    width: 17px;
    height: 17px;
    border-radius: 50%;
    background: #2ea043;
    color: #fff;
    font-size: 10px;
    font-weight: 800;
    flex: 0 0 auto;
    animation: check-pop 0.28s var(--ease);
}

.nav-done[hidden] { display: none; }

.sec-num.is-done {
    background: #2ea043;
    color: #fff;
}

.subcard-head { margin-bottom: 4px; }

.subcard-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 600;
    font-size: 16px;
    margin-bottom: 4px;
}

.repeat-item-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 500;
    font-size: 15px;
    color: var(--ink-2);
}

.module-title {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-weight: 500;
    font-size: 15.5px;
}

.sec-titles h2 {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 20px;
    font-weight: 600;
    letter-spacing: -0.01em;
}

.tag-opt {
    background: #f0f0f2;
    color: var(--muted);
    border-radius: 999px;
    padding: 2px 9px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.3px;
}

.input {
    width: 100%;
    height: 46px;
    padding: 0 14px;
    border: 1.5px solid var(--line-strong);
    border-radius: 10px;
    font: inherit;
    font-size: 16px;
    background: #fff;
    color: var(--ink);
    transition: border-color 0.15s var(--ease);
}

/* Mehrzeilige Textfelder: wachsen mit dem Inhalt (Enter = neue Zeile) */
textarea.input {
    height: auto;
    min-height: 46px;
    padding: 11px 14px;
    line-height: 1.5;
    resize: none;
    overflow: hidden;
    display: block;
}

.input:focus {
    outline: none;
    border-color: var(--black);
    outline: 4px solid rgba(255, 206, 0, 0.45);
    outline-offset: -1px;
}

.input::placeholder { color: #b3b3b8; }

select.input {
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%236e6e73' stroke-width='2' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 15px center;
    padding-right: 42px;
    cursor: pointer;
}

input.sig { font-family: 'Segoe Script', 'Brush Script MT', cursive; font-size: 20px; }

/* Datum-Feld: native Breite begrenzen – verhindert horizontales Überlaufen (Overscroll) auf Mobilgeräten */
input[type='date'].input {
    min-width: 0;
    max-width: 100%;
}

/* iOS: natives Datum-Widget kompakt rendern, sonst läuft es über den Screen */
@supports (-webkit-touch-callout: none) {
    input[type='date'].input {
        -webkit-appearance: none;
        appearance: none;
    }
}

/* Versicherer-Badge bei Fragen, die nicht für alle gelten */
.chip-insurer {
    margin-left: auto;
    background: #f0f0f2;
    color: var(--muted);
    border-radius: 999px;
    padding: 3px 10px;
    font-size: 11.5px;
    font-weight: 500;
    letter-spacing: 0.3px;
    flex: 0 0 auto;
}

/* Datei-Upload */
.file-picker {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    border: 1.5px dashed var(--line-strong);
    border-radius: 12px;
    background: #fafafa;
    cursor: pointer;
    transition: all 0.16s var(--ease);
}

.file-picker:hover { border-color: var(--yellow); background: rgba(255, 206, 0, 0.06); }

.file-btn {
    background: var(--black);
    color: #fff;
    font-size: 13.5px;
    font-weight: 500;
    padding: 8px 16px;
    border-radius: 999px;
    transition: all 0.16s var(--ease);
}

.file-picker:hover .file-btn { background: #000; }

.file-name {
    color: var(--muted);
    font-size: 13px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.file-real {
    position: absolute;
    opacity: 0;
    width: 1px;
    height: 1px;
    pointer-events: none;
}

/* Ja/Nein-Segmentsteuerung */

.seg {
    display: inline-flex;
    background: #ececf0;
    border-radius: 999px;
    padding: 3px;
    gap: 3px;
}

.seg-btn {
    border: 0;
    background: transparent;
    padding: 9px 28px;
    border-radius: 999px;
    font: inherit;
    font-weight: 500;
    color: var(--muted);
    cursor: pointer;
    transition: all 0.18s var(--ease);
}

.seg-btn:hover { color: var(--ink); }

.seg-btn.on { background: var(--black); color: #fff; }

/* Bestätigungs-Checkbox */

.check {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    cursor: pointer;
    padding: 14px 16px;
    border: 1.5px solid var(--line);
    border-radius: 12px;
    background: #fafafa;
    transition: all 0.16s var(--ease);
}

.check:hover { border-color: var(--line-strong); }

.check-input { position: absolute; opacity: 0; pointer-events: none; }

.check-box {
    width: 22px;
    height: 22px;
    flex: 0 0 22px;
    border: 1.5px solid var(--line-strong);
    border-radius: 7px;
    display: grid;
    place-items: center;
    color: transparent;
    font-size: 13px;
    font-weight: 800;
    transition: all 0.15s var(--ease);
    background: #fff;
    margin-top: 1px;
}

.check-input:checked + .check-box { background: var(--yellow); border-color: var(--yellow); color: var(--black); }

.check-input:focus-visible + .check-box {
    outline: 4px solid rgba(255, 206, 0, 0.45);
    outline-offset: 2px;
}

.check-text { font-weight: 400; font-size: 16px; }

/* Bedingte Folgefragen (childrenYes) */

.cond {
    display: grid;
    grid-template-rows: 0fr;
    transition: grid-template-rows 0.4s var(--ease);
}

.cond.open { grid-template-rows: 1fr; }

.cond-inner { overflow: hidden; min-height: 0; }

.cond.open .cond-inner { padding-left: 20px; border-left: 3px solid var(--yellow); margin-left: 2px; }

.cond.open .cond-inner .field:first-child { margin-top: 26px; }

/* Untergruppen */

.subcard {
    background: #fbfbfd;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 18px 20px;
}

.subcard + .subcard, .subcard + .field, .field + .subcard, .subcard + .repeat, .repeat + .subcard { margin-top: 18px; }

.subcard-desc { color: var(--muted); font-size: 13px; margin-bottom: 14px; }

/* Wiederholbare Blöcke */

.repeat { margin-top: 6px; }

.repeat-list { display: flex; flex-direction: column; gap: 12px; }

.repeat-item {
    border: 1.5px dashed var(--line-strong);
    border-radius: var(--radius);
    background: #fbfbfd;
    padding: 16px 18px;
}

.repeat-item-head { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }

.repeat-index {
    width: 30px;
    height: 30px;
    flex: 0 0 30px;
    border-radius: 50%;
    background: var(--yellow);
    color: var(--black);
    font-weight: 800;
    display: grid;
    place-items: center;
    font-size: 13px;
}

.btn-remove {
    margin-left: auto;
    border: 1px solid var(--line);
    background: #fff;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    cursor: pointer;
    color: var(--muted);
    font-size: 13px;
    transition: all 0.15s var(--ease);
}

.btn-remove:hover { background: var(--red); color: #fff; border-color: var(--red); }

.btn-add {
    width: 100%;
    margin-top: 12px;
    padding: 12px;
    border: 1.5px dashed var(--line-strong);
    background: transparent;
    border-radius: var(--radius);
    font: inherit;
    font-weight: 500;
    color: var(--ink-2);
    cursor: pointer;
    transition: all 0.2s var(--ease);
}

.btn-add:hover { border-color: var(--yellow); background: rgba(255, 206, 0, 0.08); color: var(--black); }

/* Krankheits-Module */

.module { border: 1px solid var(--line); border-radius: var(--radius); background: #fff; overflow: hidden; }

.module + .module { margin-top: 12px; }

.module-head {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 18px;
    background: #fafafa;
    border: 0;
    cursor: pointer;
    font: inherit;
    text-align: left;
    transition: background 0.15s var(--ease);
}

.module-head:hover { background: #f3f3f5; }

.module-badge {
    background: var(--yellow);
    color: var(--black);
    font-size: 11px;
    font-weight: 800;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    padding: 3px 9px;
    border-radius: 999px;
    flex: 0 0 auto;
}

.module-cond { color: var(--muted); font-size: 12.5px; }

.module-chev { margin-left: auto; transition: transform 0.2s var(--ease); color: var(--muted); font-size: 13px; }

.module.open .module-chev { transform: rotate(180deg); }

.module-body { display: none; padding: 18px 20px; border-top: 1px solid var(--line); }

.module.open .module-body { display: block; }

/* ---------------- Modal ---------------- */

.modal-root {
    position: fixed;
    inset: 0;
    z-index: 90;
    display: grid;
    place-items: center;
    padding: 20px;
}

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

.modal-backdrop { position: absolute; inset: 0; background: rgba(13, 13, 11, 0.5); backdrop-filter: blur(6px); }

.modal-card {
    position: relative;
    background: #fff;
    border-radius: 18px;
    width: min(680px, 100%);
    max-height: 86vh;
    display: flex;
    flex-direction: column;
    animation: modal-in 0.25s var(--ease);
}

@keyframes modal-in { from { opacity: 0; transform: translateY(14px) scale(0.98); } to { opacity: 1; transform: none; } }

.modal-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 22px;
    border-bottom: 1px solid var(--line);
}

.modal-head h2 { font-size: 17px; font-weight: 600; }

.modal-x {
    border: 0;
    background: transparent;
    font-size: 22px;
    cursor: pointer;
    color: var(--muted);
    width: 32px;
    height: 32px;
    border-radius: 50%;
    transition: all 0.15s var(--ease);
}

.modal-x:hover { background: #f0f0f2; color: var(--ink); }

.modal-body { padding: 20px 22px; overflow: auto; }

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    padding: 16px 22px;
    border-top: 1px solid var(--line);
    background: #fafafa;
    border-radius: 0 0 18px 18px;
}

.modal-hint { color: var(--muted); font-size: 13.5px; margin-bottom: 14px; }

.modal-label {
    display: block;
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    color: var(--muted);
    margin: 14px 0 6px;
}

.modal-body .input { margin-bottom: 4px; }

.json-preview {
    background: #141413;
    color: #e8e8e8;
    border-radius: 10px;
    padding: 14px;
    font: 12px/1.6 ui-monospace, 'Cascadia Code', Consolas, monospace;
    max-height: 220px;
    overflow: auto;
    white-space: pre;
}

.issue-box { background: #fff8e1; border: 1px solid #f0d24b; border-radius: 10px; padding: 12px 14px; margin: 10px 0; }

.issue-title { font-weight: 700; font-size: 13px; margin-bottom: 6px; }

.issue-list { list-style: none; font-size: 12.5px; color: #5a4a00; max-height: 150px; overflow: auto; }

.issue-list li { padding: 3px 0; }

.issue-path { font-weight: 600; }

.save-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    border: 1px solid var(--line);
    border-radius: 12px;
    margin-bottom: 8px;
    transition: border-color 0.15s var(--ease);
}

.save-row:hover { border-color: var(--line-strong); }

.save-info { flex: 1; min-width: 0; }

.save-name { font-weight: 700; font-size: 14px; word-break: break-word; }

.save-meta { color: var(--muted); font-size: 12px; }

/* ---------------- Toasts ---------------- */

.toast-root {
    position: fixed;
    right: 20px;
    bottom: 20px;
    z-index: 100;
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-width: 400px;
}

.toast {
    background: var(--black);
    color: #fff;
    padding: 13px 18px;
    border-radius: 12px;
    font-size: 13.5px;
    font-weight: 500;
    border-left: 4px solid var(--yellow);
    animation: toast-in 0.3s var(--ease);
    word-break: break-word;
}

.toast-err { border-left-color: var(--red); }
.toast-warn { border-left-color: #ff9500; }

.toast.out { opacity: 0; transform: translateY(8px); transition: all 0.3s var(--ease); }

@keyframes toast-in { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }

/* ---------------- Footer ---------------- */

.footer {
    max-width: 1180px;
    margin: 0 auto 44px;
    padding: 0 20px;
    color: var(--muted);
    font-size: 12.5px;
    text-align: center;
}

/* ---------------- Auto-Speichern-Hinweis (Release) ---------------- */

.auto-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: rgba(255, 206, 0, 0.16);
    color: var(--ink);
    border: 1px solid rgba(255, 206, 0, 0.5);
    border-radius: 999px;
    padding: 6px 12px;
    font-size: 12.5px;
    font-weight: 600;
    white-space: nowrap;
}

/* ---------------- Responsive ---------------- */

@media (max-width: 960px) {
    .layout { grid-template-columns: minmax(0, 1fr); }
    .sidebar { position: static; order: -1; min-width: 0; }
    .content { min-width: 0; }
    .sidenav { flex-direction: row; overflow-x: auto; padding-bottom: 6px; gap: 8px; }
    .nav-item { flex: 0 0 auto; width: auto; }
    .nav-count { display: none; }
    .hero { padding: 32px 26px; }
    .section-body { padding: 24px 22px 28px; }
    .section-head { padding: 20px 22px; }
}

@media (max-width: 640px) {
    /* Topbar: Logo oben, Buttons in eigener scrollbarer Zeile */
    .topbar-inner { padding: 10px 12px; gap: 8px; }
    .brand { gap: 8px; }
    .brand-logo { height: 24px; }
    .brand-name { font-size: 16px; }
    .brand-tag, .autosave-note { display: none; }
    .topbar-actions {
        flex-basis: 100%;
        order: 2;
        margin-left: 0;
        overflow-x: auto;
        padding: 2px 0 4px;
        gap: 6px;
        scrollbar-width: none;
    }
    .topbar-actions::-webkit-scrollbar { display: none; }
    .btn { padding: 8px 13px; font-size: 12.5px; white-space: nowrap; }
    .auto-badge { font-size: 11.5px; padding: 5px 10px; }

    /* Navigation als weiße Pills unter der Topbar */
    .sidenav { padding: 4px 12px 10px; }
    .nav-item {
        background: #fff;
        border: 1px solid var(--line);
        border-radius: 999px;
        padding: 8px 14px;
        box-shadow: none;
        max-width: 240px;
    }
    .nav-item:hover { box-shadow: none; }
    .nav-item.active { background: var(--black); border-color: var(--black); }
    .nav-num { display: none; }
    .nav-label { font-size: 13px; white-space: normal; }

    /* Fortschritt */
    .progress-shell { height: 30px; }
    .progress-meta { font-size: 11px; right: 10px; }

    /* Layout */
    .layout { padding: 0 10px; margin-top: 14px; }

    /* Hero */
    .hero { padding: 24px 18px 26px; border-radius: 16px; margin-bottom: 16px; }
    .hero-kicker { font-size: 10.5px; }
    .hero-title { font-size: 20px; margin: 8px 0 10px; }
    .hero-desc { font-size: 13.5px; }
    .hero-chips { gap: 6px; margin-top: 14px; }
    .chip { font-size: 11px; padding: 5px 10px; }

    /* Abschnitte */
    .section { border-radius: 16px; margin-bottom: 14px; }
    .section-head { padding: 16px 16px; gap: 12px; }
    .sec-num { width: 32px; height: 32px; flex-basis: 32px; font-size: 15px; border-radius: 10px; }
    .sec-titles h2 { font-size: 17px; }
    .sec-titles p { font-size: 12.5px; }
    .section-body { padding: 18px 16px 22px; }

    /* Felder – Touch-optimiert */
    .field { margin-bottom: 28px; }
    .field-label { font-size: 15px; }
    .input { height: 48px; font-size: 16px; padding: 0 12px; }
    textarea.input { min-height: 48px; padding: 12px; }
    .check { padding: 14px 14px; }
    .check-text { font-size: 15px; }
    .check-box { width: 24px; height: 24px; flex-basis: 24px; }

    /* Lange Wörter/Labels sicher umbrechen (kein horizontales Scrollen) */
    .field-label, .check-text, .sec-titles p, .hero-desc, .subcard-title,
    .repeat-item-title, .module-title, .hero-title, .sec-titles h2, .save-name {
        overflow-wrap: break-word;
        word-break: break-word;
    }

    /* Ja/Nein – volle Breite */
    .seg { display: flex; width: 100%; }
    .seg-btn { flex: 1; padding: 11px 0; font-size: 15px; }

    /* Subgruppen & Unterfragen */
    .subcard { padding: 14px 14px; }
    .cond.open .cond-inner { padding-left: 12px; }

    /* Module */
    .module-head { padding: 12px 14px; gap: 10px; }
    .module-cond { display: none; }
    .module-body { padding: 14px; }

    /* Modal – unten verankert, fast vollflächig */
    .modal-root { padding: 0; align-items: end; }
    .modal-card {
        width: 100%;
        max-height: 94vh;
        border-radius: 18px 18px 0 0;
        animation: sheet-in 0.28s var(--ease);
    }
    @keyframes sheet-in {
        from { opacity: 0; transform: translateY(40px); }
        to { opacity: 1; transform: none; }
    }
    .modal-head { padding: 16px 16px; }
    .modal-body { padding: 16px 16px; }
    .modal-actions { padding: 14px 16px calc(14px + env(safe-area-inset-bottom)); }

    /* Toasts */
    .toast-root { left: 12px; right: 12px; bottom: 12px; max-width: none; }
    .toast { font-size: 13px; padding: 12px 14px; }

    /* Footer */
    .footer { font-size: 11.5px; padding: 0 14px; margin-bottom: 28px; }
}

@media (max-width: 380px) {
    .btn { padding: 7px 9px; font-size: 11.5px; }
    .brand-name { display: none; }
    .hero-chips .chip:nth-child(n+4) { display: none; }
    .sec-num { display: none; }
}
