:root {
    --bg: #f1f3f6;
    --card: #ffffff;
    --card-soft: #f8f9fb;
    --line: rgba(18,24,32,0.11);
    --text: #1b222b;
    --muted: #66717c;
    --accent: #d60d16;
    --accent-soft: rgba(214, 13, 22, 0.065);
    --shadow: 0 16px 60px rgba(41, 49, 59, 0.10);
    --radius: 24px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
    font-family: Inter, Arial, Helvetica, sans-serif;
    background:
        radial-gradient(circle at top right, rgba(214,13,22,0.055), transparent 30%),
        radial-gradient(circle at bottom left, rgba(125,140,160,0.08), transparent 25%),
        var(--bg);
    color: var(--text);
    min-height: 100vh;
}

.page-wrap {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
}

.app-card {
    width: min(100%, 900px);
    background: linear-gradient(180deg, rgba(0,0,0,0.008), rgba(255,255,255,0.01)), var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
}

.app-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    padding: 24px 28px;
    border-bottom: 1px solid var(--line);
    background: rgba(0,0,0,0.008);
}

.brand-wrap {
    display: flex;
    align-items: center;
    gap: 16px;
}

.brand-logo {
    width: 72px;
    height: 72px;
    object-fit: contain;
    border-radius: 50%;
    background: #000;
    box-shadow: 0 0 0 1px rgba(0,0,0,0.08);
}

.eyebrow {
    color: var(--accent);
    text-transform: uppercase;
    letter-spacing: 0.12em;
    font-size: 0.72rem;
    margin-bottom: 6px;
    font-weight: 700;
}

h1 {
    margin: 0;
    font-size: clamp(1.5rem, 4vw, 2.1rem);
}

.app-header p {
    margin: 6px 0 0;
    color: var(--muted);
}

.login-box,
.chat-box {
    padding: 28px;
}

.login-box {
    max-width: 520px;
}

.login-box h2 {
    margin-top: 0;
    font-size: 1.5rem;
}

.intro-text,
.chat-meta,
.hint,
.status-line,
.empty-state,
.message-head span,
.logout-link {
    color: var(--muted);
}

.notice {
    margin: 18px 0;
    padding: 14px 16px;
    border-radius: 14px;
    border: 1px solid rgba(214,13,22,0.4);
    background: rgba(214,13,22,0.12);
}

.login-form,
.message-form {
    display: grid;
    gap: 12px;
}

label {
    font-weight: 600;
    font-size: 0.95rem;
}

input,
textarea {
    width: 100%;
    border: 1px solid rgba(0,0,0,0.12);
    background: var(--card-soft);
    color: var(--text);
    border-radius: 14px;
    padding: 14px 16px;
    font: inherit;
    outline: none;
}

input:focus,
textarea:focus {
    border-color: rgba(214,13,22,0.8);
    box-shadow: 0 0 0 4px rgba(214,13,22,0.16);
}

textarea {
    min-height: 96px;
    resize: vertical;
}

