:root {
  color-scheme: dark;
  --bg: #0f1117;
  --panel: #151822;
  --panel-2: #1c202c;
  --line: rgba(255,255,255,.08);
  --text: #f5f7fb;
  --muted: #9299aa;
  --accent: #b9f36d;
  --accent-2: #8fd340;
  --danger: #ff7a7a;
  --bubble: #252b38;
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; background: radial-gradient(circle at 72% 10%, #252e32 0, transparent 28%), var(--bg); color: var(--text); }
button, input { font: inherit; }
button { cursor: pointer; }
.hidden { display: none !important; }
.shell { min-height: 100vh; }
.login-view { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.login-card { width: min(420px, 100%); padding: 46px; background: rgba(21,24,34,.86); border: 1px solid var(--line); border-radius: 28px; box-shadow: 0 30px 90px rgba(0,0,0,.36); backdrop-filter: blur(20px); }
.brand-mark { display: grid; place-items: center; width: 52px; height: 52px; margin-bottom: 28px; border-radius: 16px; background: var(--accent); color: #10140d; font-size: 28px; font-weight: 800; }
.eyebrow { margin: 0 0 8px; color: var(--accent); font-size: 10px; letter-spacing: .18em; font-weight: 700; }
h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 10px; font-size: 34px; letter-spacing: -.04em; }
h2 { margin-bottom: 4px; font-size: 21px; letter-spacing: -.03em; }
h3 { margin-bottom: 10px; font-size: 24px; }
.muted { color: var(--muted); line-height: 1.5; }
.stack-form { display: grid; gap: 16px; margin-top: 30px; }
label { display: grid; gap: 8px; color: #c6cad4; font-size: 13px; }
input { width: 100%; border: 1px solid var(--line); border-radius: 12px; padding: 13px 14px; background: #10131b; color: var(--text); outline: none; transition: border-color .2s, box-shadow .2s; }
input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(185,243,109,.1); }
.primary-button, .ghost-button, .secondary-button, .danger-button { border: 0; border-radius: 12px; padding: 13px 16px; font-weight: 700; transition: transform .15s, opacity .15s; }
button:active { transform: translateY(1px); }
.primary-button { background: var(--accent); color: #11150d; }
.primary-button:hover { background: #ceff8b; }
.login-button { width: 100%; margin-top: 26px; }
.member-label { color: #c6cad4; font-size: 13px; }
.member-options { display: grid; gap: 8px; max-height: 220px; overflow-y: auto; }
.member-options label { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border: 1px solid var(--line); border-radius: 10px; }
.member-options input { width: 16px; height: 16px; accent-color: var(--accent); }
.ghost-button { margin-top: 12px; width: 100%; background: transparent; color: #c6cad4; border: 1px solid var(--line); }
.ghost-button:hover, .secondary-button:hover { border-color: rgba(185,243,109,.5); color: var(--accent); }
.form-hint { margin: 18px 0 0; color: var(--muted); font-size: 12px; }
.chat-view { display: grid; grid-template-columns: 300px minmax(0, 1fr); min-height: 100vh; }
.sidebar { padding: 28px 18px; border-right: 1px solid var(--line); background: rgba(17,19,27,.7); }
.sidebar-top, .profile-row, .conversation-header, .composer, .modal-actions { display: flex; align-items: center; }
.sidebar-top { justify-content: space-between; padding: 0 10px 24px; }
.sidebar-top h2 { font-size: 27px; }
.icon-button, .tool-button, .call-button { border: 1px solid var(--line); background: transparent; color: #c6cad4; border-radius: 10px; width: 36px; height: 36px; }
.icon-button:hover, .tool-button:hover, .call-button:hover { color: var(--accent); border-color: rgba(185,243,109,.5); }
.profile-row { gap: 12px; padding: 14px 10px 20px; border-bottom: 1px solid var(--line); }
.avatar { display: grid; place-items: center; width: 40px; height: 40px; border-radius: 13px; background: linear-gradient(145deg, var(--accent), #638e35); color: #13180e; font-weight: 800; }
.status-dot { display: block; margin-top: 3px; color: var(--muted); font-size: 11px; }
.status-dot i { display: inline-block; width: 7px; height: 7px; margin-right: 5px; border-radius: 50%; background: #777; }
.status-dot.online i { background: var(--accent); box-shadow: 0 0 8px var(--accent); }
.sound-button { margin-left: auto; border: 1px solid var(--line); border-radius: 10px; width: 34px; height: 34px; background: transparent; color: #c6cad4; }
.sound-button:hover { border-color: rgba(185,243,109,.5); color: var(--accent); }
.sidebar-actions { padding: 16px 10px 12px; }
.secondary-button { width: 100%; padding: 10px; border: 1px solid var(--line); background: transparent; color: #c6cad4; }
.sidebar-actions .secondary-button + .secondary-button { margin-top: 8px; }
.section-label { padding: 12px 10px 8px; color: #686f80; font-size: 10px; font-weight: 800; letter-spacing: .14em; text-transform: uppercase; }
.group-label { margin-top: 10px; }
.contact-list { display: grid; gap: 4px; }
.contact-item { display: flex; align-items: center; gap: 11px; width: 100%; padding: 11px 10px; border: 0; border-radius: 12px; background: transparent; color: var(--text); text-align: left; }
.contact-item:hover, .contact-item.active { background: var(--panel-2); }
.contact-item.active .contact-name { color: var(--accent); }
.contact-avatar { display: grid; place-items: center; flex: 0 0 auto; width: 34px; height: 34px; border-radius: 11px; background: #2d3544; color: #dfe6f2; font-size: 12px; font-weight: 700; }
.contact-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; }
.contact-state { margin-top: 3px; color: var(--muted); font-size: 10px; }
.contact-state i { display: inline-block; width: 6px; height: 6px; margin-right: 5px; border-radius: 50%; background: #626a79; }
.contact-state.online { color: var(--accent); }
.contact-state.online i { background: var(--accent); box-shadow: 0 0 7px rgba(185,243,109,.8); }
.conversation-panel { display: grid; grid-template-rows: auto 1fr auto auto; min-width: 0; min-height: 100vh; }
.conversation-header { justify-content: space-between; min-height: 106px; padding: 26px 42px; border-bottom: 1px solid var(--line); }
.call-actions { gap: 8px; }
.call-button { width: 40px; height: 40px; color: var(--accent); }
.message-list { overflow-y: auto; padding: 28px 42px; }
.empty-state { display: grid; place-items: center; min-height: 50vh; color: var(--muted); text-align: center; }
.empty-state span { margin-bottom: 16px; color: var(--accent); font-size: 42px; }
.empty-state p { font-size: 14px; }
.message-row { display: flex; margin: 12px 0; }
.message-row.mine { justify-content: flex-end; }
.message-row > div { width: fit-content; max-width: min(620px, 78%); }
.message-bubble { display: inline-block; width: fit-content; min-width: 48px; max-width: 100%; padding: 12px 15px; border-radius: 16px 16px 16px 5px; background: var(--bubble); color: #e9edf6; line-height: 1.5; font-size: 14px; white-space: pre-wrap; word-break: normal; overflow-wrap: break-word; }
.mine .message-bubble { border-radius: 16px 16px 5px 16px; background: var(--accent); color: #151b10; }
.message-meta { margin-top: 6px; color: var(--muted); font-size: 10px; }
.mine .message-meta { text-align: right; }
.voice-message { display: flex; align-items: center; gap: 9px; min-width: 160px; }
.voice-message button { border: 0; background: transparent; color: inherit; font-size: 18px; }
.voice-duration { font-size: 12px; }
.typing-indicator { min-height: 22px; padding: 0 42px; color: var(--muted); font-size: 11px; }
.composer { gap: 10px; padding: 12px 42px 8px; }
.composer input { flex: 1; }
.send-button { border: 0; border-radius: 11px; padding: 12px 18px; background: var(--accent); color: #11150d; font-weight: 700; }
.send-button:disabled, .composer input:disabled, .tool-button:disabled { cursor: not-allowed; opacity: .45; }
.tool-button.recording { color: #10140d; background: var(--danger); border-color: var(--danger); }
.retention-note { margin: 0; padding: 0 42px 24px; color: #656c7a; font-size: 11px; }
.toast { position: fixed; right: 24px; bottom: 24px; z-index: 20; max-width: 360px; padding: 12px 16px; border: 1px solid var(--line); border-radius: 12px; background: #222836; color: #edf2fc; box-shadow: 0 10px 35px rgba(0,0,0,.28); opacity: 0; transform: translateY(12px); pointer-events: none; transition: opacity .2s, transform .2s; }
.toast.show { opacity: 1; transform: translateY(0); }
.modal { position: fixed; inset: 0; z-index: 10; display: grid; place-items: center; padding: 24px; background: rgba(5,7,10,.68); backdrop-filter: blur(8px); }
.modal-card { width: min(360px, 100%); padding: 34px; border: 1px solid var(--line); border-radius: 24px; background: var(--panel); text-align: center; box-shadow: 0 25px 80px rgba(0,0,0,.42); }
.form-modal-card { width: min(440px, 100%); text-align: left; }
.compact-form { margin-top: 22px; }
.modal-button { min-width: 108px; }
.modal-actions .ghost-button { width: auto; margin-top: 0; }
.incoming-icon { display: grid; place-items: center; width: 64px; height: 64px; margin: 0 auto 20px; border-radius: 20px; background: var(--accent); color: #11150d; font-size: 28px; animation: pulse 1.5s infinite; }
.modal-actions { justify-content: center; gap: 12px; margin-top: 26px; }
.modal-actions button { min-width: 110px; }
.danger-button { background: #3a2025; color: #ffabab; }
@keyframes pulse { 50% { box-shadow: 0 0 0 12px rgba(185,243,109,.08); } }
@media (max-width: 820px) {
  .chat-view { grid-template-columns: 1fr; }
  .sidebar { min-height: auto; border-right: 0; border-bottom: 1px solid var(--line); }
  .contact-list { grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); }
  .group-label { display: none; }
  .conversation-panel { min-height: calc(100vh - 300px); }
  .conversation-header, .message-list, .composer { padding-left: 20px; padding-right: 20px; }
  .retention-note, .typing-indicator { padding-left: 20px; padding-right: 20px; }
}
