@import url('https://fonts.googleapis.com/css2?family=DM+Sans:wght@400;500;600;700&family=Space+Grotesk:wght@500;600;700&display=swap');

:root {
    --background: #08080f;
    --surface: #0f0f1a;
    --surface-secondary: #16162a;
    --surface-hover: rgba(126, 75, 243, 0.12);
    --text: #f0f0ff;
    --text-muted: #8888aa;
    --accent: #7e4bf3;
    --accent-hover: #9060ff;
    --accent-soft: rgba(126, 75, 243, 0.15);
    --border: rgba(126, 75, 243, 0.22);
    --error: #f05050;
    --success: #3dd68c;
    --glass-bg: rgba(15, 15, 26, 0.88);
    --input-bg: #16162a;
    --card-bg: #16162a;
    --shadow: 0 8px 32px rgba(0, 0, 0, 0.45);
    --bg-lighter: #1e1e30;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    scrollbar-width: thin;
    scrollbar-color: rgba(140, 82, 255, 0.4) rgba(10, 10, 20, 0.4);
}

/* Custom In-App Scrollbars */
::-webkit-scrollbar {
    width: 7px;
    height: 7px;
}

::-webkit-scrollbar-track {
    background: rgba(10, 10, 18, 0.4);
    border-radius: 999px;
}

::-webkit-scrollbar-thumb {
    background: rgba(140, 82, 255, 0.35);
    border-radius: 999px;
    border: 2px solid transparent;
    background-clip: padding-box;
    transition: background 0.2s ease;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(168, 85, 247, 0.75);
    border: 2px solid transparent;
    background-clip: padding-box;
    box-shadow: 0 0 10px rgba(168, 85, 247, 0.5);
}

::-webkit-scrollbar-corner {
    background: transparent;
}

/* Custom Text Selection */
::selection {
    background: rgba(140, 82, 255, 0.45);
    color: #ffffff;
    text-shadow: 0 0 8px rgba(168, 85, 247, 0.6);
}
::-moz-selection {
    background: rgba(140, 82, 255, 0.45);
    color: #ffffff;
    text-shadow: 0 0 8px rgba(168, 85, 247, 0.6);
}

/* Custom Focus Rings */
:focus-visible {
    outline: 2px solid rgba(168, 85, 247, 0.6) !important;
    outline-offset: 2px !important;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background-color: var(--background);
    color: var(--text);
    height: 100dvh;
    height: var(--app-vh, 100dvh); /* kept equal to the visible area by modules/viewport-fit.js */
    overflow: auto;
    transition: background-color 0.3s ease;
}

/* Lock scroll only when main chat view is active */
body.app-active {
    overflow: hidden;
}

#app {
    height: 100%;
}

.view {
    height: 100%;
    width: 100%;
}

/* Glassmorphism Classes */
.glass-panel {
    background: var(--surface);
    border: 1px solid var(--border);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}
.glass-panel-sidebar {
    background: var(--surface);
    border-right: 1px solid var(--border);
}
.glass-panel-header, .glass-panel-composer {
    background: var(--surface);
    border-color: var(--border);
}

/* Animations */
.fade-in {
    animation: fadeIn 0.3s ease-in-out;
}
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}
.slide-up {
    animation: slideUp 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}
@keyframes slideUp {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Utilities */
.w-100 { width: 100%; }
.mt-2 { margin-top: 0.5rem; }
.mt-3 { margin-top: 1rem; }
.mb-2 { margin-bottom: 0.5rem; }
.mb-3 { margin-bottom: 1rem; }
.mb-4 { margin-bottom: 1.5rem; }
.text-center { text-align: center; }
.text-danger { color: var(--error) !important; }
.text-success { color: #10b981; }
.d-block { display: block; }

/* Auth Layout */
#auth-view {
    display: flex;
    align-items: center;
    justify-content: center;
    overflow-y: auto;
    padding: 2.5rem 1rem;
    background: var(--background);
}

.auth-card {
    padding: 2rem;
    border-radius: 14px;
    width: 100%;
    max-width: 410px;
    text-align: left;
    margin: auto;
}

.auth-brand {
    text-align: center;
    margin-bottom: 2rem;
}

.auth-logo {
    width: 64px;
    height: 64px;
    object-fit: cover;
    border-radius: 16px;
    display: block;
    margin: 0 auto 1.25rem;
    box-shadow: 0 0 0 1px rgba(255,255,255,0.08);
}

.auth-brand h1 {
    font-size: 1.75rem;
    line-height: 1.2;
    margin: 0;
    font-weight: 700;
    letter-spacing: -0.02em;
}

.auth-brand p {
    margin-top: 0.5rem;
    color: var(--text-muted);
    font-size: 0.95rem;
}

form {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.auth-card form label {
    color: var(--text);
    font-size: 0.85rem;
    font-weight: 600;
    margin-bottom: -0.6rem;
}

.field-help {
    color: var(--text-muted);
    font-size: 0.75rem;
    line-height: 1.45;
    margin: -0.35rem 0 0;
}

.registration-success {
    text-align: center;
}

.registration-success[hidden] {
    display: none;
}

.success-mark {
    width: 3rem;
    height: 3rem;
    margin: 0 auto 1rem;
    border: 1px solid var(--accent);
    border-radius: 50%;
    color: var(--accent);
    display: grid;
    place-items: center;
    font-size: 1.5rem;
}

.registration-success h2 {
    font-size: 1.2rem;
}

.registration-success p {
    color: var(--text-muted);
    margin: 0.5rem 0 1.5rem;
}

input[type="email"], input[type="text"], input[type="password"] {
    padding: 0.75rem 0.875rem;
    border-radius: 9px;
    border: 1px solid var(--border);
    background-color: var(--input-bg, var(--surface-secondary));
    color: var(--text);
    width: 100%;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
}

textarea {
    padding: 0.75rem 0.875rem;
    border-radius: 9px;
    border: 1px solid var(--border);
    background-color: var(--surface-secondary);
    color: var(--text);
    width: 100%;
    min-height: 92px;
    resize: vertical;
    font: inherit;
    outline: none;
}

textarea:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 2px rgba(155, 108, 255, 0.22);
}

input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.3);
}

.password-wrapper {
    position: relative;
    width: 100%;
}

.toggle-password {
    position: absolute;
    right: 0.5rem;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 0.85rem;
    padding: 0.25rem;
}

.toggle-password:hover {
    color: var(--text);
}

/* Buttons */
.btn-primary {
    padding: 0.75rem;
    border-radius: 8px;
    border: none;
    background-color: var(--accent);
    color: white;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}
.btn-primary:hover {
    background-color: var(--accent-hover);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.4);
}
.btn-primary:active {
    transform: translateY(0);
}

.btn-secondary {
    padding: 0.75rem;
    border-radius: 8px;
    border: 1px solid var(--border);
    background-color: var(--surface-secondary);
    color: var(--text);
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.2s;
}
.btn-secondary:hover {
    background-color: rgba(255, 255, 255, 0.1);
}

.btn-danger {
    background-color: var(--error);
}
.btn-danger:hover {
    background-color: #dc2626;
    box-shadow: 0 4px 12px rgba(239, 68, 68, 0.4);
}

.btn-icon {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.25rem;
    cursor: pointer;
    padding: 0.5rem;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}
.btn-icon:hover {
    background-color: var(--surface-secondary);
    color: var(--text);
}

.auth-card p {
    margin-top: 1.5rem;
    font-size: 0.9rem;
}

.auth-switch {
    text-align: center;
}

#forgot-access-wrap {
    margin-top: 0.5rem;
}

/* Device account recovery */
.ip-recovery[hidden] {
    display: none;
}

.recovery-heading {
    font-size: 1rem;
    margin: 0.75rem 0;
}

.ip-recovery h3 {
    font-size: 0.95rem;
    margin: 0.75rem 0;
}
.ip-recovery-copy {
    color: var(--text-muted);
    font-size: 0.88rem;
    line-height: 1.5;
    margin: 0.25rem 0 1rem;
}

.ip-recovery-list {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
    max-height: 320px;
    overflow-y: auto;
    margin-bottom: 1rem;
}

.ip-recovery-loading {
    color: var(--text-muted);
    font-size: 0.88rem;
    line-height: 1.5;
    text-align: center;
    padding: 1rem 0;
}

.ip-recovery-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    width: 100%;
    padding: 0.7rem 0.8rem;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: var(--surface-secondary);
    color: var(--text);
    text-align: left;
    font: inherit;
    cursor: pointer;
    transition: border-color 0.2s, background 0.2s, transform 0.2s;
}

.ip-recovery-item:hover:not(:disabled),
.ip-recovery-item:focus-visible:not(:disabled) {
    border-color: var(--accent);
    background: rgba(140, 82, 255, 0.12);
    transform: translateY(-1px);
}

.ip-recovery-item:disabled {
    opacity: 0.6;
    cursor: wait;
}

.ip-recovery-item img {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
}

.ip-recovery-item-info {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.ip-recovery-item-name {
    font-weight: 600;
    font-size: 0.92rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.ip-recovery-item-meta {
    font-size: 0.76rem;
    color: var(--text-muted);
}

.ip-recovery-item-action {
    margin-left: auto;
    flex-shrink: 0;
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--accent);
}

.ip-recovery-status {
    color: var(--text-muted);
    font-size: 0.85rem;
    text-align: center;
    margin-bottom: 0.75rem;
}

.ip-recovery-status[hidden] {
    display: none;
}

.ip-recovery-status.is-error {
    color: var(--error);
}

#ip-recovery-back {
    margin-top: 0.5rem;
}

/* Quick "sign in as" picker on the main login form (device-linked accounts only; password still required) */
.device-accounts {
    margin-bottom: 1rem;
}

.device-accounts[hidden] {
    display: none;
}

.device-accounts-support {
    margin-top: 0.6rem;
    text-align: center;
}

.invite-connect-option {
    display: flex;
    align-items: flex-start;
    gap: 0.7rem;
    text-align: left;
    padding: 0.8rem;
    margin-bottom: 1.25rem;
    border: 1px solid var(--border);
    border-radius: 9px;
    background: rgba(22, 22, 45, 0.52);
    cursor: pointer;
}

.invite-choice-help {
    color: var(--text-muted);
    font-size: 0.8rem;
    line-height: 1.45;
    margin: -0.5rem 0 0.9rem;
}

.invite-connect-option input {
    width: 1rem;
    height: 1rem;
    accent-color: var(--accent);
    margin-top: 0.15rem;
    flex: 0 0 auto;
}

.invite-connect-option strong,
.invite-connect-option small {
    display: block;
}

.invite-connect-option strong {
    font-size: 0.88rem;
}

.invite-connect-option small {
    color: var(--text-muted);
    font-size: 0.78rem;
    margin-top: 0.2rem;
}

.auth-card a {
    color: var(--accent);
    text-decoration: none;
    transition: color 0.2s;
}

.auth-card a:hover {
    color: var(--accent-hover);
    text-decoration: underline;
}

.error {
    color: var(--error);
    margin-top: 1rem;
    font-size: 0.9rem;
    min-height: 1.2rem;
}

/* Main Layout */
#main-view {
    display: flex;
}

.sidebar {
    width: 300px;
    display: flex;
    flex-direction: column;
}

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

.sidebar-title {
    font-weight: 700;
    font-size: 1.1rem;
}

.dm-list {
    flex: 1;
    overflow-y: auto;
    /* Only show scrollbar when the list is actually scrollable / being hovered */
    scrollbar-gutter: auto;
}
/* Hide scrollbar track on dm-list when content fits */
.dm-list:not(:hover):not(:focus-within) {
    scrollbar-color: transparent transparent;
}
.dm-list:not(:hover):not(:focus-within)::-webkit-scrollbar-thumb {
    background: transparent !important;
    box-shadow: none !important;
}
.dm-list:not(:hover):not(:focus-within)::-webkit-scrollbar-track {
    background: transparent !important;
}

.dm-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem;
    cursor: pointer;
    border-bottom: 1px solid var(--border);
    transition: background-color 0.2s, padding-left 0.2s;
}

.dm-item:hover {
    background-color: var(--surface-secondary);
    padding-left: 1.2rem;
}

.dm-item.active {
    background-color: rgba(155, 108, 255, 0.1);
    border-left: 4px solid var(--accent);
    padding-left: calc(1rem - 4px);
}

.dm-item img {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    object-fit: cover;
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}

.dm-info {
    flex: 1;
    overflow: hidden;
}

.dm-actions {
    display: flex;
    align-items: center;
    gap: 0.3rem;
    flex-shrink: 0;
}

.unread-badge {
    min-width: 1.3rem;
    height: 1.3rem;
    padding: 0 0.35rem;
    display: grid;
    place-items: center;
    border-radius: 999px;
    background: var(--accent);
    color: #100b1c;
    font-size: 0.7rem;
    font-weight: 700;
}

.conversation-pin {
    border: 0;
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 1.1rem;
    line-height: 1;
    padding: 0.25rem;
}

.conversation-pin:hover,
.conversation-pin.is-pinned {
    color: var(--accent);
}

.dm-info h4 {
    margin: 0;
    font-size: 0.95rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.dm-info p {
    margin: 0;
    font-size: 0.8rem;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-footer {
    padding: 1rem;
    border-top: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    background-color: var(--surface);
}

.user-profile {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.user-profile img {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    object-fit: cover;
}

.user-profile span {
    font-weight: 600;
    font-size: 0.9rem;
}

.sidebar-options-wrapper {
    position: relative;
}

.dropdown-menu {
    position: absolute;
    bottom: 120%;
    right: 0;
    background-color: var(--surface);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--border);
    border-radius: 8px;
    box-shadow: 0 -4px 16px rgba(0,0,0,0.3);
    min-width: 150px;
    z-index: 100;
    overflow: hidden;
}

.dropdown-item {
    padding: 0.75rem 1rem;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 500;
    transition: background-color 0.2s;
}

.dropdown-item:hover {
    background-color: var(--surface-secondary);
}

.chat-area {
    flex: 1;
    background: var(--background);
    display: flex;
    flex-direction: row; /* Allow sidebar side-by-side */
    overflow: hidden;
    min-height: 0;
}

.chat-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    height: 100%;
    min-width: 0;
    min-height: 0;
}

.search-sidebar {
    width: 320px;
    border-left: 1px solid var(--border);
    display: flex;
    flex-direction: column;
}

.search-sidebar-header {
    padding: 1rem 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border);
}

.search-sidebar-input-container {
    padding: 1rem;
    border-bottom: 1px solid var(--border);
}

.search-filter-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
    margin-top: 0.65rem;
}

.search-chip {
    border: 1px solid var(--border);
    background: transparent;
    color: var(--text-muted);
    border-radius: 999px;
    padding: 0.3rem 0.55rem;
    font-size: 0.72rem;
    cursor: pointer;
}

.search-chip:hover {
    color: var(--text);
    border-color: var(--accent);
}

