/* ============================================================================
   RPG Messenger — LA MIDNIGHT BRUTALIST
   Chat-/Konversations-Plugin: Header, Iconbar, Nachrichten-Bubbles,
   Quickreply, Emoji-Keyboard, Galerie, Lightbox, Inline-Moderation.

   Brutalist-Anpassungen: scharfe Kanten überall, Akzent-Orange für CTAs,
   Mono-Schrift für kleine Labels & Pagination.
   ============================================================================ */


/* ---------- Helper ---------------------------------------------------------*/
/* Versteckt Element via Klasse. DOPPELTE Specificity (.rpgm-hidden.rpgm-hidden):
   Modal-Klassen wie .rpgm-modal, .rpgm-input-modal, .rpgm-lightbox und
   .rpgm-search-bar setzen selbst display:flex — ohne diesen Trick würden
   die später im CSS definierten Klassen den Helper überschreiben und alle
   Popups wären beim Seitenladen offen.
   Inline-Styles vom JS (style.display = 'flex') gewinnen weiterhin, weil
   inline immer höher als jede Klasse wiegt. So bleibt das Toggle-Verhalten
   intakt. */
.rpgm-hidden.rpgm-hidden {
    display: none;
}

/* Hinweis für ausgeloggte Besucher (Quickreply-Slot) */
.rpgm-loginhint {
    text-align: center;
    padding: var(--space-md);
    color: var(--text-muted);
}

/* Status-Hinweise in der Galerie (Lade…/Keine Medien…) */
.rpgm-status-text {
    text-align: center;
    padding: var(--space-lg);
    opacity: 0.6;
    margin: 0;
}

/* Fehler-Variante des Status-Hinweises */
.rpgm-status-error {
    color: var(--error);
    opacity: 1;
}

/* Hinweistext im Link-Eingabe-Modal */
.rpgm-link-hint {
    opacity: 0.6;
    font-size: 0.85rem;
    margin: 0;
}


/* ---------- Wrapper ------------------------------------------------------- */
/* Brutalist: kein Box-Container, nur dezente Border-Trennlinien zwischen
   den Bereichen (Header, Iconbar, Chat, Quickreply). */
.rpgm-wrapper {
    border: none;
    border-radius: 0;
    overflow: visible;
    margin: var(--space-md) 0;
    background: transparent;
}


/* ============================================================================
   HEADER
   ============================================================================ */

.rpgm-header {
    padding: var(--space-lg) 0;
    border-bottom: 1px solid var(--text-dark);
    display: flex;
    align-items: center;
    gap: var(--space-md);
    background: transparent;
}

/* Zurück-Button links (rund — bewusste Ausnahme für Touch-Targets) */
.rpgm-header-back {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.25rem;
    height: 2.25rem;
    border: 1px solid var(--border-light);
    border-radius: 50%;
    text-decoration: none;
    font-size: 1rem;
    opacity: 0.7;
    flex-shrink: 0;
    color: var(--text);
    transition: var(--transition);
}

.rpgm-header-back:hover {
    opacity: 1;
    background: var(--bg);
    border-color: var(--accent);
    color: var(--accent);
}

.rpgm-header-center {
    flex: 1;
}

.rpgm-header-title {
    font-family: var(--font-display);
    font-size: 1.3rem;
    font-weight: normal;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin: 0 0 var(--space-xs) 0;
    color: var(--text);
}

.rpgm-header-participants {
    font-family: var(--font-body);
    font-size: 0.85rem;
    margin: 0 0 0.1875rem 0;
    color: var(--text-dim);
}

.rpgm-header-participants a {
    text-decoration: none;
    margin-right: var(--space-md);
    color: var(--accent);
}

.rpgm-header-date {
    font-family: var(--font-mono);
    font-size: 0.7rem;
    opacity: 0.7;
    margin: 0;
    color: var(--text-muted);
    letter-spacing: 0.05em;
}


/* ============================================================================
   ICONBAR (immersiv/dekorativ)
   ============================================================================ */

.rpgm-iconbar {
    display: flex;
    justify-content: center;
    gap: var(--space-xs);
    padding: var(--space-sm) 0;
    border-bottom: 1px solid var(--border);
    flex-wrap: wrap;
    background: transparent;
}

.rpgm-iconbar a,
.rpgm-iconbar span {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.375rem var(--space-md);
    font-family: var(--font-mono);
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    opacity: 0.6;
    text-decoration: none;
    border-radius: 0;
    color: var(--text-dim);
    transition: var(--transition);
}

.rpgm-iconbar i {
    font-size: 0.9rem;
}

.rpgm-iconbar a:hover {
    opacity: 1;
    background: var(--bg-alt);
    color: var(--accent);
}

.rpgm-iconbar span {
    cursor: default;
}


/* ============================================================================
   MAIN LAYOUT
   ============================================================================ */

