:root {
    --cm-blue: #1595d3;
    --cm-blue-dark: #0f6f9e;
    --cm-green: #20b766;
    --cm-ink: #142033;
    --cm-muted: #758197;
    --cm-line: #e4eaf1;
    --cm-bg: #edf3f7;
    --cm-panel: #ffffff;
    --cm-soft: #f4f7fa;
    --cm-danger: #e64d55;
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--cm-bg); color: var(--cm-ink); font-family: "Segoe UI", Tahoma, sans-serif; }
button, input, textarea { font: inherit; }
button { cursor: pointer; }

.cm-guest {
    min-height: calc(100vh - 72px);
    display: grid;
    place-items: center;
    padding: 40px 20px;
    background:
        radial-gradient(circle at 15% 20%, rgba(21,149,211,.18), transparent 32%),
        radial-gradient(circle at 82% 78%, rgba(32,183,102,.16), transparent 34%),
        linear-gradient(145deg, #f5fbff, #eef4f7);
}
.cm-guest-card { width: min(760px, 100%); padding: 56px; background: rgba(255,255,255,.92); border: 1px solid #dce8f0; border-radius: 34px; box-shadow: 0 30px 100px rgba(20,68,98,.16); text-align: center; }
.cm-brand-mark { width: 92px; height: 92px; margin: 0 auto 18px; display: grid; place-items: center; border-radius: 30px; color: #fff; font-size: 42px; background: linear-gradient(145deg, var(--cm-blue), #22bbe6); box-shadow: 0 18px 40px rgba(21,149,211,.3); }
.cm-kicker { color: var(--cm-blue); letter-spacing: .18em; font-size: 12px; font-weight: 900; }
.cm-guest h1 { margin: 10px 0; font-size: clamp(34px, 7vw, 58px); }
.cm-guest p { margin: 0 auto; max-width: 580px; color: var(--cm-muted); font-size: 18px; line-height: 1.7; }
.cm-feature-row { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; margin: 28px 0; }
.cm-feature-row span { padding: 9px 13px; border-radius: 999px; background: #eaf7fd; color: var(--cm-blue-dark); font-weight: 700; }
.cm-primary-link, .cm-primary-button { display: inline-flex; justify-content: center; align-items: center; gap: 10px; border: 0; border-radius: 15px; padding: 14px 22px; background: linear-gradient(135deg, var(--cm-blue), #1cb6df); color: #fff; font-weight: 800; text-decoration: none; box-shadow: 0 12px 30px rgba(21,149,211,.24); }

.cm-app { width: min(1480px, calc(100% - 32px)); height: calc(100vh - 96px); min-height: 650px; margin: 16px auto; display: grid; grid-template-columns: 390px minmax(0, 1fr); overflow: hidden; background: #fff; border: 1px solid #dce5ed; border-radius: 24px; box-shadow: 0 20px 70px rgba(25,61,88,.14); }
.cm-sidebar { display: flex; flex-direction: column; min-width: 0; background: #fff; border-right: 1px solid var(--cm-line); }
.cm-sidebar-head, .cm-chat-head { min-height: 72px; display: flex; align-items: center; gap: 12px; padding: 12px 16px; background: #f8fafc; border-bottom: 1px solid var(--cm-line); }
.cm-sidebar-head > div:nth-child(2) { min-width: 0; flex: 1; }
.cm-sidebar-head strong, .cm-chat-head strong { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cm-sidebar-head small, .cm-chat-head small { display: block; margin-top: 2px; color: var(--cm-muted); }
.cm-avatar { width: 48px; height: 48px; flex: 0 0 48px; display: grid; place-items: center; overflow: hidden; border-radius: 50%; border: 0; color: #fff; font-weight: 900; background: linear-gradient(145deg, var(--cm-blue), #596ac5); background-size: cover; background-position: center; }
.cm-avatar-large { width: 78px; height: 78px; flex-basis: 78px; font-size: 25px; }
.cm-icon-button, .cm-back-button { width: 42px; height: 42px; display: grid; place-items: center; border: 0; border-radius: 50%; background: transparent; color: #516073; }
.cm-icon-button:hover, .cm-back-button:hover { background: #e9f0f5; color: var(--cm-blue); }
.cm-stories { display: flex; gap: 11px; min-height: 102px; padding: 13px 14px 8px; overflow-x: auto; scrollbar-width: none; }
.cm-stories::-webkit-scrollbar { display: none; }
.cm-story { min-width: 64px; display: grid; justify-items: center; gap: 5px; border: 0; background: transparent; color: var(--cm-ink); }
.cm-story small { width: 66px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cm-story-ring { width: 57px; height: 57px; display: grid; place-items: center; border: 3px solid var(--cm-green); border-radius: 50%; color: #fff; font-weight: 900; background: linear-gradient(145deg, #6f7fef, var(--cm-blue)); }
.cm-story-add { border-color: #b6e0f4; background: var(--cm-blue); }
.cm-search { display: flex; align-items: center; gap: 10px; margin: 6px 14px 12px; padding: 0 14px; min-height: 44px; border-radius: 14px; color: #8b96a6; background: var(--cm-soft); border: 1px solid transparent; }
.cm-search:focus-within { border-color: #a7d9ef; background: #fff; box-shadow: 0 0 0 3px rgba(21,149,211,.08); }
.cm-search input { min-width: 0; flex: 1; border: 0; outline: 0; background: transparent; color: var(--cm-ink); }
.cm-tabs { display: grid; grid-template-columns: repeat(3, 1fr); padding: 0 12px 8px; border-bottom: 1px solid var(--cm-line); }
.cm-tabs button { padding: 10px 4px; border: 0; border-radius: 10px; background: transparent; color: var(--cm-muted); font-size: 12px; font-weight: 700; }
.cm-tabs button.active { color: var(--cm-blue); background: #eaf7fd; }
.cm-list { min-height: 0; flex: 1; overflow-y: auto; }
.cm-list-loading { min-height: 180px; display: flex; align-items: center; justify-content: center; gap: 6px; }
.cm-list-loading span { width: 8px; height: 8px; border-radius: 50%; background: var(--cm-blue); animation: cm-bounce .9s infinite alternate; }
.cm-list-loading span:nth-child(2) { animation-delay: .2s; }
.cm-list-loading span:nth-child(3) { animation-delay: .4s; }
@keyframes cm-bounce { to { transform: translateY(-9px); opacity: .45; } }
.cm-list-empty { padding: 70px 28px; color: var(--cm-muted); text-align: center; line-height: 1.6; }
.cm-chat-row, .cm-person-row { width: 100%; display: flex; align-items: center; gap: 12px; padding: 12px 14px; border: 0; border-bottom: 1px solid #edf1f5; background: #fff; text-align: left; }
.cm-chat-row:hover, .cm-person-row:hover, .cm-chat-row.active { background: #eef8fc; }
.cm-row-body { min-width: 0; flex: 1; }
.cm-row-title { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.cm-row-title strong { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cm-row-title time { color: #8994a5; font-size: 11px; }
.cm-row-preview { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 4px; color: var(--cm-muted); }
.cm-row-preview span:first-child { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cm-unread { min-width: 24px; height: 24px; padding: 0 7px; display: grid; place-items: center; border-radius: 999px; background: var(--cm-blue); color: #fff; font-size: 11px; font-weight: 800; }
.cm-online-dot { color: var(--cm-green); }

.cm-conversation { position: relative; min-width: 0; background: #dce7ed; background-image: radial-gradient(#c7d5dc 1px, transparent 1px); background-size: 22px 22px; }
.cm-empty-chat { position: absolute; inset: 0; display: grid; place-content: center; justify-items: center; padding: 30px; text-align: center; background: rgba(244,248,250,.88); backdrop-filter: blur(2px); }
.cm-empty-orbit { width: 118px; height: 118px; display: grid; place-items: center; border-radius: 38px; color: #fff; font-size: 48px; background: linear-gradient(145deg, var(--cm-blue), var(--cm-green)); transform: rotate(-5deg); box-shadow: 0 22px 55px rgba(26,118,150,.25); }
.cm-empty-chat h2 { margin: 25px 0 8px; font-size: 30px; }
.cm-empty-chat p { max-width: 520px; margin: 0; color: var(--cm-muted); line-height: 1.6; }
.cm-empty-chat a { margin-top: 20px; color: var(--cm-blue-dark); font-weight: 800; text-decoration: none; }
.cm-chat-panel { height: 100%; display: grid; grid-template-rows: auto minmax(0, 1fr) auto auto; }
.cm-chat-person { min-width: 0; flex: 1; }
.cm-back-button { display: none; }
.cm-messages { min-height: 0; overflow-y: auto; padding: 24px clamp(16px, 5vw, 72px); scroll-behavior: smooth; }
.cm-message { display: flex; margin: 8px 0; }
.cm-message.mine { justify-content: flex-end; }
.cm-bubble { position: relative; max-width: min(680px, 82%); padding: 10px 13px 7px; border-radius: 15px 15px 15px 4px; background: #fff; box-shadow: 0 1px 2px rgba(20,32,51,.12); white-space: pre-wrap; overflow-wrap: anywhere; }
.cm-message.mine .cm-bubble { border-radius: 15px 15px 4px 15px; background: #d9f6e4; }
.cm-quote { margin: -2px 0 7px; padding: 7px 9px; border-left: 3px solid var(--cm-blue); border-radius: 7px; background: rgba(21,149,211,.08); color: #436174; font-size: 12px; }
.cm-message-meta { display: flex; justify-content: flex-end; gap: 5px; margin-top: 4px; color: #778495; font-size: 10px; }
.cm-message.mine .cm-message-meta i { color: var(--cm-green); }
.cm-reply { display: flex; align-items: center; justify-content: space-between; padding: 9px 18px; border-top: 1px solid #dce5eb; background: #edf9fe; }
.cm-reply div { min-width: 0; display: grid; }
.cm-reply strong { color: var(--cm-blue-dark); font-size: 12px; }
.cm-reply span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--cm-muted); }
.cm-reply button { border: 0; background: transparent; color: var(--cm-muted); }
.cm-composer { display: flex; align-items: flex-end; gap: 8px; padding: 10px 14px; border-top: 1px solid var(--cm-line); background: #f8fafc; }
.cm-composer button { width: 45px; height: 45px; flex: 0 0 45px; border: 0; border-radius: 50%; color: #677487; background: transparent; }
.cm-composer textarea { min-height: 45px; max-height: 130px; flex: 1; resize: none; padding: 11px 15px; border: 1px solid #dfe6ed; border-radius: 22px; outline: 0; background: #fff; }
.cm-composer textarea:focus { border-color: #a7d9ef; }
.cm-composer .cm-send { color: #fff; background: var(--cm-blue); }

.cm-modal-backdrop { position: fixed; inset: 0; z-index: 9999; display: grid; place-items: center; padding: 20px; background: rgba(8,20,32,.62); backdrop-filter: blur(5px); }
.cm-modal { position: relative; width: min(590px, 100%); max-height: calc(100vh - 40px); overflow-y: auto; padding: 28px; border-radius: 24px; background: #fff; box-shadow: 0 30px 90px rgba(0,0,0,.28); }
.cm-modal-close { position: absolute; right: 16px; top: 16px; width: 38px; height: 38px; border: 0; border-radius: 50%; background: var(--cm-soft); color: var(--cm-muted); }
.cm-modal-title { display: flex; align-items: center; gap: 16px; padding-right: 38px; }
.cm-modal h2 { margin: 0 0 5px; }
.cm-modal p { margin: 0; color: var(--cm-muted); }
.cm-profile-form { display: grid; gap: 14px; margin-top: 24px; }
.cm-profile-form label { display: grid; gap: 6px; color: #536174; font-size: 13px; font-weight: 700; }
.cm-profile-form input, .cm-profile-form textarea { width: 100%; padding: 11px 12px; border: 1px solid #dbe4ec; border-radius: 11px; outline: 0; color: var(--cm-ink); background: #fff; }
.cm-profile-form input:focus, .cm-profile-form textarea:focus { border-color: var(--cm-blue); box-shadow: 0 0 0 3px rgba(21,149,211,.08); }
.cm-prefix-input { display: flex; align-items: center; border: 1px solid #dbe4ec; border-radius: 11px; overflow: hidden; }
.cm-prefix-input span { padding-left: 12px; color: var(--cm-muted); }
.cm-prefix-input input { border: 0; box-shadow: none !important; }
.cm-profile-form .cm-check { display: flex; grid-auto-flow: column; justify-content: start; align-items: center; }
.cm-profile-form .cm-check input { width: 18px; height: 18px; }
.cm-primary-button { width: 100%; }
.cm-search-modal { min-height: 430px; }
.cm-search-large { margin: 22px 0 12px; }
.cm-people-results { display: grid; }
.cm-person-actions { display: flex; gap: 4px; }
.cm-person-actions button { width: 36px; height: 36px; border: 0; border-radius: 50%; background: #eef6fa; color: var(--cm-blue-dark); }
.cm-toast { position: fixed; left: 50%; bottom: 28px; z-index: 10000; transform: translateX(-50%); padding: 12px 18px; border-radius: 12px; color: #fff; background: #142033; box-shadow: 0 12px 35px rgba(0,0,0,.25); }
[hidden] { display: none !important; }

@media (max-width: 900px) {
    .cm-app { width: 100%; height: calc(100vh - 64px); min-height: 560px; margin: 0; border: 0; border-radius: 0; grid-template-columns: 1fr; }
    .cm-sidebar { border: 0; }
    .cm-conversation { position: fixed; inset: 64px 0 0; z-index: 100; display: none; }
    .cm-app.chat-open .cm-conversation { display: block; }
    .cm-app.chat-open .cm-sidebar { visibility: hidden; }
    .cm-back-button { display: grid; }
    .cm-messages { padding: 16px 12px; }
    .cm-bubble { max-width: 88%; }
}

@media (max-width: 520px) {
    .cm-guest-card { padding: 36px 20px; border-radius: 24px; }
    .cm-feature-row { display: grid; }
    .cm-modal { padding: 22px 17px; border-radius: 19px; }
    .cm-modal-title { align-items: flex-start; }
}
