/* ═══ Chat: Nachrichten, Composer, Anhänge, Reaktionsleiste ═════════════ */
.messages { flex: 1; min-height: 0; overflow-y: auto; overflow-x: hidden; padding: 1rem 0 .5rem; display: flex; flex-direction: column; scroll-behavior: auto; overscroll-behavior: contain; }
.messages .top-sentinel { height: 1px; flex: none; }
.chat-intro { padding: 1rem 1.25rem 1.5rem; display: grid; gap: .4rem; }
.chat-intro .big { width: 64px; height: 64px; border-radius: 50%; background: var(--accent-soft); color: var(--accent-strong); display: grid; place-items: center; margin-bottom: .4rem; }
.chat-intro .big .icon { width: 30px; height: 30px; }
.chat-intro h2 { font-size: 1.5rem; }
.chat-intro p { color: var(--muted); }
.day-sep { display: flex; align-items: center; gap: .8rem; margin: 1rem 1.25rem .35rem; font-size: .72rem; font-weight: 650; color: var(--muted); letter-spacing: .04em; }
.day-sep::before, .day-sep::after { content: ""; flex: 1; height: 1px; background: var(--border); }
.new-sep { display: flex; align-items: center; margin: .6rem 1.25rem .2rem; font-size: .68rem; font-weight: 750; letter-spacing: .05em; text-transform: uppercase; color: var(--danger); }
.new-sep::before { content: ""; flex: 1; height: 1px; background: var(--danger); opacity: .7; }
.new-sep span { padding: .05rem .45rem; border-radius: 4px; background: var(--danger); color: #fff; margin-left: .5rem; }
.msg { position: relative; display: grid; grid-template-columns: 40px minmax(0, 1fr); column-gap: .9rem; padding: .15rem 1.25rem .15rem 1.25rem; margin-top: .7rem; transition: background var(--t-fast); animation: fade-in 180ms ease; }
.msg.compact { margin-top: 0; }
.msg.compact .avatar-col { display: flex; justify-content: center; align-items: flex-start; }
.msg.compact .ts-mini { opacity: 0; font-size: .65rem; color: var(--muted); padding-top: .3rem; }
.msg.compact:hover .ts-mini { opacity: 1; }
.msg:hover { background: var(--hover); }
.msg.highlight { background: color-mix(in srgb, var(--accent) 12%, transparent); box-shadow: inset 3px 0 0 var(--accent); }
.msg.mentioned { background: color-mix(in srgb, var(--warning) 9%, transparent); box-shadow: inset 3px 0 0 var(--warning); }
.msg.pending { opacity: .6; }
.msg.failed { box-shadow: inset 3px 0 0 var(--danger); }
.msg .avatar { --s: 40px; cursor: pointer; --dot-bg: transparent; }
.msg-head { display: flex; align-items: baseline; gap: .5rem; min-height: 1.4rem; }
.msg-author { font-weight: 650; cursor: pointer; color: var(--c, var(--text)); }
.msg-author:hover { text-decoration: underline; }
.msg-time { font-size: .72rem; color: var(--muted); }
.msg-edited { font-size: .68rem; color: var(--muted); }
.msg-body { line-height: 1.5; overflow-wrap: anywhere; word-break: break-word; white-space: pre-wrap; }
.msg-body p { margin: 0; }
.msg-body code { font-family: var(--mono); font-size: .85em; background: var(--surface-4); padding: .1em .35em; border-radius: 6px; }
.msg-body pre { margin: .35rem 0; padding: .7rem .9rem; border-radius: var(--radius-sm); background: var(--surface-1); border: 1px solid var(--border); overflow-x: auto; font-family: var(--mono); font-size: .84rem; white-space: pre; }
.msg-body pre code { background: none; padding: 0; }
.msg-body blockquote { margin: .2rem 0; padding: .1rem .8rem; border-left: 3px solid var(--border-strong); color: var(--text-2); }
.msg-body .spoiler { background: var(--surface-4); color: transparent; border-radius: 5px; cursor: pointer; padding: 0 .2em; }
.msg-body .spoiler.revealed { color: inherit; background: var(--accent-softer); }
.msg-body .emoji-big { font-size: 2.1rem; line-height: 1.3; }
.mention { background: var(--accent-soft); color: var(--accent-strong); padding: 0 .3em; border-radius: 6px; font-weight: 550; cursor: pointer; }
.mention:hover { background: var(--accent); color: var(--accent-ink); }
.mention.me { background: color-mix(in srgb, var(--warning) 22%, transparent); color: var(--warning); }
.msg-actions { position: absolute; right: 1rem; top: -14px; display: none; background: var(--surface-3); border: 1px solid var(--border-strong); border-radius: 10px; box-shadow: var(--shadow); padding: 2px; z-index: 3; }
.msg:hover .msg-actions, .msg:focus-within .msg-actions { display: flex; }
.msg-actions .icon-btn { width: 30px; height: 30px; }
@media (hover: none) { .msg-actions { display: flex; opacity: 0; } .msg:active .msg-actions, .msg:focus-within .msg-actions { opacity: 1; } }
.reply-ref { display: flex; align-items: center; gap: .45rem; font-size: .8rem; color: var(--muted); margin-bottom: .1rem; padding-left: 0; cursor: pointer; min-width: 0; }
.reply-ref:hover { color: var(--text-2); }
.reply-ref .icon { width: 14px; height: 14px; transform: scaleY(-1); }
.reply-ref .avatar { --s: 16px; }
.reply-ref .rn { font-weight: 600; color: var(--text-2); }
.reply-ref .rt { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.msg-edit textarea { width: 100%; margin-top: .25rem; }
.msg-edit .hint { font-size: .72rem; color: var(--muted); margin-top: .2rem; }
.system-msg { margin: .5rem 1.25rem; display: flex; gap: .5rem; align-items: center; color: var(--muted); font-size: .85rem; }

/* Anhänge */
.attachments { display: grid; gap: .45rem; margin-top: .3rem; justify-items: start; }
.att-media { position: relative; max-width: min(420px, 100%); border-radius: var(--radius); overflow: hidden; background: var(--surface-1); border: 1px solid var(--border); cursor: zoom-in; line-height: 0; }
.att-media img, .att-media video { max-width: 100%; max-height: 340px; width: auto; height: auto; object-fit: contain; }
.att-media video { cursor: default; background: #000; }
.att-media.sized { background: var(--surface-3); }
.att-audio { width: min(380px, 100%); }
.att-file { display: flex; align-items: center; gap: .75rem; padding: .65rem .8rem; border-radius: var(--radius); background: var(--surface-1); border: 1px solid var(--border); max-width: 380px; width: 100%; color: var(--text); transition: border-color var(--t-fast), background var(--t-fast); }
.att-file:hover { border-color: var(--border-strong); background: var(--surface-3); text-decoration: none; }
.att-file .fi { width: 38px; height: 38px; border-radius: 10px; background: var(--accent-soft); color: var(--accent-strong); display: grid; place-items: center; flex: none; }
.att-file .meta { min-width: 0; flex: 1; }
.att-file .n { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.att-file .s { font-size: .75rem; color: var(--muted); }
.att-removed { display: inline-flex; gap: .4rem; align-items: center; color: var(--muted); font-style: italic; font-size: .85rem; padding: .35rem .6rem; border: 1px dashed var(--border-strong); border-radius: 10px; }

/* Link-Vorschau light */
.embed-link { display: inline-block; max-width: 100%; }

/* Composer */
.composer-wrap { padding: 0 1.25rem calc(1rem + var(--safe-bottom)); flex: none; position: relative; }
.composer { background: var(--surface-3); border: 1px solid var(--border); border-radius: var(--radius); transition: border-color var(--t-fast), box-shadow var(--t); }
.composer:focus-within { border-color: color-mix(in srgb, var(--accent) 60%, var(--border)); box-shadow: 0 0 0 3px var(--accent-softer); }
.composer.disabled { opacity: .6; pointer-events: none; }
.composer-row { display: flex; align-items: flex-end; gap: .15rem; padding: .35rem; }
.composer textarea { flex: 1; min-width: 0; max-height: 40dvh; min-height: 38px; padding: .55rem .5rem; background: none; border: 0; resize: none; line-height: 1.45; field-sizing: content; }
.composer textarea::placeholder { color: var(--muted); }
.composer-bar { display: flex; align-items: center; gap: .6rem; padding: .45rem .9rem; border-bottom: 1px solid var(--border); font-size: .82rem; color: var(--text-2); }
.composer-bar .icon { width: 14px; height: 14px; }
.composer-bar .x { margin-left: auto; }
.composer-bar b { color: var(--text); }
.pending-files { display: flex; gap: .6rem; flex-wrap: wrap; padding: .7rem .7rem 0; }
.pf { position: relative; width: 124px; padding: .4rem; border-radius: 12px; background: var(--surface-2); border: 1px solid var(--border); display: grid; gap: .3rem; }
.pf .th { height: 76px; border-radius: 8px; background: var(--surface-4); display: grid; place-items: center; overflow: hidden; color: var(--muted); }
.pf .th img { width: 100%; height: 100%; object-fit: cover; }
.pf .n { font-size: .72rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pf .progress { height: 4px; }
.pf .rm { position: absolute; right: -6px; top: -6px; width: 22px; height: 22px; border-radius: 50%; background: var(--surface-4); border: 1px solid var(--border-strong); display: grid; place-items: center; }
.pf .rm:hover { background: var(--danger); color: #fff; }
.pf .rm .icon { width: 12px; height: 12px; }
.pf.err .n { color: var(--danger); }
.typing-line { height: 22px; padding: 0 1.5rem; font-size: .78rem; color: var(--muted); display: flex; align-items: center; gap: .5rem; flex: none; }
.typing-dots { display: inline-flex; gap: 3px; }
.typing-dots i { width: 5px; height: 5px; border-radius: 50%; background: var(--muted); animation: pulse 1s infinite; }
.typing-dots i:nth-child(2) { animation-delay: .15s; } .typing-dots i:nth-child(3) { animation-delay: .3s; }
.jump-bottom { position: absolute; left: 50%; bottom: 5.5rem; transform: translateX(-50%); z-index: 4; padding: .4rem .9rem; border-radius: 99px; background: var(--accent); color: var(--accent-ink); font-size: .82rem; font-weight: 600; box-shadow: var(--shadow); animation: slide-up var(--t) var(--ease); display: flex; gap: .4rem; align-items: center; }
.drop-overlay { position: absolute; inset: .75rem; z-index: 30; border-radius: var(--radius-lg); border: 2px dashed var(--accent); background: color-mix(in srgb, var(--bg) 78%, transparent); backdrop-filter: blur(6px); display: grid; place-items: center; text-align: center; pointer-events: none; animation: fade-in 120ms ease; }
.drop-overlay .icon { width: 44px; height: 44px; color: var(--accent-strong); margin: 0 auto .5rem; }

/* Autocomplete / Emoji */
.suggest { position: absolute; left: 1.25rem; right: 1.25rem; bottom: calc(100% - .6rem); max-height: 260px; overflow-y: auto; background: var(--surface-2); border: 1px solid var(--border-strong); border-radius: var(--radius); box-shadow: var(--shadow); padding: .3rem; z-index: 10; animation: pop-in 120ms var(--ease); }
.suggest .item { display: flex; align-items: center; gap: .6rem; padding: .4rem .6rem; border-radius: 10px; width: 100%; text-align: left; }
.suggest .item.sel, .suggest .item:hover { background: var(--accent-soft); }
.suggest .item .avatar { --s: 24px; }
.suggest .item .e { font-size: 1.2rem; width: 24px; text-align: center; }
.emoji-pop { width: 340px; max-width: calc(100vw - 1.5rem); display: flex; flex-direction: column; max-height: 380px; }
.emoji-pop .search { padding: .6rem; }
.emoji-pop .cats { display: flex; gap: .1rem; padding: 0 .5rem; border-bottom: 1px solid var(--border); overflow-x: auto; }
.emoji-pop .cats button { padding: .4rem .5rem; font-size: 1.1rem; opacity: .6; border-bottom: 2px solid transparent; }
.emoji-pop .cats button.active, .emoji-pop .cats button:hover { opacity: 1; border-color: var(--accent); }
.emoji-grid { display: grid; grid-template-columns: repeat(8, 1fr); gap: 2px; padding: .5rem; overflow-y: auto; flex: 1; }
.emoji-grid button { font-size: 1.4rem; line-height: 1; padding: .3rem 0; border-radius: 8px; text-align: center; }
.emoji-grid button:hover { background: var(--hover); transform: scale(1.18); }
.emoji-grid .cat-title { grid-column: 1 / -1; font-size: .7rem; font-weight: 650; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); padding: .4rem .2rem .1rem; }

/* Lightbox */
.lightbox { position: fixed; inset: 0; z-index: 300; background: rgba(0, 0, 0, .88); display: grid; place-items: center; animation: fade-in var(--t) ease; padding: 1rem; }
.lightbox img { max-width: 94vw; max-height: 88dvh; object-fit: contain; border-radius: 10px; box-shadow: var(--shadow); }
.lightbox .bar { position: absolute; top: calc(.75rem + var(--safe-top)); right: .75rem; display: flex; gap: .4rem; }
.lightbox .bar .icon-btn { background: rgba(255, 255, 255, .12); color: #fff; width: 40px; height: 40px; border-radius: 50%; }

/* Profilkarte */
.pcard { width: 320px; max-width: calc(100vw - 1.5rem); overflow: hidden; }
.pcard .banner { height: 76px; background: linear-gradient(135deg, var(--pc, var(--accent)), color-mix(in srgb, var(--pc, var(--accent)) 40%, #1b2a6b)); }
.pcard .body { padding: 0 1rem 1rem; }
.pcard .avatar { --s: 76px; margin-top: -38px; border: 5px solid var(--surface-2); --dot-bg: var(--surface-2); }
.pcard h3 { font-size: 1.15rem; margin-top: .5rem; }
.pcard .un { color: var(--muted); font-size: .85rem; }
.pcard .bio { margin-top: .6rem; padding-top: .6rem; border-top: 1px solid var(--border); font-size: .875rem; color: var(--text-2); white-space: pre-wrap; overflow-wrap: anywhere; }
.pcard .chips { display: flex; flex-wrap: wrap; gap: .3rem; margin-top: .6rem; }
.pcard .acts { display: flex; gap: .4rem; margin-top: .8rem; flex-wrap: wrap; }
.profile-edit-banner { height: 90px; border-radius: var(--radius) var(--radius) 0 0; background: linear-gradient(135deg, var(--pc, var(--accent)), color-mix(in srgb, var(--pc, var(--accent)) 40%, #1b2a6b)); }
.avatar-edit { position: relative; display: inline-block; cursor: pointer; }
.avatar-edit .over { position: absolute; inset: 0; border-radius: 50%; background: rgba(0, 0, 0, .55); color: #fff; display: grid; place-items: center; opacity: 0; transition: opacity var(--t); font-size: .7rem; font-weight: 650; text-align: center; }
.avatar-edit:hover .over, .avatar-edit:focus-visible .over { opacity: 1; }

/* Badges & leuchtender Name (Caller+) */
.pbadges { display: inline-flex; align-items: center; gap: 3px; vertical-align: middle; margin-left: .3rem; }
.pbadge { display: inline-flex; line-height: 0; }
.pbadge svg { display: block; filter: drop-shadow(0 1px 1px rgba(0,0,0,.35)); }
.pb-gold svg { filter: drop-shadow(0 0 4px rgba(255,200,60,.8)); }
.pb-legend svg { filter: drop-shadow(0 0 5px rgba(179,136,255,.9)); animation: pb-pulse 2.4s ease-in-out infinite; }
@keyframes pb-pulse { 50% { filter: drop-shadow(0 0 9px rgba(125,249,255,1)); transform: scale(1.08); } }
.glow-name { color: var(--glow) !important; text-shadow: 0 0 6px var(--glow), 0 0 14px color-mix(in srgb, var(--glow) 70%, transparent); font-weight: 650; animation: glow-breathe 3s ease-in-out infinite; }
@keyframes glow-breathe { 50% { text-shadow: 0 0 3px var(--glow), 0 0 8px color-mix(in srgb, var(--glow) 60%, transparent); } }
@media (prefers-reduced-motion: reduce) { .glow-name, .pb-legend svg { animation: none; } }
.pcard .banner { background-size: cover; background-position: center; }
.pcard .pbadges { display: flex; margin: .45rem 0 0; flex-wrap: wrap; gap: 5px; }
.custom-emoji { width: 1.4em; height: 1.4em; vertical-align: -.3em; object-fit: contain; display: inline-block; }
.custom-emoji.big { width: 1.7rem; height: 1.7rem; }
.suggest .custom-emoji { width: 24px; height: 24px; }
.banner-edit { height: 110px; border-radius: var(--radius-sm); background: linear-gradient(135deg, var(--accent), #1b2a6b) center/cover; display: grid; place-items: center; border: 1px solid var(--border); }
.glow-preview { font-size: 1.05rem; padding: 0 .5rem; }

/* Reaktionen & Umfragen */
.reactions { display: flex; flex-wrap: wrap; gap: .3rem; margin-top: .35rem; }
.reaction { display: inline-flex; align-items: center; gap: .3rem; padding: .1rem .5rem; border-radius: 999px; border: 1px solid var(--border-strong); background: var(--surface-2); font-size: .85rem; line-height: 1.5; }
.reaction:hover { border-color: var(--accent); }
.reaction.mine { background: var(--accent-soft); border-color: var(--accent); }
.reaction .n { font-weight: 650; font-size: .8rem; }
.reaction.add { color: var(--muted); }
.poll { margin-top: .4rem; padding: .75rem; max-width: 460px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); background: var(--surface-2); display: grid; gap: .45rem; }
.poll-q { font-weight: 650; display: flex; gap: .4rem; align-items: center; }
.poll-opts { display: grid; gap: .35rem; }
.poll-opt { position: relative; display: flex; justify-content: space-between; gap: .5rem; padding: .45rem .65rem; border: 1px solid var(--border); border-radius: var(--radius-sm); overflow: hidden; text-align: left; background: var(--surface-1, transparent); }
.poll-opt .bar { position: absolute; inset: 0 auto 0 0; background: color-mix(in srgb, var(--accent) 28%, transparent); transition: width .3s; }
.poll-opt .lbl, .poll-opt .pc { position: relative; display: inline-flex; gap: .3rem; align-items: center; }
.poll-opt .pc { color: var(--muted); font-size: .8rem; white-space: nowrap; }
.poll-opt.mine { border-color: var(--accent); }
.poll.closed .poll-opt { cursor: default; opacity: .85; }

/* Caller+: Profil-Themes & Avatar-Rahmen */
.pcard.themed { border: 2px solid var(--pc-border); box-shadow: 0 0 22px color-mix(in srgb, var(--pc-border) 45%, transparent); }
.avatar[class*="frame-"] { outline-offset: 2px; }
.avatar.frame-gold { outline: 3px solid #f5c542; box-shadow: 0 0 10px #f5c542; }
.avatar.frame-neon { outline: 3px solid #29f0ff; box-shadow: 0 0 12px #29f0ff, 0 0 24px #ff3df0; }
.avatar.frame-ice { outline: 3px solid #bfe9ff; box-shadow: 0 0 12px #7cc8ff; }
.avatar.frame-fire { outline: 3px solid #ff7a1a; box-shadow: 0 0 12px #ff4d00, 0 0 22px #ffb300; animation: fr-fire 1.4s ease-in-out infinite; }
.avatar.frame-pulse { outline: 3px solid var(--accent-strong); animation: fr-pulse 1.8s ease-in-out infinite; }
.avatar.frame-rainbow { outline: 3px solid red; animation: fr-rainbow 4s linear infinite; }
@keyframes fr-fire { 50% { box-shadow: 0 0 6px #ff4d00, 0 0 14px #ffb300; } }
@keyframes fr-pulse { 50% { box-shadow: 0 0 0 6px color-mix(in srgb, var(--accent) 35%, transparent); } }
@keyframes fr-rainbow { 0% { outline-color: #ff3b3b; box-shadow: 0 0 10px #ff3b3b; } 20% { outline-color: #ffd23b; box-shadow: 0 0 10px #ffd23b; } 40% { outline-color: #3bff7a; box-shadow: 0 0 10px #3bff7a; } 60% { outline-color: #3bc8ff; box-shadow: 0 0 10px #3bc8ff; } 80% { outline-color: #b13bff; box-shadow: 0 0 10px #b13bff; } 100% { outline-color: #ff3b3b; box-shadow: 0 0 10px #ff3b3b; } }
@media (prefers-reduced-motion: reduce) { .avatar[class*="frame-"] { animation: none !important; } }
.theme-preview { margin-top: .6rem; width: 260px; border: 2px solid var(--accent); border-radius: var(--radius-sm); overflow: hidden; background: var(--surface-2); }
.theme-preview .tp-banner { height: 48px; background-size: cover; }
.theme-preview .tp-body { display: flex; align-items: center; gap: .6rem; padding: 0 .75rem .75rem; margin-top: -22px; }
.theme-preview .tp-body .avatar { border: 3px solid var(--surface-2); }

/* ── Suche & Pins ── */
.msg-pinned { display: inline-flex; color: var(--warn, #ffb454); margin-left: .35rem; vertical-align: -1px; }
.msg-pinned.corner { position: absolute; right: .9rem; top: .35rem; margin: 0; }
.sr-wrap { display: grid; gap: .8rem; min-height: 0; }
.sr-form { display: grid; gap: .5rem; }
.sr-row { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }
.sr-row .input { flex: 1; min-width: 10rem; }
.sr-row.filters .select { flex: 0 1 auto; }
.sr-row.filters .input { flex: 1 1 9rem; }
.sr-results { max-height: min(60vh, 560px); overflow-y: auto; display: grid; gap: .25rem; align-content: start; }
.sr-count { font-size: .75rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); padding: .2rem .2rem .4rem; }
.sr-item { display: flex; gap: .65rem; align-items: flex-start; text-align: left; width: 100%; padding: .55rem .6rem; border: 1px solid var(--border); border-radius: 10px; background: var(--surface-2); cursor: pointer; color: inherit; font: inherit; }
.sr-item:hover { border-color: var(--accent); }
.sr-main { min-width: 0; flex: 1; }
.sr-head { display: flex; align-items: baseline; gap: .3rem; flex-wrap: wrap; }
.sr-place { margin-left: auto; color: var(--text-2); background: var(--surface-4); border-radius: 6px; padding: 0 .4rem; }
.sr-pin { color: var(--warn, #ffb454); }
.sr-body { overflow-wrap: anywhere; max-height: 7.5em; overflow: hidden; }
.sr-hint { padding: .4rem .2rem; }
.pins-pop { width: min(420px, 92vw); max-height: 70vh; display: flex; flex-direction: column; }
.pins-head { display: flex; align-items: center; gap: .45rem; font-weight: 700; padding: .2rem .2rem .6rem; border-bottom: 1px solid var(--border); margin-bottom: .5rem; }
.pins-list { overflow-y: auto; display: grid; gap: .5rem; }
.pin-item { border: 1px solid var(--border); border-radius: 10px; padding: .55rem .65rem; background: var(--surface-2); }
.pin-top { display: flex; align-items: center; gap: .45rem; margin-bottom: .25rem; }
.pin-body { overflow-wrap: anywhere; max-height: 9em; overflow: hidden; }
.pin-acts { display: flex; gap: .4rem; margin-top: .45rem; justify-content: flex-end; }
.pins-empty { display: grid; justify-items: center; text-align: center; padding: 1.2rem .6rem; gap: .2rem; }
.bottom-sentinel { height: 1px; }
.suggest .cmd { font-weight: 700; color: var(--accent-strong, var(--accent)); }
.suggest .cmd-desc { margin-left: auto; padding-left: .8rem; text-align: right; }
.cmd-help td { vertical-align: top; }
.slow-note { font-size: .78rem; color: var(--text-2); padding: .35rem .8rem 0; }
