:root {
  --bg: #1e1f22;
  --panel: #2b2d31;
  --panel2: #313338;
  --text: #e6e7ea;
  --muted: #9aa0a8;
  --accent: #e0a458;
  --accent-2: #c98a3c;
  --danger: #e5484d;
  --ok: #3ccf7a;
  --radius: 12px;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.error { color: var(--danger); min-height: 1.2em; margin: 0; }
button, input, select { font: inherit; color: inherit; }

/* ---- Giriş ---- */
#join { display: grid; place-items: center; min-height: 100%; padding: 24px; }
.card { width: min(400px, 100%); background: var(--panel); padding: 28px; border-radius: 16px;
  display: flex; flex-direction: column; gap: 14px; box-shadow: 0 10px 40px #0006; }
.card h1 { margin: 0; font-size: 28px; }
.card p { margin: 0; }
.card label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--muted); }
.card label.row { flex-direction: row; align-items: center; gap: 8px; color: var(--text); }
.card input:not([type=checkbox]), .card select { background: var(--bg); border: 1px solid #0000;
  border-radius: 8px; padding: 10px 12px; outline: none; }
.card input:focus, .card select:focus { border-color: var(--accent); }
details { display: flex; flex-direction: column; gap: 12px; }
details[open] > summary { margin-bottom: 12px; }
details > label + label { margin-top: 12px; }
summary { cursor: pointer; color: var(--muted); font-size: 13px; }
.primary { background: var(--accent); color: #1b1408; border: 0; border-radius: 8px; padding: 12px;
  font-weight: 600; cursor: pointer; }
.primary:hover { background: var(--accent-2); }
.primary:disabled { opacity: .6; cursor: wait; }

