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

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

:root {
    --bg-primary: #0d0f14;
    --bg-secondary: #141720;
    --bg-tertiary: #1a1e2a;
    --bg-hover: #1f2435;
    --bg-active: #252b3d;
    --bg-message-own: #6c3bdb;
    --bg-message-other: #1e2235;
    --text-primary: #e8eaf0;
    --text-secondary: #8b90a0;
    --text-tertiary: #5a5f72;
    --accent: #7c4dff;
    --accent-light: #a17dff;
    --accent-gradient: linear-gradient(135deg, #7c4dff, #448aff);
    --accent-gradient-2: linear-gradient(135deg, #6c3bdb, #3d7bf5);
    --border: rgba(255, 255, 255, 0.06);
    --shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    --online: #4cdf7a;
    --unread: #ff5c8d;
    --typing: #ffc14d;
    --scrollbar: #2a2f42;
    --scrollbar-hover: #3a4058;
}

body.light-theme {
    --bg-primary: #f5f6fa;
    --bg-secondary: #ffffff;
    --bg-tertiary: #eef0f6;
    --bg-hover: #e8ebf2;
    --bg-active: #dde1ed;
    --bg-message-own: #7c4dff;
    --bg-message-other: #eef0f6;
    --text-primary: #1a1e2a;
    --text-secondary: #6b7084;
    --text-tertiary: #9a9eb2;
    --border: rgba(0, 0, 0, 0.06);
    --shadow: 0 8px 32px rgba(0, 0, 0, 0.08);
    --scrollbar: #d0d3de;
    --scrollbar-hover: #b8bccf;
}

body {
    font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    overflow: hidden;
    transition: background 0.3s ease;
}

.toast-root {
    position: fixed;
    right: 20px;
    bottom: 20px;
    display: grid;
    gap: 10px;
    z-index: 1200;
}

.toast-message {
    min-width: 260px;
    max-width: min(360px, calc(100vw - 32px));
    padding: 14px 16px;
    border-radius: 16px;
    background: rgba(17, 21, 31, 0.92);
    border: 1px solid rgba(255, 255, 255, 0.08);
    color: #fff;
    box-shadow: var(--shadow);
    opacity: 0;
    transform: translateY(10px);
    transition: opacity 0.2s ease, transform 0.2s ease;
}

body.light-theme .toast-message {
    background: rgba(34, 39, 53, 0.92);
}

.app.booting .chat-list-panel,
.app.booting .chat-main,
.app.booting .nav-avatar,
.app.booting .nav-badge {
    visibility: hidden;
}

.toast-message.visible {
    opacity: 1;
    transform: translateY(0);
}

.context-menu {
    position: fixed;
    z-index: 120;
    min-width: 232px;
    padding: 6px;
    border-radius: 10px;
    background: rgba(20, 23, 32, 0.98);
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
}

.context-menu button {
    width: 100%;
    border: 0;
    border-radius: 7px;
    background: transparent;
    color: var(--text-primary);
    text-align: left;
    padding: 9px 10px;
    cursor: pointer;
    display: grid;
    grid-template-columns: 28px 1fr;
    align-items: center;
    gap: 8px;
    font-size: 13px;
}

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

.context-menu button.danger {
    color: #ff6b7f;
}

.context-icon {
    width: 26px;
    height: 26px;
    border-radius: 7px;
    display: grid;
    place-items: center;
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    font-size: 14px;
}

.context-icon svg {
    display: block;
}

.context-menu button.danger .context-icon {
    color: #ff6b7f;
    background: rgba(255, 77, 103, 0.1);
}

.context-dialog-backdrop {
    position: fixed;
    inset: 0;
    z-index: 130;
    display: grid;
    place-items: center;
    padding: 20px;
    background: rgba(0, 0, 0, 0.42);
}

.context-dialog {
    width: min(100%, 420px);
    padding: 22px;
    border-radius: 22px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
}

.context-dialog h3 {
    margin-bottom: 8px;
}

.context-dialog p {
    color: var(--text-secondary);
    line-height: 1.45;
    margin-bottom: 16px;
}

.context-checkbox {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--text-secondary);
    margin-bottom: 18px;
}

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

.context-dialog-secondary,
.context-dialog-primary,
.context-dialog-danger,
.forward-chat-list button {
    border: 0;
    border-radius: 12px;
    padding: 10px 13px;
    cursor: pointer;
}

.context-dialog-secondary {
    background: var(--bg-tertiary);
    color: var(--text-secondary);
}

.context-dialog-primary {
    background: var(--accent);
    color: #fff;
}

.context-dialog-danger {
    background: #ff4d67;
    color: #fff;
}

.context-dialog-actions.vertical {
    display: grid;
    grid-template-columns: 1fr;
}

.forward-chat-list {
    display: grid;
    gap: 8px;
    margin-bottom: 16px;
}

.forward-chat-list button {
    width: 100%;
    text-align: left;
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

button,
input {
    font: inherit;
}

::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-secondary);
}

