/* SDChat — Neutral Minimal Design System (Step 6: 2-Pane Workspace, DMs & Groups) */

:root {
    --bg: #FAFAFA;
    --surface: #FFFFFF;
    --surface-2: #F4F4F4;
    --border: #E5E5E5;
    --text: #171717;
    --muted: #737373;
    --accent: #262626;
    --accent-text: #FFFFFF;
    --bubble-own: #F0F0F0;
    --bubble-other: #FFFFFF;
    --danger: #8B2E2E;
    --danger-bg: #FAF2F2;
    --danger-border: #E5CACA;
    --backdrop: rgba(10, 10, 10, 0.45);

    /* Neutral deterministic avatar shades (Light) */
    --av-bg-0: #E5E5E5;
    --av-bg-1: #DCDCDC;
    --av-bg-2: #D4D4D4;
    --av-bg-3: #EBEBEB;
    --av-bg-4: #E0E0E0;

    --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;

    --radius-sm: 6px;
    --radius-md: 8px;
    --transition: 150ms ease;
    color-scheme: light;
}

[data-theme="dark"] {
    --bg: #0A0A0A;
    --surface: #141414;
    --surface-2: #1A1A1A;
    --border: #262626;
    --text: #EDEDED;
    --muted: #8A8A8A;
    --accent: #EDEDED;
    --accent-text: #0A0A0A;
    --bubble-own: #1F1F1F;
    --bubble-other: #141414;
    --danger: #C25B5B;
    --danger-bg: #1F1212;
    --danger-border: #3D2020;
    --backdrop: rgba(0, 0, 0, 0.7);

    /* Neutral deterministic avatar shades (Dark) */
    --av-bg-0: #222222;
    --av-bg-1: #282828;
    --av-bg-2: #1E1E1E;
    --av-bg-3: #2D2D2D;
    --av-bg-4: #252525;
    color-scheme: dark;
}

*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html,
body {
    height: 100%;
    background-color: var(--bg);
    color: var(--text);
    font-family: var(--font-sans);
    font-size: 14px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

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

:focus-visible {
    outline: 2px solid var(--text);
    outline-offset: 2px;
}

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

[hidden] {
    display: none !important;
}

.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;
}

/* Auth Layout */
.app-root {
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
}

.auth-shell {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
}

.auth-card {
    width: 100%;
    max-width: 440px;
    background-color: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 24px;
}

.auth-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border);
}

.brand-lockup {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.brand-mark {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--text);
}

.brand-title {
    font-size: 15px;
    font-weight: 600;
    letter-spacing: -0.01em;
}

/* Theme Switcher */
.theme-switcher {
    display: inline-flex;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background-color: var(--surface-2);
    padding: 2px;
    gap: 2px;
}

.theme-btn {
    border: none;
    background: transparent;
    color: var(--muted);
    padding: 4px 8px;
    font-size: 12px;
    border-radius: 4px;
    cursor: pointer;
    transition: background-color var(--transition), color var(--transition);
}

.theme-btn[aria-pressed="true"] {
    background-color: var(--surface);
    color: var(--text);
    font-weight: 500;
}

/* Typography */
.screen-title {
    font-size: 18px;
    font-weight: 600;
    letter-spacing: -0.015em;
    margin-bottom: 6px;
}

.screen-subtitle {
    color: var(--muted);
    font-size: 13px;
    line-height: 1.5;
    margin-bottom: 20px;
}

.muted-text {
    color: var(--muted);
    font-size: 13px;
}

.mono-inline {
    font-family: var(--font-mono);
    font-size: 12.5px;
    color: var(--text);
    font-weight: 500;
}

/* Alert Box */
.alert-box {
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background-color: var(--surface-2);
    color: var(--text);
    font-size: 13px;
    margin-bottom: 16px;
}

.alert-box[data-variant="danger"] {
    border-color: var(--danger-border);
    background-color: var(--danger-bg);
    color: var(--danger);
}