.rpgm-main {
    display: block;
}


/* ---------- Chat-Bereich --------------------------------------------------- */
.rpgm-chat {
    padding: var(--space-lg) 0;
    min-height: 21.875rem;
}


/* ============================================================================
   PAGINATION
   ============================================================================ */

.rpgm-pagination {
    padding: var(--space-sm) var(--space-lg);
    text-align: center;
}

.rpgm-pagination:empty {
    display: none;
}

.rpgm-pagination .pagination {
    display: inline-flex;
    justify-content: center;
    align-items: center;
    gap: 0.1875rem;
    font-family: var(--font-mono);
    font-size: 0.75rem;
    opacity: 0.6;
    transition: opacity 0.2s var(--ease);
}

.rpgm-pagination:hover .pagination {
    opacity: 1;
}

.rpgm-pagination .pagination a,
.rpgm-pagination .pagination span {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 1.5rem;
    height: 1.5rem;
    padding: 0 0.375rem;
    border-radius: 0;
    font-family: var(--font-mono);
    font-size: 0.75rem;
    text-decoration: none;
    transition: all 0.15s var(--ease);
    color: inherit;
}

.rpgm-pagination .pagination a {
    background: transparent;
}

.rpgm-pagination .pagination a:hover {
    background: var(--bg-alt);
    color: var(--accent);
}

/* Aktuelle Seite: Akzent-Hintergrund */
.rpgm-pagination .pagination .pagination_current {
    background: var(--accent-dim);
    color: var(--accent);
    font-weight: 600;
}

.rpgm-pagination .pagination .pages {
    margin-right: var(--space-xs);
    opacity: 0.7;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}


/* ============================================================================
   NACHRICHTEN
   ============================================================================ */

.rpgm-msg {
    display: flex;
    align-items: flex-start;
    margin-bottom: 1.125rem;
    gap: var(--space-sm);
}

/* Eigene Nachrichten: Layout spiegeln */
.rpgm-msg--right {
    flex-direction: row-reverse;
}


/* ---------- Side-Container (Nummer + Avatar) ------------------------------ */
.rpgm-msg-side {
    display: flex;
    align-items: flex-start;
    gap: 0.375rem;
    flex-shrink: 0;
}

/* Bei eigenen Bubbles: Nummer rechts vom Avatar */
.rpgm-msg--right .rpgm-msg-side {
    flex-direction: row-reverse;
}

/* Post-Nummer (z. B. #42) */
.rpgm-post-num {
    font-family: var(--font-mono);
    font-size: 0.6rem;
    font-weight: bold;
    text-decoration: none;
    opacity: 0.4;
    padding: 0.125rem 0.25rem;
    margin-top: 0.75rem;
    color: var(--text-muted);
    transition: opacity 0.2s var(--ease);
}

.rpgm-post-num:hover {
    opacity: 0.8;
    color: var(--accent);
}


/* ---------- Avatar-Spalte -------------------------------------------------- */
.rpgm-msg-avatar-col {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.25rem;
    flex-shrink: 0;
}

/* Edit/Delete-Buttons unter Avatar (nur sichtbar bei Hover) */
.rpgm-msg-actions-side {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.25rem;
    margin-top: var(--space-xs);
    opacity: 0;
    transition: opacity 0.2s var(--ease);
}

.rpgm-msg:hover .rpgm-msg-actions-side {
    opacity: 1;
}

/* Edit/Delete-Buttons (rund — bewusste Ausnahme für Icon-Targets) */
.rpgm-edit-btn,
.rpgm-delete-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.375rem;
    height: 1.375rem;
    border-radius: 50%;
    background: var(--bg-alt);
    text-decoration: none;
    font-size: 0.55rem;
    opacity: 0.7;
    color: var(--text-dim);
    transition: var(--transition);
}

.rpgm-edit-btn:hover {
    opacity: 1;
    background: var(--info-bg);
    color: var(--info);
}

.rpgm-delete-btn:hover {
    opacity: 1;
    background: var(--error-bg);
    color: var(--error);
}

.rpgm-msg-avatar-link {
    display: block;
}

/* Avatar (rund) */
.rpgm-msg-avatar {
    width: 2.8125rem;
    height: 2.8125rem;
    border-radius: 50%;
    object-fit: cover;
    display: block;
    transition: transform 0.2s var(--ease);
}

.rpgm-msg-avatar:hover {
    transform: scale(1.1);
}


/* ---------- Bubbles ------------------------------------------------------- */
.rpgm-msg-wrap {
    max-width: 65%;
}

.rpgm-msg--right .rpgm-msg-wrap {
    text-align: right;
}

.rpgm-msg-bubble {
    display: inline-block;
    padding: var(--space-sm) 0.875rem;
    /* Bewusste Ausnahme zum Brutalist-Prinzip: Chat-Messenger-Idiom.
       Drei Ecken rund, eine spitz (zur Sprecherseite) — typischer
       "Talking-Bubble"-Look wie iMessage/WhatsApp. */
    border-radius: 1rem;
    line-height: 1.45;
    text-align: left;
    position: relative;
}