::-webkit-scrollbar-thumb {
    background: var(--scrollbar);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--scrollbar-hover);
}

.app {
    display: flex;
    height: 100vh;
    min-height: 100vh;
    min-width: 0;
    min-height: 0;
}

.app.auth-mode .nav-sidebar,
.app.auth-mode .chat-list-panel {
    display: none;
}

.app.auth-mode .chat-main {
    background:
        radial-gradient(circle at top left, rgba(124, 77, 255, 0.22), transparent 28%),
        radial-gradient(circle at bottom right, rgba(68, 138, 255, 0.18), transparent 24%),
        var(--bg-primary);
}

.app.app-view-dashboard .chat-list-panel {
    display: none;
}

.app.app-view-dashboard .chat-main {
    background: radial-gradient(circle at top left, rgba(68, 138, 255, 0.12), transparent 30%),
        radial-gradient(circle at bottom right, rgba(124, 77, 255, 0.16), transparent 25%),
        var(--bg-primary);
}

.nav-sidebar {
    width: 68px;
    background: var(--bg-secondary);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 16px 0;
    gap: 4px;
    z-index: 10;
}

.nav-logo {
    width: 42px;
    height: 42px;
    background: var(--accent-gradient);
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 20px;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    position: relative;
}

.nav-logo:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 20px rgba(124, 77, 255, 0.4);
}

.nav-logo svg {
    width: 22px;
    height: 22px;
    fill: #fff;
}

.pulse-ring {
    position: absolute;
    inset: 0;
    border-radius: 14px;
    border: 2px solid var(--accent);
    animation: pulse-ring 2s ease-out infinite;
    opacity: 0;
}

@keyframes pulse-ring {
    0% {
        transform: scale(1);
        opacity: 0.6;
    }
    100% {
        transform: scale(1.4);
        opacity: 0;
    }
}

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

.nav-btn:hover,
.nav-btn.active {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.nav-btn.active::before {
    content: "";
    position: absolute;
    left: -12px;
    width: 3px;
    height: 20px;
    background: var(--accent);
    border-radius: 0 3px 3px 0;
}

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

.nav-logout-btn:hover {
    color: #ff6b7f;
}

.nav-badge {
    position: absolute;
    top: 4px;
    right: 4px;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    background: var(--unread);
    border-radius: 999px;
    font-size: 10px;
    font-weight: 600;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid var(--bg-secondary);
}

.nav-spacer {
    flex: 1;
}

.nav-avatar,
.chat-avatar,
.chat-header-avatar,
.profile-side-avatar,
.message-avatar,
.person-avatar {
    user-select: none;
    overflow: hidden;
}

.nav-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--accent-gradient);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    color: #fff;
    transition: box-shadow 0.2s;
    position: relative;
    margin-bottom: 8px;
}

.nav-avatar:hover {
    box-shadow: 0 0 0 2px var(--accent);
}

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

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

