*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #0f1117;
  --surface: #1a1d27;
  --surface2: #22263a;
  --border: #2e3350;
  --accent: #6c63ff;
  --accent-hover: #5a52e0;
  --text: #e8eaf6;
  --text-muted: #8b90b0;
  --you-bg: #1e2d4a;
  --them-bg: #1e3a2a;
  --you-border: #2a5298;
  --them-border: #2a7a45;
  --danger: #e05555;
  --success: #4caf50;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
}

body {
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

/* ── Landing page ── */
.landing {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 2rem;
  gap: 2.5rem;
}

.landing-logo {
  text-align: center;
}

.landing-logo h1 {
  font-size: 2.8rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  background: linear-gradient(135deg, #6c63ff 0%, #a78bfa 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.landing-logo p {
  color: var(--text-muted);
  margin-top: 0.5rem;
  font-size: 1.05rem;
}

.landing-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 2rem;
  width: 100%;
  max-width: 420px;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.landing-card h2 {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-size: 0.8rem;
  margin-bottom: 0.25rem;
}

.divider {
  display: flex;
  align-items: center;
  gap: 1rem;
  color: var(--text-muted);
  font-size: 0.85rem;
}
.divider::before, .divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--border);
}

.join-form {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.join-form input { min-width: 0; }
.join-form .btn { flex-shrink: 0; }

input[type="text"], input[type="url"] {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  padding: 0.7rem 1rem;
  font-size: 16px;
  flex: 1;
  outline: none;
  transition: border-color 0.2s;
}

input[type="text"]:focus, input[type="url"]:focus {
  border-color: var(--accent);
}

input::placeholder { color: var(--text-muted); }

.error-msg { color: #e05555; font-size: 0.85rem; }

.btn {
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.95rem;
  font-weight: 600;
  padding: 0.75rem 1.5rem;
  transition: background 0.2s, transform 0.1s;
  white-space: nowrap;
}

.btn:active { transform: scale(0.97); }

.btn-primary {
  background: var(--accent);
  color: #fff;
  width: 100%;
}
.btn-primary:hover { background: var(--accent-hover); }

.btn-secondary {
  background: var(--surface2);
  color: var(--text);
  border: 1px solid var(--border);
}
.btn-secondary:hover { background: var(--border); }

.btn-danger {
  background: var(--danger);
  color: #fff;
}
.btn-danger:hover { background: #c44040; }

.btn-icon {
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 50%;
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  padding: 0;
  transition: background 0.2s;
}
.btn-icon:hover { background: var(--border); }
.btn-icon.active {
  background: var(--accent);
  border-color: var(--accent);
}
.btn-icon.muted {
  background: var(--danger);
  border-color: var(--danger);
}

/* ── Room / call page ── */
.call-page {
  display: grid;
  grid-template-rows: 1fr auto auto;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
}

/* Video area */
.video-area {
  position: relative;
  background: #000;
  overflow: hidden;
}

#remote-video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

#local-video {
  position: absolute;
  bottom: 1rem;
  right: 1rem;
  width: 160px;
  height: 120px;
  border-radius: 10px;
  object-fit: cover;
  border: 2px solid var(--border);
  background: var(--surface2);
  z-index: 10;
}

.video-placeholder {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  color: var(--text-muted);
  background: var(--surface);
}

.avatar {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  background: var(--surface2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
  border: 2px solid var(--border);
}

.status-badge {
  font-size: 0.8rem;
  padding: 0.25rem 0.75rem;
  border-radius: 20px;
  background: var(--surface2);
  border: 1px solid var(--border);
}
.status-badge.connecting { color: #ffa726; border-color: #ffa726; }
.status-badge.connected { color: var(--success); border-color: var(--success); }
.status-badge.waiting { color: var(--text-muted); }
.status-badge.disconnected { color: var(--danger); border-color: var(--danger); }

/* Captions */
.captions-area {
  background: var(--surface);
  border-top: 1px solid var(--border);
  height: 140px;
  overflow-y: auto;
  padding: 0.6rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  scroll-behavior: smooth;
  flex-shrink: 0;
}

.captions-area:empty::before {
  content: "Captions will appear here once the call starts...";
  color: var(--text-muted);
  font-size: 0.85rem;
  font-style: italic;
}

.caption {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  max-width: 85%;
  animation: fadeIn 0.2s ease;
}

.caption.you { align-self: flex-end; align-items: flex-end; }
.caption.them { align-self: flex-start; align-items: flex-start; }

.caption-bubble {
  padding: 0.4rem 0.75rem;
  border-radius: 12px;
  font-size: 0.9rem;
  line-height: 1.4;
}

.caption.you .caption-original {
  background: var(--you-bg);
  border: 1px solid var(--you-border);
  border-radius: 12px 12px 2px 12px;
}

.caption.them .caption-original {
  background: var(--them-bg);
  border: 1px solid var(--them-border);
  border-radius: 12px 12px 12px 2px;
}

.caption-translated {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-style: italic;
  padding: 0 0.5rem;
}

/* Controls bar */
.controls {
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding: 0.6rem 1rem;
  display: grid;
  grid-template-rows: auto auto;
  gap: 0.5rem;
  flex-shrink: 0;
}

.controls-center {
  display: flex;
  gap: 0.75rem;
  align-items: center;
  justify-content: center;
}

.lang-select-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  font-size: 0.85rem;
  color: var(--text-muted);
}

select {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  padding: 0.45rem 0.75rem;
  font-size: 16px;
  outline: none;
  cursor: pointer;
}

select:focus { border-color: var(--accent); }

/* Share link */
.share-bar {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.6rem 1rem;
  font-size: 0.85rem;
  color: var(--text-muted);
  flex-wrap: wrap;
}

.share-bar span { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.share-bar .btn { padding: 0.35rem 0.75rem; font-size: 0.8rem; }

/* Utils */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: translateY(0); }
}

.hidden { display: none !important; }

/* Responsive */
@media (max-width: 700px) {
  input, select, textarea { font-size: 16px; }

  /* Home page */
  .landing { padding: 1.5rem; gap: 1.5rem; }
  .landing-logo h1 { font-size: 2rem; }
  .landing-card { padding: 1.5rem; }
  .join-form { flex-direction: column; }
  .join-form .btn { width: 100%; }

  /* Room page */
  #local-video { width: 90px; height: 68px; bottom: 0.5rem; right: 0.5rem; }
  .captions-area { height: 120px; padding: 0.5rem 0.75rem; }
  .controls { padding: 0.5rem 0.75rem; gap: 0.4rem; }
  .controls-center { gap: 0.6rem; }
  .lang-select-wrap span { display: none; }
}