/* Eingehende Nachricht: dezenter Hintergrund, spitze Ecke unten links */
.rpgm-msg--left .rpgm-msg-bubble {
    background: var(--bg-alt);
    color: var(--text);
    border: 1px solid var(--border);
    border-bottom-left-radius: 0.25rem;
}

/* Eigene Nachricht: Akzent-Bubble, spitze Ecke unten rechts */
.rpgm-msg--right .rpgm-msg-bubble {
    background: var(--accent);
    color: var(--bg);
    border: 1px solid var(--accent);
    border-bottom-right-radius: 0.25rem;
}

.rpgm-msg-time {
    font-family: var(--font-mono);
    font-size: 0.65rem;
    opacity: 0.5;
    margin-top: 0.1875rem;
    padding: 0 var(--space-xs);
    color: var(--text-muted);
}


/* ============================================================================
   QUICKREPLY
   ============================================================================ */

.rpgm-quickreply {
    padding: var(--space-md) 0;
    border-top: 1px solid var(--text-dark);
    display: flex;
    justify-content: center;
    align-items: center;
    /* Anker für Emoji-Keyboard und Attach-Menu */
    position: relative;
    background: transparent;
}

.rpgm-qr-row {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    width: 100%;
    /* Breiter (Messenger-App-Look): vorher 37.5rem, jetzt 56rem */
    max-width: 56rem;
    margin: 0 auto;
    /* flex-wrap: das rpg_charcount-Plugin injiziert <div class="rpg-charcount-display">
       direkt als Sibling nach der Textarea, also mitten in diese Zeile.
       Ohne wrap würde der Counter Platz von der Textarea klauen.
       Mit wrap + flex:0 0 100% am Counter rutscht er auf eine eigene Zeile darunter. */
    flex-wrap: wrap;
}

/* Plus-Button für Anhänge (rund — Touch-Target).
   Einheitliche Größe 2.5rem mit Emoji- und Send-Button.

   !important auf border-radius: das Theme-globale css3.css setzt
   `button, textarea, … { border-radius: 0 !important; }` als Brutalist-
   Reset. Im Messenger sind Pille/Kreis-Formen das gewollte Idiom, also
   müssen wir gegen das !important antreten — keine Specificity rettet
   uns sonst. padding:0 verhindert dass der Legacy-Padding aus
   06-buttons.css den Kreis zu einem Oval dehnt. */
.rpgm-qr-row .rpgm-qr-plus {
    width: 2.5rem;
    height: 2.5rem;
    padding: 0;
    border-radius: 50% !important;
    background: var(--bg-alt);
    border: 1px solid var(--border-light);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    flex-shrink: 0;
    font-size: 1rem;
    opacity: 0.7;
    color: var(--text-dim);
    transition: var(--transition);
}

.rpgm-qr-row .rpgm-qr-plus:hover {
    background: var(--bg-card);
    border-color: var(--accent);
    color: var(--accent);
    opacity: 1;
}

/* Wrapper für Plus-Button + Attach-Menu */
.rpgm-qr-plus-wrap {
    position: relative;
}


/* ---------- Attach-Menu Popup --------------------------------------------- */
.rpgm-attach-menu {
    position: absolute;
    bottom: 100%;
    left: 0;
    background: var(--bg-card);
    border: 1px solid var(--border-light);
    border-radius: 0;
    box-shadow: var(--shadow);
    padding: var(--space-sm) 0;
    margin-bottom: var(--space-sm);
    min-width: 10rem;
    z-index: 100;
}

.rpgm-attach-option {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    width: 100%;
    padding: var(--space-sm) var(--space-md);
    border: none;
    background: none;
    font-family: var(--font-body);
    font-size: 0.9rem;
    color: var(--text);
    cursor: pointer;
    transition: background 0.1s var(--ease);
    text-align: left;
}

.rpgm-attach-option:hover {
    background: var(--bg-alt);
    color: var(--accent);
}

.rpgm-attach-option i {
    width: 1.125rem;
    text-align: center;
    opacity: 0.7;
}


/* ---------- Input-Modal (für Bild- oder Link-Eingabe) --------------------- */
.rpgm-input-modal {
    position: fixed;
    inset: 0;
    /* Overlay-Schwarz: bleibt hardcoded weil semantisch (Backdrop-Tönung) */
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

.rpgm-input-modal-content {
    background: var(--bg-card);
    border: 1px solid var(--border-light);
    border-radius: 0;
    width: 90%;
    max-width: 28.125rem;
    box-shadow: var(--shadow);
}

.rpgm-input-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--space-md) var(--space-lg);
    border-bottom: 1px solid var(--border);
    font-family: var(--font-display);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text);
}

