/* Self-hosted fonts — no external Google Fonts dependency. */
@font-face {
    font-family: 'Inter';
    font-style: normal;
    font-weight: 400 600;
    font-display: swap;
    src: url('assets/fonts/inter-cyrillic.woff2') format('woff2');
    unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}
@font-face {
    font-family: 'Inter';
    font-style: normal;
    font-weight: 400 600;
    font-display: swap;
    src: url('assets/fonts/inter-cyrillic-ext.woff2') format('woff2');
    unicode-range: U+0460-052F, U+1C80-1C8A, U+20B4, U+2DE0-2DFF, U+A640-A69F, U+FE2E-FE2F;
}
@font-face {
    font-family: 'Inter';
    font-style: normal;
    font-weight: 400 600;
    font-display: swap;
    src: url('assets/fonts/inter-latin-ext.woff2') format('woff2');
    unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
    font-family: 'Inter';
    font-style: normal;
    font-weight: 400 600;
    font-display: swap;
    src: url('assets/fonts/inter-latin.woff2') format('woff2');
    unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
:root {
    --accent: #1cce5e;
    --accent-hover: #17b350;
    --accent-dim: rgba(28, 206, 94, 0.12);
    --danger: #ff4757;
    --warning: #ffab00;
    --msg-font-size: 15px;

    /* Default (Dark) Theme */
    --bg: #0f1729;
    --surface: rgba(255,255,255,0.04);
    --surface-hover: rgba(255,255,255,0.07);
    --border: rgba(255,255,255,0.08);
    --text: #f1f5f9;
    --text-dim: #64748b;
    --input-bg: rgba(0,0,0,0.25);
    --input-border: rgba(255,255,255,0.1);
    --msg-in: rgba(255,255,255,0.06);
    --msg-out: rgba(28, 206, 94, 0.18);
    --msg-out-border: rgba(28, 206, 94, 0.35);
    --sb-track: rgba(255,255,255,0.04);
    --sb-thumb: rgba(255,255,255,0.20);
    --sb-thumb-hover: rgba(255,255,255,0.40);
    --sb-thumb-active: rgba(28, 206, 94, 0.40);
    --panel-msg-area: #0f1729;
}

[data-theme="light"] {
    --accent: #16984b;
    --accent-hover: #117d3d;
    --accent-dim: rgba(22, 152, 75, 0.14);
    --bg: #dcecf7;
    --surface: rgba(255,255,255,0.75);
    --surface-hover: rgba(255,255,255,0.9);
    --border: rgba(0,0,0,0.07);
    --text: #0f1729;
    --text-dim: #64748b;
    --input-bg: rgba(255,255,255,0.9);
    --input-border: rgba(0,0,0,0.12);
    --msg-in: rgba(0,0,0,0.05);
    --msg-out: rgba(28, 206, 94, 0.15);
    --msg-out-border: rgba(28, 206, 94, 0.3);
    --sb-track: rgba(0,0,0,0.04);
    --sb-thumb: rgba(0,0,0,0.18);
    --sb-thumb-hover: rgba(0,0,0,0.35);
    --sb-thumb-active: rgba(34, 197, 94, 0.40);
    --panel-msg-area: #f5faff;
}

/* Global scrollbar styling */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: var(--sb-track); border-radius: 999px; }
::-webkit-scrollbar-thumb { background: var(--sb-thumb); border-radius: 999px; transition: background-color 0.15s ease-in-out; }
::-webkit-scrollbar-thumb:hover { background: var(--sb-thumb-hover); }
::-webkit-scrollbar-thumb:active { background: var(--sb-thumb-active); }

/* Prevent icon text flash */
.material-symbols-outlined {
    font-family: 'Material Symbols Outlined';
    font-size: 22px;
    line-height: 1;
    letter-spacing: normal;
    text-transform: none;
    display: inline-block;
    white-space: nowrap;
    direction: ltr;
    -webkit-font-smoothing: antialiased;
    visibility: hidden;
}
.fonts-loaded .material-symbols-outlined {
    visibility: visible;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
    height: 100%;
    font-family: 'Inter', sans-serif;
    background: var(--bg);
    color: var(--text);
    overflow: hidden;
    transition: background 0.3s, color 0.3s;
}

#app {
    height: 100vh;
    height: 100dvh;
}

/* AUTH SCREEN */
body::before, body::after {
    content: '';
    position: fixed;
    border-radius: 50%;
    z-index: -1;
    filter: blur(120px);
    opacity: 0.1;
    pointer-events: none;
}
body::before {
    width: 500px; height: 500px;
    background: var(--accent);
    top: -100px; left: -150px;
}
body::after {
    width: 400px; height: 400px;
    background: #3b82f6;
    bottom: -100px; right: -100px;
}

.auth-wrapper {
    height: 100vh;
    height: 100dvh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.auth-card {
    width: 100%;
    max-width: 440px;
    padding: 44px 36px;
}

.glass-panel {
    background: var(--surface);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--border);
    box-shadow: 0 20px 60px rgba(0,0,0,0.2);
}

.hidden { display: none !important; }

.header { text-align: center; margin-bottom: 28px; }

.logo-wrapper {
    width: 68px; height: 68px;
    background: var(--accent-dim);
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    margin: 0 auto 16px;
    color: var(--accent);
}
.logo-icon { font-size: 32px !important; }
.success-logo { background: rgba(28,206,94,0.2); }

.header h1 { font-size: 22px; font-weight: 600; margin-bottom: 6px; }
.subtitle { color: var(--text-dim); font-size: 14px; }

.autolink-autofill-hint {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    margin: 0 0 14px;
    padding: 12px 14px;
    border: 1px solid rgba(34, 197, 94, 0.28);
    border-radius: 12px;
    background: rgba(34, 197, 94, 0.12);
    color: var(--text);
    font-size: 13px;
    line-height: 1.45;
    text-align: left;
}
.autolink-autofill-hint .material-symbols-outlined {
    color: var(--accent);
    font-size: 20px !important;
    flex: none;
}

.input-group { position: relative; margin-bottom: 14px; }
.input-group > .material-symbols-outlined {
    position: absolute;
    left: 14px; top: 50%; transform: translateY(-50%);
    color: var(--text-dim); font-size: 20px !important;
}
.input-group.has-toggle input { padding-right: 44px; }
.password-toggle-btn {
    position: absolute;
    right: 6px; top: 50%; transform: translateY(-50%);
    background: transparent;
    border: none;
    padding: 6px;
    border-radius: 8px;
    color: var(--text-dim);
    display: flex; align-items: center; justify-content: center;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
}
.password-toggle-btn:hover { background: var(--input-bg); color: var(--text); }
.password-toggle-btn .material-symbols-outlined { font-size: 20px !important; }

input:not([type="checkbox"]):not([type="radio"]), textarea {
    width: 100%;
    background: var(--input-bg);
    border: 1px solid var(--input-border);
    border-radius: 12px;
    padding: 13px 14px 13px 44px;
    color: var(--text);
    font-family: inherit;
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
    resize: none;
}
input:not([type="checkbox"]):not([type="radio"]):focus, textarea:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(28,206,94,0.1);
}
input[type="checkbox"], input[type="radio"] {
    width: auto;
    padding: 0;
    margin: 0;
    background: transparent;
    border: none;
    border-radius: 0;
    accent-color: var(--accent);
    cursor: pointer;
}

button { cursor: pointer; border: none; font-family: inherit; }

button.is-loading {
    position: relative;
    pointer-events: none;
}

.button-loading-spinner {
    width: 1.05em;
    height: 1.05em;
    border: 2px solid currentColor;
    border-top-color: transparent;
    border-radius: 999px;
    display: inline-block;
    flex: none;
    animation: appSpinnerRotate 0.75s linear infinite;
}

.primary-btn {
    display: flex; align-items: center; justify-content: center;
    gap: 8px;
    width: 100%;
    padding: 13px;
    background: var(--accent);
    color: #fff;
    border-radius: 12px;
    font-size: 15px; font-weight: 570;
    margin-top: 20px;
    transition: background 0.2s, transform 0.1s;
}
.primary-btn:hover { background: var(--accent-hover); }
.primary-btn:active { transform: scale(0.99); }
.primary-btn:disabled { opacity: 0.5; cursor: not-allowed; }

.danger-btn {
    display: flex; align-items: center; justify-content: center;
    gap: 10px;
    width: 100%;
    padding: 12px;
    background: rgba(255, 71, 87, 0.1);
    color: var(--danger);
    border: 1px solid rgba(255, 71, 87, 0.2);
    border-radius: 12px;
    font-size: 14px; font-weight: 600;
    transition: all 0.2s;
}
.danger-btn:hover { background: var(--danger); color: #fff; }

[data-theme="light"] .danger-btn {
    background: #ff4759;
    color: #fffaff;
    border: 1px solid #ff4759;
}
[data-theme="light"] .danger-btn:hover {
    background: #fffaff;
    color: #ff4759;
    border-color: #ff4759;
}

.inline-btn { width: auto; padding: 11px 20px; margin-top: 0; }

.error-box {
    display: flex; align-items: center; gap: 8px;
    background: rgba(255,71,87,0.1);
    color: var(--danger);
    border-radius: 10px; padding: 10px 14px;
    font-size: 14px; margin-bottom: 14px;
}

/* APP LAYOUT */
.app-layout {
    display: flex;
    height: 100vh;
    height: 100dvh;
    min-height: 0;
    overflow: hidden;
}

/* SIDEBAR */
.sidebar {
    width: 260px;
    min-width: 260px;
    display: flex;
    flex-direction: column;
    border-right: 1px solid var(--border);
    background: var(--surface);
    backdrop-filter: blur(20px);
    transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1), min-width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.sidebar.collapsed {
    width: 72px;
    min-width: 72px;
}

.sidebar.collapsed .sidebar-title,
.sidebar.collapsed .admin-chip,
.sidebar.collapsed .sidebar-nav .nav-item span:not(.material-symbols-outlined),
.sidebar.collapsed .status-dot {
    display: none !important;
}

.sidebar.collapsed .nav-item {
    justify-content: center;
    padding: 12px 0 !important;
    width: 100% !important;
    font-size: 0 !important;
    gap: 0 !important;
}

.sidebar.collapsed .nav-item .material-symbols-outlined {
    font-size: 24px !important;
    margin: 0 !important;
}

.sidebar.collapsed .sidebar-header {
    justify-content: center;
    padding: 22px 0 16px;
}
.sidebar.collapsed .collapse-btn { transform: rotate(180deg); }
.sidebar.collapsed .logo-icon-sm { display: none !important; margin: 0; }




.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 22px 20px 16px;
    border-bottom: 1px solid var(--border);
}
.logo-icon-sm { color: var(--accent); font-size: 22px !important; }
.sidebar-title { font-weight: 600; font-size: 16px; }

.sidebar-nav { padding: 12px 10px; flex: 1; }

.nav-item {
    display: flex; align-items: center; gap: 10px;
    width: 100%;
    padding: 10px 14px;
    border-radius: 10px;
    background: transparent;
    color: var(--text-dim);
    font-size: 14px; font-weight: 500;
    margin-bottom: 4px;
    transition: all 0.2s;
}
.nav-item:hover { background: var(--surface-hover); color: var(--text); }
.nav-item.active { background: var(--accent-dim); color: var(--accent); }
.nav-icon-badge-host {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
    line-height: 1;
}

.sidebar-footer {
    display: flex; align-items: center; justify-content: space-between;
    padding: 14px 16px;
    border-top: 1px solid var(--border);
}

.admin-chip {
    display: flex; align-items: center; gap: 10px;
    min-width: 0;
}
.admin-chip strong { display: block; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.admin-chip small { color: var(--text-dim); font-size: 12px; }

/* MAIN CONTENT */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    height: 100vh;
    height: 100dvh;
    min-height: 0;
    overflow: hidden;
    position: relative;
    background: var(--bg);
}

.panel {
    padding: 36px 40px;
    max-width: 900px;
    margin: 0 auto;
    width: 100%;
    overflow-x: hidden;
    overflow-y: auto; height: 100%;
}

#panelUsers,
#panelSettings,
#settingsPanel {
    max-width: none;
}

#panelUsers > *,
#panelSettings > *,
#settingsPanel > * {
    width: 100%;
    max-width: 900px;
    margin-left: auto;
    margin-right: auto;
}

/* ----------------------------------------------------------------- conference panel */

.conference-panel {
    padding: 0;
    max-width: none;
    margin: 0;
    overflow: hidden;
    width: 100%;
    height: 100%;
}
.conference-mount {
    width: 100%;
    height: 100%;
    display: flex;
}
.conference-mount > iframe {
    flex: 1;
    width: 100%;
    height: 100%;
    border: 0;
    display: block;
}

/* Floating island shown when a call is active and the user is browsing
   another panel of the messenger. Click → return to conference. */
.conf-floating-island {
    position: fixed;
    top: 18px;
    right: 18px;
    z-index: 1900;
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px 10px 12px;
    min-height: 44px;
    min-width: 174px;
    box-sizing: border-box;
    background: var(--accent, #2962ff);
    color: #fff;
    border-radius: 18px;
    box-shadow: 0 6px 24px rgba(0, 0, 0, 0.28);
    cursor: pointer;
    user-select: none;
    font-weight: 600;
    transition: box-shadow .15s ease, top .22s cubic-bezier(0.4, 0, 0.2, 1), left .22s cubic-bezier(0.4, 0, 0.2, 1), right .22s cubic-bezier(0.4, 0, 0.2, 1), bottom .22s cubic-bezier(0.4, 0, 0.2, 1);
}
.conf-floating-island:hover {
    box-shadow: 0 10px 28px rgba(0, 0, 0, 0.32);
}
.conf-floating-island.is-dragging {
    transition: none !important;
    cursor: grabbing;
    box-shadow: 0 14px 36px rgba(0, 0, 0, 0.38);
}
.conf-floating-island.hidden { display: none; }

.conf-floating-island .conf-floating-timer {
    font-variant-numeric: tabular-nums;
    letter-spacing: 0;
}
.conf-floating-island .conf-floating-back .material-symbols-outlined {
    font-size: 18px;
    opacity: 0.9;
}
.conf-floating-island .conf-floating-label {
    font-size: 12px;
    line-height: 1;
    opacity: 0.92;
}

/* ----------------------------------------------------------------- embed mode (?embed=1) */

html[data-embed="1"] body,
body[data-embed="1"] {
    background: transparent !important;
}
html[data-embed="1"] .sidebar,
body[data-embed="1"] .sidebar {
    display: none !important;
}
html[data-embed="1"] #authView,
html[data-embed="1"] #successView,
body[data-embed="1"] #authView,
body[data-embed="1"] #successView {
    display: none !important;
}
html[data-embed="1"] [data-panel="panelConference"],
html[data-embed="1"] [data-user-panel="userConferencePanel"],
body[data-embed="1"] [data-panel="panelConference"],
body[data-embed="1"] [data-user-panel="userConferencePanel"] {
    display: none !important;
}
html[data-embed="1"] .app-layout,
body[data-embed="1"] .app-layout {
    grid-template-columns: 1fr !important;
}
/* Inside the embed, hide the floating island — we are already inside the call. */
html[data-embed="1"] #confFloatingIsland,
body[data-embed="1"] #confFloatingIsland {
    display: none !important;
}
/* When embedded with a specific partner, hide the "back to contacts" button. */
html[data-embed-partner="1"] #backToUsersBtn,
body[data-embed-partner="1"] #backToUsersBtn,
html[data-embed-partner="1"] #adminChatBackBtn,
body[data-embed-partner="1"] #adminChatBackBtn {
    display: none !important;
}
/* In embed mode, hide the audio-call buttons in the chat header — calls are
   already happening in the parent conference window and these would be confusing. */
html[data-embed="1"] #adminCallBtn,
html[data-embed="1"] #userCallBtn,
body[data-embed="1"] #adminCallBtn,
body[data-embed="1"] #userCallBtn {
    display: none !important;
}

.panel-admin-storage,
.panel-admin-diagnostics,
.panel-admin-audit-log {
    max-width: 980px;
    margin: 18px auto;
    padding: 28px;
    background: var(--panel-msg-area);
    border: 1px solid var(--border);
    border-radius: 28px;
    box-shadow: 0 16px 42px rgba(15, 23, 41, 0.08);
}

.panel-admin-storage .chat-main,
.panel-admin-diagnostics .chat-main,
.panel-admin-audit-log .chat-main {
    display: block;
    height: auto;
    min-height: 0;
    background: transparent;
    overflow: visible !important;
}

.panel-header { margin-bottom: 24px; }
.panel-header h2 { font-size: 24px; font-weight: 600; margin-bottom: 8px; }
.panel-header p { color: var(--text-dim); font-size: 15px; }

/* Fixed chat panel flex structure */
#panelChat {
    height: 100%;
    display: flex;
    flex-direction: column;
    min-height: 0;
    padding: 0;
    max-width: none;
    position: relative;
    margin: 0;
}

#chatPanel {
    display: flex;
    flex-direction: column;
    height: 100%;
    min-height: 0;
    position: relative;
}

