/* DenAI — mobile-first, iOS zuerst. Bewusst ohne Framework: eine Familien-App
   braucht kein Grid-System, aber sehr wohl Safe-Area-Handling und grosse Tap-Ziele. */

:root {
    --bg: #f7f4ee;
    --surface: #ffffff;
    --surface-alt: #efe9df;
    --text: #221f1b;
    --text-muted: #6d675e;
    --accent: #a2571f;
    --accent-soft: #f2e2d2;
    --border: #ded6c9;
    --danger: #9d2f26;

    --radius: 18px;
    --tap: 48px;

    --safe-top: env(safe-area-inset-top, 0px);
    --safe-bottom: env(safe-area-inset-bottom, 0px);

    color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #161513;
        --surface: #221f1d;
        --surface-alt: #2c2825;
        --text: #f0ece5;
        --text-muted: #a49c91;
        --accent: #e0a06a;
        --accent-soft: #3a2d22;
        --border: #38322c;
        --danger: #e08b83;
    }
}

* {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    height: 100%;
}

body {
    background: var(--bg);
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
    font-size: 17px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;

    /* Verhindert das Gummiband-Scrollen der Seite auf iOS; gescrollt wird nur die Liste. */
    overscroll-behavior-y: none;
}

button,
input,
textarea {
    font: inherit;
    color: inherit;
}

/* ---------- Startbildschirm ---------- */

.boot {
    height: 100dvh;
    display: grid;
    place-content: center;
    gap: 1.25rem;
    justify-items: center;
}

.boot__mark {
    font-size: 1.75rem;
    font-weight: 650;
    letter-spacing: -0.02em;
}

.boot__bar {
    width: 160px;
    height: 4px;
    border-radius: 999px;
    background: var(--surface-alt);
    overflow: hidden;
}

.boot__bar span {
    display: block;
    height: 100%;
    width: 40%;
    border-radius: inherit;
    background: var(--accent);
    animation: boot-slide 1.1s ease-in-out infinite;
}

@keyframes boot-slide {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(350%); }
}

/* ---------- Grundgeruest ---------- */

.shell {
    display: flex;
    flex-direction: column;
    height: 100dvh;
}

.shell__header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: calc(var(--safe-top) + 0.6rem) 1rem 0.6rem;
    background: color-mix(in srgb, var(--bg) 88%, transparent);
    backdrop-filter: saturate(1.4) blur(12px);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 10;
}

.shell__title {
    font-size: 1.05rem;
    font-weight: 650;
    margin: 0;
    letter-spacing: -0.01em;
}

.shell__spacer {
    flex: 1;
}

.shell__main {
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 1rem;
}

/* ---------- Profilwahl ---------- */

.profile-picker {
    display: flex;
    gap: 0.4rem;
    align-items: center;
}

.profile-chip {
    min-height: 36px;
    padding: 0.3rem 0.85rem;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: var(--surface);
    cursor: pointer;
    white-space: nowrap;
}

.profile-chip--active {
    background: var(--accent-soft);
    border-color: var(--accent);
    font-weight: 600;
}

/* ---------- Chat ---------- */

.messages {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    max-width: 44rem;
    margin: 0 auto;
}

.bubble {
    padding: 0.7rem 0.95rem;
    border-radius: var(--radius);
    max-width: 85%;
    overflow-wrap: anywhere;
    white-space: pre-wrap;
}

.bubble--user {
    align-self: flex-end;
    background: var(--accent-soft);
    border-bottom-right-radius: 6px;
}

.bubble--assistant {
    align-self: flex-start;
    background: var(--surface);
    border: 1px solid var(--border);
    border-bottom-left-radius: 6px;
}

.bubble--error {
    align-self: stretch;
    background: transparent;
    border: 1px dashed var(--danger);
    color: var(--danger);
    max-width: 100%;
}

.bubble__meta {
    display: block;
    margin-top: 0.4rem;
    font-size: 0.75rem;
    color: var(--text-muted);
}

.empty {
    text-align: center;
    color: var(--text-muted);
    padding: 3rem 1rem;
}

/* ---------- Eingabe ---------- */

.composer {
    display: flex;
    gap: 0.5rem;
    align-items: flex-end;
    padding: 0.6rem 1rem calc(var(--safe-bottom) + 0.6rem);
    border-top: 1px solid var(--border);
    background: var(--bg);
}

.composer__input {
    flex: 1;
    min-height: var(--tap);
    max-height: 8rem;
    padding: 0.7rem 0.9rem;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    background: var(--surface);
    resize: none;

    /* Unter 16px zoomt iOS beim Fokussieren in das Feld hinein. */
    font-size: 16px;
}

.composer__input:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: -1px;
}

.btn {
    min-height: var(--tap);
    min-width: var(--tap);
    padding: 0 1.1rem;
    border-radius: var(--radius);
    border: 1px solid transparent;
    background: var(--accent);
    color: #fff;
    font-weight: 600;
    cursor: pointer;
}

@media (prefers-color-scheme: dark) {
    .btn {
        color: #1a1512;
    }
}

.btn:disabled {
    opacity: 0.45;
    cursor: default;
}

.btn--quiet {
    background: transparent;
    color: var(--text-muted);
    border-color: var(--border);
    font-weight: 500;
    padding: 0 0.8rem;
    min-height: 36px;
}

/* ---------- Hinweise ---------- */

.notice {
    max-width: 44rem;
    margin: 0 auto 1rem;
    padding: 0.75rem 0.95rem;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    background: var(--surface-alt);
    color: var(--text-muted);
    font-size: 0.9rem;
}

/* ---------- Blazor-Fehleranzeige ---------- */

#blazor-error-ui {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 1000;
    padding: 0.8rem calc(1rem + var(--safe-bottom)) calc(0.8rem + var(--safe-bottom));
    background: var(--danger);
    color: #fff;
}

#blazor-error-ui .dismiss {
    float: right;
    cursor: pointer;
    padding: 0 0.5rem;
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}