.rpgm-input-modal-close {
    background: none;
    border: none;
    font-size: 1.1rem;
    cursor: pointer;
    opacity: 0.5;
    padding: var(--space-xs);
    color: var(--text-dim);
}

.rpgm-input-modal-close:hover {
    opacity: 1;
    color: var(--accent);
}

.rpgm-input-modal-body {
    padding: var(--space-lg);
}

.rpgm-input-modal-body input {
    width: 100%;
    padding: var(--space-md);
    border: 1px solid var(--border-light);
    border-radius: 0;
    background: var(--bg-input);
    color: var(--text);
    font-family: var(--font-body);
    font-size: 0.95rem;
    box-sizing: border-box;
}

.rpgm-input-modal-body input:focus {
    outline: none;
    border-color: var(--accent);
}

.rpgm-input-preview {
    margin-top: var(--space-md);
    text-align: center;
    min-height: 3.125rem;
}

.rpgm-input-preview img {
    max-width: 100%;
    max-height: 12.5rem;
    border-radius: 0;
}

.rpgm-input-preview.rpgm-preview-error {
    color: var(--error);
    font-size: 0.85rem;
    padding: var(--space-md);
}

.rpgm-input-modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: var(--space-sm);
    padding: var(--space-md) var(--space-lg);
    border-top: 1px solid var(--border);
}

.rpgm-input-cancel,
.rpgm-input-confirm {
    padding: var(--space-sm) var(--space-lg);
    border-radius: 0;
    font-family: var(--font-display);
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    cursor: pointer;
    border: none;
    transition: var(--transition);
}

.rpgm-input-cancel {
    background: var(--bg-alt);
    color: var(--text-dim);
    border: 1px solid var(--border-light);
}

.rpgm-input-cancel:hover {
    background: var(--bg);
    color: var(--text);
}

.rpgm-input-confirm {
    background: var(--accent);
    color: var(--bg);
}

.rpgm-input-confirm:hover {
    background: var(--accent-hover);
    /* Text dunkel halten — globaler a:hover würde sonst accent setzen */
    color: var(--bg);
}


/* ---------- Quickreply Textarea --------------------------------------------
   Messenger-App-Look: stärker gerundete Pille, mehr Padding,
   etwas größer für komfortables Tippen.

   !important auf border-radius: css3.css setzt für textarea global
   `border-radius: 0 !important` als Brutalist-Reset. Im Messenger ist
   die Eingabe-Pille das gewollte Idiom, also müssen wir gegensteuern. */
.rpgm-qr-row textarea {
    flex: 1;
    padding: 0.75rem 1.25rem;
    border: 1px solid var(--border-light);
    /* Pill-Form deutlicher ausgeprägt — war 1.25rem, jetzt 1.5rem */
    border-radius: 1.5rem !important;
    resize: none;
    font-family: var(--font-body);
    font-size: 0.95rem;
    line-height: 1.4;
    background: var(--bg-input);
    color: var(--text);
    min-height: 2.5rem;
    max-height: 8rem;
    overflow-y: auto;
    /* 05-forms.css setzt beim Focus einen 2px box-shadow als Glow.
       Hier explizit auf none, damit der Fokus nur über Border-Farbe
       signalisiert wird (passt besser zum Pill-Look). */
    box-shadow: none;
}

.rpgm-qr-row textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: none;
}

/* Send-Button (rund — Touch-Target / Akzent-CTA).
   Einheitliche Größe 2.5rem mit Plus- und Emoji-Button.

   !important auf border-radius: das Theme-globale css3.css setzt
   `button { border-radius: 0 !important; }` als Brutalist-Reset.
   Send-Button ist im Messenger-Idiom rund — also gegensteuern.
   padding:0 verhindert dass der Legacy-Padding aus 06-buttons.css
   den Kreis zu einem Rechteck dehnt. */
.rpgm-qr-row .rpgm-qr-send {
    width: 2.5rem;
    height: 2.5rem;
    padding: 0;
    border-radius: 50% !important;
    background: var(--accent);
    color: var(--bg);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 0.9rem;
    transition: var(--transition);
}

.rpgm-qr-row .rpgm-qr-send:hover {
    background: var(--accent-hover);
    /* Text dunkel halten — globaler a:hover würde sonst accent setzen */
    color: var(--bg);
}


/* ---------- Charcount-Override im Messenger ---------------------------------
   Das rpg_charcount-Plugin rendert <div class="rpg-charcount-display">
   als Sibling DIREKT nach dem <textarea> — also mitten in die Flex-Row.
   Damit er nicht Platz neben der Textarea klaut:
   - flex: 0 0 100% → volle Breite, bricht in neue Zeile (parent hat flex-wrap)
   - order: 99       → wird visuell hinter Plus/Textarea/Emoji/Send geschoben,
                       egal wo das Plugin ihn im DOM einsetzt
   Dadurch sitzt der Counter dezent als eigene Zeile unter der Eingabe. */
