:root {
  color-scheme: dark;
  --bg: #101117;
  --panel: #171922;
  --panel-2: #1d202b;
  --line: rgba(255,255,255,.09);
  --text: #f4f4f7;
  --muted: #9699aa;
  --accent: #b9f36b;
  --accent-ink: #15190f;
  --purple: #b5a3ff;
}
* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; background: radial-gradient(ellipse at top left, #202231 0, var(--bg) 52%); color: var(--text); font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; }
button, input { font: inherit; }
button { cursor: pointer; }
.hidden { display: none !important; }
.app-shell { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.auth-screen { width: min(100%, 440px); text-align: center; padding: 28px 0; }
.brand-mark { width: 54px; height: 54px; display: grid; place-items: center; margin: 0 auto 24px; border-radius: 18px; background: var(--accent); color: #15190f; font-size: 25px; font-weight: 900; letter-spacing: -4px; padding-right: 4px; box-shadow: 0 10px 35px #b9f36b22; }
.brand-mark span { color: #4d5d34; }
.eyebrow { text-transform: uppercase; letter-spacing: .19em; font-size: 10px; font-weight: 800; color: var(--accent); }
h1 { margin: 10px 0; font-size: clamp(38px, 8vw, 54px); letter-spacing: -.06em; }
.muted { color: var(--muted); }
.auth-copy { margin: 0 0 28px; }
.auth-card { text-align: left; padding: 8px; background: rgba(23,25,34,.92); border: 1px solid var(--line); border-radius: 24px; box-shadow: 0 24px 90px #0005; }
.tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 5px; padding: 5px; border-radius: 15px; background: #101117; margin-bottom: 18px; }
.tab { border: 0; border-radius: 11px; background: transparent; color: var(--muted); padding: 12px 8px; font-weight: 700; }
.tab.active { color: var(--text); background: var(--panel-2); }
#auth-form { padding: 8px 12px 12px; }
.field { display: block; font-size: 12px; font-weight: 700; color: #dfe0e8; margin: 0 0 16px; }
.field input { display: block; width: 100%; margin-top: 8px; border: 1px solid var(--line); border-radius: 12px; background: #11131a; color: var(--text); padding: 14px; outline: none; }
.field input:focus, .search-box:focus-within, #message-input:focus { border-color: #b9f36b88; box-shadow: 0 0 0 3px #b9f36b12; }
.field small { display: block; color: var(--muted); font-weight: 400; margin-top: 7px; }
.primary-button { width: 100%; border: 0; border-radius: 12px; background: var(--accent); color: var(--accent-ink); padding: 14px; font-weight: 900; }
.primary-button:disabled, .send-button:disabled { opacity: .55; cursor: wait; }
.status-message { min-height: 18px; margin: 12px 0 0; font-size: 12px; line-height: 1.5; color: var(--purple); }
.fine-print { max-width: 340px; margin: 18px auto 0; font-size: 11px; line-height: 1.6; color: #737687; }

.chat-screen { width: min(1200px, 100%); height: min(780px, calc(100vh - 48px)); min-height: 520px; display: grid; grid-template-columns: 320px minmax(0, 1fr); overflow: hidden; border: 1px solid var(--line); border-radius: 24px; background: var(--panel); box-shadow: 0 30px 100px #0005; }
.sidebar { min-width: 0; border-right: 1px solid var(--line); display: flex; flex-direction: column; background: #151720; }
.sidebar-header { padding: 24px 20px 18px; display: flex; justify-content: space-between; align-items: flex-start; border-bottom: 1px solid var(--line); gap: 10px; }
.brand-line { display: flex; align-items: center; gap: 9px; font-weight: 850; letter-spacing: -.03em; }
.brand-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 14px #b9f36b88; }
.small { font-size: 11px; }
#current-user-label { margin: 7px 0 0; }
.quiet-button { background: transparent; border: 1px solid var(--line); border-radius: 9px; padding: 8px 10px; color: var(--muted); font-size: 11px; }
.search-area { padding: 20px 16px 12px; }
.search-area > label { display: block; font-size: 12px; font-weight: 800; margin-bottom: 10px; }
.search-box { display: flex; align-items: center; gap: 8px; padding: 0 12px; border: 1px solid var(--line); border-radius: 12px; background: #101117; color: var(--muted); }
.search-box span { font-size: 23px; }
.search-box input { width: 100%; min-width: 0; border: 0; outline: 0; padding: 12px 0; background: transparent; color: var(--text); font-size: 12px; }
.search-results { max-height: 180px; overflow: auto; }
.user-result, .conversation-item { display: flex; width: 100%; align-items: center; gap: 10px; text-align: left; border: 0; background: transparent; color: var(--text); padding: 11px 9px; border-radius: 12px; }
.user-result:hover, .conversation-item:hover, .conversation-item.selected { background: #ffffff0a; }
.user-result { margin-top: 4px; }
.avatar { width: 38px; height: 38px; flex: 0 0 38px; display: grid; place-items: center; border-radius: 13px; background: linear-gradient(145deg, #b9f36b, #8dd8c4); color: #172016; font-weight: 900; }
.user-result .avatar, .conversation-item .avatar { width: 34px; height: 34px; flex-basis: 34px; border-radius: 11px; font-size: 12px; }
.result-name { font-size: 12px; font-weight: 800; }
.result-hint { display: block; color: var(--muted); font-size: 10px; margin-top: 3px; }
.section-heading { padding: 17px 22px 7px; color: #707486; font-size: 9px; letter-spacing: .17em; font-weight: 900; }
.conversation-list { padding: 0 10px 14px; overflow: auto; }
.empty-note { padding: 10px; color: var(--muted); font-size: 12px; line-height: 1.5; }
.conversation-item { margin: 3px 0; }
.conversation-item .item-text { min-width: 0; }
.conversation-item .item-text strong { display: block; font-size: 12px; overflow: hidden; text-overflow: ellipsis; }
.conversation-item .item-text span { display: block; margin-top: 4px; color: var(--muted); font-size: 10px; }
.chat-panel { min-width: 0; min-height: 0; }
.empty-chat { height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 25px; }
.empty-icon { width: 62px; height: 62px; display: grid; place-items: center; border: 1px solid var(--line); border-radius: 21px; color: var(--accent); font-size: 30px; background: #ffffff05; }
.empty-chat h2 { margin: 22px 0 8px; font-size: 25px; letter-spacing: -.04em; }
.empty-chat p { color: var(--muted); font-size: 13px; line-height: 1.6; }
.active-chat { height: 100%; min-height: 0; display: flex; flex-direction: column; }
.chat-header { display: flex; align-items: center; gap: 12px; padding: 18px 22px; border-bottom: 1px solid var(--line); }
.chat-heading { min-width: 0; }
.chat-heading h2 { margin: 0; font-size: 14px; }
.chat-heading p { margin: 5px 0 0; }
.call-button { margin-left: auto; display: inline-flex; align-items: center; gap: 7px; border: 1px solid #b9f36b55; border-radius: 11px; padding: 9px 13px; color: var(--accent); background: #b9f36b0d; font-size: 13px; font-weight: 800; }
.call-button:disabled { opacity: .5; cursor: not-allowed; }
.call-overlay { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 20px; background: #080910d9; backdrop-filter: blur(12px); }
.call-card { width: min(100%, 360px); text-align: center; padding: 30px 24px 22px; border: 1px solid var(--line); border-radius: 25px; background: linear-gradient(145deg, #222635, #151720); box-shadow: 0 25px 90px #0009; }
.call-orb { width: 74px; height: 74px; display: grid; place-items: center; margin: 0 auto 20px; border-radius: 24px; color: #172016; background: var(--accent); font-size: 28px; box-shadow: 0 0 45px #b9f36b25; }
.call-card h2 { margin: 9px 0; font-size: 24px; }
.call-card .muted { min-height: 20px; font-size: 13px; }
.call-actions { display: flex; gap: 12px; margin-top: 24px; }
.call-actions button { flex: 1; border: 0; border-radius: 12px; padding: 13px 10px; font-weight: 850; }
.accept-button { background: var(--accent); color: var(--accent-ink); }
.decline-button { background: #ff657a; color: #260a10; }
.call-footnote { margin: 20px 0 0; color: #777b8d; font-size: 10px; }
.messages { flex: 1; min-height: 0; overflow-y: auto; padding: 24px clamp(14px, 4vw, 44px); display: flex; flex-direction: column; gap: 10px; }
.message-row { display: flex; flex-direction: column; max-width: min(78%, 520px); align-self: flex-start; }
.message-row.mine { align-self: flex-end; }
.message-bubble { padding: 11px 14px; border: 1px solid var(--line); border-radius: 15px 15px 15px 4px; background: #222531; font-size: 13px; line-height: 1.5; white-space: pre-wrap; overflow-wrap: anywhere; }
.message-row.mine .message-bubble { color: #15190f; background: var(--accent); border-color: transparent; border-radius: 15px 15px 4px 15px; }
.message-time { padding: 5px 3px 0; color: #7d8192; font-size: 9px; }
.message-row.mine .message-time { text-align: right; }
.no-messages { margin: auto; color: var(--muted); text-align: center; font-size: 12px; }
.message-form { display: flex; gap: 10px; padding: 16px 20px 20px; border-top: 1px solid var(--line); }
#message-input { flex: 1; min-width: 0; background: #101117; border: 1px solid var(--line); border-radius: 13px; outline: none; color: var(--text); padding: 14px; font-size: 13px; }
.send-button { width: 46px; border: 0; border-radius: 13px; background: var(--accent); color: var(--accent-ink); font-size: 23px; font-weight: 900; }
.toast { position: fixed; left: 50%; bottom: 22px; transform: translate(-50%, 20px); opacity: 0; pointer-events: none; padding: 12px 16px; max-width: calc(100vw - 30px); border: 1px solid var(--line); border-radius: 12px; background: #252835; color: var(--text); font-size: 12px; transition: .2s ease; box-shadow: 0 12px 35px #0006; }
.toast.show { transform: translate(-50%, 0); opacity: 1; }
@media (max-width: 720px) {
  .app-shell { padding: 0; display: block; }
  .chat-screen { width: 100%; height: 100dvh; min-height: 0; border-radius: 0; border: 0; grid-template-columns: 1fr; }
  .sidebar { border-right: 0; border-bottom: 1px solid var(--line); max-height: 44dvh; }
  .sidebar-header { padding: 15px 16px 12px; }
  .search-area { padding: 12px 14px 5px; }
  .search-results { max-height: 90px; }
  .section-heading { padding: 9px 18px 4px; }
  .conversation-list { max-height: 100px; }
  .chat-panel { min-height: 0; height: 56dvh; }
  .chat-header { padding: 12px 14px; }
  .call-button { font-size: 11px; padding: 8px 9px; }
  .call-button span { display: none; }
  .messages { padding: 15px 12px; }
  .message-form { padding: 10px 12px 12px; }
  .auth-screen { padding: 36px 20px; }
}
