:root {
  color-scheme: dark;
  --bg: #07111d;
  --bg-2: #0d1727;
  --panel: rgba(12, 20, 35, 0.84);
  --line: rgba(159, 184, 255, 0.15);
  --text: #eef4ff;
  --muted: #8ca1c5;
  --accent: #70f0c1;
  --accent-2: #79a7ff;
  --chip: rgba(255, 255, 255, 0.08);
  --bubble-me: linear-gradient(135deg, #2d6cff, #79a7ff);
  --bubble-them: rgba(255, 255, 255, 0.08);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: "Manrope", system-ui, sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(121, 167, 255, 0.16), transparent 28%),
    radial-gradient(circle at bottom right, rgba(112, 240, 193, 0.12), transparent 25%),
    linear-gradient(165deg, var(--bg), var(--bg-2));
}

button, input, textarea { font: inherit; }
button {
  border: 0;
  border-radius: 999px;
  background: var(--chip);
  color: var(--text);
  padding: 0.78rem 1rem;
  cursor: pointer;
}

.frame { min-height: 100vh; padding: 18px; }
.join-screen {
  min-height: calc(100vh - 36px);
  display: grid;
  place-items: center;
}
.join-card, .sidebar, .chat {
  background: var(--panel);
  border: 1px solid var(--line);
  backdrop-filter: blur(22px);
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.38);
}
.join-card {
  width: min(100%, 440px);
  border-radius: 28px;
  padding: 24px;
}
.brand { display: flex; gap: 12px; align-items: center; margin-bottom: 20px; }
.brand-mark {
  width: 54px; height: 54px; display: grid; place-items: center;
  border-radius: 18px; background: linear-gradient(135deg, var(--accent-2), var(--accent));
  color: #06101b; font-weight: 800;
}
.brand h1 { margin: 0 0 4px; font-size: 1.5rem; }
.brand p { margin: 0; color: var(--muted); }
.field-group { display: grid; gap: 8px; margin-bottom: 14px; }
.segmented { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 14px; }
.seg { background: rgba(255,255,255,0.04); }
.seg.active { background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #05111c; font-weight: 800; }
.field-group label, .panel-title { color: var(--muted); font-size: 0.85rem; text-transform: uppercase; letter-spacing: 0.14em; }
.field-group input, .search input, .composer textarea {
  width: 100%; border-radius: 18px; border: 1px solid var(--line); background: rgba(255,255,255,0.05);
  color: var(--text); padding: 0.95rem 1rem; outline: none;
}
.primary-btn { background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #05111c; font-weight: 800; }
.hint { color: var(--muted); margin: 14px 0 0; font-size: 0.92rem; }
.auth-message {
  min-height: 1.2rem;
  margin: 12px 0 0;
  color: #ffb4a8;
  font-size: 0.92rem;
}
.auth-message.ok { color: var(--accent); }

.app-screen {
  display: grid; grid-template-columns: minmax(280px, 360px) 1fr; gap: 18px;
  min-height: calc(100vh - 36px);
}
.sidebar, .chat { border-radius: 28px; }
.sidebar { padding: 18px; display: grid; gap: 16px; min-height: 0; }
.topbar, .actions, .status-chip, .call-actions { display: flex; align-items: center; gap: 10px; }
.topbar { justify-content: space-between; }
.room-name, .chat-title h2 { font-weight: 800; letter-spacing: -0.03em; }
.room-meta, .chat-title p, .member-meta, .message-time, .call-status { color: var(--muted); }
.status-chip { padding: 10px 12px; border-radius: 16px; background: rgba(255,255,255,0.05); font-size: 0.92rem; }
.session-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border-radius: 16px;
  background: rgba(255,255,255,0.05);
  font-size: 0.92rem;
}
.dot { width: 10px; height: 10px; border-radius: 50%; background: #ff8a80; }
.dot[data-online="true"] { background: var(--accent); }
.session-dot[data-online="true"] { box-shadow: 0 0 0 4px rgba(112, 240, 193, 0.14); }
.session-dot[data-online="false"] { box-shadow: 0 0 0 4px rgba(255, 138, 128, 0.14); }
.actions { flex-wrap: wrap; }
.search { display: block; }
.panel-title { margin-top: 2px; }
.members-list { display: grid; gap: 10px; overflow: auto; }
.member { display: flex; gap: 12px; align-items: center; padding: 10px 12px; border-radius: 18px; background: rgba(255,255,255,0.04); }
.avatar {
  width: 42px; height: 42px; border-radius: 16px; display: grid; place-items: center;
  background: linear-gradient(135deg, var(--accent-2), var(--accent)); color: #06111b; font-weight: 800;
}
.member-copy { min-width: 0; }
.member-name { font-weight: 700; }

.call-panel { display: grid; gap: 10px; }
.history-list { display: grid; gap: 8px; max-height: 180px; overflow: auto; }
.history-item {
  padding: 10px 12px;
  border-radius: 16px;
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--line);
}
.history-item strong { display: block; margin-bottom: 4px; }
.history-meta { color: var(--muted); font-size: 0.86rem; }
.incoming-call {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(0, 0, 0, 0.34);
  padding: 18px;
}
.incoming-card {
  width: min(100%, 360px);
  padding: 20px;
  border-radius: 24px;
  background: rgba(12, 20, 35, 0.96);
  border: 1px solid var(--line);
  box-shadow: 0 30px 80px rgba(0,0,0,0.45);
}
.profile-modal {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(0, 0, 0, 0.34);
  padding: 18px;
}
.profile-card {
  width: min(100%, 420px);
  padding: 20px;
  border-radius: 24px;
  background: rgba(12, 20, 35, 0.96);
  border: 1px solid var(--line);
  box-shadow: 0 30px 80px rgba(0,0,0,0.45);
}
.profile-preview { display: flex; gap: 12px; align-items: center; margin-bottom: 16px; }
.profile-name { font-size: 1.1rem; font-weight: 800; }
.profile-username { color: var(--muted); }
.profile-session { color: var(--muted); margin-top: 4px; font-size: 0.88rem; }
.video-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 10px;
}
video {
  width: 100%; aspect-ratio: 4 / 3; background: #04070c; border-radius: 18px; object-fit: cover;
  border: 1px solid var(--line);
}