.primary-btn {
    appearance: none;
    border: none;
    border-radius: 999px;
    background: linear-gradient(180deg, #ef1b25, #b40810);
    color: white;
    font: inherit;
    font-weight: 700;
    padding: 14px 18px;
    cursor: pointer;
    transition: transform 0.15s ease, opacity 0.15s ease;
}

.primary-btn:hover { transform: translateY(-1px); }
.primary-btn:active { transform: translateY(0); }

.logout-link {
    text-decoration: none;
    white-space: nowrap;
}

.chat-meta,
.form-footer {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
}

.chat-meta {
    margin-bottom: 14px;
    font-size: 0.95rem;
}

.messages {
    height: 420px;
    overflow-y: auto;
    padding: 18px;
    border-radius: 20px;
    background: #f7f8fa;
    border: 1px solid var(--line);
    display: grid;
    gap: 12px;
    margin-bottom: 16px;
}

.message-item {
    background: rgba(20,30,40,0.035);
    border: 1px solid rgba(20,30,40,0.05);
    border-radius: 18px;
    padding: 14px 16px;
}

.message-item.own-message {
    background: var(--accent-soft);
    border-color: rgba(214,13,22,0.15);
}

.message-head {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 8px;
    font-size: 0.92rem;
}

.message-body {
    line-height: 1.5;
    white-space: normal;
    word-wrap: break-word;
}

.empty-state {
    padding: 30px;
    text-align: center;
    border: 1px dashed rgba(20,30,40,0.12);
    border-radius: 16px;
}

.status-line {
    min-height: 24px;
    margin-top: 12px;
    font-size: 0.92rem;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

@media (max-width: 720px) {
    .page-wrap { padding: 0; }
    .app-card { min-height: 100vh; border-radius: 0; }
    .app-header { padding: 20px; align-items: flex-start; }
    .brand-logo { width: 58px; height: 58px; }
    .login-box,
    .chat-box { padding: 20px; }
    .messages { height: 50vh; }
}

.welcome-banner { display: grid; gap: 7px; padding: 17px 20px; margin-bottom: 20px; border: 1px solid #f0d6d7; border-left: 4px solid var(--accent); background: #fff7f7; border-radius: 14px; line-height: 1.5; }
.welcome-banner strong { font-size: 1.05rem; }
.welcome-banner span { color: #555e69; }
.app-footer { display:flex; justify-content:space-between; gap:12px; flex-wrap:wrap; padding:16px 28px; border-top:1px solid var(--line); font-size:.82rem; color:var(--muted); }
.app-footer a {color:var(--muted); text-decoration:none;}
.app-footer a:hover {text-decoration:underline;}
.admin-panel { padding:28px; }
.admin-panel h2 {margin-top:0;}
.admin-panel form {display:grid;gap:12px;max-width:460px;}
.admin-panel p {color:var(--muted);line-height:1.6;}
.admin-actions {display:flex;gap:12px;flex-wrap:wrap;align-items:center;}
.danger-btn {background:#b70e1a;border:0;color:white;border-radius:10px;padding:10px 14px;cursor:pointer;font-weight:700;}
.admin-list {display:grid;gap:12px;margin:22px 0 0;}
.admin-message {display:flex;align-items:flex-start;justify-content:space-between;gap:15px;border:1px solid var(--line);border-radius:12px;padding:14px;}
.admin-message p {margin:8px 0 0;white-space:pre-wrap;overflow-wrap:anywhere;color:var(--text);}
.admin-message form {display:block;}
.admin-message time {color:var(--muted);font-size:.85rem;margin-left:8px;}
@media(max-width:720px){.admin-panel{padding:20px}.app-footer{padding:16px 20px}}

/* Adminantworten direkt im Chat */
.admin-chat-link { display: inline-block; text-decoration: none; margin: 8px 0 16px; }
.reply-context { background: #fff0ef; border: 1px solid #e8c4c2; border-radius: 12px; padding: 12px; display:flex; align-items:center; justify-content:space-between; gap:14px; margin-bottom: 12px; }
.reply-context[hidden] { display:none; }
.reply-context p { margin: 5px 0 0; font-size: 0.9rem; color: #555; }
.cancel-reply, .reply-button { background: transparent; color: #aa111c; border: 1px solid #e5c6c8; border-radius: 999px; padding: 7px 12px; cursor: pointer; font: inherit; font-size:.85rem; }
.reply-button { margin-top: 12px; }
.admin-message-chat { border-left: 4px solid #c91824 !important; background: #fff1f2 !important; }
.admin-message-chat .message-head strong { color: #ae101a; }
.quoted-message { background: rgba(0,0,0,.05); border-left: 3px solid #bd6168; padding: 9px 12px; border-radius: 6px; margin-bottom: 10px; font-size: .85rem; white-space: normal; }

/* Antworten bleiben direkt unter der ursprünglichen Hörerfrage. */
.messages { display: block; }
.conversation-thread { margin-bottom: 12px; }
.conversation-thread .nested-reply { margin: 8px 0 0 18px; padding-left: 12px; border-left: 2px solid #e4b7ba; }
.conversation-thread .nested-reply .message-item { margin: 0; }
@media (max-width: 520px) { .conversation-thread .nested-reply { margin-left: 8px; padding-left: 9px; } }
