:root {
  --bg: #0f1115;
  --panel: #1a1d24;
  --panel-2: #252a33;
  --text: #e8eaed;
  --muted: #9aa0a6;
  --accent: #3b82f6;
  --danger: #ef4444;
  --speaking: #22c55e;
  --radius: 12px;
}

* { 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; }

button {
  font: inherit;
  color: inherit;
  cursor: pointer;
  border: 0;
}

/* ---- Lobi ---- */
.lobby {
  min-height: 100%;
  display: grid;
  place-items: center;
  padding: 16px;
}

.card {
  width: 100%;
  max-width: 420px;
  background: var(--panel);
  border-radius: var(--radius);
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.card h1 { margin: 0; font-size: 22px; }

.card label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 14px;
  color: var(--muted);
}

.card input, .chat-form input {
  background: var(--panel-2);
  border: 1px solid transparent;
  color: var(--text);
  border-radius: 8px;
  padding: 10px 12px;
  font: inherit;
}

.card input:focus, .chat-form input:focus {
  outline: none;
  border-color: var(--accent);
}

.preview {
  position: relative;
  aspect-ratio: 16 / 9;
  background: #000;
  border-radius: var(--radius);
  overflow: hidden;
}

.preview video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transform: scaleX(-1);
}

.preview-off {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: var(--muted);
}

.preview-controls {
  display: flex;
  justify-content: center;
  gap: 12px;
}

.primary {
  background: var(--accent);
  padding: 12px;
  border-radius: 8px;
  font-weight: 600;
}

.primary:disabled { opacity: .6; cursor: default; }

.error { color: var(--danger); margin: 0; font-size: 14px; }

/* ---- Görüşme ---- */
.call {
  height: 100%;
  display: flex;
  flex-direction: column;
}

.topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  background: var(--panel);
}

.room-label { font-weight: 600; }

.link-btn {
  background: var(--panel-2);
  padding: 6px 10px;
  border-radius: 8px;
  font-size: 14px;
}

.status { margin-left: auto; color: var(--muted); font-size: 14px; }

.stage {
  flex: 1;
  display: flex;
  min-height: 0;
}

.grid {
  flex: 1;
  display: grid;
  gap: 8px;
  padding: 8px;
  grid-template-columns: repeat(var(--cols, 1), 1fr);
  grid-auto-rows: 1fr;
  min-height: 0;
}

.tile {
  position: relative;
  background: #000;
  border-radius: var(--radius);
  overflow: hidden;
  min-height: 0;
  outline: 3px solid transparent;
  outline-offset: -3px;
  transition: outline-color .15s;
}

.tile.speaking { outline-color: var(--speaking); }

.tile video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.tile.local video { transform: scaleX(-1); }
.tile.screen video { object-fit: contain; transform: none; }

.avatar {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background: var(--panel-2);
  font-size: 48px;
  font-weight: 600;
}

.tile-info {
  position: absolute;
  left: 8px;
  bottom: 8px;
  display: flex;
  gap: 6px;
  align-items: center;
  background: rgba(0, 0, 0, .55);
  padding: 4px 8px;
  border-radius: 6px;
  font-size: 13px;
}

.tile-conn {
  position: absolute;
  top: 8px;
  right: 8px;
  background: rgba(0, 0, 0, .55);
  padding: 4px 8px;
  border-radius: 6px;
  font-size: 12px;
  color: var(--muted);
}

.controls {
  display: flex;
  justify-content: center;
  gap: 12px;
  padding: 12px;
  background: var(--panel);
}

.round {
  position: relative;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--panel-2);
  font-size: 20px;
}

.round.off { background: var(--danger); }
.round.active { background: var(--accent); }
.round.danger { background: var(--danger); }

.badge {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--danger);
}

/* ---- Sohbet ---- */
.chat {
  width: 320px;
  display: flex;
  flex-direction: column;
  background: var(--panel);
  border-left: 1px solid var(--panel-2);
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.chat-msg .meta { font-size: 12px; color: var(--muted); }
.chat-msg .text { white-space: pre-wrap; word-break: break-word; }
.chat-msg.system { color: var(--muted); font-size: 13px; font-style: italic; }

.chat-form {
  display: flex;
  gap: 8px;
  padding: 12px;
}

.chat-form input { flex: 1; min-width: 0; }

.chat-form button {
  background: var(--accent);
  border-radius: 8px;
  padding: 0 12px;
}

@media (max-width: 700px) {
  .chat {
    position: fixed;
    inset: 0 0 72px 0;
    width: auto;
    z-index: 10;
  }
  .link-btn { font-size: 12px; }
}
