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

:root {
    --bg: #1a1a2e;
    --bg-secondary: #16213e;
    --bg-card: #1f2b47;
    --text: #e0e0e0;
    --text-muted: #8892a4;
    --accent: #5865f2;
    --accent-hover: #4752c4;
    --danger: #ed4245;
    --success: #57f287;
    --warning: #fee75c;
    --border: #2d3b55;
    --tab-active: #5865f2;
    --tab-hover: #2d3b55;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    height: 100vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* Header */
header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 20px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 8px;
}

header h1 {
    font-size: 18px;
    font-weight: 600;
}

.badge {
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.badge.standby {
    background: var(--warning);
    color: #000;
}

.badge.active {
    background: var(--success);
    color: #000;
}

/* Buttons */
.btn {
    padding: 6px 14px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    transition: background 0.15s;
}

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

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

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

.btn-danger:hover {
    background: #c93b3e;
}

.btn-icon {
    background: transparent;
    color: var(--text);
    font-size: 20px;
    padding: 4px 8px;
}

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

.btn-small {
    padding: 3px 8px;
    font-size: 11px;
}

/* Tab Bar */
#tab-bar {
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
    overflow-x: auto;
    white-space: nowrap;
}

#tab-bar::-webkit-scrollbar {
    height: 3px;
}

#tab-bar::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 3px;
}

#tab-list {
    display: flex;
    padding: 0 10px;
}

.tab {
    padding: 8px 18px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-muted);
    border-bottom: 2px solid transparent;
    transition: all 0.15s;
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}

.tab:hover {
    color: var(--text);
    background: var(--tab-hover);
}

.tab.active {
    color: #fff;
    border-bottom-color: var(--tab-active);
}

.tab .tab-count {
    background: var(--accent);
    color: #fff;
    font-size: 10px;
    padding: 1px 6px;
    border-radius: 8px;
    font-weight: 700;
}

.tab .tab-new {
    width: 8px;
    height: 8px;
    background: var(--accent);
    border-radius: 50%;
    display: none;
}

.tab.has-new .tab-new {
    display: block;
}

/* Content Area */
main {
    flex: 1;
    overflow-y: auto;
    padding: 16px 20px;
}

#empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: var(--text-muted);
    gap: 8px;
}

#empty-state .hint {
    font-size: 13px;
}

/* Message Panels (one per sender, toggled by tabs) */
.message-panel {
    display: none;
}

.message-panel.visible {
    display: block;
}

/* Message Card */
.message-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 14px 16px;
    margin-bottom: 10px;
    animation: fadeIn 0.2s ease;
}

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

.message-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 8px;
}

.message-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    object-fit: cover;
    background: var(--border);
}

.message-author {
    font-weight: 600;
    font-size: 14px;
}

.message-time {
    color: var(--text-muted);
    font-size: 11px;
    margin-left: auto;
}

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

/* Attachments */
.message-attachments {
    margin-top: 10px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.attachment-image {
    max-width: 100%;
    max-height: 400px;
    border-radius: 6px;
    cursor: pointer;
    transition: transform 0.2s;
}

.attachment-image:hover {
    transform: scale(1.01);
}

.attachment-pdf {
    width: 100%;
    height: 500px;
    border: 1px solid var(--border);
    border-radius: 6px;
}

.attachment-video {
    max-width: 100%;
    max-height: 400px;
    border-radius: 6px;
}

.attachment-generic {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--accent);
    text-decoration: none;
    font-size: 13px;
}

.attachment-generic:hover {
    background: var(--tab-hover);
}

/* Settings Modal */
.overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.overlay.hidden {
    display: none;
}

.modal {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 12px;
    width: 540px;
    max-height: 80vh;
    overflow-y: auto;
}

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

.modal-header h2 {
    font-size: 16px;
}

.btn-close {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 22px;
    cursor: pointer;
}

.btn-close:hover {
    color: var(--text);
}

.modal-body {
    padding: 20px;
}

fieldset {
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 16px;
    margin-bottom: 16px;
}

legend {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-muted);
    padding: 0 6px;
}

label {
    display: block;
    font-size: 13px;
    color: var(--text-muted);
    margin-bottom: 10px;
}

input[type="text"] {
    display: block;
    width: 100%;
    margin-top: 4px;
    padding: 8px 10px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text);
    font-size: 13px;
    outline: none;
}

input[type="text"]:focus {
    border-color: var(--accent);
}

/* User list in settings */
.user-entry {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 10px;
    background: var(--bg);
    border-radius: 6px;
    margin-bottom: 6px;
    font-size: 13px;
}

.user-entry .user-label {
    font-weight: 600;
}

.user-entry .user-token {
    color: var(--text-muted);
    font-family: monospace;
    font-size: 11px;
}

.add-user-form {
    display: flex;
    gap: 8px;
    margin-top: 10px;
}

.add-user-form input {
    flex: 1;
    margin-top: 0;
}

/* Scrollbar */
main::-webkit-scrollbar,
.modal::-webkit-scrollbar {
    width: 6px;
}

main::-webkit-scrollbar-thumb,
.modal::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 3px;
}