.rpgm-quickreply .rpg-charcount-display {
    flex: 0 0 100%;
    order: 99;
    /* Symmetrisch zum Plus-Button + Padding der Textarea-Pille — Counter
       sitzt optisch im selben Raster wie die Eingabe. */
    margin: 0.375rem 0 0;
    padding: 0 1.25rem 0 3.5rem;
    background: transparent;
    text-align: right;
    font-family: var(--font-mono);
    font-size: 0.65rem;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    opacity: 0.5;
    transition: opacity 0.2s var(--ease);
    /* Counter ist Info, nicht interaktiv */
    pointer-events: none;
}

/* Beim Tippen / Fokus: Counter wird besser lesbar */
.rpgm-quickreply:focus-within .rpg-charcount-display {
    opacity: 0.85;
}

/* Warn-Zustand (Plugin setzt .is-warning bei Grenze):
   bleibt voll sichtbar, Akzent in Error-Farbe */
.rpgm-quickreply .rpg-charcount-display.is-warning {
    opacity: 1;
    color: var(--error);
    font-weight: 700;
}


/* ============================================================================
   EMOJI-KEYBOARD
   ============================================================================ */

.rpgm-qr-row .rpgm-qr-emoji {
    /* Einheitliche Größe 2.5rem mit Plus- und Send-Button.
       !important auf border-radius gegen das globale Brutalist-Reset
       in css3.css (`button { border-radius: 0 !important }`). */
    width: 2.5rem;
    height: 2.5rem;
    padding: 0;
    border-radius: 50% !important;
    background: none;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    flex-shrink: 0;
    font-size: 1.1rem;
    opacity: 0.5;
    color: var(--text-dim);
    transition: opacity 0.2s var(--ease);
}

.rpgm-qr-row .rpgm-qr-emoji:hover {
    opacity: 1;
}


/* ---------- Emoji-Panel --------------------------------------------------- */
.rpgm-emoji-kb {
    position: absolute;
    bottom: 100%;
    right: 0;
    width: 21.25rem;
    max-width: 95vw;
    background: var(--bg-card);
    border: 1px solid var(--border-light);
    border-radius: 0;
    box-shadow: var(--shadow);
    z-index: 9998;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    margin-bottom: var(--space-sm);
}

/* Suchfeld */
.rpgm-emoji-kb-header {
    padding: var(--space-sm) 0.75rem 0.375rem;
}

.rpgm-emoji-kb-search {
    width: 100%;
    padding: var(--space-sm) 0.75rem;
    border: 1px solid var(--border-light);
    border-radius: 0;
    font-family: var(--font-body);
    font-size: 0.85rem;
    background: var(--bg-input);
    color: var(--text);
    box-sizing: border-box;
}

.rpgm-emoji-kb-search:focus {
    outline: none;
    border-color: var(--accent);
}


/* Kategorie-Tabs (horizontal scrollbar) */
.rpgm-emoji-kb-tabs {
    display: flex;
    gap: 0.125rem;
    padding: 0.25rem var(--space-sm);
    border-bottom: 1px solid var(--border);
    overflow-x: auto;
    /* Scrollbar verstecken (Firefox + WebKit) */
    scrollbar-width: none;
}

.rpgm-emoji-kb-tabs::-webkit-scrollbar {
    display: none;
}

.rpgm-emoji-kb-tab {
    flex-shrink: 0;
    width: 2.125rem;
    height: 2.125rem;
    border: none;
    background: none;
    border-radius: 0;
    font-size: 1.1rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0.5;
    transition: all 0.15s var(--ease);
}

.rpgm-emoji-kb-tab:hover {
    opacity: 0.8;
    background: var(--bg-alt);
}

.rpgm-emoji-kb-tab--active {
    opacity: 1;
    background: var(--accent-dim);
    border-bottom: 2px solid var(--accent);
}


/* Emoji-Grid */
.rpgm-emoji-kb-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 0.125rem;
    padding: var(--space-sm);
    height: 15rem;
    overflow-y: auto;
    align-content: flex-start;
}

.rpgm-emoji-kb-grid::-webkit-scrollbar {
    width: 0.25rem;
}

.rpgm-emoji-kb-grid::-webkit-scrollbar-thumb {
    background: var(--border-light);
    border-radius: 0;
}

.rpgm-emoji-kb-btn {
    width: 2.375rem;
    height: 2.375rem;
    border: none;
    background: none;
    font-size: 1.4rem;
    cursor: pointer;
    border-radius: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.1s var(--ease);
    padding: 0;
    line-height: 1;
}

.rpgm-emoji-kb-btn:hover {
    background: var(--bg-alt);
    transform: scale(1.15);
}