.chat-list-panel {
    width: 320px;
    background: var(--bg-secondary);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.chat-list-header,
.chat-search,
.message-input-container,
.chat-header {
    background: var(--bg-secondary);
}

.chat-list-header {
    padding: 20px 16px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.chat-list-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.chat-list-header h2 {
    font-size: 20px;
    font-weight: 600;
}

.chat-search {
    padding: 0 16px 16px;
}

.search-input,
.message-input {
    width: 100%;
    border: 1px solid var(--border);
    outline: 0;
    color: var(--text-primary);
}

.search-input {
    background: var(--bg-tertiary);
    border-radius: 10px;
    padding: 10px 12px;
    font-size: 14px;
}

.search-input:focus,
.input-wrapper:focus-within {
    border-color: var(--accent);
}

.chat-list {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: 0 8px 8px;
}

.chat-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    border-radius: 12px;
    cursor: pointer;
    transition: background 0.2s;
    margin-bottom: 4px;
}

.chat-item:hover {
    background: var(--bg-hover);
}

.chat-item.active {
    background: var(--bg-active);
}

.chat-item.muted .chat-name,
.chat-item.muted .chat-last-msg {
    opacity: 0.72;
}

.chat-avatar,
.chat-header-avatar,
.profile-side-avatar {
    background: var(--accent-gradient-2);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    color: #fff;
    flex-shrink: 0;
}

.chat-avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
}

.chat-header-avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
}

.chat-info {
    flex: 1;
    min-width: 0;
}

.chat-name {
    font-weight: 600;
    margin-bottom: 4px;
    display: flex;
    align-items: center;
    gap: 6px;
}

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

.chat-last-msg {
    font-size: 13px;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-last-msg.is-typing {
    color: var(--typing);
}

.chat-meta {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 4px;
}

.chat-time,
.message-time {
    font-size: 11px;
    color: var(--text-tertiary);
}

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

.chat-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    min-height: 0;
    background: radial-gradient(circle at top, rgba(124, 77, 255, 0.08), transparent 35%), var(--bg-primary);
}

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

.dashboard-header {
    align-items: flex-start;
}

.dashboard-copy {
    max-width: 540px;
}

.dashboard-copy p {
    margin-top: 6px;
    color: var(--text-secondary);
    line-height: 1.5;
}

.dashboard-chip {
    padding: 8px 12px;
    border-radius: 999px;
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    font-size: 13px;
    border: 1px solid var(--border);
}

.chat-header-left,
.chat-header-actions,
.input-wrapper {
    display: flex;
    align-items: center;
}

.chat-header-left {
    gap: 16px;
}

.chat-header-info h3 {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 4px;
}

.chat-status {
    font-size: 13px;
    color: var(--text-secondary);
}

.chat-status.online {
    color: var(--online);
}

.chat-status.typing {
    color: var(--typing);
}

.audio-speed-bar {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
    padding: 10px 24px;
    background: linear-gradient(90deg, rgba(37, 211, 102, 0.08), rgba(124, 77, 255, 0.08)), var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    color: var(--text-secondary);
    font-size: 12px;
    flex-shrink: 0;
}

.audio-speed-bar[hidden] {
    display: none;
}

.audio-speed-bar button {
    border: 1px solid var(--border);
    border-radius: 999px;
    padding: 5px 9px;
    color: var(--text-secondary);
    background: var(--bg-tertiary);
    cursor: pointer;
    transition: all 0.18s ease;
}

.audio-speed-bar button:hover,
.audio-speed-bar button.active {
    color: #fff;
    border-color: var(--accent);
    background: var(--accent);
}

.pinned-message-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 24px;
    background: rgba(124, 77, 255, 0.1);
    border-bottom: 1px solid var(--border);
    color: var(--text-secondary);
    flex-shrink: 0;
}

.pinned-message-bar strong {
    display: block;
    color: var(--accent-light);
    font-size: 12px;
    margin-bottom: 2px;
}

.pinned-message-bar span {
    display: block;
    font-size: 13px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: min(560px, 58vw);
}

.pinned-clear-btn {
    border: 1px solid var(--border);
    border-radius: 999px;
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    padding: 7px 11px;
    cursor: pointer;
}

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

.pane-toggle-btn.active {
    color: var(--accent-light);
    background: rgba(124, 77, 255, 0.16);
}