/* USERS LIST */
.users-list { display: grid; gap: 10px; }
.admin-users-lazy-sentinel {
    min-height: 56px;
    display: flex;
    align-items: center;
    justify-content: center;
}
.admin-users-lazy-sentinel .app-spinner {
    width: 24px;
    height: 24px;
    border-width: 2px;
}
.user-row {
    display: flex; align-items: center; gap: 14px;
    padding: 16px 20px;
    min-height: 84px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 16px;
    cursor: pointer;
    transition: all 0.2s;
    max-width: 100%;
    box-sizing: border-box;
    overflow: hidden;
}
.user-row:hover { border-color: var(--accent); background: var(--surface-hover); transform: translateY(-1px); }
.user-row.is-active { border-color: var(--accent); background: var(--surface-hover); }
.user-row.is-notes { border-style: dashed; }
.user-row-avatar {
    width: 46px; height: 46px;
    background: var(--accent);
    color: #fff;
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: 18px;
    flex-shrink: 0;
}
.user-row-info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
}
.user-row-name { font-weight: 600; font-size: 16px; display: block; margin-bottom: 4px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-row-role { font-size: 13px; color: var(--text-dim); display: flex; align-items: center; gap: 6px; }
.user-row-lastmsg { font-size: 13px; color: var(--text-dim); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; margin-top: 2px; }
.user-row-note { font-size: 12px; color: var(--accent); display: flex; align-items: center; gap: 6px; margin-top: 6px; overflow: hidden; }
.user-row-note .material-symbols-outlined { font-size: 15px; flex: 0 0 auto; }
.user-row-note-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-row-indicator { display: flex; align-items: center; gap: 6px; margin-top: 6px; font-size: 12px; }
.user-row-key-warning { color: #eab308; display: flex; align-items: center; gap: 6px; }
.user-row-key-warning .material-symbols-outlined { font-size: 15px; flex: 0 0 auto; text-decoration: line-through; opacity: 0.7; }
.user-row-new-account { color: var(--danger); display: flex; align-items: center; gap: 6px; font-weight: 500; }
.user-row-new-account .material-symbols-outlined { font-size: 15px; flex: 0 0 auto; }
.user-row-new-account .countdown { font-variant-numeric: tabular-nums; }

.user-row-actions {
    display: flex; gap: 8px; align-items: center;
}
.user-action-btn {
    width: 36px; height: 36px;
    border-radius: 10px;
    background: var(--surface);
    border: 1px solid var(--border);
    color: var(--text-dim);
    display: flex; align-items: center; justify-content: center;
    transition: 0.2s; cursor: pointer;
}
.user-action-btn:hover { background: var(--surface-hover); color: var(--text); border-color: var(--text-dim); }
.user-action-btn.del-btn:hover { background: rgba(255, 71, 87, 0.15); color: var(--danger); border-color: rgba(255, 71, 87, 0.3); }

/* CHAT AREA */
.chat-main {
    flex: 1;
    display: flex; flex-direction: column;
    height: 100vh;
    height: 100dvh;
    min-height: 0;
    position: relative;
    background: var(--panel-msg-area);
}

.chat-topbar, .chat-topbar-admin {
    display: flex; align-items: center; gap: 14px;
    padding: 16px 24px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    backdrop-filter: blur(10px);
    flex-shrink: 0;
    position: relative;
    z-index: 30;
}
.pinned-banner {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    z-index: 25;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    padding: 12px 24px;
    background: var(--surface);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-bottom: 1px solid rgba(76, 154, 255, 0.24);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.18);
    cursor: pointer;
    overflow: hidden;
    max-height: 200px;
    opacity: 1;
    transform: translateY(0);
    transition:
        opacity 200ms cubic-bezier(0.22, 0.9, 0.32, 1),
        transform 200ms cubic-bezier(0.22, 0.9, 0.32, 1),
        max-height 200ms cubic-bezier(0.22, 0.9, 0.32, 1),
        padding 200ms cubic-bezier(0.22, 0.9, 0.32, 1),
        border-bottom-width 200ms cubic-bezier(0.22, 0.9, 0.32, 1);
}
.pinned-banner.hidden {
    display: flex !important;
    opacity: 0;
    transform: translateY(-12px);
    pointer-events: none;
}
.pinned-banner-copy {
    min-width: 0;
    flex: 1;
}
.pinned-banner-label {
    display: block;
    margin-bottom: 4px;
    font-size: 11px;
    font-weight: 700;
    color: #4c9aff;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}
.pinned-banner-text {
    color: var(--text);
    font-size: 14px;
    line-height: 1.35;
    word-break: break-word;
}
.pinned-banner-copy-file {
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.pinned-banner-file-row {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}
.pinned-banner-thumb {
    width: 38px;
    height: 38px;
    border-radius: 10px;
    flex: none;
}
.pinned-banner-file-icon {
    width: 38px;
    height: 38px;
    border-radius: 10px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: none;
    background: rgba(76, 154, 255, 0.12);
    color: #4c9aff;
    font-size: 20px;
}
.pinned-banner-file-copy {
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.pinned-banner-file-copy .pinned-banner-text {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.pinned-banner-file-meta {
    font-size: 12px;
    color: var(--text-dim);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.pinned-banner-icon {
    color: #4c9aff;
    flex-shrink: 0;
}
.pinned-banner-actions {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    flex: none;
}
.pinned-banner-unpin-btn {
    width: 28px;
    height: 28px;
    border: 1px solid rgba(100, 116, 139, 0.22);
    border-radius: 50%;
    background: rgba(15, 23, 41, 0.16);
    color: var(--text-dim);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    cursor: pointer;
    transition: background 0.18s ease, color 0.18s ease, border-color 0.18s ease, transform 0.18s ease;
}
.pinned-banner-unpin-btn:hover {
    background: rgba(239, 68, 68, 0.14);
    border-color: rgba(239, 68, 68, 0.32);
    color: #ef4444;
    transform: scale(1.04);
}
.pinned-banner-unpin-btn .material-symbols-outlined {
    font-size: 18px !important;
}

.contact-avatar {
    width: 44px; height: 44px;
    background: var(--accent);
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-weight: 700; color: #fff;
    flex-shrink: 0;
}
.contact-avatar-sm {
    width: 24px; height: 24px;
    background: var(--accent);
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-size: 12px; color: #fff;
    margin-right: 4px;
}

.messages-area {
    flex: 1; overflow-y: auto; overflow-x: hidden;
    min-height: 0;
    padding: 24px;
    display: flex; flex-direction: column; gap: 10px;
}

.messages-date-divider {
    text-align: center;
    margin: 20px auto;
    padding: 6px 14px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 20px;
    font-size: 12px;
    color: var(--text-dim);
    width: fit-content;
}
.messages-area > .messages-date-divider:first-child,
.messages-area > .msg-date-separator:first-child {
    margin-top: 100px;
}

.msg-wrap { display: flex; flex-direction: column; max-width: 75%; position: relative; --swipe-reply-progress: 0; }
@media (hover: none) and (pointer: coarse) {
    .msg-wrap { touch-action: pan-y; -webkit-user-select: none; user-select: none; }
}
.msg-wrap.is-swiping-reply { will-change: transform; }
.msg-wrap.swipe-reply-snapping { transition: transform 180ms ease; }
.msg-wrap.is-swiping-reply::after,
.msg-wrap.swipe-reply-snapping::after {
    content: 'reply';
    font-family: 'Material Symbols Outlined', 'Material Icons';
    font-weight: normal;
    font-size: 22px;
    position: absolute;
    top: 50%;
    right: -44px;
    width: 34px;
    height: 34px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: var(--accent-dim, rgba(76, 154, 255, 0.2));
    color: var(--accent);
    opacity: calc(var(--swipe-reply-progress) * 1);
    transform: translateY(-50%) scale(calc(0.7 + var(--swipe-reply-progress) * 0.3));
    pointer-events: none;
}
.msg-wrap.swipe-reply-snapping::after { transition: opacity 180ms ease, transform 180ms ease; }
.msg-wrap.incoming { align-self: flex-start; align-items: flex-start; }
.msg-wrap.outgoing { align-self: flex-end; align-items: flex-end; }
.msg-wrap.system-message { max-width: 100%; align-self: center; }
.msg-wrap.message-jump-highlight .msg-bubble {
    box-shadow: 0 0 0 2px rgba(255, 71, 87, 0.92), 0 0 28px rgba(255, 71, 87, 0.32);
}
.msg-date-separator.message-jump-highlight span {
    box-shadow: 0 0 0 2px rgba(255, 71, 87, 0.92), 0 0 28px rgba(255, 71, 87, 0.26);
}
.msg-wrap.message-pinned .msg-bubble {
    box-shadow: 0 0 0 2px rgba(76, 154, 255, 0.85), 0 0 22px rgba(76, 154, 255, 0.16);
}

.msg-bubble {
    padding: 12px 16px;
    border-radius: 18px;
    font-size: var(--msg-font-size, 15px);
    line-height: 1.4;
    word-break: break-word;
}
.incoming .msg-bubble { background: var(--msg-in); border-bottom-left-radius: 4px; }
.outgoing .msg-bubble { background: var(--msg-out); border: 1px solid var(--msg-out-border); border-bottom-right-radius: 4px; cursor: context-menu; }
.msg-reply {
    margin-bottom: 10px;
    padding: 10px 12px;
    border-left: 3px solid var(--accent);
    border-radius: 12px;
    background: rgba(255,255,255,0.05);
    cursor: pointer;
}
.msg-reply-author {
    font-size: 11px;
    font-weight: 700;
    color: var(--accent);
    margin-bottom: 4px;
}
.msg-reply-text {
    font-size: 13px;
    color: var(--text-dim);
    line-height: 1.35;
}
.reply-file-preview {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
    max-width: 100%;
}
.reply-file-thumb {
    flex: none;
    width: 32px;
    height: 32px;
    border-radius: 6px;
    overflow: hidden;
    background: var(--surface-hover);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    position: relative;
}
.reply-file-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}
.reply-file-thumb .file-attachment-placeholder {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    color: var(--text-dim);
}
.reply-file-icon {
    flex: none;
    font-size: 20px;
    color: var(--text-dim);
}
.reply-file-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    min-width: 0;
    flex: 1;
}

.msg-meta { display: flex; align-items: center; gap: 8px; margin-top: 4px; flex-wrap: wrap; }
.incoming .msg-meta { justify-content: flex-start; }
.outgoing .msg-meta { justify-content: flex-end; }
.msg-time { font-size: 11px; color: var(--text-dim); }
.msg-status-group { display: inline-flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.msg-status-separator { font-size: 11px; color: var(--text-dim); }
.typing-indicator {
    pointer-events: none;
}
.typing-bubble {
    display: inline-flex;
    align-items: center;
    min-width: 72px;
    padding: 14px 16px;
}
.typing-dots {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}
.typing-dots span {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--text-dim);
    opacity: 0.35;
    animation: typing-dot 1.2s infinite ease-in-out;
}
.typing-dots span:nth-child(2) {
    animation-delay: 0.2s;
}
.typing-dots span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typing-dot {
    0%, 80%, 100% {
        opacity: 0.3;
        transform: translateY(0);
    }
    40% {
        opacity: 1;
        transform: translateY(-2px);
    }
}
.msg-edited-status { font-size: 11px; color: var(--text-dim); }
.msg-read-status { font-size: 11px; color: var(--accent); font-weight: 600; }
.msg-sender { font-size: 12px; font-weight: 600; color: var(--accent); margin-bottom: 2px; }

.chat-input-bar {
    padding: 16px 24px;
    background: var(--surface);
    border-top: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    gap: 12px;
    flex-shrink: 0;
}
.chat-compose-row {
    width: 100%;
    display: flex;
    align-items: flex-end;
    gap: 8px;
}
.chat-compose-row > textarea {
    order: 2;
    flex: 1 1 auto;
    min-width: 0;
}
.chat-compose-row > .composer-actions {
    order: 3;
    display: contents;
}
.chat-compose-row .emoji-picker-wrap {
    order: 1;
    flex: 0 0 auto;
}
.chat-compose-row .attach-btn {
    order: 3;
}
.chat-compose-row .edit-cancel-btn {
    order: 4;
}
.chat-compose-row .send-btn {
    order: 5;
}
.composer-actions {
    display: flex;
    align-items: flex-end;
    gap: 8px;
}
.composer-context {
    width: 100%;
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 14px;
    border-radius: 14px;
    border: 1px solid rgba(28, 206, 94, 0.28);
    background: rgba(28, 206, 94, 0.08);
}
.composer-context-copy {
    min-width: 0;
}
.composer-context-label {
    display: block;
    margin-bottom: 4px;
    font-size: 11px;
    font-weight: 700;
    color: var(--accent);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
.composer-context-text {
    font-size: 13px;
    color: var(--text);
    line-height: 1.4;
    word-break: break-word;
}
.composer-context-close {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-dim);
    background: transparent;
    flex-shrink: 0;
}

.send-btn {
    width: 48px; height: 48px;
    min-width: 48px;
    flex: 0 0 48px;
    background: var(--accent); color: #fff;
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    transition: transform 0.2s;
}
.send-btn.is-confirm { background: var(--accent-hover); }
.send-btn:hover:not(:disabled) { transform: scale(1.05); }
.send-btn:disabled { opacity: 0.3; }
.send-btn.is-sending { opacity: 1; cursor: default; }
.send-btn.is-sending:hover { transform: none; }
.send-btn.is-sending .material-symbols-outlined { display: none; }
.send-btn.is-sending::after {
    content: '';
    width: 20px;
    height: 20px;
    border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, 0.35);
    border-top-color: #fff;
    animation: spin 0.8s linear infinite;
}
.emoji-picker-wrap {
    position: relative;
}
.emoji-toggle-btn {
    width: 48px;
    height: 48px;
    min-width: 48px;
    flex: 0 0 48px;
    border-radius: 50%;
    background: var(--surface);
    border: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: center;
}
.emoji-toggle-btn:hover {
    color: var(--accent);
    border-color: var(--accent);
}
.emoji-loading {
    padding: 28px 12px;
    text-align: center;
    color: var(--text-dim);
    font-size: 13px;
}
.emoji-picker {
    position: absolute;
    left: 0;
    right: auto;
    bottom: calc(100% + 10px);
    width: 336px;
    max-height: 380px;
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    overflow-y: auto;
    border-radius: 18px;
    border: 1px solid rgba(15, 23, 41, 0.12);
    background: rgba(255, 255, 255, 0.98);
    color: #0f1729;
    box-shadow: 0 20px 40px rgba(15, 23, 41, 0.18);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    overscroll-behavior: contain;
    touch-action: pan-y;
    user-select: none;
    -webkit-user-select: none;
    z-index: 20;
}
.emoji-section {
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.emoji-section + .emoji-section {
    padding-top: 12px;
    border-top: 1px solid rgba(15, 23, 41, 0.08);
}
.emoji-section-title {
    font-size: 11px;
    font-weight: 700;
    color: #64748b;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}
.emoji-grid {
    display: grid;
    grid-template-columns: repeat(6, minmax(0, 1fr));
    gap: 8px;
}
.emoji-option {
    width: 100%;
    aspect-ratio: 1;
    border-radius: 12px;
    background: transparent;
    border: 1px solid rgba(15, 23, 41, 0.05);
    color: #0f1729;
    font-size: 22px;
    line-height: 1;
    touch-action: manipulation;
}
.emoji-option:hover {
    background: rgba(15, 23, 41, 0.06);
    border-color: rgba(15, 23, 41, 0.12);
}
.emoji-option:focus-visible {
    outline: none;
    border-color: rgba(28, 206, 94, 0.55);
    box-shadow: 0 0 0 3px rgba(28, 206, 94, 0.16);
}

/* SETTINGS */
.settings-list {
    display: flex; flex-direction: column; gap: 16px; margin-top: 20px;
    -ms-overflow-style: none; scrollbar-width: none;
    overflow-y: auto; overflow-x: hidden;
    padding-bottom: 30px; /* buffer to avoid clipping */
}
.settings-list::-webkit-scrollbar { display: none; }
#panelSettings .settings-list,
#settingsPanel .settings-list {
    overflow: visible;
}
.settings-section {
    display: flex;
    flex-direction: column;
    gap: 12px;
}
.settings-section-title {
    margin: 0;
    padding: 0 4px;
    color: var(--text-dim);
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}
.settings-section-items {
    display: flex;
    flex-direction: column;
    gap: 0;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 16px;
    overflow: hidden;
}
.settings-section-items > .settings-item {
    background: transparent;
    border: 0;
    border-radius: 0;
}
.settings-section-items > .settings-item + .settings-item {
    border-top: 1px solid var(--border);
}
.settings-section-items > .danger-btn {
    width: auto;
    margin: 12px;
}
select.secret-phrase-input {
    background: var(--surface); color: var(--text);
}
select.secret-phrase-input option {
    background: var(--surface); color: var(--text);
}
.settings-item {
    display: flex; align-items: center; justify-content: space-between;
    padding: 16px 20px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 16px;
}
.settings-item-info { display: flex; align-items: center; gap: 14px; }
.settings-item-info .material-symbols-outlined { color: var(--text-dim); }
.settings-item-info strong { display: block; font-size: 16px; }
.settings-item-info small { color: var(--text-dim); font-size: 13px; line-height: 1.45; }

.settings-divider { height: 1px; background: var(--border); margin: 8px 0; }

.theme-mode-control {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px;
    border-radius: 16px;
    background: var(--input-bg);
    border: 1px solid var(--input-border);
    flex-shrink: 0;
    max-width: 100%;
    box-sizing: border-box;
}
.theme-mode-btn {
    width: 42px;
    height: 42px;
    border-radius: 12px;
    background: transparent;
    border: 1px solid transparent;
    color: var(--text-dim);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s, color 0.2s, border-color 0.2s, box-shadow 0.2s;
}
.theme-mode-btn .material-symbols-outlined {
    color: inherit;
}
.theme-mode-btn:hover {
    color: var(--text);
    background: var(--surface-hover);
}
.theme-mode-btn.is-active {
    color: var(--text);
    background: var(--surface);
    border-color: rgba(28, 206, 94, 0.34);
    box-shadow: 0 0 0 3px rgba(28, 206, 94, 0.12);
}
.theme-mode-dot {
    width: 11px;
    height: 11px;
    border-radius: 50%;
    background: currentColor;
}

.secret-field-row {
    width: 100%;
    display: flex;
    align-items: stretch;
    gap: 8px;
}
.secret-phrase-input {
    padding: 13px 16px;
    font-family: inherit;
    letter-spacing: 0.01em;
}
.secret-field-btn {
    width: 48px;
    min-width: 48px;
    border-radius: 12px;
    background: var(--surface);
    border: 1px solid var(--border);
    color: var(--text);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s, border-color 0.2s, color 0.2s, opacity 0.2s;
}
.secret-field-btn:hover:not(:disabled) {
    background: var(--surface-hover);
    border-color: var(--accent);
    color: var(--accent);
}
.secret-field-btn:disabled,
.secret-field-btn.is-disabled {
    opacity: 0.45;
    cursor: not-allowed;
}
.password-recovery-actions {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 10px;
    align-items: flex-start;
}
.display-name-editor {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 10px;
    align-items: stretch;
    margin-top: 10px;
}
.display-name-save-btn {
    align-self: flex-start;
}
.display-name-input {
    flex: 1;
    padding: 10px 12px;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text);
    font-size: 0.95em;
    outline: none;
    transition: border-color 0.15s, box-shadow 0.15s;
}
.display-name-input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(88,166,255,0.18);
}
.display-name-save-btn {
    padding: 10px 18px;
    white-space: nowrap;
}
.display-name-hint {
    display: block;
    margin-top: 6px;
    min-height: 1em;
    opacity: 0.85;
}
.display-name-hint.error {
    color: #f87171;
    opacity: 1;
}
.display-name-hint.success {
    color: #4ade80;
    opacity: 1;
}
.recovery-trigger-btn {
    width: 100%;
    justify-content: center;
}
.password-recovery-hint {
    color: var(--text-dim);
    font-size: 13px;
}
.password-recovery-hint.is-error {
    color: var(--warning);
}

/* TOGGLE SWITCH */
.toggle {
    position: relative;
    display: inline-block;
    width: 50px;
    height: 26px;
}
.toggle input { opacity: 0; width: 0; height: 0; }
.toggle-slider {
    position: absolute; cursor: pointer;
    top: 0; left: 0; right: 0; bottom: 0;
    background-color: var(--border);
    transition: .4s; border-radius: 34px;
}
.toggle-slider:before {
    position: absolute; content: "";
    height: 18px; width: 18px;
    left: 4px; bottom: 4px;
    background-color: white;
    transition: .4s; border-radius: 50%;
}
input:checked + .toggle-slider { background-color: var(--accent); }
input:checked + .toggle-slider:before { transform: translateX(24px); }

/* MISC */
.copy-group { display: flex; gap: 8px; align-items: center; }
.copy-group input { padding-left: 14px; }
.copy-group button {
    padding: 0 16px; background: var(--surface);
    border: 1px solid var(--border); border-radius: 12px;
    color: var(--text);
}
.copy-group button:hover { background: var(--accent); color: #fff; }
.invite-box { margin-top: 18px; }
.invite-box label { display: block; margin-bottom: 10px; }
.invite-history-card {
    margin-top: 22px;
    padding: 20px;
    border-radius: 18px;
    background: var(--surface);
    border: 1px solid var(--border);
}
.invite-history-header {
    margin-bottom: 14px;
}
.invite-history-header h3 {
    margin: 0 0 6px;
    font-size: 18px;
}
.invite-history-header p {
    margin: 0;
    color: var(--text-dim);
    font-size: 14px;
}
.invite-table-wrap {
    width: 100%;
    overflow-x: auto;
}
.invite-table {
    width: 100%;
    border-collapse: collapse;
    min-width: 640px;
}
.invite-table th,
.invite-table td {
    padding: 14px 12px;
    text-align: left;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}
.invite-table th {
    color: var(--text-dim);
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
.invite-link-cell {
    min-width: 0;
}
.invite-link-anchor {
    display: block;
    color: var(--accent);
    text-decoration: none;
    word-break: break-all;
}
.invite-link-anchor:hover {
    text-decoration: underline;
}
.invite-link-meta {
    margin-top: 6px;
    color: var(--text-dim);
    font-size: 12px;
}
.invite-status-chip {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    border-radius: 999px;
    font-size: 13px;
    font-weight: 600;
    border: 1px solid transparent;
}
.invite-status-chip .material-symbols-outlined {
    font-size: 18px;
}
.invite-status-active {
    background: rgba(36, 169, 110, 0.12);
    color: #24a96e;
    border-color: rgba(36, 169, 110, 0.2);
}
.invite-status-used {
    background: rgba(231, 76, 60, 0.12);
    color: #e74c3c;
    border-color: rgba(231, 76, 60, 0.2);
}
.invite-status-revoked {
    background: rgba(127, 140, 141, 0.14);
    color: #95a5a6;
    border-color: rgba(127, 140, 141, 0.2);
}
.invite-status-meta {
    margin-top: 8px;
    color: var(--text-dim);
    font-size: 12px;
    line-height: 1.4;
}
.invite-actions {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
}
.invite-action-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 12px;
    border-radius: 12px;
    border: 1px solid var(--border);
    background: var(--panel-msg-area);
    color: var(--text);
    cursor: pointer;
    transition: 0.2s ease;
}
.invite-action-btn:hover {
    border-color: var(--accent);
    color: var(--accent);
}
.invite-action-btn.is-danger:hover {
    border-color: rgba(231, 76, 60, 0.4);
    color: var(--danger);
}
.invite-table-empty {
    text-align: center !important;
    color: var(--text-dim);
    padding: 28px 12px !important;
}

.seed-copy-group {
    align-items: stretch;
    margin-bottom: 20px;
}
.seed-copy-group .seed-phrase-box { margin-bottom: 0; }
.seed-copy-group button {
    min-width: 56px;
    align-self: stretch;
    display: flex;
    align-items: center;
    justify-content: center;
}

.seed-phrase-box {
    background: var(--accent-dim);
    color: var(--accent);
    padding: 20px; border-radius: 16px;
    font-size: 20px; font-weight: 700;
    border: 2px dashed var(--accent);
    margin-bottom: 20px;
    flex: 1;
}

.warning-box {
    background: rgba(255, 171, 0, 0.1);
    color: var(--warning);
    padding: 16px; border-radius: 12px;
    display: flex; gap: 12px; font-size: 14px;
    margin-bottom: 24px; text-align: left;
    line-height: 1.45;
}
.warning-box p {
    margin: 0;
}
.warning-box p + p {
    margin-top: 10px;
}
.warning-box strong {
    color: var(--text);
}
[data-theme="light"] .warning-box {
    background: rgba(184, 120, 0, 0.18);
    color: #8a5a00;
}

.settings-item.vertical-settings {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
}

.volume-slider {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 6px;
    background: var(--border);
    border-radius: 3px;
    outline: none;
    padding: 0;
    margin: 0;
}
.volume-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 18px;
    height: 18px;
    background: var(--accent);
    cursor: pointer;
    border-radius: 50%;
    border: 3px solid var(--bg);
    box-shadow: 0 0 10px rgba(0,0,0,0.2);
}

.chat-header-info { padding-left: 10px; flex: 1; min-width: 0; display: flex; align-items: center; gap: 8px; }
.chat-header-name {
    font-size: 16px;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.chat-header-clock-wrapper {
    display: flex;
    align-items: center;
}
@media (max-width: 768px) {
    .chat-header-clock-wrapper {
        margin-left: auto;
        padding-right: 4px;
    }
}
.hdr-indicator-wrap {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    color: var(--accent);
    font-size: 13px;
    font-weight: 500;
    margin-left: 6px;
}
.hdr-typing-dots {
    display: inline-flex;
    align-items: center;
    gap: 3px;
}
.hdr-typing-dots span {
    width: 4px;
    height: 4px;
    border-radius: 50%;
    background: var(--accent);
    opacity: 0.35;
    animation: typing-dot 1.2s infinite ease-in-out;
}
.hdr-typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.hdr-typing-dots span:nth-child(3) { animation-delay: 0.4s; }

.anim-spin {
    animation: spin 1s linear infinite;
}
@keyframes spin { 100% { transform: rotate(360deg); } }
.chat-refresh-btn {
    order: -1;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--text-dim);
    background: var(--surface);
    border: 1px solid var(--border);
    transition: transform 0.2s ease, border-color 0.2s ease;
}
.chat-refresh-btn .material-symbols-outlined {
    transition: transform 0.2s ease;
}
.chat-refresh-btn:hover {
    color: var(--text-dim);
    border-color: var(--border);
}
.chat-refresh-btn.is-spinning .material-symbols-outlined {
    animation: chat-refresh-spin 0.55s ease;
}
@keyframes chat-refresh-spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}
.msk-clock { font-size: 11px; color: var(--text-dim); font-weight: 500; display: inline-flex; align-items: center; white-space: nowrap; }
.chat-header-status { font-size: 11px; color: var(--text-dim); display: flex; align-items: center; gap: 6px; margin-top: 4px; }
.chat-header-status:empty { display: none; }
.status-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.status-dot.online { background: #2ecc71; box-shadow: 0 0 8px rgba(46, 204, 113, 0.4); }
.status-dot.offline { background: #95a5a6; }

/* Slider with small/large labels (font size) */
.slider-with-labels {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
}
.slider-label-sm {
    font-size: 12px;
    color: var(--text-dim);
    flex-shrink: 0;
    font-weight: 600;
    min-width: 14px;
    text-align: center;
}
.slider-label-lg {
    font-size: 18px;
    color: var(--text-dim);
    flex-shrink: 0;
    font-weight: 600;
    min-width: 18px;
    text-align: center;
}

/* Settings item wrapping allowed for small controls */
.settings-item {
    flex-wrap: wrap;
}
.settings-item-info {
    min-width: 0;
    flex: 1;
}
.settings-item-info > div {
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.action-btn-copy {
    display: inline-flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 3px;
    text-align: left;
    line-height: 1.2;
}
.action-btn-label {
    font-size: 17px;
    font-weight: 700;
    line-height: 1.2;
}
.action-btn-note {
    font-size: 14px;
    color: rgba(255, 255, 255, 0.78);
    font-weight: 500;
    line-height: 1.3;
}
.secondary-outline-btn .action-btn-note {
    color: var(--text);
    opacity: 0.92;
}
.devices-open-btn {
    align-self: stretch;
    font-size: 15px;
    font-weight: 600;
}
.devices-open-btn .action-btn-label {
    font-size: inherit;
    font-weight: inherit;
}
.devices-modal-list {
    gap: 16px !important;
}
.devices-modal-card {
    width: min(92vw, 620px);
    max-width: 620px;
    max-height: calc(100dvh - 32px);
    overflow-y: auto;
    overscroll-behavior: contain;
    scrollbar-gutter: stable;
}
.devices-modal-list-shell {
    max-height: min(40dvh, 340px);
    overflow-y: auto;
    padding-right: 8px;
}
.devices-actions-block {
    gap: 32px !important;
}
.devices-block-head {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 14px;
}
.devices-block-title {
    text-align: left;
    font-size: 20px;
    line-height: 1.25;
    margin: 0;
}
.devices-block-head + .devices-option {
    margin-top: -12px;
}
.devices-info-btn {
    width: auto;
    margin: 0;
    padding: 10px 14px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    background: rgba(25, 53, 55, 0.82);
}
.devices-info-btn .material-symbols-outlined {
    font-size: 18px !important;
}
.devices-option {
    gap: 16px !important;
}
.devices-option-btn {
    min-height: 68px;
    padding: 14px 18px;
}
.devices-option-btn:disabled {
    opacity: 0.55;
    cursor: not-allowed;
    pointer-events: none;
    box-shadow: none !important;
    transform: none !important;
}
#devicesGenerateManualBtn:disabled,
#devicesGenerateAutolinkBtn:disabled {
    background: #64748b !important;
    border-color: #64748b !important;
    color: rgba(255, 255, 255, 0.92) !important;
}
#devicesGenerateManualBtn:disabled .action-btn-note,
#devicesGenerateAutolinkBtn:disabled .action-btn-note {
    color: rgba(255, 255, 255, 0.82) !important;
    opacity: 1 !important;
}
#devicesGenerateManualBtn {
    background: #169a4a;
}
#devicesGenerateManualBtn .action-btn-note {
    color: #ffffff;
    opacity: 1;
}
#devicesGenerateManualBtn:hover {
    background: #12833f;
}
.option-copy {
    display: flex;
    flex-direction: column;
    gap: 6px;
    color: #7b8ea7 !important;
    font-size: 14px;
    line-height: 1.48;
    font-weight: 500;
    padding: 0 24px 4px;
}
.devices-option-accent .option-copy {
    color: #7b8ea7 !important;
}
.option-copy p {
    margin: 0;
    color: #7b8ea7 !important;
}
.devices-option-accent .option-copy p {
    color: #7b8ea7 !important;
}
.devices-option .warning-box {
    background: #2a3a4f;
    color: #e2e8f0 !important;
    border: 1px solid #f59e0b;
    padding: 20px;
    margin-top: 8px !important;
}
.devices-option .warning-box p,
.devices-option .warning-box strong,
.devices-option .warning-box > div {
    color: #e2e8f0 !important;
}
.devices-option .warning-box .material-symbols-outlined {
    color: #f59e0b;
}
.devices-option .warning-box > div {
    padding: 0 24px 0 12px;
}
#devicesGenerateAutolinkBtn {
    background: #169a4a;
    color: #ffffff;
    border-color: #169a4a;
    transition: background-color 0.22s ease, border-color 0.22s ease, box-shadow 0.22s ease, transform 0.1s ease;
}
#devicesGenerateAutolinkBtn .action-btn-note {
    color: #ffffff;
    opacity: 1;
}
#devicesGenerateAutolinkBtn:hover {
    background: #12833f;
    border-color: #12833f;
}
[data-theme="light"] .devices-option-accent {
    background: #e2e8f0 !important;
    border-color: #cbd5e1 !important;
    box-shadow: 0 1px 0 rgba(148, 163, 184, 0.2);
}
[data-theme="light"] .action-btn-note {
    color: #475569;
    opacity: 1;
}
[data-theme="light"] .option-copy,
[data-theme="light"] .option-copy p,
[data-theme="light"] .devices-option-accent .option-copy,
[data-theme="light"] .devices-option-accent .option-copy p {
    color: #334155 !important;
    font-weight: 600;
}
[data-theme="light"] .devices-option .warning-box {
    background: #f8fafc;
    color: #475569 !important;
    border: 1px solid #f59e0b;
}
[data-theme="light"] .devices-option .warning-box p,
[data-theme="light"] .devices-option .warning-box > div {
    color: #334155 !important;
}
[data-theme="light"] .devices-option .warning-box strong {
    color: #1e293b !important;
}
[data-theme="light"] #devicesGenerateAutolinkBtn {
    background: #169a4a;
    color: #ffffff;
    border-color: #169a4a;
    box-shadow: none;
}
[data-theme="light"] #devicesGenerateAutolinkBtn:hover {
    background: #12833f;
    border-color: #12833f;
}
[data-theme="light"] #devicesGenerateAutolinkBtn .action-btn-note {
    color: #ffffff;
    opacity: 1;
}
[data-theme="light"] #devicesGenerateManualBtn:disabled,
[data-theme="light"] #devicesGenerateAutolinkBtn:disabled {
    background: #94a3b8 !important;
    border-color: #94a3b8 !important;
    color: rgba(255, 255, 255, 0.96) !important;
}
.device-entry {
    gap: 16px !important;
    align-items: flex-start !important;
    padding: 16px 18px;
}
.device-entry .settings-item-info {
    align-items: flex-start;
    gap: 12px;
}
.device-entry .settings-item-info .material-symbols-outlined {
    margin-top: 2px;
}
.device-entry-main {
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.device-entry-title {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
}
.device-entry-title strong {
    font-size: 16px;
    line-height: 1.25;
}
.device-entry-badge {
    display: inline-flex;
    align-items: center;
    padding: 3px 8px;
    border-radius: 999px;
    background: #169a4a;
    color: #fff;
    font-size: 12px;
    font-weight: 700;
    line-height: 1.2;
}
.device-entry-meta {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    width: 100%;
    margin-top: 4px;
}
.device-entry-meta small {
    display: block;
    font-size: 13px;
    line-height: 1.35;
    word-break: break-word;
}
.device-entry-meta-added {
    text-align: right;
    white-space: nowrap;
    flex-shrink: 0;
}
.device-entry-meta-label {
    display: block;
    margin-bottom: 2px;
    color: #64748b;
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.01em;
}
[data-theme="light"] .device-entry-meta-label {
    color: #475569;
}
.device-delete-btn {
    align-self: center;
}
@media (max-width: 600px) {
    .device-entry-meta {
        flex-direction: column;
        align-items: flex-start;
        gap: 6px;
    }
    .device-entry-meta-added {
        text-align: left;
        white-space: normal;
    }
    #devicesModal .modal-header-close {
        top: 4px;
        right: 8px;
    }
}