.chat {
  display: grid; grid-template-rows: auto 1fr auto; min-width: 0; min-height: 0;
}
.chat-header { padding: 18px 20px; border-bottom: 1px solid var(--line); }
.messages { padding: 20px; overflow: auto; display: grid; gap: 12px; align-content: end; }
.message-row { display: flex; }
.message-row.me { justify-content: end; }
.bubble {
  max-width: min(640px, 80%); padding: 0.9rem 1rem; border-radius: 20px; border: 1px solid var(--line);
  line-height: 1.45;
}
.message-row.me .bubble { background: var(--bubble-me); color: #fff; border-bottom-right-radius: 8px; }
.message-row.them .bubble, .message-row .bubble { background: var(--bubble-them); border-bottom-left-radius: 8px; }
.bubble-name { font-size: 0.8rem; color: var(--accent); margin-bottom: 4px; font-weight: 700; }
.composer { display: grid; grid-template-columns: 1fr auto; gap: 10px; padding: 18px 20px 20px; border-top: 1px solid var(--line); }
.composer textarea { resize: none; min-height: 52px; max-height: 160px; }

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0, 0, 0, 0); border: 0;
}

@media (max-width: 920px) {
  .app-screen { grid-template-columns: 1fr; }
}

@media (max-width: 720px) {
  .frame { padding: 0; }
  .join-screen { min-height: 100vh; padding: 18px; }
  .sidebar, .chat { border-radius: 0; }
  .app-screen { min-height: 100vh; }
  .video-grid { grid-template-columns: 1fr; }
}
