/* ==========================================================================
   KI Company – Chatbot Konfigurator Landingpage
   Aufbau:  1 Grundlagen · 2 Layout-Huelle · 3 Vorschau-Widget
            4 Konfigurator · 5 CTA · 6 Seite 2 · 7 Danke · 8 Responsive
   ========================================================================== */

/* ============ 1 GRUNDLAGEN ============ */

:root {
    --brand:      #4B2B7F;      /* KI Company Dunkellila */
    --bot:        #4B2B7F;      /* Chatbot-Farbe, wird per JS ueberschrieben */
    --bot-ink:    #ffffff;      /* Textfarbe auf der Chatbot-Farbe */

    --bg:         #ffffff;
    --flaeche:    #f6f6f8;
    --ink:        #16161a;
    --muted:      #6b6b76;
    --hairline:   #e4e4ea;
    --fehler:     #d93025;

    --r-gross:    22px;
    --r-mittel:   14px;
    --r-klein:    10px;

    --schatten:   0 1px 2px rgba(20,20,30,.04), 0 8px 28px rgba(20,20,30,.07);

    --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "Helvetica Neue",
            "Inter", Arial, sans-serif;
}

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

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

body {
    font-family: var(--sans);
    -webkit-font-smoothing: antialiased;
    background: var(--bg);
    color: var(--ink);
    line-height: 1.45;
    overscroll-behavior-y: none;
}

button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: none; }
svg { width: 100%; height: 100%; display: block; }

/* ============ 2 LAYOUT-HUELLE ============
   Seite 1 muss auf dem Handy ohne Scrollen auf einen Bildschirm passen.
   Deshalb: feste Hoehe (dvh beruecksichtigt die Browserleisten von iOS),
   Flex-Spalte, und die Vorschau nimmt sich den uebrigen Platz.
   Sicherheitsnetz weiter unten: auf sehr flachen Displays darf gescrollt
   werden, damit nie etwas abgeschnitten wird.                              */

.shell {
    display: flex;
    flex-direction: column;
    height: 100dvh;
    max-width: 520px;
    margin: 0 auto;
    padding: 0 18px calc(14px + env(safe-area-inset-bottom));
    /* auto statt hidden: passt etwas wider Erwarten doch nicht (sehr grosse
       Systemschrift, Tastatur offen), wird gescrollt statt abgeschnitten. */
    overflow-y: auto;
}

.shell-scroll { height: auto; min-height: 100dvh; overflow: visible; }

.topbar {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 0 12px;
}

.logo { height: 26px; width: auto; }

.zurueck {
    width: 32px; height: 32px;
    display: grid; place-items: center;
    color: var(--ink);
    border-radius: 50%;
    margin-left: -6px;
}
.zurueck svg { width: 20px; height: 20px; }
.zurueck:active { background: var(--flaeche); }

.intro { flex: 0 0 auto; text-align: center; padding: 2px 0 14px; }

.intro h1 {
    font-size: clamp(30px, 9vw, 42px);
    font-weight: 800;
    letter-spacing: -.02em;
    text-transform: uppercase;
    line-height: 1.05;
}

.intro p {
    margin-top: 6px;
    font-size: 13px;
    letter-spacing: .04em;
    text-transform: uppercase;
    color: var(--muted);
}

.intro-links { text-align: left; }
.intro-links h1 { text-transform: none; font-size: clamp(26px, 7vw, 34px); }
.intro-links p {
    text-transform: none; letter-spacing: 0; font-size: 15px;
    line-height: 1.5; margin-top: 8px;
}

/* ============ 3 VORSCHAU-WIDGET ============
   Nachbau des echten WebChatAgent-Widgets: Kopfzeile mit Avatar und Name,
   Bot-Blase links, Nutzer-Blase in der Akzentfarbe rechts, Eingabezeile.   */

.vorschau-buehne {
    flex: 1 1 auto;
    /* Die Vorschau ist der Kern der Seite – sie darf schrumpfen, aber nie
       so weit, dass man den Chatbot nicht mehr erkennt. */
    min-height: 208px;
    display: flex;
    background: var(--flaeche);
    border-radius: var(--r-gross);
    padding: 12px;
    margin-bottom: 16px;
}

.widget {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
    background: #fff;
    border-radius: var(--r-mittel);
    box-shadow: var(--schatten);
    overflow: hidden;
}