.icon-btn,
.attach-btn,
.composer-action-btn,
.send-btn {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    border: 0;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.icon-btn,
.attach-btn,
.composer-action-btn {
    background: var(--bg-tertiary);
    color: var(--text-secondary);
}

.icon-btn:hover,
.attach-btn:hover,
.composer-action-btn:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

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

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

.profile-side-panel {
    display: none;
    width: 33%;
    min-width: 260px;
    max-width: 390px;
    padding: 22px;
    border-left: 1px solid var(--border);
    background:
        radial-gradient(circle at 80% 8%, rgba(68, 138, 255, 0.1), transparent 28%),
        linear-gradient(180deg, rgba(255, 255, 255, 0.035), transparent),
        var(--bg-secondary);
    flex-shrink: 0;
}

.chat-body-layout.with-profile-pane .profile-side-panel {
    display: flex;
}

.profile-side-card {
    width: 100%;
    min-height: 220px;
    border: 1px dashed var(--border);
    border-radius: 24px;
    padding: 22px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    color: var(--text-secondary);
}

.profile-side-avatar {
    width: 76px;
    height: 76px;
    border-radius: 22px;
    font-size: 24px;
    box-shadow: var(--shadow);
}

.profile-side-kicker {
    display: inline-flex;
    margin-bottom: 8px;
    color: var(--accent-light);
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.02em;
}

.profile-side-card h4 {
    margin-bottom: 8px;
    color: var(--text-primary);
    font-size: 20px;
}

.profile-side-card p {
    line-height: 1.55;
    font-size: 14px;
}

.messages-container {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.dashboard-grid {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: 24px;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
    align-content: start;
}

.auth-screen {
    flex: 1;
    display: grid;
    place-items: center;
    padding: 24px;
}

.auth-panel {
    width: min(100%, 440px);
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.04), transparent), var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 28px;
    padding: 28px;
    box-shadow: var(--shadow);
}

.auth-brand {
    margin-bottom: 20px;
}

.auth-kicker {
    display: inline-flex;
    padding: 6px 10px;
    border-radius: 999px;
    background: var(--bg-tertiary);
    color: var(--accent-light);
    font-size: 12px;
    font-weight: 600;
    margin-bottom: 14px;
}

.auth-brand h1 {
    font-size: 30px;
    line-height: 1.1;
    margin-bottom: 10px;
}

.auth-brand p,
.auth-hint {
    color: var(--text-secondary);
    line-height: 1.55;
}

.auth-form {
    display: grid;
    gap: 12px;
}

.auth-input {
    width: 100%;
    border: 1px solid var(--border);
    background: var(--bg-tertiary);
    border-radius: 14px;
    color: var(--text-primary);
    padding: 14px 16px;
    outline: 0;
}

.auth-input:focus {
    border-color: var(--accent);
}

.auth-error {
    background: rgba(255, 92, 141, 0.12);
    border: 1px solid rgba(255, 92, 141, 0.24);
    color: #ff8fb0;
    padding: 12px 14px;
    border-radius: 14px;
    font-size: 13px;
}

.auth-info {
    background: rgba(124, 77, 255, 0.12);
    border: 1px solid rgba(124, 77, 255, 0.24);
    color: var(--text-primary);
    padding: 12px 14px;
    border-radius: 14px;
    font-size: 13px;
    line-height: 1.5;
}

.auth-submit {
    border: 0;
    border-radius: 14px;
    background: var(--accent-gradient);
    color: #fff;
    padding: 14px 16px;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s ease, opacity 0.2s ease;
}

.auth-submit:hover {
    transform: translateY(-1px);
}

.auth-submit.secondary {
    margin-top: 16px;
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border: 1px solid var(--border);
}

.auth-submit.compact-action {
    padding: 10px 14px;
    border-radius: 12px;
    white-space: nowrap;
}

.compact-upload {
    display: inline-flex;
    width: fit-content;
    margin-top: 0;
}

.auth-switch {
    margin-top: 14px;
    border: 0;
    background: transparent;
    color: var(--accent-light);
    cursor: pointer;
    padding: 0;
}

.auth-switch.subtle {
    color: var(--text-secondary);
}

.auth-hint {
    margin-top: 16px;
    font-size: 13px;
}

.auth-textarea {
    min-height: 104px;
    resize: vertical;
}

.dashboard-card {
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.03), transparent), var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 22px;
    padding: 20px;
    box-shadow: var(--shadow);
}

.avatar-panel {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 16px;
    padding: 16px;
    border-radius: 18px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
}

.avatar-panel-copy p {
    margin-top: 6px;
    color: var(--text-secondary);
    font-size: 13px;
    line-height: 1.5;
}

.dashboard-card-head {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 14px;
}

