:root {
  color-scheme: dark;
  --bg-deep: #101216;     /* kullanıcı paneli, giriş alanları */
  --bg-side: #171a20;     /* kenar çubuğu */
  --bg-main: #1e2229;     /* sohbet alanı */
  --bg-hover: #272c35;
  --line: #2c313a;
  --text: #e6e8eb;
  --muted: #8f97a3;
  --accent: #3ecf8e;
  --accent-ink: #06281a;
  --danger: #e5534b;
  --warn: #e0a339;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--bg-main);
  color: var(--text);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", sans-serif;
}

h1, h2 { margin: 0; }

.icon {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex: none;
}

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

button:disabled { opacity: 0.6; cursor: default; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.avatar {
  flex: none;
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--bg-hover);
  color: #fff;
  font-weight: 600;
  font-size: 14px;
  box-shadow: 0 0 0 2px transparent;
  transition: box-shadow 0.1s;
}

/* ---- Giriş ekranı ---- */
#join-view {
  min-height: 100%;
  display: grid;
  place-items: center;
  padding: 24px 16px;
  background: var(--bg-deep);
}

.join-card {
  width: 100%;
  max-width: 400px;
  padding: 32px;
  background: var(--bg-main);
  border-radius: 10px;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.35);
}

.join-card h1 { font-size: 24px; text-align: center; }
.join-sub { margin: 6px 0 24px; text-align: center; color: var(--muted); }

label {
  display: block;
  margin-bottom: 16px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: var(--muted);
}

input:not([type="range"]), select {
  display: block;
  width: 100%;
  margin-top: 8px;
  padding: 10px 12px;
  background: var(--bg-deep);
  color: var(--text);
  border: 1px solid transparent;
  border-radius: 6px;
  font: inherit;
  font-size: 15px;
  text-transform: none;
  letter-spacing: 0;
}

input[type="range"] { width: 100%; accent-color: var(--accent); }

button.primary {
  width: 100%;
  padding: 11px 14px;
  background: var(--accent);
  color: var(--accent-ink);
  border-radius: 6px;
  font-weight: 600;
}

button.primary:hover { filter: brightness(1.08); }

.error { min-height: 1.4em; margin: 12px 0 0; color: var(--danger); font-size: 14px; }

/* ---- Oda düzeni ---- */
#room-view {
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
  height: 100vh;
  height: 100dvh;
}

#sidebar {
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: var(--bg-side);
}

.side-head, .chat-head {
  flex: none;
  display: flex;
  align-items: center;
  gap: 8px;
  height: 50px;
  padding: 0 14px;
  border-bottom: 1px solid var(--bg-deep);
  font-weight: 600;
}

.side-head h1 {
  flex: 1;
  min-width: 0;
  font-size: 16px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

button.ghost {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border-radius: 6px;
  color: var(--muted);
  font-size: 13px;
}

button.ghost:hover { background: var(--bg-hover); color: var(--text); }
button.ghost .icon { width: 16px; height: 16px; }

.side-scroll { flex: 1; min-height: 0; overflow-y: auto; padding: 14px 8px; }

.section-label {
  padding: 0 8px 6px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
}

.channel {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 8px;
  border-radius: 6px;
  background: var(--bg-hover);
  font-weight: 500;
}

.channel .icon { color: var(--muted); }
.count { margin-left: auto; font-size: 12px; color: var(--muted); }

#peers { list-style: none; margin: 4px 0 0; padding: 0 0 0 20px; }

#peers li {
  padding: 5px 8px;
  border-radius: 6px;
}

#peers li:hover { background: var(--bg-hover); }

.peer-line { display: flex; align-items: center; gap: 8px; min-height: 28px; }
#peers .avatar { width: 26px; height: 26px; font-size: 12px; }
li.speaking .avatar { box-shadow: 0 0 0 2px var(--accent); }

.peer-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--muted);
}

li.speaking .peer-name { color: var(--text); }
.peer-icons { display: flex; gap: 4px; color: var(--muted); }
.peer-icons .icon { width: 15px; height: 15px; }
.badge { font-size: 12px; color: var(--muted); }
.badge:empty { display: none; }
li.problem .badge { color: var(--danger); }

