:root {
  --bg: #0f1115;
  --panel: #171a21;
  --panel-2: #1f232c;
  --text: #e8eaf0;
  --muted: #9aa1ae;
  --accent: #5b8cff;
  --danger: #ff5b6e;
  --border: #2a2f3a;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

.hidden { display: none !important; }

/* Gate */
.overlay {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(circle at 50% 20%, #1c2030, #090a0d);
  padding: 16px;
  z-index: 50;
}

.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 28px;
  max-width: 420px;
  width: 100%;
}

.card h1 { margin: 0 0 8px; font-size: 28px; }
.card p { color: var(--muted); line-height: 1.5; font-size: 14px; }

.check {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  font-size: 13px;
  color: var(--muted);
  margin: 16px 0;
}
.check a { color: var(--accent); }

#gate-enter, .primary {
  width: 100%;
  padding: 12px;
  border-radius: 10px;
  border: none;
  background: var(--accent);
  color: #fff;
  font-weight: 600;
  font-size: 16px;
  cursor: pointer;
}
#gate-enter:disabled { opacity: .4; cursor: not-allowed; }

/* App layout */
#app { display: flex; flex-direction: column; height: 100%; }

header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
}
.brand { font-weight: 700; }
.status { font-size: 13px; color: var(--muted); }

main {
  flex: 1;
  display: flex;
  gap: 1px;
  min-height: 0;
  background: var(--border);
}

.video-area {
  flex: 2;
  position: relative;
  background: #000;
  min-width: 0;
}

#remote-video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  background: #000;
}

#local-video {
  position: absolute;
  bottom: 86px;
  right: 16px;
  width: 140px;
  aspect-ratio: 4/3;
  object-fit: cover;
  border-radius: 10px;
  border: 2px solid var(--border);
  background: #111;
}

.idle-panel {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  background: rgba(10, 11, 14, 0.75);
}
.idle-panel .primary { width: 200px; }
.idle-panel .hint { color: var(--muted); font-size: 13px; }

.controls {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  display: flex;
  gap: 8px;
  justify-content: center;
  padding: 14px;
  background: linear-gradient(transparent, rgba(0,0,0,.55));
}

.icon-btn {
  padding: 10px 14px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--panel-2);
  color: var(--text);
  cursor: pointer;
  font-size: 14px;
}
.icon-btn.danger { border-color: #4a2630; color: var(--danger); }
.icon-btn:hover { filter: brightness(1.15); }

.chat-area {
  flex: 1;
  background: var(--panel);
  display: flex;
  flex-direction: column;
  min-width: 260px;
}

.chat-log {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
  font-size: 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.chat-log .msg { max-width: 85%; padding: 6px 10px; border-radius: 10px; }
.chat-log .me { align-self: flex-end; background: var(--accent); color: #fff; }
.chat-log .them { align-self: flex-start; background: var(--panel-2); }
.chat-log .sys { align-self: center; color: var(--muted); font-size: 12px; }

.chat-form {
  display: flex;
  border-top: 1px solid var(--border);
}
.chat-form input {
  flex: 1;
  padding: 12px;
  background: transparent;
  border: none;
  color: var(--text);
  outline: none;
}
.chat-form button {
  padding: 0 16px;
  border: none;
  background: transparent;
  color: var(--accent);
  font-weight: 600;
  cursor: pointer;
}

@media (max-width: 760px) {
  main { flex-direction: column; }
  .chat-area { max-height: 40%; }
}