/* Debug Log Area */
.debug-log-container {
    position: fixed; bottom: 0; left: 0; width: 100%; height: 300px;
    background: #000; color: #0f0; z-index: 10000; font-family: monospace;
    font-size: 11px; display: flex; flex-direction: column; opacity: 0.9;
    border-top: 2px solid #333;
}
.debug-header { padding: 8px 12px; background: #222; display: flex; justify-content: space-between; border-bottom: 1px solid #333; }
#debugContent { flex: 1; padding: 10px; overflow-y: auto; white-space: pre-wrap; }
.debug-toggle-btn { margin: 10px; padding: 6px 12px; font-size: 11px; opacity: 0.5; cursor: pointer; background: var(--bg); color: var(--text-dim); border: 1px solid var(--border); border-radius: 4px; transition: 0.2s; }
.debug-toggle-btn:hover { opacity: 1; color: var(--text); border-color: var(--accent); }

.chat-header-actions { display: flex; gap: 8px; margin-left: auto; }

.loading-hint { text-align: center; color: var(--text-dim); padding: 40px; }
.app-spinner-wrap {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px;
}
.chat-loading-spinner {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
    z-index: 15;
}
.invite-invalid-overlay {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background: var(--bg, #0b1120);
    z-index: 4000;
    animation: inviteInvalidFade 180ms ease;
}
.invite-invalid-overlay .invite-invalid-card {
    max-width: 420px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 14px;
    padding: 28px 26px;
    border: 1px solid var(--border);
    border-radius: 18px;
    background: var(--surface);
    color: var(--text);
    text-align: center;
    font-size: 15px;
    line-height: 1.4;
    box-shadow: 0 18px 40px rgba(0, 0, 0, 0.26);
}
.invite-invalid-overlay .material-symbols-outlined {
    font-size: 44px !important;
    color: var(--accent);
}
@keyframes inviteInvalidFade {
    from { opacity: 0; }
    to { opacity: 1; }
}
.app-spinner {
    width: 38px;
    height: 38px;
    border: 3px solid rgba(28, 206, 94, 0.18);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: appSpinnerRotate 0.9s linear infinite;
}
@keyframes appSpinnerRotate {
    to { transform: rotate(360deg); }
}
.icon-btn { background: transparent; color: var(--text-dim); }
.icon-btn:disabled,
.call-action-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}
.call-action-btn {
    width: 40px;
    height: 40px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 12px;
    background: var(--accent-dim);
    color: var(--accent);
    border: 1px solid rgba(28, 206, 94, 0.22);
    transition: transform 0.15s ease, background 0.2s ease, border-color 0.2s ease;
}
.call-action-btn:hover {
    background: rgba(28, 206, 94, 0.2);
    border-color: rgba(28, 206, 94, 0.4);
}
.call-action-btn:active {
    transform: scale(0.97);
}
.call-action-btn .material-symbols-outlined {
    font-size: 21px !important;
}
.edit-cancel-btn {
    width: 48px;
    height: 48px;
    min-width: 48px;
    flex: 0 0 48px;
    border-radius: 50%;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text-dim);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s, background 0.2s, border-color 0.2s, color 0.2s;
}
.edit-cancel-btn:hover:not(:disabled) {
    transform: scale(1.04);
    background: var(--surface-hover);
    border-color: rgba(255, 71, 87, 0.26);
    color: var(--danger);
}
.edit-cancel-btn:disabled {
    opacity: 0.45;
}
.chat-calendar-btn {
    width: 40px;
    height: 40px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 12px;
    border: 1px solid var(--border);
    background: rgba(255, 255, 255, 0.04);
    color: var(--text-dim);
    transition: transform 0.15s ease, background 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}
.chat-calendar-btn:hover {
    transform: translateY(-1px);
    background: var(--accent-dim);
    border-color: rgba(28, 206, 94, 0.28);
    color: var(--accent);
}
[data-theme="light"] .chat-calendar-btn {
    background: rgba(255, 255, 255, 0.82);
}
.chat-calendar-btn .material-symbols-outlined {
    font-size: 21px !important;
}
.call-overlay {
    position: fixed;
    inset: 0;
    z-index: 1400;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background: rgba(4, 10, 20, 0.7);
    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px);
}
.call-card {
    width: min(100%, 420px);
    padding: 28px 24px 24px;
    text-align: center;
}
.call-badge {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 14px;
    margin: 0 auto 22px auto;
    width: fit-content;
    border-radius: 999px;
    background: rgba(28, 206, 94, 0.12);
    color: var(--accent);
    font-size: 13px;
    font-weight: 600;
}
.call-avatar {
    width: 88px;
    height: 88px;
    margin: 0 auto 18px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, rgba(28, 206, 94, 0.9), rgba(17, 125, 61, 0.95));
    color: #fff;
    font-size: 34px;
    font-weight: 700;
    box-shadow: 0 18px 40px rgba(28, 206, 94, 0.22);
}
.call-card h2 {
    font-size: 24px;
    margin-bottom: 10px;
}
.call-status-text {
    min-height: 24px;
    color: var(--text-dim);
    font-size: 15px;
    line-height: 1.45;
}
.call-status-text.call-status-lost {
    color: #ff4d4f;
    font-weight: 600;
}
.call-timer {
    margin: 14px auto 0;
    width: fit-content;
    color: var(--text);
    font-size: 28px;
    font-weight: 700;
    letter-spacing: 0.04em;
}
.call-quality-panel {
    margin-top: 18px;
    padding: 14px;
    border-radius: 16px;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid var(--border);
    text-align: left;
}
[data-theme="light"] .call-overlay {
    background: rgba(244, 250, 255, 0.92);
}
[data-theme="light"] .call-card {
    background: rgba(255, 255, 255, 0.96);
    box-shadow: 0 24px 64px rgba(44, 72, 110, 0.14);
}
[data-theme="light"] .call-quality-panel {
    background: rgba(248, 251, 255, 0.98);
    border-color: rgba(15, 23, 41, 0.08);
}
[data-theme="light"] .call-toast {
    background: rgba(255, 255, 255, 0.96);
    color: var(--text);
    border: 1px solid rgba(15, 23, 41, 0.08);
}
[data-theme="light"] .call-toast.toast-success {
    background: rgba(18, 142, 84, 0.96);
    color: #fff;
    border-color: transparent;
}
[data-theme="light"] .call-toast.toast-offline {
    background: rgba(196, 67, 83, 0.96);
    color: #fff;
    border-color: transparent;
}
.call-quality-summary {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}
.call-quality-summary-label {
    color: var(--text-dim);
    font-size: 13px;
}
.call-quality-current {
    font-size: 14px;
    font-weight: 700;
    color: var(--text);
}
.call-quality-current-btn {
    padding: 0;
    border: 0;
    background: transparent;
    font: inherit;
    line-height: inherit;
}
.call-quality-current-btn.is-clickable {
    cursor: pointer;
    text-decoration: underline;
    text-decoration-style: dotted;
    text-underline-offset: 3px;
}
.call-quality-current-btn.is-clickable:hover {
    color: var(--accent);
}
.call-quality-mode-pill {
    padding: 4px 10px;
    border-radius: 999px;
    background: rgba(28, 206, 94, 0.14);
    color: var(--accent);
    font-size: 12px;
    font-weight: 700;
}
.call-quality-profiles {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    margin-top: 12px;
}
.call-quality-profiles.hidden {
    display: none !important;
}
.call-quality-profile-btn {
    padding: 10px 12px;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--border);
    color: var(--text-dim);
    font-size: 13px;
    font-weight: 600;
    transition: background 0.2s ease, border-color 0.2s ease, color 0.2s ease, transform 0.15s ease;
}
.call-quality-profile-btn:hover {
    border-color: rgba(28, 206, 94, 0.32);
    color: var(--text);
}
.call-quality-profile-btn:active {
    transform: scale(0.98);
}
.call-quality-profile-btn.is-active {
    background: rgba(28, 206, 94, 0.14);
    border-color: rgba(28, 206, 94, 0.45);
    color: var(--accent);
}
.call-quality-profile-btn.is-inspecting:not(.is-active) {
    border-color: rgba(255, 255, 255, 0.26);
    color: var(--text);
}
.call-quality-profile-btn.is-readonly {
    opacity: 0.7;
}
.call-quality-details {
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid var(--border);
}
.call-quality-details.hidden {
    display: none !important;
}
.call-quality-details-title {
    color: var(--text);
    font-size: 13px;
    font-weight: 700;
}
.call-quality-metrics {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    margin-top: 10px;
}
.call-quality-metrics span {
    font-size: 12px;
    color: var(--text-dim);
}
.call-quality-metrics span#callQualityMetricConnType {
    grid-column: 1 / -1;
}
.call-quality-details-hint {
    margin-top: 10px;
    color: var(--text-dim);
    font-size: 12px;
    line-height: 1.45;
}
.call-actions {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 14px;
    margin-top: 26px;
}
.call-control-btn {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    box-shadow: 0 14px 30px rgba(0, 0, 0, 0.18);
    transition: transform 0.15s ease, box-shadow 0.2s ease, opacity 0.2s ease;
}
.call-control-btn:active {
    transform: scale(0.97);
}
.call-control-btn .material-symbols-outlined {
    font-size: 28px !important;
}
.call-accept-btn {
    background: linear-gradient(135deg, #1cce5e, #16984b);
}
.call-decline-btn {
    background: linear-gradient(135deg, #ff5b6a, #e63d4c);
}
.call-neutral-btn {
    background: rgba(255, 255, 255, 0.12);
    color: var(--text);
    border: 1px solid var(--border);
}
.call-neutral-btn.is-muted {
    background: rgba(255, 171, 0, 0.18);
    color: #ffbf33;
    border-color: rgba(255, 171, 0, 0.3);
}
.call-toast {
    position: fixed;
    left: 50%;
    bottom: 28px;
    transform: translateX(-50%);
    z-index: 1450;
    padding: 12px 18px;
    border-radius: 999px;
    background: rgba(15, 23, 41, 0.92);
    color: #fff;
    box-shadow: 0 12px 28px rgba(0, 0, 0, 0.22);
    font-size: 14px;
    line-height: 1.3;
    white-space: nowrap;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}
.call-toast.has-icon .material-symbols-outlined {
    font-size: 18px;
}
.call-toast.toast-success {
    background: rgba(14, 124, 72, 0.96);
}
.call-toast.toast-offline {
    background: rgba(121, 31, 44, 0.96);
}
.call-quality-mode-toggle {
    display: inline-flex;
    align-items: center;
    align-self: center;
    flex-wrap: wrap;
    gap: 8px;
    padding: 6px;
    border-radius: 14px;
    background: var(--surface);
    border: 1px solid var(--border);
}
.call-quality-mode-btn {
    min-width: 98px;
    padding: 10px 14px;
    border-radius: 10px;
    background: transparent;
    color: var(--text-dim);
    font-size: 13px;
    font-weight: 700;
    transition: background 0.2s ease, color 0.2s ease, box-shadow 0.2s ease;
}
.call-quality-mode-btn.is-active {
    background: rgba(28, 206, 94, 0.15);
    color: var(--accent);
    box-shadow: inset 0 0 0 1px rgba(28, 206, 94, 0.22);
}
.call-quality-mode-btn:not(.is-active):hover {
    color: var(--text);
    background: var(--surface-hover);
}
.message-context-menu {
    position: fixed;
    z-index: 1200;
    min-width: 180px;
    padding: 8px;
    background: rgba(15, 23, 41, 0.96);
    border: 1px solid var(--border);
    border-radius: 16px;
    box-shadow: 0 18px 38px rgba(0, 0, 0, 0.28);
    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px);
    transform-origin: top left;
    opacity: 1;
    transform: scale(1);
    transition: opacity 160ms ease, transform 160ms ease;
}
.message-context-menu.hidden {
    display: block !important;
    opacity: 0;
    transform: scale(0.92);
    pointer-events: none;
    visibility: hidden;
    transition: opacity 160ms ease, transform 160ms ease, visibility 0s linear 160ms;
}
[data-theme="light"] .message-context-menu {
    background: rgba(255, 255, 255, 0.96);
    box-shadow: 0 18px 38px rgba(0, 0, 0, 0.12);
}
.message-context-action {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: 10px;
    background: transparent;
    color: var(--text);
    font-size: 14px;
    text-align: left;
}
.message-context-action:hover {
    background: var(--surface-hover);
    color: var(--accent);
}
.message-context-action .material-symbols-outlined {
    font-size: 18px !important;
    color: inherit;
}
.message-context-action.hidden {
    display: none;
}
.secondary-outline-btn {
    width: 100%;
    margin-inline: auto;
    padding: 12px;
    border-radius: 12px;
    background: #193537;
    color: #f1f5f9;
    border: 1px solid #1cce5e;
    font-size: 14px;
    font-weight: 600;
    transition: transform 0.1s, box-shadow 0.2s;
}
.secondary-outline-btn:hover {
    box-shadow: 0 0 0 3px rgba(28, 206, 94, 0.12);
}
[data-theme="light"] #seedLeaveModal .secondary-outline-btn {
    background: #ffffff;
    color: #1e293b;
    border-color: #94a3b8;
    box-shadow: none;
}
[data-theme="light"] #seedLeaveModal .secondary-outline-btn:hover {
    background: #f8fafc;
    border-color: #64748b;
    box-shadow: none;
}
[data-theme="light"] #seedLeaveModal p {
    color: #334155;
}
.modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 1400;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: rgba(4, 10, 20, 0.72);
}
.modal-card {
    width: min(100%, 420px);
    padding: 28px;
    border-radius: 20px;
}
#manageUserModal .modal-card { max-width: 700px; width: 100%; }

