:root {
  color-scheme: light dark;
  --accent: #3b6cf6;
  --error: #d93025;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

body {
  margin: 0;
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 16px;
  box-sizing: border-box;
}

/* Екрани перемикаються атрибутом hidden; правило сильніше за будь-який display нижче. */
[hidden] {
  display: none !important;
}

.card {
  width: 100%;
  max-width: 360px;
  display: grid;
  gap: 12px;
}

h1 {
  margin: 0 0 8px;
  text-align: center;
}

section,
form {
  display: grid;
  gap: 8px;
}

section p {
  margin: 0;
}

button,
input {
  font: inherit;
  padding: 12px;
  border: 1px solid #8888;
  border-radius: 10px;
  background: transparent;
  color: inherit;
}

button {
  cursor: pointer;
}

button.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

button.danger {
  background: var(--error);
  border-color: var(--error);
  color: #fff;
}

button.link {
  justify-self: start;
  padding: 0;
  border: none;
  background: none;
  text-decoration: underline;
}

.stack {
  display: grid;
  gap: 8px;
}

.code {
  font-family: ui-monospace, "Cascadia Mono", Consolas, monospace;
  word-break: break-all;
}

.hint {
  font-size: 0.9em;
  opacity: 0.8;
}

.check {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  font-size: 0.9em;
}

.check input {
  padding: 0;
  margin: 0.2em 0 0;
}

button:disabled {
  opacity: 0.6;
  cursor: default;
}

summary {
  cursor: pointer;
  margin-bottom: 8px;
}

.message {
  margin: 0;
}

.message.error {
  color: var(--error);
}

/* Розмова: відео партнера на весь екран, своє в кутку, кнопки внизу. */
body.in-call {
  padding: 0;
  place-items: stretch;
  background: #000;
  color: #fff;
}

body.in-call .card {
  max-width: none;
  gap: 0;
}

body.in-call h1,
body.in-call #logout {
  display: none;
}

body.in-call .message {
  position: fixed;
  left: 16px;
  right: 16px;
  bottom: 96px;
  text-align: center;
}

#talk {
  display: block;
  position: relative;
  height: 100vh;
  height: 100dvh;
}

#remote-video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  background: #111;
}

#local-video {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 28%;
  max-width: 160px;
  border-radius: 10px;
  transform: scaleX(-1);
}

#talk .e2ee {
  position: absolute;
  top: 12px;
  left: 12px;
  padding: 4px 8px;
  border-radius: 8px;
  background: #0009;
  font-size: 0.9em;
}

[data-ok="true"] {
  color: #7ee787;
}

[data-ok="false"] {
  color: #ff7b72;
}

#talk .controls {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 16px;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  padding: 0 12px env(safe-area-inset-bottom);
}

#talk .controls button:not(.danger) {
  background: #0009;
  border-color: #fff6;
}

#talk .controls button[aria-pressed="true"] {
  background: #fff;
  color: #000;
}