.search-results-container {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

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

.empty-glass {
    padding: 1rem 2rem;
    background: var(--surface-secondary);
    backdrop-filter: blur(10px);
    border-radius: 20px;
    border: 1px solid var(--border);
    color: var(--text-muted);
}

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

.chat-header img {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    object-fit: cover;
}

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

.chat-header-info span:first-child {
    font-weight: 600;
    font-size: 1.1rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-header-info span:last-child {
    font-size: 0.85rem;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-search-container {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.chat-search-container input {
    width: 200px;
    padding: 0.5rem 1rem;
    border-radius: 20px;
}

.messages {
    flex: 1 1 0%;
    min-height: 0;
    padding: 1.5rem;
    overflow-y: auto;
    overflow-x: hidden;
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

/* Indicator shown while older history is being fetched */
.older-messages-loader {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.4rem 0;
    color: var(--text-muted);
    font-size: 0.82rem;
}

.older-messages-spinner {
    width: 14px;
    height: 14px;
    flex-shrink: 0;
    border-radius: 50%;
    border: 2px solid var(--border);
    border-top-color: var(--accent);
    animation: olderMessagesSpin 0.8s linear infinite;
}

@keyframes olderMessagesSpin {
    to { transform: rotate(360deg); }
}

.message {
    display: flex;
    flex-direction: column;
    max-width: 75%;
    min-width: 0;
    position: relative;
    padding-right: 2rem; /* space for the ... button */
    animation: fadeIn 0.3s ease-out;
}

.message.sent {
    align-self: flex-end;
    align-items: flex-end;
    padding-right: 0;
    padding-left: 2rem;
}

.message.received {
    align-self: flex-start;
}

.message-actions-btn {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: var(--surface-secondary);
    border: 1px solid var(--border);
    color: var(--text-muted);
    border-radius: 50%;
    width: 28px;
    height: 28px;
    display: none;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.2s, color 0.2s;
    z-index: 10;
}
.message-actions-btn:hover {
    background: var(--surface);
    color: var(--text);
}

.message:hover .message-actions-btn {
    display: flex;
}

.message.received .message-actions-btn {
    right: 0;
}

.message.sent .message-actions-btn {
    left: 0;
}

.message-sender {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-bottom: 0.3rem;
    margin-left: 0.5rem;
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.message-pfp {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    object-fit: cover;
}

.message-display-name {
    font-weight: 500;
    color: var(--text);
}

.profile-link {
    border: 0;
    padding: 0;
    background: transparent;
    color: inherit;
    font: inherit;
    cursor: pointer;
    text-align: left;
}

.profile-link:hover {
    color: var(--accent);
    text-decoration: underline;
}

.dm-profile-name {
    display: block;
    max-width: 100%;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.profile-handle-link {
    color: var(--text-muted);
    font-size: 0.85rem;
}

.profile-modal-content {
    max-width: 380px;
    text-align: center;
    position: relative;
}

.profile-modal-close {
    position: absolute;
    top: 0.75rem;
    right: 0.75rem;
}

.profile-modal-picture {
    width: 92px;
    height: 92px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid var(--accent);
    margin: 0 auto 1rem;
    display: block;
}

.profile-modal-handle {
    border: 0;
    background: transparent;
    color: var(--accent);
    cursor: pointer;
    font-size: 0.9rem;
}

.profile-modal-pronouns {
    color: var(--text-muted);
    font-size: 0.82rem;
    margin-top: 0.75rem;
}

.profile-modal-bio {
    color: var(--text);
    line-height: 1.5;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    margin: 0.8rem 0 1.25rem;
}

.profile-modal-actions {
    display: flex;
    gap: 0.6rem;
}

.profile-modal-message,
.profile-loading {
    color: var(--text-muted);
    font-size: 0.82rem;
    margin-top: 0.75rem;
}

/* Developer badge tag shown on profile modal */
.profile-dev-badge-tag {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    background: var(--surface-secondary);
    border: 1px solid var(--border);
    color: var(--text);
    font-size: 0.78rem;
    font-weight: 600;
    padding: 0.35rem 0.85rem;
    border-radius: 999px;
    margin: 0.5rem auto 0.6rem;
    cursor: pointer;
    letter-spacing: 0.01em;
    box-shadow: none;
    transition: background 0.2s ease, border-color 0.2s ease, transform 0.15s ease;
}
.profile-dev-badge-tag svg {
    color: var(--accent);
    stroke: var(--accent);
}
.profile-dev-badge-tag:hover {
    background: rgba(155, 108, 255, 0.12);
    border-color: var(--accent);
    color: var(--text);
    box-shadow: none;
    transform: translateY(-1px);
}

.chat-readonly-notice {
    padding: 0.55rem 1rem;
    border-bottom: 1px solid rgba(239, 68, 68, 0.3);
    background: rgba(239, 68, 68, 0.08);
    color: #fca5a5;
    font-size: 0.8rem;
    text-align: center;
}

.chat-readonly-notice[hidden] {
    display: none;
}

.message-handle {
    font-size: 0.7rem;
    color: rgba(255,255,255,0.4);
}

.sent-sender .message-timestamp {
    margin-right: 0.2rem;
}
.sent-sender .message-handle {
    margin-right: 0.2rem;
}

.message-timestamp {
    font-size: 0.7rem;
    color: rgba(255,255,255,0.4);
}

.message-bubble {
    background: var(--surface-secondary);
    padding: 0.75rem 1rem;
    border-radius: 12px;
    border-top-left-radius: 4px;
    border: 1px solid var(--border);
    word-break: break-word;
    overflow-wrap: anywhere;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    line-height: 1.4;
    position: relative;
    max-width: 100%;
    overflow-x: hidden;
}

.message-bubble a {
    color: #60a5fa;
    text-decoration: underline;
    text-underline-offset: 2px;
    word-break: break-all;
    overflow-wrap: anywhere;
    transition: color 0.15s ease;
}

.message-bubble a:hover {
    color: #93c5fd;
}

.message.received .message-bubble {
    border-top-left-radius: 4px;
}

.message.sent .message-bubble {
    background: #51319a;
    color: white;
    border: none;
    border-top-right-radius: 4px;
}

.message.sent .message-bubble a {
    color: #a5f3fc;
    text-decoration: underline;
    text-underline-offset: 2px;
}

.message.sent .message-bubble a:hover {
    color: #ffffff;
}

.message-edited {
    font-size: 0.7rem;
    color: rgba(255,255,255,0.7);
    margin-left: 0.5rem;
}

.message.received .message-edited {
    color: var(--text-muted);
}

.message-deleted {
    font-style: italic;
    color: var(--text-muted);
    opacity: 0.7;
}

/* ── Read Receipts ─────────────────────────────────── */

.msg-receipt-inline-icon {
    width: 14px;
    height: 14px;
    object-fit: contain;
    vertical-align: middle;
    margin-left: 4px;
    opacity: 0.85;
    transition: opacity 0.2s ease, transform 0.2s ease;
}

.msg-receipt-inline-icon.sending {
    animation: receipt-pulse 1.2s ease-in-out infinite;
}

/* Read receipt badge — tiny profile picture(s) pinned to the corner of the last
   message a person has read, Facebook Messenger-style. No text, no "sent/delivered"
   state; it simply isn't there until someone has actually read that far. */
.msg-receipt-badge {
    position: absolute;
    right: 6px;
    bottom: -9px;
    display: flex;
    align-items: center;
    z-index: 5;
    animation: receipt-fadein 0.25s ease;
}

.receipt-avatar {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    object-fit: cover;
    border: 1.5px solid var(--surface);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
}

.receipt-avatar + .receipt-avatar {
    margin-left: -6px;
}

.msg-receipt-badge.is-expandable {
    cursor: pointer;
}

.msg-receipt-badge.is-expandable:hover .receipt-avatar {
    transform: translateY(-1px);
}

.seen-by-popover {
    position: absolute;
    bottom: calc(100% + 8px);
    right: 0;
    min-width: 160px;
    max-width: 220px;
    max-height: 220px;
    overflow-y: auto;
    background: var(--surface-secondary);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 8px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
    z-index: 50;
}

.seen-by-popover-title {
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 2px 6px 6px;
}

.seen-by-popover-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.seen-by-popover-list li {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 5px 6px;
    border-radius: 6px;
    font-size: 0.82rem;
}

.seen-by-popover-list li:hover {
    background: var(--surface-hover);
}

.seen-by-popover-list li img {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
}

/* ── Presence: online / last seen ─────────────────────── */

.dm-avatar-wrap {
    position: relative;
    flex-shrink: 0;
    line-height: 0;
}

.dm-presence-dot {
    position: absolute;
    bottom: 1px;
    right: 1px;
    width: 11px;
    height: 11px;
    border-radius: 50%;
    background: var(--text-muted);
    border: 2px solid var(--surface, #1a1625);
    transition: background-color 0.2s ease;
}

.dm-presence-dot.is-online {
    background: #22c55e;
}

.chat-presence-status {
    font-size: 0.72rem;
    color: var(--text-muted);
    display: block;
    margin-top: 1px;
}

.chat-presence-status.is-online {
    color: #22c55e;
    font-weight: 600;
}

/* Optimistic sending message — faint version of sent bubble */
.message.optimistic-sending {
    opacity: 0.65;
}

/* Offline send queue: message is stored locally and will be retried automatically */
.message.optimistic-sending.is-queued { opacity: 0.8; }
.message.optimistic-sending.is-queued .message-bubble { border: 1px dashed var(--text-muted); }
.message.optimistic-sending.is-failed { opacity: 1; }
.message.optimistic-sending.is-failed .message-bubble { border: 1px solid var(--error); }
.queued-status {
    margin-top: 4px;
    font-size: 0.75rem;
    color: var(--text-muted);
    text-align: right;
}
.message.optimistic-sending.is-failed .queued-status { color: var(--error); }
.queued-action {
    background: none;
    border: none;
    padding: 0 2px;
    margin-left: 4px;
    font: inherit;
    font-weight: 600;
    color: var(--accent);
    cursor: pointer;
    text-decoration: underline;
}
.queued-action:hover { filter: brightness(1.2); }

/* ── End Read Receipts ─────────────────────────────── */

/* Markdown specific styles */
.message-bubble p { margin-bottom: 0.5rem; }
.message-bubble p:last-child { margin-bottom: 0; }
.message-bubble strong { font-weight: 700; }
.message-bubble em { font-style: italic; }
.message-bubble .roleplay-aside {
    display: block;
    border-left: 2px solid var(--accent);
    color: var(--accent);
    font-style: italic;
    padding-left: 0.7rem;
    margin: 0.15rem 0;
}
.message-bubble code {
    background-color: rgba(0,0,0,0.3);
    padding: 0.1rem 0.3rem;
    border-radius: 4px;
    font-family: monospace;
    font-size: 0.9em;
}
.message.sent .message-bubble code {
    background-color: rgba(255,255,255,0.2);
}

.link-preview {
    display: flex;
    width: 100%;
    max-width: 360px;
    margin-top: 0.75rem;
    overflow: hidden;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: rgba(0,0,0,0.16);
}

.link-preview[hidden],
.link-preview:empty,
.link-preview:not(:has(*)) {
    display: none !important;
    margin: 0 !important;
    padding: 0 !important;
    border: none !important;
}

.link-preview img {
    width: 92px;
    min-height: 92px;
    object-fit: cover;
}

.link-preview-copy {
    display: flex;
    min-width: 0;
    flex-direction: column;
    gap: 0.2rem;
    padding: 0.6rem 0.7rem;
}

.link-preview-copy strong,
.link-preview-copy span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.link-preview-copy span {
    font-size: 0.78rem;
    color: var(--text-muted);
}

.link-preview-copy small {
    color: var(--accent);
}

.message.sent .link-preview {
    background: rgba(0, 0, 0, 0.25);
    border-color: rgba(255, 255, 255, 0.2);
}

.message.sent .link-preview-copy strong {
    color: #ffffff;
}

.message.sent .link-preview-copy span {
    color: rgba(255, 255, 255, 0.8);
}

.message.sent .link-preview-copy small {
    color: #a5f3fc;
}

.message-attachments {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}

.message-attachment {
    position: relative;
    border-radius: 8px;
    overflow: hidden; /* Fixes corner cutoff */
    border: 1px solid rgba(255,255,255,0.15);
}

.message-attachment img {
    max-width: min(200px, 100%);
    max-height: 200px;
    border-radius: 8px;
    cursor: pointer;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    position: relative;
}

.message-attachment video {
    display: block;
    width: min(360px, 100%);
    max-height: 260px;
    background: #000;
}

.message-audio {
    padding: 0.35rem;
    background: var(--surface-secondary);
}

.message-attachment audio {
    display: block;
    width: min(360px, 100%);
    min-width: 260px;
}

.message.merged {
    margin-top: -0.25rem;
}

.message.merged .message-sender {
    display: none !important;
}

.message.merged .message-bubble {
    border-top-left-radius: 12px;
}

.message.sent.merged .message-bubble {
    border-top-right-radius: 12px;
}

.message-hover-timestamp {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    font-size: 0.7rem;
    color: var(--text-muted);
    opacity: 0;
    transition: opacity 0.2s;
    pointer-events: none;
    white-space: nowrap;
}

.message:not(.merged) .message-hover-timestamp {
    display: none;
}

.message:hover .message-hover-timestamp {
    opacity: 1;
}

.message.sent .message-hover-timestamp {
    right: 100%;
    margin-right: 0.5rem;
}

.message.received .message-hover-timestamp {
    left: 100%;
    margin-left: 0.5rem;
}

.message-attachment-file {
    padding: 0.75rem;
    background-color: var(--surface-secondary);
    border: 1px solid var(--border);
    border-radius: 12px;
    display: flex;
    align-items: center;
    font-size: 0.85rem;
    text-decoration: none;
    color: inherit;
    transition: background-color 0.2s;
    word-break: break-all;
}
.message-attachment-file:hover {
    background-color: rgba(255, 255, 255, 0.1);
}

.composer-container {
    border-top: 1px solid var(--border);
}

.composer-container.drag-active {
    border-top-color: var(--accent);
    box-shadow: inset 0 2px 0 var(--accent);
}

.attachment-previews {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem 0;
    display: none;
}

.upload-progress {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    padding: 0.6rem 1.5rem 0;
    color: var(--text-muted);
    font-size: 0.75rem;
}

.upload-progress[hidden] {
    display: none;
}

.upload-progress-bar {
    height: 4px;
    flex: 1;
    max-width: 240px;
    overflow: hidden;
    border-radius: 999px;
    background: #25212f;
}

.upload-progress-bar span {
    display: block;
    height: 100%;
    width: 0;
    background: var(--accent);
    transition: width 0.15s ease;
}

.attachment-preview {
    position: relative;
    width: 60px;
    height: 60px;
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid var(--border);
    background-color: var(--surface-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.7rem;
    text-align: center;
}

.attachment-preview img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.remove-attachment {
    position: absolute;
    top: 2px;
    right: 2px;
    background-color: rgba(0,0,0,0.7);
    color: white;
    border: none;
    border-radius: 50%;
    width: 18px;
    height: 18px;
    font-size: 10px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.message-composer {
    padding: 1rem 1.5rem;
    display: flex;
    flex-direction: row !important; /* Fix vertical stacking */
    gap: 0.75rem;
    align-items: center;
}

#message-input {
    flex: 1;
    min-width: 0;
    border-radius: 20px;
    padding: 0.75rem 1.25rem;
}

/* Context Menu */
.context-menu {
    position: fixed;
    border-radius: 12px;
    z-index: 2000;
    min-width: 150px;
    max-width: calc(100vw - 16px);
    padding: 0.5rem;
    box-shadow: 0 10px 32px rgba(0, 0, 0, 0.55), 0 0 0 1px var(--border);
    animation: contextMenuPop 0.16s cubic-bezier(0.16, 1, 0.3, 1);
    transform-origin: top left;
}

@keyframes contextMenuPop {
    from {
        opacity: 0;
        transform: scale(0.92);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.menu-item {
    padding: 0.5rem 1rem;
    cursor: pointer;
    font-size: 0.9rem;
    border-radius: 6px;
    transition: background-color 0.2s;
    display: flex;
    align-items: center;
    touch-action: manipulation;
}

.menu-item:hover {
    background-color: rgba(255,255,255,0.1);
}

/* Mobile tap & hold (long-press) styles */
@media (pointer: coarse), (max-width: 768px) {
    .message,
    .message * {
        -webkit-touch-callout: none;
    }

    .message-bubble {
        user-select: none;
        -webkit-user-select: none;
    }

    .menu-item {
        padding: 0.65rem 1rem;
        font-size: 0.95rem;
    }
}

.message.message-long-pressed .message-bubble {
    transform: scale(0.97);
    filter: brightness(1.2);
    transition: transform 0.15s ease, filter 0.15s ease;
}

/* Translation styles */
.translation-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    margin-top: 0.45rem;
    font-size: 0.7rem;
    color: var(--text-muted);
    opacity: 0.85;
    letter-spacing: 0.01em;
}

.translation-badge svg {
    flex-shrink: 0;
    opacity: 0.7;
}

.translate-toggle-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    margin-top: 0.4rem;
    background: var(--surface-secondary);
    border: 1px solid var(--border);
    border-radius: 999px;
    color: var(--text-muted);
    font-size: 0.7rem;
    font-weight: 500;
    padding: 0.22rem 0.7rem 0.22rem 0.5rem;
    cursor: pointer;
    transition: background 0.15s, color 0.15s, border-color 0.15s;
    letter-spacing: 0.01em;
}

.translate-toggle-btn svg {
    flex-shrink: 0;
    opacity: 0.75;
    transition: opacity 0.15s;
}

.translate-toggle-btn:hover {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
    opacity: 1;
}

.translate-toggle-btn:hover svg {
    opacity: 1;
}

.message.sent .translate-toggle-btn {
    background: rgba(255,255,255,0.12);
    border-color: rgba(255,255,255,0.25);
    color: rgba(255,255,255,0.75);
}

.message.sent .translate-toggle-btn:hover {
    background: rgba(255,255,255,0.28);
    border-color: rgba(255,255,255,0.5);
    color: #fff;
}

.message.sent .translation-badge {
    color: rgba(255,255,255,0.55);
}

.translate-loading {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 0.4rem;
    animation: fadeIn 0.3s;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}
.translate-spinner {
    width: 11px;
    height: 11px;
    border: 2px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
    display: inline-block;
}

/* Modals */
.modal,
.modal-overlay {
    position: fixed;
    inset: 0;
    background-color: rgba(0,0,0,0.72);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 99999;
}

.modal-content {
    padding: 2rem;
    border-radius: 18px;
    width: 100%;
    max-width: 460px;
    background: var(--surface);
    border: 1px solid var(--border);
    box-shadow: 0 24px 64px rgba(0,0,0,0.6), 0 0 0 1px rgba(126,75,243,0.15);
    color: var(--text);
    position: relative;
}

.modal-content h2 {
    font-size: 1.15rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
    color: var(--text);
}

.modal-content p {
    color: var(--text-muted);
    font-size: 0.9rem;
    margin-bottom: 1rem;
}

.modal-actions {
    display: flex;
    gap: 0.6rem;
    justify-content: flex-end;
    margin-top: 1.2rem;
}

/* ─── Code Blocks ─────────────────────────────────────────────── */
.code-block-wrapper {
    border-radius: 12px;
    overflow: hidden;
    border: 1px solid rgba(126, 75, 243, 0.35);
    margin: 0.65rem 0;
    background: #13102a;
    font-size: 0;  /* remove inline gap */
}

.code-block-topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 6px 10px;
    background: #1d1640;
    border-bottom: 1px solid rgba(126, 75, 243, 0.3);
}

.code-block-topbar-left {
    display: flex;
    align-items: center;
    gap: 7px;
}

.code-block-logo {
    width: 16px;
    height: 16px;
    object-fit: contain;
    opacity: 0.85;
    flex-shrink: 0;
}

.code-block-lang {
    font-size: 0.72rem;
    font-weight: 600;
    color: #a78bfa;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    font-family: 'DM Sans', sans-serif;
}

.code-block-body {
    display: flex;
    overflow-x: auto;
}

.code-line-numbers {
    display: flex;
    flex-direction: column;
    padding: 1em 10px 1em 12px;
    background: rgba(0,0,0,0.25);
    border-right: 1px solid rgba(126, 75, 243, 0.2);
    user-select: none;
    font-family: 'JetBrains Mono', 'Fira Code', monospace;
    font-size: 0.82rem;
    line-height: 1.5;
    color: rgba(167, 139, 250, 0.4);
    text-align: right;
    min-width: 36px;
    flex-shrink: 0;
}

.code-line-numbers span {
    display: block;
    line-height: 1.5;
}

.code-block-body pre[class*="language-"] {
    margin: 0 !important;
    border-radius: 0 !important;
    border: none !important;
    background: transparent !important;
    flex: 1;
    font-size: 0.83rem;
    line-height: 1.5;
    overflow: visible;
}

.copy-code-btn {
    padding: 3px 8px;
    background: rgba(126, 75, 243, 0.18);
    border: 1px solid rgba(126, 75, 243, 0.3);
    border-radius: 5px;
    color: #a78bfa;
    font-size: 0.72rem;
    font-family: 'DM Sans', sans-serif;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 4px;
    transition: background 0.15s, color 0.15s;
    white-space: nowrap;
}

.copy-code-btn:hover {
    background: rgba(126, 75, 243, 0.4);
    color: #fff;
}

/* Prism.js — reset background to transparent so our wrapper bg shows */
pre[class*="language-"],
code[class*="language-"] {
    font-family: 'JetBrains Mono', 'Fira Code', 'Cascadia Code', monospace !important;
    font-size: 0.83rem !important;
    background: transparent !important;
}

/* ─── Viboro AI Response Card ─────────────────────────────────── */
.viboro-card {
    display: flex;
    flex-direction: column;
    gap: 0;
    border-radius: 14px;
    overflow: hidden;
    border: 1px solid rgba(126, 75, 243, 0.4);
    background: #11102a;
    max-width: 560px;
    width: 100%;
    margin: 0.5rem 0;
    box-shadow: 0 8px 32px rgba(0,0,0,0.4), 0 0 0 1px rgba(126,75,243,0.1);
}

.viboro-card-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    background: #1a1540;
    border-bottom: 1px solid rgba(126, 75, 243, 0.25);
}

.viboro-card-header img {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    object-fit: cover;
}

.viboro-card-header-info {
    display: flex;
    flex-direction: column;
    gap: 1px;
}

.viboro-card-title {
    font-size: 0.8rem;
    font-weight: 700;
    color: #a78bfa;
}

.viboro-card-subtitle {
    font-size: 0.7rem;
    color: var(--text-muted);
}

.viboro-card-prompt {
    padding: 10px 14px;
    background: rgba(126, 75, 243, 0.07);
    border-bottom: 1px solid rgba(126, 75, 243, 0.15);
}

.viboro-card-prompt-label {
    font-size: 0.68rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: rgba(167, 139, 250, 0.6);
    margin-bottom: 3px;
}

.viboro-card-prompt-text {
    font-size: 0.88rem;
    color: var(--text);
    line-height: 1.45;
}

.viboro-card-response {
    padding: 12px 14px;
}

.viboro-card-response-label {
    font-size: 0.68rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: rgba(167, 139, 250, 0.6);
    margin-bottom: 6px;
}

.viboro-card-response-body {
    font-size: 0.88rem;
    color: var(--text);
    line-height: 1.55;
}

.viboro-card-response-body p:last-child { margin-bottom: 0; }
.viboro-card-response-body code {
    background: rgba(126,75,243,0.2);
    padding: 1px 5px;
    border-radius: 4px;
    font-family: monospace;
    font-size: 0.82em;
}

/* Viboro card placed as standalone block in chat (not in a bubble) */
.viboro-card-container {
    display: flex;
    justify-content: center;
    padding: 6px 12px;
    animation: messageIn 0.24s ease-out both;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.code-display {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background-color: var(--surface-secondary);
    padding: 1rem;
    border-radius: 8px;
    margin-top: 0.5rem;
    font-family: monospace;
    font-size: 1.2rem;
    letter-spacing: 2px;
    border: 1px solid var(--border);
}

hr {
    border: none;
    border-top: 1px solid var(--border);
    margin: 1.5rem 0;
}

.search-results-container {
    max-height: 100%; 
    overflow-y: auto; 
    display: flex; 
    flex-direction: column; 
    gap: 0.5rem;
}

/* ==========================================
   REVAMPED SETTINGS MODAL (PC & MOBILE)
   ========================================== */
/* ==========================================
   REVAMPED SETTINGS MODAL (PC & MOBILE)
   ========================================== */
.settings-modal-content {
    max-width: 860px !important;
    width: 90% !important;
    height: 60vh !important;
    max-height: 60vh !important;
    min-height: 0 !important;
    padding: 0 !important;
    display: flex !important;
    overflow: hidden !important;
    border-radius: 18px !important;
}

.settings-sidebar {
    width: 270px;
    height: 100%;
    background: var(--surface-secondary);
    padding: 1.25rem 1rem;
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    flex-shrink: 0;
    overflow-y: auto;
}

.settings-sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.25rem 0.5rem 0.85rem;
    border-bottom: 1px solid var(--border);
    margin-bottom: 0.5rem;
}

.settings-title-wrap {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    color: var(--text);
}

.settings-title-wrap h3 {
    font-size: 1.1rem;
    font-weight: 700;
    margin: 0;
    color: var(--text);
    letter-spacing: -0.01em;
}

@media (min-width: 769px) {
    .settings-sidebar-header .desktop-close-btn {
        display: none !important;
    }
}

.settings-group-title {
    font-size: 0.65rem;
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--text-muted);
    margin: 0.9rem 0 0.3rem 0.6rem;
}

.settings-tab {
    padding: 0.55rem 0.75rem;
    cursor: pointer;
    font-size: 0.88rem;
    font-weight: 500;
    transition: all 0.18s ease;
    color: var(--text-muted);
    border-radius: 10px;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 0.2rem;
    position: relative;
    border: 1px solid transparent;
}

.settings-tab:hover {
    background-color: rgba(155, 108, 255, 0.08);
    color: var(--text);
}

.settings-tab.active {
    background-color: var(--surface-hover, rgba(155, 108, 255, 0.14));
    color: var(--text);
    font-weight: 600;
    border-color: var(--border);
}

.settings-tab.active .settings-tab-icon {
    transform: scale(1.08);
    box-shadow: 0 2px 8px rgba(155, 108, 255, 0.25);
}

/* Icon Badges */
.settings-tab-icon {
    width: 28px;
    height: 28px;
    border-radius: 8px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.icon-purple { background: rgba(168, 85, 247, 0.14); color: #c084fc; border: 1px solid rgba(168, 85, 247, 0.25); }
.icon-pink   { background: rgba(236, 72, 153, 0.14); color: #f472b6; border: 1px solid rgba(236, 72, 153, 0.25); }
.icon-blue   { background: rgba(59, 130, 246, 0.14); color: #60a5fa; border: 1px solid rgba(59, 130, 246, 0.25); }
.icon-cyan   { background: rgba(6, 182, 212, 0.14);  color: #22d3ee; border: 1px solid rgba(6, 182, 212, 0.25); }
.icon-green  { background: rgba(16, 185, 129, 0.14); color: #34d399; border: 1px solid rgba(16, 185, 129, 0.25); }
.icon-violet { background: rgba(139, 92, 246, 0.14); color: #a78bfa; border: 1px solid rgba(139, 92, 246, 0.25); }

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

/* Mobile User Header Widget (Image 2 Reference) */
.mobile-settings-user-card {
    display: none;
    align-items: center;
    gap: 0.85rem;
    padding: 0.85rem 1rem;
    border-radius: 14px;
    background: var(--surface);
    border: 1px solid var(--border);
    margin-bottom: 0.75rem;
    cursor: pointer;
    transition: background 0.15s ease;
}
.mobile-settings-user-card:hover {
    background: var(--surface-hover);
}
.mobile-settings-user-card img {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid var(--accent);
}
.mobile-user-info {
    display: flex;
    flex-direction: column;
    flex: 1;
}
.mobile-user-info span {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text);
}
.mobile-user-info small {
    font-size: 0.78rem;
    color: var(--text-muted);
}
.mobile-settings-user-card .chevron-right {
    color: var(--text-muted);
}

/* Settings Body & Panes */
.settings-body {
    flex: 1;
    height: 100%;
    padding: 1.75rem 2.25rem;
    overflow-y: auto;
    position: relative;
    background: var(--background);
}

.settings-sidebar::-webkit-scrollbar,
.settings-body::-webkit-scrollbar {
    width: 6px;
}
.settings-sidebar::-webkit-scrollbar-track,
.settings-body::-webkit-scrollbar-track {
    background: transparent;
}
.settings-sidebar::-webkit-scrollbar-thumb,
.settings-body::-webkit-scrollbar-thumb {
    background: rgba(155, 108, 255, 0.25);
    border-radius: 999px;
}
.settings-sidebar::-webkit-scrollbar-thumb:hover,
.settings-body::-webkit-scrollbar-thumb:hover {
    background: rgba(155, 108, 255, 0.5);
}

.settings-body-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
}

.body-close-btn {
    position: absolute;
    top: 1.25rem;
    right: 1.5rem;
    z-index: 10;
}

.settings-pane-intro {
    margin-bottom: 1.25rem;
    padding-right: 2.5rem;
}

.settings-pane-intro h3 {
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 0.3rem;
    letter-spacing: -0.01em;
}

.settings-pane-intro p {
    color: var(--text-muted);
    font-size: 0.84rem;
    line-height: 1.4;
}

.settings-section {
    background: var(--surface-secondary);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 1.75rem 2.25rem !important;
    margin-bottom: 1.25rem;
    box-sizing: border-box !important;
    width: 100% !important;
}

.settings-section h4 {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 0.4rem;
}

/* Theme Selection Cards Grid (Image 1 Reference) */
.theme-selection-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1.25rem;
    margin-top: 1rem;
}

.theme-card-option {
    cursor: pointer;
    border-radius: 14px;
    overflow: hidden;
    background: var(--surface-secondary);
    border: 2px solid var(--border);
    transition: border-color 0.2s ease, transform 0.15s ease, box-shadow 0.2s ease;
    display: flex;
    flex-direction: column;
}

.theme-card-option:hover {
    border-color: var(--accent);
    transform: translateY(-2px);
}

.theme-card-option input[type="radio"]:checked + span {
    color: var(--accent);
    font-weight: 700;
}

.theme-card-option:has(input[type="radio"]:checked) {
    border-color: var(--accent);
    box-shadow: 0 0 16px rgba(155, 108, 255, 0.2);
}

.theme-card-preview {
    height: 110px;
    padding: 0.75rem;
    display: flex;
    gap: 0.5rem;
}

.dark-theme-preview {
    background: #0b0b14;
}
.light-theme-preview {
    background: #f1f5f9;
}
.cyber-theme-preview {
    background: #14092a;
}

.theme-card-preview .mock-sidebar {
    width: 28%;
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.06);
    padding: 0.4rem;
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
}
.light-theme-preview .mock-sidebar {
    background: rgba(0, 0, 0, 0.06);
}

.mock-line {
    height: 5px;
    border-radius: 3px;
    background: rgba(255, 255, 255, 0.2);
}
.light-theme-preview .mock-line {
    background: rgba(0, 0, 0, 0.2);
}
.mock-line.short { width: 60%; }
.mock-line.accent { background: var(--accent); }

.mock-chat {
    flex: 1;
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.03);
    padding: 0.4rem;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    gap: 0.35rem;
}
.light-theme-preview .mock-chat {
    background: #ffffff;
}

.mock-msg {
    height: 12px;
    border-radius: 4px;
    width: 50%;
    background: rgba(255, 255, 255, 0.15);
}
.light-theme-preview .mock-msg {
    background: #e2e8f0;
}
.mock-msg.right {
    align-self: flex-end;
}
.mock-msg.accent {
    background: var(--accent);
}

.theme-card-footer {
    padding: 0.75rem 1rem;
    display: flex;
    align-items: center;
    gap: 0.6rem;
    background: var(--surface);
    border-top: 1px solid var(--border);
    font-size: 0.85rem;
    color: var(--text-muted);
}
.theme-card-footer input[type="radio"] {
    accent-color: var(--accent);
    width: 16px;
    height: 16px;
}

/* Switch Toggle (iOS style) */
.switch-toggle {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
}
.switch-toggle input {
    opacity: 0;
    width: 0;
    height: 0;
}
.switch-slider {
    position: absolute;
    cursor: pointer;
    top: 0; left: 0; right: 0; bottom: 0;
    background-color: var(--surface-hover, #2e2e42);
    border: 1px solid var(--border);
    transition: .3s;
    border-radius: 24px;
}
.switch-slider:before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 2px;
    bottom: 2px;
    background-color: white;
    transition: .3s;
    border-radius: 50%;
}
.switch-toggle input:checked + .switch-slider {
    background-color: var(--accent);
    border-color: var(--accent);
}
.switch-toggle input:checked + .switch-slider:before {
    transform: translateX(20px);
}

/* ==========================================
   END-TO-END ENCRYPTION (E2EE) STYLING
   ========================================== */
.e2ee-chat-banner {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.65rem;
    padding: 0.65rem 1.15rem;
    margin: 1.25rem auto 1rem;
    max-width: 90%;
    width: fit-content;
    background: var(--surface-secondary);
    border: 1px solid var(--border);
    border-radius: 12px;
    color: var(--text-muted);
    font-size: 0.78rem;
    text-align: center;
    line-height: 1.45;
}
.e2ee-chat-banner svg {
    color: #10b981;
    flex-shrink: 0;
}

.e2ee-header-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    font-size: 0.72rem;
    font-weight: 600;
    color: #10b981;
    background: rgba(16, 185, 129, 0.12);
    border: 1px solid rgba(16, 185, 129, 0.25);
    padding: 0.2rem 0.6rem;
    border-radius: 999px;
    margin-left: 0.3rem;
}
.e2ee-header-badge svg {
    stroke: #10b981;
}

.e2ee-settings-card {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}
.e2ee-card-top {
    display: flex;
    align-items: flex-start;
    gap: 0.85rem;
}
.e2ee-icon-badge {
    width: 38px;
    height: 38px;
    border-radius: 10px;
    background: rgba(16, 185, 129, 0.12);
    border: 1px solid rgba(16, 185, 129, 0.25);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.e2ee-card-info {
    flex: 1;
}
.e2ee-card-info h4 {
    margin-bottom: 0.25rem !important;
}
.e2ee-card-info p {
    margin-bottom: 0 !important;
    font-size: 0.83rem;
    color: var(--text-muted);
}
.e2ee-status-badge {
    font-size: 0.72rem;
    font-weight: 700;
    color: #10b981;
    background: rgba(16, 185, 129, 0.14);
    border: 1px solid rgba(16, 185, 129, 0.3);
    padding: 0.25rem 0.65rem;
    border-radius: 999px;
}
.e2ee-fingerprint-box {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--surface);
    border: 1px solid var(--border);
    padding: 0.65rem 0.9rem;
    border-radius: 10px;
    font-size: 0.8rem;
    color: var(--text-muted);
}
.e2ee-fingerprint-box code {
    font-family: 'Space Grotesk', monospace;
    color: var(--accent);
    font-weight: 600;
    letter-spacing: 0.05em;
}

/* Mobile Settings Layout Styles */
.mobile-chevron,
.mobile-only-inline {
    display: none;
}
.settings-mobile-row {
    display: none;
    align-items: center;
    justify-content: space-between;
    padding: 0.6rem 0.75rem;
    background: var(--surface);
    border-radius: 10px;
    border: 1px solid var(--border);
    margin-bottom: 0.4rem;
    color: var(--text);
    font-size: 0.88rem;
}
.settings-mobile-row-left {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}
.settings-status-badge {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-left: auto;
    margin-right: 0.3rem;
}

.settings-pane {
    animation: fadeIn 0.2s;
}

.settings-pane h4 {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 0.25rem;
    color: var(--text);
}

.panic-mode-button {
    position: fixed;
    right: 1.5rem;
    bottom: 1.5rem;
    z-index: 99998;
    width: 56px;
    height: 56px;
    padding: 5px;
    align-items: center;
    justify-content: center;
    border: 1px solid rgba(255, 45, 55, 0.65);
    border-radius: 50%;
    background: rgba(20, 12, 14, 0.94);
    box-shadow: 0 4px 16px rgba(255, 30, 45, 0.35);
    cursor: grab;
    touch-action: none;
    user-select: none;
    transition: box-shadow 0.18s ease, transform 0.18s ease;
}

.panic-mode-button:hover {
    transform: scale(1.06);
    box-shadow: 0 6px 22px rgba(255, 30, 45, 0.55);
}

.panic-mode-button:active {
    cursor: grabbing;
}

.panic-mode-button:focus-visible {
    outline: 2px solid #ff303a;
    outline-offset: 3px;
}

.panic-mode-button img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: contain;
    pointer-events: none;
}



/* Toast Container (Always on topmost layer above all modals and overlays) */
.toast-container {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    z-index: 10000000 !important;
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
    pointer-events: none;
}

.toast {
    pointer-events: auto;
    background: rgba(18, 18, 28, 0.96);
    border-left: 4px solid var(--accent);
    color: var(--text);
    padding: 0.9rem 1.4rem;
    border-radius: 12px;
    box-shadow: 0 16px 45px rgba(0, 0, 0, 0.7), 0 0 20px rgba(155, 108, 255, 0.25);
    animation: slideInRight 0.3s cubic-bezier(0.16, 1, 0.3, 1) forwards, fadeOut 0.35s ease forwards 4.65s;
    font-size: 0.9rem;
    font-weight: 500;
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-top: 1px solid rgba(255, 255, 255, 0.12);
    border-right: 1px solid rgba(255, 255, 255, 0.12);
    border-bottom: 1px solid rgba(255, 255, 255, 0.12);
    display: flex;
    align-items: center;
    gap: 0.6rem;
    z-index: 10000001 !important;
}

.toast.toast-error {
    border-left-color: var(--error);
    box-shadow: 0 16px 45px rgba(0, 0, 0, 0.7), 0 0 20px rgba(239, 68, 68, 0.25);
}

.message-attachment {
    position: relative;
    border-radius: 8px;
    overflow: hidden; 
    border: 1px solid rgba(255,255,255,0.15);
    display: inline-block;
}
.message-attachment img {
    display: block;
    cursor: pointer;
    transition: transform 0.2s;
    border: none;
    border-radius: 0;
}
.message-attachment img:hover {
    transform: scale(1.02);
}

@keyframes slideInRight {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}
@keyframes fadeOut {
    from { opacity: 1; }
}

/* Landing Page Styles */
.landing-view {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100dvh;
    text-align: center;
    padding: 2rem;
    position: relative;
    overflow-y: auto;
}

.landing-logo {
    max-width: 400px;
    margin-bottom: 2rem;
}

.landing-copy {
    max-width: 600px;
    font-size: 1.2rem;
    color: var(--text-muted);
    margin-bottom: 3rem;
    line-height: 1.6;
}

.stats-container {
    display: flex;
    gap: 2rem;
    margin-bottom: 3rem;
}

.stat-box {
    background: var(--surface);
    border: 1px solid var(--accent);
    padding: 1.5rem 2rem;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(140, 82, 255, 0.2);
    min-width: 200px;
}

.stat-value {
    font-size: 2.5rem;
    font-weight: bold;
    color: var(--text);
    margin-bottom: 0.5rem;
}

.stat-label {
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--accent);
}

.landing-actions {
    display: flex;
    gap: 1.5rem;
    margin-bottom: 4rem;
}

.landing-actions .btn-primary, .landing-actions .btn-secondary {
    padding: 1rem 2rem;
    font-size: 1.1rem;
}

.landing-footer {
    position: absolute;
    bottom: 2rem;
    display: flex;
    gap: 2rem;
    font-size: 0.9rem;
    flex-wrap: wrap;
    justify-content: center;
}

.landing-footer a {
    color: var(--text-muted);
    text-decoration: none;
    transition: color 0.2s;
}

.landing-footer a:hover {
    color: var(--text);
}

.app-logo-small {
    height: 32px;
    margin-right: 1rem;
    vertical-align: middle;
}

/* Emoji picker dark theme */
emoji-picker {
    --background: #0c0c19;
    --border-color: rgba(255,255,255,0.1);
    --indicator-color: var(--accent);
    --input-border-color: rgba(255,255,255,0.15);
    --input-font-color: #fff;
    --input-placeholder-color: #888;
    --outline-color: var(--accent);
    --category-emoji-padding: 0.3rem;
    --emoji-size: 1.4rem;
    --num-columns: 8;
    border-radius: 12px;
    box-shadow: 0 8px 30px rgba(0,0,0,0.6);
}

/* Dropdown item alignment */
.dropdown-item {
    display: flex;
    align-items: center;
}

/* Menu items flex */
.menu-item {
    display: flex;
    align-items: center;
}

/* Reply quote in message bubble */
.reply-quote {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 0.45rem 0.65rem;
    margin-bottom: 0.5rem;
    border-left: 3px solid #c084fc;
    background: rgba(140, 82, 255, 0.12);
    border-radius: 4px;
    cursor: pointer;
    transition: background 0.15s;
    max-width: 100%;
    overflow: hidden;
}
.reply-quote:hover {
    background: rgba(140, 82, 255, 0.2);
}
.reply-quote-name {
    font-size: 0.75rem;
    font-weight: 700;
    color: #c084fc;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.reply-quote-text {
    font-size: 0.8rem;
    color: rgba(255, 255, 255, 0.8);
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    word-break: break-word;
    overflow-wrap: anywhere;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* High contrast styles for reply quotes on purple sent message bubbles */
.message.sent .reply-quote {
    border-left-color: #ffffff;
    background: rgba(0, 0, 0, 0.25);
}
.message.sent .reply-quote:hover {
    background: rgba(0, 0, 0, 0.35);
}
.message.sent .reply-quote-name {
    color: #ffffff;
}
.message.sent .reply-quote-text {
    color: rgba(255, 255, 255, 0.88);
}

/* Highlight flash when scrolled to */
@keyframes highlightFlash {
    0%   { background: rgba(140, 82, 255, 0.25); }
    100% { background: transparent; }
}
.message.highlight-flash {
    animation: highlightFlash 1.5s ease-out forwards;
    border-radius: 8px;
}

/* PFP Drop Zone on Register */
.pfp-drop-zone {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 1.25rem;
    border: 2px dashed rgba(140, 82, 255, 0.4);
    border-radius: 12px;
    cursor: pointer;
    background: rgba(140, 82, 255, 0.05);
    transition: border-color 0.2s, background 0.2s;
    min-height: 120px;
    text-align: center;
    margin-bottom: 0.5rem;
}
.pfp-drop-zone:hover {
    border-color: var(--accent);
    background: rgba(140, 82, 255, 0.1);
}

/* --- MOBILE RESPONSIVENESS --- */
.mobile-only {
    display: none !important;
}

@media (max-width: 768px) {
    .mobile-only {
        display: flex !important;
    }
    
    .desktop-only {
        display: none !important;
    }

    /* Landing Page Resizing */
    .landing-copy {
        font-size: 1rem;
        padding: 0 1rem;
    }
    .landing-logo {
        max-width: 100%;
        width: 250px;
    }
    .stats-container {
        flex-direction: column;
        gap: 1rem;
        width: 100%;
        align-items: stretch;
    }
    .stat-box {
        width: 100%;
    }
    .landing-actions {
        flex-direction: column;
        width: min(100%, 280px);
        margin-bottom: 1.5rem;
    }
    .landing-actions .btn-primary, .landing-actions .btn-secondary {
        width: 100%;
    }
    .landing-footer {
        position: static;
        margin-top: 1rem;
        gap: 0.75rem 1.25rem;
        font-size: 0.8rem;
    }

    /* Main view toggling */
    /* When mobile-chat-active is NOT on main-view, show sidebar, hide chat-area */
    #main-view:not(.mobile-chat-active) .sidebar {
        width: 100%;
        display: flex;
    }
    #main-view:not(.mobile-chat-active) .chat-area {
        display: none !important;
    }
    
    /* When mobile-chat-active IS on main-view, hide sidebar, show chat-area */
    #main-view.mobile-chat-active .sidebar {
        display: none !important;
    }
    #main-view.mobile-chat-active .chat-area {
        display: flex !important;
        width: 100%;
    }
    
    /* Sidebar Footer restyle */
    .sidebar-footer {
        flex-direction: column;
        align-items: stretch;
        padding: 1rem 0 0 0;
        gap: 1rem;
    }
    .user-profile {
        padding: 0 1rem;
    }
    .mobile-bottom-nav {
        width: 100%;
        justify-content: space-around;
        padding: 0.75rem 1rem;
        border-top: 1px solid var(--border);
        background: rgba(0,0,0,0.2);
    }
    .mobile-nav-btn {
        padding: 0.5rem;
    }
}

@media (max-width: 768px) {
    /* Mobile Settings Modal Revamp */
    #settings-modal .modal-content {
        max-width: 100% !important;
        width: 100% !important;
        height: 100vh !important;
        max-height: 100vh !important;
        border-radius: 0 !important;
        flex-direction: column !important;
    }

    .mobile-only-inline {
        display: inline-block !important;
    }
    .mobile-chevron {
        display: block !important;
        margin-left: auto;
        color: var(--text-muted);
    }
    .mobile-settings-user-card {
        display: flex !important;
    }
    .settings-mobile-row {
        display: flex !important;
    }

    #settings-modal:not(.mobile-settings-active) .settings-sidebar {
        display: flex !important;
        flex-direction: column;
        width: 100% !important;
        height: 100% !important;
        border-right: none;
    }
    #settings-modal:not(.mobile-settings-active) .settings-body {
        display: none !important;
    }

    #settings-modal.mobile-settings-active .settings-sidebar {
        display: none !important;
    }
    #settings-modal.mobile-settings-active .settings-body {
        display: flex !important;
        flex-direction: column;
        width: 100% !important;
        height: 100% !important;
        padding: 1.25rem 1rem !important;
    }
}

