/* Import modern google fonts */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

/* Color Variables and Theme Settings */
:root {
    --accent: #4CAF93;
    --accent-hover: #3e937b;
    --accent-soft: #E4F3EE;
    --bg: #FFFFFF;
    --bg-soft: #F5F7F8;
    --bg-subtle: #F5F7F9;
    --border: #ECEFF1;
    --bubble-in: #F1F4F5;
    --bubble-me: #4CAF93;
    --bubble-me-text: #FFFFFF;
    --danger: #E5736B;
    --danger-hover: #d25f57;
    --divider: #EDF1F1;
    --surface: #FFFFFF;
    --text-primary: #1E2A2E;
    --text-secondary: #7A8A90;
    --text-tertiary: #A9B6BB;
    --section-bg: #EEF1EE;
    --font: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    
    --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.02);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.05);
    --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.08);
}

[data-theme="dark"] {
    --accent: #5FC5A6;
    --accent-hover: #4fb294;
    --accent-soft: #183D35;
    --bg: #0F1416;
    --bg-soft: #171D20;
    --bg-subtle: #1D2528;
    --border: #2A3337;
    --bubble-in: #1F292D;
    --bubble-me: #3FAF93;
    --bubble-me-text: #FFFFFF;
    --danger: #FF8A80;
    --danger-hover: #ff7368;
    --divider: #263034;
    --surface: #151B1E;
    --text-primary: #EAF1F2;
    --text-secondary: #B0BEC5;
    --text-tertiary: #7F8F96;
    --section-bg: #1A2225;
    
    --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.1);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.15);
    --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.2);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    outline: none;
    -webkit-font-smoothing: antialiased;
}

.hidden {
    display: none !important;
}

body, html {
    font-family: var(--font);
    background-color: var(--bg-soft);
    color: var(--text-primary);
    width: 100%;
    height: 100%;
    overflow: hidden;
    transition: background-color 0.3s, color 0.3s;
}

/* Scrollbar styles */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}
::-webkit-scrollbar-track {
    background: transparent;
}
::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
    background: var(--text-tertiary);
}

/* App Container */
#app-root {
    width: 100%;
    height: 100%;
    display: flex;
    position: relative;
}

/* Authentication Screen (Login / Register) */
.auth-container {
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    background: linear-gradient(135deg, var(--bg-soft) 0%, var(--bg-subtle) 100%);
    position: absolute;
    top: 0;
    left: 0;
    z-index: 100;
    transition: opacity 0.3s ease, visibility 0.3s;
}

.auth-container.hidden {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

.auth-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 40px;
    width: 400px;
    box-shadow: var(--shadow-lg);
    display: flex;
    flex-direction: column;
    align-items: center;
    animation: fadeIn 0.4s ease-out;
}

.auth-logo {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 68px;
    height: 68px;
    border-radius: 20px;
    background: var(--accent-soft);
    color: var(--accent);
    margin-bottom: 20px;
}

.auth-logo svg {
    width: 36px;
    height: 36px;
}