/* Empty-State im Emoji-Grid */
.rpgm-emoji-kb-empty {
    width: 100%;
    text-align: center;
    padding: var(--space-2xl) var(--space-lg);
    font-family: var(--font-mono);
    font-size: 0.85rem;
    opacity: 0.5;
    color: var(--text-muted);
}


/* ============================================================================
   SUCH-LEISTE (innerhalb des Chats)
   ============================================================================ */

/* Search-Bar: Brutalist — transparent, nur Trennlinie unten, Input scharfkantig */
.rpgm-search-bar {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    padding: var(--space-sm) 0;
    background: transparent;
    border-bottom: 1px solid var(--border);
}

.rpgm-search-bar input {
    flex: 1;
    padding: var(--space-sm) var(--space-md);
    border: 1px solid var(--border-light);
    border-radius: 0;
    background: var(--bg-input);
    color: var(--text);
    font-family: var(--font-body);
    font-size: 0.85rem;
    transition: border-color 0.2s var(--ease);
}

.rpgm-search-bar input::placeholder {
    color: var(--text-muted);
    font-family: var(--font-mono);
    font-size: 0.75rem;
    letter-spacing: 0.05em;
}

.rpgm-search-bar input:focus {
    outline: none;
    border-color: var(--accent);
}

/* Navigations-Buttons (prev/next/close) — Outline-Style scharfkantig */
.rpgm-search-bar button {
    width: 2rem;
    height: 2rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: 1px solid var(--border-light);
    border-radius: 0;
    padding: 0;
    cursor: pointer;
    color: var(--text-dim);
    transition: var(--transition);
}

.rpgm-search-bar button:hover {
    border-color: var(--accent);
    color: var(--accent);
}

#rpgm-search-results {
    font-family: var(--font-mono);
    font-size: 0.7rem;
    letter-spacing: 0.05em;
    opacity: 0.7;
    min-width: 2.5rem;
    color: var(--text-muted);
    font-variant-numeric: tabular-nums;
}

/* !important: muss inline-Browser-Defaults für ::selection überschreiben */
.rpgm-highlight {
    background: var(--warning-bg) !important;
    color: var(--warning) !important;
}

.rpgm-highlight-current {
    background: var(--warning) !important;
    color: var(--bg) !important;
}


/* ============================================================================
   MESSAGE ACTIONS (Zitieren, Reagieren) — beim Bubble-Hover
   ============================================================================ */

.rpgm-msg-actions {
    display: none;
    position: absolute;
    top: var(--space-xs);
    gap: var(--space-xs);
}

.rpgm-msg--left  .rpgm-msg-actions { right: -3.75rem; }
.rpgm-msg--right .rpgm-msg-actions { left: -3.75rem; }

.rpgm-msg-bubble:hover .rpgm-msg-actions {
    display: flex;
}

.rpgm-action-btn {
    width: 1.75rem;
    height: 1.75rem;
    border-radius: 50%;
    border: 1px solid var(--border-light);
    background: var(--bg-card);
    color: var(--text-dim);
    cursor: pointer;
    font-size: 0.75rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}

.rpgm-action-btn:hover {
    background: var(--bg);
    border-color: var(--accent);
    color: var(--accent);
}


/* ============================================================================
   MSG META (Zeit + Status)
   ============================================================================ */

.rpgm-msg-meta {
    display: flex;
    align-items: center;
    gap: var(--space-xs);
    margin-top: 0.1875rem;
    padding: 0 var(--space-xs);
}

.rpgm-msg-status {
    font-family: var(--font-mono);
    font-size: 0.7rem;
    color: var(--accent);
}


/* ============================================================================
   REAKTIONEN
   ============================================================================ */

.rpgm-reactions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem;
    margin-top: 0.25rem;
    padding: 0 0.25rem;
}

/* Bei eigenen Bubbles: Reactions auch rechts ausgerichtet — sonst hingen
   sie default links innerhalb des rechten Wrappers (text-align greift bei
   flex nicht) */
.rpgm-msg--right .rpgm-reactions {
    justify-content: flex-end;
}

.rpgm-reaction {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.125rem 0.5rem;
    background: var(--bg-alt);
    border: 1px solid var(--border-light);
    /* Pill-Form passend zum Chat-Bubble-Idiom (Reactions auf abgerundete
       Bubbles wirken mit scharfen Kanten unsauber) */
    border-radius: 1rem;
    font-size: 0.8rem;
    line-height: 1;
    cursor: pointer;
    transition: transform 0.1s var(--ease), background 0.1s var(--ease);
    position: relative;
}

.rpgm-reaction:hover {
    transform: scale(1.1);
    background: var(--bg-card);
}

/* Eigene Reaktion: Akzent-Border, dezenter Akzent-Hintergrund */
.rpgm-reaction--own {
    background: var(--accent-dim);
    border-color: var(--accent);
}

.rpgm-reaction--own:hover {
    background: var(--accent-dim);
}