.dashboard-card-kicker {
    display: inline-flex;
    width: fit-content;
    padding: 6px 10px;
    border-radius: 999px;
    background: var(--bg-tertiary);
    color: var(--accent-light);
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.02em;
}

.dashboard-card-title {
    font-size: 19px;
}

.dashboard-card-text {
    color: var(--text-secondary);
    line-height: 1.6;
    margin-bottom: 16px;
}

.stats-row,
.setting-list,
.person-list,
.timeline-list,
.permission-list,
.user-management-list,
.profile-form {
    display: grid;
    gap: 12px;
}

.filter-row {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
    margin-bottom: 16px;
}

.stats-row {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.stat-pill,
.setting-item,
.person-item,
.timeline-item {
    border-radius: 16px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
}

.stat-pill {
    padding: 14px;
}

.stat-pill strong {
    display: block;
    font-size: 22px;
    margin-bottom: 4px;
}

.stat-pill span,
.setting-item p,
.person-meta,
.timeline-item p {
    color: var(--text-secondary);
    font-size: 13px;
    line-height: 1.45;
}

.setting-item,
.person-item,
.timeline-item {
    padding: 16px;
}

.setting-item strong,
.person-name,
.timeline-item strong {
    display: block;
    margin-bottom: 4px;
}

.person-item {
    display: flex;
    align-items: center;
    gap: 12px;
}

.person-copy {
    flex: 1;
    min-width: 0;
}

.person-avatar {
    width: 44px;
    height: 44px;
    border-radius: 14px;
    background: var(--accent-gradient-2);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    flex-shrink: 0;
}

.person-avatar.large {
    width: 72px;
    height: 72px;
    border-radius: 20px;
}

.person-meta {
    margin-top: 2px;
}

.person-bio {
    margin-top: 6px;
    color: var(--text-secondary);
    font-size: 13px;
    line-height: 1.45;
}

.status-label {
    display: inline-flex;
    margin-top: 8px;
    padding: 6px 10px;
    border-radius: 999px;
    background: rgba(76, 223, 122, 0.12);
    color: var(--online);
    font-size: 12px;
    font-weight: 600;
}

.profile-field {
    display: grid;
    gap: 8px;
}

.profile-field span {
    font-size: 13px;
    color: var(--text-secondary);
}

.profile-field.compact {
    margin: 0;
}

.permission-list {
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
}

.permission-chip {
    padding: 12px 14px;
    border-radius: 14px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    color: var(--text-primary);
    font-size: 13px;
}

.user-management-item {
    display: grid;
    gap: 12px;
    padding: 16px;
    border-radius: 18px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
}

.user-management-head {
    display: flex;
    align-items: center;
    gap: 12px;
}

.role-select {
    width: 100%;
    border: 1px solid var(--border);
    background: var(--bg-secondary);
    color: var(--text-primary);
    border-radius: 12px;
    padding: 12px 14px;
    outline: 0;
}

.role-select:focus {
    border-color: var(--accent);
}

.timeline-item time {
    display: block;
    margin-top: 8px;
    color: var(--text-tertiary);
    font-size: 12px;
}

.message {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    max-width: 72%;
}

.message.own {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.message-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--accent-gradient-2);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    color: #fff;
    flex-shrink: 0;
}

.message-bubble {
    background: var(--bg-message-other);
    padding: 12px 16px;
    border-radius: 18px 18px 18px 4px;
    box-shadow: var(--shadow);
}

.message.own .message-bubble {
    background: var(--bg-message-own);
    color: #fff;
    border-radius: 18px 18px 4px 18px;
}

.message-text {
    font-size: 14px;
    line-height: 1.5;
    white-space: pre-wrap;
    word-break: break-word;
}

.message-attachment {
    display: block;
    margin-top: 10px;
    border-radius: 14px;
}

.message-attachment.image {
    max-width: min(280px, 100%);
    border: 1px solid var(--border);
}

.message-attachment.file {
    padding: 12px 14px;
    background: rgba(255, 255, 255, 0.08);
    color: inherit;
    text-decoration: none;
    border: 1px solid rgba(255, 255, 255, 0.12);
}

.message.own .message-time {
    color: rgba(255, 255, 255, 0.72);
}

.voice-message {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: min(300px, 66vw);
}

.message.selectable {
    cursor: pointer;
}

