:root {
    --navy: #0f2742;
    --navy-2: #183a5a;
    --blue: #176b87;
    --blue-2: #245f79;
    --cyan: #e7f4f7;
    --ink: #172334;
    --muted: #667386;
    --line: #dce3eb;
    --surface: #f4f7fa;
    --surface-2: #eef3f7;
    --white: #ffffff;
    --danger: #b93643;
    --danger-soft: #fff0f1;
    --success: #16835f;
    --success-soft: #eaf8f2;
    --radius: 18px;
    --shadow: 0 22px 65px rgba(15, 39, 66, .11);
    --shadow-soft: 0 10px 30px rgba(15, 39, 66, .07);
    --app-height: 100dvh;
}

* { box-sizing: border-box; }
html { min-height: 100%; background: var(--surface); }
body {
    min-height: 100%;
    margin: 0;
    color: var(--ink);
    background: linear-gradient(180deg, #f8fafc 0%, #f1f5f8 100%);
    font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; }
button, a, input, select, textarea { -webkit-tap-highlight-color: transparent; }
button { touch-action: manipulation; }
input, select, textarea {
    width: 100%;
    border: 1px solid #ccd6e1;
    border-radius: 11px;
    background: #fff;
    color: var(--ink);
    outline: 0;
    transition: border-color .18s, box-shadow .18s, background .18s;
}
input, select { height: 46px; padding: 0 13px; }
textarea { resize: none; padding: 10px 12px; }
input:focus, select:focus, textarea:focus { border-color: #6b9eb1; box-shadow: 0 0 0 4px rgba(23, 107, 135, .1); }
label { display: grid; gap: 7px; color: #344154; font-size: 13px; font-weight: 700; }
code { word-break: break-all; color: #314258; font-size: 11px; }
.visually-hidden { position: absolute !important; width: 1px !important; height: 1px !important; padding: 0 !important; margin: -1px !important; overflow: hidden !important; clip: rect(0,0,0,0) !important; white-space: nowrap !important; border: 0 !important; }

.site-header {
    height: 74px;
    padding: 0 clamp(18px, 4vw, 58px);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    border-bottom: 1px solid rgba(205, 216, 228, .9);
    background: rgba(255,255,255,.9);
    backdrop-filter: blur(16px);
    position: sticky;
    top: 0;
    z-index: 90;
}
.brand { display: inline-flex; align-items: center; gap: 11px; min-width: 0; }
.brand-mark {
    width: 42px;
    height: 42px;
    flex: 0 0 42px;
    display: grid;
    place-items: center;
    border-radius: 13px;
    color: #fff;
    background: linear-gradient(145deg, var(--navy), var(--blue));
    box-shadow: 0 9px 22px rgba(15,39,66,.22);
    position: relative;
}
.brand-mark::after { content: ""; position: absolute; left: 8px; bottom: 5px; border: 5px solid transparent; border-top-color: var(--blue); transform: rotate(22deg); }
.brand-mark span { font-weight: 900; font-size: 18px; }
.brand > span:last-child { min-width: 0; display: grid; line-height: 1.2; }
.brand strong { font-size: 16px; letter-spacing: .02em; }
.brand small { margin-top: 4px; color: var(--muted); font-size: 10px; font-weight: 500; }
.header-actions { display: flex; align-items: center; gap: 13px; }
.user-chip, .header-admin-link {
    min-height: 34px;
    padding: 7px 12px;
    display: inline-flex;
    align-items: center;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 700;
}
.user-chip { color: #3c4a5d; background: #eef3f7; }
.header-admin-link { color: #fff; background: var(--navy); }
.text-link { color: var(--muted); font-size: 12px; font-weight: 700; }
.text-link:hover { color: var(--blue); }
.site-footer {
    min-height: 60px;
    padding: 17px clamp(18px, 4vw, 58px);
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 20px;
    color: #7b8796;
    border-top: 1px solid var(--line);
    background: #fff;
    font-size: 11px;
}
.flash-stack { position: fixed; top: 86px; right: 20px; z-index: 150; width: min(390px, calc(100vw - 40px)); display: grid; gap: 9px; }
.flash { padding: 12px 14px; border: 1px solid var(--line); border-radius: 12px; background: #fff; box-shadow: var(--shadow-soft); font-size: 13px; transition: .3s; }
.flash-success { color: #126548; border-color: #b8e5d3; background: var(--success-soft); }
.flash-error { color: #9b2633; border-color: #efc2c7; background: var(--danger-soft); }
.flash.is-hiding { opacity: 0; transform: translateY(-8px); }

.primary-button, .secondary-button, .danger-button {
    min-height: 46px;
    padding: 0 18px;
    display: inline-grid;
    place-items: center;
    border-radius: 11px;
    cursor: pointer;
    font-weight: 800;
    transition: transform .16s, box-shadow .16s, opacity .16s;
}
.primary-button { border: 0; color: #fff; background: linear-gradient(135deg, var(--navy), var(--blue)); box-shadow: 0 10px 24px rgba(15,39,66,.17); }
.secondary-button { border: 1px solid #b9c9d6; color: var(--navy); background: #fff; }
.danger-button { border: 1px solid #efbdc3; color: var(--danger); background: var(--danger-soft); }
.primary-button:hover, .secondary-button:hover, .danger-button:hover { transform: translateY(-1px); }
.compact-button { min-height: 40px; font-size: 12px; }
.inline-button { width: auto; display: inline-grid; }

.auth-shell { min-height: calc(100vh - 134px); display: grid; grid-template-columns: minmax(0,1.15fr) minmax(390px,.85fr); }
.hero-panel {
    padding: clamp(54px, 8vw, 110px);
    display: flex;
    flex-direction: column;
    justify-content: center;
    color: #fff;
    background:
        radial-gradient(circle at 80% 10%, rgba(67,151,177,.42), transparent 34%),
        radial-gradient(circle at 12% 92%, rgba(68,113,149,.34), transparent 33%),
        linear-gradient(145deg, #0d2239 0%, #123b58 58%, #17637c 100%);
    position: relative;
    overflow: hidden;
}
.hero-panel::after { content: ""; position: absolute; width: 330px; height: 330px; right: -120px; bottom: -140px; border: 1px solid rgba(255,255,255,.15); border-radius: 50%; box-shadow: 0 0 0 48px rgba(255,255,255,.025), 0 0 0 95px rgba(255,255,255,.018); }
.eyebrow { color: #5d8799; font-size: 11px; font-weight: 900; letter-spacing: .18em; text-transform: uppercase; }
.hero-panel .eyebrow { color: #a9dce8; }
.hero-panel h1 { margin: 17px 0 18px; font-size: clamp(40px, 5vw, 68px); line-height: 1.1; letter-spacing: -.045em; }
.hero-panel h1 span { color: #9de1ec; }
.hero-panel > p { width: min(100%, 630px); margin: 0; color: rgba(255,255,255,.72); font-size: 15px; }
.feature-grid { margin-top: 36px; display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 12px; width: min(100%, 650px); }
.feature-grid article { padding: 16px; border: 1px solid rgba(255,255,255,.13); border-radius: 14px; background: rgba(255,255,255,.065); backdrop-filter: blur(8px); }
.feature-grid strong, .feature-grid span { display: block; }
.feature-grid strong { font-size: 13px; }
.feature-grid span { margin-top: 4px; color: rgba(255,255,255,.61); font-size: 11px; }
.hero-emoticon { margin-top: 22px; color: rgba(255,255,255,.7); font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 16px; }
.auth-card { width: min(100% - 48px, 470px); margin: auto; padding: 30px; border: 1px solid var(--line); border-radius: 22px; background: rgba(255,255,255,.94); box-shadow: var(--shadow); }
.auth-tabs { padding: 5px; display: grid; grid-template-columns: 1fr 1fr; gap: 5px; border-radius: 12px; background: var(--surface-2); }
.auth-tab { height: 38px; border: 0; border-radius: 9px; color: var(--muted); background: transparent; cursor: pointer; font-size: 12px; font-weight: 800; }
.auth-tab.is-active { color: var(--navy); background: #fff; box-shadow: 0 3px 10px rgba(15,39,66,.08); }
.auth-form { display: none; gap: 17px; margin-top: 26px; }
.auth-form.is-active { display: grid; }
.form-heading h2 { margin: 0; font-size: 25px; }
.form-heading p { margin: 3px 0 0; color: var(--muted); font-size: 12px; }
.password-field { display: flex; align-items: center; position: relative; }
.password-field input { padding-right: 60px; }
.password-toggle { position: absolute; right: 8px; height: 30px; padding: 0 8px; border: 0; color: var(--blue); background: transparent; cursor: pointer; font-size: 11px; font-weight: 800; }
.form-note { margin: -4px 0 0; color: var(--muted); text-align: center; font-size: 10px; }

.dashboard-shell, .admin-shell { width: min(1180px, calc(100% - 40px)); margin: 0 auto; padding: 52px 0 70px; }
.dashboard-intro, .admin-hero { display: flex; justify-content: space-between; align-items: flex-end; gap: 25px; }
.dashboard-intro h1, .admin-hero h1 { margin: 8px 0 5px; font-size: clamp(30px, 4vw, 44px); letter-spacing: -.035em; }
.dashboard-intro p, .admin-hero p { max-width: 760px; margin: 0; color: var(--muted); font-size: 13px; }
.dashboard-summary { min-width: 145px; padding: 18px 20px; text-align: right; border: 1px solid var(--line); border-radius: 15px; background: #fff; box-shadow: var(--shadow-soft); }
.dashboard-summary strong, .dashboard-summary span { display: block; }
.dashboard-summary strong { color: var(--navy); font-size: 31px; line-height: 1; }
.dashboard-summary span { margin-top: 6px; color: var(--muted); font-size: 11px; }
.admin-callout { margin-top: 24px; padding: 18px 20px; display: flex; align-items: center; gap: 14px; border-radius: 16px; color: #fff; background: linear-gradient(135deg, var(--navy), #225d79); box-shadow: 0 16px 35px rgba(15,39,66,.16); }
.admin-callout-icon { width: 42px; height: 42px; display: grid; place-items: center; border-radius: 12px; background: rgba(255,255,255,.12); font-size: 20px; }
.admin-callout > span:nth-child(2) { display: grid; }
.admin-callout small { color: rgba(255,255,255,.67); }
.admin-callout b { margin-left: auto; font-size: 12px; }
.action-grid { margin-top: 28px; display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 20px; }
.panel-card { padding: 27px; display: grid; gap: 17px; border: 1px solid var(--line); border-radius: var(--radius); background: #fff; box-shadow: var(--shadow-soft); }
.panel-card-muted { background: #f9fbfc; }
.panel-icon { width: 44px; height: 44px; display: grid; place-items: center; border-radius: 13px; color: #fff; background: var(--navy); font-size: 24px; }
.panel-title h2 { margin: 0; font-size: 20px; }
.panel-title p { margin: 3px 0 0; color: var(--muted); font-size: 11px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 13px; }
.code-input { text-transform: uppercase; letter-spacing: .18em; font-weight: 900; }
.rooms-section { margin-top: 42px; }
.section-heading { display: flex; justify-content: space-between; align-items: flex-end; gap: 20px; }
.section-heading h2 { margin: 0; font-size: 22px; }
.section-heading p { margin: 3px 0 0; color: var(--muted); font-size: 11px; }
.section-heading > a, .section-heading > span { color: var(--blue); font-size: 12px; font-weight: 800; }
.room-grid { margin-top: 16px; display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 16px; }
.room-card { min-height: 230px; padding: 21px; display: flex; flex-direction: column; border: 1px solid var(--line); border-radius: 16px; background: #fff; box-shadow: 0 7px 24px rgba(15,39,66,.05); transition: .18s; }
.room-card:hover { transform: translateY(-3px); border-color: #abc3d1; box-shadow: var(--shadow-soft); }
.room-card-top { display: flex; justify-content: space-between; gap: 10px; }
.room-status, .room-lock, .role-badge { padding: 4px 8px; border-radius: 999px; font-size: 9px; font-weight: 900; }
.room-status { color: #146849; background: #e9f7f1; }
.room-lock { color: #536273; background: #eff3f6; }
.role-badge { color: #174f68; background: #e5f2f6; }
.role-badge-admin { color: #fff; background: var(--navy); }
.room-card h3 { margin: 21px 0 12px; font-size: 19px; }
.room-code { color: var(--muted); font-size: 11px; }
.room-code strong { margin-left: 5px; color: var(--navy); letter-spacing: .16em; }
.room-meta { margin-top: 19px; display: grid; gap: 3px; color: var(--muted); font-size: 10px; }
.room-enter { margin-top: auto; padding-top: 20px; color: var(--blue); font-size: 12px; font-weight: 900; }
.empty-state { margin-top: 16px; padding: 48px 20px; text-align: center; border: 1px dashed #c8d4df; border-radius: var(--radius); background: rgba(255,255,255,.55); }
.empty-illustration { color: #91a3b6; font-size: 42px; }
.empty-state h3 { margin: 8px 0 3px; }
.empty-state p { margin: 0; color: var(--muted); font-size: 12px; }

.message-page { min-height: calc(100vh - 134px); display: grid; place-items: center; padding: 40px 20px; }
.message-card { width: min(100%, 540px); padding: 44px; text-align: center; border: 1px solid var(--line); border-radius: 22px; background: #fff; box-shadow: var(--shadow); }
.message-symbol { width: 58px; height: 58px; display: grid; place-items: center; margin: 15px auto; border-radius: 50%; color: #fff; background: var(--navy); font-size: 28px; }
.message-card h1 { margin: 14px 0 7px; }
.message-card > p { color: var(--muted); }
.invite-details { display: grid; gap: 7px; margin: 24px 0; padding: 16px; border-radius: 12px; background: var(--surface-2); font-size: 12px; }
.invite-details span { display: flex; justify-content: space-between; gap: 20px; }
.invite-form { display: grid; gap: 16px; text-align: left; }

.admin-hero { align-items: center; }
.admin-tabs { margin: 28px 0 18px; padding: 5px; display: flex; gap: 4px; overflow-x: auto; border: 1px solid var(--line); border-radius: 13px; background: #fff; }
.admin-tabs a { min-width: max-content; padding: 9px 14px; border-radius: 9px; color: var(--muted); font-size: 12px; font-weight: 800; }
.admin-tabs a.is-active { color: #fff; background: var(--navy); }
.stat-grid { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 14px; }
.stat-grid article { padding: 21px; display: grid; border: 1px solid var(--line); border-radius: 15px; background: #fff; box-shadow: var(--shadow-soft); }
.stat-grid span { color: var(--muted); font-size: 11px; font-weight: 800; }
.stat-grid strong { margin: 7px 0 4px; color: var(--navy); font-size: 29px; }
.stat-grid small { color: #8a95a3; font-size: 10px; }
.admin-card { margin-top: 17px; padding: 24px; border: 1px solid var(--line); border-radius: var(--radius); background: #fff; box-shadow: var(--shadow-soft); }
.compact-room-list { margin-top: 16px; display: grid; }
.compact-room-list a { padding: 13px 4px; display: flex; align-items: center; justify-content: space-between; gap: 20px; border-bottom: 1px solid #edf1f4; }
.compact-room-list a:last-child { border-bottom: 0; }
.compact-room-list span { display: grid; }
.compact-room-list small { color: var(--muted); font-size: 10px; }
.compact-room-list b { color: var(--muted); font-size: 10px; font-weight: 600; }
.empty-inline { padding: 30px; text-align: center; color: var(--muted); font-size: 12px; }
.data-table-wrap { margin-top: 16px; overflow-x: auto; border: 1px solid var(--line); border-radius: 13px; }
.data-table { width: 100%; min-width: 850px; border-collapse: collapse; background: #fff; font-size: 12px; }
.data-table th, .data-table td { padding: 13px 14px; text-align: left; vertical-align: top; border-bottom: 1px solid #edf1f4; }
.data-table th { color: #556276; background: #f5f8fa; font-size: 10px; letter-spacing: .04em; }
.data-table td > strong, .data-table td > small { display: block; }
.data-table td small { max-width: 420px; color: var(--muted); overflow-wrap: anywhere; }
.data-table tbody tr:last-child td { border-bottom: 0; }
.table-actions { display: flex; align-items: center; gap: 9px; }
.table-actions a, .table-actions button { border: 0; color: var(--blue); background: transparent; cursor: pointer; font-size: 11px; font-weight: 800; }
.table-actions button { color: var(--danger); }
.visits-table { min-width: 1050px; }
.admin-account-card { max-width: 720px; }
.wide-form { max-width: 520px; margin-top: 20px; }

.room-page { width: 100%; height: var(--app-height); min-height: 0; overflow: hidden; background: #edf2f6; }
.room-page .site-header, .room-page .site-footer, .room-page > .flash-stack { display: none; }
.chat-layout { width: 100%; height: var(--app-height); min-height: 0; display: grid; grid-template-columns: 360px minmax(0,1fr); overflow: hidden; background: #edf2f6; }
.chat-sidebar { min-height: 0; padding: 22px; overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; border-right: 1px solid var(--line); background: #fff; position: relative; z-index: 60; }
.sidebar-heading { display: flex; justify-content: space-between; align-items: center; gap: 15px; }
.back-link { color: var(--muted); font-size: 12px; font-weight: 700; }
.sidebar-close { display: none; width: 37px; height: 37px; place-items: center; border: 0; border-radius: 10px; color: var(--muted); background: #f0f4f7; cursor: pointer; font-size: 24px; }
.room-identity { padding: 25px 0 22px; text-align: center; border-bottom: 1px solid var(--line); }
.room-avatar { width: 64px; height: 64px; display: grid; place-items: center; margin: 0 auto; border-radius: 18px; color: #fff; background: linear-gradient(145deg, var(--navy), #2a7790); box-shadow: 0 14px 30px rgba(15,39,66,.18); font-size: 25px; font-weight: 900; }
.room-identity h1 { margin: 13px 0 8px; font-size: 19px; overflow-wrap: anywhere; }
.role-badges { display: flex; justify-content: center; flex-wrap: wrap; gap: 6px; }
.info-block { padding: 17px 0; border-bottom: 1px solid var(--line); }
.info-label { display: block; margin-bottom: 7px; color: var(--muted); font-size: 10px; font-weight: 700; }
.copy-row { display: flex; align-items: center; gap: 8px; }
.copy-row strong { flex: 1; color: var(--navy); letter-spacing: .17em; }
.copy-row input { height: 36px; padding: 0 9px; font-size: 10px; }
.copy-row button { flex: 0 0 auto; min-height: 32px; padding: 0 10px; border: 0; border-radius: 8px; color: var(--blue); background: var(--cyan); cursor: pointer; font-size: 10px; font-weight: 800; }
.info-block small { display: block; margin-top: 7px; color: var(--muted); font-size: 9px; }
.info-list { display: grid; gap: 10px; padding: 18px 0; }
.info-list div { display: flex; justify-content: space-between; gap: 14px; font-size: 11px; }
.info-list span { color: var(--muted); }
.info-list strong { text-align: right; }
.member-panel { padding: 17px 0; border-top: 1px solid var(--line); }
.member-panel-heading { margin-bottom: 10px; display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.member-panel-heading h2 { margin: 0; font-size: 13px; }
.member-panel-heading span { color: var(--muted); font-size: 9px; }
.member-list { display: grid; gap: 7px; }
.member-item { min-width: 0; padding: 8px 9px; display: flex; align-items: center; gap: 9px; border-radius: 10px; background: #f5f8fa; }
.member-avatar { width: 30px; height: 30px; flex: 0 0 30px; display: grid; place-items: center; border-radius: 9px; color: #fff; background: #647b91; font-size: 11px; font-weight: 900; }
.member-item > span:nth-child(2) { min-width: 0; flex: 1; display: grid; }
.member-item strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 11px; }
.member-item small { color: var(--muted); font-size: 9px; }
.member-item i { width: 8px; height: 8px; flex: 0 0 8px; border-radius: 50%; background: #1ead75; box-shadow: 0 0 0 4px rgba(30,173,117,.1); }
.member-list-loading, .member-list-empty { padding: 9px; color: var(--muted); text-align: center; font-size: 9px; }
.member-history-panel .member-list { max-height: 250px; overflow-y: auto; }
.member-history-item { background: #fafbfd; }
.management-panel { margin: 2px 0 18px; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; background: #fbfcfd; }
.management-panel summary { padding: 13px 14px; cursor: pointer; color: var(--navy); font-size: 11px; font-weight: 900; }
.management-panel[open] summary { border-bottom: 1px solid var(--line); }
.management-form { padding: 14px; display: grid; gap: 12px; }
.management-form label { font-size: 10px; }
.management-form input, .management-form select { height: 39px; font-size: 11px; }
.management-divider { border-top: 1px solid var(--line); }
.management-label { color: #344154; font-size: 10px; font-weight: 900; }
.checkbox-list { display: grid; gap: 6px; }
.checkbox-list label { padding: 7px 8px; display: flex; align-items: center; gap: 8px; border-radius: 8px; background: #f1f5f8; }
.checkbox-list input { width: 15px; height: 15px; }
.muted-note { margin: 0; color: var(--muted); font-size: 9px; }
.kick-list { display: grid; gap: 6px; }
.kick-list form { padding: 8px; display: flex; align-items: center; justify-content: space-between; gap: 10px; border-radius: 8px; background: #f4f7f9; font-size: 10px; }
.kick-list button { border: 0; color: var(--danger); background: transparent; cursor: pointer; font-size: 10px; font-weight: 900; }
.sidebar-notice { padding: 12px; border-radius: 10px; color: #5f6c7f; background: #eef3f6; font-size: 9px; }
.leave-form { margin-top: 18px; text-align: center; }
.danger-link { border: 0; color: var(--danger); background: transparent; cursor: pointer; font-size: 10px; font-weight: 800; }
.sidebar-backdrop { display: none; }

.chat-main { min-width: 0; min-height: 0; display: grid; grid-template-rows: auto minmax(0,1fr) auto; overflow: hidden; }
.chat-topbar { min-height: 72px; padding: 12px clamp(14px, 3vw, 28px); display: flex; align-items: center; gap: 13px; border-bottom: 1px solid var(--line); background: rgba(255,255,255,.94); backdrop-filter: blur(14px); z-index: 10; }
.sidebar-toggle { display: none; width: 39px; height: 39px; flex: 0 0 39px; place-items: center; border: 0; border-radius: 10px; color: var(--navy); background: #edf2f6; cursor: pointer; font-size: 17px; }
.topbar-room { min-width: 0; }
.chat-topbar h2 { margin: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 16px; }
.chat-topbar p { margin: 2px 0 0; color: var(--muted); font-size: 10px; }
.live-dot { width: 7px; height: 7px; display: inline-block; margin-right: 6px; border-radius: 50%; background: #24b47e; box-shadow: 0 0 0 4px rgba(36,180,126,.12); }
.topbar-expiry { margin-left: auto; flex: 0 0 auto; text-align: right; color: var(--muted); font-size: 9px; }
.topbar-expiry strong { display: block; color: var(--navy); font-variant-numeric: tabular-nums; font-size: 12px; }
.message-list { min-height: 0; overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; padding: 24px clamp(15px, 4vw, 54px); scroll-behavior: smooth; scrollbar-gutter: stable; }
.message-loading, .chat-empty { min-height: 100%; display: grid; place-items: center; align-content: center; color: var(--muted); text-align: center; }
.message-loading span { width: 30px; height: 30px; border: 3px solid #d6deea; border-top-color: var(--blue); border-radius: 50%; animation: spin .8s linear infinite; }
.message-loading p { font-size: 11px; }
.chat-empty div { color: #9aabc0; font-size: 40px; }
.chat-empty strong { margin-top: 8px; }
.chat-empty span { color: var(--muted); font-size: 11px; }
@keyframes spin { to { transform: rotate(360deg); } }
.message-row { max-width: 780px; display: flex; gap: 10px; margin: 0 auto 18px 0; }
.message-row.is-self { margin-left: auto; margin-right: 0; flex-direction: row-reverse; }
.message-avatar { width: 34px; height: 34px; flex: 0 0 34px; display: grid; place-items: center; border-radius: 10px; color: #fff; background: #73859c; font-size: 12px; font-weight: 900; }
.message-row.is-self .message-avatar { background: var(--blue); }
.message-body { min-width: 0; max-width: min(72vw, 630px); }
.message-meta { display: flex; align-items: center; gap: 8px; margin: 0 3px 5px; font-size: 9px; }
.message-meta span { color: var(--muted); }
.message-row.is-self .message-meta { justify-content: flex-end; }
.message-bubble { width: fit-content; max-width: 100%; padding: 10px 13px; border: 1px solid #d8e0e8; border-radius: 4px 15px 15px 15px; background: #fff; box-shadow: 0 5px 15px rgba(15,39,66,.04); }
.message-bubble p { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; font-size: 13px; line-height: 1.6; }
.message-row.is-self .message-bubble { margin-left: auto; color: #fff; border-color: var(--blue); border-radius: 15px 4px 15px 15px; background: var(--blue); }
.image-bubble { padding: 5px; overflow: hidden; }
.image-bubble img { display: block; max-width: min(48vw, 440px); max-height: 440px; border-radius: 10px; cursor: zoom-in; object-fit: contain; }
.composer-zone { padding: 8px clamp(12px, 4vw, 54px) max(10px, env(safe-area-inset-bottom)); border-top: 1px solid rgba(211,220,229,.85); background: rgba(247,249,251,.96); backdrop-filter: blur(12px); position: relative; z-index: 12; }
.composer-zone.is-dragging { background: #e8f4f7; box-shadow: inset 0 0 0 2px var(--blue); }
.upload-preview { margin-bottom: 8px; padding: 8px 11px; display: flex; align-items: center; gap: 10px; border: 1px solid var(--line); border-radius: 11px; background: #fff; }
.upload-preview[hidden] { display: none; }
.upload-preview img { width: 44px; height: 44px; border-radius: 8px; object-fit: cover; }
.upload-preview div { min-width: 0; flex: 1; display: grid; }
.upload-preview strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 11px; }
.upload-preview span { color: var(--muted); font-size: 9px; }
.upload-preview button { border: 0; color: var(--muted); background: transparent; cursor: pointer; font-size: 20px; }
.emoticon-panel { margin-bottom: 8px; padding: 9px; display: flex; flex-wrap: wrap; gap: 7px; border: 1px solid var(--line); border-radius: 11px; background: #fff; box-shadow: var(--shadow-soft); }
.emoticon-panel[hidden] { display: none; }
.emoticon-panel button { min-height: 34px; padding: 6px 9px; border: 1px solid #e0e7ed; border-radius: 8px; color: #3c4b5d; background: #f7f9fb; cursor: pointer; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 10px; }
.composer { padding: 7px; display: flex; align-items: flex-end; gap: 7px; border: 1px solid #c5d1dc; border-radius: 14px; background: #fff; box-shadow: 0 9px 26px rgba(15,39,66,.08); }
.composer textarea { min-height: 42px; max-height: 132px; padding: 10px 6px; border: 0; box-shadow: none; line-height: 1.5; }
.composer-icon-button { width: 42px; height: 42px; flex: 0 0 42px; display: grid; place-items: center; border: 0; border-radius: 10px; color: var(--blue); background: var(--cyan); cursor: pointer; font-size: 20px; font-weight: 800; }
.send-button { min-width: 84px; height: 42px; flex: 0 0 auto; padding: 0 12px; display: flex; justify-content: center; align-items: center; gap: 8px; border: 0; border-radius: 10px; color: #fff; background: var(--blue); cursor: pointer; font-weight: 900; }
.send-button b { width: 20px; height: 20px; display: grid; place-items: center; border-radius: 50%; color: var(--blue); background: #fff; }
.send-button.is-upload span::after { content: "图片"; }
.send-button.is-upload span { font-size: 0; }
.send-button.is-upload span::after { font-size: 12px; }
.send-button:disabled { opacity: .55; cursor: wait; }
.composer-hint { padding-top: 5px; text-align: center; color: var(--muted); font-size: 8px; }
.toast { position: fixed; left: 50%; bottom: max(22px, env(safe-area-inset-bottom)); z-index: 180; transform: translate(-50%, 14px); max-width: calc(100vw - 32px); padding: 10px 14px; border-radius: 10px; color: #fff; background: rgba(15,39,66,.96); opacity: 0; pointer-events: none; transition: .24s; text-align: center; font-size: 11px; }
.toast.is-visible { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 1050px) {
    .room-grid { grid-template-columns: repeat(2, minmax(0,1fr)); }
    .chat-layout { grid-template-columns: 1fr; }
    .chat-sidebar { position: fixed; inset: 0 auto 0 0; width: min(90vw, 370px); transform: translateX(-103%); transition: transform .22s ease; box-shadow: 20px 0 55px rgba(15,39,66,.24); }
    .chat-sidebar.is-open { transform: translateX(0); }
    .sidebar-close, .sidebar-toggle { display: grid; }
    .sidebar-backdrop { position: fixed; inset: 0; z-index: 55; display: block; background: rgba(9,24,40,.42); backdrop-filter: blur(2px); }
    .sidebar-backdrop[hidden] { display: none; }
}

@media (max-width: 820px) {
    .auth-shell { grid-template-columns: 1fr; }
    .hero-panel { min-height: auto; padding: 58px 8vw; }
    .auth-card { margin: 42px auto; }
    .stat-grid { grid-template-columns: repeat(2, minmax(0,1fr)); }
}

@media (max-width: 700px) {
    .site-header { height: 66px; padding: 0 15px; }
    .brand small, .user-chip { display: none; }
    .header-actions { gap: 9px; }
    .header-admin-link { padding: 6px 9px; font-size: 10px; }
    .site-footer { flex-direction: column; gap: 2px; text-align: center; }
    .flash-stack { top: 74px; right: 12px; width: calc(100vw - 24px); }
    .hero-panel { padding: 48px 21px; }
    .hero-panel h1 { font-size: 39px; }
    .feature-grid { grid-template-columns: 1fr; }
    .auth-card { width: calc(100% - 26px); padding: 22px; margin: 28px auto; }
    .dashboard-shell, .admin-shell { width: calc(100% - 26px); padding: 34px 0 52px; }
    .dashboard-intro, .admin-hero { align-items: flex-start; flex-direction: column; }
    .dashboard-summary { display: none; }
    .admin-callout { align-items: flex-start; }
    .admin-callout b { display: none; }
    .action-grid, .room-grid, .form-row { grid-template-columns: 1fr; }
    .panel-card { padding: 21px; }
    .message-card { padding: 30px 21px; }
    .stat-grid { grid-template-columns: 1fr 1fr; }
    .stat-grid article { padding: 17px; }
    .stat-grid strong { font-size: 24px; }
    .admin-card { padding: 17px; }
    .compact-room-list a { align-items: flex-start; flex-direction: column; gap: 3px; }

    .chat-topbar { min-height: 64px; padding: 9px 10px; }
    .topbar-expiry { font-size: 8px; }
    .topbar-expiry strong { font-size: 10px; }
    .message-list { padding: 17px 10px; }
    .message-row { margin-bottom: 14px; }
    .message-avatar { width: 31px; height: 31px; flex-basis: 31px; }
    .message-body { max-width: calc(100vw - 67px); }
    .message-bubble p { font-size: 13px; }
    .image-bubble img { max-width: 70vw; max-height: 330px; }
    .composer-zone { padding: 7px 8px max(8px, env(safe-area-inset-bottom)); }
    .composer { gap: 5px; padding: 5px; }
    .composer-icon-button { width: 38px; height: 38px; flex-basis: 38px; font-size: 18px; }
    .composer textarea { min-height: 38px; padding: 8px 4px; font-size: 16px; }
    .send-button { min-width: 42px; width: 42px; height: 38px; padding: 0; }
    .send-button span { display: none; }
    .send-button b { width: 21px; height: 21px; }
    .composer-hint { display: none; }
    .emoticon-panel { max-height: 150px; overflow-y: auto; }
}

@media (max-width: 430px) {
    .brand strong { font-size: 14px; }
    .stat-grid { grid-template-columns: 1fr; }
    .chat-topbar h2 { max-width: 40vw; }
    .topbar-expiry strong { max-width: 126px; }
    .composer-icon-button:nth-of-type(2) { width: 36px; flex-basis: 36px; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