.modal-header-close { position: absolute; top: 12px; right: 16px; background: none; border: none; color: var(--text-dim); cursor: pointer; transition: 0.2s; font-size: 32px; font-weight: 300; padding: 0 4px; }
.modal-header-close:hover { color: var(--text); transform: scale(1.1); }

.modal-card h3 {
    font-size: 22px;
    margin-bottom: 20px;
    margin-top:16px;
}
.modal-card p {
    color: var(--text-dim);
    font-size: 14px;
    line-height: 1.5;
    margin: 0;
}
.modal-card p + p {
    margin-top: 12px;
}

#welcomeModal:not(.hidden) {
    animation: welcome-modal-overlay-in 220ms ease both;
    z-index: 1505;
}
#welcomeModal:not(.hidden) .welcome-modal-card {
    animation: welcome-modal-card-in 280ms cubic-bezier(0.2, 0.9, 0.2, 1) both;
}
.welcome-modal-card {
    position: relative;
    width: min(100%, 780px);
    max-width: 780px;
    max-height: calc(100dvh - 32px);
    padding: 0;
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior: contain;
    scrollbar-gutter: stable;
    border-color: rgba(255,255,255,0.12);
    background:
        radial-gradient(circle at top right, rgba(28, 206, 94, 0.20), transparent 34%),
        radial-gradient(circle at left center, rgba(59, 130, 246, 0.18), transparent 30%),
        rgba(10, 18, 34, 0.92);
}
.welcome-modal-card::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(180deg, rgba(255,255,255,0.04), rgba(255,255,255,0));
    pointer-events: none;
}
.welcome-modal-hero,
.welcome-modal-highlights,
.welcome-modal-section,
.welcome-modal-note,
.welcome-modal-actions {
    position: relative;
    z-index: 1;
}
.welcome-modal-hero {
    padding: 34px 34px 24px;
    border-bottom: 1px solid rgba(255,255,255,0.08);
}
.welcome-modal-eyebrow {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-height: 34px;
    padding: 8px 14px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: #eafff2;
    background: rgba(28, 206, 94, 0.14);
    border: 1px solid rgba(28, 206, 94, 0.28);
    width: fit-content;
}
.welcome-modal-eyebrow::before {
    content: '';
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #1cce5e;
    box-shadow: 0 0 0 6px rgba(28, 206, 94, 0.16);
}
.welcome-modal-hero h2 {
    margin: 18px 0 14px;
    max-width: 620px;
    font-size: clamp(28px, 4vw, 40px);
    line-height: 1.02;
    letter-spacing: -0.04em;
}
#welcomeModalLead {
    max-width: 620px;
    font-size: 16px;
    line-height: 1.6;
    color: #cbd5e1;
}
.welcome-modal-highlights {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
    padding: 24px 34px 20px;
}
.welcome-modal-feature {
    display: grid;
    grid-template-columns: 48px minmax(0, 1fr);
    gap: 14px;
    align-items: start;
    padding: 18px;
    border-radius: 20px;
    background: rgba(255,255,255,0.04);
    border: 1px solid rgba(255,255,255,0.08);
    transition: transform 0.18s ease, border-color 0.18s ease, background 0.18s ease;
}
.welcome-modal-feature:hover {
    transform: translateY(-2px);
    background: rgba(255,255,255,0.06);
    border-color: rgba(28, 206, 94, 0.24);
}
.welcome-modal-feature-icon {
    width: 48px;
    height: 48px;
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #eafff2;
    background: linear-gradient(135deg, rgba(28, 206, 94, 0.24), rgba(59, 130, 246, 0.22));
    border: 1px solid rgba(255,255,255,0.08);
}
.welcome-modal-feature-icon .material-symbols-outlined {
    font-size: 24px !important;
}
.welcome-modal-feature-title {
    font-size: 16px;
    font-weight: 700;
    color: var(--text);
}
.welcome-modal-feature-text {
    margin-top: 8px;
    color: #cbd5e1;
    font-size: 14px;
    line-height: 1.55;
}
.welcome-modal-section {
    padding: 0 34px 22px;
}
.welcome-modal-guides-layout .welcome-modal-section {
    padding-top: 24px;
}
.welcome-modal-no-close #welcomeModalCloseBtn {
    display: none;
}
.welcome-modal-section-label {
    margin-bottom: 12px;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--text-dim);
}
.welcome-modal-steps {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px;
}
.welcome-modal-steps.is-guide-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}
.welcome-modal-step {
    padding: 18px;
    border-radius: 18px;
    background: rgba(255,255,255,0.03);
    border: 1px solid rgba(255,255,255,0.07);
}
.welcome-modal-step-index {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 12px;
    color: #ecfdf3;
    font-size: 14px;
    font-weight: 700;
    background: rgba(28, 206, 94, 0.18);
    border: 1px solid rgba(28, 206, 94, 0.3);
}
.welcome-modal-step-title {
    font-size: 15px;
    font-weight: 700;
}
.welcome-modal-step-text {
    margin-top: 8px;
    color: #cbd5e1;
    font-size: 14px;
    line-height: 1.55;
}
.welcome-modal-guide {
    border-radius: 18px;
    background: rgba(255,255,255,0.03);
    border: 1px solid rgba(255,255,255,0.07);
    overflow: hidden;
}
.welcome-modal-guide-summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    width: 100%;
    padding: 18px 20px;
    border: none;
    background: transparent;
    color: inherit;
    cursor: pointer;
    font-size: 15px;
    font-weight: 700;
    font-family: inherit;
    text-align: left;
    appearance: none;
}
.welcome-modal-guide-summary span {
    flex: 1;
}
.welcome-modal-guide-summary::after {
    content: 'expand_more';
    font-family: 'Material Symbols Outlined';
    font-size: 24px;
    line-height: 1;
    color: var(--text-dim);
    transition: transform 0.2s ease;
}
.welcome-modal-guide.is-open .welcome-modal-guide-summary::after {
    transform: rotate(180deg);
}
.welcome-modal-guide-body {
    display: grid;
    grid-template-rows: 0fr;
    opacity: 0;
    padding: 0 20px;
    border-top: 1px solid transparent;
    transition: grid-template-rows 240ms ease, opacity 200ms ease, padding 240ms ease, border-color 240ms ease;
}
.welcome-modal-guide-body-inner {
    overflow: hidden;
    min-height: 0;
    transform: translateY(-8px);
    transition: transform 240ms ease;
}
.welcome-modal-guide.is-open .welcome-modal-guide-body {
    grid-template-rows: 1fr;
    opacity: 1;
    padding-bottom: 20px;
    border-top-color: rgba(255,255,255,0.07);
}
.welcome-modal-guide.is-open .welcome-modal-guide-body-inner {
    transform: translateY(0);
}
.welcome-modal-guide-note {
    margin: 16px 0 0;
    color: #cbd5e1;
    font-size: 14px;
    line-height: 1.55;
}
.welcome-modal-guide-columns {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
    margin-top: 16px;
}
.welcome-modal-guide-column {
    padding: 16px;
    border-radius: 16px;
    background: rgba(255,255,255,0.03);
    border: 1px solid rgba(255,255,255,0.06);
}
.welcome-modal-guide-column-label {
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--text-dim);
}
.welcome-modal-guide-list {
    margin: 12px 0 0;
    padding-left: 18px;
    color: #d6e1ee;
    font-size: 14px;
    line-height: 1.6;
}
.welcome-modal-guide-list li + li {
    margin-top: 8px;
}
.welcome-modal-note {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    margin: 0 34px;
    padding: 16px 18px;
    border-radius: 18px;
    background: rgba(255,255,255,0.04);
    border: 1px solid rgba(255,255,255,0.08);
}
.welcome-modal-note .material-symbols-outlined {
    margin-top: 2px;
    color: var(--accent);
    font-size: 20px !important;
}
#welcomeModalNote {
    color: #d6e1ee;
    font-size: 14px;
    line-height: 1.55;
}
.welcome-modal-actions {
    padding: 22px 34px 34px;
    margin-top: 0;
}
.welcome-modal-actions .primary-btn {
    margin-top: 0;
}

@keyframes welcome-modal-overlay-in {
    from { opacity: 0; }
    to { opacity: 1; }
}
@keyframes welcome-modal-card-in {
    from {
        opacity: 0;
        transform: translateY(18px) scale(0.98);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

[data-theme="light"] .welcome-modal-card {
    border-color: rgba(15, 23, 41, 0.08);
    background:
        radial-gradient(circle at top right, rgba(28, 206, 94, 0.18), transparent 34%),
        radial-gradient(circle at left center, rgba(59, 130, 246, 0.12), transparent 30%),
        rgba(255,255,255,0.94);
}
[data-theme="light"] .welcome-modal-hero {
    border-bottom-color: rgba(15, 23, 41, 0.08);
}
[data-theme="light"] #welcomeModalLead,
[data-theme="light"] .welcome-modal-feature-text,
[data-theme="light"] .welcome-modal-step-text,
[data-theme="light"] #welcomeModalNote {
    color: #475569;
}
[data-theme="light"] .welcome-modal-feature,
[data-theme="light"] .welcome-modal-step,
[data-theme="light"] .welcome-modal-guide,
[data-theme="light"] .welcome-modal-guide-column,
[data-theme="light"] .welcome-modal-note {
    background: rgba(255,255,255,0.66);
    border-color: rgba(15, 23, 41, 0.08);
}
[data-theme="light"] .welcome-modal-feature:hover {
    background: rgba(255,255,255,0.9);
}
[data-theme="light"] .welcome-modal-step-index {
    color: #0f172a;
    background: linear-gradient(135deg, rgba(34, 197, 94, 0.24), rgba(59, 130, 246, 0.18));
    border-color: rgba(15, 23, 41, 0.14);
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.76);
}
[data-theme="light"] .welcome-modal-feature-icon {
    color: #0f6b3a;
    background: linear-gradient(135deg, rgba(34, 197, 94, 0.18), rgba(59, 130, 246, 0.16));
    border-color: rgba(15, 23, 41, 0.12);
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.7);
}
[data-theme="light"] .welcome-modal-guide-note,
[data-theme="light"] .welcome-modal-guide-list {
    color: #475569;
}
[data-theme="light"] .welcome-modal-eyebrow {
    color: #10653a;
    background: rgba(28, 206, 94, 0.12);
    border-color: rgba(28, 206, 94, 0.24);
}

@media (max-width: 820px) {
    .welcome-modal-hero,
    .welcome-modal-highlights,
    .welcome-modal-section,
    .welcome-modal-actions {
        padding-left: 20px;
        padding-right: 20px;
    }
    .welcome-modal-hero {
        padding-top: 24px;
        padding-bottom: 18px;
    }
    .welcome-modal-guides-layout .welcome-modal-section {
        padding-top: 20px;
    }
    .welcome-modal-highlights,
    .welcome-modal-steps {
        grid-template-columns: 1fr;
    }
    .welcome-modal-guide-columns {
        grid-template-columns: 1fr;
    }
    .welcome-modal-note {
        margin-left: 20px;
        margin-right: 20px;
    }
    .devices-modal-card {
        width: min(100%, 100%);
        max-height: calc(100dvh - 16px);
    }
    .devices-modal-list-shell {
        max-height: min(34dvh, 280px);
    }
    .devices-block-head {
        gap: 10px;
    }
    .devices-info-btn {
        width: 100%;
    }
}

/* ---- STORAGE BARS ---- */
.storage-bar-wrapper {
    height: 16px;
    background: var(--border);
    border-radius: 8px;
    overflow: hidden;
    display: flex;
    width: 100%;
    margin: 8px 0;
}
.storage-bar-segment {
    height: 100%;
    transition: width 0.5s ease;
}
.storage-legend {
    display: flex; gap: 12px; flex-wrap: wrap; margin-top: 10px; font-size: 13px;
}
.storage-legend-item {
    display: flex; align-items: center; gap: 6px; cursor: pointer; transition: 0.2s;
    padding: 4px 8px; border-radius: 6px;
}
.storage-legend-item:hover { background: var(--surface-hover); }
.storage-legend-color { width: 12px; height: 12px; border-radius: 50%; }

.upload-progress-bubble {
    display: flex;
    flex-direction: column;
    gap: 8px;
    min-width: 240px;
    max-width: 360px;
}
.upload-progress-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
}
.upload-progress-name {
    flex: 1 1 auto;
    min-width: 0;
    font-weight: 500;
    font-size: 14px;
    word-break: break-word;
}
.upload-progress-cancel {
    width: 32px;
    height: 32px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
    border-radius: 10px;
    border: 1px solid rgba(255,255,255,0.08);
    background: rgba(255,255,255,0.05);
    color: var(--text-dim);
    transition: background 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}
.upload-progress-cancel:hover {
    background: rgba(255,255,255,0.1);
    color: var(--text);
    border-color: rgba(255,255,255,0.16);
}
.upload-progress-cancel .material-symbols-outlined {
    font-size: 18px;
}
.upload-progress-bar,
.msg-group-download-all-progress-bar,
.file-download-progress-bar {
    width: 100%;
    height: 4px;
    background: rgba(255, 255, 255, 0.10);
    border-radius: 3px;
    overflow: hidden;
    position: relative;
}
.upload-progress-fill,
.msg-group-download-all-progress-fill,
.file-download-progress-fill {
    height: 100%;
    width: 0%;
    background: var(--accent);
    border-radius: inherit;
    transition: width 0.15s linear;
    position: relative;
}
.upload-progress-fill::after {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.25), transparent);
    animation: upload-progress-shimmer 1.2s linear infinite;
}
@keyframes upload-progress-shimmer {
    0%   { transform: translateX(-100%); }
    100% { transform: translateX(100%); }
}
.upload-progress-stats {
    display: flex;
    flex-wrap: wrap;
    gap: 4px 12px;
    font-size: 12px;
    opacity: 0.85;
}
.upload-progress-processing .upload-progress-fill::after {
    animation-duration: 0.8s;
}
.upload-progress-cancelling .upload-progress-fill {
    opacity: 0.55;
}
.upload-confirm-card {
    text-align: center;
    max-width: 560px;
    max-height: min(720px, calc(100vh - 32px));
    max-height: min(720px, calc(100dvh - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px) - 32px));
    overflow-y: auto;
    overscroll-behavior: contain;
    display: flex;
    flex-direction: column;
}
.upload-confirm-dropzone {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin: 16px 0;
    padding: 16px;
    border: 1px dashed rgba(28, 206, 94, 0.35);
    border-radius: 16px;
    background: rgba(28, 206, 94, 0.08);
    text-align: left;
    transition: border-color 0.2s ease, background 0.2s ease, transform 0.2s ease;
}
.upload-confirm-dropzone.is-dragging {
    border-color: var(--accent);
    background: rgba(28, 206, 94, 0.14);
    transform: scale(1.01);
}
.upload-confirm-dropzone:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 3px;
}
.upload-confirm-dropzone-copy {
    display: flex;
    align-items: center;
    gap: 12px;
}
.upload-confirm-dropzone-copy .material-symbols-outlined {
    font-size: 24px;
    color: var(--accent);
}
.upload-confirm-drop-title,
.upload-confirm-drop-hint {
    display: block;
}
.upload-confirm-drop-title {
    font-weight: 600;
}
.upload-confirm-drop-hint {
    margin-top: 4px;
    font-size: 13px;
    color: var(--text-dim);
}
.upload-confirm-add-btn {
    align-self: flex-start;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}
