:root {
  --bg: #f4f3fb;
  --surface: #ffffff;
  --surface-2: #ecebf7;
  --text: #1c1b29;
  --muted: #6b6a80;
  --accent: #6d5efc;
  --accent-text: #ffffff;
  --speaking: #22c55e;
  --danger: #e5484d;
  --border: #dcdaee;
  --shadow: 0 1px 2px rgb(0 0 0 / 0.05), 0 8px 24px rgb(40 30 120 / 0.06);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #13121c;
    --surface: #1c1b29;
    --surface-2: #262536;
    --text: #ecebf5;
    --muted: #9a99b2;
    --accent: #8b7fff;
    --accent-text: #0f0e17;
    --speaking: #34d399;
    --danger: #ff6b6f;
    --border: #2f2e44;
    --shadow: none;
  }
}
:root[data-theme="dark"] {
  --bg: #13121c;
  --surface: #1c1b29;
  --surface-2: #262536;
  --text: #ecebf5;
  --muted: #9a99b2;
  --accent: #8b7fff;
  --accent-text: #0f0e17;
  --speaking: #34d399;
  --danger: #ff6b6f;
  --border: #2f2e44;
  --shadow: none;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-tap-highlight-color: transparent;
}
.shell {
  max-width: 640px;
  margin: 0 auto;
  padding: max(16px, env(safe-area-inset-top)) 16px calc(24px + env(safe-area-inset-bottom));
}
.top { display: flex; align-items: center; gap: 10px; margin: 8px 0 20px; }
.top h1 { font-size: 1.4rem; margin: 0; letter-spacing: -0.01em; }
.room-badge {
  background: var(--surface-2);
  color: var(--muted);
  border-radius: 999px;
  padding: 2px 10px;
  font-size: 0.85rem;
}
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 20px;
  box-shadow: var(--shadow);
}
.hidden { display: none !important; }

form { display: grid; gap: 14px; }
label { display: grid; gap: 6px; font-weight: 600; font-size: 0.92rem; }
input:not([type="checkbox"]):not([type="range"]) {
  font: inherit;
  padding: 12px 14px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-weight: 400;
}
input:focus-visible, button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

button {
  font: inherit;
  font-weight: 600;
  border: 0;
  border-radius: 12px;
  padding: 12px 16px;
  cursor: pointer;
  min-height: 44px;
  touch-action: manipulation;
}
button:disabled { opacity: 0.6; cursor: progress; }
.primary { background: var(--accent); color: var(--accent-text); }
.secondary { background: var(--surface-2); color: var(--text); }
.secondary[aria-pressed="true"] { background: var(--danger); color: #fff; }
.danger { background: transparent; color: var(--danger); border: 1px solid var(--danger); }

.presence { margin: 0; color: var(--muted); font-size: 0.92rem; min-height: 1.3em; }
.presence .dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--speaking); margin-right: 6px; }
.error { margin: 0; color: var(--danger); min-height: 1.3em; font-size: 0.92rem; }

.peers {
  list-style: none;
  margin: 0 0 16px;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 12px;
}
.peer {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 16px 12px 12px;
  display: grid;
  justify-items: center;
  gap: 8px;
  text-align: center;
  box-shadow: var(--shadow);
}
.avatar {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 1.5rem;
  font-weight: 700;
  color: #fff;
  box-shadow: 0 0 0 3px transparent;
  transition: box-shadow 120ms ease;
}
.peer.speaking .avatar { box-shadow: 0 0 0 3px var(--speaking), 0 0 16px var(--speaking); }
.peer-name { font-weight: 600; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.peer-name .me { color: var(--muted); font-weight: 400; }
.peer-status { font-size: 0.8rem; color: var(--muted); min-height: 1.2em; }
.peer input[type="range"] { width: 100%; accent-color: var(--accent); }

.controls { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.controls .danger { grid-column: 1 / -1; }
@media (min-width: 520px) {
  .controls { grid-template-columns: 1fr 1fr auto; }
  .controls .danger { grid-column: auto; }
}

.ptt {
  width: 100%;
  min-height: 88px;
  margin-bottom: 8px;
  font-size: 1.1rem;
  background: var(--surface-2);
  color: var(--text);
  border: 2px dashed var(--border);
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  touch-action: none; /* parmak kayınca kaydırma başlayıp konuşmayı kesmesin */
}
.ptt.active { background: var(--speaking); color: #062b14; border-color: transparent; }
.hint { color: var(--muted); font-size: 0.85rem; margin: 0 0 12px; text-align: center; }
#unlockAudioBtn { width: 100%; margin-bottom: 12px; }

.settings { margin-top: 14px; display: grid; gap: 18px; }
.switch { display: flex; gap: 12px; align-items: flex-start; font-weight: 400; cursor: pointer; }
.switch input { width: 20px; height: 20px; margin-top: 2px; accent-color: var(--accent); flex: none; }
.switch span, .gate { display: grid; gap: 2px; }
small { color: var(--muted); font-size: 0.83rem; }
small.warn { color: var(--danger); }
.gate-head { display: flex; justify-content: space-between; align-items: center; }
.inline { display: flex; gap: 6px; align-items: center; font-weight: 400; }
.inline input { accent-color: var(--accent); }
.meter { position: relative; height: 10px; border-radius: 999px; background: var(--surface-2); overflow: hidden; margin: 8px 0 4px; }
.meter-fill { position: absolute; inset: 0 auto 0 0; width: 0; background: var(--muted); transition: width 60ms linear; }
.meter-fill.open { background: var(--speaking); }
.meter-line { position: absolute; top: 0; bottom: 0; width: 2px; background: var(--danger); }
.gate input[type="range"] { width: 100%; accent-color: var(--accent); }
.gate input[type="range"]:disabled { opacity: 0.5; }

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(20px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  background: var(--text);
  color: var(--bg);
  padding: 10px 16px;
  border-radius: 10px;
  max-width: calc(100% - 32px);
  font-size: 0.92rem;
}
