:root {
  --bg: #050506;
  --panel: rgba(255, 255, 255, 0.06);
  --panel-strong: rgba(255, 255, 255, 0.1);
  --text: #f8f7f2;
  --muted: rgba(248, 247, 242, 0.62);
  --line: rgba(255, 255, 255, 0.14);
  --hot: #ff3b23;
  --hot-2: #ff8a3d;
  --ok: #d8ff5f;
  --shadow: 0 24px 80px rgba(0, 0, 0, 0.55);
  --radius: 28px;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { min-height: 100%; }
body {
  margin: 0;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at 20% 10%, rgba(255, 59, 35, 0.22), transparent 35%),
    radial-gradient(circle at 82% 18%, rgba(255, 138, 61, 0.14), transparent 32%),
    linear-gradient(135deg, #050506 0%, #101011 55%, #050506 100%);
  color: var(--text);
  overflow-x: hidden;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(255,255,255,.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,.04) 1px, transparent 1px);
  background-size: 44px 44px;
  mask-image: linear-gradient(to bottom, rgba(0,0,0,.65), transparent 85%);
}

button, input, textarea { font: inherit; }
button { cursor: pointer; }

.gate-body {
  display: grid;
  place-items: center;
  padding: 28px;
}

.gate-shell {
  width: min(1120px, 100%);
  min-height: min(720px, calc(100vh - 56px));
  display: grid;
  grid-template-columns: 1.15fr .85fr;
  gap: 22px;
}

.brand-panel, .login-card, .panel, .chat-area, .sidebar {
  border: 1px solid var(--line);
  background: linear-gradient(145deg, rgba(255,255,255,.08), rgba(255,255,255,.035));
  box-shadow: var(--shadow);
  backdrop-filter: blur(22px);
}

.brand-panel {
  position: relative;
  overflow: hidden;
  border-radius: var(--radius);
  padding: clamp(28px, 6vw, 72px);
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
}

.brand-panel h1 {
  margin: 0;
  font-size: clamp(3.2rem, 9vw, 7.8rem);
  letter-spacing: -.08em;
  line-height: .86;
  text-transform: uppercase;
}

.logo-block strong span, .brand-panel h1 span { color: var(--hot); }

.lead {
  max-width: 580px;
  color: var(--muted);
  font-size: clamp(1.1rem, 2vw, 1.45rem);
  margin: 20px 0 0;
}

.eyebrow, .label {
  text-transform: uppercase;
  letter-spacing: .18em;
  font-weight: 800;
  color: var(--hot-2);
  font-size: .76rem;
}

.signal-radar {
  position: absolute;
  width: min(55vw, 620px);
  aspect-ratio: 1;
  right: -120px;
  top: -110px;
  opacity: .74;
}

.signal-radar span {
  position: absolute;
  inset: calc(var(--i, 0) * 12%);
  border: 1px solid rgba(255,255,255,.18);
  border-radius: 50%;
  animation: radarPulse 3.5s ease-in-out infinite;
}
.signal-radar span:nth-child(1) { --i: 0; }
.signal-radar span:nth-child(2) { --i: 1; animation-delay: .2s; }
.signal-radar span:nth-child(3) { --i: 2; animation-delay: .4s; }
.signal-radar span:nth-child(4) { --i: 3; animation-delay: .6s; }
.signal-radar::after {
  content: "";
  position: absolute;
  inset: 50% 0 0 50%;
  transform-origin: 0 0;
  background: linear-gradient(45deg, rgba(255,59,35,.0), rgba(255,59,35,.34), rgba(255,255,255,.0));
  clip-path: polygon(0 0, 100% 9%, 100% 0);
  animation: sweep 5s linear infinite;
}
.dot {
  position: absolute;
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--text);
  box-shadow: 0 0 20px rgba(255,255,255,.8);
}
.d1 { top: 28%; left: 42%; }
.d2 { top: 61%; left: 72%; animation: blink 1.4s infinite; }
.d3 { top: 46%; left: 23%; animation: blink 1.8s infinite; }
.d4 { top: 75%; left: 39%; animation: blink 2.2s infinite; }