.auth-title {
    font-size: 24px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.auth-subtitle {
    font-size: 14px;
    color: var(--text-secondary);
    margin-bottom: 30px;
}

.auth-form {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

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

.input-group label {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.input-group input {
    background: var(--bg-soft);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 12px 16px;
    font-size: 14px;
    font-family: var(--font);
    color: var(--text-primary);
    transition: border-color 0.2s, background-color 0.2s;
}

.input-group input:focus {
    border-color: var(--accent);
    background: var(--surface);
}

.auth-button {
    background: var(--accent);
    color: var(--bubble-me-text);
    border: none;
    border-radius: 12px;
    padding: 14px;
    font-size: 15px;
    font-weight: 600;
    font-family: var(--font);
    cursor: pointer;
    margin-top: 10px;
    transition: background-color 0.2s, transform 0.1s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.auth-button:hover {
    background: var(--accent-hover);
}

.auth-button:active {
    transform: scale(0.98);
}

.auth-switch {
    margin-top: 24px;
    font-size: 13px;
    color: var(--text-secondary);
}

.auth-switch span {
    color: var(--accent);
    font-weight: 600;
    cursor: pointer;
    margin-left: 4px;
}

.auth-switch span:hover {
    text-decoration: underline;
}

/* Dashboard Shell */
.dashboard-container {
    width: 100%;
    height: 100%;
    display: flex;
    opacity: 1;
    transition: opacity 0.3s ease;
}

.dashboard-container.hidden {
    opacity: 0;
    pointer-events: none;
}

/* Sidebar Column */
.sidebar {
    width: 68px;
    height: 100%;
    background-color: var(--bg-soft);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 24px 0;
    justify-content: space-between;
    flex-shrink: 0;
    z-index: 10;
}

.sidebar-top {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 28px;
    width: 100%;
}

.user-profile-btn {
    position: relative;
    cursor: pointer;
    transition: transform 0.2s;
}

.user-profile-btn:hover {
    transform: scale(1.05);
}

.avatar {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    color: #FFFFFF;
    font-size: 16px;
    user-select: none;
    position: relative;
    background-size: cover;
    background-position: center;
}

.avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: inherit;
}

.row-order-controls {
    display: flex;
    flex-direction: column;
    gap: 2px;
    margin-left: 6px;
}

.row-order-controls button {
    width: 20px;
    height: 18px;
    border: 0;
    background: transparent;
    color: var(--text-tertiary);
    cursor: pointer;
    font-size: 9px;
}

.row-order-controls button:hover {
    color: var(--accent);
}

.status-dot {
    position: absolute;
    bottom: -1px;
    right: -1px;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background-color: var(--accent);
    border: 2px solid var(--bg-soft);
}

.status-dot.offline {
    background-color: var(--text-tertiary);
}

.nav-links {
    display: flex;
    flex-direction: column;
    gap: 16px;
    width: 100%;
    align-items: center;
}

.nav-item {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
}

.nav-item svg {
    width: 20px;
    height: 20px;
    stroke-width: 2px;
}

.nav-item:hover {
    color: var(--accent);
    background-color: var(--accent-soft);
}

.nav-item.active {
    color: var(--accent);
    background-color: var(--accent-soft);
}

.nav-badge {
    position: absolute;
    top: 2px;
    right: 2px;
    background-color: var(--danger);
    color: white;
    font-size: 10px;
    font-weight: 700;
    padding: 2px 5px;
    border-radius: 10px;
    min-width: 16px;
    text-align: center;
    border: 1px solid var(--bg-soft);
}

.sidebar-bottom {
    display: flex;
    flex-direction: column;
    gap: 16px;
    width: 100%;
    align-items: center;
}

/* Middle Column (List Pane) */
.list-pane {
    width: 280px;
    height: 100%;
    background-color: var(--bg);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
}

.list-header {
    padding: 16px 20px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.list-title-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.list-title {
    font-size: 20px;
    font-weight: 700;
    color: var(--text-primary);
}

.list-actions {
    display: flex;
    gap: 10px;
}

.action-icon {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s;
}

.action-icon svg {
    width: 18px;
    height: 18px;
}

.action-icon:hover {
    background-color: var(--bg-soft);
    color: var(--text-primary);
}

.action-icon.active {
    color: var(--accent);
    background-color: var(--accent-soft);
}

.search-bar-container {
    display: flex;
    align-items: center;
    background-color: var(--bg-soft);
    border-radius: 10px;
    padding: 8px 12px;
    gap: 8px;
    border: 1px solid transparent;
    transition: border-color 0.2s;
}

.search-bar-container:focus-within {
    border-color: var(--accent);
    background-color: var(--surface);
}

.search-bar-container svg {
    width: 16px;
    height: 16px;
    color: var(--text-tertiary);
}

.search-bar-container input {
    background: transparent;
    border: none;
    font-size: 13px;
    color: var(--text-primary);
    width: 100%;
}

.search-bar-container input::placeholder {
    color: var(--text-tertiary);
}

/* Sorting Control Row */
.sort-mode-control {
    margin: 0 20px 10px 20px;
    background: var(--bg-soft);
    border-radius: 8px;
    padding: 3px;
    display: flex;
    border: 1px solid var(--border);
}

.sort-tab {
    flex: 1;
    text-align: center;
    padding: 6px 0;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
}

.sort-tab.active {
    background-color: var(--accent);
    color: white;
}

/* Scrollable Item List */
.list-content {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

.list-item {
    display: flex;
    align-items: center;
    padding: 12px 20px;
    gap: 12px;
    cursor: pointer;
    transition: background-color 0.2s;
    user-select: none;
    border-bottom: 1px solid transparent;
}

.list-item:hover {
    background-color: var(--bg-soft);
}

.list-item.active {
    background-color: var(--accent-soft);
}

.list-item.pinned {
    background-color: var(--bg-subtle);
}
.list-item.pinned.active {
    background-color: var(--accent-soft);
}

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

.list-item-header {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 8px;
}

.list-item-name {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.list-item-time {
    font-size: 11px;
    color: var(--text-secondary);
    white-space: nowrap;
}

.list-item-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.list-item-preview {
    font-size: 12px;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.list-item-badge {
    background-color: var(--accent);
    color: white;
    font-size: 10px;
    font-weight: 700;
    height: 18px;
    min-width: 18px;
    padding: 0 4px;
    border-radius: 9px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.section-header {
    padding: 6px 20px;
    background-color: var(--bg-soft);
    color: var(--text-secondary);
    font-size: 11px;
    font-weight: 700;
    border-top: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
    letter-spacing: 0.5px;
}

.section-header:first-of-type {
    border-top: none;
}

.state-message {
    padding: 40px 20px;
    text-align: center;
    color: var(--text-secondary);
    font-size: 13px;
}

/* Right Column (Content Pane) */
.content-pane {
    flex: 1;
    height: 100%;
    background-color: var(--bg-subtle);
    display: flex;
    flex-direction: column;
    position: relative;
}

/* Empty State */
.empty-state {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 16px;
    color: var(--text-secondary);
    padding: 40px;
}

.empty-state svg {
    width: 96px;
    height: 96px;
    color: var(--border);
    stroke-width: 1px;
    animation: float 4s ease-in-out infinite;
}

.empty-state h3 {
    color: var(--text-primary);
    font-size: 18px;
    font-weight: 600;
}

.empty-state p {
    font-size: 14px;
    max-width: 320px;
    text-align: center;
}

/* Chat Panel */
.chat-panel {
    display: flex;
    flex-direction: column;
    height: 100%;
    width: 100%;
    background: var(--bg);
}

.chat-header {
    height: 64px;
    border-bottom: 1px solid var(--border);
    padding: 0 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    background-color: var(--bg);
    flex-shrink: 0;
}

.chat-info {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
}

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

.chat-name {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-status {
    font-size: 11px;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 4px;
}

.chat-status.online::before {
    content: '';
    display: inline-block;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background-color: var(--accent);
}

.chat-header-actions {
    display: flex;
    gap: 12px;
}

.typing-indicator-text {
    font-style: italic;
    color: var(--accent);
    font-size: 11px;
}

/* Messages Scroller */
.messages-scroller {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    background-color: var(--bg-subtle);
}

.message-row {
    display: flex;
    gap: 12px;
    max-width: 75%;
    width: fit-content;
}

.message-row.me {
    margin-left: auto;
    flex-direction: row-reverse;
}

.message-bubble {
    padding: 10px 14px;
    border-radius: 16px;
    font-size: 14px;
    line-height: 1.5;
    position: relative;
    word-break: break-all;
    box-shadow: var(--shadow-sm);
}

.message-row.them .message-bubble {
    background-color: var(--bubble-in);
    color: var(--text-primary);
    border-top-left-radius: 4px;
}

.message-row.me .message-bubble {
    background-color: var(--bubble-me);
    color: var(--bubble-me-text);
    border-top-right-radius: 4px;
}

.message-sender {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 4px;
    display: block;
}

.message-time {
    font-size: 10px;
    color: var(--text-tertiary);
    margin-top: 4px;
    text-align: right;
    display: block;
}

.message-row.me .message-time {
    color: rgba(255, 255, 255, 0.7);
}

.message-row > .avatar {
    width: 34px;
    height: 34px;
    font-size: 13px;
}

.message-bubble audio {
    display: block;
    width: 235px;
    max-width: 100%;
}

.message-system {
    align-self: center;
    background-color: rgba(0, 0, 0, 0.05);
    color: var(--text-secondary);
    font-size: 11px;
    padding: 4px 10px;
    border-radius: 12px;
    margin: 8px 0;
    max-width: 80%;
    text-align: center;
    user-select: none;
}

[data-theme="dark"] .message-system {
    background-color: rgba(255, 255, 255, 0.05);
}

/* Image Message */
.message-image-button {
    display: block;
    padding: 0;
    border: none;
    background: transparent;
    cursor: pointer;
}

.message-image {
    max-width: 240px;
    max-height: 240px;
    border-radius: 12px;
    cursor: pointer;
    overflow: hidden;
    display: block;
}

.message-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.image-viewer-overlay {
    position: absolute;
    inset: 0;
    z-index: 1800;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 64px 32px 32px;
    background: rgba(8, 10, 14, 0.94);
    touch-action: pan-y;
}

.image-viewer-overlay.hidden {
    display: none;
}

.image-viewer-overlay > img {
    display: block;
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    user-select: none;
    touch-action: pan-y;
    cursor: grab;
}

.image-viewer-overlay > img:active {
    cursor: grabbing;
}

.image-viewer-toolbar {
    position: absolute;
    top: 16px;
    right: 16px;
    display: flex;
    gap: 8px;
}

.image-viewer-toolbar button {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    border: 1px solid rgba(255, 255, 255, 0.22);
    border-radius: 6px;
    color: #fff;
    background: rgba(255, 255, 255, 0.1);
    cursor: pointer;
}

.image-viewer-toolbar button:hover {
    background: rgba(255, 255, 255, 0.2);
}

.image-viewer-toolbar svg {
    width: 20px;
    height: 20px;
}

.image-viewer-nav {
    position: absolute;
    top: 50%;
    z-index: 1;
    width: 46px;
    height: 46px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    border: 1px solid rgba(255, 255, 255, 0.22);
    border-radius: 50%;
    color: #fff;
    background: rgba(255, 255, 255, 0.12);
    transform: translateY(-50%);
    cursor: pointer;
}

.image-viewer-nav:hover:not(:disabled) {
    background: rgba(255, 255, 255, 0.24);
}

.image-viewer-nav:disabled {
    opacity: 0.22;
    cursor: default;
}

.image-viewer-nav svg {
    width: 26px;
    height: 26px;
}

.image-viewer-prev { left: 18px; }
.image-viewer-next { right: 18px; }

.image-viewer-counter {
    position: absolute;
    bottom: 18px;
    left: 50%;
    min-width: 64px;
    padding: 6px 12px;
    border-radius: 16px;
    color: #fff;
    background: rgba(0, 0, 0, 0.48);
    text-align: center;
    transform: translateX(-50%);
    pointer-events: none;
}

/* File Message */
.message-file-card {
    display: flex;
    align-items: center;
    gap: 12px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 12px;
    width: 240px;
    color: var(--text-primary);
}

.file-icon {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    background: var(--accent-soft);
    color: var(--accent);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.file-info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

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

.file-size {
    font-size: 11px;
    color: var(--text-secondary);
}

.file-download-btn {
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.file-download-btn:hover {
    color: var(--accent);
}

.file-download-btn svg {
    width: 18px;
    height: 18px;
}

/* Voice Message */
.message-voice-bubble {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    min-width: 100px;
}

.voice-wave {
    display: flex;
    align-items: center;
    gap: 2px;
    flex: 1;
}

.voice-bar {
    width: 3px;
    height: 14px;
    background-color: var(--text-secondary);
    border-radius: 2px;
}

.message-row.me .voice-bar {
    background-color: rgba(255, 255, 255, 0.7);
}

.voice-duration {
    font-size: 12px;
    font-weight: 500;
}

/* Chat Input Bar */
.chat-input-area {
    background: var(--bg);
    border-top: 1px solid var(--border);
    padding: 12px 24px 20px 24px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    flex-shrink: 0;
    position: relative;
}

.input-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.toolbar-left {
    display: flex;
    gap: 12px;
}

.toolbar-btn {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s;
    position: relative;
}

.toolbar-btn svg {
    width: 18px;
    height: 18px;
}

.toolbar-btn:hover {
    background: var(--bg-soft);
    color: var(--text-primary);
}

.toolbar-btn.active {
    color: var(--accent);
    background-color: var(--accent-soft);
}

/* Textarea styling */
.pasted-image-preview {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    min-height: 76px;
    margin-bottom: 8px;
    padding: 8px 10px;
    background: var(--bg-soft);
    border: 1px solid var(--border);
    border-radius: 8px;
}

.pasted-image-preview.hidden {
    display: none;
}

.pasted-image-preview img {
    width: 60px;
    height: 60px;
    display: block;
    object-fit: cover;
    border-radius: 6px;
    background: var(--surface);
}

.pasted-image-preview button {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    border: none;
    border-radius: 6px;
    color: var(--text-secondary);
    background: var(--surface);
    cursor: pointer;
}

.pasted-image-preview button:hover {
    color: var(--danger);
    background: var(--border);
}

.pasted-image-preview button svg {
    width: 18px;
    height: 18px;
}

.input-field-wrapper {
    display: flex;
    align-items: flex-end;
    background: var(--bg-soft);
    border-radius: 14px;
    padding: 8px 12px;
    gap: 8px;
    border: 1px solid transparent;
    transition: border-color 0.2s, background-color 0.2s;
}

.input-field-wrapper:focus-within {
    border-color: var(--accent);
    background: var(--surface);
}

.input-field-wrapper textarea {
    flex: 1;
    background: transparent;
    border: none;
    resize: none;
    font-family: var(--font);
    font-size: 14px;
    color: var(--text-primary);
    height: 24px;
    min-height: 24px;
    max-height: 104px;
    line-height: 20px;
    overflow-y: hidden;
    padding: 2px 0;
}

.input-field-wrapper textarea::placeholder {
    color: var(--text-tertiary);
}

.send-button {
    background: var(--accent);
    color: white;
    border: none;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background-color 0.2s, transform 0.1s;
}

.send-button:hover {
    background: var(--accent-hover);
}

.send-button:active {
    transform: scale(0.95);
}

.send-button svg {
    width: 16px;
    height: 16px;
}

/* Voice Recorder Panel */
.voice-recorder-panel {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--accent-soft);
    border: 1px solid var(--accent);
    border-radius: 12px;
    padding: 12px 20px;
    margin-top: 8px;
    animation: slideUp 0.2s ease-out;
}

.recorder-status {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    font-weight: 600;
    color: var(--accent);
}

.recorder-blink {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: var(--danger);
    animation: pulse 1s infinite alternate;
}

.recorder-wave-preview {
    display: flex;
    align-items: center;
    gap: 3px;
    height: 24px;
}

.recorder-wave-bar {
    width: 3px;
    height: 10px;
    background: var(--accent);
    border-radius: 2px;
    animation: soundWave 0.8s infinite alternate ease-in-out;
}

.recorder-actions {
    display: flex;
    gap: 12px;
}

.recorder-btn {
    padding: 6px 12px;
    border-radius: 8px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    border: none;
    font-family: var(--font);
}

.recorder-btn.cancel {
    background: transparent;
    color: var(--text-secondary);
}

.recorder-btn.send {
    background: var(--accent);
    color: white;
}

/* Uploading Progress Overlay */
.upload-progress-overlay {
    position: absolute;
    left: 24px;
    right: 24px;
    bottom: 74px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    box-shadow: var(--shadow-md);
    z-index: 5;
}

.progress-header {
    display: flex;
    justify-content: space-between;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
}

.progress-bar-container {
    height: 6px;
    background: var(--bg-soft);
    border-radius: 3px;
    overflow: hidden;
}

.progress-bar-fill {
    height: 100%;
    background: var(--accent);
    width: 0%;
    transition: width 0.1s;
}

/* Emoji Picker Dropdown */
.emoji-picker-panel {
    position: absolute;
    bottom: 84px;
    left: 24px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 16px;
    width: 300px;
    height: 240px;
    box-shadow: var(--shadow-lg);
    display: flex;
    flex-direction: column;
    z-index: 100;
    overflow: hidden;
    animation: fadeIn 0.2s ease;
}

.emoji-picker-header {
    padding: 10px 14px;
    border-bottom: 1px solid var(--border);
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
}

.emoji-grid {
    flex: 1;
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 6px;
    padding: 10px;
    overflow-y: auto;
}

.emoji-item {
    font-size: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    border-radius: 6px;
    padding: 4px;
    transition: transform 0.1s, background-color 0.1s;
}

.emoji-item:hover {
    background-color: var(--bg-soft);
    transform: scale(1.15);
}

/* Detail Panels (Contacts detail / Group Detail / Settings Panels) */
.detail-panel {
    flex: 1;
    height: 100%;
    display: flex;
    flex-direction: column;
    background-color: var(--bg);
}

.detail-header {
    height: 64px;
    border-bottom: 1px solid var(--border);
    padding: 0 24px;
    display: flex;
    align-items: center;
    font-size: 16px;
    font-weight: 600;
    background-color: var(--bg);
}

.detail-body {
    flex: 1;
    overflow-y: auto;
    padding: 40px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 30px;
}

/* Profile Card Detail */
.profile-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    width: 100%;
    max-width: 440px;
}

.profile-card .avatar {
    width: 96px;
    height: 96px;
    font-size: 32px;
}

.profile-title {
    font-size: 22px;
    font-weight: 700;
    color: var(--text-primary);
}

.profile-signature {
    font-size: 14px;
    color: var(--text-secondary);
    text-align: center;
    line-height: 1.4;
}

.info-rows {
    width: 100%;
    background: var(--bg-soft);
    border-radius: 16px;
    border: 1px solid var(--border);
    padding: 8px 16px;
}

.info-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 0;
    border-bottom: 1px solid var(--border);
    font-size: 14px;
}

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

.info-label {
    color: var(--text-secondary);
}

.info-val {
    color: var(--text-primary);
    font-weight: 500;
}

.profile-actions {
    display: flex;
    flex-direction: column;
    gap: 12px;
    width: 100%;
    max-width: 440px;
}

.btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    border: none;
    border-radius: 12px;
    padding: 14px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.2s, transform 0.1s;
    font-family: var(--font);
}

.btn:active {
    transform: scale(0.98);
}

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

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

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

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

.btn-outline {
    background-color: transparent;
    border: 1px solid var(--border);
    color: var(--text-primary);
}

.btn-outline:hover {
    background-color: var(--bg-soft);
}

/* Group Management details */
.group-members-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 16px;
    width: 100%;
    max-width: 440px;
}

.grid-member {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    cursor: pointer;
}

.grid-member-name {
    font-size: 12px;
    color: var(--text-secondary);
    text-align: center;
    width: 100%;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.grid-action-btn {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    border: 2px dashed var(--text-tertiary);
    color: var(--text-tertiary);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.grid-action-btn:hover {
    border-color: var(--accent);
    color: var(--accent);
    background-color: var(--accent-soft);
}

/* Form Settings Group */
.settings-form {
    width: 100%;
    max-width: 480px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.form-group label {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
}

.form-group input, .form-group select, .form-group textarea {
    background: var(--bg-soft);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 10px 14px;
    font-size: 14px;
    color: var(--text-primary);
    font-family: var(--font);
    width: 100%;
    transition: border-color 0.2s, background-color 0.2s;
}

.form-group input:focus, .form-group select:focus, .form-group textarea:focus {
    border-color: var(--accent);
    background: var(--surface);
}

.toggle-setting {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 0;
    border-bottom: 1px solid var(--border);
}

.toggle-setting-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.toggle-setting-title {
    font-size: 14px;
    font-weight: 600;
}

.toggle-setting-desc {
    font-size: 12px;
    color: var(--text-secondary);
}

/* Swither toggle slider */
.switch-slider {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
    cursor: pointer;
}

.switch-slider input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider-round {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: var(--border);
    transition: .3s;
    border-radius: 34px;
}

.slider-round:before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: .3s;
    border-radius: 50%;
}

.switch-slider input:checked + .slider-round {
    background-color: var(--accent);
}

.switch-slider input:checked + .slider-round:before {
    transform: translateX(20px);
}

/* Call Simulator Screen */
.call-simulator-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(15, 20, 22, 0.95);
    backdrop-filter: blur(12px);
    z-index: 1000;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: space-between;
    padding: 60px 40px;
    color: #FFFFFF;
    transition: opacity 0.3s ease, visibility 0.3s;
    animation: fadeIn 0.3s;
}

.call-simulator-overlay.hidden {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

.call-profile-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
    margin-top: 40px;
}

.call-avatar-wrapper {
    position: relative;
}

.call-avatar {
    width: 120px;
    height: 120px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 40px;
    font-weight: 700;
    color: white;
    user-select: none;
    box-shadow: 0 0 40px rgba(0, 0, 0, 0.3);
}

.call-avatar-wrapper.ringing::before {
    content: '';
    position: absolute;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    background: var(--accent);
    opacity: 0.4;
    animation: ringPulse 2s infinite;
    z-index: -1;
}

.call-name {
    font-size: 24px;
    font-weight: 700;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.call-status-text {
    font-size: 15px;
    color: rgba(255, 255, 255, 0.7);
    margin-top: 6px;
    font-weight: 500;
}

/* Video grid */
.call-video-grid {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -2;
    display: grid;
    grid-template-columns: 1fr;
    grid-template-rows: 1fr;
    background: #000;
}

.local-video-preview {
    position: absolute;
    top: 24px;
    right: 24px;
    width: 120px;
    height: 180px;
    background: #2a3337;
    border: 2px solid white;
    box-shadow: var(--shadow-lg);
    z-index: 10;
    overflow: hidden;
}

.local-video-preview img, .call-video-grid img,
.local-video-preview video, .call-video-grid video {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.call-video-grid > video {
    grid-column: 1;
    grid-row: 1;
}

.call-control-dock {
    display: flex;
    flex-direction: column;
    gap: 30px;
    align-items: center;
    width: 100%;
    max-width: 400px;
}

.dial-buttons {
    display: flex;
    gap: 32px;
}

.incoming-buttons {
    display: flex;
    gap: 60px;
}

.circle-btn {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    border: none;
    color: white;
    transition: all 0.2s;
}

.circle-btn:active {
    transform: scale(0.9);
}

.circle-btn svg {
    width: 24px;
    height: 24px;
}

.circle-btn .mute-slash {
    display: none;
}

.circle-btn.muted .mute-slash {
    display: block;
}

.circle-btn.hangup {
    background-color: var(--danger);
}
.circle-btn.hangup:hover {
    background-color: var(--danger-hover);
    box-shadow: 0 0 20px rgba(229, 115, 107, 0.4);
}

.circle-btn.accept {
    background-color: var(--accent);
}
.circle-btn.accept:hover {
    background-color: var(--accent-hover);
    box-shadow: 0 0 20px rgba(76, 175, 147, 0.4);
}

.circle-btn.toggle {
    background-color: rgba(255, 255, 255, 0.15);
    border: 1px solid rgba(255, 255, 255, 0.1);
}
.circle-btn.toggle:hover {
    background-color: rgba(255, 255, 255, 0.25);
}

.circle-btn.toggle.muted {
    background-color: #ef4444;
    border: 2px solid #ffb4ae;
    box-shadow: 0 0 0 4px rgba(239, 68, 68, 0.22), 0 0 22px rgba(239, 68, 68, 0.55);
}

.circle-btn.toggle.muted:hover {
    background-color: #dc2626;
}

.circle-btn.toggle.muted + span {
    color: #ffb4ae;
    font-weight: 700;
}

.circle-btn.audio-output.earpiece {
    background-color: var(--accent);
    border-color: rgba(255, 255, 255, 0.55);
}

.circle-btn.audio-output .audio-output-earpiece {
    display: none;
}

.circle-btn.audio-output.earpiece .audio-output-speaker {
    display: none;
}

.circle-btn.audio-output.earpiece .audio-output-earpiece {
    display: block;
}

.circle-btn-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    font-size: 11px;
    color: rgba(255, 255, 255, 0.7);
}

#call-audio-remote {
    position: absolute;
    width: 1px;
    height: 1px;
    opacity: 0;
    pointer-events: none;
}

/* Modals / Dialogs */
.dialog-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(4px);
    z-index: 500;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: opacity 0.3s ease, visibility 0.3s;
}

.dialog-overlay.hidden {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

.dialog-box {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 16px;
    width: 380px;
    padding: 24px;
    box-shadow: var(--shadow-lg);
    animation: scaleIn 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.dialog-title {
    font-size: 16px;
    font-weight: 700;
    color: var(--text-primary);
}

.dialog-text {
    font-size: 14px;
    color: var(--text-secondary);
    line-height: 1.5;
}

.dialog-actions {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
}

.modal-form {
    display: flex;
    flex-direction: column;
    gap: 14px;
    max-height: 420px;
    overflow-y: auto;
}

.modal-form input,
.modal-form select,
.modal-form textarea {
    width: 100%;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--bg-soft);
    color: var(--text-primary);
    padding: 10px 12px;
    font: inherit;
}

.modal-member-list {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
}

.member-option {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px;
    border: 1px solid var(--border);
    border-radius: 8px;
}

.context-menu {
    position: fixed;
    z-index: 2000;
    width: 164px;
    padding: 6px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    box-shadow: var(--shadow-lg);
}

.context-menu button {
    width: 100%;
    border: 0;
    border-radius: 6px;
    background: transparent;
    color: var(--text-primary);
    text-align: left;
    padding: 9px 10px;
    cursor: pointer;
}

.context-menu button:hover {
    background: var(--bg-soft);
}

.context-menu button.danger {
    color: var(--danger);
}

#toast-root {
    position: fixed;
    right: 24px;
    top: 20px;
    z-index: 3000;
    display: flex;
    flex-direction: column;
    gap: 8px;
    pointer-events: none;
}

.toast {
    max-width: 360px;
    padding: 10px 14px;
    border-radius: 8px;
    background: rgba(28, 34, 36, 0.94);
    color: #fff;
    box-shadow: var(--shadow-md);
    font-size: 13px;
    animation: fadeIn 0.2s ease;
}

.custom-detail-body {
    align-items: stretch;
    max-width: 680px;
    width: 100%;
    margin: 0 auto;
}

.request-card {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    padding: 14px;
    border-bottom: 1px solid var(--border);
}

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

.request-main span,
.favorite-source {
    color: var(--text-secondary);
    font-size: 12px;
}

.request-card .btn {
    width: auto;
    padding: 8px 12px;
}

.favorite-card {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 16px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface);
}

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

.favorite-meta span {
    color: var(--text-tertiary);
    font-size: 11px;
}

.favorite-media {
    max-width: 100%;
    max-height: 320px;
    object-fit: contain;
    border-radius: 6px;
    background: #111;
}

.desktop-qr-card {
    width: 100%;
    max-width: 420px;
    margin: auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    text-align: center;
}

.desktop-qr-card img {
    width: 320px;
    height: 320px;
    max-width: 100%;
    aspect-ratio: 1;
    object-fit: contain;
    border: 10px solid #fff;
    border-radius: 6px;
}

.desktop-qr-card span,
.qr-scanner-stage p {
    color: var(--text-secondary);
    font-size: 13px;
}

.qr-scanner-stage {
    position: relative;
    width: min(100%, 620px);
    margin: auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
}

.qr-scanner-stage video {
    width: 100%;
    aspect-ratio: 16 / 10;
    object-fit: cover;
    border-radius: 8px;
    background: #111;
}

.qr-scan-frame {
    position: absolute;
    top: 12%;
    width: min(45%, 230px);
    aspect-ratio: 1;
    border: 3px solid var(--accent);
    border-radius: 6px;
    box-shadow: 0 0 0 999px rgba(0, 0, 0, 0.28);
    pointer-events: none;
}

/* Message Search Dialog Scroll List */
.search-results-list {
    max-height: 200px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    border: 1px solid var(--border);
    border-radius: 8px;
}

.search-result-row {
    padding: 10px 14px;
    border-bottom: 1px solid var(--border);
    cursor: pointer;
    font-size: 13px;
    transition: background-color 0.1s;
}

.search-result-row:last-child {
    border-bottom: none;
}

.search-result-row:hover {
    background-color: var(--bg-soft);
}

.search-result-meta {
    display: flex;
    justify-content: space-between;
    color: var(--text-secondary);
    font-size: 11px;
    margin-bottom: 4px;
}

.search-result-content {
    color: var(--text-primary);
    word-break: break-all;
}

/* QR Code Display Card */
.qr-card-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    padding: 12px 0;
}

.qr-box-mockup {
    width: 180px;
    height: 180px;
    background: #FFFFFF;
    border: 8px solid #FFFFFF;
    box-shadow: var(--shadow-md);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
}

.qr-box-mockup svg {
    width: 100%;
    height: 100%;
    color: #1e2a2e;
}

.qr-scanner-line {
    position: absolute;
    width: 100%;
    height: 2px;
    background: var(--accent);
    top: 0;
    box-shadow: 0 0 8px var(--accent);
    animation: scanAnimation 2s infinite linear;
}

/* Animations */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes scaleIn {
    from { transform: scale(0.95); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

@keyframes slideUp {
    from { transform: translateY(12px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

@keyframes float {
    0% { transform: translateY(0px); }
    50% { transform: translateY(-8px); }
    100% { transform: translateY(0px); }
}

@keyframes ringPulse {
    0% { transform: scale(1); opacity: 0.4; }
    100% { transform: scale(1.6); opacity: 0; }
}

@keyframes pulse {
    from { opacity: 0.3; }
    to { opacity: 1; }
}

@keyframes soundWave {
    from { height: 4px; }
    to { height: 20px; }
}

@keyframes scanAnimation {
    0% { top: 0%; }
    50% { top: 100%; }
    100% { top: 0%; }
}

.mobile-back-button {
    display: none;
    width: 36px;
    height: 36px;
    flex: 0 0 36px;
    align-items: center;
    justify-content: center;
    border: 0;
    border-radius: 6px;
    color: var(--text-primary);
    background: transparent;
    cursor: pointer;
}

.mobile-back-button svg {
    width: 22px;
    height: 22px;
}

.detail-header-leading {
    display: flex;
    align-items: center;
}

.web-desktop-only {
    display: none !important;
}

@media (max-width: 760px) {
    body,
    html,
    #app-root {
        height: 100%;
        height: 100dvh;
        min-width: 0;
    }

    .auth-container {
        align-items: stretch;
        background: var(--bg);
    }

    .auth-card {
        width: 100%;
        max-width: none;
        justify-content: center;
        padding: 32px 24px max(32px, env(safe-area-inset-bottom));
        border: 0;
        border-radius: 0;
        box-shadow: none;
    }

    .dashboard-container {
        position: relative;
        min-width: 0;
        padding-bottom: calc(64px + env(safe-area-inset-bottom));
    }

    .sidebar {
        position: absolute;
        z-index: 50;
        left: 0;
        right: 0;
        bottom: 0;
        width: 100%;
        height: calc(64px + env(safe-area-inset-bottom));
        padding: 0 8px env(safe-area-inset-bottom);
        border-top: 1px solid var(--border);
        border-right: 0;
        flex-direction: row;
        background: var(--surface);
    }

    .sidebar-top,
    .sidebar-bottom,
    .nav-links {
        display: contents;
    }

    .user-profile-btn,
    #sidebar-theme-toggle,
    #sidebar-logout-btn {
        display: none;
    }

    .nav-item,
    #sidebar-settings-btn {
        width: 20%;
        height: 56px;
        min-width: 0;
        flex-direction: column;
        gap: 3px;
        border-radius: 4px;
        font-size: 10px;
    }

    .nav-item[data-tab]::after,
    #sidebar-settings-btn::after {
        line-height: 1;
        color: currentColor;
    }

    .nav-item[data-tab="chats"]::after { content: "聊天"; }
    .nav-item[data-tab="contacts"]::after { content: "联系人"; }
    .nav-item[data-tab="groups"]::after { content: "群组"; }
    .nav-item[data-tab="favorites"]::after { content: "收藏"; }
    #sidebar-settings-btn::after { content: "我的"; }

    .nav-badge {
        top: 2px;
        right: calc(50% - 22px);
    }

    .list-pane {
        width: 100%;
        min-width: 0;
        border-right: 0;
    }

    .list-header {
        padding: calc(14px + env(safe-area-inset-top)) 16px 12px;
    }

    .list-title {
        font-size: 22px;
    }

    .list-item {
        min-height: 68px;
        padding: 11px 16px;
    }

    .content-pane {
        display: none;
        width: 100%;
        min-width: 0;
        height: 100%;
    }

    .dashboard-container.mobile-detail-open {
        padding-bottom: 0;
    }

    .dashboard-container.mobile-detail-open .sidebar,
    .dashboard-container.mobile-detail-open .list-pane {
        display: none;
    }

    .dashboard-container.mobile-detail-open .content-pane {
        display: flex;
    }

    .mobile-back-button {
        display: inline-flex;
    }

    .chat-header,
    .detail-header {
        min-height: calc(58px + env(safe-area-inset-top));
        height: auto;
        padding: env(safe-area-inset-top) 10px 0;
        gap: 6px;
    }

    .chat-header .chat-info {
        flex: 1;
    }

    .chat-header .avatar {
        width: 36px;
        height: 36px;
        font-size: 14px;
    }

    .chat-header-actions {
        gap: 0;
    }

    .chat-header-actions .action-icon {
        width: 34px;
        height: 34px;
    }

    #chat-action-search-message,
    #chat-action-clear {
        display: none !important;
    }

    .messages-scroller {
        padding: 16px 12px;
    }

    .message-row {
        max-width: 94%;
    }

    .message-image,
    .message-file-card {
        max-width: min(240px, 66vw);
    }

    .chat-input-area {
        padding: 8px 10px max(10px, env(safe-area-inset-bottom));
    }

    .toolbar-left {
        width: 100%;
        justify-content: space-around;
    }

    .input-field-wrapper textarea {
        font-size: 16px;
    }

    .emoji-picker-panel {
        left: 0;
        width: min(320px, calc(100vw - 20px));
    }

    .detail-body {
        padding: 24px 16px max(24px, env(safe-area-inset-bottom));
        gap: 22px;
    }

    .dialog-overlay {
        padding: 16px;
    }

    .dialog-box,
    #dialog-search-msg-overlay .dialog-box {
        width: 100% !important;
        max-width: 420px;
        max-height: calc(100dvh - 32px);
        overflow-y: auto;
        padding: 20px;
        border-radius: 8px;
    }

    .call-simulator-overlay {
        min-height: 100dvh;
        padding: calc(36px + env(safe-area-inset-top)) 18px calc(28px + env(safe-area-inset-bottom));
    }

    .call-control-dock {
        max-width: 100%;
    }

    .circle-btn-container {
        min-width: 68px;
    }

    .image-viewer-overlay {
        position: fixed;
        padding: 64px 10px 16px;
    }

    .image-viewer-nav {
        width: 38px;
        height: 38px;
    }

    .image-viewer-nav svg {
        width: 22px;
        height: 22px;
    }

    .image-viewer-prev { left: 6px; }
    .image-viewer-next { right: 6px; }
}
