/* webrtcs: one stylesheet for every page (CSP style-src 'self': no inline styles). */
:root {
  --bg: #f4f5f7;
  --panel: #ffffff;
  --ink: #1d2330;
  --muted: #5d6677;
  --line: #d9dde5;
  --accent: #1f6feb;
  --accent-ink: #ffffff;
  --danger: #c62828;
  --ok: #2e7d32;
  --tile: #11151c;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1218;
    --panel: #181c24;
    --ink: #e7eaf0;
    --muted: #9aa3b2;
    --line: #2a303c;
    --accent: #4c8dff;
    --danger: #ff6b6b;
    --ok: #5cc26b;
    --tile: #05070a;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
[hidden] { display: none !important; }
a { color: var(--accent); }
h1 { font-size: 1.5rem; margin: 0 0 1rem; }
h2 { font-size: 1.1rem; margin: 0 0 .75rem; }
main.narrow { max-width: 26rem; margin: 8vh auto; padding: 0 1rem; }
main.wide { max-width: 52rem; margin: 4vh auto; padding: 0 1rem; }
.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 1.25rem;
  margin-bottom: 1rem;
}
label { display: block; margin: .6rem 0 .25rem; color: var(--muted); font-size: .9rem; }
label.inline { display: flex; align-items: center; gap: .5rem; color: var(--ink); }
input[type=text], input[type=password], input[type=number], select, textarea {
  width: 100%;
  padding: .55rem .65rem;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--bg);
  color: var(--ink);
  font: inherit;
}
button, .button {
  display: inline-block;
  padding: .5rem 1rem;
  border: 1px solid var(--accent);
  border-radius: 6px;
  background: var(--accent);
  color: var(--accent-ink);
  font: inherit;
  cursor: pointer;
  text-decoration: none;
}
button.secondary, .button.secondary { background: transparent; color: var(--accent); }
button.danger { background: var(--danger); border-color: var(--danger); }
button:disabled { opacity: .5; cursor: default; }
button.link { background: none; border: none; color: var(--accent); padding: 0; text-decoration: underline; }
.row { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; margin-top: .75rem; }
.grow { flex: 1; }
.status { min-height: 1.4em; margin: .5rem 0 0; }
.status-error { color: var(--danger); }
.status-ok { color: var(--ok); }
.status-info { color: var(--muted); }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  padding: .6rem 1rem; background: var(--panel); border-bottom: 1px solid var(--line);
}
.topbar .title { font-weight: 600; }
.notice { padding: .6rem .8rem; border-radius: 6px; border: 1px solid var(--line); background: var(--panel); }
.notice.warn { border-color: var(--danger); }
.invite-list { list-style: none; padding: 0; margin: .75rem 0 0; }
.invite-list li { display: flex; gap: .5rem; align-items: center; margin-top: .5rem; flex-wrap: wrap; }
.invite-list input { flex: 1; min-width: 12rem; }

/* Room */
body.room { display: flex; flex-direction: column; height: 100vh; }
.preview { display: grid; grid-template-columns: minmax(0, 1fr) minmax(16rem, 22rem); gap: 1rem; padding: 1rem; max-width: 64rem; margin: 0 auto; width: 100%; }
.preview video { width: 100%; aspect-ratio: 16 / 9; background: var(--tile); border-radius: 10px; object-fit: cover; }
.call { flex: 1; display: grid; grid-template-columns: minmax(0, 1fr) 20rem; min-height: 0; }
.stage { display: flex; flex-direction: column; min-height: 0; padding: .75rem; gap: .75rem; }
.grid { flex: 1; display: grid; gap: .5rem; grid-template-columns: repeat(auto-fit, minmax(15rem, 1fr)); grid-auto-rows: minmax(9rem, 1fr); min-height: 0; overflow: auto; }
.tile { position: relative; background: var(--tile); border-radius: 8px; overflow: hidden; min-height: 9rem; }
.tile video { width: 100%; height: 100%; object-fit: cover; display: block; }
.tile.self video { transform: scaleX(-1); }
.tile .label {
  position: absolute; left: .4rem; bottom: .4rem; right: .4rem;
  display: flex; gap: .4rem; align-items: center; flex-wrap: wrap;
  color: #fff; font-size: .85rem; text-shadow: 0 1px 2px #000;
}
.tile .badge { background: rgba(0, 0, 0, .55); border-radius: 4px; padding: 0 .35rem; }
.tile .placeholder { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; color: #8a93a3; font-size: 2rem; }
.tile.reconnecting { opacity: .55; }
.modmenu { position: absolute; top: .4rem; right: .4rem; }
.modmenu summary { list-style: none; cursor: pointer; background: rgba(0, 0, 0, .55); color: #fff; border-radius: 4px; padding: .1rem .5rem; }
.modmenu summary::-webkit-details-marker { display: none; }
.modmenu .menu { position: absolute; right: 0; top: 1.8rem; z-index: 5; background: var(--panel); border: 1px solid var(--line); border-radius: 6px; padding: .3rem; display: flex; flex-direction: column; gap: .2rem; min-width: 12rem; }
.modmenu .menu button { text-align: left; background: transparent; color: var(--ink); border: none; padding: .35rem .5rem; }
.modmenu .menu button:hover { background: var(--bg); }
.modmenu .menu button.danger { color: var(--danger); }
.controls { display: flex; gap: .5rem; justify-content: center; flex-wrap: wrap; }
.controls button[aria-pressed=true] { background: var(--danger); border-color: var(--danger); }
.side { display: flex; flex-direction: column; border-left: 1px solid var(--line); background: var(--panel); min-height: 0; }
.side h2 { padding: .6rem .8rem 0; margin: 0; }
.messages { flex: 1; overflow-y: auto; padding: .5rem .8rem; list-style: none; margin: 0; min-height: 6rem; }
.messages li { margin-bottom: .45rem; word-wrap: break-word; overflow-wrap: anywhere; white-space: pre-wrap; }
.messages .who { font-weight: 600; margin-right: .35rem; }
.messages .when { color: var(--muted); font-size: .75rem; margin-right: .35rem; }
.messages li.system { color: var(--muted); font-style: italic; }
.chatform { display: flex; gap: .4rem; padding: .5rem .8rem; border-top: 1px solid var(--line); }
.chatform input { flex: 1; }
.files { list-style: none; margin: 0; padding: .3rem .8rem; max-height: 30vh; overflow-y: auto; border-top: 1px solid var(--line); }
.files li { margin: .4rem 0; font-size: .9rem; }
.files .fname { overflow-wrap: anywhere; }
.files progress { width: 100%; }
.files .frow { display: flex; gap: .4rem; align-items: center; flex-wrap: wrap; }
.filebar { padding: .4rem .8rem .7rem; }
.ended { max-width: 30rem; margin: 15vh auto; text-align: center; padding: 0 1rem; }
.banner { padding: .5rem 1rem; background: var(--accent); color: var(--accent-ink); text-align: center; }
.banner.warn { background: var(--danger); }
@media (max-width: 760px) {
  .preview { grid-template-columns: 1fr; }
  .call { grid-template-columns: 1fr; grid-template-rows: minmax(0, 1fr) minmax(14rem, 40vh); }
  .side { border-left: none; border-top: 1px solid var(--line); }
}