.upload-confirm-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 16px;
    max-height: 280px;
    overflow-y: auto;
    text-align: left;
}
.upload-confirm-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    border-radius: 14px;
    border: 1px solid var(--border);
    background: var(--surface-hover);
}
.upload-confirm-item-icon {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
    background: var(--accent-dim);
    color: var(--accent);
}
.upload-confirm-item-meta {
    flex: 1 1 auto;
    min-width: 0;
}
.upload-confirm-item-name {
    font-weight: 600;
    word-break: break-word;
}
.upload-confirm-item-size {
    margin-top: 4px;
    font-size: 12px;
    color: var(--text-dim);
}
.upload-confirm-item-remove {
    width: 36px;
    height: 36px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
    border-radius: 12px;
    border: 1px solid rgba(255,255,255,0.08);
    background: rgba(255,255,255,0.04);
}
.upload-confirm-item-remove:hover {
    background: rgba(255,255,255,0.1);
    color: var(--danger);
}
.upload-confirm-actions {
    position: sticky;
    bottom: -1px;
    z-index: 2;
    margin: 18px -28px -28px;
    padding: 14px 28px 28px;
    background: linear-gradient(180deg, rgba(15, 23, 42, 0), var(--surface) 18px);
}
.upload-confirm-actions .primary-btn,
.upload-confirm-actions .secondary-outline-btn {
    margin-top: 0;
}
.upload-dock {
    padding: 0 24px 14px;
    background: var(--surface);
    border-top: 1px solid var(--border);
    flex-shrink: 0;
}
.upload-dock-card {
    display: flex;
    align-items: stretch;
    gap: 14px;
    padding: 14px 16px;
    border-radius: 18px;
    border: 1px solid var(--border);
    background: rgba(18, 26, 38, 0.96);
    box-shadow: 0 10px 28px rgba(10, 24, 38, 0.16);
}
.upload-dock-card.upload-state-uploading {
    background: linear-gradient(180deg, rgba(250, 204, 21, 0.26), rgba(18, 26, 38, 0.96));
    border-color: rgba(250, 204, 21, 0.38);
}
.upload-dock-card.upload-state-done {
    background: linear-gradient(180deg, rgba(34, 197, 94, 0.22), rgba(18, 26, 38, 0.96));
    border-color: rgba(34, 197, 94, 0.34);
}
.upload-dock-card.upload-state-error {
    background: linear-gradient(180deg, rgba(239, 68, 68, 0.22), rgba(18, 26, 38, 0.96));
    border-color: rgba(239, 68, 68, 0.34);
}
.upload-dock-card.upload-state-cancelled {
    background: linear-gradient(180deg, rgba(245, 158, 11, 0.2), rgba(18, 26, 38, 0.96));
    border-color: rgba(245, 158, 11, 0.32);
}
.upload-dock-icon {
    width: 46px;
    height: 46px;
    flex: 0 0 auto;
    border-radius: 14px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    background: rgba(255, 255, 255, 0.14);
}
.upload-dock-icon .material-symbols-outlined {
    font-size: 24px;
}
.upload-state-uploading .upload-dock-icon,
.upload-state-uploading .upload-hub-fab,
.upload-state-uploading .upload-hub-card,
.upload-state-uploading .upload-hub-group {
    color: #fff7d6;
}
.upload-state-done .upload-dock-icon,
.upload-state-done .upload-hub-fab,
.upload-state-done .upload-hub-card,
.upload-state-done .upload-hub-group {
    color: #e7ffef;
}
.upload-state-error .upload-dock-icon,
.upload-state-error .upload-hub-fab,
.upload-state-error .upload-hub-card,
.upload-state-error .upload-hub-group {
    color: #ffe5e5;
}
.upload-dock-copy {
    flex: 1 1 auto;
    min-width: 0;
}
.upload-dock-title {
    font-size: 14px;
    font-weight: 700;
    margin-bottom: 4px;
}
.upload-dock-line {
    font-size: 12px;
    line-height: 1.45;
    color: var(--text);
}
.upload-dock-line-dim {
    color: var(--text-dim);
}
.upload-dock-line-files {
    margin-top: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.upload-dock-bar {
    height: 4px;
    margin-top: 10px;
    border-radius: 3px;
    overflow: hidden;
    background: rgba(255,255,255,0.10);
}
.upload-dock-bar-fill {
    height: 100%;
    width: 0%;
    border-radius: inherit;
    background: var(--accent);
    transition: width 0.18s linear;
}
.upload-dock-cancel {
    width: 38px;
    height: 38px;
    align-self: center;
    border-radius: 12px;
    border: 1px solid rgba(255,255,255,0.08);
    background: rgba(255,255,255,0.05);
}
.upload-dock-cancel:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}
.upload-hub-fab {
    position: fixed;
    right: 22px;
    bottom: 108px;
    z-index: 540;
    display: inline-flex;
    align-items: center;
    gap: 10px;
    min-height: 56px;
    padding: 0 18px;
    border-radius: 999px;
    background: rgba(18, 26, 38, 0.96);
    color: #fff;
    box-shadow: 0 18px 42px rgba(10, 24, 38, 0.34);
}
.upload-hub-fab.upload-state-uploading {
    background: linear-gradient(135deg, rgba(245, 158, 11, 0.98), rgba(202, 138, 4, 0.98));
}
.upload-hub-fab.upload-state-done {
    background: linear-gradient(135deg, rgba(22, 163, 74, 0.98), rgba(34, 197, 94, 0.98));
}
.upload-hub-fab.upload-state-error {
    background: linear-gradient(135deg, rgba(220, 38, 38, 0.98), rgba(239, 68, 68, 0.98));
}
.upload-hub-fab.upload-state-cancelled {
    background: linear-gradient(135deg, rgba(217, 119, 6, 0.98), rgba(245, 158, 11, 0.98));
}
.upload-hub-fab .material-symbols-outlined {
    font-size: 22px;
}
.upload-hub-fab-label {
    font-size: 14px;
    font-weight: 700;
}
.upload-hub-fab-badge {
    min-width: 24px;
    height: 24px;
    padding: 0 7px;
    border-radius: 999px;
    background: rgba(255,255,255,0.22);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 700;
}
.upload-hub-panel {
    position: fixed;
    right: 22px;
    bottom: 178px;
    width: min(420px, calc(100vw - 24px));
    max-height: min(72vh, calc(100dvh - 210px));
    z-index: 541;
    display: flex;
    flex-direction: column;
}
.upload-hub-card {
    padding: 18px;
    border-radius: 24px;
    border: 1px solid var(--border);
    background: rgba(18, 26, 38, 0.98);
    box-shadow: 0 22px 44px rgba(10, 24, 38, 0.32);
    max-height: 100%;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}
.upload-hub-card.upload-state-uploading {
    border-color: rgba(250, 204, 21, 0.34);
}
.upload-hub-card.upload-state-done {
    border-color: rgba(34, 197, 94, 0.34);
}
.upload-hub-card.upload-state-error {
    border-color: rgba(239, 68, 68, 0.34);
}
.upload-hub-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 14px;
}
.upload-hub-head-copy {
    min-width: 0;
    flex: 1 1 auto;
}
.upload-hub-title {
    font-size: 16px;
    font-weight: 700;
    margin-bottom: 6px;
}
.upload-hub-line {
    font-size: 12px;
    line-height: 1.45;
}
.upload-hub-line-dim {
    color: var(--text-dim);
}
.upload-hub-head-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 0 0 auto;
}
.upload-hub-overall-bar,
.upload-hub-file-bar {
    height: 4px;
    border-radius: 3px;
    overflow: hidden;
    background: rgba(255,255,255,0.10);
}
.upload-hub-overall-bar {
    margin-top: 14px;
}
.upload-hub-overall-fill,
.upload-hub-file-fill {
    height: 100%;
    width: 0%;
    border-radius: inherit;
    background: var(--accent);
    transition: width 0.18s linear;
}
.upload-hub-groups {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-top: 16px;
    flex: 1 1 auto;
    min-height: 0;
    max-height: none;
    overflow-y: auto;
    padding-right: 4px;
    overscroll-behavior: contain;
}
.upload-hub-group {
    border: 1px solid var(--border);
    border-radius: 18px;
    background: rgba(255,255,255,0.07);
    overflow: hidden;
}
.upload-hub-group.upload-state-uploading {
    border-color: rgba(250, 204, 21, 0.24);
}
.upload-hub-group.upload-state-done {
    border-color: rgba(34, 197, 94, 0.24);
}
.upload-hub-group-summary {
    list-style: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 14px 16px;
}
.upload-hub-group-summary::-webkit-details-marker {
    display: none;
}
.upload-hub-group-summary-copy {
    min-width: 0;
}
.upload-hub-group-name {
    font-size: 14px;
    font-weight: 700;
    line-height: 1.35;
}
.upload-hub-line-chat {
    color: var(--text);
}
.upload-hub-group-meta {
    margin-top: 4px;
    font-size: 12px;
    color: var(--text-dim);
}
.upload-hub-group-arrow {
    font-size: 20px;
    color: var(--text-dim);
    transition: transform 0.18s ease;
}
.upload-hub-group[open] .upload-hub-group-arrow {
    transform: rotate(180deg);
}
.upload-hub-group-body {
    padding: 0 16px 16px;
}
.upload-hub-group-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 12px;
}
.upload-hub-group-toolbar-copy {
    font-size: 12px;
    color: var(--text-dim);
}
.upload-hub-group-files {
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.upload-hub-file-row {
    padding: 12px 14px;
    border-radius: 14px;
    border: 1px solid rgba(255,255,255,0.10);
    background: rgba(255,255,255,0.09);
}
.upload-hub-file-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
}
.upload-hub-file-name {
    min-width: 0;
    font-size: 13px;
    font-weight: 600;
    word-break: break-word;
}
.upload-hub-file-status {
    flex: 0 0 auto;
    font-size: 11px;
    font-weight: 700;
    color: var(--accent);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
.upload-hub-file-meta {
    margin-top: 6px;
    font-size: 12px;
    color: var(--text-dim);
}
.upload-hub-file-target {
    margin-top: 6px;
    font-size: 12px;
    font-weight: 600;
    color: var(--text);
}
.upload-hub-file-bar {
    margin-top: 10px;
}
.upload-status-error .upload-hub-file-status {
    color: var(--danger);
}
.upload-status-cancelled .upload-hub-file-status {
    color: #f59e0b;
}
.upload-status-done .upload-hub-file-status {
    color: #22c55e;
}
.upload-status-cancelling .upload-hub-file-status {
    color: #f59e0b;
}
[data-theme="light"] .upload-dock-card,
[data-theme="light"] .upload-hub-card,
[data-theme="light"] .upload-hub-group,
[data-theme="light"] .upload-hub-file-row {
    color: #0f172a;
}
[data-theme="light"] .upload-dock-card {
    background: rgba(255, 255, 255, 0.98);
}
[data-theme="light"] .upload-dock-card.upload-state-uploading {
    background: linear-gradient(180deg, rgba(250, 204, 21, 0.26), rgba(255, 255, 255, 0.98));
}
[data-theme="light"] .upload-dock-card.upload-state-done {
    background: linear-gradient(180deg, rgba(34, 197, 94, 0.22), rgba(255, 255, 255, 0.98));
}
[data-theme="light"] .upload-hub-card,
[data-theme="light"] .upload-hub-group,
[data-theme="light"] .upload-hub-file-row {
    background: rgba(255, 255, 255, 0.98);
}
.chat-calendar-modal-card {
    width: min(100%, 580px);
    max-width: 580px;
    padding: 24px;
    transform-origin: var(--chat-calendar-origin-x, calc(100% - 40px)) var(--chat-calendar-origin-y, 28px);
    will-change: transform, opacity;
    backface-visibility: hidden;
}
#chatCalendarModal.chat-calendar-opening {
    animation: chat-calendar-overlay-in 240ms ease both;
}
#chatCalendarModal.chat-calendar-closing {
    pointer-events: none;
    animation: chat-calendar-overlay-out 180ms ease both;
}
#chatCalendarModal.chat-calendar-opening .chat-calendar-modal-card {
    animation: chat-calendar-card-in 240ms cubic-bezier(0.22, 1, 0.36, 1) both;
}
#chatCalendarModal.chat-calendar-closing .chat-calendar-modal-card {
    animation: chat-calendar-card-out 180ms cubic-bezier(0.4, 0, 1, 1) both;
}
@keyframes chat-calendar-overlay-in {
    from { background: rgba(4, 10, 20, 0); }
    to { background: rgba(4, 10, 20, 0.72); }
}
@keyframes chat-calendar-overlay-out {
    from { background: rgba(4, 10, 20, 0.72); }
    to { background: rgba(4, 10, 20, 0); }
}
@keyframes chat-calendar-card-in {
    from {
        opacity: 0;
        transform: scale(0.16);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}
@keyframes chat-calendar-card-out {
    from {
        opacity: 1;
        transform: scale(1);
    }
    to {
        opacity: 0;
        transform: scale(0.16);
    }
}
.chat-calendar-modal-head {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding-right: 36px;
}
.chat-calendar-modal-card h3 {
    margin: 0;
    font-size: 24px;
    line-height: 1.15;
}
.chat-calendar-eyebrow {
    display: inline-flex;
    align-items: center;
    width: fit-content;
    padding: 7px 12px;
    border-radius: 999px;
    background: var(--accent-dim);
    color: var(--accent);
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}
.chat-calendar-months-row {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    gap: 10px;
    align-items: center;
    margin-top: 18px;
}
.chat-calendar-nav-btn {
    width: 38px;
    height: 38px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 12px;
    border: 1px solid var(--border);
    background: rgba(255, 255, 255, 0.04);
    color: var(--text-dim);
    transition: transform 0.15s ease, background 0.2s ease, border-color 0.2s ease, color 0.2s ease, opacity 0.2s ease;
}
.chat-calendar-nav-btn:hover:not(:disabled) {
    transform: translateY(-1px);
    background: var(--accent-dim);
    border-color: rgba(28, 206, 94, 0.24);
    color: var(--accent);
}
.chat-calendar-nav-btn:disabled {
    opacity: 0.42;
    cursor: not-allowed;
}
.chat-calendar-nav-btn .material-symbols-outlined {
    font-size: 22px !important;
}
[data-theme="light"] .chat-calendar-nav-btn {
    background: rgba(255, 255, 255, 0.82);
}
.chat-calendar-month-tabs {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 8px;
    touch-action: pan-y;
}
.chat-calendar-month-tab {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 46px;
    padding: 10px 8px;
    border-radius: 14px;
    border: 1px solid var(--border);
    background: rgba(255, 255, 255, 0.03);
    color: var(--text-dim);
    font-size: 14px;
    font-weight: 600;
    transition: transform 0.15s ease, border-color 0.2s ease, background 0.2s ease, color 0.2s ease, box-shadow 0.2s ease;
}
.chat-calendar-month-tab-copy {
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    line-height: 1.05;
}
.chat-calendar-month-text {
    display: block;
}
.chat-calendar-month-year {
    display: block;
    font-size: 11px;
    font-weight: 600;
    opacity: 0.78;
}
.chat-calendar-month-tab:hover {
    transform: translateY(-1px);
    color: var(--text);
    border-color: rgba(28, 206, 94, 0.26);
}
.chat-calendar-month-tab.is-active {
    color: var(--text);
    font-weight: 700;
    border-color: rgba(28, 206, 94, 0.32);
    background: linear-gradient(180deg, rgba(28, 206, 94, 0.16), rgba(28, 206, 94, 0.08));
    box-shadow: 0 10px 24px rgba(0, 0, 0, 0.18);
}
[data-theme="light"] .chat-calendar-month-tab {
    background: rgba(255, 255, 255, 0.82);
}
[data-theme="light"] .chat-calendar-month-tab.is-active {
    box-shadow: 0 12px 28px rgba(27, 53, 87, 0.12);
}
.chat-calendar-shell {
    margin-top: 16px;
    padding: 16px;
    border-radius: 22px;
    border: 1px solid var(--border);
    background: var(--surface);
    touch-action: pan-y;
}
[data-theme="light"] .chat-calendar-shell {
    background: rgba(255, 255, 255, 0.82);
}
.chat-calendar-weekdays,
.chat-calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
    gap: 8px;
}
.chat-calendar-weekdays {
    margin-bottom: 8px;
}
.chat-calendar-weekday {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 26px;
    color: var(--text-dim);
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}
.chat-calendar-day {
    position: relative;
    min-height: 62px;
    padding: 10px;
    border-radius: 18px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    background: rgba(255, 255, 255, 0.06);
    color: var(--text);
    display: flex;
    align-items: flex-start;
    justify-content: flex-start;
    transition: transform 0.15s ease, border-color 0.2s ease, background 0.2s ease, box-shadow 0.2s ease, opacity 0.2s ease;
}
.chat-calendar-day:not(.is-disabled):not(.is-outside) {
    border-color: rgba(255, 255, 255, 0.09);
    background: rgba(255, 255, 255, 0.07);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
}
.chat-calendar-day:hover:not(.is-disabled):not(.is-outside) {
    transform: translateY(-1px);
    border-color: rgba(28, 206, 94, 0.32);
    background: rgba(255, 255, 255, 0.1);
    box-shadow: 0 14px 28px rgba(0, 0, 0, 0.14);
}
[data-theme="light"] .chat-calendar-day {
    border-color: rgba(15, 23, 41, 0.12);
    background: rgba(255, 255, 255, 0.88);
}
[data-theme="light"] .chat-calendar-day:not(.is-disabled):not(.is-outside) {
    border-color: rgba(15, 23, 41, 0.14);
    background: rgba(255, 255, 255, 0.94);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.55);
}
[data-theme="light"] .chat-calendar-day:hover:not(.is-disabled):not(.is-outside) {
    background: rgba(255, 255, 255, 0.98);
}
.chat-calendar-day.is-outside {
    visibility: hidden;
    pointer-events: none;
}
.chat-calendar-day.is-disabled {
    cursor: default;
}
.chat-calendar-day.is-empty:not(.is-disabled) {
    opacity: 0.88;
}
.chat-calendar-day.is-future {
    opacity: 0.45;
}
.chat-calendar-day.is-today {
    border-color: rgba(28, 206, 94, 0.48);
    background: linear-gradient(180deg, rgba(28, 206, 94, 0.16), rgba(28, 206, 94, 0.05));
}
.chat-calendar-day-number {
    font-size: 14px;
    font-weight: 700;
    line-height: 1;
}
.chat-calendar-day-dot {
    position: absolute;
    right: 9px;
    bottom: 9px;
    border-radius: 999px;
    background: rgb(28, 206, 94);
    box-shadow: none;
    transition: transform 0.15s ease, opacity 0.2s ease;
}
[data-theme="light"] .chat-calendar-day-dot {
    background: rgb(28, 206, 94);
    box-shadow: none;
}
.chat-calendar-day:hover .chat-calendar-day-dot {
    transform: scale(1.06);
}
.chat-calendar-day-dot.level-0 {
    width: 12px;
    height: 12px;
    opacity: 0;
    box-shadow: none;
}
.chat-calendar-day-dot.level-1 {
    width: 12px;
    height: 12px;
    opacity: 0.34;
}
.chat-calendar-day-dot.level-2 {
    width: 14px;
    height: 14px;
    opacity: 0.58;
}
.chat-calendar-day-dot.level-3 {
    width: 16px;
    height: 16px;
    opacity: 0.8;
}
.chat-calendar-day-dot.level-4 {
    width: 20px;
    height: 20px;
    opacity: 1;
}
.chat-calendar-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 16px;
    color: var(--text-dim);
    font-size: 12px;
}
.chat-calendar-legend-item {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: rgba(255, 255, 255, 0.03);
}
[data-theme="light"] .chat-calendar-legend-item {
    background: rgba(255, 255, 255, 0.78);
}
.chat-calendar-legend-dot {
    position: relative;
    width: 12px;
    height: 12px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.chat-calendar-legend-dot::before {
    content: "";
    border-radius: 999px;
    background:
        radial-gradient(circle at 35% 35%, rgba(255, 255, 255, 0.58), transparent 46%),
        linear-gradient(135deg, rgba(28, 206, 94, 1), rgba(28, 206, 94, 0.42));
    box-shadow: 0 0 0 1px rgba(28, 206, 94, 0.18);
}
[data-theme="light"] .chat-calendar-legend-dot::before {
    background:
        radial-gradient(circle at 35% 35%, rgba(255, 255, 255, 0.82), transparent 46%),
        linear-gradient(135deg, rgba(22, 152, 75, 1), rgba(22, 152, 75, 0.46));
    box-shadow: 0 0 0 1px rgba(22, 152, 75, 0.18);
}
.chat-calendar-legend-dot.level-0::before {
    width: 6px;
    height: 6px;
    opacity: 0;
    box-shadow: none;
}
.chat-calendar-legend-dot.level-1::before {
    width: 6px;
    height: 6px;
    opacity: 0.25;
}
.chat-calendar-legend-dot.level-2::before {
    width: 7px;
    height: 7px;
    opacity: 0.5;
}
.chat-calendar-legend-dot.level-3::before {
    width: 8px;
    height: 8px;
    opacity: 0.75;
}
.chat-calendar-legend-dot.level-4::before {
    width: 10px;
    height: 10px;
    opacity: 1;
}
@media (max-width: 640px) {
    #chatCalendarModal {
        padding: 14px;
    }
    .chat-calendar-modal-card {
        width: min(100%, 420px);
        max-height: min(82vh, 560px);
        padding: 18px;
        overflow-y: auto;
    }
    .chat-calendar-modal-head {
        gap: 8px;
        padding-right: 28px;
    }
    .chat-calendar-modal-card h3 {
        font-size: 20px;
    }
    .chat-calendar-eyebrow {
        padding: 6px 10px;
        font-size: 11px;
    }
    .chat-calendar-month-tabs {
        gap: 6px;
    }
    .chat-calendar-months-row {
        gap: 8px;
        margin-top: 14px;
    }
    .chat-calendar-nav-btn {
        width: 34px;
        height: 34px;
        border-radius: 11px;
    }
    .chat-calendar-month-tab {
        min-height: 40px;
        padding: 8px 6px;
        border-radius: 12px;
        font-size: 13px;
    }
    .chat-calendar-month-year {
        font-size: 10px;
    }
    .chat-calendar-shell {
        margin-top: 12px;
        padding: 12px;
        border-radius: 18px;
    }
    .chat-calendar-weekdays,
    .chat-calendar-grid {
        gap: 6px;
    }
    .chat-calendar-weekday {
        min-height: 20px;
        font-size: 10px;
    }
    .chat-calendar-day {
        min-height: 50px;
        padding: 8px;
        border-radius: 15px;
    }
    .chat-calendar-day-number {
        font-size: 13px;
    }
    .chat-calendar-day-dot {
        right: 6px;
        bottom: 6px;
    }
    .chat-calendar-day-dot.level-0 {
        width: 10px;
        height: 10px;
    }
    .chat-calendar-day-dot.level-1 {
        width: 10px;
        height: 10px;
    }
    .chat-calendar-day-dot.level-2 {
        width: 12px;
        height: 12px;
    }
    .chat-calendar-day-dot.level-3 {
        width: 14px;
        height: 14px;
    }
    .chat-calendar-day-dot.level-4 {
        width: 16px;
        height: 16px;
    }
}
.admin-note-field {
    width: 100%;
    min-height: 110px;
    resize: vertical;
    border-radius: 12px;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text);
    padding: 12px 14px;
    font: inherit;
    line-height: 1.5;
    outline: none;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}
