:root {
    --bg-primary: #f3efe6;
    --bg-secondary: #dfe9eb;
    --panel: rgba(255, 255, 255, 0.88);
    --panel-strong: #ffffff;
    --border: rgba(26, 49, 58, 0.1);
    --text-main: #15323c;
    --text-muted: #687981;
    --brand: #13757e;
    --brand-dark: #0f5f66;
    --accent: #f3c788;
    --bubble-in: #fde7d8;
    --bubble-out: #d7f3eb;
    --danger: #bb4231;
    font-family: Arial, Helvetica, sans-serif;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    background:
        radial-gradient(circle at top left, rgba(243, 199, 136, 0.6), transparent 28%),
        linear-gradient(135deg, var(--bg-primary), var(--bg-secondary));
    color: var(--text-main);
}

button,
input {
    font: inherit;
}

button {
    cursor: pointer;
}

.hidden {
    display: none !important;
}

.page-shell {
    min-height: 100vh;
    padding: 20px;
}

.auth-screen,
.chat-screen {
    min-height: calc(100vh - 40px);
}

.auth-screen {
    display: grid;
    grid-template-columns: 1.2fr 0.9fr;
    gap: 20px;
}

.auth-panel,
.sidebar,
.chat-area {
    border: 1px solid var(--border);
    border-radius: 28px;
    background: var(--panel);
    box-shadow: 0 18px 48px rgba(21, 50, 60, 0.1);
    backdrop-filter: blur(14px);
}

.auth-copy {
    padding: 56px;
    background:
        linear-gradient(155deg, rgba(19, 117, 126, 0.97), rgba(14, 83, 89, 0.94)),
        linear-gradient(40deg, transparent, rgba(255, 255, 255, 0.14));
    color: #f9f4ec;
}

.auth-copy h1 {
    margin: 18px 0 16px;
    font-size: clamp(2.4rem, 4vw, 4rem);
    line-height: 1.05;
}

.auth-copy p {
    max-width: 440px;
    color: rgba(249, 244, 236, 0.8);
}

.auth-form-panel {
    padding: 36px;
}

.auth-tabs {
    display: inline-flex;
    background: #edf2f3;
    border-radius: 999px;
    padding: 4px;
    margin-bottom: 24px;
}

.auth-tab {
    border: 0;
    border-radius: 999px;
    background: transparent;
    padding: 12px 20px;
    color: var(--text-muted);
}

.auth-tab.active {
    background: var(--panel-strong);
    color: var(--text-main);
    box-shadow: 0 8px 18px rgba(21, 50, 60, 0.08);
}

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

.auth-form label {
    display: flex;
    flex-direction: column;
    gap: 8px;
    font-weight: 700;
}

.auth-form input,
.composer input {
    width: 100%;
    padding: 14px 16px;
    border: 1px solid var(--border);
    border-radius: 16px;
    background: #fffcf7;
    outline: none;
}

.auth-form input:focus,
.composer input:focus {
    border-color: rgba(19, 117, 126, 0.45);
    box-shadow: 0 0 0 4px rgba(19, 117, 126, 0.12);
}

.eyebrow {
    text-transform: uppercase;
    letter-spacing: 0.16em;
    font-size: 0.72rem;
    color: var(--text-muted);
}

.auth-copy .eyebrow {
    color: rgba(249, 244, 236, 0.68);
}