/* Badge & Friends Modal Styling */
.friends-modal-content {
    max-width: 480px;
    width: 90%;
}

.friends-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

#friends-modal-close {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0.2rem 0.5rem;
    line-height: 1;
    border-radius: 6px;
    transition: color 0.15s ease, background 0.15s ease;
}

#friends-modal-close:hover {
    color: var(--text);
    background: rgba(255, 255, 255, 0.1);
}

.icon-badge {
    background: var(--accent);
    color: #ffffff;
    font-size: 0.7rem;
    font-weight: 700;
    padding: 0.15rem 0.4rem;
    border-radius: 999px;
    margin-left: 0.35rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.friends-tabs {
    display: flex;
    gap: 1rem;
    border-bottom: 1px solid var(--border);
    padding-bottom: 0.5rem;
    margin-bottom: 1rem;
}

.friends-tab {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 0.95rem;
    font-weight: 600;
    padding: 0.4rem 0.8rem;
    cursor: pointer;
    border-radius: 6px;
    transition: all 0.2s ease;
}

.friends-tab:hover {
    color: var(--text);
    background: rgba(255, 255, 255, 0.05);
}

.friends-tab.active {
    color: var(--accent);
    background: rgba(155, 108, 255, 0.15);
}

.friends-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    max-height: 380px;
    overflow-y: auto;
}

.friend-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem;
    background: var(--surface-secondary);
    border: 1px solid var(--border);
    border-radius: 10px;
    transition: transform 0.15s ease, border-color 0.15s ease;
}

.friend-item:hover {
    border-color: var(--accent);
}

.friend-item-pfp {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    object-fit: cover;
    cursor: pointer;
}

.friend-item-info {
    display: flex;
    flex-direction: column;
    flex: 1;
    overflow: hidden;
}

.friend-item-name {
    font-weight: 600;
    color: var(--text);
    text-align: left;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.friend-item-handle {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.friend-item-actions {
    display: flex;
    gap: 0.5rem;
}

.profile-pending-pill {
    background: rgba(155, 108, 255, 0.15);
    color: var(--accent);
    padding: 0.6rem 1rem;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 600;
    text-align: center;
}

/* Vibora Media Wrappers */
.vibora-video-container, .vibora-audio-container {
    background: var(--surface-secondary);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 0.6rem;
    max-width: 100%;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.25);
    margin-top: 0.3rem;
}

.vibora-media-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-muted);
    padding: 0 0.2rem;
}

.vibora-media-name {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: var(--text);
}

.vibora-video-container video {
    width: 100%;
    max-width: 480px;
    border-radius: 8px;
    outline: none;
    display: block;
    background: #000;
}

.vibora-audio-container audio {
    width: 100%;
    min-width: 260px;
    border-radius: 8px;
    outline: none;
}

/* Auto-expanding Textarea Message Composer */
#message-input {
    flex: 1;
    background: transparent;
    border: none;
    outline: none;
    color: var(--text);
    font-family: inherit;
    font-size: 0.95rem;
    resize: none;
    overflow-y: hidden;
    max-height: 140px;
    height: 40px;
    min-height: 40px;
    line-height: 1.4;
    padding: 0.55rem 0.85rem;
    box-sizing: border-box;
    white-space: pre-wrap;
    overflow-wrap: break-word;
    word-break: break-word;
}

/* In-Chat Animated Typing Bubble */
.typing-bubble-message {
    animation: fadeIn 0.25s ease-out forwards;
    margin-bottom: 0.75rem;
}

.typing-bubble-body {
    display: inline-flex;
    align-items: center;
    padding: 0.65rem 1.1rem !important;
    min-height: 24px;
    border-radius: 16px;
    background: var(--surface-secondary);
    border: 1px solid var(--border);
}

.typing-dots {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    height: 14px;
}

.typing-dots span {
    width: 7px;
    height: 7px;
    background-color: var(--text-muted);
    border-radius: 50%;
    display: inline-block;
    animation: typingBouncing 1.4s infinite ease-in-out both;
}

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

@keyframes typingBouncing {
    0%, 80%, 100% {
        transform: scale(0.65);
        opacity: 0.4;
    }
    40% {
        transform: scale(1.15);
        opacity: 1;
        background-color: var(--accent);
        box-shadow: 0 0 6px var(--accent-soft);
    }
}