.admin-note-field:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.12);
}


.modal-actions {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-top: 24px;
}
.recovery-modal-card {
    max-width: 460px;
}
.recovery-modal-card p,
.password-recovery-hint {
    color: #cbd5e1;
}
.recovery-modal-card.glass-panel {
    background: rgba(15, 23, 41, 0.84);
    border-color: rgba(255, 255, 255, 0.1);
}
[data-theme="light"] .recovery-modal-card.glass-panel {
    background: var(--surface);
    border-color: var(--border);
}
#restorePromptModal .modal-card:has(#restorePromptStepResetWarn:not(.hidden)) {
    max-width: 620px;
}
.recovery-warning-box {
    margin-top: 18px;
    margin-bottom: 0;
}
[data-theme="light"] .recovery-modal-card p,
[data-theme="light"] .password-recovery-hint {
    color: #475569;
}
[data-theme="light"] .recovery-modal-card .warning-box {
    background: #f8fafc;
    color: #475569;
    border: 1px solid #f59e0b;
    box-shadow: none;
}
[data-theme="light"] .recovery-modal-card .warning-box .material-symbols-outlined {
    color: #f59e0b;
}
[data-theme="light"] .recovery-modal-card .warning-box p,
[data-theme="light"] .recovery-modal-card .warning-box > div {
    color: #475569 !important;
}
[data-theme="light"] .recovery-modal-card .warning-box strong {
    color: #1e293b !important;
}
[data-theme="light"] .recovery-modal-card .secondary-outline-btn {
    background: #ffffff;
    color: #1e293b;
    border: 1px solid #94a3b8;
    box-shadow: none;
}
[data-theme="light"] .recovery-modal-card .secondary-outline-btn:hover {
    background: #f8fafc;
    border-color: #64748b;
    box-shadow: none;
}
.recovery-result-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 18px;
}
.recovery-result-label {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-dim);
}
.modal-danger-btn {
    margin-top: 0;
    background: var(--danger);
    color: #fff;
    border-color: transparent;
}
.unread-badge {
    background: var(--danger);
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    min-width: 20px;
    height: 20px;
    padding: 0 6px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-left: auto;
    box-shadow: 0 4px 10px rgba(255, 71, 87, 0.3);
    animation: badge-pulse 2s infinite;
}

@keyframes badge-pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.1); }
    100% { transform: scale(1); }
}

.system-message {
    display: flex;
    width: 100%;
    justify-content: center !important;
    align-items: center;
    margin: 8px 0;
    pointer-events: none;
}
.system-message span {
    background: var(--surface);
    color: var(--text-dim);
    padding: 5px 14px;
    border-radius: 14px;
    font-size: 12px;
    text-align: center;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}
.msg-date-separator {
    display: flex;
    width: 100%;
    justify-content: center;
    margin: 14px 0 10px;
    pointer-events: none;
}
.msg-date-separator span {
    background: rgba(15, 23, 41, 0.72);
    border: 1px solid var(--border);
    color: var(--text-dim);
    padding: 6px 12px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
    line-height: 1;
    box-shadow: 0 6px 18px rgba(0,0,0,0.12);
    backdrop-filter: blur(8px);
}
[data-theme="light"] .msg-date-separator span {
    background: rgba(255, 255, 255, 0.82);
}