.login-card {
  border-radius: var(--radius);
  padding: clamp(24px, 4vw, 44px);
  align-self: center;
}
.login-card h2 { margin: 20px 0 8px; font-size: clamp(2rem, 4vw, 3.4rem); letter-spacing: -.06em; }
.login-card p { color: var(--muted); }
.status-pill, .connection-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 1px solid rgba(216,255,95,.32);
  background: rgba(216,255,95,.08);
  color: var(--ok);
  border-radius: 999px;
  padding: 8px 12px;
  font-weight: 800;
  font-size: .82rem;
}
.status-pill span {
  width: 8px; height: 8px; border-radius: 50%; background: var(--ok); box-shadow: 0 0 14px var(--ok);
}
form label {
  display: grid;
  gap: 8px;
  margin-top: 18px;
  color: rgba(248,247,242,.8);
  font-weight: 700;
}
input, textarea {
  width: 100%;
  border: 1px solid var(--line);
  background: rgba(0,0,0,.34);
  color: var(--text);
  border-radius: 18px;
  padding: 15px 16px;
  outline: none;
}
input:focus, textarea:focus { border-color: rgba(255, 138, 61, .75); box-shadow: 0 0 0 4px rgba(255, 59, 35, .14); }
.login-card button, .composer button {
  width: 100%;
  margin-top: 22px;
  border: 0;
  border-radius: 18px;
  padding: 15px 18px;
  background: linear-gradient(135deg, var(--hot), var(--hot-2));
  color: white;
  font-weight: 1000;
  text-transform: uppercase;
  letter-spacing: .08em;
}
.error-box { min-height: 1.4em; color: #ffb2a7 !important; }

.portal-body { min-height: 100vh; padding: 18px; }
.app-shell {
  min-height: calc(100vh - 36px);
  display: grid;
  grid-template-columns: 340px 1fr;
  gap: 18px;
}
.sidebar {
  border-radius: 26px;
  padding: 18px;
  display: grid;
  align-content: start;
  gap: 16px;
}
.logo-block {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 4px 14px;
}
.logo-block strong {
  display: block;
  font-size: 1.35rem;
  letter-spacing: -.05em;
}
.logo-block small { color: var(--muted); }
.mini-transmitter {
  width: 42px;
  height: 42px;
  border-radius: 14px;
  border: 1px solid var(--line);
  display: grid;
  place-items: center;
  background: rgba(255,255,255,.06);
}
.mini-transmitter span {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--hot);
  box-shadow: 0 0 0 8px rgba(255,59,35,.15), 0 0 32px rgba(255,59,35,.8);
}
.panel {
  border-radius: 22px;
  padding: 16px;
  box-shadow: none;
}
.identity-panel h2 { margin: 0 0 12px; }
.ghost-btn {
  border: 1px solid var(--line);
  color: var(--text);
  background: transparent;
  border-radius: 14px;
  padding: 10px 12px;
  font-weight: 800;
}
.room-list, .online-list { display: grid; gap: 8px; }
.room-btn, .user-btn {
  width: 100%;
  text-align: left;
  border: 1px solid transparent;
  border-radius: 16px;
  padding: 12px;
  color: var(--text);
  background: rgba(255,255,255,.045);
}
.room-btn:hover, .user-btn:hover, .room-btn.active, .user-btn.active {
  border-color: rgba(255,138,61,.44);
  background: rgba(255,59,35,.12);
}
.room-btn strong, .user-btn strong { display: block; }
.room-btn small, .user-btn small { color: var(--muted); }
.chat-area {
  border-radius: 26px;
  display: grid;
  grid-template-rows: auto 1fr auto;
  min-width: 0;
  overflow: hidden;
}
.chat-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 18px;
  padding: 22px;
  border-bottom: 1px solid var(--line);
}
.chat-header h1 { margin: 2px 0 0; font-size: clamp(1.8rem, 4vw, 3rem); letter-spacing: -.06em; }
.message-list {
  padding: 22px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.empty-state {
  margin: auto;
  max-width: 520px;
  text-align: center;
  color: var(--muted);
  border: 1px dashed var(--line);
  border-radius: 24px;
  padding: 28px;
}
.message {
  max-width: min(720px, 88%);
  display: grid;
  gap: 6px;
  align-self: flex-start;
}
.message.mine { align-self: flex-end; }
.message .bubble {
  border: 1px solid var(--line);
  background: rgba(255,255,255,.07);
  border-radius: 20px 20px 20px 6px;
  padding: 12px 14px;
  line-height: 1.45;
  white-space: pre-wrap;
  word-wrap: break-word;
}
.message.mine .bubble {
  background: linear-gradient(135deg, rgba(255,59,35,.34), rgba(255,138,61,.2));
  border-color: rgba(255,138,61,.35);
  border-radius: 20px 20px 6px 20px;
}
.meta {
  color: var(--muted);
  font-size: .78rem;
  padding: 0 4px;
}
.composer {
  display: grid;
  grid-template-columns: 1fr 140px;
  gap: 12px;
  padding: 18px;
  border-top: 1px solid var(--line);
}
.composer textarea { resize: none; min-height: 54px; max-height: 160px; }
.composer button { margin: 0; }

@keyframes sweep { to { transform: rotate(360deg); } }
@keyframes radarPulse { 50% { border-color: rgba(255,138,61,.46); transform: scale(1.018); } }
@keyframes blink { 50% { opacity: .25; transform: scale(.72); } }

@media (max-width: 900px) {
  .gate-shell, .app-shell { grid-template-columns: 1fr; }
  .gate-shell { min-height: auto; }
  .brand-panel { min-height: 420px; }
  .sidebar { order: 2; }
  .chat-area { min-height: 70vh; }
}

@media (max-width: 620px) {
  .portal-body, .gate-body { padding: 10px; }
  .app-shell { min-height: calc(100vh - 20px); gap: 10px; }
  .chat-header { align-items: flex-start; flex-direction: column; }
  .composer { grid-template-columns: 1fr; }
  .message { max-width: 96%; }
}