/* Forms & Inputs */
.auth-form {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.auth-terms-note {
    margin-top: 14px;
    margin-bottom: 0;
}

.field-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.field-label-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.field-label {
    font-size: 12.5px;
    font-weight: 500;
    color: var(--text);
}

.field-hint,
.availability-hint {
    font-size: 11.5px;
    color: var(--muted);
    font-family: var(--font-mono);
}

.availability-hint[data-status="invalid"] {
    color: var(--danger);
}

.availability-hint[data-status="valid"] {
    color: var(--text);
}

.prefix-input-wrap {
    position: relative;
    display: flex;
    align-items: center;
}

.input-prefix {
    position: absolute;
    left: 12px;
    font-family: var(--font-mono);
    font-size: 13.5px;
    color: var(--muted);
    pointer-events: none;
}

.text-input {
    width: 100%;
    height: 38px;
    padding: 0 12px;
    background-color: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 14px;
    color: var(--text);
    transition: border-color var(--transition);
}

.text-input.input-with-prefix {
    padding-left: 28px;
    font-family: var(--font-mono);
}

.text-input.input-sm {
    height: 32px;
    font-size: 13px;
    padding: 0 10px;
}

.text-area {
    width: 100%;
    padding: 8px 12px;
    background-color: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 14px;
    color: var(--text);
    resize: vertical;
    min-height: 74px;
    transition: border-color var(--transition);
}

.text-input::placeholder,
.text-area::placeholder {
    color: var(--muted);
}

.text-input:focus,
.text-area:focus {
    border-color: var(--text);
    outline: none;
}

/* Avatars (Image + Neutral Deterministic Initials Circle + Presence Dot) */
.avatar-wrap {
    position: relative;
    display: inline-flex;
    flex-shrink: 0;
}

.avatar {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    border: 1px solid var(--border);
    background-color: var(--av-bg-0);
    color: var(--text);
    font-family: var(--font-mono);
    font-weight: 600;
    text-transform: uppercase;
    user-select: none;
    overflow: hidden;
    flex-shrink: 0;
}

.avatar[data-shade="0"] { background-color: var(--av-bg-0); }
.avatar[data-shade="1"] { background-color: var(--av-bg-1); }
.avatar[data-shade="2"] { background-color: var(--av-bg-2); }
.avatar[data-shade="3"] { background-color: var(--av-bg-3); }
.avatar[data-shade="4"] { background-color: var(--av-bg-4); }

.avatar-sm { width: 32px; height: 32px; font-size: 11.5px; }
.avatar-md { width: 38px; height: 38px; font-size: 13px; }
.avatar-lg { width: 64px; height: 64px; font-size: 20px; }

.avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.presence-dot {
    position: absolute;
    right: -1px;
    bottom: -1px;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background-color: var(--text);
    border: 2px solid var(--surface);
}

.avatar-picker-row {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 12px;
    background-color: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    margin-bottom: 16px;
}

.avatar-picker-actions {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.btn-row {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

/* ========================================================================== */
/* Step 6: Two-Pane Desktop / Single-Pane Mobile Workspace                    */
/* ========================================================================== */

.workspace-shell {
    height: 100dvh;
    width: 100%;
    display: flex;
    overflow: hidden;
    background-color: var(--bg);
}

/* Left Sidebar (~320px) */
.sidebar-pane {
    width: 320px;
    flex-shrink: 0;
    height: 100%;
    display: flex;
    flex-direction: column;
    background-color: var(--surface);
    border-right: 1px solid var(--border);
}

.sidebar-header {
    height: 56px;
    padding: 0 14px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.sidebar-header-actions {
    display: flex;
    align-items: center;
    gap: 6px;
}

.sidebar-search {
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.conv-list {
    flex: 1;
    overflow-y: auto;
    padding: 6px;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.conv-item {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 10px;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    background: transparent;
    text-align: left;
    cursor: pointer;
    transition: background-color var(--transition), border-color var(--transition), transform 0.14s ease;
}

.conv-item:hover {
    background-color: var(--surface-2);
    transform: translateX(3px);
}

.conv-item:active {
    transform: scale(0.982);
}

.conv-item[aria-selected="true"] {
    background-color: var(--surface-2);
    border-color: var(--border);
}

.conv-item-body {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.conv-item-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 6px;
}

.conv-item-title {
    font-size: 13.5px;
    font-weight: 500;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.conv-item-time {
    font-family: var(--font-mono);
    font-size: 11px;
    color: var(--muted);
    flex-shrink: 0;
}

.conv-item-bottom {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.conv-item-preview {
    font-size: 12.5px;
    color: var(--muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.conv-item-badges {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    flex-shrink: 0;
}

.unread-pill {
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    border-radius: 999px;
    background-color: var(--accent);
    color: var(--accent-text);
    font-family: var(--font-mono);
    font-size: 11px;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

/* Sidebar User Footer */
.sidebar-footer {
    padding: 10px 12px;
    border-top: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    background-color: var(--surface);
    flex-shrink: 0;
}

.user-footer-btn {
    display: flex;
    align-items: center;
    gap: 10px;
    background: transparent;
    border: none;
    text-align: left;
    cursor: pointer;
    min-width: 0;
    flex: 1;
    padding: 4px;
    border-radius: var(--radius-sm);
    transition: background-color var(--transition);
}

.user-footer-btn:hover {
    background-color: var(--surface-2);
}

.user-footer-meta {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.user-footer-name {
    font-size: 13px;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-footer-handle {
    font-family: var(--font-mono);
    font-size: 11px;
    color: var(--muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-footer-actions {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-shrink: 0;
}

.dot-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    min-width: 16px;
    height: 16px;
    padding: 0 4px;
    border-radius: 999px;
    background-color: var(--accent);
    color: var(--accent-text);
    font-family: var(--font-mono);
    font-size: 10px;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

/* Main Chat Pane */
.chat-pane {
    flex: 1;
    min-width: 0;
    height: 100%;
    display: flex;
    flex-direction: column;
    background-color: var(--bg);
}

.chat-empty-state {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
}

.empty-state-card {
    max-width: 380px;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.empty-state-actions {
    margin-top: 12px;
    justify-content: center;
}

.chat-active-view {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
}

.chat-header {
    height: 56px;
    padding: 0 16px;
    background-color: var(--surface);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-shrink: 0;
}

.chat-header-left {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}

.chat-header-titles {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.chat-header-title-row {
    display: flex;
    align-items: center;
    gap: 8px;
}

.chat-title {
    font-size: 14.5px;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-subtitle {
    font-size: 12px;
    color: var(--muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-header-actions {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}

.chat-body-split {
    flex: 1;
    min-height: 0;
    display: flex;
    overflow: hidden;
}

.chat-messages-col {
    position: relative;
    flex: 1;
    min-width: 0;
    min-height: 0;
    display: flex;
    flex-direction: column;
    background-color: var(--bg);
}

.chat-messages-viewport {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: 16px 20px 12px;
    display: flex;
    flex-direction: column;
}

.system-event-pill {
    align-self: center;
    margin: 6px auto;
    padding: 5px 12px;
    border-radius: 999px;
    border: 1px solid var(--border);
    background-color: var(--surface);
    color: var(--muted);
    font-size: 12px;
    text-align: center;
    max-width: 90%;
}

/* Right Slide-In Info Panel */
.conv-info-panel {
    width: 300px;
    flex-shrink: 0;
    height: 100%;
    background-color: var(--surface);
    border-left: 1px solid var(--border);
    display: flex;
    flex-direction: column;
}

.info-panel-header {
    height: 48px;
    padding: 0 16px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}

.info-panel-body {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 18px;
}

.info-hero {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 6px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border);
}

.info-title {
    font-size: 15px;
    font-weight: 600;
    margin-top: 4px;
}

.info-section {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border);
}

.info-section:last-child {
    border-bottom: none;
}

.compact-user-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.compact-user-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 8px;
    background-color: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
}

.compact-user-left {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
    flex: 1;
}

.compact-user-meta {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.compact-user-name {
    font-size: 12.5px;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.compact-user-handle {
    font-family: var(--font-mono);
    font-size: 11px;
    color: var(--muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Selected Member Chips */
.chip-list {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.member-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 3px 8px;
    border-radius: 999px;
    background-color: var(--surface-2);
    border: 1px solid var(--border);
    font-size: 12px;
}

.chip-remove-btn {
    border: none;
    background: transparent;
    color: var(--muted);
    cursor: pointer;
    font-size: 13px;
    line-height: 1;
}

.modal-top-gap {
    margin-top: 12px;
}

.mobile-only {
    display: none !important;
}

@media (max-width: 767px) {
    .mobile-only {
        display: inline-flex !important;
    }

    .sidebar-pane {
        width: 100%;
        border-right: none;
    }

    .workspace-shell[data-mobile-pane="list"] .chat-pane {
        display: none;
    }

    .workspace-shell[data-mobile-pane="chat"] .sidebar-pane {
        display: none;
    }

    .conv-info-panel {
        position: fixed;
        inset: 0;
        width: 100%;
        z-index: 80;
    }
}

/* Square Avatar Cropper Modal */
.crop-modal-body {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.crop-stage-wrap {
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 16px;
}

.crop-canvas {
    width: 256px;
    height: 256px;
    border-radius: 50%;
    border: 1px solid var(--border);
    cursor: grab;
    touch-action: none;
    background-color: var(--bg);
}

.crop-canvas:active {
    cursor: grabbing;
}

.range-input {
    width: 100%;
    accent-color: var(--text);
}

/* Settings Modal */
.modal-panel-md {
    max-width: 580px;
    max-height: min(680px, calc(100dvh - 32px));
}

.settings-body {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.settings-section {
    display: flex;
    flex-direction: column;
    gap: 14px;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--border);
}

.settings-section:last-child {
    border-bottom: none;
    padding-bottom: 0;
}

.section-heading {
    font-size: 14px;
    font-weight: 600;
}

/* 6-Box OTP Input Grid */
.otp-fieldset {
    border: none;
}

.otp-grid {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 8px;
}

.otp-digit {
    width: 100%;
    height: 46px;
    text-align: center;
    font-family: var(--font-mono);
    font-size: 18px;
    font-weight: 600;
    background-color: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    transition: border-color var(--transition), background-color var(--transition);
}

.otp-digit:focus {
    border-color: var(--text);
    background-color: var(--surface-2);
    outline: 2px solid var(--text);
    outline-offset: 1px;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    height: 38px;
    padding: 0 16px;
    font-size: 13.5px;
    font-weight: 500;
    border-radius: var(--radius-sm);
    border: 1px solid transparent;
    cursor: pointer;
    transition: all 0.15s cubic-bezier(0.2, 0, 0, 1);
}

.btn:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
}

.btn:active:not(:disabled) {
    transform: translateY(0) scale(0.98);
}

.icon-btn {
    transition: transform 0.15s cubic-bezier(0.2, 0, 0, 1),
                background-color var(--transition),
                color var(--transition);
}

.icon-btn:hover:not(:disabled) {
    transform: scale(1.08);
}

.icon-btn:active:not(:disabled) {
    transform: scale(0.92);
}

.btn-sm {
    height: 30px;
    padding: 0 10px;
    font-size: 12px;
}

.btn:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

.btn-block {
    width: 100%;
}

.btn-primary {
    background-color: var(--accent);
    color: var(--accent-text);
    border-color: var(--accent);
}

.btn-primary:hover:not(:disabled) {
    opacity: 0.9;
}

.btn-secondary {
    background-color: var(--surface-2);
    color: var(--text);
    border-color: var(--border);
}

.btn-secondary:hover:not(:disabled) {
    border-color: var(--muted);
}

.btn-danger {
    background-color: var(--danger-bg);
    color: var(--danger);
    border-color: var(--danger-border);
}

.btn-danger:hover:not(:disabled) {
    border-color: var(--danger);
}

.btn-link {
    background: none;
    border: none;
    color: var(--text);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    padding: 2px 4px;
    border-radius: 4px;
}

.btn-link:disabled {
    color: var(--muted);
    cursor: default;
}

.icon-btn {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background-color: var(--surface-2);
    color: var(--text);
    cursor: pointer;
    transition: border-color var(--transition);
}

.icon-btn:hover {
    border-color: var(--muted);
}

.otp-footer {
    margin-top: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-size: 13px;
}

.dot-sep {
    color: var(--muted);
}

/* Status Gate & Meta Lists */
.status-badge-row {
    margin-bottom: 12px;
}

.status-pill {
    display: inline-flex;
    align-items: center;
    padding: 2px 7px;
    font-family: var(--font-mono);
    font-size: 10.5px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    border-radius: 4px;
    background-color: var(--surface-2);
    border: 1px solid var(--border);
    color: var(--text);
}

.status-pill[data-variant="danger"] {
    border-color: var(--danger-border);
    background-color: var(--danger-bg);
    color: var(--danger);
}

.status-pill[data-variant="owner"] {
    border-color: rgba(234, 179, 8, 0.4);
    background-color: rgba(234, 179, 8, 0.12);
    color: #facc15;
}

.status-pill[data-variant="admin"] {
    border-color: rgba(99, 102, 241, 0.4);
    background-color: rgba(99, 102, 241, 0.15);
    color: #a5b4fc;
}

.status-pill[data-variant="perm"] {
    font-size: 10px;
    padding: 1px 6px;
    background-color: var(--surface-3);
    border-color: var(--border-subtle);
    color: var(--text-muted);
    text-transform: none;
    letter-spacing: normal;
    border-radius: 4px;
}

.admin-perms-chips {
    display: inline-flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-left: 6px;
    vertical-align: middle;
}

.checkbox-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 6px;
}

.checkbox-label {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 9px 12px;
    border-radius: var(--radius-sm, 6px);
    background: var(--surface-2);
    border: 1px solid var(--border-subtle);
    cursor: pointer;
    font-size: 13px;
    line-height: 1.4;
    transition: background 0.15s ease, border-color 0.15s ease;
}

.checkbox-label:hover {
    background: var(--surface-3);
    border-color: var(--border);
}

.checkbox-label input[type="checkbox"] {
    margin-top: 2px;
    accent-color: var(--primary);
    width: 15px;
    height: 15px;
    cursor: pointer;
}

.status-pill-success {
    border-color: var(--border);
    background-color: var(--surface-3);
    color: var(--text-muted);
}

/* Telegram-style Pinned Message Banner */
.chat-pinned-banner {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 7px 16px;
    background: rgba(18, 24, 38, 0.9);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border-subtle);
    border-left: 3px solid var(--primary, #3b82f6);
    z-index: 10;
    animation: bannerDrop 0.22s cubic-bezier(0.16, 1, 0.3, 1) both;
}

@keyframes bannerDrop {
    from { opacity: 0; transform: translateY(-8px); }
    to { opacity: 1; transform: translateY(0); }
}

.pinned-banner-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--primary, #3b82f6);
    flex-shrink: 0;
}

.pinned-banner-content {
    display: flex;
    flex-direction: column;
    gap: 1px;
    min-width: 0;
    flex: 1;
    cursor: pointer;
    text-align: left;
}

.pinned-banner-title {
    font-size: 11px;
    font-weight: 600;
    color: var(--primary, #3b82f6);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.pinned-banner-text {
    font-size: 13px;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.pinned-banner-content:hover .pinned-banner-text {
    text-decoration: underline;
}

/* Highlight pulse when jumping to pinned or searched message */
@keyframes msgHighlightPulse {
    0% { background-color: rgba(59, 130, 246, 0.35); box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.5); }
    60% { background-color: rgba(59, 130, 246, 0.15); }
    100% { background-color: transparent; box-shadow: none; }
}

.msg-highlight-pulse {
    animation: msgHighlightPulse 1.8s ease-out forwards;
    border-radius: 8px;
}

/* In-Composer Voice Recording Bar */
.composer-voice-panel {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 8px 12px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm, 6px);
    animation: voicePanelSlide 0.2s cubic-bezier(0.16, 1, 0.3, 1) both;
}

@keyframes voicePanelSlide {
    from { opacity: 0; transform: scale(0.98) translateY(4px); }
    to { opacity: 1; transform: scale(1) translateY(0); }
}

.voice-recording-info {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 140px;
}

.recording-pulse-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background-color: #ef4444;
    animation: recordingPulse 1.2s infinite ease-in-out;
}

@keyframes recordingPulse {
    0%, 100% { transform: scale(0.85); opacity: 0.5; }
    50% { transform: scale(1.2); opacity: 1; box-shadow: 0 0 10px rgba(239, 68, 68, 0.8); }
}

.recording-label {
    font-size: 13px;
    font-weight: 500;
    color: var(--text);
}

.recording-timer {
    font-family: var(--font-mono);
    font-size: 13px;
    font-weight: 600;
    color: #ef4444;
}

.voice-waveform-preview {
    display: flex;
    align-items: center;
    gap: 3px;
    height: 24px;
    flex: 1;
    justify-content: center;
    max-width: 200px;
}

.voice-bar {
    width: 3px;
    height: 8px;
    background-color: var(--primary, #3b82f6);
    border-radius: 2px;
    animation: voiceBarDance 1s infinite ease-in-out;
}

.voice-bar:nth-child(2) { animation-delay: 0.1s; height: 14px; }
.voice-bar:nth-child(3) { animation-delay: 0.25s; height: 20px; }
.voice-bar:nth-child(4) { animation-delay: 0.05s; height: 12px; }
.voice-bar:nth-child(5) { animation-delay: 0.35s; height: 18px; }
.voice-bar:nth-child(6) { animation-delay: 0.15s; height: 22px; }
.voice-bar:nth-child(7) { animation-delay: 0.4s; height: 16px; }
.voice-bar:nth-child(8) { animation-delay: 0.2s; height: 10px; }
.voice-bar:nth-child(9) { animation-delay: 0.3s; height: 19px; }
.voice-bar:nth-child(10) { animation-delay: 0.12s; height: 15px; }
.voice-bar:nth-child(11) { animation-delay: 0.28s; height: 11px; }
.voice-bar:nth-child(12) { animation-delay: 0.08s; height: 7px; }

@keyframes voiceBarDance {
    0%, 100% { transform: scaleY(0.4); opacity: 0.4; }
    50% { transform: scaleY(1); opacity: 1; }
}

.voice-recording-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.composer-voice-btn {
    color: var(--text-muted);
    transition: color 0.15s ease, transform 0.15s ease;
}

.composer-voice-btn:hover {
    color: var(--primary, #3b82f6);
    transform: scale(1.08);
}

/* Telegram-style Voice Message Player in Chat Bubble */
.att-voice-card {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 12px;
    background: var(--surface-2);
    border: 1px solid var(--border-subtle);
    border-radius: 12px;
    min-width: 240px;
    max-width: 360px;
    margin-top: 4px;
}

.voice-play-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background-color: var(--primary, #3b82f6);
    color: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    cursor: pointer;
    flex-shrink: 0;
    transition: transform 0.15s ease, background-color 0.15s ease;
}

.voice-play-btn:hover {
    transform: scale(1.06);
    background-color: #2563eb;
}

.voice-card-body {
    display: flex;
    flex-direction: column;
    gap: 5px;
    min-width: 0;
    flex: 1;
}

.voice-scrubber-track {
    width: 100%;
    height: 4px;
    background: var(--surface-3);
    border-radius: 2px;
    position: relative;
    cursor: pointer;
    overflow: hidden;
}

.voice-scrubber-fill {
    height: 100%;
    width: 0%;
    background: var(--primary, #3b82f6);
    border-radius: 2px;
    transition: width 0.08s linear;
}

.voice-meta-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 11px;
    font-family: var(--font-mono);
    color: var(--text-muted);
}

.voice-speed-pill {
    padding: 1px 6px;
    border-radius: 4px;
    background: var(--surface-3);
    border: 1px solid var(--border-subtle);
    font-size: 10px;
    cursor: pointer;
    color: var(--text-muted);
    user-select: none;
}

.voice-speed-pill:hover {
    color: var(--text);
    border-color: var(--border);
}

.terms-content {
    line-height: 1.6;
    font-size: 13.5px;
}

.terms-section {
    margin-bottom: 18px;
}

.terms-section h3 {
    font-size: 14px;
    font-weight: 600;
    margin: 0 0 6px 0;
    color: var(--text);
}

.terms-section p {
    margin: 0 0 8px 0;
    color: var(--text-muted);
}

.terms-section ul {
    margin: 0;
    padding-left: 20px;
    color: var(--text-muted);
}

.terms-section li {
    margin-bottom: 6px;
}

.info-box {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 12px;
    background-color: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    margin-bottom: 16px;
}

.info-label {
    font-size: 12px;
    color: var(--muted);
}

.stack-actions {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 16px;
}

/* Modal Backdrop & Panels */
@keyframes modalBackdropFade {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes modalPanelSlide {
    from {
        opacity: 0;
        transform: scale(0.96) translateY(10px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

.modal-backdrop {
    position: fixed;
    inset: 0;
    z-index: 100;
    background-color: var(--backdrop);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    animation: modalBackdropFade 0.2s ease-out both;
}

.modal-panel {
    width: 100%;
    max-height: calc(100dvh - 32px);
    background-color: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: modalPanelSlide 0.22s cubic-bezier(0.16, 1, 0.3, 1) both;
    box-shadow: 0 16px 36px rgba(0, 0, 0, 0.22);
}

.modal-panel-wide {
    max-width: 860px;
    height: min(680px, calc(100dvh - 32px));
}

.modal-panel-sm {
    max-width: 420px;
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.modal-title-group {
    display: flex;
    align-items: center;
    gap: 10px;
}

.modal-title {
    font-size: 16px;
    font-weight: 600;
    letter-spacing: -0.01em;
}

.modal-body {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
}

.modal-footer-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 8px;
}

/* Admin Tabs */
.tab-bar {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 8px 20px;
    border-bottom: 1px solid var(--border);
    background-color: var(--surface-2);
    overflow-x: auto;
    flex-shrink: 0;
}

.tab-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    font-size: 13px;
    font-weight: 500;
    color: var(--muted);
    background: transparent;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    cursor: pointer;
    white-space: nowrap;
    transition: background-color var(--transition), color var(--transition), border-color var(--transition);
}

.tab-btn[aria-selected="true"] {
    background-color: var(--surface);
    color: var(--text);
    border-color: var(--border);
}

.tab-count {
    font-family: var(--font-mono);
    font-size: 11px;
    padding: 1px 6px;
    border-radius: 999px;
    background-color: var(--surface-2);
    border: 1px solid var(--border);
}

/* Admin Panes & Toolbars */
.admin-pane {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.pane-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.pane-toolbar-wrap {
    flex-wrap: wrap;
}

.search-inline {
    flex: 1;
    min-width: 200px;
}

.filter-group {
    display: inline-flex;
    flex-wrap: wrap;
    gap: 4px;
}

.filter-chip {
    padding: 4px 10px;
    font-size: 12px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background-color: var(--surface-2);
    color: var(--muted);
    cursor: pointer;
    transition: background-color var(--transition), color var(--transition), border-color var(--transition);
}

.filter-chip[aria-pressed="true"] {
    background-color: var(--accent);
    color: var(--accent-text);
    border-color: var(--accent);
}

/* Admin Lists & Rows */
.admin-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.admin-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 12px;
    background-color: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    flex-wrap: wrap;
}

.admin-row-main {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 180px;
    flex: 1;
}

.admin-row-title {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    font-weight: 500;
    font-size: 13.5px;
}

.admin-row-sub {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    color: var(--muted);
    font-family: var(--font-mono);
    font-size: 11.5px;
}

.admin-row-actions {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}

.empty-box {
    padding: 28px 16px;
    text-align: center;
    border: 1px dashed var(--border);
    border-radius: var(--radius-sm);
    color: var(--muted);
    font-size: 13px;
}

/* Storage Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 10px;
}

.stat-card {
    padding: 12px 14px;
    background-color: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
}

.stat-label {
    font-size: 11.5px;
    color: var(--muted);
    margin-bottom: 4px;
}

.stat-value {
    font-family: var(--font-mono);
    font-size: 16px;
    font-weight: 600;
}

/* Neutral Toasts */
.toast-container {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 200;
    display: flex;
    flex-direction: column;
    gap: 8px;
    pointer-events: none;
}

.toast {
    padding: 8px 14px;
    background-color: var(--accent);
    color: var(--accent-text);
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 500;
    pointer-events: auto;
}

/* ==========================================================================
   Step 7: Messaging Stream, Markdown, Code Blocks, Reactions & Composer
   ========================================================================== */

.reconnect-banner {
    padding: 6px 14px;
    background-color: var(--surface-2);
    border-bottom: 1px solid var(--border);
    color: var(--muted);
    font-family: var(--font-mono);
    font-size: 12px;
    text-align: center;
    flex-shrink: 0;
}

.history-loader {
    align-self: center;
    padding: 6px 12px;
    margin-bottom: 10px;
    font-size: 12px;
    color: var(--muted);
    background-color: var(--surface);
    border: 1px solid var(--border);
    border-radius: 999px;
}

.chat-messages-list {
    display: flex;
    flex-direction: column;
    gap: 2px;
    margin-top: auto;
}

/* Date & Unread Dividers */
.msg-divider {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 14px 0 8px;
    user-select: none;
}

.msg-divider::before,
.msg-divider::after {
    content: "";
    flex: 1;
    height: 1px;
    background-color: var(--border);
}

.msg-divider-label {
    font-family: var(--font-mono);
    font-size: 11px;
    font-weight: 500;
    color: var(--muted);
    padding: 2px 10px;
    border-radius: 999px;
    background-color: var(--surface);
    border: 1px solid var(--border);
}

.msg-divider-unread .msg-divider-label {
    background-color: var(--accent);
    color: var(--accent-text);
    border-color: var(--accent);
}

/* Telegram-Style Spring Message Appear Animations */
@keyframes msgAppearTelegram {
    0% {
        opacity: 0;
        transform: translateY(12px) scale(0.975);
    }
    65% {
        opacity: 1;
        transform: translateY(-2px) scale(1.006);
    }
    100% {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

@keyframes msgAppearOutgoing {
    0% {
        opacity: 0;
        transform: translateY(12px) translateX(6px) scale(0.975);
    }
    65% {
        opacity: 1;
        transform: translateY(-2px) translateX(-1px) scale(1.006);
    }
    100% {
        opacity: 1;
        transform: translateY(0) translateX(0) scale(1);
    }
}

.msg-row {
    position: relative;
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 6px 10px;
    border-radius: var(--radius-sm);
    transition: background-color var(--transition), transform 0.14s cubic-bezier(0.34, 1.56, 0.64, 1);
    animation: msgAppearTelegram 0.22s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

.msg-row.msg-me {
    animation-name: msgAppearOutgoing;
}

.msg-row.msg-grouped {
    padding-top: 2px;
    padding-bottom: 2px;
}

.msg-row:hover {
    background-color: var(--surface-2);
}

.msg-row.msg-highlight {
    background-color: var(--surface-2);
    outline: 1px solid var(--text);
}

.msg-gutter {
    width: 34px;
    flex-shrink: 0;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding-top: 2px;
}

.msg-hover-time {
    font-family: var(--font-mono);
    font-size: 10px;
    color: var(--muted);
    opacity: 0;
    line-height: 20px;
    user-select: none;
    transition: opacity var(--transition);
}

.msg-row:hover .msg-hover-time {
    opacity: 1;
}

.msg-main {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.msg-header {
    display: flex;
    align-items: baseline;
    gap: 8px;
    flex-wrap: wrap;
}

.msg-sender-name {
    font-size: 13.5px;
    font-weight: 600;
    color: var(--text);
}

.msg-sender-handle {
    font-family: var(--font-mono);
    font-size: 11.5px;
    color: var(--muted);
}

.msg-timestamp {
    font-family: var(--font-mono);
    font-size: 11px;
    color: var(--muted);
}

/* Reply Quote Banner Inside Message */
.msg-reply-quote {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    max-width: 100%;
    padding: 4px 8px;
    margin-bottom: 2px;
    border-left: 2px solid var(--muted);
    background-color: var(--surface);
    border-radius: 0 4px 4px 0;
    font-size: 12px;
    color: var(--muted);
    cursor: pointer;
    text-align: left;
    border-top: none;
    border-right: none;
    border-bottom: none;
    transition: transform 0.12s cubic-bezier(0.34, 1.56, 0.64, 1), background-color var(--transition);
}

.msg-reply-quote:hover {
    color: var(--text);
    border-left-color: var(--text);
    transform: translateX(2px);
}

.msg-reply-sender {
    font-weight: 600;
    color: var(--text);
    white-space: nowrap;
}

.msg-reply-snippet {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Markdown Message Body & Discord Rich Extensions */
.msg-body {
    font-size: 14px;
    line-height: 1.52;
    color: var(--text);
    word-wrap: break-word;
    overflow-wrap: anywhere;
}

.msg-body p {
    margin: 0 0 6px;
}

.msg-body p:last-child {
    margin-bottom: 0;
}

.msg-body ul,
.msg-body ol {
    margin: 4px 0 6px 20px;
}

.msg-body blockquote {
    margin: 6px 0;
    padding: 4px 12px;
    border-left: 4px solid var(--primary, #6366f1);
    background-color: var(--surface-2);
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
    color: var(--muted);
}

.msg-body a {
    color: var(--primary, #38bdf8);
    text-decoration: none;
    transition: text-decoration 0.15s ease;
}

.msg-body a:hover {
    text-decoration: underline;
}

.msg-body code:not(.hljs) {
    font-family: var(--font-mono);
    font-size: 12.5px;
    padding: 1px 5px;
    border-radius: 4px;
    background-color: var(--surface);
    border: 1px solid var(--border);
}

/* Discord Headings in Messages */
.msg-body h1 {
    font-size: 1.35em;
    font-weight: 700;
    margin: 10px 0 4px;
}

.msg-body h2 {
    font-size: 1.2em;
    font-weight: 600;
    margin: 8px 0 4px;
}

.msg-body h3 {
    font-size: 1.05em;
    font-weight: 600;
    margin: 6px 0 2px;
}

/* Discord GFM Tables */
.msg-body table {
    width: 100%;
    border-collapse: collapse;
    margin: 8px 0;
    font-size: 13px;
    border-radius: var(--radius-sm);
    overflow: hidden;
    border: 1px solid var(--border);
}

.msg-body th,
.msg-body td {
    padding: 6px 10px;
    border: 1px solid var(--border);
    text-align: left;
}

.msg-body th {
    background-color: var(--surface-2);
    font-weight: 600;
}

.msg-body tr:nth-child(even) {
    background-color: rgba(255, 255, 255, 0.02);
}

/* Discord Task Lists */
.msg-body input[type="checkbox"] {
    margin-right: 6px;
    accent-color: var(--primary);
    cursor: default;
    vertical-align: middle;
}

/* Discord Spoilers with Click-to-Reveal */
.discord-spoiler {
    background-color: var(--surface-3, rgba(255, 255, 255, 0.14));
    color: transparent;
    border-radius: var(--radius-sm);
    padding: 1px 6px;
    cursor: pointer;
    user-select: none;
    transition: background-color 0.18s ease, color 0.18s ease;
    display: inline-block;
    vertical-align: middle;
    position: relative;
    overflow: hidden;
    min-height: 1.35em;
    min-width: 24px;
}

.discord-spoiler:not(.is-revealed) .spoiler-inner {
    filter: blur(8px);
    opacity: 0;
    pointer-events: none;
}

.discord-spoiler:not(.is-revealed)::after {
    content: "Spoiler";
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 500;
    font-family: var(--font-mono);
    color: var(--muted);
    letter-spacing: 0.04em;
    pointer-events: none;
    background: repeating-linear-gradient(
        45deg,
        rgba(255, 255, 255, 0.03),
        rgba(255, 255, 255, 0.03) 6px,
        rgba(255, 255, 255, 0.07) 6px,
        rgba(255, 255, 255, 0.07) 12px
    );
}

.discord-spoiler.is-revealed {
    background-color: rgba(255, 255, 255, 0.08);
    color: inherit;
    user-select: auto;
}

.discord-spoiler.is-revealed .spoiler-inner {
    filter: none;
    opacity: 1;
    pointer-events: auto;
    animation: spoilerFadeIn 0.22s ease forwards;
}

@keyframes spoilerFadeIn {
    0% { filter: blur(5px); opacity: 0; transform: scale(0.97); }
    100% { filter: blur(0); opacity: 1; transform: scale(1); }
}

/* Discord Underline & Highlight */
.discord-underline {
    text-decoration: underline;
    text-underline-offset: 3px;
    text-decoration-thickness: 1.5px;
}

.discord-subtext {
    display: block;
    font-size: 0.82em;
    color: var(--muted);
    margin-top: 2px;
    line-height: 1.4;
}

.discord-mark {
    background-color: rgba(234, 179, 8, 0.25);
    color: var(--text);
    padding: 1px 4px;
    border-radius: 3px;
    border-bottom: 2px solid #eab308;
}

/* Discord Timestamp Badges */
.discord-timestamp-badge {
    display: inline-flex;
    align-items: center;
    padding: 1px 6px;
    border-radius: var(--radius-sm);
    background-color: var(--surface-2);
    border: 1px solid var(--border);
    font-family: var(--font-mono);
    font-size: 0.85em;
    color: var(--text);
    cursor: help;
    transition: background-color var(--transition);
}

.discord-timestamp-badge:hover {
    background-color: var(--surface);
    border-color: var(--muted);
}

/* User & Channel Mentions */
.mention-pill {
    display: inline-flex;
    align-items: center;
    padding: 0 6px;
    border-radius: var(--radius-sm);
    background-color: rgba(99, 102, 241, 0.15);
    color: var(--primary, #6366f1);
    font-weight: 500;
    font-size: 0.95em;
    transition: background-color var(--transition), transform 0.12s ease;
    cursor: default;
}

.mention-pill:hover {
    background-color: rgba(99, 102, 241, 0.28);
    transform: translateY(-1px);
}

.mention-pill.mention-me {
    background-color: rgba(234, 179, 8, 0.2);
    color: #facc15;
    border: 1px solid rgba(234, 179, 8, 0.4);
    box-shadow: 0 0 8px rgba(234, 179, 8, 0.15);
    font-weight: 600;
}

.channel-pill {
    display: inline-flex;
    align-items: center;
    padding: 0 6px;
    border-radius: var(--radius-sm);
    background-color: var(--surface-2);
    color: var(--muted);
    font-family: var(--font-mono);
    font-size: 0.9em;
    border: 1px solid var(--border);
}

/* Telegram / Discord Big Emoji */
.msg-body.msg-big-emoji p,
.msg-body.msg-big-emoji {
    font-size: 38px !important;
    line-height: 1.25 !important;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    animation: bigEmojiBounce 0.4s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

@keyframes bigEmojiBounce {
    0% { transform: scale(0.4); opacity: 0; }
    60% { transform: scale(1.18); opacity: 1; }
    80% { transform: scale(0.95); }
    100% { transform: scale(1); }
}

.msg-deleted-placeholder {
    font-size: 13px;
    font-style: italic;
    color: var(--muted);
}

/* Meta Footer: (edited) & Read Receipts (✓ / ✓✓ / Seen by N) */
.msg-meta-inline {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin-top: 2px;
    font-family: var(--font-mono);
    font-size: 11px;
    color: var(--muted);
}

.msg-edited-tag {
    color: var(--muted);
}

.msg-receipt {
    color: var(--muted);
}

.msg-receipt[data-read="true"] {
    color: var(--text);
    font-weight: 600;
}

.msg-send-error {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: var(--danger);
}

/* Developer Fenced Code Block Card */
.code-block-card {
    margin: 6px 0;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background-color: var(--surface);
    overflow: hidden;
}

.code-block-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 5px 10px;
    background-color: var(--surface-2);
    border-bottom: 1px solid var(--border);
    font-family: var(--font-mono);
    font-size: 11.5px;
    color: var(--muted);
}

.code-block-actions {
    display: flex;
    align-items: center;
    gap: 6px;
}

.code-action-btn {
    padding: 2px 8px;
    font-family: var(--font-mono);
    font-size: 11px;
    color: var(--text);
    background-color: var(--surface);
    border: 1px solid var(--border);
    border-radius: 4px;
    cursor: pointer;
    transition: border-color var(--transition), background-color var(--transition);
}

.code-action-btn:hover {
    border-color: var(--muted);
}

.code-block-pre {
    margin: 0;
    padding: 10px 12px;
    overflow-x: auto;
    font-family: var(--font-mono);
    font-size: 12.5px;
    line-height: 1.5;
    color: var(--text);
}

.code-block-pre.is-collapsed {
    max-height: 220px;
    overflow-y: hidden;
    position: relative;
}

/* Neutral Monochrome / Grayscale Syntax Highlighting (highlight.js) */
.hljs {
    color: var(--text);
    background: transparent;
}

.hljs-comment,
.hljs-quote {
    color: var(--muted);
    font-style: italic;
}

.hljs-keyword,
.hljs-selector-tag,
.hljs-literal,
.hljs-type,
.hljs-addition {
    color: var(--text);
    font-weight: 600;
}

.hljs-string,
.hljs-regexp,
.hljs-meta .hljs-string {
    color: var(--muted);
}

.hljs-title,
.hljs-section,
.hljs-built_in,
.hljs-name {
    color: var(--text);
    font-weight: 600;
}

.hljs-number,
.hljs-symbol,
.hljs-bullet,
.hljs-variable,
.hljs-template-variable,
.hljs-attr,
.hljs-attribute {
    color: var(--text);
}

.hljs-Emphasis {
    font-style: italic;
}

.hljs-strong {
    font-weight: 600;
}

/* Reactions Bar & Spring Reaction Pills (Telegram-Style) */
.msg-reactions-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 4px;
    margin-top: 4px;
}

@keyframes reactionPop {
    0% { transform: scale(0.68); }
    50% { transform: scale(1.26); }
    75% { transform: scale(0.95); }
    100% { transform: scale(1); }
}

.reaction-pill {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 2px 8px;
    border-radius: 999px;
    font-size: 12px;
    background-color: var(--surface);
    border: 1px solid var(--border);
    color: var(--text);
    cursor: pointer;
    transition: transform 0.14s cubic-bezier(0.34, 1.56, 0.64, 1), border-color var(--transition), background-color var(--transition);
}

.reaction-pill:hover {
    border-color: var(--muted);
    transform: translateY(-2px) scale(1.08);
}

.reaction-pill:active {
    transform: scale(0.92);
}

.reaction-pill[data-just-reacted="true"] {
    animation: reactionPop 0.35s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

.reaction-pill[data-active="true"] {
    background-color: var(--surface-2);
    border-color: var(--text);
    font-weight: 600;
}

.reaction-count {
    font-family: var(--font-mono);
    font-size: 11px;
}

/* ==========================================================================
   Discord & Telegram Modern Message Hover Actions Bar & Context Menu
   ========================================================================== */

/* 1. Sleek Compact Hover Bar (Quick React, Reply, More) */
@keyframes quickBarEntrance {
    0% {
        opacity: 0;
        transform: translateY(4px) scale(0.92);
    }
    100% {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.msg-quick-bar {
    position: absolute;
    top: -14px;
    right: 14px;
    display: none;
    align-items: center;
    gap: 2px;
    padding: 3px 4px;
    background: var(--surface);
    background: color-mix(in srgb, var(--surface) 92%, transparent);
    backdrop-filter: blur(12px) saturate(160%);
    -webkit-backdrop-filter: blur(12px) saturate(160%);
    border: 1px solid var(--border);
    border-radius: 8px;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.25);
    z-index: 15;
    pointer-events: auto;
}

.msg-row:hover .msg-quick-bar,
.msg-row:focus-within .msg-quick-bar,
.msg-quick-bar.is-active {
    display: inline-flex;
    animation: quickBarEntrance 0.14s cubic-bezier(0.16, 1, 0.3, 1) both;
}

.msg-quick-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    padding: 0;
    color: var(--muted);
    background: transparent;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    transition: color 0.12s ease, background-color 0.12s ease, transform 0.12s ease;
}

.msg-quick-btn svg {
    width: 15px;
    height: 15px;
    stroke-width: 2;
}

.msg-quick-btn:hover {
    color: var(--text);
    background-color: var(--surface-2);
    transform: scale(1.12);
}

.msg-quick-btn:active {
    transform: scale(0.92);
}

/* 2. Discord & Telegram Native Right-Click Context Menu */
@keyframes contextMenuPop {
    0% {
        opacity: 0;
        transform: scale(0.92) translateY(-4px);
    }
    100% {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

.msg-context-menu {
    position: fixed;
    z-index: 9999;
    width: 236px;
    background: var(--surface);
    background: color-mix(in srgb, var(--surface) 94%, transparent);
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.55), 0 0 0 1px rgba(255, 255, 255, 0.05);
    padding: 6px;
    transform-origin: top left;
    animation: contextMenuPop 0.15s cubic-bezier(0.16, 1, 0.3, 1) forwards;
    user-select: none;
    -webkit-user-select: none;
}

.context-reactions-strip {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 3px;
    padding: 4px 6px 6px;
}

.context-emoji-slot {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    font-size: 17px;
    background: transparent;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    transition: transform 0.14s cubic-bezier(0.34, 1.56, 0.64, 1), background-color 0.12s ease;
}

.context-emoji-slot:hover {
    transform: scale(1.36) translateY(-3px);
    background-color: var(--surface-2);
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3);
    z-index: 2;
}

.context-emoji-slot:active {
    transform: scale(0.9);
}

.context-divider {
    height: 1px;
    background-color: var(--border);
    margin: 4px 4px;
}

.context-items-list {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.context-item {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    height: 34px;
    padding: 0 10px;
    background: transparent;
    border: none;
    border-radius: 6px;
    color: var(--text);
    font-size: 13px;
    font-weight: 500;
    text-align: left;
    cursor: pointer;
    transition: background-color 0.12s ease, color 0.12s ease;
}

.context-icon {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
    color: var(--muted);
    transition: color 0.12s ease;
}

.context-label {
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.context-hint {
    font-size: 10.5px;
    font-family: var(--font-mono);
    color: var(--muted);
    background: var(--surface-2);
    padding: 1px 5px;
    border-radius: 4px;
    border: 1px solid var(--border);
}

.context-item:hover {
    background-color: var(--surface-2);
    color: var(--text);
}

.context-item:hover .context-icon {
    color: var(--text);
}

.context-item:active {
    transform: scale(0.98);
}

.context-item.is-danger {
    color: #ef4444;
}

.context-item.is-danger .context-icon {
    color: #ef4444;
}

.context-item.is-danger:hover {
    background-color: rgba(239, 68, 68, 0.14);
    color: #f87171;
}

.context-item.is-danger:hover .context-icon {
    color: #f87171;
}

/* Telegram / Mobile Long-Press Message Selection Feedback */
.msg-row.has-context-open {
    background-color: var(--surface-2);
    outline: 1px solid var(--border);
}

/* Floating "New messages ↓" Pill with Spring Bounce */
@keyframes jumpBottomPop {
    0% {
        opacity: 0;
        transform: translateX(-50%) translateY(16px) scale(0.85);
    }
    100% {
        opacity: 1;
        transform: translateX(-50%) translateY(0) scale(1);
    }
}

.jump-bottom-pill {
    position: absolute;
    bottom: 96px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 20;
    padding: 6px 14px;
    border-radius: 999px;
    background-color: var(--accent);
    color: var(--accent-text);
    border: 1px solid var(--accent);
    box-shadow: var(--shadow-md);
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: transform 0.16s cubic-bezier(0.34, 1.56, 0.64, 1), background-color var(--transition), box-shadow 0.16s ease;
}

.jump-bottom-pill:not([hidden]) {
    animation: jumpBottomPop 0.26s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

.jump-bottom-pill:hover {
    transform: translateX(-50%) translateY(-2px) scale(1.05);
    box-shadow: var(--shadow-lg);
}

.jump-bottom-pill:active {
    transform: translateX(-50%) scale(0.95);
}

/* Ephemeral Typing Bar with Telegram 3-Dot Wave Animation */
@keyframes typingBarSlide {
    0% { opacity: 0; transform: translateY(4px); }
    100% { opacity: 1; transform: translateY(0); }
}

.chat-typing-bar {
    min-height: 24px;
    padding: 2px 20px;
    font-size: 12px;
    color: var(--muted);
    flex-shrink: 0;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: opacity 0.2s ease;
}

.chat-typing-bar.is-active {
    animation: typingBarSlide 0.2s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

.telegram-typing-wave {
    display: inline-flex;
    align-items: center;
    gap: 3.5px;
    height: 12px;
}

.telegram-typing-dot {
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background-color: var(--primary, #6366f1);
    animation: telegramDotWave 1.3s infinite ease-in-out both;
}

.telegram-typing-dot:nth-child(1) { animation-delay: -0.32s; }
.telegram-typing-dot:nth-child(2) { animation-delay: -0.16s; }
.telegram-typing-dot:nth-child(3) { animation-delay: 0s; }

@keyframes telegramDotWave {
    0%, 80%, 100% {
        transform: scale(0.6) translateY(0);
        opacity: 0.35;
    }
    40% {
        transform: scale(1.25) translateY(-4px);
        opacity: 1;
    }
}

.telegram-typing-text {
    font-size: 12px;
    color: var(--muted);
}

/* Composer Area */
.chat-composer-wrap {
    padding: 8px 16px 12px;
    background-color: var(--surface);
    border-top: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    gap: 6px;
    flex-shrink: 0;
}

.composer-context-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 5px 10px;
    background-color: var(--surface-2);
    border-left: 2px solid var(--text);
    border-radius: 4px;
    font-size: 12px;
    animation: composerReplySlide 0.18s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

@keyframes composerReplySlide {
    0% { opacity: 0; transform: translateY(-6px); }
    100% { opacity: 1; transform: translateY(0); }
}

.composer-context-main {
    display: flex;
    align-items: center;
    gap: 6px;
    min-width: 0;
    flex: 1;
}

.composer-context-kind {
    font-weight: 600;
    color: var(--text);
    white-space: nowrap;
}

.composer-context-text {
    color: var(--muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.icon-btn-sm {
    width: 24px;
    height: 24px;
}

.chat-composer-form {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.composer-input-row {
    display: flex;
    align-items: flex-end;
    gap: 8px;
}

.composer-textarea {
    flex: 1;
    min-height: 38px;
    max-height: 168px;
    padding: 8px 12px;
    font-family: var(--font-sans);
    font-size: 14px;
    line-height: 1.45;
    color: var(--text);
    background-color: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    resize: none;
    overflow-y: auto;
    transition: border-color var(--transition);
}

.composer-textarea:focus {
    border-color: var(--text);
    outline: none;
}

/* Telegram Send Button Micro-Animation */
@keyframes sendFly {
    0% { transform: scale(0.85) rotate(0deg); }
    40% { transform: scale(1.2) rotate(-8deg); }
    100% { transform: scale(1) rotate(0deg); }
}

.composer-send-btn {
    height: 38px;
    flex-shrink: 0;
    transition: transform 0.16s cubic-bezier(0.34, 1.56, 0.64, 1), background-color var(--transition);
}

.composer-send-btn:hover:not(:disabled) {
    transform: translateY(-1px) scale(1.05);
}

.composer-send-btn:active:not(:disabled) {
    transform: scale(0.92);
}

.composer-send-btn.just-sent {
    animation: sendFly 0.35s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

.composer-footer-hints {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    font-family: var(--font-mono);
    font-size: 11px;
    color: var(--muted);
}

.composer-char-counter[data-warn="true"] {
    color: var(--danger);
    font-weight: 600;
}

/* ==========================================================================
   Step 8: File Sharing, Chunked Upload Tray, Inline Attachments & Previewer
   ========================================================================== */

.chat-drop-overlay {
    position: absolute;
    inset: 12px;
    z-index: 40;
    background-color: var(--backdrop);
    border: 2px dashed var(--text);
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
}

.drop-overlay-card {
    padding: 20px 28px;
    background-color: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    text-align: center;
}

.drop-overlay-title {
    font-size: 15px;
    font-weight: 600;
    color: var(--text);
}

.composer-attach-btn {
    width: 38px;
    height: 38px;
    padding: 0;
    flex-shrink: 0;
}

/* Composer Upload Queue Tray */
.composer-upload-tray {
    display: flex;
    flex-direction: column;
    gap: 6px;
    max-height: 180px;
    overflow-y: auto;
    padding: 6px;
    background-color: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
}

.upload-queue-item {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 6px 10px;
    background-color: var(--surface);
    border: 1px solid var(--border);
    border-radius: 6px;
}

.upload-queue-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.upload-queue-name {
    font-size: 12.5px;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1;
}

.upload-queue-stats {
    font-family: var(--font-mono);
    font-size: 11px;
    color: var(--muted);
    white-space: nowrap;
}

.upload-queue-actions {
    display: flex;
    align-items: center;
    gap: 4px;
}

.upload-progress-track {
    width: 100%;
    height: 4px;
    background-color: var(--surface-2);
    border-radius: 999px;
    overflow: hidden;
}

.upload-progress-fill {
    height: 100%;
    background-color: var(--text);
    transition: width 120ms linear;
}

/* Message Attachments Rendering */
.msg-attachments-stack {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 4px;
    max-width: 540px;
}

.att-image-card {
    display: inline-flex;
    flex-direction: column;
    max-width: 340px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background-color: var(--surface);
    overflow: hidden;
}

.att-image-thumb {
    display: block;
    max-width: 340px;
    max-height: 260px;
    width: auto;
    height: auto;
    object-fit: contain;
    background-color: var(--surface-2);
    cursor: zoom-in;
}

.att-media-caption {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 6px 10px;
    border-top: 1px solid var(--border);
    font-size: 11.5px;
    color: var(--muted);
}

.att-video-card {
    display: flex;
    flex-direction: column;
    max-width: 440px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background-color: var(--surface);
    overflow: hidden;
}

.att-video-player {
    width: 100%;
    max-height: 300px;
    background-color: #000000;
    display: block;
}

.att-audio-card {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 10px 12px;
    max-width: 420px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background-color: var(--surface);
}

.att-audio-player {
    width: 100%;
    height: 34px;
}

.att-file-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background-color: var(--surface);
}

.att-file-left {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
    flex: 1;
}

.att-ext-badge {
    min-width: 40px;
    height: 34px;
    padding: 0 6px;
    border-radius: 6px;
    background-color: var(--surface-2);
    border: 1px solid var(--border);
    font-family: var(--font-mono);
    font-size: 10.5px;
    font-weight: 600;
    color: var(--text);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-transform: uppercase;
    flex-shrink: 0;
}

.att-file-meta {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.att-file-name {
    font-size: 13px;
    font-weight: 500;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.att-file-sub {
    font-family: var(--font-mono);
    font-size: 11px;
    color: var(--muted);
}

.att-file-actions {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}

/* Universal Developer File Preview Modal */
.modal-panel-preview {
    max-width: 980px;
    height: min(780px, calc(100dvh - 32px));
}

.preview-header-meta {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.preview-header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.preview-modal-body {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 16px;
    background-color: var(--bg);
    flex: 1;
    min-height: 0;
    overflow: hidden;
}

.preview-truncation-banner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 8px 12px;
    background-color: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-family: var(--font-mono);
    font-size: 12px;
    color: var(--muted);
    flex-shrink: 0;
}

.preview-lightbox-stage {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    overflow: auto;
    padding: 12px;
    background-color: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
}

.preview-lightbox-img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    transition: transform var(--transition);
    cursor: zoom-in;
}

.preview-lightbox-img[data-zoomed="true"] {
    max-width: none;
    max-height: none;
    cursor: zoom-out;
}

/* PDF Preview Container & Native Iframe */
.preview-pdf-container {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
    width: 100%;
    height: 100%;
}

.preview-pdf-notice {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 8px;
    padding: 8px 12px;
    background-color: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 12px;
    color: var(--muted);
    flex-shrink: 0;
}

.preview-pdf-frame {
    flex: 1;
    min-height: 480px;
    width: 100%;
    height: 100%;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background-color: var(--surface);
}

/* Video & Audio Preview Stages */
.preview-media-stage {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 16px;
    padding: 24px;
    background-color: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    overflow: auto;
}

.preview-video-player {
    max-width: 100%;
    max-height: 100%;
    border-radius: var(--radius-sm);
    background-color: #000;
    box-shadow: var(--shadow-md);
}

.preview-audio-stage {
    min-height: 240px;
}

.preview-audio-icon {
    color: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    width: 72px;
    height: 72px;
    border-radius: 50%;
    background-color: var(--surface-2);
    border: 1px solid var(--border);
}

.preview-audio-player {
    width: 100%;
    max-width: 480px;
}

/* Rendered Markdown */
.preview-markdown-rendered {
    flex: 1;
    min-height: 0;
    overflow: auto;
    padding: 20px;
    background-color: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-family: var(--font-sans);
    font-size: 14px;
    line-height: 1.6;
    color: var(--text);
}

.preview-markdown-rendered h1,
.preview-markdown-rendered h2,
.preview-markdown-rendered h3 {
    margin-top: 1.25em;
    margin-bottom: 0.5em;
    font-weight: 600;
}

.preview-markdown-rendered p {
    margin-bottom: 1em;
}

.preview-markdown-rendered code {
    font-family: var(--font-mono);
    font-size: 0.9em;
    padding: 2px 6px;
    background-color: var(--surface-2);
    border-radius: var(--radius-sm);
}

.preview-markdown-rendered pre {
    background-color: var(--surface-2);
    padding: 12px;
    border-radius: var(--radius-sm);
    overflow-x: auto;
    margin: 1em 0;
}

/* Fallback Card for Non-Previewable / Binary Files */
.preview-fallback-card {
    flex: 1;
    min-height: 280px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    gap: 12px;
    padding: 32px 16px;
    background-color: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
}

.preview-fallback-icon {
    font-family: var(--font-mono);
    font-size: 14px;
    font-weight: 700;
    color: var(--primary);
    background-color: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 8px 16px;
    letter-spacing: 0.05em;
}

.preview-fallback-name {
    font-size: 16px;
    font-weight: 600;
    color: var(--text);
    margin: 0;
    word-break: break-all;
}

.preview-fallback-meta {
    font-family: var(--font-mono);
    font-size: 12px;
    color: var(--muted);
    margin: 0;
}

.preview-fallback-desc {
    max-width: 440px;
    font-size: 13px;
    color: var(--muted);
    margin: 0 0 8px 0;
    line-height: 1.5;
}

/* Line-Numbered Code & Text Preview */
.preview-code-wrap {
    flex: 1;
    min-height: 0;
    overflow: auto;
    background-color: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
}

.preview-code-wrap.wrap-lines .preview-code-line {
    white-space: pre-wrap;
    word-break: break-all;
}

.preview-code-table {
    width: 100%;
    border-collapse: collapse;
    font-family: var(--font-mono);
    font-size: 12.5px;
    line-height: 1.5;
}

.preview-code-ln {
    width: 48px;
    padding: 0 10px;
    text-align: right;
    color: var(--muted);
    user-select: none;
    border-right: 1px solid var(--border);
    background-color: var(--surface-2);
    vertical-align: top;
}

.preview-code-line {
    padding: 0 12px;
    white-space: pre;
    color: var(--text);
    vertical-align: top;
}

/* Collapsible JSON Tree View (DOM-built) */
.preview-json-tree {
    flex: 1;
    overflow: auto;
    padding: 14px;
    background-color: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-family: var(--font-mono);
    font-size: 12.5px;
    line-height: 1.55;
}

.json-branch {
    margin-left: 16px;
    border-left: 1px solid var(--border);
    padding-left: 10px;
}

.json-toggle-btn {
    background: transparent;
    border: none;
    color: var(--text);
    font-family: var(--font-mono);
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    padding: 1px 4px;
}

.json-key {
    color: var(--text);
    font-weight: 600;
}

.json-val-str {
    color: var(--muted);
}

.json-val-primitive {
    color: var(--text);
}

/* CSV / TSV Sticky-Header Table View */
.preview-csv-wrap {
    flex: 1;
    overflow: auto;
    background-color: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
}

.preview-csv-table {
    width: 100%;
    border-collapse: collapse;
    font-family: var(--font-mono);
    font-size: 12px;
}

.preview-csv-table th,
.preview-csv-table td {
    padding: 6px 10px;
    border: 1px solid var(--border);
    text-align: left;
    white-space: nowrap;
}

.preview-csv-table th {
    position: sticky;
    top: 0;
    background-color: var(--surface-2);
    color: var(--text);
    font-weight: 600;
    z-index: 2;
}

/* Shared Media Grid in Info Panel */
.shared-media-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 6px;
}

.shared-media-thumb {
    aspect-ratio: 1 / 1;
    width: 100%;
    object-fit: cover;
    border-radius: 4px;
    border: 1px solid var(--border);
    background-color: var(--surface-2);
    cursor: pointer;
}

/* ==========================================================================
   Step 9: Search Modal, Quick Switcher (Ctrl/Cmd+K), Skeletons & Mobile Polish
   ========================================================================== */

.sidebar-search-row {
    display: flex;
    align-items: center;
    gap: 6px;
}

.sidebar-search-row .text-input {
    flex: 1;
    min-width: 0;
}

.search-modal-body {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.search-controls-stack {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.search-filters-row {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
}

.search-sender-wrap {
    width: 170px;
}

.search-results-list {
    flex: 1;
    overflow-y: auto;
}

.search-result-card {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 10px 12px;
    background-color: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    cursor: pointer;
    text-align: left;
    transition: border-color var(--transition), background-color var(--transition);
}

.search-result-card:hover {
    border-color: var(--text);
    background-color: var(--surface-2);
}

.search-result-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    flex-wrap: wrap;
}

.search-result-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12.5px;
}

.search-result-conv {
    font-weight: 600;
    color: var(--text);
}

.search-result-sender {
    color: var(--muted);
}

.search-result-snippet {
    font-size: 13px;
    color: var(--text);
    line-height: 1.45;
    word-break: break-word;
}

/* Quick Switcher List & Active Keyboard Selection */
.quick-switcher-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    width: 100%;
    padding: 8px 10px;
    background-color: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    cursor: pointer;
    text-align: left;
    color: var(--text);
    transition: background-color var(--transition), border-color var(--transition);
}

.quick-switcher-item:hover,
.quick-switcher-item[data-active="true"] {
    background-color: var(--surface-2);
    border-color: var(--text);
}

/* Neutral Static Skeletons (No Shimmer / Gradients) */
.skeleton-stack {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.skeleton-row {
    height: 48px;
    border-radius: var(--radius-sm);
    background-color: var(--surface-2);
    border: 1px solid var(--border);
}

/* Help Modal & Shortcuts Layout */
.help-kbd-chip {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 7px 10px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 12.5px;
    color: var(--text);
}

.help-kbd-chip kbd {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 2px 6px;
    font-family: var(--font-mono);
    font-size: 11px;
    font-weight: 600;
    color: var(--text);
    box-shadow: 0 1px 1px rgba(0,0,0,0.06);
}

.composer-footer-hints:empty {
    display: none;
}

/* Tasteful Micro-Animations & Status Transitions */
@keyframes badgePop {
    0% { transform: scale(0.7); opacity: 0; }
    100% { transform: scale(1); opacity: 1; }
}

.status-pill, .dot-badge {
    animation: badgePop 0.2s cubic-bezier(0.16, 1, 0.3, 1) both;
}

@keyframes toastSlide {
    from {
        opacity: 0;
        transform: translateY(-12px) scale(0.96);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.toast {
    animation: toastSlide 0.22s cubic-bezier(0.16, 1, 0.3, 1) both;
}

/* Mobile Responsive & Touch Target Polish (>= 40px targets + safe-area insets) */
@media (max-width: 767px) {
    .btn,
    .icon-btn,
    .conv-item,
    .quick-switcher-item {
        min-height: 40px;
    }

    .chat-header {
        padding: 0 10px;
        gap: 6px;
    }

    .chat-header-actions .header-btn-text {
        display: none;
    }

    .chat-header-actions {
        gap: 4px;
    }

    .chat-header-actions .btn-sm {
        padding: 6px 8px;
        min-width: 32px;
    }

    .chat-header-left {
        gap: 8px;
        min-width: 0;
    }

    .chat-title {
        font-size: 14px;
        max-width: 140px;
    }

    #chat-header-enc-pill {
        font-size: 10px;
        padding: 1px 5px;
    }

    .chat-composer-wrap {
        padding: 6px 10px 10px;
        padding-bottom: calc(10px + env(safe-area-inset-bottom, 0px));
    }

    .composer-textarea {
        font-size: 14px;
        padding: 8px 10px;
    }

    .sidebar-footer {
        padding-bottom: env(safe-area-inset-bottom, 0px);
        height: calc(56px + env(safe-area-inset-bottom, 0px));
    }

    .modal-panel {
        max-height: calc(100dvh - 20px);
        margin: 8px;
        width: 100%;
    }

    .modal-panel-wide,
    .modal-panel-md,
    .modal-panel-sm {
        max-width: 100%;
    }

    .modal-body {
        padding: 16px;
    }
}