.volume {
  display: none;
  height: 16px;
  margin: 4px 0 2px;
}

#peers li:hover .volume, #peers li:focus-within .volume { display: block; }

.status {
  flex: none;
  margin: 0;
  padding: 0 14px;
  color: var(--warn);
  font-size: 13px;
}

.status:not(:empty) { padding-bottom: 8px; }

.user-panel {
  flex: none;
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 8px;
  background: var(--bg-deep);
}

.me-text { flex: 1; min-width: 0; margin: 0 4px 0 6px; line-height: 1.25; }
#me-name { font-weight: 600; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#me-state { font-size: 12px; color: var(--accent); }
#me-state.off { color: var(--muted); }

.icon-btn {
  flex: none;
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 6px;
  color: var(--muted);
}

.icon-btn:hover { background: var(--bg-hover); color: var(--text); }
.icon-btn.on { color: var(--danger); }
.icon-btn.leave:hover { background: var(--danger); color: #fff; }

/* ---- Sohbet ---- */
#chat { display: flex; flex-direction: column; min-width: 0; min-height: 0; background: var(--bg-main); }
.chat-head .hash { color: var(--muted); font-size: 20px; font-weight: 400; }

#messages {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  list-style: none;
  margin: 0;
  padding: 16px 0 8px;
}

.msg {
  display: grid;
  grid-template-columns: 40px minmax(0, 1fr);
  column-gap: 14px;
  padding: 2px 16px;
  margin-top: 14px;
}

.msg.grouped { margin-top: 0; }
.msg:hover { background: rgba(0, 0, 0, 0.12); }
.msg .avatar { width: 40px; height: 40px; font-size: 16px; margin-top: 2px; }
.msg-head { display: flex; align-items: baseline; gap: 8px; }
.msg-name { font-weight: 600; }
.msg-time { font-size: 12px; color: var(--muted); }
.msg-text { white-space: pre-wrap; overflow-wrap: anywhere; }
.msg-text a { color: #6cb6ff; }

.system {
  padding: 2px 16px 2px 70px;
  margin-top: 8px;
  font-size: 13px;
  color: var(--muted);
}

.empty {
  padding: 24px 16px;
  color: var(--muted);
}

#chat-form {
  flex: none;
  display: flex;
  align-items: flex-end;
  gap: 4px;
  margin: 0 16px 20px;
  padding: 6px 6px 6px 14px;
  background: var(--bg-hover);
  border-radius: 8px;
}

#chat-input {
  flex: 1;
  min-width: 0;
  max-height: 160px;
  padding: 7px 0;
  resize: none;
  border: 0;
  outline: 0;
  background: none;
  color: var(--text);
  font: inherit;
}

#chat-input::placeholder { color: var(--muted); }
#chat-form:focus-within { box-shadow: 0 0 0 2px var(--accent); }
.icon-btn.send:hover { color: var(--accent); background: none; }

/* ---- Ayarlar penceresi ---- */
dialog {
  width: min(440px, calc(100vw - 32px));
  padding: 24px;
  border: 0;
  border-radius: 10px;
  background: var(--bg-main);
  color: var(--text);
}

dialog::backdrop { background: rgba(0, 0, 0, 0.6); }
.dialog-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; }
.dialog-head h2 { font-size: 18px; }

.hint {
  display: block;
  margin-top: 6px;
  font-size: 13px;
  font-weight: 400;
  text-transform: none;
  letter-spacing: 0;
}

.meter {
  position: relative;
  height: 10px;
  margin: 12px 0 6px;
  background: var(--bg-deep);
  border-radius: 5px;
  overflow: hidden;
}

#meter-fill { height: 100%; width: 0; background: var(--muted); }
#meter-fill.open { background: var(--accent); }
#meter-mark { position: absolute; top: 0; bottom: 0; width: 2px; background: var(--text); }

/* ---- Dar ekran: kenar çubuğu üstte, sohbet altta ---- */
@media (max-width: 720px) {
  #room-view {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto minmax(0, 1fr);
  }
  .side-scroll { max-height: 28vh; }
  .volume { display: block; }
}