.widget-kopf {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 11px 14px;
    background: var(--bot);
    color: var(--bot-ink);
    transition: background .25s ease;
}

.widget-avatar {
    width: 34px; height: 34px;
    flex: 0 0 34px;
    border-radius: 50%;
    background: #fff;
    color: var(--bot);
    display: grid; place-items: center;
    overflow: hidden;
    transition: color .25s ease;
}
.widget-avatar svg { width: 22px; height: 22px; }
.widget-avatar img { width: 100%; height: 100%; object-fit: cover; }

.widget-name {
    flex: 1;
    font-weight: 700;
    font-size: 16px;
    letter-spacing: -.01em;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.widget-schliessen { font-size: 20px; opacity: .85; line-height: 1; }

.widget-verlauf {
    flex: 1 1 0;
    min-height: 0;
    overflow-y: auto;
    padding: 14px;
    display: flex;
    flex-direction: column;
    gap: 9px;
    -webkit-overflow-scrolling: touch;
}

/* Nachrichten sitzen unten am Eingabefeld, wie in echten Chats. Ohne das
   klafft in einem hohen Fenster eine Luecke zwischen Verlauf und Eingabe.
   margin-top:auto statt justify-content:flex-end – letzteres macht bei
   Ueberlauf den oberen Bereich unerreichbar. */
.widget-verlauf > :first-child { margin-top: auto; }

.blase {
    max-width: 84%;
    padding: 9px 13px;
    font-size: 14.5px;
    line-height: 1.4;
    border-radius: 16px;
    word-break: break-word;
    white-space: pre-wrap;
}

.blase-bot {
    align-self: flex-start;
    background: #ededf2;
    color: var(--ink);
    border-bottom-left-radius: 5px;
}

.blase-user {
    align-self: flex-end;
    background: var(--bot);
    color: var(--bot-ink);
    border-bottom-right-radius: 5px;
    transition: background .25s ease;
}

.tipp-blase { display: flex; gap: 4px; padding: 12px 14px; }
.tipp-blase span {
    width: 6px; height: 6px; border-radius: 50%;
    background: #9a9aa8;
    animation: tippen 1.3s infinite ease-in-out;
}
.tipp-blase span:nth-child(2) { animation-delay: .18s; }
.tipp-blase span:nth-child(3) { animation-delay: .36s; }

@keyframes tippen {
    0%, 60%, 100% { opacity: .3; transform: translateY(0); }
    30%           { opacity: 1;  transform: translateY(-3px); }
}

.widget-eingabe {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 0 12px 12px;
    padding: 10px 14px;
    border: 1px solid var(--hairline);
    border-radius: 999px;
}

.widget-platzhalter { flex: 1; color: #a0a0ad; font-size: 14.5px; }

.widget-senden {
    width: 19px; height: 19px;
    flex: 0 0 19px;
    color: var(--bot);
    transition: color .25s ease;
}

/* ============ 4 KONFIGURATOR ============ */

.konfigurator { flex: 0 0 auto; }

.konfig-titel { margin-bottom: 12px; }

.konfig-titel h2 {
    font-size: clamp(19px, 5.5vw, 24px);
    font-weight: 800;
    letter-spacing: -.02em;
    text-transform: uppercase;
}

.konfig-titel p { font-size: 13.5px; color: var(--muted); margin-top: 3px; }

.reihen { display: flex; flex-direction: column; gap: 8px; }

.reihe {
    border: 1px solid var(--hairline);
    border-radius: var(--r-mittel);
    transition: border-color .2s ease, box-shadow .2s ease;
}

.reihe.offen {
    border-color: var(--brand);
    box-shadow: 0 0 0 3px rgba(75, 43, 127, .09);
}

.reihe-kopf {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 11px 13px;
    text-align: left;
    border-radius: var(--r-mittel);
}

.reihe-icon {
    width: 19px; height: 19px;
    flex: 0 0 19px;
    color: var(--brand);
    display: grid; place-items: center;
}

.farb-punkt {
    width: 15px; height: 15px;
    border-radius: 50%;
    background: var(--bot);
    box-shadow: inset 0 0 0 1px rgba(0,0,0,.08);
    transition: background .25s ease;
}

.reihe-label {
    flex: 1;
    font-size: 14.5px;
    color: var(--muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.reihe-label b { color: var(--ink); font-weight: 600; }

.reihe-haken {
    color: var(--brand);
    font-size: 14px;
    opacity: 0;
    transition: opacity .2s ease;
}
.reihe.erledigt .reihe-haken { opacity: 1; }

.reihe-pfeil {
    width: 9px; height: 9px;
    flex: 0 0 9px;
    border-right: 1.8px solid #9a9aa8;
    border-bottom: 1.8px solid #9a9aa8;
    transform: rotate(45deg) translate(-2px, -2px);
    transition: transform .22s ease;
}
.reihe.offen .reihe-pfeil { transform: rotate(-135deg) translate(-2px, -2px); }

/* Aufklapp-Bereich: Hoehe wird animiert, Inhalt bleibt im DOM */
.reihe-inhalt {
    display: grid;
    grid-template-rows: 0fr;
    transition: grid-template-rows .24s ease;
}
.reihe.offen .reihe-inhalt { grid-template-rows: 1fr; }

/* Jeder Aufklapp-Inhalt sitzt in einem .reihe-body. Formularelemente direkt
   als Grid-Kind zu setzen funktioniert nicht: Input und Textarea behalten
   ihre Mindesthoehe und die Zeile klappt dann nie ganz zu. min-height:0
   ist hier zusaetzlich zwingend. */
.reihe-body { overflow: hidden; min-height: 0; }

.reihe.offen .reihe-body { padding: 0 13px 12px; }

.reihe-body input[type="text"],
.reihe-body textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--hairline);
    border-radius: var(--r-klein);
    background: #fbfbfd;
    font-size: 15px;
    resize: none;
    outline: none;
}
.reihe-body input[type="text"]:focus,
.reihe-body textarea:focus {
    border-color: var(--brand);
    background: #fff;
}

.reihe-hinweis {
    margin-top: 6px;
    font-size: 12px;
    color: var(--muted);
}

/* Website fehlt beim Klick auf "Jetzt konfigurieren" */
.reihe.ungueltig { border-color: var(--fehler); box-shadow: 0 0 0 3px rgba(217,48,37,.09); }
.reihe.ungueltig .reihe-icon { color: var(--fehler); }
.reihe.ungueltig .reihe-body input[type="text"] { border-color: var(--fehler); }

/* Farbauswahl */
.farb-auswahl { display: flex; align-items: center; gap: 9px; flex-wrap: wrap; }

.farb-chip {
    width: 30px; height: 30px;
    border-radius: 50%;
    background: var(--c);
    box-shadow: inset 0 0 0 1px rgba(0,0,0,.08);
    transition: transform .15s ease, box-shadow .15s ease;
}
.farb-chip:hover { transform: scale(1.08); }
.farb-chip.gewaehlt {
    box-shadow: 0 0 0 2px #fff, 0 0 0 4px var(--c);
}

.farb-eigen {
    width: 30px; height: 30px;
    border-radius: 50%;
    overflow: hidden;
    position: relative;
    cursor: pointer;
    background: conic-gradient(#e2574c, #e2b24c, #4ce27a, #4cc8e2, #6b4ce2, #e24cc0, #e2574c);
    box-shadow: inset 0 0 0 1px rgba(0,0,0,.08);
}
.farb-eigen input[type="color"] {
    position: absolute; inset: -6px;
    width: calc(100% + 12px); height: calc(100% + 12px);
    border: none; padding: 0; opacity: 0; cursor: pointer;
}

/* Hex-Eingabe fuer Kunden, die ihre exakte Markenfarbe kennen.
   Bleibt mit Farbkreisen und Color-Picker in beide Richtungen synchron. */
.farb-hex {
    width: 92px;
    flex: 0 0 92px;
    padding: 7px 9px;
    border: 1px solid var(--hairline);
    border-radius: var(--r-klein);
    background: #fbfbfd;
    font-size: 14px;
    font-variant-numeric: tabular-nums;
    letter-spacing: .02em;
    text-transform: uppercase;
    outline: none;
}
.farb-hex:focus { border-color: var(--brand); background: #fff; }
.farb-hex.ungueltig { border-color: var(--fehler); color: var(--fehler); }

/* Avatarauswahl */
.avatar-auswahl { display: flex; align-items: center; gap: 9px; flex-wrap: wrap; }

.avatar-chip {
    width: 38px; height: 38px;
    flex: 0 0 38px;
    display: grid; place-items: center;
    border: 1px solid var(--hairline);
    border-radius: 50%;
    color: var(--muted);
    background: #fbfbfd;
    overflow: hidden;
    transition: border-color .18s ease, color .18s ease;
}
.avatar-chip svg { width: 21px; height: 21px; }
.avatar-chip img { width: 100%; height: 100%; object-fit: cover; }

.avatar-chip.gewaehlt {
    border-color: var(--brand);
    color: var(--brand);
    box-shadow: 0 0 0 3px rgba(75, 43, 127, .1);
}

.avatar-upload { cursor: pointer; border-style: dashed; position: relative; }
.avatar-upload .upload-bild { display: none; }
.avatar-upload.hat-bild { border-style: solid; }
.avatar-upload.hat-bild .upload-icon { display: none; }
.avatar-upload.hat-bild .upload-bild { display: block; }

/* Hinweiszeile */
.hinweis {
    display: flex;
    align-items: center;
    gap: 7px;
    font-size: 12.5px;
    color: var(--muted);
    padding: 10px 3px;
    min-height: 34px;
}
.hinweis-funke { color: var(--brand); }

/* ============ 5 CTA ============ */

.cta {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 9px;
    padding: 15px 20px;
    border: 1.5px solid var(--brand);
    border-radius: 999px;
    background: var(--brand);
    color: #fff;
    font-size: 16px;
    font-weight: 700;
    letter-spacing: -.01em;
    transition: transform .12s ease, opacity .18s ease;
    text-decoration: none;
}
.cta:active { transform: scale(.985); }
.cta[disabled] { opacity: .6; pointer-events: none; }

.cta-sekundaer {
    background: transparent;
    color: var(--brand);
    margin-top: 26px;
}

/* ============ 6 SEITE 2 – KONTAKT ============ */

.fortschritt {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 0 18px;
}
.fortschritt-punkt {
    width: 8px; height: 8px;
    border-radius: 50%;
    background: var(--hairline);
}
.fortschritt-punkt.erledigt,
.fortschritt-punkt.aktiv { background: var(--brand); }
.fortschritt-linie { flex: 1; height: 2px; background: var(--brand); border-radius: 1px; }

.zusammenfassung {
    background: var(--flaeche);
    border-radius: var(--r-mittel);
    padding: 13px;
    margin-bottom: 22px;
}

.zus-widget { display: flex; align-items: center; gap: 11px; }

.zus-avatar {
    width: 38px; height: 38px;
    flex: 0 0 38px;
    border-radius: 50%;
    background: var(--bot);
    color: #fff;
    display: grid; place-items: center;
    overflow: hidden;
}
.zus-avatar svg { width: 22px; height: 22px; }
.zus-avatar img { width: 100%; height: 100%; object-fit: cover; }

.zus-text { min-width: 0; display: flex; flex-direction: column; }
.zus-text b { font-size: 14.5px; }
.zus-text span {
    font-size: 13px; color: var(--muted);
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

.zus-aendern {
    display: inline-block;
    margin-top: 10px;
    font-size: 13px;
    color: var(--brand);
    text-decoration: none;
    border-bottom: 1px solid rgba(75,43,127,.3);
}

#KontaktFormular { display: flex; flex-direction: column; gap: 18px; }

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

.feld-label { font-size: 14px; font-weight: 600; }
.feld-label i { color: var(--fehler); font-style: normal; }
.feld-label em {
    font-style: normal; font-weight: 400;
    font-size: 12.5px; color: var(--muted);
    margin-left: 4px;
}

.feld input {
    width: 100%;
    padding: 13px 14px;
    border: 1px solid var(--hairline);
    border-radius: var(--r-klein);
    background: #fbfbfd;
    font-size: 16px;              /* verhindert Auto-Zoom auf iOS */
    outline: none;
    transition: border-color .18s ease;
}
.feld input:focus { border-color: var(--brand); background: #fff; }

.feld-hinweis { font-size: 12.5px; color: var(--muted); }

.feld-fehler {
    display: none;
    font-size: 12.5px;
    color: var(--fehler);
}
.feld.ungueltig input { border-color: var(--fehler); }
.feld.ungueltig .feld-fehler { display: block; }
.feld.ungueltig .feld-hinweis { display: none; }

.fehler-global {
    display: none;
    font-size: 13.5px;
    color: var(--fehler);
    padding: 11px 13px;
    background: rgba(217, 48, 37, .07);
    border-radius: var(--r-klein);
}
.fehler-global.sichtbar { display: block; }

.dsgvo {
    font-size: 12px;
    line-height: 1.5;
    color: var(--muted);
    text-align: center;
    padding-bottom: 20px;
}

.zus-website {
    margin-top: 10px;
    font-size: 13px;
    color: var(--muted);
}
.zus-website b { color: var(--ink); font-weight: 600; }

/* ============ 6b LADESCREEN ============
   Liegt als Overlay ueber dem Konfigurator und laeuft feste 10 Sekunden
   (Dauer in config.js). Parallel legt das Szenario im Hintergrund den
   Chatbot an. */

.ladescreen {
    position: fixed;
    inset: 0;
    z-index: 50;
    display: grid;
    place-items: center;
    padding: 24px;
    background: var(--bg);
    opacity: 0;
    transition: opacity .35s ease;
}
.ladescreen.sichtbar { opacity: 1; }
.ladescreen[hidden]  { display: none; }

.lade-inhalt {
    width: 100%;
    max-width: 340px;
    text-align: center;
}

/* Avatar aus der Konfiguration, damit sich der Ladescreen wie eine
   Fortsetzung der Vorschau anfuehlt und nicht wie eine fremde Seite. */
.lade-widget {
    position: relative;
    width: 74px;
    height: 74px;
    margin: 0 auto 26px;
    display: grid;
    place-items: center;
}

.lade-avatar {
    position: relative;
    z-index: 1;
    width: 66px; height: 66px;
    border-radius: 50%;
    background: var(--bot);
    color: #fff;
    display: grid; place-items: center;
    overflow: hidden;
}
.lade-avatar svg { width: 36px; height: 36px; }
.lade-avatar img { width: 100%; height: 100%; object-fit: cover; }

.lade-puls {
    position: absolute;
    inset: 0;
    border-radius: 50%;
    border: 2px solid var(--bot);
    opacity: .5;
    animation: pulsieren 1.9s infinite ease-out;
}

@keyframes pulsieren {
    0%   { transform: scale(.9);  opacity: .55; }
    100% { transform: scale(1.5); opacity: 0; }
}

.lade-inhalt h2 {
    font-size: clamp(20px, 6vw, 25px);
    font-weight: 800;
    letter-spacing: -.02em;
    line-height: 1.2;
}

.lade-text {
    margin-top: 10px;
    font-size: 14.5px;
    line-height: 1.5;
    color: var(--muted);
}

.lade-balken {
    height: 5px;
    margin: 26px 0 14px;
    border-radius: 3px;
    background: var(--hairline);
    overflow: hidden;
}

.lade-balken-fuellung {
    width: 0;
    height: 100%;
    border-radius: 3px;
    background: var(--brand);
}

.lade-schritt {
    font-size: 13px;
    color: var(--muted);
    min-height: 19px;
}

/* ============ 6c STARTSEITE (willkommen.html) ============ */

.seite-willkommen .shell { max-width: 560px; }

.will-inhalt { flex: 1; padding: 6px 0 0; }

.will-marke {
    font-size: 12px;
    letter-spacing: .08em;
    text-transform: uppercase;
    color: var(--brand);
    font-weight: 700;
    margin-bottom: 10px;
}

.will-inhalt h1 {
    font-size: clamp(28px, 8vw, 40px);
    font-weight: 800;
    letter-spacing: -.025em;
    line-height: 1.12;
}

.will-lead {
    margin-top: 14px;
    font-size: 16px;
    line-height: 1.55;
    color: var(--muted);
}

.will-buehne {
    background: var(--flaeche);
    border-radius: var(--r-gross);
    padding: 14px;
    margin: 26px 0;
    height: 340px;
    display: flex;
}

.seite-willkommen .cta { margin-top: 4px; }

.will-unter {
    margin-top: 12px;
    text-align: center;
    font-size: 12.5px;
    color: var(--muted);
}

.will-punkte {
    list-style: none;
    margin: 34px 0 0;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.will-punkte li {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    font-size: 14.5px;
    line-height: 1.5;
    color: var(--muted);
}
.will-punkte b { color: var(--ink); font-weight: 600; }

.will-icon {
    width: 21px; height: 21px;
    flex: 0 0 21px;
    margin-top: 2px;
    border-radius: 50%;
    background: var(--brand);
    color: #fff;
    display: grid; place-items: center;
}
.will-icon svg { width: 12px; height: 12px; }

.will-fuss {
    margin-top: 44px;
    padding: 22px 0 30px;
    border-top: 1px solid var(--hairline);
    display: flex;
    justify-content: center;
}
.will-fuss-logo { height: 20px; width: auto; opacity: .45; }

/* ============ 7 DANKE-SEITE ============ */

.seite-danke .shell { justify-content: flex-start; }

.danke-inhalt {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding-bottom: 40px;
}

.danke-haken {
    width: 62px; height: 62px;
    border-radius: 50%;
    background: var(--brand);
    color: #fff;
    display: grid; place-items: center;
    margin-bottom: 22px;
}
.danke-haken svg { width: 30px; height: 30px; }

.danke-inhalt h1 {
    font-size: clamp(24px, 7vw, 32px);
    font-weight: 800;
    letter-spacing: -.02em;
}

.danke-inhalt > p {
    margin-top: 12px;
    font-size: 15px;
    color: var(--muted);
    line-height: 1.55;
    max-width: 34ch;
}

.danke-schritte {
    display: flex;
    flex-direction: column;
    gap: 9px;
    margin-top: 30px;
    width: 100%;
    max-width: 320px;
}

.danke-schritt {
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 11px 14px;
    background: var(--flaeche);
    border-radius: var(--r-klein);
    font-size: 14px;
    text-align: left;
}
.danke-spam {
    margin-top: 18px;
    font-size: 12.5px;
    color: var(--muted);
}

.danke-schritt b {
    width: 22px; height: 22px;
    flex: 0 0 22px;
    display: grid; place-items: center;
    border-radius: 50%;
    background: var(--brand);
    color: #fff;
    font-size: 12px;
}

/* ============ 7b PLATZ SCHAFFEN BEIM BEARBEITEN ============
   Mit fuenf Zeilen reicht der Platz auf dem Handy nicht mehr, sobald eine
   davon aufklappt. Loesung: Waehrend des Bearbeitens tritt der Kopfbereich
   zurueck und die Vorschau gibt Hoehe ab - so wie mobile Apps ihren Header
   einklappen, sobald man ein Feld fokussiert. Gilt nur unterhalb der
   Desktop-Breite, oben ist ohnehin genug Platz. */

@media (max-width: 859px) {

    .intro, .vorschau-buehne { transition: min-height .24s ease; }

    .shell.reihe-offen .intro p { display: none; }
    .shell.reihe-offen .vorschau-buehne { min-height: 190px; }

    /* In der geschrumpften Vorschau ist nur noch Platz fuer die Begruessung -
       und genau die wird ja gerade eingestellt. Nutzerblase und Tipp-Punkte
       sind Deko und wuerden sonst angeschnitten. Die Akzentfarbe bleibt
       ueber Kopfzeile und Senden-Pfeil sichtbar. */
    .shell.reihe-offen .blase-user,
    .shell.reihe-offen .tipp-blase { display: none; }

    /* Zusaetzlich das Widget selbst zusammenziehen, damit die Begruessung
       auch bei zwei Zeilen Text vollstaendig hineinpasst statt zu scrollen. */
    .shell.reihe-offen .widget-kopf      { padding: 8px 12px; }
    .shell.reihe-offen .widget-avatar    { width: 30px; height: 30px; flex: 0 0 30px; }
    .shell.reihe-offen .widget-avatar svg { width: 19px; height: 19px; }
    .shell.reihe-offen .widget-name      { font-size: 15px; }
    .shell.reihe-offen .widget-verlauf   { padding: 10px 12px; }
    .shell.reihe-offen .widget-eingabe   { margin: 0 10px 10px; padding: 8px 12px; }
    .shell.reihe-offen .widget-platzhalter { font-size: 13.5px; }
    .shell.reihe-offen .blase { font-size: 13.5px; padding: 8px 11px; max-width: 92%; }
}

/* ============ 8 RESPONSIVE ============ */

/* --- Kompakt-Modus fuer kleine Handys (iPhone SE & Co, 667 px hoch) ---
   Alles rund um die Vorschau wird enger gezogen, damit die Vorschau selbst
   ihre 208 px behaelt und die Seite trotzdem ohne Scrollen auskommt. */
@media (max-height: 720px) {

    .shell { padding-bottom: calc(10px + env(safe-area-inset-bottom)); }

    .topbar { padding: 8px 0 6px; }
    .logo   { height: 21px; }

    .intro    { padding: 0 0 9px; }
    .intro h1 { font-size: clamp(22px, 7vw, 28px); }
    .intro p  { font-size: 10.5px; margin-top: 2px; }

    /* Auf kleinen Handys zaehlt jeder Pixel: Das Widget wird schlanker und
       zeigt nur noch die Begruessung. Nutzerblase und Tipp-Punkte sind reine
       Deko – die Akzentfarbe bleibt ueber Kopfzeile und Senden-Pfeil sichtbar,
       und die Begruessungsnachricht steht vollstaendig da statt angeschnitten. */
    .vorschau-buehne { min-height: 176px; padding: 10px; margin-bottom: 12px; }

    .widget-kopf      { padding: 8px 12px; }
    .widget-avatar    { width: 30px; height: 30px; flex: 0 0 30px; }
    .widget-avatar svg { width: 19px; height: 19px; }
    .widget-name      { font-size: 15px; }
    .widget-verlauf   { padding: 11px 12px; gap: 6px; }
    .widget-eingabe   { margin: 0 10px 10px; padding: 8px 12px; }
    .widget-platzhalter { font-size: 13.5px; }

    .blase { font-size: 13.5px; padding: 8px 11px; max-width: 92%; }
    .blase-user, .tipp-blase { display: none; }

    .konfig-titel   { margin-bottom: 9px; }
    .konfig-titel h2 { font-size: 17px; }
    .konfig-titel p  { display: none; }   /* Platz fuer den aufgeklappten Inhalt */

    /* Hinweiszeile einzeilig halten, sonst springt das Layout beim Umbruch */
    .hinweis span:last-child {
        white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
    }

    .reihen     { gap: 6px; }
    .reihe-kopf { padding: 9px 12px; }
    .reihe-label { font-size: 13.5px; }
    .reihe.offen .reihe-body { padding: 0 12px 9px; }

    .hinweis { font-size: 11.5px; padding: 6px 3px; min-height: 24px; }

    .reihe-hinweis { font-size: 11px; margin-top: 4px; }

    .cta { padding: 13px 18px; font-size: 15px; }

    /* Kleine Handys: hier weicht der gesamte Kopfbereich, nicht nur der
       Untertitel - anders geht sich die aufgeklappte Zeile nicht aus. */
    .shell.reihe-offen .intro { display: none; }
    .shell.reihe-offen .vorschau-buehne { min-height: 168px; }
}

/* Handy quer oder Tastatur offen: hier ist kein Ein-Bildschirm-Layout mehr
   moeglich – lieber sauber scrollen als Inhalt abschneiden. */
@media (max-height: 480px) {
    .shell { height: auto; min-height: 100dvh; }
}

/* Ab Tablet: Vorschau und Konfigurator nebeneinander. */
@media (min-width: 860px) {

    .seite-konfigurator .shell {
        max-width: 1080px;
        display: grid;
        grid-template-columns: 1fr 1fr;
        grid-template-areas:
            "kopf     kopf"
            "titel    titel"
            "vorschau konfig";
        grid-template-rows: auto auto 1fr;
        column-gap: 48px;
        padding: 0 32px 28px;
        align-items: start;
    }

    .seite-konfigurator .topbar { grid-area: kopf; padding: 20px 0 4px; }
    .seite-konfigurator .logo { height: 30px; }

    .seite-konfigurator .intro {
        grid-area: titel;
        text-align: left;
        padding: 0 0 20px;
    }
    .seite-konfigurator .intro h1 { font-size: 46px; }

    .seite-konfigurator .vorschau-buehne {
        grid-area: vorschau;
        height: min(60vh, 540px);
        margin-bottom: 0;
        padding: 22px;
        align-self: start;
    }

    .seite-konfigurator .konfigurator {
        grid-area: konfig;
        align-self: start;
    }

    .seite-konfigurator .konfig-titel h2 { font-size: 32px; }
    .seite-konfigurator .konfig-titel { margin-bottom: 20px; }
    .seite-konfigurator .reihen { gap: 10px; }
    .seite-konfigurator .reihe-kopf { padding: 14px 16px; }
    .seite-konfigurator .cta { padding: 17px 22px; }

    .shell-scroll { max-width: 560px; }
}

@media (prefers-reduced-motion: reduce) {
    * { animation-duration: .001ms !important; transition-duration: .001ms !important; }
}
