* {
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

html,
body {
    margin: 0;
    padding: 0;
    min-height: 100%;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, Helvetica, sans-serif;
    color: #132238;
    background: #eef3f8;
}

body {
    min-height: 100vh;
}

img {
    display: block;
    max-width: 100%;
}

button,
input,
textarea {
    font-family: inherit;
}

textarea {
    resize: none;
}

a {
    color: inherit;
}

.chat-body {
    background: #e8eff6;
}

.admin-body {
    background: radial-gradient(circle at top left, #eff5ff 0%, #eef2f7 42%, #edf1f6 100%);
}

.admin-shell,
.missing-wrap {
    width: 100%;
    max-width: 1180px;
    margin: 0 auto;
    padding: 20px 16px 34px;
}

.top-space {
    margin-top: 20px;
}

.card {
    background: #ffffff;
    border-radius: 28px;
    padding: 22px;
    box-shadow: 0 18px 45px rgba(19, 34, 56, 0.08);
    border: 1px solid rgba(217, 224, 236, 0.84);
    margin-bottom: 16px;
}

.page-title {
    margin: 0;
    font-size: 34px;
    line-height: 1.2;
    font-weight: 800;
    letter-spacing: -0.02em;
}

.section-title {
    margin: 0;
    font-size: 24px;
    line-height: 1.25;
    font-weight: 800;
}

.section-subtitle,
.hero-subtitle {
    display: none;
}

.center-text {
    text-align: center;
}

.text-input,
.message-input {
    width: 100%;
    border: 2px solid #d8e2ef;
    border-radius: 20px;
    padding: 15px 16px;
    font-size: 18px;
    color: #132238;
    background: #ffffff;
    outline: none;
}

.text-input:focus,
.message-input:focus {
    border-color: #1f6fff;
    box-shadow: 0 0 0 4px rgba(31, 111, 255, 0.1);
}

.message-input {
    min-height: 84px;
    max-height: 220px;
    line-height: 1.55;
    padding: 18px 18px;
    font-size: 18px;
}

.primary-btn,
.secondary-btn,
.ghost-btn,
.danger-btn,
.send-btn,
.file-circle-btn {
    border: 0;
    border-radius: 18px;
    padding: 14px 16px;
    font-size: 17px;
    font-weight: 700;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    transition: transform 0.15s ease, box-shadow 0.15s ease, opacity 0.15s ease;
}

.primary-btn:hover,
.secondary-btn:hover,
.ghost-btn:hover,
.danger-btn:hover,
.send-btn:hover,
.file-circle-btn:hover {
    transform: translateY(-1px);
}

.primary-btn,
.send-btn {
    background: linear-gradient(135deg, #106cff 0%, #2f8eff 100%);
    color: #ffffff;
    box-shadow: 0 12px 22px rgba(16, 108, 255, 0.2);
}

.secondary-btn,
.ghost-btn,
.file-circle-btn {
    background: #eff4ff;
    color: #1a62e3;
}

.danger-btn {
    background: linear-gradient(135deg, #f0556b 0%, #e04158 100%);
    color: #ffffff;
    box-shadow: 0 12px 22px rgba(224, 65, 88, 0.2);
}

.send-square-btn,
.file-circle-btn {
    width: 56px;
    height: 56px;
    padding: 0;
    flex: 0 0 56px;
}

.send-square-btn svg,
.file-circle-btn svg,
.download-icon svg {
    width: 22px;
    height: 22px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.full-btn,
.stretch-btn {
    width: 100%;
}

.small-btn {
    padding: 10px 14px;
    border-radius: 14px;
    font-size: 15px;
}

.notice {
    border-radius: 18px;
    padding: 14px 16px;
    font-size: 16px;
    margin-bottom: 14px;
}

.notice.error {
    background: #fee9ee;
    color: #b02745;
}

.notice.success {
    background: #eaf8ef;
    color: #127042;
}

.stack-form > * + * {
    margin-top: 12px;
}

.compact-form {
    margin-top: 16px;
}

.copy-field {
    display: flex;
    align-items: stretch;
    gap: 10px;
}

.copy-field .text-input {
    flex: 1;
    min-width: 0;
}

.action-row {
    display: flex;
    gap: 10px;
    margin-top: 14px;
}

.stretch-form {
    flex: 1;
}

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

.brand-mark {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 74px;
    height: 34px;
    padding: 0 14px;
    border-radius: 999px;
    background: #106cff;
    color: #ffffff;
    font-size: 14px;
    font-weight: 800;
    letter-spacing: 0.08em;
    margin-bottom: 12px;
}

.admin-topbar-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

.admin-badge {
    display: inline-flex;
    align-items: center;
    min-height: 42px;
    padding: 0 16px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.92);
    color: #2f4561;
    font-size: 15px;
    font-weight: 700;
    box-shadow: 0 8px 20px rgba(19, 34, 56, 0.06);
}

.wide-auth-card {
    max-width: 560px;
    margin: 24px auto 0;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 14px;
    margin-bottom: 16px;
}

.stat-card {
    border-radius: 24px;
    padding: 18px;
    box-shadow: 0 12px 30px rgba(19, 34, 56, 0.06);
    border: 1px solid rgba(217, 224, 236, 0.85);
    background: #ffffff;
}

.accent-blue {
    background: linear-gradient(180deg, #ffffff 0%, #f3f8ff 100%);
}

.accent-green {
    background: linear-gradient(180deg, #ffffff 0%, #f2fbf6 100%);
}

.accent-violet {
    background: linear-gradient(180deg, #ffffff 0%, #f7f4ff 100%);
}

.stat-label {
    font-size: 15px;
    color: #66778d;
}

.stat-value {
    font-size: 32px;
    line-height: 1.15;
    font-weight: 800;
    margin-top: 6px;
}

.admin-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr);
    gap: 16px;
}

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

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

.copy-panel {
    margin-top: 18px;
    padding-top: 18px;
    border-top: 1px solid #edf1f6;
}

.copy-panel-label {
    font-size: 14px;
    font-weight: 700;
    color: #64758c;
    margin-bottom: 10px;
}

.room-list {
    display: grid;
    gap: 14px;
}

.room-item {
    border-radius: 24px;
    padding: 18px;
    background: linear-gradient(180deg, #ffffff 0%, #fbfcff 100%);
    border: 1px solid #e5ebf5;
    box-shadow: 0 12px 30px rgba(19, 34, 56, 0.05);
}

.room-item-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
}

.room-main-text strong {
    display: block;
    font-size: 20px;
    line-height: 1.3;
}

.meta-line {
    display: block;
    margin-top: 6px;
    font-size: 14px;
    color: #718199;
}

.room-meta-row {
    display: flex;
    gap: 8px;
    margin-top: 10px;
}

.meta-chip,
.count-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 34px;
    padding: 0 12px;
    background: #eef4ff;
    color: #295fd5;
    border-radius: 999px;
    font-size: 14px;
    font-weight: 700;
    white-space: nowrap;
}

.compact-copy-field {
    margin-top: 14px;
}

.empty-state {
    font-size: 16px;
    color: #6f8097;
}

.chat-app {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.chat-header {
    position: sticky;
    top: 0;
    z-index: 20;
    padding: calc(env(safe-area-inset-top) + 12px) 14px 12px;
    background: linear-gradient(135deg, #0f6dff 0%, #1e7fff 100%);
    color: #ffffff;
    box-shadow: 0 12px 28px rgba(13, 31, 60, 0.16);
}

.chat-title-wrap,
.chat-main,
.chat-form {
    width: 100%;
    max-width: 620px;
    margin-left: auto;
    margin-right: auto;
}

.chat-title-wrap {
    display: flex;
    align-items: center;
    gap: 12px;
}

.chat-avatar {
    width: 48px;
    height: 48px;
    flex: 0 0 48px;
    border-radius: 16px;
    background: rgba(255, 255, 255, 0.18);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    font-weight: 800;
}

.chat-heading {
    min-width: 0;
}

.chat-brand {
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0;
    text-transform: none;
    opacity: 0.88;
}

.chat-title {
    font-size: 22px;
    line-height: 1.25;
    font-weight: 800;
    margin-top: 2px;
    word-break: break-word;
}

.chat-main {
    flex: 1;
    overflow-y: auto;
    padding: 14px 12px 176px;
    display: flex;
    flex-direction: column;
}

.date-divider {
    align-self: center;
    margin: 8px 0 14px;
    padding: 8px 12px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.92);
    color: #6e7d92;
    font-size: 13px;
    font-weight: 700;
    box-shadow: 0 8px 20px rgba(19, 34, 56, 0.06);
}

.message {
    width: 100%;
    display: flex;
    flex-direction: column;
    margin-bottom: 16px;
}

.message.mine {
    align-items: flex-end;
}

.message.other {
    align-items: flex-start;
}

.sender-row {
    max-width: 84%;
    margin-bottom: 5px;
    padding: 0 4px;
    font-size: 13px;
    font-weight: 700;
    color: #6b7c92;
}

.message.mine .sender-row {
    text-align: right;
}

.bubble {
    display: inline-block;
    max-width: 84%;
    border-radius: 24px;
    padding: 12px 14px;
    background: #ffffff;
    color: #14243a;
    box-shadow: 0 10px 24px rgba(19, 34, 56, 0.08);
    border: 1px solid rgba(223, 231, 241, 0.9);
}

.message.mine .bubble {
    background: linear-gradient(135deg, #168c49 0%, #28ad5e 100%);
    color: #ffffff;
    border-color: rgba(20, 128, 61, 0.28);
}

.bubble.attachment-only {
    width: auto;
    max-width: min(300px, 84vw);
    padding: 8px;
}

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

.attachments {
    margin-top: 12px;
}

.bubble.attachment-only .attachments {
    margin-top: 0;
}

.image-grid {
    display: inline-flex;
    flex-wrap: wrap;
    gap: 8px;
    width: auto;
}

.image-grid.image-grid-1 {
    display: inline-block;
}

.image-grid .image-card {
    display: block;
    border-radius: 20px;
    overflow: hidden;
    background: rgba(255, 255, 255, 0.18);
}

.message.other .image-grid .image-card {
    background: #edf3fb;
}

.image-grid.image-grid-1 .image-card {
    width: 180px;
    max-width: min(180px, 60vw);
}

.image-grid.image-grid-2 .image-card,
.image-grid.image-grid-3 .image-card,
.image-grid.image-grid-4 .image-card,
.image-grid.image-grid-5 .image-card,
.image-grid.image-grid-6 .image-card {
    width: calc(50% - 4px);
    max-width: calc(50% - 4px);
}

.image-card a {
    display: block;
}

.image-card img {
    width: 100%;
    height: 256px;
    object-fit: cover;
    object-position: center;
    border-radius: 20px;
}

.image-grid.image-grid-2 .image-card img,
.image-grid.image-grid-3 .image-card img,
.image-grid.image-grid-4 .image-card img,
.image-grid.image-grid-5 .image-card img,
.image-grid.image-grid-6 .image-card img {
    height: 168px;
}

.file-list {
    margin-top: 0;
    width: auto;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
}

.file-card {
    display: inline-flex;
    width: auto;
    max-width: min(320px, 78vw);
    border-radius: 18px;
    overflow: hidden;
    background: rgba(255, 255, 255, 0.2);
}

.message.other .file-card {
    background: #edf3fb;
}

.download-link {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    width: auto;
    max-width: 100%;
    padding: 14px;
    text-decoration: none;
}

.download-icon {
    width: 42px;
    height: 42px;
    flex: 0 0 42px;
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.22);
    display: flex;
    align-items: center;
    justify-content: center;
}

.message.other .download-icon {
    background: rgba(16, 108, 255, 0.08);
}

.download-meta {
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 4px;
    flex: 1 1 auto;
}

.file-name {
    font-size: 15px;
    font-weight: 700;
    line-height: 1.45;
    word-break: break-word;
}

.file-meta {
    font-size: 12px;
    opacity: 0.84;
}

.time-row {
    margin-top: 6px;
    padding: 0 4px;
    font-size: 13px;
    color: #6c7a90;
}

.message.mine .time-row {
    text-align: right;
}

.composer-wrap {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 30;
    padding: 10px 12px calc(env(safe-area-inset-bottom) + 10px);
    background: linear-gradient(180deg, rgba(232, 239, 246, 0) 0%, #e8eff6 34%, #e8eff6 100%);
}

.chat-form {
    position: relative;
    z-index: 31;
}

.composer-row {
    display: flex;
    align-items: flex-end;
    gap: 10px;
}

.composer-row-advanced {
    align-items: flex-end;
    gap: 10px;
}

.upload-preview {
    display: none;
    flex-wrap: wrap;
    gap: 8px;
}

.upload-preview.in-form {
    margin-top: 10px;
}

.upload-preview.has-files {
    display: flex;
}

.upload-thumb {
    position: relative;
    width: 56px;
    height: 56px;
    border-radius: 14px;
    overflow: hidden;
    background: #f3f6fb;
    border: 1px solid #dde6f1;
    box-shadow: 0 8px 18px rgba(19, 34, 56, 0.06);
    flex: 0 0 56px;
}

.upload-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.upload-thumb-file {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 6px;
    background: #eef4ff;
}

.upload-file-ext {
    font-size: 11px;
    font-weight: 800;
    color: #315ecb;
    text-align: center;
    line-height: 1.2;
    word-break: break-word;
}

.upload-thumb-remove {
    position: absolute;
    top: 4px;
    right: 4px;
    width: 18px;
    height: 18px;
    border: 0;
    border-radius: 50%;
    background: rgba(17, 24, 39, 0.72);
    color: #ffffff;
    font-size: 14px;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    padding: 0;
}

.chat-form input[type="file"] {
    display: block;
}

.image-viewer {
    position: fixed;
    inset: 0;
    background: rgba(7, 12, 23, 0.86);
    display: none;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    padding: 20px 16px 28px;
    z-index: 60;
}

.image-viewer.open {
    display: flex;
}

.image-viewer img {
    max-width: min(96vw, 520px);
    max-height: calc(100vh - 188px);
    border-radius: 20px;
}

.viewer-close {
    position: absolute;
    top: calc(env(safe-area-inset-top) + 16px);
    right: 16px;
    width: 48px;
    height: 48px;
    border: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.16);
    color: #ffffff;
    font-size: 34px;
    line-height: 1;
    cursor: pointer;
    z-index: 3;
}

.viewer-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 50px;
    height: 50px;
    border: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    color: #ffffff;
    display: none;
    align-items: center;
    justify-content: center;
    font-size: 34px;
    line-height: 1;
    cursor: pointer;
    box-shadow: 0 12px 30px rgba(0, 0, 0, 0.24);
    z-index: 4;
    backdrop-filter: blur(8px);
}

.viewer-prev {
    left: 16px;
}

.viewer-next {
    right: 16px;
}

.viewer-actions {
    margin-top: 16px;
}

.viewer-download {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 120px;
    min-height: 46px;
    padding: 0 18px;
    border-radius: 999px;
    background: #ffffff;
    color: #0f6dff;
    font-size: 15px;
    font-weight: 700;
    text-decoration: none;
    box-shadow: 0 10px 24px rgba(0, 0, 0, 0.2);
}

.viewer-caption {
    margin-top: 16px;
    color: #ffffff;
    font-size: 15px;
    text-align: center;
    line-height: 1.5;
    max-width: min(92vw, 520px);
}

.copy-toast {
    position: fixed;
    left: 50%;
    bottom: calc(env(safe-area-inset-bottom) + 90px);
    transform: translateX(-50%) translateY(12px);
    min-width: 120px;
    padding: 10px 14px;
    border-radius: 999px;
    background: rgba(20, 29, 40, 0.92);
    color: #ffffff;
    font-size: 14px;
    font-weight: 700;
    text-align: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.18s ease, transform 0.18s ease;
    z-index: 80;
}

.copy-toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

.hero-subtitle,
.section-subtitle {
    display: none;
}

.admin-hero-clean {
    padding-bottom: 14px;
}

.field-block {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.field-label {
    font-size: 14px;
    font-weight: 700;
    color: #5f728c;
}

.admin-card-strong {
    box-shadow: 0 22px 52px rgba(19, 34, 56, 0.08);
}

@media (max-width: 991px) {
    .admin-grid {
        grid-template-columns: 1fr;
    }

    .copy-field,
    .action-row,
    .admin-hero,
    .admin-topbar-actions {
        flex-direction: column;
        align-items: stretch;
    }

    .copy-field .secondary-btn {
        width: 100%;
    }
}

@media (max-width: 680px) {
    .composer-row-advanced {
        gap: 8px;
    }

    .send-square-btn,
    .file-circle-btn {
        width: 46px;
        height: 46px;
        flex-basis: 46px;
        border-radius: 14px;
    }

    .message-input {
        min-height: 72px;
        padding: 16px;
        font-size: 18px;
    }

    .upload-thumb {
        width: 52px;
        height: 52px;
        flex-basis: 52px;
        border-radius: 13px;
    }

    .viewer-nav {
        width: 44px;
        height: 44px;
        font-size: 30px;
    }
}

@media (max-width: 640px) {
    .page-title {
        font-size: 28px;
    }

    .section-title {
        font-size: 21px;
    }

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

    .stat-card {
        padding: 14px;
    }

    .stat-value {
        font-size: 26px;
    }

    .card {
        padding: 18px;
        border-radius: 24px;
    }

    .sender-row,
    .bubble {
        max-width: 92%;
    }

    .chat-title {
        font-size: 21px;
    }

    .message-text {
        font-size: 18px;
    }

    .chat-main {
        padding-bottom: 190px;
    }

    .bubble.attachment-only {
        max-width: min(280px, 78vw);
    }

    .image-grid.image-grid-1 .image-card {
        width: min(180px, 58vw);
    }

    .image-card img {
        height: 244px;
    }

    .image-grid.image-grid-2 .image-card,
    .image-grid.image-grid-3 .image-card,
    .image-grid.image-grid-4 .image-card,
    .image-grid.image-grid-5 .image-card,
    .image-grid.image-grid-6 .image-card {
        width: calc(50% - 4px);
        max-width: calc(50% - 4px);
    }

    .image-grid.image-grid-2 .image-card img,
    .image-grid.image-grid-3 .image-card img,
    .image-grid.image-grid-4 .image-card img,
    .image-grid.image-grid-5 .image-card img,
    .image-grid.image-grid-6 .image-card img {
        height: 152px;
    }

    .file-card {
        max-width: min(300px, 78vw);
    }

    .viewer-prev {
        left: 10px;
    }

    .viewer-next {
        right: 10px;
    }
}
