/* Kinder-Oberfläche: Startbildschirm, Geschichten-Regal, Antwortzone (kinder-ui.js).
   Die App-Basis ist immer hell: bewusst keine prefers-color-scheme-Blöcke. */

/* ===== Gemeinsame Bausteine ===== */
/* Die Symbolbilder sind selten quadratisch: nie in ein festes Maß pressen, immer einpassen. */
img[src*="symbole/"] { object-fit: contain; }
.ku-greeting[hidden], .ku-pill[hidden], .ku-shelf[hidden] { display: none !important; }
.ku-pill {
    display: inline-flex; align-items: center; gap: 6px; min-height: 44px; padding: 8px 18px;
    border: 0; border-radius: 999px; background: var(--color-surface, #fff);
    color: var(--color-text-primary, #111827); font: inherit; font-weight: 700; cursor: pointer;
    box-shadow: var(--shadow-sm, 0 1px 3px rgba(0, 0, 0, .12));
}
.ku-speak {
    flex: none; width: 48px; height: 48px; display: grid; place-items: center; padding: 0;
    border: 0; border-radius: 50%; background: var(--color-primary-light, #ECFDF5); cursor: pointer;
}
.ku-speak img { width: 30px; height: 30px; }
.ku-pill:focus-visible, .ku-speak:focus-visible, .ku-book:focus-visible, .ku-seg-btn:focus-visible,
.ku-key:focus-visible, .ku-stem:focus-visible, .ku-choice:focus-visible {
    outline: 3px solid var(--color-accent-blue, #3B82F6); outline-offset: 2px;
}

/* ===== Startbildschirm (Zustand Leer) ===== */
.ku-greeting {
    display: flex; align-items: center; gap: 14px; padding: 14px 18px; margin-bottom: 16px;
    background: var(--color-surface, #fff); border-radius: var(--radius-md, 20px);
    border-left: 6px solid var(--color-primary, #10B981);
    box-shadow: var(--shadow-sm, 0 1px 3px rgba(0, 0, 0, .12));
}
.ku-greeting p { margin: 0; font-size: 1.5rem; line-height: 1.3; }
.ku-write-back { align-self: flex-start; margin-bottom: 12px; }
.input-way-sub, .input-way-short { display: none; }
.ku-write-own { display: none; }

body.ku-start #reader-container { display: none; }
body.ku-start .go-explore-bar { display: none; }
body.ku-start .ku-write-own { display: flex; }
body.ku-start .input-ways {
    flex: 1; margin-top: 0; display: grid; gap: 16px; align-content: center;
    grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); grid-auto-rows: minmax(150px, 300px);
}
body.ku-start .input-ways > .photo-dropdown-container { display: flex; }
body.ku-start .input-way-btn {
    justify-content: center; gap: 12px; padding: 20px 12px; min-height: 150px;
    font-size: 1.25rem; font-weight: 700; line-height: 1.25; text-align: center;
    border-radius: var(--radius-md, 20px);
}
body.ku-start .input-way-btn img { width: 84px; height: 84px; object-fit: contain; }
body.ku-start .input-way-sub {
    display: block; font-size: .95rem; font-weight: 400; color: var(--color-text-secondary, #4B5563);
}
body.ku-start .input-way-btn.is-busy { border-color: var(--color-primary, #10B981); cursor: progress; }
body.ku-start .input-way-btn.is-busy img { animation: ku-wobble 1.1s ease-in-out infinite; }
/* Im Startzustand sind diese Chips sinnlos (nichts zu speichern, nichts rückgängig) */
body.ku-start #btn-add-collection, body.ku-start #btn-undo-task { display: none !important; }
@keyframes ku-wobble { 0%, 100% { transform: rotate(-8deg); } 50% { transform: rotate(8deg); } }

/* Bereit-Zustand: kurze Beschriftung in den Chips */
.input-ways.compact .input-way-long { display: none; }
.input-ways.compact .input-way-short { display: inline; }

/* ===== Geschichten-Regal ===== */
.ku-shelf[hidden] { display: none; }
.ku-shelf {
    position: fixed; inset: 0; z-index: 900; display: flex; flex-direction: column; gap: 16px;
    padding: max(16px, env(safe-area-inset-top, 0px)) max(20px, env(safe-area-inset-right, 0px))
             max(16px, env(safe-area-inset-bottom, 0px)) max(20px, env(safe-area-inset-left, 0px));
    background: var(--color-bg, #CBD5E1); overflow: hidden;
}
.ku-shelf-head { display: flex; align-items: center; gap: 14px; }
.ku-shelf-title { flex: 1; margin: 0; font-size: 1.5rem; line-height: 1.25; }
.ku-shelf-bar { display: flex; flex-wrap: wrap; gap: 12px; justify-content: space-between; }
.ku-seg {
    display: inline-flex; flex-wrap: wrap; gap: 4px; padding: 4px; border-radius: 999px;
    background: var(--color-surface, #fff);
}
.ku-seg-btn {
    min-height: 44px; padding: 6px 18px; border: 0; border-radius: 999px; background: transparent;
    color: var(--color-text-primary, #111827); font: inherit; font-weight: 700; cursor: pointer;
}
.ku-seg-btn[aria-pressed="true"] { background: var(--color-primary, #10B981); color: #fff; }
.ku-shelf-grid {
    flex: 1; min-height: 0; overflow-y: auto; display: grid; gap: 14px; align-content: start;
    grid-auto-rows: max-content;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); padding-bottom: 8px;
    -webkit-overflow-scrolling: touch;
}
.ku-book {
    display: flex; align-items: center; gap: 14px; min-height: 112px; padding: 14px 16px;
    border: 2px solid transparent; border-radius: var(--radius-md, 20px);
    background: var(--color-surface, #fff); color: var(--color-text-primary, #111827);
    font: inherit; text-align: left; cursor: pointer;
    box-shadow: var(--shadow-sm, 0 1px 3px rgba(0, 0, 0, .12));
}
.ku-book:hover { border-color: var(--color-primary, #10B981); }
.ku-book-pic { flex: none; width: 72px; height: 72px; object-fit: contain; opacity: .45; }
.ku-book-pic.is-picture { opacity: 1; }
.ku-book-body { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.ku-book-title { font-size: 1.15rem; font-weight: 700; line-height: 1.25; }
.ku-book-teaser {
    font-size: .95rem; line-height: 1.35; color: var(--color-text-secondary, #4B5563);
    display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.ku-book-dots { display: flex; gap: 5px; margin-top: 4px; }
.ku-book-dots i { width: 10px; height: 10px; border-radius: 50%; background: var(--color-border, #E5E7EB); }
.ku-book-dots i.is-on { background: var(--color-accent-amber, #F59E0B); }
.ku-shelf-empty { grid-column: 1 / -1; margin: 24px 0; font-size: 1.1rem; text-align: center; }

/* ===== Aufgaben-Karte: beschriftete Werkzeuge ===== */
.task-tool-btn { width: auto; min-width: 44px; padding: 0 14px 0 10px; gap: 6px; opacity: 1; }
.task-tool-btn .toolbar-btn-label { display: inline; font-size: .95rem; }
#btn-task-options { font-size: 1rem; padding: 0 14px; }
.task-options-aa { font-size: 1.05rem; font-weight: 700; }

/* ===== Antwortzone über der Eingabezeile ===== */
.ku-answer[hidden], .ku-answer [hidden] { display: none !important; }
.ku-answer {
    flex-shrink: 0; display: flex; flex-direction: column; gap: 6px; padding: 8px 12px 0;
    border-top: 1px solid var(--color-border, #E5E7EB);
}
.ku-answer + #chat-input-area { border-top: 0; padding-top: 8px; }

/* ===== Chat kompakt: Kopf, Schritte-Leiste und Eingabe lassen dem Gespräch den Platz ===== */
body.ku-working #chat-header { padding-top: 6px; padding-bottom: 6px; }
body.ku-working #chat-input-area { padding: 10px 12px; }
body.ku-working .lernweg-bar { padding: 2px 12px; container-type: inline-size; overflow: hidden; }
body.ku-working .lernweg-bar-steps { align-items: center; }
body.ku-working .lernweg-bar-step { flex: 0 0 auto; flex-direction: row; gap: 6px; }
body.ku-working .lernweg-bar-dot { flex: none; width: 30px; height: 30px; font-size: 15px; }
body.ku-working .lernweg-bar-label { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
body.ku-working .lernweg-bar-step.is-current { flex-shrink: 1; }
body.ku-working .lernweg-bar-link { margin-top: 0; min-width: 10px; }
/* Schmale Leiste: nur der aktuelle Schritt trägt seinen Namen */
@container (max-width: 470px) {
    body.ku-working .lernweg-bar-step:not(.is-current) .lernweg-bar-label { display: none; }
}
/* Niedriger Bildschirm (Querformat, kleine Fenster): noch etwas enger */
@media (max-height: 760px) {
    body.ku-working #chat-header { padding-top: 3px; padding-bottom: 3px; }
    body.ku-working .lernweg-bar { padding-top: 0; padding-bottom: 0; }
    body.ku-working #chat-input-area { padding-top: 6px; padding-bottom: 8px; }
    .ku-answer { padding-top: 6px; }
    .ku-stem { min-height: 36px; }
}
.ku-choices { display: flex; flex-wrap: wrap; gap: 8px; }
/* Die Hilfen stehen möglichst in EINER Zeile: Die Knöpfe teilen sich die Breite,
   lange Beschriftungen dürfen dafür zweizeilig werden. */
.ku-stems { display: flex; flex-wrap: nowrap; gap: 6px; }
/* Die kurzen Knöpfe außen bleiben einzeilig, die langen in der Mitte geben nach */
.ku-stems > .ku-stem:first-child, .ku-stems > .ku-stem:last-child { flex-shrink: 0; white-space: nowrap; }
.ku-stem {
    flex: 1 1 auto; min-width: 0; min-height: 40px; padding: 4px 8px; line-height: 1.15; border: 2px solid var(--color-border, #E5E7EB);
    border-radius: 999px; background: var(--color-surface, #fff);
    color: var(--color-text-primary, #111827); font: inherit; font-size: .85rem; cursor: pointer;
}
.ku-stem[aria-pressed="true"] {
    border-color: var(--color-primary, #10B981); background: var(--color-primary-light, #ECFDF5);
    color: #065F46; font-weight: 700;
}
.ku-choice {
    flex: 1 1 120px; min-height: 52px; padding: 8px 18px; border: 2px solid var(--color-primary, #10B981);
    border-radius: 16px; background: var(--color-primary-light, #ECFDF5); color: #065F46;
    font: inherit; font-size: 1.15rem; font-weight: 700; cursor: pointer;
}
.ku-hint { margin: 0; font-size: .9rem; color: var(--color-text-secondary, #4B5563); }
.ku-pad { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.ku-key {
    min-height: 44px; padding: 0; border: 1px solid var(--color-border, #E5E7EB); border-radius: 10px;
    background: var(--color-surface-sunken, #F3F4F6); color: var(--color-text-primary, #111827);
    font: inherit; font-size: 1.2rem; cursor: pointer;
}
.ku-key-op { background: #DBEAFE; border-color: #BFDBFE; font-weight: 700; }
.ku-key-wide3 { grid-column: span 3; }
.ku-key-wide2 { grid-column: span 2; }
.ku-key:active, .ku-stem:active, .ku-choice:active { transform: scale(.96); }

/* Sprechen ist der erste Weg: Mikrofon deutlich als Knopf */
.chat-composer-mic { min-width: 56px; }

@media screen and (max-width: 600px) {
    /* Der Platz für den fixierten „Los geht's!“-Knopf wird nur im Bereit-Zustand gebraucht */
    body.ku-start main, body.ku-working main { padding-bottom: max(10px, env(safe-area-inset-bottom)); }
    /* Arbeiten: Die Geschichte nimmt, was sie braucht (höchstens ein Drittel, dann
       scrollt sie); das Gespräch bekommt den Rest, die Eingabe bleibt immer sichtbar. */
    body.ku-working .task-chat-wrapper { gap: 10px; }
    body.ku-working .task-chat-wrapper:has(#chat-container.visible) .task-side {
        flex: 0 0 auto; max-height: 34%; overflow-y: auto; -webkit-overflow-scrolling: touch;
    }
    /* Schritte-Leiste: nur der aktuelle Schritt trägt seinen Namen */
    body.ku-working .task-chat-wrapper:has(#chat-container.visible) #reader-container { min-height: 96px; }
    body.ku-working #chat-container.visible { flex: 1 1 0; min-height: 0; max-height: none; }
    body.ku-working #chat-messages { min-height: 72px; }
    .ku-answer { padding: 8px 10px 0; gap: 6px; }
    .ku-pad { gap: 4px; }
    .ku-greeting p { font-size: 1.2rem; }
    body.ku-start .input-ways { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
    body.ku-start .input-way-btn { min-height: 120px; font-size: 1.05rem; padding: 14px 8px; }
    body.ku-start .input-way-btn img { width: 56px; height: 56px; }
    .ku-shelf-title { font-size: 1.2rem; }
    .ku-shelf-grid { grid-template-columns: minmax(0, 1fr); }
    .task-tool-btn .toolbar-btn-label { display: none; }
    .task-tool-btn { padding: 0; width: 44px; }
    .ku-key { min-height: 38px; font-size: 1.1rem; }
    .ku-choice { min-height: 46px; }
}
@media (prefers-reduced-motion: reduce) {
    body.ku-start .input-way-btn.is-busy img { animation: none; }
    .ku-key:active, .ku-stem:active, .ku-choice:active { transform: none; }
}
