:root {
  --bg: #1e1f22;
  --panel: #2b2d31;
  --panel-alt: #313338;
  --input: #383a40;
  --hover: #404249;
  --text: #f2f3f5;
  --muted: #b5bac1;
  --faint: #80848e;
  --accent: #5865f2;
  --accent-hover: #4752c4;
  --success: #23a55a;
  --danger: #da373c;
  --warning: #f0b232;
  --radius: 8px;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  overflow: hidden;
}
[hidden] { display: none !important; }
button { font: inherit; color: inherit; cursor: pointer; border: 0; background: none; }
button:disabled { cursor: not-allowed; opacity: .4; }
input { font: inherit; color: var(--text); }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.center { text-align: center; }
.spacer { flex: 1; }

/* İkonlar (inline SVG, app.js doldurur) */
i[data-icon] { display: inline-flex; width: 20px; height: 20px; }
i[data-icon] svg { width: 100%; height: 100%; }

/* Butonlar */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 14px; border-radius: 6px; font-weight: 600; font-size: 14px;
  background: var(--input); transition: background .15s;
}
.btn:hover:not(:disabled) { background: var(--hover); }
.btn.primary { background: var(--accent); color: #fff; }
.btn.primary:hover:not(:disabled) { background: var(--accent-hover); }
.btn.danger { background: var(--danger); color: #fff; }
.btn.ghost { color: var(--muted); }
.btn.block { width: 100%; justify-content: center; padding: 12px; font-size: 16px; margin-top: 20px; }
.icon-btn { padding: 6px; border-radius: 6px; color: var(--muted); }
.icon-btn:hover { background: var(--hover); }

/* Giriş */
.join { height: 100%; display: grid; place-items: center; padding: 16px; }
.card { width: 100%; max-width: 420px; background: var(--panel); border-radius: 12px; padding: 28px; }
.logo { margin: 0; text-align: center; font-size: 32px; font-weight: 800; display: flex; align-items: center; justify-content: center; gap: 10px; }
.logo-dot { width: 18px; height: 18px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 5px rgba(88,101,242,.25); }
.card label { display: block; font-size: 12px; font-weight: 700; color: var(--muted); letter-spacing: .5px; margin: 16px 0 6px; }
.card input { width: 100%; background: var(--bg); border: 1px solid transparent; border-radius: 6px; padding: 10px 12px; font-size: 16px; outline: none; }
.card input:focus { border-color: var(--accent); }
.error { color: var(--danger); margin: 14px 0 0; }

/* Oda düzeni */
.room { height: 100%; display: flex; }
.sidebar { width: 280px; flex-shrink: 0; background: var(--panel); display: flex; flex-direction: column; }
.sidebar-head { padding: 16px; border-bottom: 1px solid var(--bg); display: flex; align-items: baseline; gap: 8px; }
.room-name { font-weight: 700; font-size: 16px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.members { list-style: none; margin: 0; padding: 8px; flex: 1; overflow-y: auto; }
.member { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 10px; padding: 6px 8px; border-radius: 6px; }
.member:hover { background: var(--panel-alt); }
.member .name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.member .sub { font-size: 11px; color: var(--faint); }
.member .icons { display: flex; gap: 4px; color: var(--success); }
.member .icons .off { color: var(--danger); }
.member .icons .live { color: #fff; background: var(--danger); font-size: 10px; font-weight: 800; padding: 1px 5px; border-radius: 4px; }
.member .icons i { width: 16px; height: 16px; }
.member input[type=range] { grid-column: 2 / 4; width: 100%; accent-color: var(--accent); height: 14px; }

.avatar {
  position: relative; width: 34px; height: 34px; border-radius: 50%;
  display: grid; place-items: center; font-weight: 700; color: #fff;
  transition: box-shadow .1s;
}
.avatar.speaking { box-shadow: 0 0 0 2px var(--panel), 0 0 0 4px var(--success); }
.avatar .dot { position: absolute; right: -2px; bottom: -2px; width: 12px; height: 12px; border-radius: 50%; border: 2px solid var(--panel); background: var(--success); }
.avatar .dot.connecting { background: var(--warning); }
.avatar .dot.failed { background: var(--danger); }

.controls { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; padding: 10px; background: var(--bg); }
.ctrl { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 4px; border-radius: var(--radius); background: var(--input); font-size: 11px; font-weight: 600; }
.ctrl:hover:not(:disabled) { background: var(--hover); }
.ctrl.on { background: var(--accent); color: #fff; }
.ctrl.alert { background: var(--danger); color: #fff; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; background: var(--panel-alt); }
.topbar { height: 52px; flex-shrink: 0; display: flex; align-items: center; gap: 8px; padding: 0 16px; border-bottom: 1px solid var(--bg); }
.topbar strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Ekran paylaşım alanı */
.stage { flex: 3; min-height: 0; background: #000; display: flex; flex-direction: column; padding: 8px; gap: 8px; }
.stage-main { flex: 1; min-height: 0; }
.stage-thumbs { display: flex; gap: 8px; overflow-x: auto; flex-shrink: 0; }
.stage-thumbs:empty { display: none; }
.tile { position: relative; width: 100%; height: 100%; border-radius: 6px; overflow: hidden; background: #111; }
.tile video { width: 100%; height: 100%; object-fit: contain; display: block; }
.tile .label { position: absolute; left: 8px; bottom: 8px; background: rgba(0,0,0,.65); padding: 3px 8px; border-radius: 4px; font-size: 12px; }
.tile .fs { position: absolute; right: 8px; bottom: 8px; background: rgba(0,0,0,.65); color: #fff; padding: 4px; border-radius: 4px; opacity: 0; transition: opacity .15s; }
.tile:hover .fs { opacity: 1; }
.stage-thumbs .tile { width: 160px; height: 90px; flex-shrink: 0; cursor: pointer; }
.stage-thumbs .tile .fs { display: none; }

/* Sohbet */
.chat { flex: 2; min-height: 0; display: flex; flex-direction: column; }
.messages { flex: 1; overflow-y: auto; padding: 12px 16px; display: flex; flex-direction: column; gap: 2px; }
.msg { display: grid; grid-template-columns: 40px 1fr; gap: 0 12px; padding: 4px 0; }
.msg.cont { padding-top: 0; }
.msg .avatar { width: 40px; height: 40px; grid-row: span 2; }
.msg.cont .avatar { visibility: hidden; height: 0; }
.msg .meta { display: flex; gap: 8px; align-items: baseline; }
.msg.cont .meta { display: none; }
.msg .author { font-weight: 700; }
.msg .time { color: var(--faint); font-size: 11px; }
.msg .text { white-space: pre-wrap; word-break: break-word; }
.msg .text a { color: #00a8fc; }
.sys { color: var(--faint); font-size: 13px; font-style: italic; padding: 4px 0 4px 52px; }
.chat-form { display: flex; gap: 8px; padding: 0 16px 16px; }
.chat-form input { flex: 1; min-width: 0; background: var(--input); border: 0; border-radius: var(--radius); padding: 12px 14px; outline: none; }

/* Bildirim */
.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: var(--panel); border: 1px solid var(--hover); padding: 10px 16px; border-radius: var(--radius); box-shadow: 0 8px 24px rgba(0,0,0,.4); z-index: 10; max-width: calc(100% - 32px); }

.mobile-only { display: none; }

/* Mobil */
@media (max-width: 760px) {
  .mobile-only { display: inline-flex; }
  /* transform kullanılmaz: içteki position:fixed kontroller viewport'a göre kalmalı */
  .sidebar { position: fixed; top: 0; bottom: 0; left: -100%; z-index: 5; transition: left .2s; box-shadow: 4px 0 24px rgba(0,0,0,.5); width: 85%; max-width: 300px; }
  .room.show-sidebar .sidebar { left: 0; }
  .main { padding-bottom: 76px; }
  .controls { position: fixed; left: 0; right: 0; bottom: 0; z-index: 4; }
  .room.show-sidebar .controls { position: static; }
  .topbar .btn span { display: none; }
  .stage { flex: none; height: 38vh; }
  .chat-form { padding: 0 12px 12px; }
  .messages { padding: 12px; }
}
