:root {
  /* Always dark, whatever the browser or system prefers (and in every browser alike). */
  --bg: #161615;
  --panel: #20201e;
  --text: #ecebe6;
  --muted: #9a9a93;
  --line: #34342f;
  --accent: #5b8ff5;
  --accent-text: #0b0b0a;
  --ok: #6cc38a;
  --error: #f08a80;
  color-scheme: dark;
}

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 system-ui, sans-serif;
}

main.screen {
  max-width: 720px;
  margin: 0 auto;
  padding: 24px 16px 48px;
  opacity: 0.4;
  pointer-events: none;
}
body.ready main.screen { opacity: 1; pointer-events: auto; }

h1 { font-size: 22px; margin: 0; }
h2 { font-size: 17px; margin: 0 0 8px; }
p { margin: 8px 0; }
.mono, .fingerprint { font-family: ui-monospace, monospace; }
.hint, .fingerprint { color: var(--muted); font-size: 13px; }

.bar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 12px;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 12px;
  margin-bottom: 16px;
  border-bottom: 1px solid var(--line);
}
#pair-screen .bar, #settings-screen .bar, #account-screen .bar, #admin-screen .bar { justify-content: flex-start; }

.row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }

section, details {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  margin-bottom: 12px;
}
section details { margin: 12px 0 0; padding: 12px; }
details summary { cursor: pointer; font-weight: 600; }

.field { display: flex; flex-direction: column; gap: 4px; margin-top: 12px; font-size: 13px; color: var(--muted); }
.field input { color: var(--text); }
.field input[type='range'] { padding: 0; }
.check { display: flex; gap: 8px; align-items: center; cursor: pointer; }

button, input, select {
  font: inherit;
  border-radius: 6px;
  border: 1px solid var(--line);
  padding: 6px 12px;
  background: var(--panel);
  color: var(--text);
  min-width: 0;
}
button { cursor: pointer; }
button:hover:not(:disabled) { border-color: var(--muted); }
button:disabled { opacity: 0.5; cursor: default; }
button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
button.quiet { border-color: transparent; color: var(--muted); }
#add-by-key button { margin-top: 12px; }

/* Another tab has Screenshare open. */
#elsewhere {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: var(--bg);
  text-align: center;
}
#elsewhere > div { max-width: 480px; }