.avatar-pick { display: flex; align-items: center; gap: 16px; }
.avatar-preview { width: 72px; height: 72px; border-radius: 50%; display: grid; place-items: center; flex: none;
  font-size: 26px; font-weight: 700; color: #fff; background: var(--panel2) center / cover no-repeat; }
.avatar-actions { display: flex; flex-direction: column; align-items: flex-start; gap: 4px; }
.card label.file-btn { display: inline-block; background: var(--panel2); color: var(--text); padding: 8px 14px;
  border-radius: 8px; cursor: pointer; font-size: 14px; }
.card label.file-btn:hover { background: #3a3c42; }
.has-photo { background-size: cover !important; background-position: center !important; color: transparent !important; }
.link { background: none; border: 0; color: var(--muted); cursor: pointer; padding: 4px; }
.link:hover { color: var(--text); }

/* ---- Lobi ---- */
#lobby { display: grid; place-items: start center; min-height: 100%; padding: 24px; }
.lobby-card { width: min(520px, 100%); margin-top: 6vh; }
.lobby-head { display: flex; align-items: center; justify-content: space-between; }
.icon-btn { background: var(--panel2); border: 0; border-radius: 10px; width: 40px; height: 40px; font-size: 18px;
  cursor: pointer; }
.icon-btn:hover { background: #3a3c42; }
#roomList { display: flex; flex-direction: column; gap: 10px; }
.room { text-align: left; background: var(--panel2); border: 1px solid transparent; border-radius: 12px;
  padding: 12px 14px; cursor: pointer; display: flex; flex-direction: column; gap: 8px; }
.room:hover { border-color: var(--accent); }
.room:disabled { opacity: .6; cursor: wait; }
.room-head { display: flex; align-items: center; gap: 8px; }
.room-name { font-weight: 600; }
.room-name::before { content: '🔊 '; }
.room-count { font-size: 13px; }
.room-join { margin-left: auto; color: var(--accent); font-size: 13px; font-weight: 600; }
.room.active { border-color: #3ccf7a55; }
.members { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.members:empty { display: none; }
.members li { display: flex; align-items: center; gap: 8px; font-size: 14px; }
.members .mini-avatar { width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center;
  font-size: 11px; font-weight: 700; color: #fff; flex: none; }
.members .st { margin-left: auto; font-size: 13px; }
.new-room { display: flex; gap: 8px; }
.new-room input { flex: 1; min-width: 0; }
.new-room .primary { padding: 10px 16px; }

/* ---- Görüşme ---- */
#call { height: 100%; display: grid; grid-template-columns: 1fr 320px; grid-template-rows: 1fr auto;
  grid-template-areas: "stage chat" "controls controls"; }
#call.no-chat { grid-template-columns: 1fr 0; }
#call.no-chat #chat { display: none; }
#stage { grid-area: stage; overflow: auto; padding: 12px; }
#grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); align-content: center;
  min-height: 100%; }

.tile { position: relative; background: var(--panel2); border-radius: var(--radius); overflow: hidden;
  aspect-ratio: 16 / 9; outline: 3px solid transparent; transition: outline-color .12s; }
.tile.speaking { outline-color: var(--ok); }
.tile video { width: 100%; height: 100%; object-fit: cover; display: none; background: #000; }
.tile.screen video { object-fit: contain; }
.tile.self:not(.screen) video { transform: scaleX(-1); }
.tile.has-video video { display: block; }
.tile.has-video .avatar { display: none; }
.tile.screen { grid-column: 1 / -1; }
.tile:fullscreen { border-radius: 0; outline: 0; }
.tile:fullscreen video { object-fit: contain; }
.avatar { position: absolute; inset: 0; margin: auto; width: 84px; height: 84px; border-radius: 50%;
  display: grid; place-items: center; font-size: 32px; font-weight: 700; color: #fff; user-select: none; }
.label { position: absolute; left: 8px; bottom: 8px; background: #000a; padding: 3px 9px; border-radius: 6px;
  font-size: 13px; display: flex; gap: 6px; max-width: calc(100% - 16px); }
.label .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tile .conn { position: absolute; top: 8px; left: 8px; font-size: 12px; background: #000a; padding: 2px 8px;
  border-radius: 6px; color: var(--muted); }
.vol { position: absolute; right: 8px; bottom: 10px; width: 90px; opacity: 0; transition: opacity .15s;
  accent-color: var(--accent); }
.tile:hover .vol { opacity: 1; }

/* ---- Sohbet ---- */
#chat { grid-area: chat; background: var(--panel); display: flex; flex-direction: column; min-height: 0;
  border-left: 1px solid #0003; }
#chat header { padding: 14px 16px; font-weight: 600; border-bottom: 1px solid #0003; }
#messages { flex: 1; overflow-y: auto; padding: 12px 16px; display: flex; flex-direction: column; gap: 10px; }
.msg .who { font-weight: 600; font-size: 13px; }
.msg .time { color: var(--muted); font-size: 11px; margin-left: 6px; }
.msg .text { white-space: pre-wrap; word-wrap: break-word; }
.msg.system { color: var(--muted); font-size: 12px; font-style: italic; }
#chatForm { padding: 12px; }
#chatInput { width: 100%; background: var(--bg); border: 0; border-radius: 8px; padding: 10px 12px; outline: none; }

/* ---- Kontroller ---- */
#controls { grid-area: controls; display: flex; align-items: center; gap: 12px; padding: 10px 16px;
  background: var(--panel); border-top: 1px solid #0003; }
#controls #status, #controls .spacer { flex: 1; font-size: 13px; }
.buttons { display: flex; gap: 8px; }
.buttons button { background: var(--panel2); border: 0; border-radius: 10px; padding: 6px 12px; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; min-width: 64px; }
.buttons button span { font-size: 20px; }
.buttons button small { font-size: 11px; color: var(--muted); }
.buttons button:hover { background: #3a3c42; }
.buttons button.off { background: #5a2427; }
.buttons button.on { background: #2f4a37; }
.buttons button.danger { background: var(--danger); }
.buttons button.danger small { color: #fff; }

@media (max-width: 800px) {
  #call { grid-template-columns: 1fr; grid-template-rows: 1fr 40% auto;
    grid-template-areas: "stage" "chat" "controls"; }
  #call.no-chat { grid-template-rows: 1fr 0 auto; }
  #controls #status, #controls .spacer { display: none; }
  .buttons { width: 100%; justify-content: space-between; }
  .buttons button { min-width: 0; flex: 1; padding: 6px 4px; }
}