/* Mobile back button - only visible on mobile */
.mobile-back-btn {
    display: none !important;
}
.msg-image-attachment,
.msg-video-attachment {
    max-width: 280px;
    border-radius: 10px;
    overflow: hidden;
    margin: 4px 0;
    cursor: zoom-in;
    display: inline-flex;
    position: relative;
    border: none;
    padding: 10px;
    background: transparent;
    pointer-events: none;
}
.msg-image-attachment img,
.msg-video-attachment video {
    width: 250px;
    height: 250px;
    display: block;
    object-fit: cover;
    background: rgba(128,128,128,0.15);
    transition: opacity 0.2s;
    pointer-events: auto;
    border-radius: 8px;
    cursor: zoom-in;
}
.msg-image-attachment .msg-image-size-badge,
.msg-image-attachment .file-attachment-placeholder,
.msg-video-attachment .msg-image-size-badge,
.msg-video-attachment .file-attachment-placeholder,
.msg-video-attachment .msg-video-play-badge {
    pointer-events: auto;
}
.msg-image-attachment:not(.async-file-image) img[src=""] {
    opacity: 0;
    height: 0;
}
.msg-image-attachment.async-file-image img[src=""] {
    opacity: 0;
}
.msg-video-attachment.async-file-video video[src=""] {
    opacity: 0;
}
.file-attachment-placeholder {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 12px;
    text-align: center;
    color: var(--text-dim);
    background: rgba(12, 18, 28, 0.45);
    font-size: 13px;
}
.msg-image-attachment.is-loaded .file-attachment-placeholder,
.msg-video-attachment.is-loaded .file-attachment-placeholder {
    display: none;
}
.msg-image-attachment.is-error .file-attachment-placeholder,
.msg-video-attachment.is-error .file-attachment-placeholder {
    background: rgba(120, 24, 24, 0.35);
    color: #ffd5d5;
}
[data-theme="light"] .file-attachment-placeholder {
    background: rgba(235, 240, 248, 0.85);
    color: var(--text);
}
.msg-video-play-badge {
    position: absolute;
    right: 16px;
    bottom: 16px;
    width: 40px;
    height: 40px;
    border-radius: 999px;
    background: rgba(5, 10, 18, 0.72);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 8px 24px rgba(0,0,0,0.28);
}
.msg-video-play-badge .material-symbols-outlined {
    font-size: 26px !important;
}
[data-theme="light"] .msg-video-play-badge {
    background: rgba(16, 22, 30, 0.82);
}
.msg-file-attachment {
    margin: 4px 0;
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.msg-file-attachment-row {
    display: flex;
    align-items: stretch;
    gap: 8px;
}
.msg-file-attachment .file-link-info {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--surface);
    border: 1px solid var(--border);
    padding: 8px 12px;
    border-radius: 8px;
    color: var(--accent);
    font-weight: 500;
    flex: 1;
    min-width: 0;
    cursor: default;
    user-select: none;
}
.msg-file-attachment .file-link-info .file-name {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.msg-file-attachment .file-link-info .file-size {
    flex: none;
    font-size: 12px;
    font-weight: 400;
    color: var(--text-dim);
    margin-left: 6px;
}
.msg-file-attachment .file-download-btn {
    flex: none;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--accent);
    cursor: pointer;
    text-decoration: none;
    transition: background 0.2s;
    appearance: none;
}
.msg-file-attachment .file-download-btn:hover {
    background: var(--surface-hover);
}
.msg-file-attachment .file-download-btn.is-downloading {
    color: #ff7676;
    border-color: rgba(255, 118, 118, 0.4);
}
.msg-file-attachment .file-download-btn .material-symbols-outlined {
    font-size: 20px !important;
}
.msg-group-download-all-row {
    width: min(100%, 320px);
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 8px;
}
.incoming .msg-group-download-all-row {
    align-items: flex-start;
}
.outgoing .msg-group-download-all-row {
    align-items: flex-end;
}
.msg-group-download-all-btn {
    appearance: none;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-height: 34px;
    padding: 8px 14px;
    border-radius: 999px;
    border: 1px solid rgba(76, 154, 255, 0.24);
    background: rgba(17, 24, 39, 0.62);
    color: var(--accent);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.18s ease, border-color 0.18s ease, transform 0.18s ease, opacity 0.18s ease;
}
.msg-group-download-all-btn:hover {
    background: rgba(17, 24, 39, 0.78);
    border-color: rgba(76, 154, 255, 0.38);
    transform: translateY(-1px);
}
[data-theme="light"] .msg-group-download-all-btn {
    background: rgba(255, 255, 255, 0.92);
    border-color: rgba(22, 152, 75, 0.22);
    color: var(--accent);
    box-shadow: 0 8px 18px rgba(15, 23, 41, 0.08);
}
[data-theme="light"] .msg-group-download-all-btn:hover {
    background: #ffffff;
    border-color: rgba(22, 152, 75, 0.36);
}
.msg-group-download-all-btn:disabled {
    cursor: default;
    transform: none;
}
.msg-group-download-all-btn.is-downloading {
    color: var(--text);
    border-color: rgba(255, 199, 79, 0.38);
    background: rgba(255, 199, 79, 0.16);
}
.msg-group-download-all-btn .material-symbols-outlined {
    font-size: 18px !important;
}
.msg-group-download-all-label {
    white-space: nowrap;
}
.msg-group-download-all-progress {
    width: 100%;
    padding: 10px 12px;
    border-radius: 14px;
    border: 1px solid rgba(76, 154, 255, 0.16);
    background: rgba(10, 16, 28, 0.82);
    backdrop-filter: blur(12px);
}
.msg-group-download-all-progress.is-done {
    border-color: rgba(76, 175, 80, 0.28);
    background: rgba(35, 82, 42, 0.28);
}
.msg-group-download-all-progress.is-error {
    border-color: rgba(255, 118, 118, 0.3);
    background: rgba(110, 29, 29, 0.28);
}
.msg-group-download-all-progress-title {
    font-size: 12px;
    font-weight: 700;
    color: var(--text);
}
.msg-group-download-all-progress-bar {
    margin-top: 8px;
}
.msg-group-download-all-progress-fill {
    transition: width 120ms linear;
}
.msg-group-download-all-progress-fill.indeterminate {
    animation: group-download-progress-indeterminate 1.2s linear infinite;
}
.msg-group-download-all-progress-meta {
    margin-top: 8px;
    font-size: 12px;
    color: var(--text-dim);
    line-height: 1.35;
}
@keyframes group-download-progress-indeterminate {
    0% { transform: translateX(-55%); }
    100% { transform: translateX(55%); }
}
.file-download-progress {
    padding: 6px 12px 8px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.file-download-progress-text {
    font-size: 12px;
    color: var(--text-dim);
}
.file-download-progress-fill {
    transition: width 120ms linear;
}
.file-download-progress-meta {
    font-size: 11px;
    color: var(--text-dim);
}
#devicesGeneratedBlock {
    position: relative;
}
.device-pairing-used-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 10px;
    background: rgba(28, 206, 94, 0.9);
    color: #fff;
    font-size: 18px;
    font-weight: 600;
    border-radius: 12px;
    z-index: 5;
    animation: devicePairingUsedFadeIn 220ms ease;
}
.device-pairing-used-overlay .material-symbols-outlined {
    font-size: 56px !important;
}
.device-pairing-pending-note {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    margin-top: 10px;
    padding: 10px 12px;
    border-radius: 10px;
    border: 1px solid rgba(148, 163, 184, 0.24);
    background: rgba(148, 163, 184, 0.10);
    color: var(--text-dim);
    font-size: 13px;
    line-height: 1.4;
    text-align: left;
}
.device-pairing-pending-note .material-symbols-outlined {
    color: var(--accent);
    font-size: 18px !important;
    flex: none;
}
@keyframes devicePairingUsedFadeIn {
    from { opacity: 0; transform: scale(0.94); }
    to { opacity: 1; transform: scale(1); }
}
.vps-gauges {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    margin-bottom: 16px;
}
.vps-gauge {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 14px 10px 12px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
}
.vps-gauge-ring {
    position: relative;
    width: 120px;
    height: 120px;
}
.vps-gauge-ring svg {
    width: 100%;
    height: 100%;
    display: block;
}
.vps-gauge-track {
    fill: none;
    stroke: var(--border);
    stroke-width: 10;
}
.vps-gauge-arc {
    fill: none;
    stroke: #22c55e;
    stroke-width: 10;
    stroke-linecap: round;
    stroke-dasharray: 0 9999;
    transition: stroke-dasharray 0.4s ease;
}
.vps-gauge-value {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 2px;
    color: var(--text);
    font-weight: 600;
    line-height: 1;
}
.vps-gauge-num { font-size: 22px; line-height: 1; }
.vps-gauge-unit { font-size: 12px; line-height: 1; color: var(--text-dim); align-self: center; }
.vps-gauge-label {
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
    margin-top: 2px;
}
.vps-gauge-sub {
    font-size: 11px;
    color: var(--text-dim);
    text-align: center;
}
.vps-chart-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 12px;
}
.admin-system-panel-head {
    display: flex;
    align-items: flex-start;
    gap: 14px;
    justify-content: space-between;
    border-bottom: 1px solid var(--border);
    padding-bottom: 16px;
    margin-bottom: 20px;
}
.admin-system-panel-head-copy {
    flex: 1 1 auto;
    min-width: 0;
}
.admin-system-panel-actions {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    gap: 10px;
}
.admin-system-panel-actions .secondary-outline-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}
.admin-diagnostics-shell {
    display: flex;
    flex-direction: column;
    gap: 18px;
}
.admin-diagnostics-hero {
    display: grid;
    grid-template-columns: minmax(0, 1.2fr) minmax(260px, 0.8fr);
    gap: 16px;
    padding: 20px;
    border-radius: 22px;
    border: 1px solid rgba(34, 197, 94, 0.18);
    background:
        radial-gradient(circle at top right, rgba(34, 197, 94, 0.14), transparent 42%),
        linear-gradient(180deg, rgba(255, 255, 255, 0.02), rgba(255, 255, 255, 0.01)),
        var(--surface);
}
.admin-diagnostics-hero-main {
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.admin-diagnostics-hero-main h3 {
    margin: 0;
    font-size: 22px;
    line-height: 1.2;
}
.admin-diagnostics-hero-main p {
    margin: 0;
    color: var(--text-dim);
    line-height: 1.55;
}
.admin-diagnostics-hero-meta {
    display: grid;
    gap: 10px;
}
.admin-diagnostics-meta-stat {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 14px 16px;
    border-radius: 16px;
    border: 1px solid var(--border);
    background: rgba(255, 255, 255, 0.03);
}
.admin-diagnostics-meta-stat span {
    font-size: 12px;
    color: var(--text-dim);
}
.admin-diagnostics-meta-stat strong {
    font-size: 16px;
    line-height: 1.25;
}
.admin-diagnostics-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
}
.admin-diagnostics-tabs {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    width: fit-content;
    padding: 4px;
    border-radius: 14px;
    border: 1px solid var(--border);
    background: rgba(255, 255, 255, 0.03);
}
.admin-diagnostics-tab {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 9px 14px;
    border: 0;
    border-radius: 10px;
    background: transparent;
    color: var(--text-dim);
    font-weight: 700;
    cursor: pointer;
}
.admin-diagnostics-tab:hover,
.admin-diagnostics-tab.is-active {
    background: rgba(59, 130, 246, 0.16);
    color: var(--text);
}
.admin-diagnostics-tab .material-symbols-outlined {
    font-size: 18px;
}
.admin-diagnostics-card {
    display: flex;
    flex-direction: column;
    gap: 16px;
    padding: 18px;
    border-radius: 20px;
    background: var(--surface);
    border: 1px solid var(--border);
}
.admin-diagnostics-card-head {
    display: flex;
    align-items: flex-start;
    gap: 12px;
}
.admin-diagnostics-card-head .material-symbols-outlined {
    font-size: 26px;
    color: var(--accent);
}
.admin-diagnostics-card-head h4 {
    margin: 0 0 4px;
    font-size: 18px;
}
.admin-diagnostics-card-head p {
    margin: 0;
    color: var(--text-dim);
    font-size: 13px;
    line-height: 1.45;
    word-break: break-word;
}
.admin-diagnostics-card-body {
    display: flex;
    flex-direction: column;
    gap: 12px;
}
.admin-diagnostics-speed-card {
    max-width: none;
}
.admin-diagnostics-speed-hero {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 18px;
    border-radius: 18px;
    border: 1px solid rgba(59, 130, 246, 0.18);
    background: rgba(59, 130, 246, 0.08);
}
.admin-diagnostics-speed-hero > div {
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.admin-diagnostics-speed-label {
    color: var(--text-dim);
    font-size: 13px;
    font-weight: 600;
}
.admin-diagnostics-speed-hero strong {
    font-size: 38px;
    line-height: 1;
}
.admin-diagnostics-speed-hero strong span {
    color: var(--text-dim);
    font-size: 20px;
}
.admin-diagnostics-row {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 14px;
    padding: 12px 14px;
    border-radius: 16px;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid rgba(255, 255, 255, 0.04);
}
.admin-diagnostics-row-copy {
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.admin-diagnostics-row-copy strong {
    font-size: 14px;
    line-height: 1.35;
}
.admin-diagnostics-row-copy small {
    color: var(--text-dim);
    line-height: 1.45;
    word-break: break-word;
}
.admin-diagnostics-row-value {
    flex: 0 0 auto;
}
.diagnostic-chip {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    border-radius: 999px;
    font-size: 13px;
    font-weight: 600;
    border: 1px solid transparent;
    white-space: nowrap;
}
.diagnostic-chip .material-symbols-outlined {
    font-size: 18px;
}
.diagnostic-chip.is-ok {
    color: #d7ffe6;
    background: rgba(34, 197, 94, 0.16);
    border-color: rgba(34, 197, 94, 0.28);
}
.diagnostic-chip.is-warn {
    color: #fff1c6;
    background: rgba(245, 158, 11, 0.16);
    border-color: rgba(245, 158, 11, 0.28);
}
.diagnostic-chip.is-off {
    color: #d8dee9;
    background: rgba(148, 163, 184, 0.12);
    border-color: rgba(148, 163, 184, 0.22);
}
.diagnostic-chip.is-neutral {
    color: #d8e8ff;
    background: rgba(59, 130, 246, 0.14);
    border-color: rgba(59, 130, 246, 0.24);
}
.admin-diagnostics-issues-block {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 14px;
    border-radius: 16px;
    background: rgba(255, 255, 255, 0.02);
    border: 1px dashed rgba(255, 255, 255, 0.08);
}
.admin-diagnostics-issues-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
.admin-diagnostics-issue,
.admin-diagnostics-empty,
.admin-diagnostics-error {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 12px 14px;
    border-radius: 14px;
}
.admin-diagnostics-issue {
    background: rgba(245, 158, 11, 0.1);
    color: #ffe8b3;
}
.admin-diagnostics-empty {
    background: rgba(34, 197, 94, 0.1);
    color: #d7ffe6;
}
.admin-diagnostics-empty.compact {
    padding: 10px 12px;
    font-size: 13px;
}
.admin-diagnostics-error {
    background: rgba(239, 68, 68, 0.12);
    color: #ffd7d7;
    border: 1px solid rgba(239, 68, 68, 0.22);
}
.admin-diagnostics-error small {
    display: block;
    margin-top: 4px;
    color: inherit;
    opacity: 0.85;
}
.admin-diagnostics-perf-block,
.admin-diagnostics-perf-section,
.admin-diagnostics-perf-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.admin-diagnostics-perf-block {
    margin-top: 2px;
}
.admin-diagnostics-perf-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 12px;
}
.admin-diagnostics-perf-grid.is-four {
    grid-template-columns: repeat(4, minmax(0, 1fr));
}
.admin-diagnostics-perf-item {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 10px 12px;
    border-radius: 14px;
    border: 1px solid rgba(255, 255, 255, 0.05);
    background: rgba(255, 255, 255, 0.025);
}
.admin-diagnostics-perf-item strong {
    font-size: 13px;
    line-height: 1.35;
    word-break: break-word;
}
.admin-diagnostics-perf-item small {
    color: var(--text-dim);
    line-height: 1.45;
    word-break: break-word;
}
.admin-audit-shell {
    display: flex;
    flex-direction: column;
    gap: 18px;
}
.admin-audit-toolbar {
    padding: 18px;
    margin-bottom: 18px;
    border-radius: 20px;
    background: var(--surface);
    border: 1px solid var(--border);
}
.admin-audit-filters {
    display: grid;
    grid-template-columns: minmax(260px, 2fr) repeat(3, minmax(0, 1fr)) auto;
    gap: 12px;
    align-items: end;
}
.admin-audit-field {
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.admin-audit-field span {
    font-size: 12px;
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
.admin-audit-field input,
.admin-audit-field select {
    width: 100%;
    min-height: 46px;
    padding: 0 14px;
    border-radius: 14px;
    border: 1px solid var(--border);
    background: rgba(255, 255, 255, 0.03);
    color: var(--text);
    outline: none;
    transition: border-color 0.18s ease, box-shadow 0.18s ease, background 0.18s ease;
}
.admin-audit-field input::placeholder {
    color: var(--text-dim);
}
.admin-audit-field input:focus,
.admin-audit-field select:focus {
    border-color: rgba(59, 130, 246, 0.36);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.12);
}
.admin-audit-filter-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    align-items: baseline;
}
.admin-audit-filter-actions .primary-btn,
.admin-audit-filter-actions .secondary-outline-btn {
    min-height: 46px;
}
.admin-audit-active-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}
.admin-audit-active-filter {
    display: inline-flex;
    align-items: center;
    padding: 8px 11px;
    border-radius: 999px;
    background: rgba(34, 197, 94, 0.12);
    border: 1px solid rgba(34, 197, 94, 0.2);
    color: #d7ffe6;
    font-size: 12px;
    line-height: 1.2;
}
.admin-audit-summary {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 12px;
}
.admin-audit-summary-card {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 16px 18px;
    border-radius: 18px;
    background: var(--surface);
    border: 1px solid var(--border);
}
.admin-audit-summary-card span {
    font-size: 12px;
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
.admin-audit-summary-card strong {
    font-size: 18px;
    line-height: 1.25;
}
.audit-log-list {
    display: flex;
    flex-direction: column;
    gap: 14px;
}
.audit-log-card {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 18px;
    border-radius: 20px;
    background: var(--surface);
    border: 1px solid var(--border);
}
.audit-log-card-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
}
.audit-log-card-title {
    flex: 1 1 auto;
    min-width: 0;
}
.audit-log-card-time {
    flex: 0 0 auto;
    font-size: 12px;
    color: var(--text-dim);
    white-space: nowrap;
}
.audit-log-card-subtitle {
    margin: 0;
    color: var(--text-dim);
    line-height: 1.5;
}
.audit-log-principals {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
}
.audit-log-principal {
    display: flex;
    flex-direction: column;
    gap: 5px;
    padding: 12px 14px;
    border-radius: 16px;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid rgba(255, 255, 255, 0.04);
}
.audit-log-principal span {
    font-size: 12px;
    color: var(--text-dim);
}
.audit-log-principal strong {
    font-size: 14px;
    line-height: 1.4;
    word-break: break-word;
}
.audit-log-details {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}
.audit-log-detail {
    display: inline-flex;
    align-items: center;
    padding: 8px 11px;
    border-radius: 999px;
    background: rgba(59, 130, 246, 0.12);
    border: 1px solid rgba(59, 130, 246, 0.18);
    color: #dbeafe;
    font-size: 12px;
    line-height: 1.2;
}
.audit-log-footer {
    display: flex;
    flex-wrap: wrap;
    gap: 10px 14px;
    font-size: 12px;
    color: var(--text-dim);
}
.audit-log-expanded {
    border-top: 1px solid rgba(255, 255, 255, 0.06);
    padding-top: 10px;
}
.audit-log-expanded summary {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    color: var(--text);
    font-size: 13px;
    font-weight: 600;
    list-style: none;
    user-select: none;
}
.audit-log-expanded summary::-webkit-details-marker {
    display: none;
}
.audit-log-expanded summary .material-symbols-outlined {
    font-size: 18px;
    color: var(--accent);
}
.audit-log-expanded[open] summary {
    margin-bottom: 12px;
}
.audit-log-expanded-body {
    display: flex;
    flex-direction: column;
    gap: 12px;
}
.audit-log-expanded-meta {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
}
.audit-log-expanded-meta div {
    display: flex;
    flex-direction: column;
    gap: 5px;
    padding: 12px 14px;
    border-radius: 16px;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid rgba(255, 255, 255, 0.04);
}
.audit-log-expanded-meta span {
    font-size: 12px;
    color: var(--text-dim);
}
.audit-log-expanded-meta strong {
    font-size: 13px;
    line-height: 1.4;
    word-break: break-word;
}
.audit-log-json {
    margin: 0;
    padding: 14px;
    border-radius: 16px;
    background: rgba(15, 23, 42, 0.38);
    border: 1px solid rgba(148, 163, 184, 0.14);
    color: #dbeafe;
    font-size: 12px;
    line-height: 1.55;
    overflow-x: auto;
    white-space: pre-wrap;
    word-break: break-word;
}
.audit-log-empty {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 18px 20px;
    border-radius: 18px;
    background: var(--surface);
    border: 1px dashed var(--border);
}
.audit-log-empty .material-symbols-outlined {
    font-size: 28px;
    color: var(--accent);
}
.audit-log-empty strong {
    display: block;
    margin-bottom: 4px;
}
.audit-log-empty small {
    color: var(--text-dim);
    line-height: 1.5;
}
.audit-log-empty-error {
    border-style: solid;
    background: rgba(239, 68, 68, 0.1);
}
[data-theme="light"] .admin-audit-summary-card,
[data-theme="light"] .admin-audit-toolbar,
[data-theme="light"] .audit-log-card,
[data-theme="light"] .audit-log-empty {
    background: rgba(255, 255, 255, 0.88);
}
[data-theme="light"] .admin-audit-field input,
[data-theme="light"] .admin-audit-field select {
    background: rgba(15, 23, 42, 0.03);
    border-color: rgba(15, 23, 42, 0.08);
}
[data-theme="light"] .admin-audit-active-filter {
    color: #166534;
    background: rgba(34, 197, 94, 0.12);
    border-color: rgba(34, 197, 94, 0.2);
}
[data-theme="light"] .audit-log-expanded {
    border-top-color: rgba(15, 23, 42, 0.08);
}
[data-theme="light"] .audit-log-expanded-meta div {
    background: rgba(15, 23, 42, 0.03);
    border-color: rgba(15, 23, 42, 0.06);
}
[data-theme="light"] .audit-log-json {
    color: #1e293b;
    background: rgba(248, 250, 252, 0.92);
    border-color: rgba(15, 23, 42, 0.08);
}
[data-theme="light"] .audit-log-principal {
    background: rgba(15, 23, 42, 0.03);
    border-color: rgba(15, 23, 42, 0.06);
}
[data-theme="light"] .audit-log-detail {
    color: #1d4ed8;
    background: rgba(59, 130, 246, 0.1);
    border-color: rgba(59, 130, 246, 0.16);
}
[data-theme="light"] .audit-log-empty-error {
    color: #991b1b;
}
[data-theme="light"] .admin-diagnostics-hero {
    border-color: rgba(22, 163, 74, 0.16);
    background:
        radial-gradient(circle at top right, rgba(34, 197, 94, 0.1), transparent 42%),
        linear-gradient(180deg, rgba(255, 255, 255, 0.8), rgba(255, 255, 255, 0.88)),
        var(--surface);
}
[data-theme="light"] .admin-diagnostics-meta-stat,
[data-theme="light"] .admin-diagnostics-row,
[data-theme="light"] .admin-diagnostics-issues-block {
    background: rgba(15, 23, 42, 0.03);
    border-color: rgba(15, 23, 42, 0.06);
}
[data-theme="light"] .diagnostic-chip.is-ok {
    color: #116336;
}
[data-theme="light"] .diagnostic-chip.is-warn {
    color: #8a4b00;
}
[data-theme="light"] .diagnostic-chip.is-off {
    color: #475569;
}
[data-theme="light"] .diagnostic-chip.is-neutral {
    color: #1d4ed8;
}
[data-theme="light"] .admin-diagnostics-issue {
    color: #8a4b00;
}
[data-theme="light"] .admin-diagnostics-empty {
    color: #116336;
}
[data-theme="light"] .admin-diagnostics-error {
    color: #991b1b;
}
.vps-chart-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 8px;
    font-size: 12px;
    color: var(--text-dim);
}
.vps-legend-item { display: inline-flex; align-items: center; gap: 6px; }
.vps-legend-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    display: inline-block;
}
#vpsLoadChart {
    width: 100%;
    display: block;
}
@media (max-width: 600px) {
    .vps-gauges { grid-template-columns: 1fr; }
    .vps-gauge-ring { width: 104px; height: 104px; }
    .admin-system-panel-head {
        flex-direction: column;
        align-items: stretch;
    }
    .admin-system-panel-actions {
        width: 100%;
    }
    .admin-system-panel-actions .secondary-outline-btn {
        width: 100%;
        justify-content: center;
    }
    .admin-diagnostics-hero,
    .admin-diagnostics-grid,
    .admin-diagnostics-perf-grid.is-four {
        grid-template-columns: 1fr;
    }
    .admin-diagnostics-tabs {
        width: 100%;
    }
    .admin-diagnostics-tab {
        flex: 1 1 0;
        justify-content: center;
    }
    .admin-diagnostics-speed-hero {
        align-items: flex-start;
        flex-direction: column;
    }
    .admin-audit-filters {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
    .admin-audit-field-search,
    .admin-audit-filter-actions {
        grid-column: 1 / -1;
    }
    .admin-audit-filter-actions {
        justify-content: flex-end;
    }
    .admin-diagnostics-hero-meta {
        grid-template-columns: 1fr;
    }
    .admin-diagnostics-row {
        flex-direction: column;
    }
    .admin-audit-summary,
    .admin-audit-filters,
    .audit-log-expanded-meta,
    .audit-log-principals {
        grid-template-columns: 1fr;
    }
    .admin-audit-toolbar,
    .audit-log-card,
    .audit-log-empty {
        padding: 16px;
    }
    .admin-audit-field-search,
    .admin-audit-filter-actions {
        grid-column: auto;
    }
    .admin-audit-filter-actions {
        flex-direction: column;
        align-items: stretch;
    }
    .admin-audit-filter-actions .primary-btn,
    .admin-audit-filter-actions .secondary-outline-btn {
        width: 100%;
    }
    .audit-log-card-head {
        flex-direction: column;
    }
}

.msg-bubble a.msg-link,
.msg-link {
    color: var(--accent);
    text-decoration: underline;
    word-break: break-all;
}
.msg-link:hover { text-decoration: none; }

.msg-wrap.system-message.call-event {
    display: flex;
    justify-content: center;
    margin: 6px 0;
}
.call-event-bubble {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    border-radius: 12px;
    background: rgba(239, 68, 68, 0.16);
    border: 1px solid rgba(239, 68, 68, 0.45);
    color: #ef4444;
    font-size: 13px;
    font-weight: 500;
}
.call-event-bubble .material-symbols-outlined {
    font-size: 18px;
    line-height: 1;
}
.call-event-time {
    color: rgba(239, 68, 68, 0.7);
    font-size: 11px;
    font-weight: 400;
    margin-left: 4px;
}

.msg-image-size-badge {
    position: absolute;
    bottom: 6px;
    right: 6px;
    padding: 2px 6px;
    border-radius: 6px;
    font-size: 11px;
    font-weight: 500;
    color: #fff;
    background: rgba(0, 0, 0, 0.55);
    pointer-events: none;
}
.attach-btn {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: var(--surface);
    border: 1px solid var(--border);
    color: var(--text-dim);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.2s, color 0.2s, border-color 0.2s, transform 0.2s;
    flex-shrink: 0;
}
.attach-btn:hover {
    color: var(--accent);
    border-color: var(--accent);
    transform: scale(1.05);
}
.user-row.is-notes .user-row-avatar {
    background: linear-gradient(135deg, var(--accent), #6ea8ff);
}
.attach-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}
.drag-drop-overlay {
    position: fixed;
    inset: 0;
    z-index: 2000;
    background: rgba(4, 10, 20, 0.85);
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(4px);
    transition: opacity 0.2s;
}
.drag-drop-overlay.hidden {
    opacity: 0;
    pointer-events: none;
}
.drag-drop-content {
    border: 3px dashed var(--accent);
    border-radius: 20px;
    padding: 60px;
    text-align: center;
    color: #fff;
    background: rgba(28, 206, 94, 0.1);
}
.drag-drop-icon {
    font-size: 64px;
    color: var(--accent);
    margin-bottom: 16px;
}
.lightbox-overlay {
    position: fixed;
    inset: 0;
    z-index: 2500;
    background: rgba(0,0,0,0.9);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 14px;
    padding: 72px 20px max(24px, env(safe-area-inset-bottom, 0px));
    box-sizing: border-box;
    cursor: zoom-out;
    transition: opacity 0.2s;
    touch-action: pan-y pinch-zoom;
    overscroll-behavior: contain;
}
.lightbox-overlay.hidden {
    opacity: 0;
    pointer-events: none;
}
.lightbox-close {
    position: absolute;
    top: 20px;
    right: 20px;
    color: #fff;
    cursor: pointer;
    background: rgba(255,255,255,0.1);
    border-radius: 50%;
    padding: 8px;
    display: flex;
}
.lightbox-counter {
    position: absolute;
    top: 22px;
    left: 22px;
    padding: 8px 12px;
    border-radius: 999px;
    background: rgba(255,255,255,0.12);
    color: #fff;
    font-size: 13px;
    font-weight: 600;
    cursor: default;
}
.lightbox-loading {
    position: absolute;
    left: 50%;
    bottom: 28px;
    transform: translateX(-50%);
    padding: 10px 14px;
    border-radius: 999px;
    background: rgba(255,255,255,0.12);
    color: #fff;
    font-size: 14px;
    font-weight: 600;
    cursor: default;
}
.lightbox-actions {
    position: static;
    transform: none;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px;
    border-radius: 8px;
    background: rgba(10, 14, 24, 0.72);
    border: 1px solid rgba(255,255,255,0.14);
    box-shadow: 0 10px 34px rgba(0,0,0,0.34);
    cursor: default;
}
.lightbox-actions.hidden {
    display: none;
}
.lightbox-action-btn {
    min-height: 38px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    border: none;
    border-radius: 6px;
    padding: 0 12px;
    background: rgba(255,255,255,0.14);
    color: #fff;
    font: inherit;
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
    transition: background 0.18s ease, transform 0.12s ease, opacity 0.18s ease;
}
.lightbox-action-btn:hover {
    background: rgba(255,255,255,0.24);
}
.lightbox-action-btn:active {
    transform: translateY(1px);
}
.lightbox-action-btn:disabled {
    opacity: 0.55;
    cursor: wait;
}
.lightbox-action-btn .material-symbols-outlined {
    font-size: 19px;
}
.lightbox-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 54px;
    height: 54px;
    border: none;
    border-radius: 999px;
    background: rgba(255,255,255,0.14);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.2s, transform 0.2s;
}
.lightbox-nav:hover {
    background: rgba(255,255,255,0.22);
}
.lightbox-nav:active {
    transform: translateY(-50%) scale(0.96);
}
.lightbox-nav .material-symbols-outlined {
    font-size: 34px !important;
}
.lightbox-nav-prev {
    left: 18px;
}
.lightbox-nav-next {
    right: 18px;
}
.lightbox-overlay img,
.lightbox-overlay video {
    max-width: 90vw;
    max-height: calc(100vh - 170px - env(safe-area-inset-bottom, 0px));
    max-height: calc(100dvh - 170px - env(safe-area-inset-bottom, 0px));
    border-radius: 4px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.5);
    cursor: default;
    touch-action: pan-y pinch-zoom;
}
.lightbox-overlay video {
    background: #000;
}


/* ========== MOBILE ADAPTATION ========== */