/* Reaction Badges & Quick Reaction Bar */
.quick-react-btn {
    background: transparent;
    border: none;
    font-size: 1.15rem;
    cursor: pointer;
    padding: 2px 4px;
    border-radius: 6px;
    transition: transform 0.15s ease, background 0.15s ease;
}
.quick-react-btn:hover {
    background: rgba(255, 255, 255, 0.15);
    transform: scale(1.2);
}

.message-reactions {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-top: 4px;
}

.reaction-badge {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    background: var(--surface-secondary);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 2px 8px;
    font-size: 0.78rem;
    cursor: pointer;
    user-select: none;
    transition: background 0.2s, border-color 0.2s;
}
.reaction-badge:hover {
    background: var(--surface);
    border-color: var(--accent);
}
.reaction-badge.reacted {
    background: rgba(155, 108, 255, 0.2);
    border-color: var(--accent);
    color: var(--accent);
    font-weight: 600;
}
.reaction-count {
    font-size: 0.72rem;
    opacity: 0.9;
}

/* Typing Indicator with moving dots & fade transitions */
.typing-indicator {
    position: absolute;
    bottom: 100%;
    left: 0;
    margin-bottom: 6px;
    padding: 0.35rem 1rem;
    font-size: 0.82rem;
    color: var(--text-muted);
    background: rgba(20, 20, 30, 0.75);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border-radius: 16px;
    border: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 6px;
    opacity: 0;
    visibility: hidden;
    transform: translateY(6px);
    transition: opacity 0.25s ease, transform 0.25s ease, visibility 0.25s ease;
    z-index: 50;
    pointer-events: none;
}

.typing-indicator.visible {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.typing-dots {
    display: inline-flex;
    align-items: center;
    gap: 3px;
}

.typing-dots span {
    width: 4px;
    height: 4px;
    background-color: var(--accent);
    border-radius: 50%;
    display: inline-block;
    animation: typingBounce 1.4s infinite ease-in-out both;
}

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

@keyframes typingBounce {
    0%, 80%, 100% {
        transform: scale(0.6);
        opacity: 0.4;
    }
    40% {
        transform: scale(1.2);
        opacity: 1;
    }
}

/* Vibora visual system */
:root {
    --background: #0b0d12;
    --surface: rgba(19, 22, 30, 0.9);
    --surface-secondary: #161a23;
    --surface-raised: #202532;
    --text: #f4f6fb;
    --text-muted: #929bac;
    --accent: #a875ff;
    --accent-hover: #bf9aff;
    --accent-soft: rgba(168, 117, 255, 0.14);
    --border: rgba(255, 255, 255, 0.1);
    --success: #7ee2b8;
    --shadow: 0 20px 70px rgba(0, 0, 0, 0.3);
}

body {
    font-family: 'DM Sans', sans-serif;
    background: radial-gradient(circle at 82% 8%, rgba(168, 117, 255, 0.12), transparent 28rem), #0b0d12;
    letter-spacing: 0;
}

h1, h2, h3, h4, .sidebar-title, .chat-display-name { font-family: 'Space Grotesk', sans-serif; }
#main-view { gap: 0; padding: 14px; background: linear-gradient(135deg, rgba(255,255,255,0.025), transparent 42%); }
.sidebar, .chat-area { border: 1px solid var(--border); box-shadow: var(--shadow); }
.sidebar { background: var(--surface); border-radius: 18px 0 0 18px; }
.chat-area { background: var(--background); border-radius: 0 18px 18px 0; overflow: hidden; }
.sidebar-header, .chat-header { min-height: 70px; padding: 0 20px; border-color: var(--border); }
.sidebar-title { font-size: 1.05rem; letter-spacing: -0.02em; }
.app-logo-small { width: 30px; height: 30px; border-radius: 10px; box-shadow: 0 0 0 4px var(--accent-soft); }
.dm-list { padding: 10px; }
.dm-item { border-radius: 12px; padding: 11px 12px; margin-bottom: 4px; border: 1px solid transparent; }
.dm-item:hover { background: var(--surface-hover); border-color: var(--border); }
.dm-item.active { background: var(--accent-soft); border-color: var(--accent); }
.chat-header { background: var(--surface); backdrop-filter: blur(18px); }
.chat-header img { width: 40px; height: 40px; border: 2px solid var(--accent); }
.messages { padding: 26px clamp(18px, 5vw, 72px); background: var(--background); }
.message { animation: messageIn 0.24s ease-out both; }
@keyframes messageIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }
.message-bubble { border: 1px solid var(--border); border-radius: 6px 16px 16px 16px; background: var(--surface-secondary); color: var(--text); box-shadow: 0 8px 24px rgba(0,0,0,0.14); }
.message.sent .message-bubble { border-radius: 16px 6px 16px 16px; background: var(--accent); color: #ffffff; border-color: var(--accent-hover); }
.message-sender { gap: 8px; }
.message-display-name { font-weight: 700; color: var(--text); }
.message-pfp { width: 28px; height: 28px; }
.composer-container { margin: 0 24px 20px; border: 1px solid var(--border); border-radius: 16px; background: var(--surface); box-shadow: 0 10px 30px rgba(0,0,0,0.2); }
.message-composer { gap: 6px; padding: 7px; }
#message-input { min-height: 42px; padding: 0.7rem 0.8rem; background: transparent; color: var(--text); }
.btn-primary { background: var(--accent); border-radius: 10px; box-shadow: 0 8px 20px var(--accent-soft); color: #ffffff; }
.btn-primary:hover { background: var(--accent-hover); }
.btn-secondary, .btn-icon { border-radius: 10px; }
/* Send button: ensure icon is visible on the purple background */
.message-composer .btn-primary.btn-icon { color: #ffffff !important; border-radius: 50% !important; }
.message-composer .btn-primary.btn-icon:hover { color: #ffffff !important; }
.glass-panel, .modal-content { border-color: var(--border); box-shadow: var(--shadow); }
.modal-content { border-radius: 18px; background: var(--surface); color: var(--text); }
.settings-sidebar { background: var(--surface-secondary); border-color: var(--border); }
.settings-tab.active { background: var(--accent-soft); color: var(--text); }
.settings-select { width: 100%; box-sizing: border-box; padding: 0.75rem 0.875rem; border-radius: 10px; border: 1px solid var(--border); background: var(--surface); color: var(--text); outline: none; }
.settings-toggle-row { display: flex; justify-content: space-between; gap: 1rem; align-items: center; margin-top: 1rem; padding: 0.85rem 1rem; border-radius: 10px; border: 1px solid var(--border); background: var(--surface); box-sizing: border-box; cursor: pointer; }
.settings-toggle-row strong, .settings-toggle-row small { display: block; }
.settings-toggle-row small { color: var(--text-muted); font-size: 0.75rem; margin-top: 0.25rem; }
.settings-toggle-row input { width: 18px; height: 18px; accent-color: var(--accent); }
.developer-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    min-width: 22px;
    padding: 0;
    border-radius: 50%;
    background: var(--surface-secondary);
    border: 1px solid var(--border);
    color: var(--accent);
    cursor: pointer;
    vertical-align: middle;
    flex-shrink: 0;
    box-shadow: none;
    transition: transform 0.15s ease, background 0.15s ease, border-color 0.15s ease;
    position: relative;
    top: -1px;
}
.developer-badge svg {
    color: var(--accent);
    stroke: var(--accent);
}
.developer-badge:hover {
    transform: scale(1.12);
    background: rgba(155, 108, 255, 0.15);
    border-color: var(--accent);
    box-shadow: none;
}
.developer-badge:active {
    transform: scale(0.92);
}
.profile-developer-badge { margin-left: 4px; }

/* Viboro Assistant badge — teal pill shown next to Viboro's display name */
.viboro-badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 2px 8px 2px 4px;
    border-radius: 20px;
    background: rgba(20, 184, 166, 0.15);
    border: 1px solid rgba(20, 184, 166, 0.4);
    color: #2dd4bf;
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.02em;
    white-space: nowrap;
    vertical-align: middle;
    flex-shrink: 0;
    position: relative;
    top: -1px;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s, transform 0.15s;
    user-select: none;
}
.viboro-badge-icon {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
    display: block;
}
.viboro-badge:hover {
    background: rgba(20, 184, 166, 0.28);
    border-color: #2dd4bf;
    transform: scale(1.03);
}

/* Dev Badge Info Modal */
#dev-badge-modal .dev-badge-hero {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    padding: 2rem 0 1rem;
}
#dev-badge-modal .dev-badge-icon-large {
    width: 72px;
    height: 72px;
    border-radius: 50%;
    background: var(--surface-secondary);
    border: 1.5px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: none;
}
#dev-badge-modal .dev-badge-icon-large svg {
    color: var(--accent);
    stroke: var(--accent);
}
#dev-badge-modal .dev-badge-title {
    font-size: 1.35rem;
    font-weight: 700;
    background: linear-gradient(135deg, #c084fc, #e9d5ff);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    text-align: center;
}
#dev-badge-modal .dev-badge-divider {
    width: 48px;
    height: 2px;
    border-radius: 2px;
    background: linear-gradient(90deg, #7c3aed, #c084fc);
    margin: 0.25rem auto 0;
}
#dev-badge-modal .dev-badge-body {
    text-align: center;
    color: var(--text-muted);
    font-size: 0.9rem;
    line-height: 1.65;
    padding: 0 0.5rem 0.5rem;
}
#dev-badge-modal .dev-badge-body strong {
    color: var(--text);
}
#dev-badge-modal .dev-badge-chips {
    display: flex;
    gap: 0.5rem;
    justify-content: center;
    flex-wrap: wrap;
    margin-top: 1.25rem;
}
#dev-badge-modal .dev-badge-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    background: rgba(124, 58, 237, 0.15);
    border: 1px solid rgba(168, 85, 247, 0.3);
    color: #c084fc;
    font-size: 0.75rem;
    font-weight: 600;
    padding: 0.3rem 0.7rem;
    border-radius: 999px;
}

/* Assistant Badge Info Modal (Teal Theme) */
#assistant-badge-modal .assistant-badge-hero {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    padding: 2rem 0 1rem;
}
#assistant-badge-modal .assistant-badge-icon-large {
    width: 76px;
    height: 76px;
    border-radius: 50%;
    background: rgba(20, 184, 166, 0.12);
    border: 2px solid rgba(45, 212, 191, 0.45);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 0 25px rgba(20, 184, 166, 0.3);
    overflow: hidden;
    padding: 3px;
}
#assistant-badge-modal .assistant-hero-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
    display: block;
}
#assistant-badge-modal .assistant-badge-title {
    font-size: 1.35rem;
    font-weight: 700;
    background: linear-gradient(135deg, #2dd4bf, #99f6e4);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    text-align: center;
}
#assistant-badge-modal .assistant-badge-divider {
    width: 48px;
    height: 2px;
    border-radius: 2px;
    background: linear-gradient(90deg, #0d9488, #2dd4bf);
    margin: 0.25rem auto 0;
}
#assistant-badge-modal .assistant-badge-body {
    text-align: center;
    color: var(--text-muted);
    font-size: 0.9rem;
    line-height: 1.65;
    padding: 0 0.5rem 0.5rem;
}
#assistant-badge-modal .assistant-badge-body strong {
    color: var(--text);
}
#assistant-badge-modal .assistant-badge-chips {
    display: flex;
    gap: 0.5rem;
    justify-content: center;
    flex-wrap: wrap;
    margin-top: 1.25rem;
}
#assistant-badge-modal .assistant-badge-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    background: rgba(20, 184, 166, 0.15);
    border: 1px solid rgba(45, 212, 191, 0.35);
    color: #2dd4bf;
    font-size: 0.75rem;
    font-weight: 600;
    padding: 0.3rem 0.7rem;
    border-radius: 999px;
}
#assistant-badge-modal .btn-assistant-close {
    background: linear-gradient(135deg, #0d9488, #14b8a6);
    border: none;
    color: #ffffff;
    box-shadow: 0 4px 15px rgba(20, 184, 166, 0.35);
}
#assistant-badge-modal .btn-assistant-close:hover {
    background: linear-gradient(135deg, #14b8a6, #2dd4bf);
}

.translation-badge { color: var(--text-muted); font-size: 0.7rem; }
.translate-toggle-btn { color: var(--text-muted); border-color: var(--border); background: var(--surface-secondary); }

@media (max-width: 768px) {
    #main-view { padding: 0; }
    .sidebar, .chat-area { border-radius: 0; border-left: 0; border-right: 0; }
    .composer-container { margin: 0 10px 10px; }
    .messages { padding: 18px 12px; }
}

/* Composer tools and GIF picker */
.composer-tools {
    display: contents;
}

.composer-more-btn {
    display: none;
}

.gif-btn {
    font-size: 0.62rem;
    font-weight: 800;
    letter-spacing: 0.02em;
    min-width: 38px;
}

.gif-picker-popup {
    position: absolute;
    right: 0;
    bottom: calc(100% + 10px);
    z-index: 1100;
    width: min(400px, calc(100vw - 24px));
    max-height: min(510px, calc(100vh - 150px));
    overflow: auto;
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: 16px;
    background: var(--surface);
    box-shadow: var(--shadow);
    backdrop-filter: blur(18px);
}

.gif-picker-popup[hidden] { display: none; }
.gif-picker-header, .gif-search-form { display: flex; align-items: center; gap: 8px; }
.gif-picker-header { justify-content: space-between; }
.gif-picker-actions { display: flex; align-items: center; gap: 4px; }
.gif-favorites-btn { color: #facc15; font-size: 1rem; }
.gif-search-form { margin-top: 10px; }
.gif-search-form input {
    min-width: 0;
    flex: 1;
    padding: 0.65rem 0.75rem;
    color: var(--text);
    background: var(--surface-secondary);
    border: 1px solid var(--border);
    border-radius: 10px;
}
.gif-search-form .btn-primary { padding: 0.62rem 0.8rem; }
.gif-picker-status { min-height: 18px; margin: 10px 2px 8px; color: var(--text-muted); font-size: 0.78rem; }
.gif-results { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
.gif-result-wrap { position: relative; min-width: 0; }
.gif-result { min-height: 78px; padding: 0; overflow: hidden; border: 1px solid transparent; border-radius: 9px; background: var(--surface-secondary); cursor: pointer; }
.gif-result:hover, .gif-result:focus-visible { border-color: var(--accent); outline: none; }
.gif-result img { display: block; width: 100%; height: 100%; min-height: 78px; object-fit: cover; }
.gif-favorite { position: absolute; top: 5px; right: 5px; width: 27px; height: 27px; padding: 0; border: 0; border-radius: 50%; background: rgba(10, 10, 15, 0.72); color: #fff; cursor: pointer; font-size: 0.9rem; opacity: 0; transition: opacity 0.15s, color 0.15s, transform 0.15s; }
.gif-result-wrap:hover .gif-favorite, .gif-favorite:focus-visible, .gif-favorite.is-favorite { opacity: 1; }
.gif-favorite.is-favorite { color: #facc15; }
.gif-favorite:hover { transform: scale(1.1); }
.gif-attribution { display: block; margin: 10px 2px 0; color: var(--text-muted); font-size: 0.62rem; text-align: right; }

@media (max-width: 768px) {
    .message-composer { position: relative; gap: 4px; }
    .composer-more-btn { display: inline-flex; flex: 0 0 auto; }
    .composer-tools {
        display: none;
        position: absolute;
        left: 6px;
        bottom: calc(100% + 8px);
        z-index: 20;
        align-items: center;
        gap: 4px;
        padding: 6px;
        border: 1px solid var(--border);
        border-radius: 14px;
        background: var(--surface);
        box-shadow: var(--shadow);
    }
    .composer-tools.is-open { display: flex; }
    #message-input { min-width: 0; padding-inline: 0.65rem; }
    .gif-picker-popup { right: -2px; width: min(400px, calc(100vw - 20px)); }
    .gif-results { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* ==========================================================
   Custom Form Validation (Red Underline & Error Text)
   ========================================================== */
.field-invalid {
    border-color: #ef4444 !important;
    border-bottom: 2px solid #ef4444 !important;
    box-shadow: 0 1px 0 0 #ef4444, 0 4px 14px rgba(239, 68, 68, 0.2) !important;
    outline: none !important;
}

.password-wrapper:has(.field-invalid) input {
    border-color: #ef4444 !important;
    border-bottom: 2px solid #ef4444 !important;
    box-shadow: 0 1px 0 0 #ef4444, 0 4px 14px rgba(239, 68, 68, 0.2) !important;
}

.field-error {
    display: flex;
    align-items: center;
    gap: 6px;
    color: #f87171;
    font-size: 0.78rem;
    font-weight: 500;
    margin-top: 0.35rem;
    margin-bottom: 0.55rem;
    line-height: 1.35;
    animation: fieldErrorSlideIn 0.2s ease-out forwards;
}

.field-error::before {
    content: '';
    display: inline-block;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #ef4444;
    box-shadow: 0 0 8px #ef4444;
    flex-shrink: 0;
}

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

/* ==========================================================
   Custom Animated PC Cursor (Purple Dot & Reactive Ring)
   ========================================================== */
@media (pointer: fine) {
    html.custom-cursor-enabled,
    html.custom-cursor-enabled body,
    html.custom-cursor-enabled button,
    html.custom-cursor-enabled a,
    html.custom-cursor-enabled input,
    html.custom-cursor-enabled select,
    html.custom-cursor-enabled textarea,
    html.custom-cursor-enabled [role="button"],
    html.custom-cursor-enabled * {
        cursor: none !important;
    }
}

#vibora-cursor,
#vibora-cursor-ring {
    position: fixed;
    top: 0;
    left: 0;
    pointer-events: none !important;
    z-index: 9999999;
    opacity: 0;
    will-change: transform, width, height, opacity;
    transition: opacity 0.25s ease, width 0.22s cubic-bezier(0.16, 1, 0.3, 1), height 0.22s cubic-bezier(0.16, 1, 0.3, 1), background-color 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}

/* Center Glowing Purple Dot */
#vibora-cursor {
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: #a855f7;
    box-shadow: 0 0 12px #a855f7, 0 0 24px rgba(168, 85, 247, 0.7);
}

/* Trailing Follower Ring / Aura */
#vibora-cursor-ring {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    border: 1.5px solid rgba(168, 85, 247, 0.5);
    background: rgba(140, 82, 255, 0.08);
    box-shadow: 0 0 16px rgba(140, 82, 255, 0.2);
    backdrop-filter: blur(1px);
    -webkit-backdrop-filter: blur(1px);
}

#vibora-cursor.is-active,
#vibora-cursor-ring.is-active {
    opacity: 1;
}

/* Hovering interactive elements: Expands smoothly */
body.cursor-hover #vibora-cursor {
    width: 12px;
    height: 12px;
    background: #c084fc;
    box-shadow: 0 0 16px #c084fc, 0 0 28px rgba(192, 132, 252, 0.9);
}

body.cursor-hover #vibora-cursor-ring {
    width: 54px;
    height: 54px;
    border-color: rgba(192, 132, 252, 0.9);
    background: rgba(168, 85, 247, 0.2);
    box-shadow: 0 0 26px rgba(168, 85, 247, 0.45);
}

/* Clicking / Mouse down: Bounces down and contracts */
body.cursor-clicking #vibora-cursor {
    background: #e9d5ff;
    box-shadow: 0 0 22px #e9d5ff;
}

body.cursor-clicking #vibora-cursor-ring {
    width: 24px;
    height: 24px;
    border-width: 2px;
    border-color: #e9d5ff;
    background: rgba(168, 85, 247, 0.45);
    box-shadow: 0 0 24px rgba(168, 85, 247, 0.65);
}

/* Hovering text fields / inputs: Precision indicator */
body.cursor-text #vibora-cursor {
    width: 3px;
    height: 20px;
    border-radius: 2px;
    background: #c084fc;
    box-shadow: 0 0 10px #c084fc;
}

body.cursor-text #vibora-cursor-ring {
    width: 22px;
    height: 30px;
    border-radius: 6px;
    border-color: rgba(168, 85, 247, 0.45);
    background: rgba(140, 82, 255, 0.06);
}

/* Discord-Style Emoji Autocomplete Popup */
.emoji-autocomplete-popup {
    position: absolute;
    bottom: 100%;
    left: 12px;
    margin-bottom: 8px;
    max-height: 230px;
    width: 290px;
    overflow-y: auto;
    border-radius: 12px;
    background: rgba(18, 18, 38, 0.96);
    border: 1px solid var(--border);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    z-index: 1200;
    box-shadow: 0 10px 36px rgba(0, 0, 0, 0.5), 0 0 1px rgba(140, 82, 255, 0.3);
    padding: 6px;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.emoji-autocomplete-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 7px 10px;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.12s ease, transform 0.1s ease;
    font-size: 0.88rem;
    color: var(--text);
}

.emoji-autocomplete-item:hover,
.emoji-autocomplete-item.selected {
    background: rgba(140, 82, 255, 0.28);
    color: #ffffff;
}

.emoji-autocomplete-left {
    display: flex;
    align-items: center;
    gap: 10px;
}

.emoji-autocomplete-char {
    font-size: 1.25rem;
    line-height: 1;
    min-width: 24px;
    text-align: center;
}

.emoji-autocomplete-code {
    font-family: var(--font-mono, monospace);
    color: var(--accent);
    font-weight: 500;
    font-size: 0.83rem;
}

.emoji-autocomplete-item.selected .emoji-autocomplete-code {
    color: #ffffff;
}

.emoji-autocomplete-hint {
    font-size: 0.72rem;
    color: var(--text-muted);
    opacity: 0.8;
}

/* ─── Voice Message Modal Redesign ────────────────────────── */
.voice-modal-content {
    max-width: 440px !important;
    padding: 1.75rem 2rem;
    border-radius: 20px;
    background: var(--surface);
    border: 1px solid var(--border);
    box-shadow: 0 24px 64px rgba(0, 0, 0, 0.7), 0 0 30px rgba(126, 75, 243, 0.2);
    color: var(--text);
    position: relative;
    overflow: hidden;
}