/* Friends */
#empty { text-align: center; padding: 40px 16px; }
#friends { list-style: none; margin: 0 0 12px; padding: 0; }
#friends li {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px 16px;
  margin-bottom: 8px;
}
#friends .who { flex: 1 1 200px; min-width: 0; display: flex; flex-direction: column; }
#friends .who strong { font-size: 16px; }
#friends .who .fingerprint { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dot { width: 10px; height: 10px; border-radius: 50%; border: 2px solid var(--muted); flex: none; }
.dot.on { background: var(--ok); border-color: var(--ok); }
.dot.sharing { background: #5aa0ff; border-color: #5aa0ff; }

.status-bar { display: flex; gap: 8px; align-items: center; }
#status, #pair-status { flex: 1; margin: 0; min-height: 1.5em; overflow-wrap: anywhere; }
[data-kind='ok'] { color: var(--ok); }
[data-kind='error'] { color: var(--error); }
#cancel { display: none; }
body:not(.busy) .status-bar:has(#status:empty) { display: none; }
body.busy #cancel { display: inline-block; }
body.busy #friends button, body.busy .bar button { opacity: 0.5; pointer-events: none; }
#pair-screen .bar button { opacity: 1; pointer-events: auto; }

/* Pairing */
code#code { display: inline-block; white-space: nowrap; font-size: 26px; letter-spacing: 2px; font-weight: 600; }
#typed-code { width: 13em; text-transform: uppercase; }
.or { margin-top: 20px; color: var(--muted); }

/* Settings */
.tabs { display: flex; gap: 4px; margin-bottom: 16px; }
.tabs button { border-color: transparent; }
.tabs button[aria-selected='true'] { border-color: var(--line); background: var(--panel); font-weight: 600; }
.setting {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 16px;
  align-items: center;
  justify-content: space-between;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
}
.setting > div { flex: 1 1 320px; }
.setting .hint { margin: 2px 0 0; }
.setting input, .setting select { flex: 0 1 240px; }

/* The call: the picture fills the window, with the overlay floating over it. */
#call { position: fixed; inset: 0; background: #000; }
#screen { width: 100%; height: 100%; object-fit: contain; display: block; }
#call-placeholder {
  position: absolute;
  inset: 0;
  margin: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #999;
  pointer-events: none;
}
#call.sharing-call .watch-only, #call:not(.sharing-call) .share-only { display: none; }
#call.sharing-call .overlay-collapse { display: none; }

.overlay { position: absolute; left: 0; top: 0; max-width: calc(100vw - 16px); touch-action: none; }
.overlay-icon {
  width: 36px;
  height: 36px;
  padding: 0;
  border-radius: 50%;
  background: rgba(20, 20, 20, 0.75);
  color: #fff;
  border: 2px solid rgba(255, 255, 255, 0.6);
  font: italic 600 18px/1 Georgia, serif;
  cursor: grab;
}
.overlay-panel {
  width: 440px;
  max-width: calc(100vw - 16px);
  background: rgba(20, 20, 20, 0.88);
  color: #eee;
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 13px;
}
.overlay-panel p { margin: 6px 0; }
.overlay-bar { display: flex; gap: 8px; align-items: center; }
.overlay-grip { cursor: grab; color: #aaa; font-weight: 700; user-select: none; padding: 0 4px; }
.overlay-header { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.overlay-collapse { background: transparent; color: #eee; border-color: rgba(255, 255, 255, 0.3); padding: 0 10px; }
.overlay-detail { color: #aaa; font-family: ui-monospace, monospace; font-size: 12px; }
.overlay-stats { font-family: ui-monospace, monospace; font-size: 12px; overflow-wrap: anywhere; white-space: pre-line; }
.overlay-note { color: #f5c26b; font-size: 12px; margin: 4px 0; }
.overlay-volume { display: flex; align-items: center; gap: 8px; margin: 6px 0; }
.overlay-volume input { flex: 1; }
.overlay .hint { color: #aaa; }
.overlay button:not(.primary):not(.overlay-icon) { background: transparent; color: #eee; }

/* Accounts */
main.screen.narrow { max-width: 480px; }
.links { justify-content: center; gap: 20px; margin: 12px 0; }
.links a { color: var(--accent); }
button.danger, .danger { color: var(--error); }
button.primary.danger { background: var(--error); border-color: var(--error); color: #fff; }
.button-like {
  display: inline-block;
  border-radius: 6px;
  border: 1px solid var(--line);
  padding: 6px 12px;
  cursor: pointer;
}
.button-like:hover { border-color: var(--muted); }

.avatar-slot {
  width: 32px;
  height: 32px;
  flex: none;
  border-radius: 50%;
  overflow: hidden;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--line);
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}
.avatar-slot.big { width: 96px; height: 96px; font-size: 32px; }
.avatar-slot img { width: 100%; height: 100%; object-fit: cover; display: block; }
.account-button { display: inline-flex; align-items: center; gap: 8px; padding: 3px 12px 3px 3px; border-radius: 999px; }
.account-button .avatar-slot { width: 28px; height: 28px; }
.account-top { gap: 16px; align-items: center; }

table.list { width: 100%; border-collapse: collapse; margin-top: 12px; }
table.list td { padding: 8px 6px; border-top: 1px solid var(--line); vertical-align: middle; }
table.list tr:first-child td { border-top: none; }
table.list .who { display: flex; flex-direction: column; min-width: 0; }
#invite-form input { flex: 1 1 200px; }
#password-form button { margin-top: 12px; }

/* Who is watching a share: one chip each, with a menu. */
.watchers { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0; }
.chip, .overlay .chip { display: inline-flex; align-items: center; gap: 6px; padding: 2px 10px 2px 2px; border-radius: 999px; background: var(--panel); color: var(--text); }
.chip .avatar-slot { width: 24px; height: 24px; font-size: 10px; }
.chip .dot { width: 8px; height: 8px; }
.chip-add { border-radius: 999px; padding: 2px 10px; }
.menu {
  position: fixed;
  z-index: 10;
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 180px;
  padding: 8px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.5);
}
.menu button { text-align: left; }
.menu-heading { margin: 0 0 2px; font-weight: 600; }
.menu-text { margin: 0 0 4px; color: var(--muted); font-size: 12px; font-family: ui-monospace, monospace; }

.dot.control { background: #f0aa3c; border-color: #f0aa3c; }
dialog {
  max-width: min(560px, calc(100vw - 32px));
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 20px;
}
dialog::backdrop { background: rgba(0, 0, 0, 0.6); }
dialog h2 { margin-top: 0; }
dialog li { margin-bottom: 10px; }
dialog a { color: var(--accent); }
dialog .hint { display: block; margin-top: 4px; }
.note { color: #f5c26b; }

/* The call's Files panel. */
.files {
  position: absolute;
  right: 16px;
  bottom: 16px;
  width: min(340px, calc(100vw - 32px));
  max-height: 50vh;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 10px;
  background: rgba(22, 22, 21, 0.92);
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--text);
  font-size: 13px;
}
.files-bar { display: flex; align-items: center; gap: 8px; }
.files-bar strong { flex: 1; }
.files-drop { margin: 0; padding: 10px; text-align: center; color: var(--muted); border: 1px dashed var(--line); border-radius: 8px; }
.files.dragging .files-drop { border-color: var(--accent); color: var(--text); background: rgba(91, 143, 245, 0.15); }
.files.collapsed .files-drop, .files.collapsed .files-list { display: none; }
.files-list { list-style: none; margin: 0; padding: 0; overflow-y: auto; display: flex; flex-direction: column; gap: 8px; }
.files-row { display: flex; flex-direction: column; gap: 3px; }
.files-title { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.files-meta, .files-note { color: var(--muted); font-size: 12px; }
.files-row progress { width: 100%; height: 6px; }
.files-buttons { display: flex; gap: 6px; }
.files-buttons button, .files-buttons a { padding: 2px 10px; font-size: 12px; }
.files-buttons a { color: var(--accent); }