@media (max-width: 768px) {
    /* Remove body overflow lock on mobile to allow scrolling where needed */
    html, body { overflow: hidden; }

    /* ---- AUTH ---- */
    .auth-card {
        padding: 28px 20px;
        border-radius: 16px;
    }

    /* ---- ADMIN LAYOUT: sidebar becomes TOP tab bar ---- */
    .app-layout {
        flex-direction: column;
    }

    .sidebar {
        width: 100% !important;
        min-width: 0 !important;
        height: 42px;
        flex-direction: row;
        border-right: none;
        border-top: none;
        border-bottom: 1px solid var(--border);
        order: 1; /* moves to TOP */
        backdrop-filter: blur(16px);
        overflow: visible;
        flex-shrink: 0;
    }

    .sidebar-header { display: none !important; }

    .sidebar-nav {
        flex: 1;
        display: flex;
        flex-direction: row;
        align-items: center;
        justify-content: space-around;
        padding: 0;
        gap: 0;
    }

    .nav-item {
        flex: 1;
        flex-direction: column;
        justify-content: center;
        align-items: center;
        gap: 0;
        padding: 4px !important;
        border-radius: 0;
        margin-bottom: 0;
        height: 42px;
    }

    .nav-item .material-symbols-outlined {
        font-size: 22px !important;
        margin: 0 !important;
    }

    .nav-item span:not(.material-symbols-outlined) {
        display: none !important;
    }
    .nav-item .contact-avatar-sm {
        width: 24px;
        height: 24px;
        font-size: 12px;
        flex: none;
    }

    .sidebar-footer { display: none !important; }

    /* ---- MAIN CONTENT ---- */
    .main-content {
        height: calc(100vh - 42px);
        height: calc(100dvh - 42px);
        min-height: 0;
        order: 2;
        overflow-y: auto; /* allow panels like settings to scroll */
    }

    /* ---- PANELS: allow scrolling ---- */
    .panel {
        padding: 20px 16px;
        max-width: 100%;
        height: 100%;
        overflow-y: auto;
    }
    .conference-panel {
        padding: 10px 0 0 !important;
    }
    .conference-mount {
        height: calc(100% - 10px);
    }


    /* ---- ADMIN CHAT panel goes full screen on mobile ---- */
    #panelChat {
        position: fixed;
        inset: 0;
        z-index: 500;
        height: 100vh !important;
        height: 100dvh !important;
        /* stays hidden until opened */
        transform: translateX(100%);
        transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        background: var(--bg);
        min-height: 0;
    }

    #panelChat:not(.hidden) {
        display: flex !important;
        transform: translateX(0);
    }

    /* Back button inside admin chat topbar for mobile */
    .chat-topbar-admin {
        padding: 12px 16px;
    }

    /* Show back arrow and hide X close on mobile */
    .mobile-back-btn {
        display: flex !important;
    }
    #adminCloseChat {
        display: none !important;
    }

    /* ---- USER CHAT LAYOUT ---- */
    /* User app-layout (chatView) mirrors admin: sidebar becomes top tab bar */
    #chatView.app-layout {
        flex-direction: column;
        height: 100vh;
        height: 100dvh;
        overflow: hidden;
    }
    #chatView .sidebar {
        order: 1;
        height: 42px;
        width: 100% !important;
        min-width: 0 !important;
        flex-direction: row;
        border-right: none;
        border-top: none;
        border-bottom: 1px solid var(--border);
        flex-shrink: 0;
    }
    #chatView .sidebar-header { display: none !important; }
    #chatView .sidebar-nav {
        flex-direction: row;
        justify-content: space-around;
        align-items: center;
        padding: 0;
    }
    #chatView .sidebar-footer { display: none !important; }
    #chatView .chat-main {
        order: 2;
        height: calc(100vh - 42px);
        height: calc(100dvh - 42px);
        flex: 1;
        display: flex;
        flex-direction: column;
        overflow: hidden;
        min-height: 0;
    }
    #userMainArea {
        height: calc(100vh - 42px);
        height: calc(100dvh - 42px);
        display: flex;
        flex-direction: column;
        overflow: hidden;
        min-height: 0;
    }

    #chatPanel {
        height: 100%;
        flex: 1;
        display: flex;
        flex-direction: column;
        overflow: hidden;
        min-height: 0;
    }

    .chat-topbar {
        padding: 12px 16px;
    }

    /* ---- MESSAGES AREA ---- */
    .messages-area {
        padding: 12px 10px !important;
        min-height: 0;
    }

    /* ---- BUBBLES ---- */
    .msg-bubble {
        max-width: 88vw !important;
        /* rely on var(--msg-font-size) defined above instead of override */
    }

    /* ---- INPUT BAR ---- */
    .chat-input-bar {
        padding: 10px 12px;
        padding-bottom: max(10px, env(safe-area-inset-bottom));
        position: sticky;
        bottom: 0;
        z-index: 5;
    }
    .upload-dock {
        padding: 0 12px 10px;
    }
    .upload-dock-card {
        padding: 12px 14px;
        gap: 12px;
    }
    .upload-dock-icon {
        width: 40px;
        height: 40px;
        border-radius: 12px;
    }
    .upload-hub-fab {
        right: 14px;
        bottom: calc(92px + env(safe-area-inset-bottom));
        min-height: 52px;
        padding: 0 16px;
    }
    .upload-hub-fab-label {
        display: none;
    }
    .upload-hub-panel {
        right: 12px;
        left: 12px;
        width: auto;
        bottom: calc(154px + env(safe-area-inset-bottom));
        max-height: calc(100dvh - 182px - env(safe-area-inset-bottom));
    }
    .upload-hub-card {
        padding: 16px;
        border-radius: 20px;
    }
    .upload-hub-head {
        flex-direction: column;
        align-items: stretch;
    }
    .upload-hub-head-actions,
    .upload-hub-group-toolbar {
        width: 100%;
        justify-content: space-between;
    }
    .upload-hub-group-summary,
    .upload-hub-group-body {
        padding-left: 14px;
        padding-right: 14px;
    }

    textarea#messageInput,
    textarea#adminMessageInput {
        font-size: 16px; /* prevents iOS zoom */
        padding: 10px 12px;
    }

    .send-btn, .attach-btn, .emoji-toggle-btn, .edit-cancel-btn {
        width: 44px;
        height: 44px;
        min-width: 44px;
        flex: 0 0 44px;
    }

    /* ---- IMAGE ATTACHMENTS ---- */
    .msg-image-attachment img,
    .msg-video-attachment video {
        width: min(220px, 80vw);
        height: min(220px, 80vw);
    }

    /* ---- EMOJI PICKER ---- */
    .emoji-picker {
        left: 0;
        right: auto;
        width: min(312px, calc(100vw - 20px));
        max-width: calc(100vw - 20px);
        max-height: 300px;
    }

    /* ---- MODALS ---- */
    .modal-card {
        max-width: calc(100vw - 32px);
        padding: 20px 16px;
    }

    .call-overlay {
        align-items: stretch;
        padding: 0;
    }
    .call-card {
        width: 100%;
        min-height: 100%;
        border-radius: 0;
        display: flex;
        flex-direction: column;
        justify-content: center;
        padding: 32px 20px;
    }
    .call-card h2 {
        font-size: 26px;
    }
    .call-status-text {
        font-size: 16px;
    }
    .call-actions {
        margin-top: 30px;
        gap: 18px;
    }
    .call-control-btn {
        width: 68px;
        height: 68px;
    }
    .call-toast {
        bottom: calc(20px + env(safe-area-inset-bottom));
        max-width: calc(100vw - 24px);
        white-space: normal;
        text-align: center;
    }
    .call-quality-profiles,
    .call-quality-metrics {
        grid-template-columns: 1fr;
    }
    .call-quality-panel {
        margin-top: 20px;
    }

    /* ---- USER LIST ---- */
    .user-row {
        padding: 12px 14px;
    }

    /* ---- SETTINGS ---- */
    .settings-item {
        align-items: flex-start;
        gap: 14px;
    }
    .theme-mode-control {
        width: 100%;
        justify-content: space-between;
        flex-wrap: nowrap; /* buttons side by side */
        overflow: hidden;
    }
    .theme-mode-btn {
        flex: 1;
        min-width: 0;
        width: auto;
        height: 38px;
        padding: 0 8px;
    }
    .call-quality-mode-toggle {
        width: 100%;
    }
    .call-quality-mode-btn {
        flex: 1;
        min-width: 0;
    }
    .theme-mode-btn .material-symbols-outlined { font-size: 18px !important; }
    .secret-field-row { flex-wrap: wrap; }
    .secret-phrase-input { min-width: 0; }

    /* ---- SETTINGS LIST: make scrollable on mobile ---- */
    .settings-list {
        -webkit-overflow-scrolling: touch;
    }

    /* ---- LIGHTBOX ---- */
    .lightbox-overlay img,
    .lightbox-overlay video {
        max-width: 98vw;
        max-height: 85vh;
    }
    .lightbox-nav {
        width: 46px;
        height: 46px;
    }
    .lightbox-nav-prev {
        left: 10px;
    }
    .lightbox-nav-next {
        right: 10px;
    }
    .lightbox-counter {
        top: 14px;
        left: 14px;
        font-size: 12px;
        padding: 7px 10px;
    }
    .lightbox-loading {
        bottom: 18px;
        font-size: 13px;
    }

    /* ---- PINNED BANNER ---- */
    .pinned-banner {
        padding: 8px 14px;
    }

    /* ---- SYSTEM MESSAGES ---- */
    .system-message {
        width: 100%;
        text-align: center;
    }
    .system-message span {
        font-size: 11px;
        padding: 3px 10px;
    }

    /* ---- UPLOAD CONFIRM MODAL ---- */
    #uploadConfirmModal {
        align-items: flex-start;
        padding: max(10px, env(safe-area-inset-top, 0px)) 10px max(10px, env(safe-area-inset-bottom, 0px));
    }
    .upload-confirm-card {
        width: min(100%, 520px);
        max-width: calc(100vw - 20px);
        max-height: calc(100vh - 20px);
        max-height: calc(100dvh - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px) - 20px);
        padding: 16px;
    }
    .upload-confirm-card h3 {
        margin: 8px 0 12px;
        font-size: 20px;
    }
    .upload-confirm-dropzone {
        margin: 8px 0 12px;
        padding: 12px;
        border-radius: 14px;
    }
    .upload-confirm-list {
        max-height: 150px;
        margin-top: 10px;
    }
    .upload-confirm-actions {
        margin: 12px -16px -16px;
        padding: 12px 16px max(16px, env(safe-area-inset-bottom, 0px));
    }
    #uploadImagePreview {
        max-height: 34vh;
        max-height: 34dvh;
    }
    #uploadImagePreviewContainer {
        margin: 10px 0 !important;
    }
}
@media(max-width: 920px) {
    .admin-audit-filters {
        grid-template-columns: none;
    }
    
}
/* Landscape mobile: reduce top bar, allow more chat space */
@media (max-width: 768px) and (orientation: landscape) {
    .sidebar { height: 38px; }
    .nav-item { height: 38px; }
    .nav-item .material-symbols-outlined { font-size: 20px !important; }
    .main-content { height: calc(100vh - 38px); height: calc(100dvh - 38px); }
    #userMainArea { height: calc(100vh - 38px); height: calc(100dvh - 38px); }
}

.msg-deleted {
    font-style: italic;
    opacity: 0.7;
    user-select: none;
}

.msg-has-history {
    cursor: pointer;
    transition: opacity 0.2s;
}

.msg-has-history:hover {
    opacity: 0.85;
}

.history-item {
    padding: 10px;
    background: var(--surface-hover);
    border-radius: 8px;
    border: 1px solid var(--border);
}

.history-item-meta {
    font-size: 11px;
    color: var(--text-dim);
    margin-bottom: 4px;
}

.history-item-body {
    word-break: break-word;
    white-space: pre-wrap;
    font-size: 14px;
    color: var(--text-base);
}

/* --- Key Exchange Banner --- */
.key-exchange-banner {
    align-self: center;
    max-width: 92%;
    width: 520px;
    margin: 18px auto;
    padding: 22px 24px;
    border-radius: 16px;
    text-align: center;
    animation: key-banner-appear 0.4s ease;
}

@keyframes key-banner-appear {
    from { opacity: 0; transform: translateY(12px) scale(0.96); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

.key-exchange-banner.warning {
    background: rgba(255, 171, 0, 0.12);
    border: 1.5px solid rgba(255, 171, 0, 0.35);
}

.key-exchange-banner.success {
    background: rgba(28, 206, 94, 0.10);
    border: 1.5px solid rgba(28, 206, 94, 0.30);
}

.key-exchange-banner-icon {
    font-size: 38px;
    margin-bottom: 8px;
    display: block;
}

.key-exchange-banner.warning .key-exchange-banner-icon {
    color: #ffab00;
}

.key-exchange-banner.success .key-exchange-banner-icon {
    color: var(--accent);
}

.key-exchange-banner-title {
    font-size: 16px;
    font-weight: 700;
    margin-bottom: 6px;
    line-height: 1.35;
}

.key-exchange-banner.warning .key-exchange-banner-title {
    color: #ffab00;
}

.key-exchange-banner.success .key-exchange-banner-title {
    color: var(--accent);
}

.key-exchange-banner-text {
    font-size: 14px;
    color: var(--text-dim);
    line-height: 1.45;
    margin-bottom: 14px;
}

.key-exchange-banner.success .key-exchange-banner-text {
    margin-bottom: 0;
}

.key-exchange-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 11px 28px;
    border-radius: 12px;
    font-size: 15px;
    font-weight: 600;
    background: var(--accent);
    color: #fff;
    border: none;
    cursor: pointer;
    transition: background 0.2s, transform 0.1s;
}

.key-exchange-btn:hover {
    background: var(--accent-hover);
}

.key-exchange-btn:active {
    transform: scale(0.97);
}

.key-exchange-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

[data-theme="light"] .key-exchange-banner.warning {
    background: rgba(255, 171, 0, 0.10);
    border-color: rgba(255, 171, 0, 0.40);
}

[data-theme="light"] .key-exchange-banner.warning .key-exchange-banner-title {
    color: #b27500;
}

[data-theme="light"] .key-exchange-banner.success {
    background: rgba(28, 206, 94, 0.08);
    border-color: rgba(28, 206, 94, 0.35);
}

/* --- Scroll to Bottom FAB --- */
.scroll-to-bottom-fab {
    position: absolute;
    bottom: 90px;
    right: 20px;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: var(--surface);
    border: 1px solid var(--border);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    cursor: pointer;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 14px rgba(0, 0, 0, 0.25);
    color: var(--text);
    opacity: 0;
    transform: translateY(16px) scale(0.8);
    transition: opacity 0.25s ease, transform 0.25s ease, background 0.15s;
    pointer-events: none;
    pointer-events: none;
}

.scroll-to-bottom-fab::after {
    content: '';
    position: absolute;
    top: -2px;
    left: -2px;
    width: 12px;
    height: 12px;
    background: var(--danger);
    border: 2px solid var(--bg);
    border-radius: 50%;
    opacity: 0;
    transform: scale(0);
    transition: 0.2s;
    pointer-events: none;
}
.scroll-to-bottom-fab.has-unread::after {
    opacity: 1;
    transform: scale(1);
}

.scroll-to-bottom-fab.visible {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: auto;
}

.scroll-to-bottom-fab.replying {
    bottom: 170px;
}

.scroll-to-bottom-fab:hover {
    background: var(--surface-hover);
    border-color: var(--accent);
    color: var(--accent);
}

.scroll-to-bottom-fab .material-symbols-outlined {
    font-size: 26px !important;
}

/* Call PiP / UI Enhancements */
.call-minimize-btn {
    position: absolute;
    top: 24px;
    right: 24px;
    z-index: 10;
    padding: 6px;
}
.call-expand-btn {
    position: absolute;
    top: 14px;
    right: 14px;
    z-index: 10;
}
.call-overlay.call-minimized {
    inset: auto;
    bottom: 24px;
    right: 24px;
    padding: 0;
    width: 230px;
    max-width: calc(100vw - 24px);
    border-radius: 16px;
    box-shadow: 0 16px 40px rgba(0,0,0,0.3);
    background: transparent;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    transition: width 0.25s ease-out, border-radius 0.25s ease-out, right 0.22s cubic-bezier(0.4, 0, 0.2, 1), bottom 0.22s cubic-bezier(0.4, 0, 0.2, 1), left 0.22s cubic-bezier(0.4, 0, 0.2, 1), top 0.22s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.2s ease, transform 0.2s ease;
}
.call-overlay.call-minimized.is-dragging {
    transition: none !important;
    cursor: grabbing;
}
.call-overlay.call-minimized.is-dragging .call-card {
    pointer-events: none;
}
.call-minimized .call-card {
    width: 100%;
    border-radius: 16px;
    padding: 16px;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px;
    box-shadow: none;
    justify-content: center;
    text-align: center;
    flex-direction: column;
}
.call-minimized .call-avatar {
    width: 48px;
    height: 48px;
    margin: 0;
    font-size: 20px;
    margin: 0 auto;
    flex: 0 0 auto;
}
.call-minimized .call-badge,
.call-minimized #callStatusText,
.call-minimized .call-quality-panel,
.call-minimized .call-e2e-panel,
.call-minimized h2 {
    display: none !important;
}
.call-minimized .call-timer {
    margin: 0;
    font-size: 16px;
    flex-grow: 1;
    text-align: left;
    flex-grow: 0;
    text-align: 0 auto;
    margin: 0 auto;
}
.call-minimized .call-actions {
    margin-top: 0;
    gap: 12px;
    width: 100%;
    justify-content: space-evenly;
}
.call-minimized .call-control-btn {
    width: 44px;
    height: 44px;
}
.call-minimized .call-control-btn .material-symbols-outlined {
    font-size: 22px !important;
}

/* Speaking Animation */
.call-avatar.speaking {
    animation: speakPulse 1.2s infinite alternate ease-in-out;
}
@keyframes speakPulse {
    0% { box-shadow: 0 0 0 0 rgba(28, 206, 94, 0.4), 0 18px 40px rgba(28, 206, 94, 0.22); transform: scale(1); }
    100% { box-shadow: 0 0 0 18px rgba(28, 206, 94, 0), 0 18px 40px rgba(28, 206, 94, 0.3); transform: scale(1.06); }
}

/* E2E Emojis */
.call-e2e-panel {
    position: relative;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 0 auto 20px auto;
    width: fit-content;
    padding: 8px 18px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.08);
    transition: background 0.2s ease;
    cursor: default;
}
[data-theme="light"] .call-e2e-panel {
    background: rgba(15, 23, 41, 0.05);
}
.call-e2e-panel:hover {
    background: rgba(255, 255, 255, 0.12);
}
[data-theme="light"] .call-e2e-panel:hover {
    background: rgba(15, 23, 41, 0.08);
}
.e2e-lock {
    font-size: 16px !important;
    color: var(--text-dim);
}
.call-e2e-emojis {
    display: flex;
    gap: 8px;
    font-size: 28px;
    line-height: 1;
    letter-spacing: 2px;
}
.e2e-tooltip {
    position: absolute;
    top: calc(100% + 6px);
    left: 50%;
    transform: translateX(-50%);
    width: 280px;
    background: rgba(15, 23, 41, 0.95);
    color: #fff;
    padding: 12px 14px;
    border-radius: 12px;
    font-size: 13px;
    line-height: 1.45;
    box-shadow: 0 10px 24px rgba(0, 0, 0, 0.4);
    z-index: 100;
    text-align: left;
    white-space: normal;
    pointer-events: none;
    border: 1px solid rgba(255, 255, 255, 0.1);
}
[data-theme="light"] .e2e-tooltip {
    background: rgba(255, 255, 255, 0.98);
    color: #334155;
    border-color: rgba(0, 0, 0, 0.1);
}

/* Consecutive Message Streaks */
.msg-wrap.outgoing + .msg-wrap.outgoing .msg-sender,
.msg-wrap.incoming + .msg-wrap.incoming .msg-sender {
    display: none;
}
/* Within a streak (same sender + same minute + same date) — tight gap (~2px total) */
.msg-wrap.msg-in-streak {
    margin-top: -8px;
}
/* Between groups — larger gap (~12px total) */
.msg-wrap.outgoing + .msg-wrap.outgoing:not(.msg-in-streak),
.msg-wrap.incoming + .msg-wrap.incoming:not(.msg-in-streak) {
    margin-top: 2px;
}

/* Streak Metadata Hiding (Same Sender & Same Minute) */
.msg-streak-hide-meta .msg-time,
.msg-streak-hide-meta .msg-read-status,
.msg-streak-hide-meta .msg-status-separator {
    display: none;
}
.msg-streak-hide-meta .msg-meta {
    justify-content: flex-end;
    min-height: 0;
}
/* Ensure edited status remains visible even in streaks */
.msg-streak-hide-meta .msg-edited-status {
    display: inline-block;
}

/* Conference nav badge — red dot on "Видеосвязь" nav button */
.conf-nav-badge {
    position: absolute;
    top: 4px;
    right: 4px;
    width: 10px;
    height: 10px;
    background: #ff4757;
    border-radius: 50%;
    border: 2px solid var(--bg, #0f1729);
    opacity: 0;
    transform: scale(0);
    transition: opacity 0.2s ease, transform 0.2s ease;
    pointer-events: none;
    z-index: 5;
}
.nav-icon-badge-host > .conf-nav-badge {
    top: -4px;
    right: -5px;
}
.sidebar.collapsed .sidebar-nav .nav-item span.nav-icon-badge-host,
.nav-item span.nav-icon-badge-host {
    display: inline-flex !important;
}
.sidebar.collapsed .sidebar-nav .nav-item .nav-icon-badge-host > .conf-nav-badge.visible,
.nav-item .nav-icon-badge-host > .conf-nav-badge.visible {
    display: block !important;
}
.conf-nav-badge.visible {
    opacity: 1;
    transform: scale(1);
}
.admin-audit-field select {
    background-color: #212939;
}
[data-theme="light"] .admin-audit-field select {
    background-color: #f6f7f8;
}
.auth-card {
    border-radius: 22px;
}