.primary-button,
.ghost-button,
.file-button {
    border: 0;
    border-radius: 16px;
    padding: 14px 18px;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.primary-button {
    background: linear-gradient(135deg, var(--brand), var(--brand-dark));
    color: #fff8ef;
}

.ghost-button,
.file-button {
    background: #ecf1f2;
    color: var(--text-main);
}

.status-text {
    min-height: 24px;
    margin: 0;
    color: var(--danger);
}

.admin-login-link {
    color: var(--brand-dark);
    text-decoration: none;
    font-weight: 700;
}

.admin-login-link:hover {
    text-decoration: underline;
}

.chat-screen {
    display: grid;
    grid-template-columns: 340px 1fr;
    gap: 20px;
}

.sidebar,
.chat-area {
    overflow: hidden;
}

.sidebar {
    display: flex;
    flex-direction: column;
}

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

.sidebar-header h2,
.chat-header h2 {
    margin: 6px 0 0;
}

.typing-indicator {
    min-height: 20px;
    margin: 6px 0 0;
    color: var(--brand);
    font-size: 0.88rem;
}

.contact-list {
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    overflow: auto;
}

.contact-item {
    width: 100%;
    border: 1px solid transparent;
    border-radius: 18px;
    background: #f7f4ed;
    padding: 16px;
    text-align: left;
    color: inherit;
}

.contact-item.active {
    border-color: rgba(19, 117, 126, 0.22);
    background: linear-gradient(135deg, rgba(19, 117, 126, 0.12), rgba(243, 199, 136, 0.2));
}

.contact-name {
    display: block;
    font-weight: 700;
}

.contact-meta {
    display: block;
    margin-top: 4px;
    color: var(--text-muted);
    font-size: 0.92rem;
}

.chat-area {
    display: grid;
    grid-template-rows: auto 1fr auto;
}

.poll-indicator {
    padding: 10px 14px;
    border-radius: 999px;
    background: #f1f4f4;
    color: var(--text-muted);
    font-size: 0.9rem;
}

.chat-messages {
    padding: 24px;
    overflow: auto;
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.empty-chat,
.empty-note {
    margin: auto 0;
    text-align: center;
    color: var(--text-muted);
}

.message-row {
    display: flex;
    justify-content: flex-start;
}

.message-row.own {
    justify-content: flex-end;
}

.message-bubble {
    max-width: min(560px, 82%);
    border-radius: 22px 22px 22px 10px;
    background: var(--bubble-in);
    padding: 14px 16px;
    box-shadow: 0 10px 24px rgba(21, 50, 60, 0.06);
    border-left: 4px solid rgba(206, 120, 54, 0.65);
}

.message-row.own .message-bubble {
    border-radius: 22px 22px 10px 22px;
    background: var(--bubble-out);
    color: var(--text-main);
    border-left-color: rgba(19, 117, 126, 0.7);
}

.message-sender {
    display: block;
    margin-bottom: 6px;
    font-size: 0.76rem;
    font-weight: 700;
    opacity: 0.72;
    letter-spacing: 0.02em;
}

.message-text {
    margin: 0 0 10px;
    white-space: pre-wrap;
    word-break: break-word;
}

.message-time {
    display: block;
    text-align: right;
    font-size: 0.78rem;
    opacity: 0.75;
}

.message-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-top: 8px;
}

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

.message-action {
    border: 0;
    background: transparent;
    color: inherit;
    opacity: 0.75;
    padding: 0;
    font-size: 0.78rem;
    text-decoration: underline;
}

.message-deleted {
    font-style: italic;
    opacity: 0.8;
}

.file-card {
    margin-bottom: 10px;
}

.message-image {
    display: block;
    width: min(280px, 100%);
    border-radius: 16px;
}

.file-link {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 12px;
    border-radius: 16px;
    background: rgba(255, 255, 255, 0.66);
    color: inherit;
    text-decoration: none;
}

.message-row.own .file-link {
    background: rgba(255, 255, 255, 0.55);
}

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

.file-actions a {
    color: inherit;
    font-size: 0.92rem;
}

.composer {
    display: grid;
    grid-template-columns: auto 1fr auto;
    gap: 14px;
    padding: 18px 24px 24px;
    border-top: 1px solid var(--border);
}

.composer-main {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.selected-file {
    min-height: 20px;
    margin: 0;
    color: var(--text-muted);
    font-size: 0.9rem;
}

.admin-shell {
    max-width: 1200px;
    margin: 0 auto;
}

.admin-auth {
    min-height: calc(100vh - 40px);
    display: grid;
    grid-template-columns: 1.1fr 0.9fr;
    gap: 20px;
}

.admin-dashboard {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.admin-header,
.admin-panel,
.admin-user-card {
    border: 1px solid var(--border);
    border-radius: 28px;
    background: var(--panel);
    box-shadow: 0 18px 48px rgba(21, 50, 60, 0.1);
    backdrop-filter: blur(14px);
}

.admin-header,
.admin-panel {
    padding: 28px;
}

.admin-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
}

.admin-header h1,
.admin-toolbar h2,
.admin-user-title h3 {
    margin: 0;
}

.admin-subtitle,
.admin-hint,
.admin-user-meta {
    color: var(--text-muted);
}

.admin-hint {
    margin-top: 0;
}

.admin-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 16px;
}

.admin-users-list {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.admin-user-card {
    padding: 20px;
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 18px;
}

.admin-user-main {
    min-width: 0;
}

.admin-user-title {
    display: flex;
    align-items: center;
    gap: 10px;
}

.admin-user-badge {
    border-radius: 999px;
    padding: 6px 10px;
    background: rgba(19, 117, 126, 0.12);
    color: var(--brand-dark);
    font-size: 0.78rem;
    font-weight: 700;
}

.admin-user-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.admin-password-input {
    min-width: 180px;
    padding: 12px 14px;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: #fffcf7;
    outline: none;
}

.admin-password-input:focus {
    border-color: rgba(19, 117, 126, 0.45);
    box-shadow: 0 0 0 4px rgba(19, 117, 126, 0.12);
}

.admin-action-button {
    padding: 12px 16px;
}

@media (max-width: 960px) {
    .auth-screen,
    .chat-screen,
    .admin-auth {
        grid-template-columns: 1fr;
    }

    .sidebar {
        max-height: 320px;
    }
}

@media (max-width: 640px) {
    .page-shell {
        padding: 12px;
    }

    .auth-copy,
    .auth-form-panel,
    .sidebar-header,
    .chat-header,
    .chat-messages,
    .composer {
        padding-left: 18px;
        padding-right: 18px;
    }

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

    .admin-header,
    .admin-toolbar,
    .admin-user-card {
        flex-direction: column;
        align-items: stretch;
    }

    .admin-user-actions {
        justify-content: flex-start;
    }

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