.rpgm-reaction small {
    font-family: var(--font-mono);
    font-size: 0.7rem;
    opacity: 0.7;
}


/* Tooltip beim Hover über die Reaktion (zeigt User-Liste) */
.rpgm-reaction-tooltip {
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    background: var(--bg);
    color: var(--text);
    border: 1px solid var(--border-light);
    padding: var(--space-xs) var(--space-sm);
    border-radius: 0;
    font-family: var(--font-mono);
    font-size: 0.75rem;
    white-space: nowrap;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s, visibility 0.2s;
    pointer-events: none;
    margin-bottom: var(--space-xs);
    z-index: 100;
}

.rpgm-reaction-tooltip::after {
    content: "";
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 5px solid transparent;
    border-top-color: var(--border-light);
}

.rpgm-reaction:hover .rpgm-reaction-tooltip {
    opacity: 1;
    visibility: visible;
}


/* ============================================================================
   QUOTE STYLING (Chat-optimiert)
   ============================================================================ */

.rpgm-quote {
    margin: 0 0 var(--space-sm) 0;
    padding: var(--space-sm) 0.75rem;
    background: var(--bg);
    border-left: 3px solid var(--text-dim);
    /* Leicht abgerundet damit der Quote-Block zur Bubble-Optik passt */
    border-radius: 0.5rem;
    font-size: 0.9em;
}

/* Quote in eigener Bubble: invertierte Farbe */
.rpgm-msg--right .rpgm-quote {
    background: rgba(255, 255, 255, 0.15);
    border-left-color: rgba(255, 255, 255, 0.5);
}

.rpgm-quote-header {
    display: flex;
    align-items: center;
    gap: 0.375rem;
    font-family: var(--font-mono);
    font-size: 0.75em;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.375rem;
    opacity: 0.85;
}

.rpgm-quote-icon {
    font-size: 0.75em;
    transform: scaleX(-1);
}

.rpgm-quote-author {
    color: inherit;
}

.rpgm-quote-body {
    line-height: 1.4;
    opacity: 0.9;
}

/* !important: blendet alte MyBB-Quotes innerhalb der Bubble aus */
.rpgm-msg-bubble .quote_container {
    display: none !important;
}


/* ============================================================================
   EMOJI PICKER (alte Variante, Fallback)
   ============================================================================ */

.rpgm-emoji-picker {
    position: fixed;
    background: var(--bg-card);
    border: 1px solid var(--border-light);
    border-radius: 0;
    box-shadow: var(--shadow);
    padding: var(--space-sm);
    z-index: 9999;
}

.rpgm-emoji-list {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-xs);
    max-width: 12.5rem;
}

.rpgm-emoji-list button {
    width: 2rem;
    height: 2rem;
    border: none;
    background: none;
    font-size: 1.2rem;
    cursor: pointer;
    border-radius: 0;
    transition: background 0.1s var(--ease);
}

.rpgm-emoji-list button:hover {
    background: var(--bg-alt);
}


/* ============================================================================
   TYPING INDICATOR
   ============================================================================ */

.rpgm-typing-indicator {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    padding: var(--space-sm) var(--space-lg);
    font-family: var(--font-mono);
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    opacity: 0.7;
    color: var(--text-dim);
}

.rpgm-typing-dots {
    display: flex;
    gap: 0.1875rem;
}

.rpgm-typing-dots span {
    width: 0.375rem;
    height: 0.375rem;
    background: var(--text-muted);
    border-radius: 50%;
    animation: rpgm-typing 1.4s infinite;
}

.rpgm-typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.rpgm-typing-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes rpgm-typing {
    0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
    30% { transform: translateY(-0.25rem); opacity: 1; }
}


/* ============================================================================
   MODALS
   ============================================================================ */

.rpgm-modal {
    position: fixed;
    inset: 0;
    /* Overlay-Schwarz: bleibt hardcoded — semantischer Backdrop */
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9998;
}

.rpgm-modal-content {
    background: var(--bg-card);
    border: 1px solid var(--border-light);
    border-radius: 0;
    max-width: 90%;
    max-height: 90%;
    overflow: auto;
    box-shadow: var(--shadow);
}

.rpgm-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--space-md) var(--space-lg);
    border-bottom: 1px solid var(--border);
}

.rpgm-modal-header h3 {
    margin: 0;
    font-family: var(--font-display);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text);
}

.rpgm-modal-close {
    background: none;
    border: none;
    font-size: 1.2rem;
    cursor: pointer;
    opacity: 0.6;
    color: var(--text-dim);
}

.rpgm-modal-close:hover {
    opacity: 1;
    color: var(--accent);
}


/* ============================================================================
   GALERIE
   ============================================================================ */

.rpgm-gallery {
    width: 37.5rem;
}

.rpgm-gallery-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.3125rem;
    padding: var(--space-md);
}

