:root {
    --xp-blue-1: #0a4cbc;
    --xp-blue-2: #1d67d2;
    --xp-blue-3: #3a79d7;
    --xp-line: #5a84b1;
    --xp-border-dark: #27507f;
    --xp-panel: #dce7f3;
    --xp-panel-2: #edf4fb;
    --xp-white: #ffffff;
    --xp-text: #11253c;
}

* { box-sizing: border-box; }
html, body { min-height: 100%; }
body {
    margin: 0;
    font-family: Tahoma, Verdana, Arial, sans-serif;
    color: var(--xp-text);
    background: radial-gradient(circle at top, #8ab0da, #5c82b1 45%, #456995 100%);
}

a { color: inherit; }

.app-shell {
    max-width: 1530px;
    margin: 12px auto 24px;
    background: #cfdbe7;
    border: 1px solid #385e89;
    box-shadow: 0 14px 34px rgba(0,0,0,.28);
}

.xp-titlebar {
    background: linear-gradient(180deg, #2e7cea 0%, #1158cf 55%, #0742aa 100%);
    color: #fff;
    min-height: 48px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 8px 0 16px;
    border-bottom: 1px solid #06388e;
}
.window-title {
    font-weight: 700;
    font-size: 20px;
    letter-spacing: .2px;
    display: flex;
    align-items: center;
    gap: 10px;
}
.title-icon { font-size: 22px; }
.xp-controls { display: flex; gap: 6px; }
.xp-control {
    width: 34px;
    height: 34px;
    display: grid;
    place-items: center;
    background: linear-gradient(#79b4ff, #3d82ea);
    border: 1px solid rgba(255,255,255,.5);
    border-radius: 4px;
    font-weight: bold;
    box-shadow: inset 0 1px 0 rgba(255,255,255,.45);
}
.xp-control.close {
    background: linear-gradient(#ff8a72, #df4a21);
}

.top-menu-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 2px;
    padding: 8px 10px;
    background: linear-gradient(#f3f5f8, #d4dae3);
    border-top: 1px solid rgba(255,255,255,.65);
    border-bottom: 1px solid #7d9bbd;
}
.top-link {
    text-decoration: none;
    padding: 10px 16px;
    border-right: 1px solid #a4b3c6;
    display: inline-flex;
    align-items: center;
    gap: 10px;
    font-size: 17px;
}
.top-link.right { margin-left: auto; }
.top-link:hover { background: rgba(255,255,255,.45); }

.workspace-frame {
    margin: 0;
    padding: 0;
    border-top: 1px solid #fff;
    background: linear-gradient(#2f6fc5, #215ba5);
}

.room-tabs {
    display: flex;
    align-items: flex-end;
    gap: 2px;
    padding: 10px 10px 0;
}
.room-tab {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-height: 40px;
    padding: 10px 18px;
    text-decoration: none;
    font-weight: 700;
    font-size: 17px;
    color: #fff;
    background: linear-gradient(#4d87d7, #1d58ac);
    border: 1px solid #1e4d91;
    border-bottom: 0;
    border-radius: 6px 6px 0 0;
    box-shadow: inset 0 1px 0 rgba(255,255,255,.25);
}
.room-tab.active {
    background: linear-gradient(#ffffff, #eef4fb);
    color: #102b48;
    position: relative;
    top: 1px;
}
.add-tab {
    cursor: default;
    min-width: 54px;
    justify-content: center;
}
.tab-emoji { font-size: 20px; }

.welcome-strip {
    margin: 0 10px;
    background: linear-gradient(#fefefe, #dbe6f2);
    border: 1px solid #7f9fc2;
    border-top: 0;
    padding: 12px 16px;
    font-size: 18px;
    font-weight: 700;
}

.chat-layout {
    display: grid;
    grid-template-columns: 1fr 330px;
    gap: 0;
    min-height: 730px;
    background: #d6e2ef;
    border-top: 1px solid #96b1cf;
}
.chat-panel, .sidebar {
    background: #dbe6f2;
}
.sidebar {
    border-left: 1px solid #89a7c7;
}
.panel-header {
    background: linear-gradient(#fdfefe, #d7e3f0);
    border-bottom: 1px solid #8fa9c6;
    padding: 10px 14px;
    font-weight: 700;
    font-size: 18px;
}
.online-title { font-size: 22px; }

.messages {
    height: 580px;
    overflow-y: auto;
    background: #fff;
    margin: 12px 10px 10px;
    border: 2px inset #b8c9dc;
    padding: 14px 16px;
}
.message-row {
    margin-bottom: 12px;
    line-height: 1.35;
    font-size: 18px;
}
.message-meta {
    color: #44698d;
    font-size: 14px;
    margin-bottom: 3px;
}
.message-name {
    font-weight: 700;
    color: #1748bd;
}
.message-name.admin { color: #b21010; }
.message-name.mod { color: #cc7a00; }
.message-name.self { color: #0e3fa8; }
.message-body { color: #182737; }
.message-body.nudge {
    display: inline-block;
    background: #fff0bf;
    border: 1px solid #d8a53d;
    padding: 6px 10px;
}
.pm-badge {
    display: inline-block;
    background: #fff1cc;
    border: 1px solid #d39c23;
    padding: 2px 6px;
    margin-right: 6px;
    font-size: 12px;
    font-weight: 700;
}
.muted { color: #657c95; }

.compose-toolbar {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    padding: 8px 10px 0;
}
.tool-btn, .retro-select, .message-form button, .context-menu button, .auth-form button {
    min-height: 44px;
    border: 1px solid #6d8db1;
    background: linear-gradient(#ffffff, #dfe7f1);
    color: #17324e;
    padding: 7px 14px;
    cursor: pointer;
    border-radius: 3px;
    box-shadow: inset 0 1px 0 rgba(255,255,255,.7);
    font-family: inherit;
    font-size: 16px;
}
.tool-btn:hover, .message-form button:hover, .context-menu button:hover, .auth-form button:hover {
    background: linear-gradient(#fffefa, #f0dfa2);
}
.format-btn {
    min-width: 44px;
    padding-inline: 0;
    font-size: 20px;
}
.retro-select { min-width: 110px; }
.smiley-btn {
    min-width: 44px;
    padding-inline: 8px;
    font-size: 28px;
    line-height: 1;
}
.more-link {
    color: #1448a8;
    font-size: 18px;
    margin: 0 8px 0 4px;
}
.sound-toggle { min-width: 120px; }
.nudge-btn {
    font-weight: 700;
    color: #b01000;
    min-width: 190px;
}

.message-form {
    display: grid;
    grid-template-columns: 1fr 160px;
    gap: 12px;
    padding: 12px 10px 12px;
}
.message-form input {
    width: 100%;
    min-height: 64px;
    padding: 12px 14px;
    border: 2px inset #b8c9dc;
    font-family: inherit;
    font-size: 17px;
    background: #fff;
}
.send-btn {
    font-size: 22px;
    font-weight: 700;
}

.users {
    padding: 0;
    background: #fff;
    margin: 12px 10px 10px;
    border: 2px inset #b8c9dc;
    min-height: 580px;
    overflow-y: auto;
}
.user-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    border-bottom: 1px solid #e0e8f0;
    cursor: context-menu;
    font-size: 18px;
}
.user-row:hover,
.user-row.active {
    background: #2b67c3;
    color: #fff;
}
.user-row:hover .user-role,
.user-row.active .user-role { color: #fff4c8; }
.user-avatar { width: 26px; text-align: center; }
.user-role {
    font-size: 13px;
    color: #b31e1e;
    margin-left: auto;
    text-transform: lowercase;
    font-weight: 700;
}
.sidebar-actions {
    display: flex;
    gap: 8px;
    padding: 0 10px 12px;
}
.sidebar-btn {
    flex: 1;
    justify-content: center;
}

.context-menu {
    position: fixed;
    z-index: 9999;
    background: #f5f7fb;
    border: 1px solid #476d95;
    box-shadow: 0 10px 24px rgba(0,0,0,.28);
    min-width: 240px;
}
.context-menu.hidden { display: none; }
.context-menu button {
    width: 100%;
    text-align: left;
    border: 0;
    border-bottom: 1px solid #d6dfeb;
    background: #f8fbff;
}
.context-menu button:last-child { border-bottom: 0; }

.status-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    background: linear-gradient(#f2f5f8, #d5dbe3);
    border-top: 1px solid #7d9bbd;
    font-size: 16px;
}

.auth-body {
    min-height: 100vh;
    display: grid;
    place-items: center;
}
.auth-window {
    width: min(520px, calc(100vw - 30px));
    background: #e7f1fb;
    border: 1px solid #345f94;
    box-shadow: 0 10px 30px rgba(0,0,0,.25);
    padding: 22px;
}
.auth-form { display: grid; gap: 8px; }
.auth-form input {
    padding: 10px;
    border: 1px solid #7d9fc3;
    font-size: 16px;
}
.auth-links { margin-top: 14px; }
.auth-links a { color: #0b3f75; }
.error-box, .success-box {
    padding: 10px;
    margin-bottom: 12px;
    border: 1px solid;
}
.error-box { background: #ffe6e6; border-color: #c44; }
.success-box { background: #eafce6; border-color: #5ea35e; }
.admin-window { width: min(980px, calc(100vw - 30px)); }
.admin-table { width: 100%; border-collapse: collapse; background: white; }
.admin-table th, .admin-table td { border: 1px solid #c8d8ea; padding: 8px; text-align: left; }
.emoji { font-size: 24px; }
.shake { animation: shake .35s linear 2; }
@keyframes shake {
    0% { transform: translateX(0); }
    25% { transform: translateX(-6px); }
    50% { transform: translateX(6px); }
    75% { transform: translateX(-4px); }
    100% { transform: translateX(0); }
}

@media (max-width: 1050px) {
    .chat-layout { grid-template-columns: 1fr; }
    .sidebar { border-left: 0; border-top: 1px solid #89a7c7; }
    .messages { height: 420px; }
    .users { min-height: 260px; }
    .top-link.right { margin-left: 0; }
}


.noselect { user-select: none; }
.pm-root {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 10000;
}
.pm-window {
    position: fixed;
    width: 360px;
    height: 340px;
    background: #d7e4f1;
    border: 1px solid #345f94;
    box-shadow: 0 14px 28px rgba(0,0,0,.28);
    pointer-events: auto;
}
.pm-window.active { z-index: 10002; }
.pm-window.flash .pm-header {
    background: linear-gradient(#4d9cff, #0c56cf);
}
.pm-header {
    height: 34px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 0 8px 0 10px;
    color: #fff;
    font-weight: 700;
    cursor: move;
    background: linear-gradient(#2e7cea 0%, #1158cf 55%, #0742aa 100%);
    border-bottom: 1px solid #06388e;
}
.pm-title {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-size: 15px;
}
.pm-close {
    width: 28px;
    height: 26px;
    border: 1px solid rgba(255,255,255,.4);
    border-radius: 3px;
    background: linear-gradient(#ff8a72, #df4a21);
    color: #fff;
    font-weight: 700;
    cursor: pointer;
}
.pm-messages {
    height: 254px;
    margin: 8px;
    padding: 10px;
    overflow-y: auto;
    background: #fff;
    border: 2px inset #b8c9dc;
}
.pm-row {
    margin-bottom: 10px;
    max-width: 88%;
}
.pm-row.self { margin-left: auto; }
.pm-row.self .pm-text {
    background: #dcebff;
    border-color: #86a8dd;
}
.pm-row.other .pm-text {
    background: #fff6d5;
    border-color: #d6b55a;
}
.pm-meta {
    font-size: 12px;
    color: #476784;
    margin-bottom: 3px;
}
.pm-text {
    padding: 7px 9px;
    border: 1px solid;
    line-height: 1.35;
    font-size: 15px;
}
.pm-form {
    display: grid;
    grid-template-columns: 1fr 88px;
    gap: 8px;
    padding: 0 8px 8px;
}
.pm-input {
    min-height: 38px;
    padding: 9px 10px;
    border: 2px inset #b8c9dc;
    background: #fff;
    font-size: 15px;
}
.pm-send {
    min-height: 38px;
    border: 1px solid #6d8db1;
    background: linear-gradient(#ffffff, #dfe7f1);
    color: #17324e;
    box-shadow: inset 0 1px 0 rgba(255,255,255,.7);
    font-family: inherit;
    font-size: 15px;
    font-weight: 700;
    cursor: pointer;
}
.pm-send:hover { background: linear-gradient(#fffefa, #f0dfa2); }
@media (max-width: 900px) {
    .pm-window {
        width: calc(100vw - 24px);
        left: 12px !important;
        right: auto !important;
        bottom: 12px !important;
    }
}
.message-name.system { color: #0f5a2f; }
.message-body.system { color: #0f5a2f; font-weight: 700; }
.form-stack { max-width: 520px; }
.notice-box {
    border: 1px solid #d39b20;
    background: #fff3c4;
    color: #5d4200;
    padding: 10px 12px;
    margin-bottom: 10px;
    border-radius: 4px;
}
.profile-card {
    display: flex;
    gap: 16px;
    align-items: flex-start;
    padding: 12px;
    margin-bottom: 16px;
    background: #eef4fb;
    border: 1px solid #8ca7c5;
    border-radius: 6px;
}
.profile-avatar { font-size: 42px; line-height: 1; }
.profile-name { font-size: 22px; font-weight: 700; color: #12365b; }
.profile-status { margin-top: 6px; color: #214f86; font-weight: 600; }
.auth-form textarea {
    width: 100%;
    min-height: 120px;
    border: 1px solid #7f9cbb;
    background: #fff;
    border-radius: 4px;
    padding: 10px 12px;
    font: inherit;
}
.admin-action-form { display:flex; flex-direction:column; gap:8px; }
.admin-action-form input[type="text"] { min-height: 36px; }
.admin-action-grid { display:flex; gap:6px; flex-wrap:wrap; }

.msg-color-red{color:#b00000;font-weight:600;}
.msg-color-blue{color:#003ea8;font-weight:600;}
.msg-color-green{color:#146b2d;font-weight:600;}
.msg-color-purple{color:#6a2ca0;font-weight:600;}
.msg-color-orange{color:#b85a00;font-weight:600;}
.message-body strong{font-weight:800;}
.message-body u{text-decoration:underline;text-underline-offset:2px;}

.profile-modal {
    position: fixed;
    inset: 0;
    background: rgba(18,35,58,.45);
    display: grid;
    place-items: center;
    z-index: 9999;
}
.profile-modal.hidden { display: none; }
.profile-dialog {
    width: min(560px, calc(100vw - 30px));
    background: linear-gradient(#fefefe, #dbe6f2);
    border: 1px solid #587da8;
    box-shadow: 0 12px 32px rgba(0,0,0,.25);
    position: relative;
    padding: 18px;
}
.profile-close {
    position: absolute;
    top: 8px;
    right: 8px;
    border: 1px solid #6d8db1;
    background: linear-gradient(#ffffff, #dfe7f1);
    min-width: 34px;
    min-height: 34px;
    cursor: pointer;
}
.profile-card.compact { align-items: flex-start; }
.profile-avatar.big { font-size: 48px; min-width: 72px; }
.profile-bio {
    margin-top: 10px;
    padding: 10px 12px;
    background: rgba(255,255,255,.7);
    border: 1px solid #a6bcd4;
    line-height: 1.45;
}
.user-name.msg-color-red,.message-name.msg-color-red,.profile-name.msg-color-red{color:#b00000;}
.user-name.msg-color-blue,.message-name.msg-color-blue,.profile-name.msg-color-blue{color:#003ea8;}
.user-name.msg-color-green,.message-name.msg-color-green,.profile-name.msg-color-green{color:#146b2d;}
.user-name.msg-color-purple,.message-name.msg-color-purple,.profile-name.msg-color-purple{color:#6a2ca0;}
.user-name.msg-color-orange,.message-name.msg-color-orange,.profile-name.msg-color-orange{color:#b85a00;}


textarea { padding: 10px; border: 1px solid #7d9fc3; font-size: 16px; font-family: inherit; }
.admin-action-grid { display:grid; grid-template-columns: repeat(4,minmax(90px,1fr)); gap:6px; margin-top:6px; }
.compact-form { margin-top:10px; }
.danger-btn { background: linear-gradient(#ffd7d1,#ffb2a7); }
.smiley-modal.hidden { display:none; }
.smiley-modal { position: fixed; inset:0; background: rgba(0,0,0,.35); z-index:10020; display:grid; place-items:center; }
.smiley-dialog { width:min(620px, calc(100vw - 20px)); background:#dbe6f2; border:1px solid #345f94; box-shadow:0 14px 34px rgba(0,0,0,.28); }
.smiley-grid { display:grid; grid-template-columns: repeat(auto-fill,minmax(56px,1fr)); gap:8px; padding:14px; }
.smiley-close { float:right; border:1px solid #6d8db1; background:linear-gradient(#fff,#dfe7f1); cursor:pointer; }
.theme-dark-night { --xp-text:#eaf2ff; background: radial-gradient(circle at top, #2e3c57, #1c2435 45%, #111724 100%); }
.theme-dark-night .app-shell, .theme-dark-night .auth-window { background:#273247; border-color:#1a2335; color:#eaf2ff; }
.theme-dark-night .top-menu-bar, .theme-dark-night .status-bar, .theme-dark-night .panel-header, .theme-dark-night .welcome-strip, .theme-dark-night .chat-panel, .theme-dark-night .sidebar, .theme-dark-night .compose-toolbar, .theme-dark-night .pm-window, .theme-dark-night .smiley-dialog { background: linear-gradient(#34435f,#253149); color:#eaf2ff; }
.theme-dark-night .messages, .theme-dark-night .users, .theme-dark-night .pm-messages, .theme-dark-night .message-form input, .theme-dark-night .pm-input, .theme-dark-night .auth-form input, .theme-dark-night textarea, .theme-dark-night .admin-table { background:#131b28; color:#eaf2ff; border-color:#4b6287; }
.theme-dark-night .tool-btn, .theme-dark-night .retro-select, .theme-dark-night .message-form button, .theme-dark-night .context-menu button, .theme-dark-night .auth-form button { background: linear-gradient(#465678,#2d3a56); color:#fff; border-color:#6582aa; }
.theme-dark-night .context-menu { background:#1e2737; }
.theme-dark-night .user-row:hover, .theme-dark-night .user-row.active { background:#3a5f9c; }
.theme-dark-night .muted { color:#a8bdd8; }


.cs-modal.hidden { display:none; }
.cs-modal {
    position: fixed;
    inset: 0;
    background: rgba(13, 27, 46, .38);
    display: grid;
    place-items: center;
    z-index: 10050;
}
.cs-modal-box {
    width: min(520px, calc(100vw - 28px));
    background: linear-gradient(#fefefe, #dbe6f2);
    border: 1px solid #587da8;
    box-shadow: 0 18px 42px rgba(0,0,0,.28);
    padding: 18px;
}
.cs-modal-title {
    font-size: 24px;
    font-weight: 700;
    color: #143964;
    margin-bottom: 12px;
}
.cs-modal-text {
    color: #1c3958;
    font-size: 16px;
    line-height: 1.45;
    margin-bottom: 12px;
    white-space: pre-wrap;
}
.cs-modal-label {
    display: block;
    margin-bottom: 8px;
    font-weight: 700;
    color: #20456f;
}
.cs-modal-label.hidden, .cs-modal-input.hidden { display:none; }
.cs-modal-input {
    width: 100%;
    min-height: 48px;
    padding: 10px 12px;
    border: 2px inset #b8c9dc;
    background: #fff;
    font: inherit;
    font-size: 17px;
}
.cs-modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 14px;
}
.cs-toast-root {
    position: fixed;
    top: 18px;
    right: 18px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    z-index: 10060;
}
.cs-toast {
    min-width: 260px;
    max-width: min(420px, calc(100vw - 36px));
    background: linear-gradient(#fefefe, #dbe6f2);
    border: 1px solid #6f8db0;
    box-shadow: 0 12px 24px rgba(0,0,0,.22);
    padding: 12px 14px;
    color: #16375c;
    font-size: 15px;
    line-height: 1.4;
}
.cs-toast.info { border-left: 6px solid #2e7cea; }
.cs-toast.success { border-left: 6px solid #2f8a3f; }
.cs-toast.warn { border-left: 6px solid #d39b20; }
.cs-toast.error { border-left: 6px solid #c3412f; }
.theme-dark-night .cs-modal-box, .theme-dark-night .cs-toast {
    background: linear-gradient(#34435f,#253149);
    color: #eaf2ff;
    border-color: #6582aa;
}
.theme-dark-night .cs-modal-title, .theme-dark-night .cs-modal-text, .theme-dark-night .cs-modal-label { color:#eaf2ff; }
.theme-dark-night .cs-modal-input { background:#131b28; color:#eaf2ff; border-color:#4b6287; }

.room-announcement { margin: 8px 14px 0; }
.compact-chat .messages { font-size: 14px; }
.compact-chat .message-row { margin-bottom: 8px; }
.compact-chat .message-body { padding: 8px 10px; }
.compact-chat .users .user-row { padding: 10px 12px; }
.admin-window textarea { width: 100%; min-height: 90px; }