.message.selected .message-bubble {
    outline: 2px solid var(--accent-light);
    outline-offset: 3px;
}

.message-select-check {
    width: 26px;
    height: 26px;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: var(--bg-secondary);
    color: #fff;
    display: grid;
    place-items: center;
    align-self: center;
    flex: 0 0 auto;
}

.message.selected .message-select-check {
    background: var(--accent);
    border-color: var(--accent);
}

.selection-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 24px;
    background: rgba(124, 77, 255, 0.12);
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.selection-toolbar strong {
    color: var(--accent-light);
}

.selection-actions {
    display: flex;
    gap: 8px;
}

.selection-actions button {
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 8px 11px;
    background: var(--bg-tertiary);
    color: var(--text-primary);
    cursor: pointer;
}

.selection-actions button:disabled {
    opacity: 0.5;
    cursor: default;
}

.voice-play-btn {
    width: 42px;
    height: 42px;
    border: 0;
    border-radius: 50%;
    color: #fff;
    background: linear-gradient(135deg, var(--accent), var(--accent-light));
    display: grid;
    place-items: center;
    cursor: pointer;
    flex: 0 0 auto;
    position: relative;
    box-shadow: 0 10px 22px rgba(124, 77, 255, 0.25);
}

.voice-icon {
    position: absolute;
    display: grid;
    place-items: center;
    transition: opacity 0.18s ease, transform 0.18s ease;
}

.voice-icon-pause {
    opacity: 0;
    transform: scale(0.7);
}

.voice-message.is-playing .voice-icon-play {
    opacity: 0;
    transform: scale(0.7);
}

.voice-message.is-playing .voice-icon-pause {
    opacity: 1;
    transform: scale(1);
}

.voice-body {
    flex: 1;
    min-width: 0;
}

.voice-waveform {
    height: 34px;
    display: flex;
    align-items: center;
    gap: 3px;
    margin-bottom: 6px;
}

.voice-waveform span {
    width: 3px;
    min-height: 4px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.28);
    transition: background 0.12s ease, transform 0.12s ease;
}

.message:not(.own) .voice-waveform span {
    background: rgba(124, 77, 255, 0.24);
}

.voice-waveform span.active {
    background: var(--accent-light);
    transform: scaleY(1.08);
}

.voice-meta {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    font-size: 12px;
    color: rgba(255, 255, 255, 0.74);
}

.message:not(.own) .voice-meta {
    color: var(--text-secondary);
}

.message-input-container {
    padding: 16px 24px;
    border-top: 1px solid var(--border);
    flex-shrink: 0;
}

.attachment-preview {
    margin-bottom: 12px;
}

.attachment-pill {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: 14px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
}

.attachment-pill span {
    color: var(--text-secondary);
    font-size: 12px;
}

.attachment-remove {
    width: 28px;
    height: 28px;
    border-radius: 999px;
    padding: 0;
}

.input-wrapper {
    gap: 12px;
    background: var(--bg-tertiary);
    border: 1px solid transparent;
    border-radius: 12px;
    padding: 4px 4px 4px 16px;
}

.composer-actions {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding-right: 4px;
    border-right: 1px solid var(--border);
}

.composer-action-btn {
    width: 34px;
    height: 34px;
    border-radius: 9px;
    background: transparent;
    position: relative;
    color: var(--text-secondary);
}

.composer-action-btn:hover {
    transform: translateY(-1px);
    color: var(--accent-light);
}

.composer-action-btn svg {
    filter: drop-shadow(0 2px 8px rgba(124, 77, 255, 0.12));
}

.message-input {
    background: transparent;
    border: 0;
    padding: 10px 0;
}

.send-btn {
    background: var(--accent);
    color: #fff;
}

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

.composer-submit-btn {
    position: relative;
    overflow: hidden;
    flex: 0 0 40px;
}

.composer-submit-btn::before {
    content: "";
    position: absolute;
    inset: 7px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.16);
    opacity: 0;
    transform: scale(0.55);
    transition: opacity 0.22s ease, transform 0.22s ease;
}

.composer-submit-btn:hover::before {
    opacity: 1;
    transform: scale(1);
}

.submit-icon {
    position: absolute;
    inset: 0;
    display: grid;
    place-items: center;
    transition: opacity 0.22s ease, transform 0.24s ease;
}