.voice-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.voice-modal-title {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    color: var(--text);
}

.voice-modal-title svg {
    color: var(--accent);
}

.voice-modal-title h3 {
    font-size: 1.15rem;
    font-weight: 600;
    margin: 0;
    letter-spacing: -0.01em;
}

.voice-modal-close {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 1.6rem;
    line-height: 1;
    padding: 0.25rem;
    cursor: pointer;
    border-radius: 8px;
    transition: color 0.15s, background-color 0.15s;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
}

.voice-modal-close:hover {
    color: var(--text);
    background: rgba(255, 255, 255, 0.08);
}

.voice-status-wrap {
    text-align: center;
    margin-bottom: 1rem;
}

.voice-status-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 12px;
    background: rgba(239, 68, 68, 0.15);
    border: 1px solid rgba(239, 68, 68, 0.35);
    color: #f87171;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    margin-bottom: 0.6rem;
}

.voice-rec-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #ef4444;
    animation: voiceRecPulse 1.2s infinite ease-in-out;
}

@keyframes voiceRecPulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.4; transform: scale(0.85); }
}

.voice-status-title {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 0.3rem;
}

.voice-status-desc {
    font-size: 0.88rem;
    color: var(--text-muted);
    margin: 0;
}

.voice-stage {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 0.5rem 0;
    min-height: 150px;
    position: relative;
    width: 100%;
}

.voice-btn-container {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0.5rem 0;
}

.voice-main-btn {
    width: 76px;
    height: 76px;
    border-radius: 50%;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: transform 0.2s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.2s ease;
    position: relative;
    z-index: 2;
    outline: none;
}

.voice-start-btn {
    background: linear-gradient(135deg, var(--accent), #9b6cff);
    color: #ffffff;
    box-shadow: 0 8px 24px rgba(126, 75, 243, 0.45);
}

.voice-start-btn:hover {
    transform: scale(1.08);
    box-shadow: 0 12px 30px rgba(126, 75, 243, 0.65);
}

.voice-stop-btn {
    background: linear-gradient(135deg, #ef4444, #dc2626);
    color: #ffffff;
    box-shadow: 0 8px 24px rgba(239, 68, 68, 0.45);
}

.voice-stop-btn:hover {
    transform: scale(1.08);
    box-shadow: 0 12px 30px rgba(239, 68, 68, 0.65);
}

.voice-pulse-ring {
    position: absolute;
    top: -10px;
    left: -10px;
    right: -10px;
    bottom: -10px;
    border-radius: 50%;
    border: 2px solid rgba(239, 68, 68, 0.6);
    animation: voiceRingPulse 1.8s cubic-bezier(0.2, 0.8, 0.2, 1) infinite;
    pointer-events: none;
}

@keyframes voiceRingPulse {
    0% { transform: scale(0.9); opacity: 0.9; }
    50% { transform: scale(1.35); opacity: 0.3; }
    100% { transform: scale(1.6); opacity: 0; }
}

.voice-timer {
    font-family: 'Space Grotesk', monospace, sans-serif;
    font-size: 1.6rem;
    font-weight: 700;
    color: var(--text);
    margin-top: 0.8rem;
    letter-spacing: 0.05em;
}

.voice-visualizer-container {
    width: 100%;
    max-width: 320px;
    height: 48px;
    margin: 0.5rem 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(22, 22, 42, 0.7);
    border: 1px solid rgba(126, 75, 243, 0.2);
    border-radius: 12px;
    padding: 6px 12px;
    overflow: hidden;
}

#voice-visualizer {
    width: 100%;
    height: 100%;
    display: block;
}

/* Custom Preview Card */
.voice-preview-card {
    width: 100%;
    background: var(--surface-secondary);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 1rem 1.2rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    margin: 0.5rem 0;
    box-shadow: inset 0 1px 1px rgba(255, 255, 255, 0.06);
}

.voice-preview-play-btn {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: var(--accent);
    color: #ffffff;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    flex-shrink: 0;
    transition: transform 0.15s, background-color 0.15s;
    box-shadow: 0 4px 14px rgba(126, 75, 243, 0.4);
}

.voice-preview-play-btn:hover {
    transform: scale(1.08);
    background: var(--accent-hover);
}

.voice-preview-track {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.voice-seek-slider {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 6px;
    background: rgba(255, 255, 255, 0.12);
    border-radius: 3px;
    outline: none;
    cursor: pointer;
    transition: background 0.2s;
}

.voice-seek-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--accent);
    cursor: pointer;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.4);
    transition: transform 0.15s;
}

.voice-seek-slider::-webkit-slider-thumb:hover {
    transform: scale(1.2);
}

.voice-preview-time-row {
    display: flex;
    justify-content: space-between;
    font-size: 0.78rem;
    color: var(--text-muted);
    font-family: 'Space Grotesk', monospace, sans-serif;
    font-weight: 500;
}

.voice-modal-actions {
    display: flex;
    gap: 0.75rem;
    justify-content: flex-end;
    align-items: center;
    margin-top: 1.25rem;
    padding-top: 0.75rem;
    border-top: 1px solid rgba(255, 255, 255, 0.06);
    width: 100%;
}


/* =====================================================================================
   Chat experience upgrade
   Message list · sidebar · rings · skeletons · lightbox · groups · statuses · motion
   ===================================================================================== */

:root {
    --ring-online: #22c55e;
    --ring-dnd: #ef4444;
    --ring-offline: rgba(136, 136, 170, 0.45);
    --skeleton-base: rgba(255, 255, 255, 0.05);
    --skeleton-shine: rgba(255, 255, 255, 0.11);
}

body.light-theme {
    --skeleton-base: rgba(0, 0, 0, 0.06);
    --skeleton-shine: rgba(0, 0, 0, 0.12);
    --ring-offline: rgba(80, 80, 110, 0.35);
}

kbd {
    display: inline-block;
    min-width: 1.5em;
    padding: 0.12em 0.45em;
    border: 1px solid var(--border);
    border-bottom-width: 2px;
    border-radius: 6px;
    background: var(--surface-secondary);
    color: var(--text);
    font: 600 0.74rem/1.3 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    text-align: center;
}

/* ── Shimmer skeletons ───────────────────────────────────────────────────────── */

@keyframes shimmer {
    from { background-position: 200% 0; }
    to { background-position: -200% 0; }
}

.skel-avatar,
.skel-lines i,
.skel-body i,
.skel-line,
.lp-skel-thumb,
.lp-skel-lines i {
    display: block;
    border-radius: 8px;
    background: linear-gradient(100deg, var(--skeleton-base) 30%, var(--skeleton-shine) 50%, var(--skeleton-base) 70%);
    background-size: 200% 100%;
    animation: shimmer 1.5s linear infinite;
}

.skel-avatar { width: 44px; height: 44px; border-radius: 50%; flex-shrink: 0; }
.skel-avatar.sm { width: 28px; height: 28px; }
.skel-lines { flex: 1; display: flex; flex-direction: column; gap: 8px; }
.skel-lines i { height: 11px; width: 80%; }
.skel-lines i:last-child { width: 55%; height: 9px; }
.skel-line { height: 44px; border-radius: 10px; margin-bottom: 8px; }

.dm-item.dm-skeleton { pointer-events: none; border-color: transparent; }

.message-skeleton {
    display: flex;
    align-items: flex-end;
    gap: 10px;
    max-width: 70%;
    padding: 0 0.25rem;
}
.message-skeleton.is-sent { align-self: flex-end; flex-direction: row-reverse; }
.skel-body { display: flex; flex-direction: column; gap: 6px; flex: 1; min-width: 0; }
.message-skeleton.is-sent .skel-body { align-items: flex-end; }
.skel-body .skel-name { width: 70px; height: 9px; }
.skel-body .skel-bubble { height: 38px; border-radius: 14px; min-width: 120px; max-width: 100%; }

.message-attachment.is-loading {
    min-width: 170px;
    min-height: 120px;
    background: linear-gradient(100deg, var(--skeleton-base) 30%, var(--skeleton-shine) 50%, var(--skeleton-base) 70%);
    background-size: 200% 100%;
    animation: shimmer 1.5s linear infinite;
}
.message-attachment.is-loading img { opacity: 0; }
.message-attachment img { transition: opacity 0.25s ease; }

/* ── Avatar rings (presence) ─────────────────────────────────────────────────── */

