:root {
  --bg: #0f1419;
  --panel: #171d26;
  --panel-2: #1f2733;
  --line: #2a3441;
  --text: #e8edf3;
  --muted: #8b98a8;
  --accent: #2dd4a7;
  --accent-ink: #052e24;
  --danger: #ef5b5b;
  --radius: 14px;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Segoe UI", system-ui, -apple-system, Arial, sans-serif;
  line-height: 1.5;
}

.hidden { display: none !important; }
.muted { color: var(--muted); margin: 0; font-size: 14px; }
.center { text-align: center; padding: 18px 0 6px; }

h1, h2 { margin: 0; line-height: 1.2; }
h1 { font-size: 24px; }
h2 { font-size: 18px; }

/* ----- לובי ----- */
#lobby {
  max-width: 560px;
  margin: 0 auto;
  padding: 32px 16px 48px;
}
.brand { display: flex; align-items: center; gap: 14px; margin-bottom: 24px; }
.logo {
  width: 52px; height: 52px; border-radius: 16px;
  background: var(--accent); color: var(--accent-ink);
  display: grid; place-items: center;
}

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 16px;
}
.card-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }

label { display: block; font-size: 13px; color: var(--muted); margin: 0 0 6px; }
.card label:not(:first-child) { margin-top: 16px; }

input {
  width: 100%;
  background: var(--panel-2);
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: 10px;
  padding: 11px 14px;
  font: inherit;
  outline: none;
  transition: border-color .15s;
}
input:focus { border-color: var(--accent); }

.row { display: flex; gap: 8px; }

.btn {
  border: 0;
  border-radius: 10px;
  padding: 11px 18px;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  color: var(--text);
  background: var(--panel-2);
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  white-space: nowrap;
  transition: filter .15s, transform .05s;
}
.btn:hover { filter: brightness(1.15); }
.btn:active { transform: scale(.97); }
.btn.primary { background: var(--accent); color: var(--accent-ink); }
.btn.ghost { background: transparent; border: 1px solid var(--line); }
.btn.icon { padding: 11px 13px; }
.btn.round { width: 56px; height: 56px; border-radius: 50%; padding: 0; }
.btn.round[aria-pressed="true"] { background: var(--danger); color: #fff; }
.btn.danger { background: var(--danger); color: #fff; }

.chip {
  font-size: 12px; padding: 3px 10px; border-radius: 99px;
  background: var(--panel-2); color: var(--muted);
}
.chip.ok { background: rgba(45, 212, 167, .15); color: var(--accent); }
.chip.bad { background: rgba(239, 91, 91, .15); color: var(--danger); }

.room-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.room-list li {
  display: flex; justify-content: space-between; align-items: center;
  background: var(--panel-2); border-radius: 10px; padding: 12px 14px;
}
.room-list .name { font-weight: 600; word-break: break-word; }
.room-list .meta { font-size: 13px; color: var(--muted); }
.room-list .btn { padding: 8px 14px; }
.room-list .btn[disabled] { opacity: .5; cursor: not-allowed; }

/* ----- חדר ----- */
#room {
  height: 100%;
  display: flex; flex-direction: column;
  max-width: 1100px; margin: 0 auto;
  padding: 16px;
}
.room-bar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }

.room-body {
  flex: 1; min-height: 0;
  display: grid; grid-template-columns: 1fr 320px; gap: 14px;
}

.peers {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: 12px;
  align-content: start;
  overflow-y: auto;
}

.peer {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px 14px 14px;
  text-align: center;
  position: relative;
}
.avatar {
  width: 72px; height: 72px; border-radius: 50%;
  margin: 0 auto 10px;
  display: grid; place-items: center;
  font-size: 28px; font-weight: 700; color: #fff;
  box-shadow: 0 0 0 0 rgba(45, 212, 167, 0);
  transition: box-shadow .12s;
}
.peer.speaking .avatar { box-shadow: 0 0 0 4px var(--accent); }
.peer .pname { font-weight: 600; word-break: break-word; }
.peer .pstatus { font-size: 12px; color: var(--muted); margin-top: 2px; min-height: 18px; }
.peer .pstatus.ok { color: var(--accent); }
.peer .pstatus.bad { color: var(--danger); }
.peer .badge-muted {
  position: absolute; top: 10px; inset-inline-start: 10px;
  background: var(--danger); color: #fff; border-radius: 99px;
  width: 24px; height: 24px; display: grid; place-items: center; font-size: 12px;
}
.peer input[type=range] { margin-top: 10px; padding: 0; height: 18px; accent-color: var(--accent); background: none; border: 0; }

/* ----- צ'אט ----- */
.chat {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  display: flex; flex-direction: column;
  padding: 12px; min-height: 0;
}
.messages { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 8px; margin-bottom: 10px; }
.msg { max-width: 88%; padding: 8px 12px; border-radius: 12px; background: var(--panel-2); word-break: break-word; }
.msg .who { font-size: 12px; color: var(--muted); display: block; }
.msg.me { align-self: flex-start; background: rgba(45, 212, 167, .16); }
.msg.sys { align-self: center; background: none; color: var(--muted); font-size: 13px; padding: 2px; }

.controls { display: flex; justify-content: center; gap: 16px; padding-top: 16px; }

.bar-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.btn.sm { padding: 6px 12px; font-size: 13px; border-radius: 8px; }

.banner {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  background: rgba(240, 140, 0, .14); border: 1px solid rgba(240, 140, 0, .5);
  border-radius: 10px; padding: 10px 14px; margin-bottom: 12px; font-size: 14px;
}

.modal {
  position: fixed; inset: 0; z-index: 20;
  background: rgba(0, 0, 0, .6);
  display: grid; place-items: center; padding: 16px;
}
.modal-box {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 20px; width: min(680px, 100%); max-height: 92vh; overflow: auto;
}
.modal-box textarea {
  width: 100%; height: 320px; resize: vertical;
  background: var(--panel-2); color: var(--text); border: 1px solid var(--line);
  border-radius: 10px; padding: 10px; font: 12px/1.5 ui-monospace, Consolas, monospace;
}

/* ----- הודעה צפה ----- */
.toast {
  position: fixed; top: 16px; left: 50%; transform: translate(-50%, -80px);
  background: var(--danger); color: #fff;
  padding: 10px 18px; border-radius: 10px; font-weight: 600;
  transition: transform .25s; z-index: 10; max-width: 90vw; text-align: center;
}
.toast.show { transform: translate(-50%, 0); }
.toast.info { background: var(--panel-2); border: 1px solid var(--line); }

@media (max-width: 760px) {
  #room { padding: 12px; }
  .room-body { grid-template-columns: 1fr; grid-template-rows: auto 220px; }
}