.submit-icon-voice {
    opacity: 1;
    transform: translateY(0) scale(1);
}

.submit-icon-send {
    opacity: 0;
    transform: translateY(12px) scale(0.72) rotate(-18deg);
}

.composer-submit-btn.is-send-mode .submit-icon-voice {
    opacity: 0;
    transform: translateY(-12px) scale(0.72);
}

.composer-submit-btn.is-send-mode .submit-icon-send {
    opacity: 1;
    transform: translateY(0) scale(1) rotate(0deg);
}

.composer-submit-btn.is-recording {
    background: #ff4d67;
    animation: recording-pulse 1.2s ease-in-out infinite;
}

.composer-submit-btn.is-recording .submit-icon-voice {
    opacity: 1;
    transform: translateY(0) scale(1);
}

.composer-submit-btn.is-recording .submit-icon-send {
    opacity: 0;
}

.typing-indicator {
    display: inline-flex;
    gap: 4px;
    padding: 12px 16px;
    background: var(--bg-message-other);
    border-radius: 18px 18px 18px 4px;
}

.typing-dot {
    width: 8px;
    height: 8px;
    background: var(--text-tertiary);
    border-radius: 50%;
    animation: typing-bounce 1.4s infinite;
}

.typing-dot:nth-child(2) {
    animation-delay: 0.2s;
}

.typing-dot:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typing-bounce {
    0%,
    60%,
    100% {
        transform: translateY(0);
    }
    30% {
        transform: translateY(-8px);
        background: var(--typing);
    }
}

@keyframes recording-pulse {
    0%,
    100% {
        box-shadow: 0 0 0 0 rgba(255, 77, 103, 0.32);
        transform: scale(1);
    }
    50% {
        box-shadow: 0 0 0 8px rgba(255, 77, 103, 0);
        transform: scale(1.03);
    }
}

.empty-state {
    margin: auto;
    max-width: 320px;
    text-align: center;
    color: var(--text-secondary);
}

.empty-state.inline {
    margin: 0;
    max-width: none;
    padding: 20px;
    border-radius: 18px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
}

.empty-state h4 {
    margin-bottom: 8px;
    font-size: 18px;
    color: var(--text-primary);
}

@media (max-width: 900px) {
    .chat-list-panel {
        width: 280px;
    }

    .profile-side-panel,
    .chat-body-layout.with-profile-pane .profile-side-panel {
        display: none;
    }

    .message {
        max-width: 82%;
    }

    .dashboard-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 700px) {
    body {
        overflow: auto;
    }

    .app {
        flex-direction: column;
    }

    .nav-sidebar {
        width: 100%;
        flex-direction: row;
        justify-content: flex-start;
        padding: 12px;
        gap: 8px;
        overflow-x: auto;
        border-right: 0;
        border-bottom: 1px solid var(--border);
    }

    .nav-logo {
        margin-bottom: 0;
    }

    .nav-spacer {
        display: none;
    }

    .chat-list-panel {
        width: 100%;
        min-height: 240px;
    }

    .app.app-view-dashboard .chat-list-panel {
        min-height: 0;
    }

    .chat-header,
    .audio-speed-bar,
    .selection-toolbar,
    .messages-container,
    .message-input-container,
    .dashboard-grid {
        padding-left: 16px;
        padding-right: 16px;
    }

    .chat-main {
        min-height: 60vh;
    }

    .message {
        max-width: 90%;
    }

    .audio-speed-bar {
        justify-content: flex-start;
        overflow-x: auto;
    }

    .selection-toolbar {
        align-items: flex-start;
        flex-direction: column;
    }

    .input-wrapper {
        gap: 8px;
        padding-left: 10px;
    }

    .composer-actions {
        gap: 2px;
        max-width: 78px;
        overflow-x: auto;
        scrollbar-width: none;
    }

    .composer-actions::-webkit-scrollbar {
        display: none;
    }

    .composer-action-btn {
        flex: 0 0 32px;
        width: 32px;
        height: 32px;
    }

    .stats-row {
        grid-template-columns: 1fr;
    }

    .filter-row {
        grid-template-columns: 1fr;
    }

    .avatar-panel {
        align-items: flex-start;
        flex-direction: column;
    }
}