.avatar-ring {
    --ring-color: var(--ring-offline);
    display: inline-flex;
    flex-shrink: 0;
    border-radius: 50%;
    padding: 2px;
    background: var(--ring-color);
    line-height: 0;
    transition: background 0.3s ease, box-shadow 0.3s ease;
}
.avatar-ring > img {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid var(--surface);
    box-sizing: border-box;
}
.avatar-ring.is-online { --ring-color: var(--ring-online); box-shadow: 0 0 10px rgba(34, 197, 94, 0.35); }
.avatar-ring.is-dnd { --ring-color: var(--ring-dnd); box-shadow: 0 0 10px rgba(239, 68, 68, 0.3); }
.avatar-ring.is-offline { --ring-color: var(--ring-offline); }
.avatar-ring.is-group { --ring-color: linear-gradient(135deg, var(--accent), #38bdf8); }
.avatar-ring.is-self { --ring-color: var(--accent-soft); }
.avatar-ring:not(.is-online):not(.is-dnd):not(.is-offline):not(.is-group):not(.is-self) { padding: 0; background: none; }
.avatar-ring:not(.is-online):not(.is-dnd):not(.is-offline):not(.is-group):not(.is-self) > img { border: 0; }
.avatar-ring.is-group,
.avatar-ring.is-self { background: var(--ring-color); }

.chat-header .avatar-ring > img { width: 40px; height: 40px; border: 2px solid var(--surface); }
.dm-item .avatar-ring > img { width: 42px; height: 42px; border: 2px solid var(--surface); box-shadow: none; }
.user-profile .avatar-ring > img { width: 34px; height: 34px; border: 2px solid var(--surface); }
.gi-member .avatar-ring > img { width: 34px; height: 34px; }
.dm-avatar-wrap { position: relative; }
.dm-group-badge {
    position: absolute;
    right: -2px;
    bottom: -2px;
    width: 17px;
    height: 17px;
    display: grid;
    place-items: center;
    border-radius: 50%;
    background: var(--accent);
    color: #fff;
    border: 2px solid var(--surface);
}

/* ── Sidebar ─────────────────────────────────────────────────────────────────── */

.sidebar-search {
    position: relative;
    display: flex;
    align-items: center;
    margin: 10px 10px 2px;
}
.sidebar-search input {
    width: 100%;
    padding: 0.55rem 3.2rem 0.55rem 2.15rem;
    border-radius: 12px;
    border: 1px solid var(--border);
    background: var(--surface-secondary);
    color: var(--text);
    font-size: 0.86rem;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
}
.sidebar-search input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.sidebar-search input::-webkit-search-cancel-button { display: none; }
.sidebar-search-icon { position: absolute; left: 12px; color: var(--text-muted); pointer-events: none; }
.sidebar-search-hint { position: absolute; right: 8px; font-size: 0.64rem; opacity: 0.8; pointer-events: none; transition: opacity 0.2s; }
.sidebar-search input:focus ~ .sidebar-search-hint,
.sidebar-search input:not(:placeholder-shown) ~ .sidebar-search-hint { opacity: 0; }

.dm-item { position: relative; gap: 0.8rem; outline: none; }
.dm-item:focus-visible { box-shadow: inset 0 0 0 2px var(--accent); }
.dm-item .dm-info { min-width: 0; }
.dm-top { display: flex; align-items: baseline; gap: 6px; min-width: 0; }
.dm-top .dm-profile-name { flex: 1; min-width: 0; }
.dm-status-emoji { font-size: 0.8rem; flex-shrink: 0; }
.dm-time { flex-shrink: 0; font-size: 0.68rem; color: var(--text-muted); font-variant-numeric: tabular-nums; }
.dm-preview { display: block; margin-top: 2px; }
.dm-preview-you { color: var(--text); opacity: 0.8; }
.dm-preview-system { font-style: italic; opacity: 0.85; }
.dm-preview-empty { opacity: 0.7; font-style: italic; }
.dm-draft { color: #f87171; font-weight: 600; }
.dm-item.has-unread .dm-profile-name { font-weight: 800; }
.dm-item.has-unread .dm-preview { color: var(--text); font-weight: 600; }
.dm-item.has-unread .dm-time { color: var(--accent-hover); font-weight: 700; }
.dm-item .conversation-pin { opacity: 0; transition: opacity 0.15s; }
.dm-item:hover .conversation-pin, .dm-item:focus-within .conversation-pin, .dm-item .conversation-pin.is-pinned { opacity: 1; }
@media (hover: none) { .dm-item .conversation-pin { opacity: 1; } }

.sidebar-empty-card {
    margin: 14px 10px;
    padding: 1.25rem 1rem;
    border: 1px dashed var(--border);
    border-radius: 14px;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.84rem;
}
.sidebar-empty-card.is-compact { border-style: solid; border-color: transparent; padding: 1rem; }
.sidebar-empty-card h4 { color: var(--text); font-size: 1rem; margin: 0.25rem 0 0.35rem; }
.sidebar-empty-card p { margin-bottom: 0.9rem; line-height: 1.45; }
.sidebar-empty-card.is-compact p { margin: 0; }
.sidebar-empty-art { font-size: 2rem; animation: wave 2.4s ease-in-out infinite; transform-origin: 70% 70%; }
@keyframes wave { 0%, 60%, 100% { transform: rotate(0); } 10%, 30% { transform: rotate(14deg); } 20%, 40% { transform: rotate(-8deg); } 50% { transform: rotate(10deg); } }

.push-prompt {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 8px 10px 0;
    padding: 0.55rem 0.7rem;
    border-radius: 12px;
    background: var(--accent-soft);
    border: 1px solid var(--border);
    font-size: 0.78rem;
}
.push-prompt[hidden] { display: none; }
.push-prompt-text { flex: 1; line-height: 1.3; }
.push-prompt-btn { border: 0; border-radius: 8px; padding: 0.3rem 0.65rem; background: var(--accent); color: #fff; font-weight: 600; cursor: pointer; }
.push-prompt-close { border: 0; background: none; color: var(--text-muted); font-size: 1.1rem; cursor: pointer; line-height: 1; }

.sidebar-footer { min-height: 62px; }
.user-profile { min-width: 0; flex: 1; }
.user-profile img { width: auto; height: auto; }
.user-profile-text { display: flex; flex-direction: column; align-items: flex-start; min-width: 0; line-height: 1.25; }
.user-profile-text .profile-link { max-width: 150px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; font-size: 0.9rem; }
.status-chip {
    border: 0;
    background: none;
    padding: 1px 0;
    max-width: 150px;
    cursor: pointer;
    color: var(--text-muted);
    font-size: 0.74rem;
    text-align: left;
}
.status-chip:hover { color: var(--text); }
.status-chip-text { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.status-chip-text.is-placeholder { opacity: 0.8; }
.status-chip[data-mode="dnd"] .status-chip-text.is-placeholder { color: var(--ring-dnd); }

/* ── Empty states ────────────────────────────────────────────────────────────── */

.empty-welcome {
    max-width: 380px;
    padding: 2rem;
    text-align: center;
    color: var(--text-muted);
}
.empty-welcome-logo { width: 64px; height: 64px; margin-bottom: 0.75rem; opacity: 0.9; animation: floaty 5s ease-in-out infinite; }
@keyframes floaty { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-6px); } }
.empty-welcome h2 { color: var(--text); font-size: 1.35rem; margin-bottom: 0.4rem; }
.empty-welcome p { line-height: 1.5; font-size: 0.9rem; }
.empty-welcome-actions { display: flex; gap: 0.6rem; justify-content: center; margin: 1.25rem 0 1rem; flex-wrap: wrap; }
.empty-welcome-actions .btn-primary, .empty-welcome-actions .btn-secondary { width: auto; padding: 0.6rem 1.1rem; }
.empty-welcome-actions [hidden] { display: none; }
.empty-welcome-hint { font-size: 0.78rem; opacity: 0.85; }

/* ── Chat header ─────────────────────────────────────────────────────────────── */

.chat-header-info .chat-presence-status { font-size: 0.74rem; }
.chat-presence-status.is-dnd { color: var(--ring-dnd); font-weight: 600; }
.chat-status-line { display: block; font-size: 0.74rem; color: var(--text-muted); margin-top: 1px; max-width: 280px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-status-line[hidden] { display: none; }
.is-group-link { cursor: pointer; }
.chat-header .chat-search-container { gap: 0.25rem; }

/* ── Pinned message banner ───────────────────────────────────────────────────── */

.pinned-banner {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.4rem 1rem 0.4rem 1.25rem;
    background: linear-gradient(90deg, var(--accent-soft), transparent 85%);
    border-bottom: 1px solid var(--border);
    animation: slideDownIn 0.25s ease-out;
}
.pinned-banner[hidden] { display: none; }
@keyframes slideDownIn { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: translateY(0); } }
.pb-icon { color: var(--accent-hover); display: grid; place-items: center; }
.pb-body { flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: flex-start; gap: 1px; border: 0; background: none; color: inherit; text-align: left; cursor: pointer; padding: 0.1rem 0; }
.pb-label { font-size: 0.68rem; font-weight: 700; letter-spacing: 0.05em; text-transform: uppercase; color: var(--accent-hover); }
.pb-label em { font-style: normal; font-weight: 500; opacity: 0.8; text-transform: none; letter-spacing: 0; }
.pb-text { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 0.84rem; color: var(--text); }
.pb-text strong { color: var(--text-muted); font-weight: 600; }
.pb-btn { border: 0; background: none; color: var(--text-muted); width: 26px; height: 26px; border-radius: 8px; display: grid; place-items: center; cursor: pointer; }
.pb-btn:hover { background: var(--surface-hover); color: var(--text); }
.pb-body:hover .pb-text { text-decoration: underline; text-decoration-color: var(--border); }

/* ── Message list ────────────────────────────────────────────────────────────── */

.messages-wrap {
    position: relative;
    flex: 1 1 0%;
    min-height: 0;
    display: flex;
    flex-direction: column;
}
.messages-wrap > .messages { flex: 1 1 0%; }
.messages { scroll-behavior: auto; overscroll-behavior: contain; }

/* Animate only genuinely new messages — restored / re-attached ones must not replay it. */
.message { animation: none; touch-action: pan-y; }
.message.is-new { animation: messageIn 0.24s ease-out both; }
.vlist-spacer { flex: none; pointer-events: none; }

/* Tighter groups: consecutive messages from one person read as a single cluster. */
.message.merged { margin-top: -1.05rem; }
.message.received.merged .message-bubble { border-top-left-radius: 6px; }
.message.sent.merged .message-bubble { border-top-right-radius: 6px; }
.message-pinned-icon { font-size: 0.78rem; color: var(--accent); margin-top: 0.2rem; }
.message-attachment-file small { margin-left: auto; padding-left: 0.75rem; color: var(--text-muted); white-space: nowrap; }
.forwarded-label { display: flex; align-items: center; gap: 5px; margin: 0 0.4rem 0.25rem; font-size: 0.72rem; color: var(--text-muted); font-style: italic; }
.forwarded-label strong { font-style: normal; font-weight: 600; }
.message.sent .forwarded-label { justify-content: flex-end; }

.day-separator,
.unread-divider {
    display: flex;
    align-items: center;
    gap: 0.9rem;
    flex: none;
    margin: 0.4rem 0;
    color: var(--text-muted);
    font-size: 0.74rem;
    font-weight: 600;
    user-select: none;
}
.day-separator::before, .day-separator::after,
.unread-divider::before, .unread-divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--border);
}
.day-separator span {
    padding: 0.22rem 0.8rem;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: var(--surface-secondary);
    letter-spacing: 0.02em;
}
.unread-divider { color: #f87171; }
.unread-divider::before, .unread-divider::after { background: rgba(248, 113, 113, 0.45); }
.unread-divider span { text-transform: uppercase; font-size: 0.68rem; letter-spacing: 0.08em; }

.message.system-message {
    align-self: center;
    max-width: 90%;
    padding: 0;
    text-align: center;
    flex: none;
}
.system-message-text {
    display: inline-block;
    padding: 0.28rem 0.85rem;
    border-radius: 999px;
    background: var(--surface-secondary);
    border: 1px solid var(--border);
    color: var(--text-muted);
    font-size: 0.76rem;
}

.messages-error {
    margin: auto;
    text-align: center;
    color: var(--text-muted);
}
.messages-error p { margin-bottom: 0.75rem; }
.messages-error .btn-primary { width: auto; padding: 0.55rem 1.2rem; }

.e2ee-chat-banner[hidden] { display: none; }

.message.is-menu-target .message-bubble { box-shadow: 0 0 0 2px var(--accent), 0 8px 24px rgba(0, 0, 0, 0.3); }
.message.highlight-flash .message-bubble { animation: highlightFlash 1.5s ease-out; }
.message-actions-btn { padding: 0; }

/* Message hover reveals the exact time even on grouped messages */
.message-hover-timestamp { pointer-events: auto; cursor: default; }

/* Swipe-to-reply affordance */
.message.is-swiping { will-change: transform; }
.swipe-reply-icon {
    position: absolute;
    left: 0;
    top: 50%;
    width: 30px;
    height: 30px;
    display: grid;
    place-items: center;
    border-radius: 50%;
    background: var(--surface-secondary);
    border: 1px solid var(--border);
    color: var(--text-muted);
    opacity: 0;
    transform: translate(-18px, -50%) scale(0.6);
    pointer-events: none;
    transition: background 0.15s, color 0.15s;
}
.swipe-reply-icon.is-armed { background: var(--accent); border-color: var(--accent); color: #fff; }

/* ── Read receipts: in the flow, under the bubble ────────────────────────────── */

.msg-receipt-badge {
    position: relative;
    right: auto;
    bottom: auto;
    align-self: flex-end;
    margin: 3px 4px 0 0;
    gap: 0;
    animation: receipt-slide 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}
@keyframes receipt-slide { from { opacity: 0; transform: translateY(-5px) scale(0.8); } to { opacity: 1; transform: none; } }
.receipt-avatar { width: 15px; height: 15px; }
.receipt-more { margin-left: 3px; font-size: 0.64rem; font-weight: 700; color: var(--text-muted); }
.seen-by-popover { bottom: auto; top: calc(100% + 6px); }
.seen-by-popover-list li time { margin-left: auto; padding-left: 10px; font-size: 0.68rem; color: var(--text-muted); }

/* ── Reaction motion ─────────────────────────────────────────────────────────── */

.reaction-badge { position: relative; overflow: visible; transition: background 0.2s, border-color 0.2s, transform 0.15s; }
.reaction-badge:active { transform: scale(0.92); }
.reaction-badge.pop { animation: reactionPop 0.42s cubic-bezier(0.34, 1.7, 0.5, 1); }
@keyframes reactionPop {
    0% { transform: scale(0.6); }
    55% { transform: scale(1.28); }
    100% { transform: scale(1); }
}
.reaction-particle {
    position: absolute;
    left: 50%;
    top: 30%;
    font-size: var(--size, 0.9rem);
    pointer-events: none;
    opacity: 0;
    animation: reactionFloat 0.95s cubic-bezier(0.2, 0.7, 0.3, 1) var(--delay, 0ms) forwards;
    z-index: 20;
}
@keyframes reactionFloat {
    0% { opacity: 0; transform: translate(-50%, 0) scale(0.4) rotate(0); }
    15% { opacity: 1; }
    100% { opacity: 0; transform: translate(calc(-50% + var(--dx)), var(--dy)) scale(1) rotate(var(--rot)); }
}
.quick-react-btn { transition: transform 0.14s cubic-bezier(0.34, 1.7, 0.5, 1); }
.quick-react-btn:hover { transform: scale(1.35) translateY(-2px); }

/* ── Link preview cards ──────────────────────────────────────────────────────── */

.link-preview { display: block; max-width: 340px; padding: 0; border: 0; background: none; margin-top: 0.6rem; }
.link-preview.is-loading { opacity: 0.9; }
.lp-card {
    display: flex;
    overflow: hidden;
    color: inherit !important;
    text-decoration: none !important;
    border: 1px solid var(--border);
    border-left: 3px solid var(--lp-accent, var(--accent));
    border-radius: 10px;
    background: rgba(0, 0, 0, 0.18);
    transition: border-color 0.2s, transform 0.2s, background 0.2s;
}
.lp-card:hover { background: rgba(0, 0, 0, 0.28); transform: translateY(-1px); text-decoration: none !important; }
.message.sent .lp-card { background: rgba(0, 0, 0, 0.24); border-color: rgba(255, 255, 255, 0.22); border-left-color: rgba(255, 255, 255, 0.7); }
.lp-media { position: relative; display: block; flex-shrink: 0; overflow: hidden; }
.lp-small .lp-media { width: 88px; }
.lp-small .lp-thumb { width: 88px; height: 100%; min-height: 88px; object-fit: cover; display: block; }
.lp-large { flex-direction: column; }
.lp-large .lp-media { width: 100%; }
.lp-large .lp-thumb { width: 100%; max-height: 180px; object-fit: cover; display: block; }
.link-preview .lp-card img { width: auto; min-height: 0; }
.link-preview .lp-small img.lp-thumb, .link-preview .lp-large img.lp-thumb { width: 100%; }
.lp-play { position: absolute; inset: 0; display: grid; place-items: center; color: #fff; font-size: 1.6rem; background: rgba(0, 0, 0, 0.28); text-shadow: 0 2px 8px rgba(0, 0, 0, 0.6); }
.lp-copy { display: flex; flex-direction: column; gap: 0.2rem; min-width: 0; padding: 0.55rem 0.7rem; }
.lp-site { display: flex; align-items: center; gap: 5px; font-size: 0.68rem; font-weight: 600; letter-spacing: 0.02em; color: var(--accent-hover); text-transform: uppercase; }
.message.sent .lp-site { color: rgba(255, 255, 255, 0.82); }
.lp-favicon { width: 14px; height: 14px; border-radius: 3px; object-fit: contain; }
.lp-title { font-size: 0.86rem; line-height: 1.3; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; color: var(--text); }
.message.sent .lp-title { color: #fff; }
.lp-desc { font-size: 0.76rem; line-height: 1.35; color: var(--text-muted); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; white-space: normal; }
.message.sent .lp-desc { color: rgba(255, 255, 255, 0.8); }
.lp-image { flex-direction: column; border-left-width: 1px; }
.lp-image img { display: block; width: 100% !important; max-height: 240px; object-fit: cover; }
.lp-skeleton { display: flex; gap: 10px; padding: 0.5rem; border: 1px solid var(--border); border-radius: 10px; width: 300px; max-width: 100%; }
.lp-skel-thumb { width: 64px; height: 64px; flex-shrink: 0; }
.lp-skel-lines { flex: 1; display: flex; flex-direction: column; gap: 8px; justify-content: center; }
.lp-skel-lines i { height: 9px; width: 90%; }
.lp-skel-lines i:nth-child(2) { width: 70%; }
.lp-skel-lines i:nth-child(3) { width: 45%; }

/* ── Scroll to latest ────────────────────────────────────────────────────────── */

.scroll-bottom-btn {
    position: absolute;
    right: 22px;
    bottom: 16px;
    z-index: 15;
    width: 42px;
    height: 42px;
    display: grid;
    place-items: center;
    border-radius: 50%;
    border: 1px solid var(--border);
    background: var(--surface-secondary);
    color: var(--text);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
    cursor: pointer;
    opacity: 0;
    transform: translateY(12px) scale(0.85);
    pointer-events: none;
    transition: opacity 0.2s ease, transform 0.25s cubic-bezier(0.16, 1, 0.3, 1), background 0.2s;
}
.scroll-bottom-btn[hidden] { display: grid; }
.scroll-bottom-btn.is-visible { opacity: 1; transform: none; pointer-events: auto; }
.scroll-bottom-btn:hover { background: var(--accent); border-color: var(--accent); color: #fff; }
.scroll-bottom-badge {
    position: absolute;
    top: -7px;
    right: -5px;
    min-width: 20px;
    height: 20px;
    padding: 0 5px;
    display: grid;
    place-items: center;
    border-radius: 999px;
    background: #ef4444;
    color: #fff;
    font-size: 0.68rem;
    font-weight: 700;
    border: 2px solid var(--background);
    animation: reactionPop 0.35s ease-out;
}
.scroll-bottom-badge[hidden] { display: none; }

/* ── Composer ────────────────────────────────────────────────────────────────── */

.char-counter { position: relative; display: grid; place-items: center; width: 26px; height: 26px; flex-shrink: 0; align-self: center; font-size: 0.6rem; font-weight: 700; color: var(--text-muted); }
.char-counter[hidden] { display: none; }
.char-counter svg { position: absolute; inset: 0; transform: rotate(-90deg); }
.char-ring-track { fill: none; stroke: var(--border); stroke-width: 2.4; }
.char-ring-fill { fill: none; stroke: var(--accent); stroke-width: 2.4; stroke-linecap: round; transition: stroke-dashoffset 0.12s linear, stroke 0.2s; }
.char-counter.is-warn { color: #f59e0b; }
.char-counter.is-warn .char-ring-fill { stroke: #f59e0b; }
.char-counter.is-limit { color: var(--error); }
.char-counter.is-limit .char-ring-fill { stroke: var(--error); }
.char-counter.is-limit { animation: reactionPop 0.3s ease-out; }

.attachment-preview.is-file {
    width: auto;
    max-width: 220px;
    height: 48px;
    padding: 0 28px 0 10px;
    gap: 8px;
    justify-content: flex-start;
    text-align: left;
}
.attachment-file-icon { font-size: 1.2rem; }
.attachment-file-meta { display: flex; flex-direction: column; min-width: 0; line-height: 1.25; }
.attachment-file-meta strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 0.76rem; }
.attachment-file-meta small { color: var(--text-muted); font-size: 0.68rem; }
.attachment-preview.is-file .remove-attachment { top: 50%; right: 6px; transform: translateY(-50%); }
.attachment-preview .remove-attachment { opacity: 0.9; }

.composer-container { padding-bottom: env(safe-area-inset-bottom, 0); }

/* ── Lightbox ────────────────────────────────────────────────────────────────── */

body.lightbox-open { overflow: hidden; }
.lb {
    --lb-dim: 1;
    position: fixed;
    inset: 0;
    z-index: 5000;
    display: flex;
    flex-direction: column;
    opacity: 0;
    transition: opacity 0.2s ease;
}
.lb[hidden] { display: none; }
.lb.is-open { opacity: 1; }
.lb-backdrop { position: absolute; inset: 0; background: rgba(5, 5, 12, calc(0.92 * var(--lb-dim))); backdrop-filter: blur(10px); }
.lb-bar {
    position: relative;
    z-index: 2;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: calc(0.75rem + env(safe-area-inset-top, 0)) 1rem 0.75rem;
    background: linear-gradient(to bottom, rgba(0, 0, 0, 0.55), transparent);
    color: #fff;
}
.lb-meta { display: flex; flex-direction: column; min-width: 0; }
.lb-name { font-size: 0.92rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lb-sub { font-size: 0.74rem; opacity: 0.7; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lb-actions { display: flex; align-items: center; gap: 0.25rem; flex-shrink: 0; }
.lb-btn {
    min-width: 38px;
    height: 38px;
    padding: 0 0.5rem;
    display: grid;
    place-items: center;
    border: 0;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.08);
    color: #fff;
    cursor: pointer;
    text-decoration: none;
    transition: background 0.15s;
}
.lb-btn:hover { background: rgba(255, 255, 255, 0.2); }
.lb-zoom-label { font-size: 0.74rem; font-weight: 600; min-width: 52px; font-variant-numeric: tabular-nums; }
.lb-stage {
    position: relative;
    z-index: 1;
    flex: 1;
    min-height: 0;
    display: grid;
    place-items: center;
    overflow: hidden;
    touch-action: none;
    cursor: zoom-in;
}
.lb.is-zoomed .lb-stage { cursor: grab; }
.lb.is-zoomed .lb-stage:active { cursor: grabbing; }
.lb-img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    user-select: none;
    -webkit-user-drag: none;
    transform-origin: center;
    will-change: transform;
    transition: opacity 0.2s;
}
.lb-img.is-loading { opacity: 0; }
.lb-spinner { position: absolute; width: 34px; height: 34px; border-radius: 50%; border: 3px solid rgba(255, 255, 255, 0.2); border-top-color: #fff; animation: spin 0.8s linear infinite; }
.lb-spinner[hidden] { display: none; }
.lb-nav {
    position: absolute;
    top: 50%;
    z-index: 3;
    width: 46px;
    height: 46px;
    transform: translateY(-50%);
    display: grid;
    place-items: center;
    border: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
    cursor: pointer;
    backdrop-filter: blur(6px);
    transition: background 0.15s, transform 0.15s;
}
.lb-nav:hover { background: rgba(255, 255, 255, 0.25); transform: translateY(-50%) scale(1.08); }
.lb-nav[hidden] { display: none; }
.lb-prev { left: 1rem; }
.lb-next { right: 1rem; }
.lb-counter { position: absolute; z-index: 3; left: 50%; bottom: 82px; transform: translateX(-50%); padding: 0.18rem 0.7rem; border-radius: 999px; background: rgba(0, 0, 0, 0.5); color: #fff; font-size: 0.74rem; font-variant-numeric: tabular-nums; }
.lb-counter:empty { display: none; }
.lb-strip {
    position: relative;
    z-index: 3;
    display: flex;
    gap: 6px;
    justify-content: safe center;
    overflow-x: auto;
    padding: 0.6rem 1rem calc(0.6rem + env(safe-area-inset-bottom, 0));
    background: linear-gradient(to top, rgba(0, 0, 0, 0.6), transparent);
}
.lb-strip[hidden] { display: none; }
.lb-thumb { flex: none; width: 52px; height: 52px; padding: 0; border: 2px solid transparent; border-radius: 8px; overflow: hidden; background: #000; opacity: 0.55; cursor: pointer; transition: opacity 0.15s, border-color 0.15s, transform 0.15s; }
.lb-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.lb-thumb:hover { opacity: 0.9; }
.lb-thumb.is-active { opacity: 1; border-color: var(--accent-hover); transform: translateY(-2px); }
@media (max-width: 640px) {
    .lb-nav { display: none; }
    .lb-zoom-label, [data-act="zoom-out"], [data-act="zoom-in"] { display: none; }
    .lb-counter { bottom: 76px; }
}

/* ── Group / status / forward modals ─────────────────────────────────────────── */

.group-modal { width: min(440px, calc(100vw - 24px)); max-height: min(680px, calc(100dvh - 32px)); display: flex; flex-direction: column; gap: 0.5rem; overflow-y: auto; text-align: left; }
.gm-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 0.25rem; }
.gm-header h3 { margin: 0; font-size: 1.15rem; }
.gm-close { font-size: 1.5rem; line-height: 1; padding: 0.15rem 0.55rem; }
.gm-label { font-size: 0.74rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-muted); margin-top: 0.4rem; }
.gm-optional { text-transform: none; letter-spacing: 0; font-weight: 400; opacity: 0.8; }
.group-modal input[type="text"], .group-modal input[type="search"] { width: 100%; padding: 0.65rem 0.85rem; border-radius: 10px; }
.gm-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.gm-chips:empty { display: none; }
.gm-chip { display: inline-flex; align-items: center; gap: 6px; padding: 2px 8px 2px 3px; border: 1px solid var(--border); border-radius: 999px; background: var(--accent-soft); color: var(--text); font-size: 0.78rem; cursor: pointer; }
.gm-chip img { width: 20px; height: 20px; border-radius: 50%; object-fit: cover; }
.gm-chip:hover { border-color: var(--accent); }
.gm-list { display: flex; flex-direction: column; gap: 2px; max-height: 260px; min-height: 80px; overflow-y: auto; padding-right: 2px; }
.gm-friend { position: relative; display: flex; align-items: center; gap: 0.7rem; padding: 0.5rem 0.6rem; border-radius: 10px; cursor: pointer; transition: background 0.15s; }
.gm-friend[hidden] { display: none; }
.gm-friend:hover { background: var(--surface-hover); }
.gm-friend input { position: absolute; opacity: 0; pointer-events: none; }
.gm-friend img { width: 36px; height: 36px; border-radius: 50%; object-fit: cover; flex-shrink: 0; }
.gm-friend-text { display: flex; flex-direction: column; min-width: 0; flex: 1; line-height: 1.25; }
.gm-friend-text strong { font-size: 0.9rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.gm-friend-text small { color: var(--text-muted); font-size: 0.74rem; }
.gm-check { width: 20px; height: 20px; border-radius: 50%; border: 2px solid var(--border); display: grid; place-items: center; flex-shrink: 0; transition: background 0.15s, border-color 0.15s; }
.gm-friend input:checked ~ .gm-check { background: var(--accent); border-color: var(--accent); }
.gm-friend input:checked ~ .gm-check::after { content: ''; width: 5px; height: 9px; margin-top: -2px; border: solid #fff; border-width: 0 2px 2px 0; transform: rotate(45deg); }
.gm-friend input:focus-visible ~ .gm-check { outline: 2px solid var(--accent-hover); outline-offset: 2px; }
.gm-friend input:disabled ~ * { opacity: 0.45; }
.gm-empty { padding: 1.25rem 0.5rem; text-align: center; color: var(--text-muted); font-size: 0.86rem; }
.gm-empty .btn-primary { width: auto; margin-top: 0.75rem; padding: 0.5rem 1.1rem; }
.gm-loading { padding: 0.25rem 0; }
.gm-error { min-height: 1.1rem; margin: 0; color: var(--error); font-size: 0.8rem; }
.gm-footer { display: flex; align-items: center; justify-content: flex-end; gap: 0.5rem; margin-top: 0.4rem; }
.gm-footer .btn-primary, .gm-footer .btn-secondary { width: auto; padding: 0.55rem 1.1rem; }
.gm-count { margin-right: auto; font-size: 0.78rem; color: var(--text-muted); }
.btn-primary:disabled { opacity: 0.45; cursor: not-allowed; box-shadow: none; }

.gi-hero { display: flex; align-items: center; gap: 0.9rem; padding: 0.4rem 0 0.2rem; }
.gi-avatar { width: 64px; height: 64px; border-radius: 18px; object-fit: cover; }
.gi-name-wrap { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.gi-name-wrap input { font-size: 1.05rem; font-weight: 700; background: transparent; border: 1px solid transparent; padding: 0.35rem 0.5rem; margin-left: -0.5rem; border-radius: 8px; }
.gi-name-wrap input:hover { border-color: var(--border); }
.gi-name-wrap input:focus { border-color: var(--accent); background: var(--surface-secondary); outline: none; }
.gi-sub { font-size: 0.78rem; color: var(--text-muted); }
.gi-section-title { display: flex; align-items: center; justify-content: space-between; margin-top: 0.5rem; font-size: 0.74rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-muted); }
.gi-link { border: 0; background: none; color: var(--accent-hover); font-size: 0.78rem; font-weight: 600; cursor: pointer; text-transform: none; letter-spacing: 0; }
.gi-link:hover { text-decoration: underline; }
.gi-add { padding: 0.6rem; border: 1px solid var(--border); border-radius: 12px; background: var(--surface-secondary); display: flex; flex-direction: column; gap: 0.5rem; }
.gi-add[hidden] { display: none; }
.gi-members { display: flex; flex-direction: column; gap: 2px; max-height: 300px; overflow-y: auto; }
.gi-member { display: flex; align-items: center; gap: 0.4rem; border-radius: 10px; }
.gi-member:hover { background: var(--surface-hover); }
.gi-member-main { flex: 1; min-width: 0; display: flex; align-items: center; gap: 0.7rem; padding: 0.4rem 0.5rem; border-radius: 10px; }
.gi-member-main:hover { text-decoration: none; }
.gi-member-text { display: flex; flex-direction: column; min-width: 0; line-height: 1.25; }
.gi-member-text strong { font-size: 0.9rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.gi-member-text strong em { font-style: normal; font-weight: 400; color: var(--text-muted); }
.gi-member-text small { color: var(--text-muted); font-size: 0.74rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.gi-badge { padding: 1px 8px; border-radius: 999px; background: var(--accent-soft); color: var(--accent-hover); font-size: 0.66rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; }
.gi-remove { border: 0; background: none; color: var(--text-muted); width: 28px; height: 28px; margin-right: 4px; border-radius: 8px; font-size: 1.2rem; cursor: pointer; line-height: 1; }
.gi-remove:hover { background: rgba(239, 68, 68, 0.15); color: #f87171; }
.btn-danger-outline { margin-top: 0.6rem; padding: 0.65rem; border-radius: 10px; border: 1px solid rgba(239, 68, 68, 0.5); background: transparent; color: #f87171; font-weight: 600; cursor: pointer; transition: background 0.15s; }
.btn-danger-outline:hover { background: rgba(239, 68, 68, 0.12); }

.st-input-row { display: flex; align-items: center; gap: 0.5rem; padding: 0.2rem; border: 1px solid var(--border); border-radius: 12px; background: var(--surface-secondary); }
.st-input-row:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.st-input-row input[type="text"] { border: 0 !important; background: transparent !important; box-shadow: none !important; outline: none; flex: 1; }
.st-emoji-btn { width: 40px; height: 40px; border: 0; border-radius: 10px; background: var(--surface); font-size: 1.3rem; cursor: pointer; }
.st-emoji-btn.is-empty { opacity: 0.5; filter: grayscale(1); }
.st-emoji-btn:hover { background: var(--surface-hover); }
.st-counter { padding-right: 0.6rem; font-size: 0.72rem; color: var(--text-muted); min-width: 1.4rem; text-align: right; }
.st-emoji-grid { display: grid; grid-template-columns: repeat(8, 1fr); gap: 2px; padding: 0.4rem; border: 1px solid var(--border); border-radius: 12px; background: var(--surface-secondary); }
.st-emoji-grid[hidden] { display: none; }
.st-emoji-grid button { border: 0; background: none; border-radius: 8px; font-size: 1.25rem; padding: 0.3rem 0; cursor: pointer; }
.st-emoji-grid button:hover { background: var(--surface-hover); transform: scale(1.15); }
.st-presets { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 0.25rem; }
.st-preset { border: 1px solid var(--border); background: transparent; color: var(--text); border-radius: 999px; padding: 0.3rem 0.7rem; font-size: 0.78rem; cursor: pointer; transition: background 0.15s, border-color 0.15s; }
.st-preset:hover { background: var(--accent-soft); border-color: var(--accent); }
.st-modes { display: flex; flex-direction: column; gap: 4px; }
.st-mode { display: flex; align-items: center; gap: 0.7rem; padding: 0.55rem 0.7rem; border: 1px solid var(--border); border-radius: 12px; cursor: pointer; transition: border-color 0.15s, background 0.15s; }
.st-mode:hover { background: var(--surface-hover); }
.st-mode input { position: absolute; opacity: 0; pointer-events: none; }
.st-mode:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.st-mode:has(input:focus-visible) { outline: 2px solid var(--accent-hover); outline-offset: 2px; }
.st-mode-dot { width: 12px; height: 12px; border-radius: 50%; flex-shrink: 0; }
.st-online { background: var(--ring-online); }
.st-dnd { background: var(--ring-dnd); }
.st-invisible { background: transparent; border: 2px solid var(--ring-offline); }
.st-mode-text { display: flex; flex-direction: column; line-height: 1.3; }
.st-mode-text strong { font-size: 0.88rem; }
.st-mode-text small { color: var(--text-muted); font-size: 0.74rem; }

.fw-preview { margin: 0; padding: 0.55rem 0.75rem; border-left: 3px solid var(--accent); border-radius: 0 10px 10px 0; background: var(--surface-secondary); color: var(--text-muted); font-size: 0.84rem; max-height: 5.5rem; overflow: hidden; display: flex; flex-direction: column; gap: 2px; }
.fw-preview em { font-size: 0.74rem; color: var(--accent-hover); }

.shortcut-list { display: flex; flex-direction: column; gap: 2px; margin: 0.25rem 0 0; }
.shortcut-row { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: 0.5rem 0.25rem; border-bottom: 1px solid var(--border); font-size: 0.86rem; }
.shortcut-row:last-child { border-bottom: 0; }
.shortcut-row dt { color: var(--text); }
.shortcut-row dd { margin: 0; white-space: nowrap; color: var(--text-muted); }

/* ── Phones: context menu becomes a bottom sheet ────────────────────────────── */

.context-menu-backdrop { position: fixed; inset: 0; z-index: 1999; background: rgba(0, 0, 0, 0.5); backdrop-filter: blur(2px); animation: fadeIn 0.18s ease-out; }
.context-menu-backdrop[hidden] { display: none; }

@media (max-width: 768px) {
    .context-menu {
        left: 0 !important;
        right: 0 !important;
        top: auto !important;
        bottom: 0 !important;
        width: 100%;
        max-width: 100%;
        padding: 0.75rem 0.75rem calc(0.75rem + env(safe-area-inset-bottom, 0));
        border-radius: 20px 20px 0 0;
        transform-origin: bottom center;
        animation: sheetUp 0.26s cubic-bezier(0.16, 1, 0.3, 1);
    }
    .context-menu::before { content: ''; display: block; width: 38px; height: 4px; margin: 0 auto 0.6rem; border-radius: 4px; background: var(--border); }
    .context-menu .menu-reactions-bar { padding: 4px 2px 10px !important; }
    .context-menu .quick-react-btn { font-size: 1.5rem; padding: 0.35rem; }
    .context-menu .menu-item { padding: 0.85rem 0.9rem; font-size: 1rem; border-radius: 12px; }
    .message.is-menu-target { z-index: 2000; position: relative; }
    .scroll-bottom-btn { right: 14px; }
    .pinned-banner { padding-left: 0.9rem; }
    .group-modal { max-height: calc(100dvh - 24px); }
    .messages { padding-left: 14px !important; padding-right: 14px !important; }
}
@keyframes sheetUp { from { transform: translateY(100%); } to { transform: translateY(0); } }

/* ── Motion & accessibility ──────────────────────────────────────────────────── */

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.001ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.001ms !important;
        scroll-behavior: auto !important;
    }
    .skel-avatar, .skel-lines i, .skel-body i, .skel-line, .lp-skel-thumb, .lp-skel-lines i { animation: none; }
}

.btn-icon:focus-visible, .dm-item:focus-visible, .reaction-badge:focus-visible { outline-offset: 1px; }

/* Typing indicator sits above the composer — give it a little breathing room from the pill */
.typing-indicator { padding-left: 1.5rem; }

.chat-presence-status[hidden] { display: none; }

/* Markdown lists inside bubbles keep their markers (the global reset removed the indent). */
.content-text ol, .content-text ul { margin: 0.3rem 0 0.3rem 1.35rem; padding: 0; }
.content-text li { margin: 0.1rem 0; }
.content-text blockquote { margin: 0.3rem 0; padding: 0.1rem 0 0.1rem 0.7rem; border-left: 3px solid var(--accent); color: var(--text-muted); }

/* ── Small-screen polish ─────────────────────────────────────────────────────── */

.message-sender { flex-wrap: wrap; row-gap: 0; }
.message-display-name { white-space: nowrap; }
.message-timestamp { white-space: nowrap; }
@media (hover: none) { .sidebar-search-hint { display: none; } }
@media (max-width: 768px) {
    .message { max-width: 90%; }
    .message-sender { margin-left: 0.25rem; }
    .sidebar-search-hint { display: none; }
    .dm-item { padding: 0.8rem 0.9rem; }
    .chat-header .chat-header-info { max-width: calc(100vw - 210px); }
    .chat-header-info .profile-link { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
}

/* Viboro assistant chat */
.dm-ai-pill {
    flex-shrink: 0;
    margin-left: 6px;
    padding: 0 6px;
    border-radius: 6px;
    background: linear-gradient(135deg, var(--accent), #38bdf8);
    color: #fff;
    font-size: 0.6rem;
    font-weight: 800;
    letter-spacing: 0.06em;
    line-height: 1.5;
    align-self: center;
}

.e2ee-header-badge[hidden] { display: none; }

.redeem-hint { margin-top: 0.6rem; font-size: 0.76rem; color: var(--text-muted); line-height: 1.4; }
.redeem-hint strong { color: var(--accent-hover); letter-spacing: 0.04em; }

/* =====================================================================================
   Mobile refresh: tab bar, filter pills, action sheet, calmer list + chat chrome
   ===================================================================================== */

.title-mobile { display: none; }
.mobile-compose-btn { display: none; }
.icon-red { background: rgba(239, 68, 68, 0.16); color: #f87171; }
.settings-logout-row .settings-tab-label { color: #f87171; }

/* Filter pills (all sizes) */
.conv-filters {
    display: flex;
    gap: 6px;
    padding: 8px 10px 4px;
    overflow-x: auto;
    scrollbar-width: none;
}
.conv-filters::-webkit-scrollbar { display: none; }
.conv-filter {
    flex: none;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 0.32rem 0.8rem;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: transparent;
    color: var(--text-muted);
    font-size: 0.78rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.conv-filter:hover { color: var(--text); border-color: var(--accent); }
.conv-filter.is-active { background: var(--accent); border-color: var(--accent); color: #fff; }
.conv-filter-count { min-width: 17px; height: 17px; padding: 0 5px; display: grid; place-items: center; border-radius: 999px; background: rgba(255, 255, 255, 0.22); font-size: 0.66rem; }
.conv-filter:not(.is-active) .conv-filter-count { background: var(--accent); color: #fff; }
.conv-filter-count[hidden] { display: none; }

/* Action sheet (the New tab and compose button) */
.action-sheet-backdrop {
    position: fixed;
    inset: 0;
    z-index: 3000;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    background: rgba(0, 0, 0, 0.55);
    backdrop-filter: blur(3px);
    animation: fadeIn 0.18s ease-out;
}
.action-sheet-backdrop[hidden] { display: none; }
.action-sheet {
    width: min(480px, 100%);
    padding: 0.6rem 0.9rem calc(0.9rem + env(safe-area-inset-bottom, 0));
    border-radius: 22px 22px 0 0;
    background: var(--surface);
    border: 1px solid var(--border);
    border-bottom: 0;
    box-shadow: 0 -12px 40px rgba(0, 0, 0, 0.5);
    animation: sheetUp 0.28s cubic-bezier(0.16, 1, 0.3, 1);
}
.action-sheet-handle { display: block; width: 38px; height: 4px; margin: 0 auto 0.7rem; border-radius: 4px; background: var(--border); }
.action-sheet h3 { margin: 0 0 0.5rem 0.3rem; font-size: 1.05rem; }
.action-sheet-item {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 0.9rem;
    padding: 0.75rem 0.6rem;
    border: 0;
    border-radius: 14px;
    background: none;
    color: var(--text);
    text-align: left;
    cursor: pointer;
    transition: background 0.15s;
}
.action-sheet-item[hidden] { display: none; }
.action-sheet-item:hover, .action-sheet-item:active { background: var(--surface-hover); }
.action-sheet-item strong { display: block; font-size: 0.96rem; }
.action-sheet-item small { display: block; color: var(--text-muted); font-size: 0.78rem; margin-top: 1px; }
.action-sheet-icon { width: 42px; height: 42px; flex-shrink: 0; display: grid; place-items: center; border-radius: 13px; background: var(--accent-soft); color: var(--accent-hover); }
.action-sheet-cancel { width: 100%; margin-top: 0.4rem; padding: 0.8rem; border: 1px solid var(--border); border-radius: 14px; background: transparent; color: var(--text); font-weight: 600; cursor: pointer; }

@media (max-width: 768px) {
    /* header: brand + one compose button, like a native messenger */
    .title-desktop { display: none; }
    .title-mobile { display: inline; font-size: 1.25rem; font-weight: 800; letter-spacing: -0.02em; }
    #friends-list-btn, #new-group-btn, #add-friend-btn { display: none; }
    .mobile-compose-btn { display: inline-grid; place-items: center; width: 40px; height: 40px; border-radius: 12px; background: var(--accent-soft); color: var(--accent-hover); }
    .sidebar-header { padding: calc(0.75rem + env(safe-area-inset-top, 0)) 1rem 0.5rem; border-bottom: 0; }
    .sidebar-search { margin: 4px 12px 2px; }
    .sidebar-search input { padding-top: 0.7rem; padding-bottom: 0.7rem; border-radius: 14px; font-size: 1rem; }
    .conv-filters { padding: 8px 12px 6px; }
    .conv-filter { padding: 0.42rem 0.95rem; font-size: 0.84rem; }

    /* conversation rows */
    .dm-list { padding: 4px 6px; }
    .dm-item { padding: 0.7rem 0.8rem; border-radius: 16px; border-bottom: 0; margin-bottom: 2px; }
    .dm-item:hover { padding-left: 0.8rem; }
    .dm-item.active { border-left: 0; padding-left: 0.8rem; }
    .dm-item .avatar-ring > img { width: 48px; height: 48px; }
    .dm-profile-name { font-size: 1rem; }
    .dm-preview { font-size: 0.86rem; }

    /* tab bar replaces the profile footer */
    .sidebar-footer { padding: 0; gap: 0; border-top: 0; background: transparent; }
    .sidebar-footer .user-profile { display: none; }
    .mobile-bottom-nav {
        display: grid !important;
        grid-template-columns: repeat(5, 1fr);
        align-items: end;
        padding: 6px 6px calc(6px + env(safe-area-inset-bottom, 0));
        border-top: 1px solid var(--border);
        background: var(--surface);
        justify-content: initial;
    }
    .tab-btn {
        position: relative;
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 3px;
        padding: 6px 0 4px;
        border: 0;
        background: none;
        color: var(--text-muted);
        font-size: 0.66rem;
        font-weight: 600;
        cursor: pointer;
        -webkit-tap-highlight-color: transparent;
        transition: color 0.15s;
    }
    .tab-btn.is-active { color: var(--accent-hover); }
    .tab-btn:active .tab-icon { transform: scale(0.88); }
    .tab-icon { position: relative; display: grid; place-items: center; transition: transform 0.12s; }
    .tab-icon-new {
        width: 46px;
        height: 46px;
        margin-top: -16px;
        border-radius: 16px;
        background: linear-gradient(135deg, var(--accent), #a06bff);
        color: #fff;
        box-shadow: 0 8px 20px var(--accent-soft), 0 0 0 4px var(--surface);
    }
    .tab-new { color: var(--text); }
    .tab-badge {
        position: absolute;
        top: -6px;
        right: -10px;
        min-width: 18px;
        height: 18px;
        padding: 0 4px;
        display: grid;
        place-items: center;
        border-radius: 999px;
        background: #ef4444;
        color: #fff;
        font-size: 0.62rem;
        font-weight: 700;
        border: 2px solid var(--surface);
        box-sizing: border-box;
        line-height: 1;
    }
    .tab-badge[hidden] { display: none; }

    /* chat chrome */
    .chat-header { padding: calc(0.55rem + env(safe-area-inset-top, 0)) 0.75rem 0.55rem; min-height: 0; }
    .e2ee-header-badge { font-size: 0; padding: 5px 7px; gap: 0; }
    .e2ee-header-badge svg { width: 12px; height: 12px; }
    .chat-search-container .btn-icon { padding: 0.5rem; }

    /* composer: round plus, pill input, send */
    .composer-container { margin: 0 8px calc(8px + env(safe-area-inset-bottom, 0)); border-radius: 22px; }
    .composer-more-btn { width: 38px; height: 38px; border-radius: 50%; background: var(--accent-soft); color: var(--accent-hover); place-items: center; }
    .composer-more-btn[aria-expanded="true"] svg { transform: rotate(45deg); }
    .composer-more-btn svg { transition: transform 0.2s; }
    #message-input { border-radius: 20px; font-size: 1rem; }

    /* settings lists feel like a native settings screen */
    .settings-tab { padding-top: 0.85rem; padding-bottom: 0.85rem; }
}

/* =====================================================================================
   Navigation refresh: desktop rail, global search, the You page, account menu
   ===================================================================================== */

mark { background: rgba(168, 85, 247, 0.34); color: inherit; border-radius: 3px; padding: 0 1px; }

/* The sidebar search field is a doorway to the search screen, not a text box. */
#conversation-filter { cursor: pointer; caret-color: transparent; text-overflow: ellipsis; }
.mobile-header-btn { display: none; }

/* ── Avatar on a tab / the rail ──────────────────────────────────────────────── */
.avatar-ring img[data-mirror="pic"] { width: 28px; height: 28px; border: 2px solid var(--surface); }
.tab-avatar .avatar-ring { padding: 2px; }
.tab-btn.is-active .tab-avatar .avatar-ring { box-shadow: 0 0 0 2px var(--accent); }

/* ── Desktop navigation rail ─────────────────────────────────────────────────── */
.app-rail { display: none; }

@media (min-width: 769px) {
    .app-rail {
        width: 72px;
        flex-shrink: 0;
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 10px;
        padding: 14px 0 14px;
        background: var(--surface);
        border: 1px solid var(--border);
        border-right: 0;
        border-radius: 18px 0 0 18px;
        box-shadow: var(--shadow);
    }
    .sidebar { border-radius: 0 !important; }
    .sidebar-footer { display: none; }
    .rail-logo { width: 44px; height: 44px; padding: 0; border: 0; border-radius: 14px; background: var(--accent-soft); display: grid; place-items: center; cursor: pointer; transition: transform 0.15s; }
    .rail-logo:hover { transform: scale(1.06); }
    .rail-logo img { width: 28px; height: 28px; border-radius: 8px; }
    .rail-group { display: flex; flex-direction: column; align-items: center; gap: 6px; margin-top: 6px; }
    .rail-spacer { flex: 1; }
    .rail-btn {
        position: relative;
        width: 46px;
        height: 46px;
        display: grid;
        place-items: center;
        border: 0;
        border-radius: 14px;
        background: transparent;
        color: var(--text-muted);
        cursor: pointer;
        transition: background 0.15s, color 0.15s, transform 0.12s;
    }
    .rail-btn:hover { background: var(--surface-hover); color: var(--text); }
    .rail-btn:active { transform: scale(0.94); }
    .rail-btn.is-active { background: var(--accent-soft); color: var(--accent-hover); }
    .rail-btn.is-active::before { content: ''; position: absolute; left: -13px; top: 12px; bottom: 12px; width: 4px; border-radius: 0 4px 4px 0; background: var(--accent); }
    .rail-new { background: var(--accent); color: #fff; box-shadow: 0 6px 16px var(--accent-soft); margin-top: 4px; }
    .rail-new:hover { background: var(--accent-hover); color: #fff; }
    .rail-profile { padding: 0; border: 0; background: none; cursor: pointer; border-radius: 50%; transition: transform 0.15s; }
    .rail-profile:hover { transform: scale(1.06); }
    .rail-profile[aria-expanded="true"] .avatar-ring { box-shadow: 0 0 0 3px var(--accent-soft); }
    .rail-profile .avatar-ring img { width: 36px; height: 36px; }
    .app-rail .tab-badge { position: absolute; top: 3px; right: 3px; min-width: 18px; height: 18px; padding: 0 4px; display: grid; place-items: center; border-radius: 999px; background: #ef4444; color: #fff; font-size: 0.64rem; font-weight: 700; border: 2px solid var(--surface); box-sizing: border-box; line-height: 1; }
    .app-rail .tab-badge[hidden] { display: none; }

    /* the sheet becomes a centred card */
    .action-sheet-backdrop { align-items: center; }
    .action-sheet { border-radius: 20px; border-bottom: 1px solid var(--border); padding-bottom: 0.9rem; width: min(420px, calc(100vw - 32px)); animation: gsIn 0.2s ease-out; }
    .action-sheet-handle { display: none; }
    .sidebar { width: 330px; }
}
@keyframes gsIn { from { opacity: 0; transform: translateY(8px) scale(0.98); } to { opacity: 1; transform: none; } }

/* ── Account menu (rail avatar) ──────────────────────────────────────────────── */
.account-menu {
    position: fixed;
    z-index: 3500;
    width: 290px;
    padding: 8px;
    border: 1px solid var(--border);
    border-radius: 16px;
    background: var(--surface);
    -webkit-backdrop-filter: blur(18px);
    backdrop-filter: blur(18px);
    max-height: calc(100vh - 24px);
    overflow-y: auto;
    box-shadow: 0 18px 50px rgba(0, 0, 0, 0.55);
    animation: gsIn 0.16s ease-out;
}
.account-menu[hidden] { display: none; }
.account-card, .account-status, .menu-row {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 0.7rem;
    border: 0;
    background: none;
    color: var(--text);
    text-align: left;
    cursor: pointer;
    border-radius: 10px;
    transition: background 0.12s;
}
.account-card { padding: 0.6rem; }
.account-card:hover, .account-status:hover, .menu-row:hover, .menu-row:focus-visible, .account-card:focus-visible, .account-status:focus-visible { background: var(--surface-hover); outline: none; }
.account-card .avatar-ring img { width: 44px; height: 44px; }
.account-card-text { display: flex; flex-direction: column; min-width: 0; line-height: 1.25; }
.account-card-text strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.account-card-text small { color: var(--text-muted); }
.account-status { padding: 0.55rem 0.65rem; margin: 2px 0; font-size: 0.86rem; border: 1px dashed var(--border); }
.account-status em { margin-left: auto; font-style: normal; font-size: 0.72rem; color: var(--text-muted); }
.status-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--ring-online); flex-shrink: 0; }
.status-dot.is-dnd { background: var(--ring-dnd); }
.status-dot.is-offline { background: var(--ring-offline); }
.menu-row { padding: 0.5rem 0.65rem; font-size: 0.9rem; }
.menu-row .settings-tab-icon, .you-row .settings-tab-icon { width: 30px; height: 30px; flex-shrink: 0; display: grid; place-items: center; border-radius: 9px; }
.menu-row kbd { margin-left: auto; }
.menu-row.is-danger { color: #f87171; }
.menu-sep { height: 1px; margin: 6px 4px; background: var(--border); }

/* Accounts on this device (switcher) */
.menu-label { padding: 0.3rem 0.65rem 0.15rem; font-size: 0.68rem; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--text-muted); }
.account-switch-row {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 0.7rem;
    padding: 0.45rem 0.65rem;
    border: 0;
    border-radius: 10px;
    background: none;
    color: var(--text);
    text-align: left;
    cursor: pointer;
    transition: background 0.12s;
}
.account-switch-row:hover, .account-switch-row:focus-visible { background: var(--surface-hover); outline: none; }
.account-switch-row img { width: 34px; height: 34px; border-radius: 50%; object-fit: cover; flex-shrink: 0; }
.account-switch-row .add-icon { width: 34px; height: 34px; flex-shrink: 0; display: grid; place-items: center; border-radius: 50%; border: 1px dashed var(--border); color: var(--text-muted); font-size: 1.2rem; line-height: 1; }
.account-switch-row .switch-hint { margin-left: auto; font-size: 0.72rem; color: var(--text-muted); }
.account-switch-row.is-danger { color: #f87171; }
.account-switch-row small { color: var(--text-muted); }
.you-accounts { padding: 0.4rem 0.75rem 1.2rem; }
.you-accounts .menu-label { padding-left: 0.4rem; }

/* ── Global search ───────────────────────────────────────────────────────────── */
body.gs-open { overflow: hidden; }
.gs { position: fixed; inset: 0; z-index: 4000; display: flex; justify-content: center; align-items: flex-start; padding-top: 11vh; }
.gs[hidden] { display: none; }
.gs-backdrop { position: absolute; inset: 0; background: rgba(5, 5, 12, 0.62); backdrop-filter: blur(6px); opacity: 0; transition: opacity 0.18s; }
.gs.is-open .gs-backdrop { opacity: 1; }
.gs-panel {
    position: relative;
    width: min(680px, calc(100vw - 32px));
    max-height: min(640px, 78vh);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 18px;
    box-shadow: 0 24px 70px rgba(0, 0, 0, 0.6);
    opacity: 0;
    transform: translateY(-8px) scale(0.985);
    transition: opacity 0.18s, transform 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}
.gs.is-open .gs-panel { opacity: 1; transform: none; }
.gs-bar { display: flex; align-items: center; gap: 0.6rem; padding: 0.8rem 1rem; border-bottom: 1px solid var(--border); }
.gs-back { display: none; width: 40px; height: 40px; margin-left: -8px; place-items: center; border: 0; border-radius: 12px; background: none; color: var(--text); cursor: pointer; }
.gs-glass { color: var(--text-muted); display: grid; }
.gs-input { flex: 1; min-width: 0; padding: 0.3rem 0 !important; border: 0 !important; background: transparent !important; box-shadow: none !important; outline: none; color: var(--text); font-size: 1.05rem; }
.gs-clear { width: 32px; height: 32px; display: grid; place-items: center; border: 0; border-radius: 50%; background: var(--surface-secondary); color: var(--text-muted); cursor: pointer; }
.gs-clear[hidden] { display: none; }
.gs-tabs { display: flex; gap: 6px; padding: 0.6rem 1rem 0.2rem; overflow-x: auto; scrollbar-width: none; }
.gs-tabs::-webkit-scrollbar { display: none; }
.gs-tab { flex: none; padding: 0.38rem 0.9rem; border: 1px solid var(--border); border-radius: 999px; background: transparent; color: var(--text-muted); font-size: 0.82rem; font-weight: 600; cursor: pointer; transition: background 0.15s, color 0.15s; }
.gs-tab:hover { color: var(--text); }
.gs-tab.is-active { background: var(--accent); border-color: var(--accent); color: #fff; }
.gs-results { flex: 1; min-height: 120px; overflow-y: auto; padding: 0.3rem 0.5rem 0.8rem; overscroll-behavior: contain; }
.gs-section h4 { display: flex; align-items: center; gap: 8px; margin: 0.8rem 0.6rem 0.25rem; font-size: 0.72rem; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--text-muted); }
.gs-chip { padding: 1px 8px; border-radius: 999px; background: var(--accent-soft); color: var(--accent-hover); font-size: 0.68rem; letter-spacing: 0; text-transform: none; }
.gs-item { width: 100%; display: flex; align-items: center; gap: 0.75rem; padding: 0.55rem 0.65rem; border: 0; border-radius: 12px; background: none; color: var(--text); text-align: left; cursor: pointer; }
.gs-item.is-selected { background: var(--accent-soft); }
.gs-item img { width: 42px; height: 42px; border-radius: 50%; object-fit: cover; flex-shrink: 0; }
.gs-text { display: flex; flex-direction: column; min-width: 0; flex: 1; gap: 2px; line-height: 1.3; }
.gs-text strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 0.95rem; }
.gs-text small { color: var(--text-muted); font-size: 0.8rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.gs-item time { flex-shrink: 0; align-self: flex-start; margin-top: 2px; font-size: 0.7rem; color: var(--text-muted); }
.gs-tag { flex-shrink: 0; padding: 1px 8px; border-radius: 6px; background: linear-gradient(135deg, var(--accent), #38bdf8); color: #fff; font-size: 0.64rem; font-weight: 800; letter-spacing: 0.05em; }
.gs-tag.is-muted { background: var(--surface-secondary); color: var(--text-muted); border: 1px solid var(--border); font-weight: 600; letter-spacing: 0; }
.gs-message { align-items: flex-start; }
.gs-meta { display: flex; align-items: baseline; gap: 6px; min-width: 0; font-size: 0.82rem; }
.gs-meta strong { font-size: 0.86rem; flex-shrink: 0; max-width: 40%; }
.gs-meta em { font-style: normal; color: var(--text-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; min-width: 0; }
.gs-meta time { margin: 0; }
.gs-snippet { color: var(--text); opacity: 0.9; font-size: 0.88rem; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; word-break: break-word; }
.gs-empty, .gs-hint { padding: 1.2rem 0.9rem; text-align: center; color: var(--text-muted); font-size: 0.86rem; line-height: 1.5; }
.gs-hint p { margin: 0.3rem 0 0; }
.gs-hint code, .gs-empty code { padding: 1px 6px; border-radius: 5px; background: var(--surface-secondary); color: var(--accent-hover); font-size: 0.78rem; }
.gs-loading { padding: 0.4rem 0.6rem; }
.gs-foot { display: flex; gap: 1.2rem; justify-content: center; padding: 0.55rem; border-top: 1px solid var(--border); color: var(--text-muted); font-size: 0.74rem; }
.gs-foot kbd { margin-right: 3px; }

/* ── The You page (phone) ────────────────────────────────────────────────────── */
.you-view { display: none; flex: 1; min-height: 0; flex-direction: column; }
.sidebar[data-view="you"] > .sidebar-header,
.sidebar[data-view="you"] > .sidebar-search,
.sidebar[data-view="you"] > .conv-filters,
.sidebar[data-view="you"] > .push-prompt,
.sidebar[data-view="you"] > .dm-list { display: none !important; }
.sidebar[data-view="you"] > .you-view { display: flex; }
.you-scroll { flex: 1; overflow-y: auto; padding: calc(0.5rem + env(safe-area-inset-top, 0)) 1rem 1.5rem; overscroll-behavior: contain; }
.you-top { display: flex; align-items: center; justify-content: space-between; padding: 0.4rem 0 0.8rem; }
.you-top h2 { margin: 0; font-size: 1.5rem; letter-spacing: -0.02em; }
.you-gear { width: 44px; height: 44px; display: grid; place-items: center; border-radius: 14px; background: var(--surface-secondary); }
.you-card { display: flex; flex-direction: column; align-items: center; text-align: center; padding: 1.4rem 1rem 1.1rem; border: 1px solid var(--border); border-radius: 22px; background: linear-gradient(160deg, var(--accent-soft), var(--surface-secondary) 60%); }
.you-avatar { padding: 0; border: 0; background: none; cursor: pointer; border-radius: 50%; }
.you-avatar .avatar-ring { padding: 3px; }
.you-avatar .avatar-ring img { width: 92px; height: 92px; border-width: 3px; }
.you-card h3 { margin: 0.8rem 0 0; font-size: 1.35rem; letter-spacing: -0.01em; }
.you-handle { margin: 2px 0 0; color: var(--text-muted); font-size: 0.92rem; }
.you-status { margin-top: 0.7rem; padding: 0.4rem 0.95rem; border: 1px solid var(--border); border-radius: 999px; background: var(--surface); color: var(--text); font-size: 0.86rem; cursor: pointer; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.you-status .is-placeholder { color: var(--text-muted); }
.you-bio { margin: 0.8rem 0 0; max-width: 32ch; color: var(--text); font-size: 0.92rem; line-height: 1.45; }
.you-bio.is-empty { color: var(--text-muted); font-size: 0.84rem; }
.you-stats { display: grid; grid-template-columns: repeat(3, 1fr); width: 100%; margin: 1.1rem 0 1rem; padding: 0.75rem 0; border-block: 1px solid var(--border); }
.you-stats > div { display: flex; flex-direction: column; gap: 2px; }
.you-stats strong { font-size: 1.2rem; }
.you-stats span { color: var(--text-muted); font-size: 0.76rem; }
.you-actions { display: flex; gap: 0.6rem; width: 100%; }
.you-actions .btn-primary, .you-actions .btn-secondary { flex: 1; min-height: 46px; border-radius: 14px; }
.you-group { margin-top: 1.2rem; }
.you-group h4 { margin: 0 0.4rem 0.45rem; font-size: 0.72rem; font-weight: 700; letter-spacing: 0.07em; text-transform: uppercase; color: var(--text-muted); }
.you-list { border: 1px solid var(--border); border-radius: 18px; background: var(--surface-secondary); overflow: hidden; }
.you-row { width: 100%; min-height: 56px; display: flex; align-items: center; gap: 0.85rem; padding: 0.55rem 0.9rem; border: 0; border-bottom: 1px solid var(--border); background: none; color: var(--text); text-align: left; cursor: pointer; -webkit-tap-highlight-color: transparent; transition: background 0.12s; }
.you-row:last-child { border-bottom: 0; }
.you-row:active, .you-row:hover { background: var(--surface-hover); }
.you-row-text { display: flex; flex-direction: column; flex: 1; min-width: 0; line-height: 1.3; }
.you-row-text strong { font-size: 0.97rem; font-weight: 600; }
.you-row-text small { color: var(--text-muted); font-size: 0.78rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.you-row .row-chevron { color: var(--text-muted); flex-shrink: 0; }
.you-row.is-danger strong { color: #f87171; }
.you-footnote { margin: 1.4rem 0 0.5rem; text-align: center; color: var(--text-muted); font-size: 0.74rem; }

/* ── Phones ──────────────────────────────────────────────────────────────────── */
@media (max-width: 768px) {
    .mobile-header-btn { display: inline-grid; place-items: center; width: 40px; height: 40px; border-radius: 12px; }
    /* the search field is a big, obvious tap target */
    .sidebar-search input { height: 46px; padding-left: 2.5rem; }
    .sidebar-search-icon { left: 15px; }
    .tab-label { font-size: 0.68rem; }
    .tab-avatar .avatar-ring img { width: 26px; height: 26px; }

    .gs { padding-top: 0; align-items: stretch; }
    .gs-panel { width: 100%; max-height: none; height: 100%; border: 0; border-radius: 0; transform: translateY(14px); }
    .gs-bar { padding: calc(0.6rem + env(safe-area-inset-top, 0)) 0.75rem 0.6rem; }
    .gs-back { display: grid; }
    .gs-esc, .gs-foot { display: none; }
    .gs-input { font-size: 1rem; }
    .gs-item { min-height: 58px; padding: 0.6rem 0.65rem; }
    .gs-results { padding-bottom: calc(1rem + env(safe-area-inset-bottom, 0)); }
}

/* =====================================================================================
   Pages and windows (instead of dialogs): Friends + You live in the sidebar, Settings and
   Invite codes open as windows. Plus: the dead strip above the phone tab bar is gone.
   ===================================================================================== */

/* The old sidebar footer holds nothing visible any more but kept a 62px minimum height,
   which painted a blank bar over the bottom of the chat list on phones. */
.sidebar-footer { display: none !important; }

/* Sidebar "pages" */
.friends-view, .you-view { display: none; flex: 1; min-height: 0; flex-direction: column; }
.sidebar[data-view="you"] > .sidebar-header,
.sidebar[data-view="you"] > .sidebar-search,
.sidebar[data-view="you"] > .conv-filters,
.sidebar[data-view="you"] > .push-prompt,
.sidebar[data-view="you"] > .dm-list,
.sidebar[data-view="friends"] > .sidebar-header,
.sidebar[data-view="friends"] > .sidebar-search,
.sidebar[data-view="friends"] > .conv-filters,
.sidebar[data-view="friends"] > .push-prompt,
.sidebar[data-view="friends"] > .dm-list { display: none !important; }
.sidebar[data-view="you"] > .you-view,
.sidebar[data-view="friends"] > .friends-view { display: flex; }

.view-top { display: flex; align-items: center; justify-content: space-between; min-height: 56px; padding: calc(0.4rem + env(safe-area-inset-top, 0)) 1rem 0.4rem; }
.view-top h2 { margin: 0; font-size: 1.5rem; letter-spacing: -0.02em; }
.view-top-btn { width: 44px; height: 44px; display: grid; place-items: center; border-radius: 14px; background: var(--surface-secondary); }
.view-top-btn:hover { background: var(--surface-hover); }
.you-scroll .view-top { padding-left: 0; padding-right: 0; }
.you-gear { transition: transform 0.25s ease; }
.you-gear:hover { transform: rotate(45deg); }

/* Friends page */
.friends-view .friends-tabs { display: flex; gap: 6px; padding: 0 1rem 0.6rem; border: 0; margin: 0; }
.friends-view .friends-tab { flex: 1; display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 0.55rem 0.5rem; border: 1px solid var(--border); border-radius: 12px; background: transparent; color: var(--text-muted); font-size: 0.86rem; font-weight: 600; cursor: pointer; transition: background 0.15s, color 0.15s; }
.friends-view .friends-tab.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.friends-tab-count { min-width: 18px; height: 18px; padding: 0 5px; display: inline-grid; place-items: center; border-radius: 999px; background: #ef4444; color: #fff; font-size: 0.66rem; font-weight: 700; }
.friends-tab-count[hidden] { display: none; }
.friends-view .friends-list { flex: 1; min-height: 0; overflow-y: auto; padding: 0 0.6rem 1rem; overscroll-behavior: contain; }
.friends-empty { padding: 2.5rem 1.2rem; text-align: center; color: var(--text-muted); font-size: 0.9rem; line-height: 1.5; }
.friends-view .friend-item { display: flex; align-items: center; gap: 0.8rem; padding: 0.7rem 0.6rem; border: 0; border-bottom: 1px solid var(--border); border-radius: 0; background: none; }
.friends-view .friend-item:last-child { border-bottom: 0; }
.friends-view .friend-item-pfp { width: 46px; height: 46px; border-radius: 50%; object-fit: cover; flex-shrink: 0; cursor: pointer; }
.friends-view .friend-item-info { display: flex; flex-direction: column; min-width: 0; flex: 1; line-height: 1.3; }
.friends-view .friend-item-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.friends-view .friend-item-handle { color: var(--text-muted); font-size: 0.8rem; }
.friends-view .friend-item-actions { display: flex; gap: 6px; flex-shrink: 0; }
.friends-view .friend-item-actions button { min-height: 38px; border-radius: 10px; }

/* The You page is a profile preview */
.you-card { margin-top: 0.2rem; }

/* Windows: Settings and Invite codes fill the app (no dimmed backdrop, no floating box) */
#settings-modal, #invite-codes-modal {
    background: var(--background);
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    z-index: 900; /* above the chat, below real dialogs and the search screen */
    align-items: stretch;
    justify-content: stretch;
    padding: 0;
    animation: windowIn 0.24s cubic-bezier(0.16, 1, 0.3, 1);
}
@keyframes windowIn { from { opacity: 0; transform: translateX(16px); } to { opacity: 1; transform: none; } }
#settings-modal .modal-content { width: 100%; max-width: none; height: 100%; max-height: none; border-radius: 0; border: 0; box-shadow: none; background: transparent; }

#invite-codes-modal { align-items: flex-start; justify-content: center; overflow-y: auto; padding: 2.2rem 1.25rem; }
#invite-codes-modal .modal-content { width: 100%; max-width: 560px !important; background: var(--surface); }

@media (min-width: 769px) {
    #settings-modal, #invite-codes-modal {
        inset: 14px 14px 14px 86px;
        border: 1px solid var(--border);
        border-radius: 18px;
        box-shadow: var(--shadow);
        overflow: hidden;
    }
    #invite-codes-modal { overflow-y: auto; }
    #settings-modal .settings-pane { max-width: 780px; }
}

@media (max-width: 768px) {
    .view-top h2 { font-size: 1.6rem; }
    .friends-view .friends-tab { min-height: 44px; }
}

@media (prefers-reduced-motion: reduce) {
    #settings-modal, #invite-codes-modal { animation: none; }
}

/* Settings window: the panel fills the window (the older dialog rules pinned it to 60vh). */
#settings-modal .settings-modal-content {
    width: 100% !important;
    max-width: none !important;
    height: 100% !important;
    max-height: none !important;
    border-radius: 0 !important;
    border: 0 !important;
    box-shadow: none !important;
    background: transparent !important;
}
@media (min-width: 769px) {
    #settings-modal .settings-sidebar { width: 300px; }
    #settings-modal .settings-body { padding: 2rem clamp(1.5rem, 4vw, 3.5rem); }
}

/* "New version" banner (see modules/app-update.js) */
.update-banner { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(84px + env(safe-area-inset-bottom, 0)); z-index: 2000; display: flex; align-items: center; gap: 10px; max-width: calc(100vw - 24px); padding: 8px 8px 8px 16px; border-radius: 16px; background: var(--surface); color: var(--text); border: 1px solid var(--border); box-shadow: var(--shadow); font-size: 0.9rem; }
.update-banner[hidden] { display: none; }
.update-banner-btn { padding: 8px 14px; border-radius: 10px; background: var(--accent); color: #fff; font-weight: 600; min-height: 38px; }
.update-banner-close { width: 34px; height: 34px; border-radius: 10px; color: var(--text-muted); font-size: 1.2rem; }
@media (min-width: 769px) { .update-banner { bottom: 24px; } }

/* --- Voice calls (public/js/modules/calls.js) --- */
.call-overlay { position: fixed; inset: 0; z-index: 10000002; display: flex; align-items: center; justify-content: center; background: rgba(0, 0, 0, 0.6); backdrop-filter: blur(4px); padding: 1rem; }
.call-overlay[hidden] { display: none; }
.call-card { width: min(320px, 100%); padding: 1.75rem 1.5rem; border-radius: 20px; text-align: center; display: flex; flex-direction: column; align-items: center; gap: 0.5rem; }
.call-avatar { width: 96px; height: 96px; border-radius: 50%; object-fit: cover; border: 2px solid var(--accent); background: var(--surface-secondary); }
.call-name { font-size: 1.2rem; font-weight: 700; color: var(--text); word-break: break-word; }
.call-status { font-size: 0.9rem; color: var(--text-muted); min-height: 1.3em; font-variant-numeric: tabular-nums; }
.call-actions { display: flex; gap: 1.25rem; justify-content: center; margin-top: 1rem; }
.call-action { width: 56px; height: 56px; border-radius: 50%; border: 0; display: inline-flex; align-items: center; justify-content: center; cursor: pointer; color: #fff; background: var(--surface-secondary); transition: transform 0.12s ease, filter 0.12s ease; }
.call-action[hidden] { display: none; }
.call-action:hover { filter: brightness(1.15); }
.call-action:active { transform: scale(0.94); }
.call-action.call-mute { color: var(--text); border: 1px solid var(--border); }
.call-action.call-mute[aria-pressed="true"] { background: var(--accent); }
.call-action.call-accept { background: #2fb36d; }
.call-action.call-decline, .call-action.call-hangup { background: #e5484d; }
.call-action.call-decline svg, .call-action.call-hangup svg { transform: rotate(135deg); }
#call-btn:disabled { opacity: 0.4; cursor: not-allowed; }

/* ── Landing page: glow, sparkles, wave, feature chips (matches the Windows installer's look) ───────────── */
.landing-bg { position: fixed; inset: 0; z-index: 0; overflow: hidden; pointer-events: none;
    background:
        radial-gradient(70% 60% at 100% 100%, rgba(112, 56, 240, 0.55) 0%, rgba(112, 56, 240, 0) 62%),
        radial-gradient(60% 50% at 0% 0%, rgba(40, 22, 120, 0.7) 0%, rgba(40, 22, 120, 0) 70%); }
.landing-wave { position: absolute; left: 0; right: 0; bottom: 0; width: 100%; height: 38%; opacity: 0.85; }
.landing-bg .spark { position: absolute; width: 12px; height: 12px; background: #b48cff; opacity: 0.8;
    clip-path: polygon(50% 0, 62% 38%, 100% 50%, 62% 62%, 50% 100%, 38% 62%, 0 50%, 38% 38%); animation: landingTwinkle 3.4s ease-in-out infinite; }
.sp1 { top: 14%; left: 12%; } .sp2 { top: 22%; right: 14%; width: 9px; height: 9px; animation-delay: 0.9s; }
.sp3 { top: 52%; left: 7%; width: 8px; height: 8px; animation-delay: 1.7s; } .sp4 { top: 44%; right: 8%; width: 15px; height: 15px; animation-delay: 2.2s; }
.sp5 { bottom: 26%; left: 22%; width: 7px; height: 7px; animation-delay: 0.5s; } .sp6 { bottom: 18%; right: 24%; width: 10px; height: 10px; animation-delay: 1.3s; }
.sp7 { top: 8%; right: 38%; width: 7px; height: 7px; animation-delay: 2.6s; }
@keyframes landingTwinkle { 0%, 100% { opacity: 0.25; transform: scale(0.8); } 50% { opacity: 0.95; transform: scale(1.12); } }

.landing-hero { position: relative; z-index: 1; display: flex; flex-direction: column; align-items: center; width: 100%; }
.landing-view .landing-footer { z-index: 1; }
.landing-logo { filter: drop-shadow(0 8px 30px rgba(120, 70, 255, 0.55)); }
.landing-actions { margin-bottom: 2.2rem; }
.landing-actions .btn-primary, .landing-actions .btn-secondary { border-radius: 14px; min-width: 170px; font-weight: 700; }
.landing-actions .btn-primary {
    background: linear-gradient(180deg, #8a4dff 0%, #6a2fe0 100%); border: 1px solid rgba(255, 255, 255, 0.2); color: #fff;
    box-shadow: 0 10px 30px rgba(122, 64, 245, 0.5), inset 0 1px 0 rgba(255, 255, 255, 0.35); transition: transform 0.12s, filter 0.12s;
}
.landing-actions .btn-primary:hover { transform: translateY(-1px); filter: brightness(1.1); }
.landing-actions .btn-secondary { background: rgba(14, 9, 40, 0.65); border: 1px solid rgba(168, 125, 255, 0.4); color: #f1eaff; backdrop-filter: blur(6px); }
.landing-actions .btn-secondary:hover { border-color: rgba(200, 170, 255, 0.7); background: rgba(30, 18, 80, 0.7); }

.landing-features { list-style: none; margin: 0 0 1.6rem; padding: 0; display: flex; flex-wrap: wrap; justify-content: center; gap: 0.7rem; }
.landing-features li { display: inline-flex; align-items: center; gap: 0.55rem; padding: 0.55rem 0.95rem; border-radius: 999px;
    border: 1px solid rgba(168, 125, 255, 0.3); background: rgba(14, 9, 40, 0.55); color: #d9ccff; font-size: 0.88rem; backdrop-filter: blur(6px); }
.landing-features svg { width: 17px; height: 17px; fill: none; stroke: #a875ff; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.landing-apps { display: inline-flex; align-items: center; gap: 0.6rem; margin-bottom: 3rem; color: #c9b8f5; font-size: 0.95rem; text-decoration: none; padding: 0.5rem 0.9rem; border-radius: 10px; }
.landing-apps svg { width: 18px; height: 18px; fill: none; stroke: #a875ff; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.landing-apps:hover { color: #fff; background: rgba(168, 125, 255, 0.14); }
body.is-native-shell .landing-apps { display: none; }   /* already inside the app */

@media (max-width: 768px) {
    .landing-features { gap: 0.5rem; padding: 0 0.5rem; }
    .landing-features li { font-size: 0.8rem; padding: 0.45rem 0.75rem; }
    .landing-actions .btn-primary, .landing-actions .btn-secondary { min-width: 0; }
    .landing-apps { margin-bottom: 1rem; }
}
@media (prefers-reduced-motion: reduce) { .landing-bg .spark { animation: none; opacity: 0.6; } }