.rpgm-gallery-grid img {
    width: 100%;
    aspect-ratio: 1;
    object-fit: cover;
    /* Brutalist: keine Rundung */
    border-radius: 0;
    cursor: pointer;
    transition: transform 0.2s var(--ease);
}

.rpgm-gallery-grid img:hover {
    transform: scale(1.05);
}


/* ============================================================================
   LIGHTBOX
   ============================================================================ */

.rpgm-lightbox {
    position: fixed;
    inset: 0;
    /* Sehr dunkler Backdrop für Bildansicht */
    background: rgba(0, 0, 0, 0.95);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

.rpgm-lightbox img {
    max-width: 90%;
    max-height: 90%;
    object-fit: contain;
}

.rpgm-lightbox button {
    position: absolute;
    background: rgba(255, 255, 255, 0.15);
    border: 1px solid rgba(255, 255, 255, 0.3);
    color: #fff;
    font-size: 1.5rem;
    width: 3.125rem;
    height: 3.125rem;
    border-radius: 50%;
    cursor: pointer;
    transition: var(--transition);
}

.rpgm-lightbox button:hover {
    background: rgba(255, 255, 255, 0.3);
}

.rpgm-lightbox-close { top: var(--space-lg); right: var(--space-lg); }
.rpgm-lightbox-prev  { left: var(--space-lg); top: 50%; transform: translateY(-50%); }
.rpgm-lightbox-next  { right: var(--space-lg); top: 50%; transform: translateY(-50%); }


/* ============================================================================
   ICONBAR-BUTTONS (Sammelklasse)
   ============================================================================ */

.rpgm-iconbar-btn {
    background: none;
    border: none;
    padding: var(--space-sm) var(--space-md);
    cursor: pointer;
    font-family: var(--font-mono);
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    opacity: 0.7;
    display: inline-flex;
    align-items: center;
    gap: var(--space-xs);
    color: var(--text-dim);
    transition: var(--transition);
}

.rpgm-iconbar-btn:hover {
    opacity: 1;
    color: var(--accent);
}


/* ============================================================================
   RESPONSIVE
   ============================================================================ */
@media (max-width: 600px) {
    .rpgm-header {
        flex-wrap: wrap;
    }

    .rpgm-header-avatars img {
        width: 2rem;
        height: 2rem;
    }

    .rpgm-sidebar {
        display: none;
    }

    .rpgm-msg-wrap {
        max-width: 80%;
    }

    .rpgm-iconbar {
        gap: 0.125rem;
    }

    .rpgm-iconbar a,
    .rpgm-iconbar span {
        padding: var(--space-xs) var(--space-sm);
        font-size: 0.65rem;
    }

    .rpgm-gallery {
        width: 95%;
    }

    .rpgm-gallery-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    /* Message-Actions auf Mobile inline statt absolut */
    .rpgm-msg-actions {
        position: static;
        display: flex;
        margin-top: var(--space-xs);
    }

    /* Emoji-Keyboard mobil: volle Breite, oben angedockt */
    .rpgm-emoji-kb {
        width: 100%;
        max-width: 100%;
        right: 0;
        margin-bottom: 0;
    }

    .rpgm-emoji-kb-grid {
        height: 12.5rem;
    }

    /* Quickreply mobil: weniger Padding, Counter kompakter */
    .rpgm-qr-row {
        gap: var(--space-xs);
    }

    .rpgm-quickreply .rpg-charcount-display {
        padding: 0 var(--space-md);
        font-size: 0.6rem;
    }
}


/* ============================================================================
   INLINE MODERATION
   ============================================================================ */

.rpgm-wrapper .inline_moderation,
.rpgm-wrapper .moderation_options {
    margin: var(--space-md) 0 0 0;
    padding: var(--space-md) 0;
    background: transparent;
    border-top: 1px solid var(--text-dark);
    border-radius: 0;
}

.rpgm-wrapper .inline_moderation select,
.rpgm-wrapper .moderation_options select {
    padding: var(--space-sm) var(--space-md);
    border: 1px solid var(--border-light);
    border-radius: 0;
    background: var(--bg-input);
    color: var(--text);
    font-family: var(--font-body);
    font-size: 0.85rem;
}

.rpgm-wrapper .inline_moderation input[type="submit"],
.rpgm-wrapper .moderation_options input[type="submit"] {
    padding: var(--space-sm) var(--space-md);
    border: none;
    border-radius: 0;
    background: var(--accent);
    color: var(--bg);
    cursor: pointer;
    font-family: var(--font-display);
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-left: var(--space-sm);
    transition: var(--transition);
}

.rpgm-wrapper .inline_moderation input[type="submit"]:hover,
.rpgm-wrapper .moderation_options input[type="submit"]:hover {
    background: var(--accent-hover);
    /* Text dunkel halten — globaler a:hover würde sonst accent setzen */
    color: var(--bg);
}