:root {
  --bg: #0b0d11;
  --surface: #14171e;
  --surface-2: #1c2029;
  --ink: #e8eaef;
  --muted: #8b919e;
  --line: rgba(255, 255, 255, 0.08);
  --accent: #e8eaef;
  --accent-ink: #12141a;
  --good: #6dcca4;
  --danger: #e07a72;
  --shadow: 0 24px 48px rgba(0, 0, 0, 0.45);
  color-scheme: dark;
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

html, body { margin: 0; min-height: 100%; }

body {
  min-height: 100vh;
  min-height: 100dvh;
  color: var(--ink);
  font-family: Manrope, "Segoe UI", sans-serif;
  background: var(--bg);
  overscroll-behavior: none;
}

button, input { font: inherit; color: inherit; }

.sr {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.gate, .room {
  min-height: 100vh;
  min-height: 100dvh;
}

.gate {
  display: grid;
  place-items: center;
  padding: 28px 22px;
}

.resonance-login-page {
  position: relative;
  isolation: isolate;
  background: #090c11;
}

.resonance-background {
  position: absolute;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  pointer-events: none;
  background: #090c11;
}

.resonance-background__canvas {
  display: block;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.login-panel {
  position: relative;
  z-index: 2;
  width: min(360px, 100%);
}

.login-departure {
  position: absolute;
  z-index: 1;
  left: 0;
  top: 0;
  width: 0;
  height: 0;
  margin: 0;
  padding: 0;
  border: 1px solid #637ca452;
  border-radius: 22px;
  opacity: 0;
  pointer-events: none;
  background: linear-gradient(145deg, #1c2637f5, #101620fa 58%, #151a2bfa);
  box-shadow: inset 0 1px 0 #c6ddff1c, 0 28px 80px #0009, 0 0 64px #416cb014;
  transform: translate(-50%, -50%);
}

.gate .card {
  position: relative;
  z-index: 2;
  width: 100%;
}

.resonance-login-page.is-exiting .card {
  pointer-events: none;
  background: transparent;
  border-color: transparent;
  box-shadow: none;
}

.resonance-login-page.is-exiting .card > * {
  opacity: 0;
  filter: blur(5px);
  transition: opacity .22s, filter .22s;
}

.resonance-login-page.is-exiting input {
  caret-color: transparent;
}

.card {
  width: min(360px, 100%);
  padding: 28px;
  background: linear-gradient(145deg, #1c2637f5, #101620fa 58%, #151a2bfa);
  border: 1px solid #637ca452;
  border-radius: 22px;
  box-shadow: inset 0 1px 0 #c6ddff1c, 0 28px 80px #0009, 0 0 64px #416cb014;
}

.fine, .alone, .dock-note, .occupancy, .lock { color: var(--muted); }

.field {
  display: grid;
  gap: 8px;
  margin-top: 0;
  margin-bottom: 0;
  color: #b4c4db;
  font-size: 13px;
  font-weight: 500;
  line-height: 18px;
}

.field + .field { margin-top: 18px; }

.field input {
  width: 100%;
  height: 44px;
  padding: 0 12px;
  color: #dce3f0;
  font-size: 16px;
  background: #0b111bd9;
  border: 1px solid #829cc826;
  border-radius: 10px;
  box-shadow: inset 0 2px 8px #0002;
  outline: none;
}

.field input:focus {
  border-color: rgba(255, 255, 255, 0.38);
  box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.06);
}

.password-row { position: relative; display: block; }
.password-row input { padding-right: 44px; }

.text-btn, .primary, .ctrl { cursor: pointer; border: 0; }

.text-btn {
  position: absolute;
  top: 50%;
  right: 4px;
  transform: translateY(-50%);
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  padding: 0;
  color: var(--muted);
  background: transparent;
  border-radius: 8px;
}

.text-btn svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.text-btn .eye-off { display: none; }
.text-btn[aria-pressed="true"] .eye-open { display: none; }
.text-btn[aria-pressed="true"] .eye-off { display: block; }
.text-btn:hover, .text-btn[aria-pressed="true"] { color: var(--ink); }

.fine { margin: 0; font-size: 12px; line-height: 1.45; }

.error, .banner {
  margin: 14px 0 0;
  padding: 10px 12px;
  color: #f3c7c3;
  background: rgba(224, 122, 114, 0.12);
  border: 1px solid rgba(224, 122, 114, 0.28);
  border-radius: 10px;
  line-height: 1.4;
}

.primary {
  width: 100%;
  height: 44px;
  margin: 18px 0 0;
  padding: 0 16px;
  color: #edf4ff;
  font-size: 15px;
  font-weight: 500;
  background: linear-gradient(115deg, #354a6c, #24364f 60%, #34415d);
  border: 1px solid #b6d4ff3b;
  border-radius: 10px;
  box-shadow: inset 0 1px 0 #d6e7ff1f, 0 4px 20px #3b74c014;
}

.primary:hover { background: linear-gradient(115deg, #46628d, #344b6f 60%, #48597c); }
.primary:disabled { cursor: wait; opacity: 0.65; }

.room {
  display: flex;
  flex-direction: column;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.025), transparent 160px),
    var(--bg);
}

.topbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 18px;
  align-items: center;
  min-height: 60px;
  padding: 0 24px;
  background: rgba(11, 13, 17, 0.92);
  border-bottom: 1px solid var(--line);
}

.brand {
  display: flex;
  gap: 10px;
  align-items: center;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.mark {
  width: 8px;
  height: 8px;
  background: var(--good);
  border-radius: 50%;
  box-shadow: 0 0 0 4px rgba(109, 204, 164, 0.14);
}

.occupancy, .lock { margin: 0; font-size: 13px; }
.lock { margin-left: auto; }

.link-admin {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 18px;
  align-items: end;
  padding: 12px 24px 14px;
  background: #12151b;
  border-bottom: 1px solid var(--line);
}

.link-admin[hidden] { display: none !important; }

.link-admin form {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: end;
  margin: 0;
}

.link-admin label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
}

.link-admin input {
  width: min(240px, 70vw);
  height: 40px;
  padding: 0 12px;
  color: var(--text);
  background: #0b111bd9;
  border: 1px solid #829cc826;
  border-radius: 10px;
}

.link-admin button {
  height: 40px;
  padding: 0 14px;
  color: #edf4ff;
  background: linear-gradient(180deg, #2a3d5c, #1b283d);
  border: 1px solid #829cc840;
  border-radius: 10px;
  cursor: pointer;
}

.link-share-line {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  max-width: 100%;
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

#link-share {
  color: #d5e4ff;
  word-break: break-all;
}

.link-admin-error {
  flex-basis: 100%;
  min-height: 0;
  margin: 0;
  color: var(--danger);
  font-size: 13px;
}

.link-admin-error:empty { display: none; }

.person-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px;
  margin-top: 10px;
}

.pin,
.insult {
  padding: 4px 10px;
  color: var(--muted);
  font-size: 12px;
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 8px;
  cursor: pointer;
}

.pin.is-on {
  color: var(--good);
  border-color: rgba(109, 204, 164, 0.45);
}

.insult.is-on {
  color: var(--danger);
  border-color: rgba(224, 122, 114, 0.55);
}

.insult-menu {
  position: fixed;
  z-index: 40;
  display: grid;
  gap: 2px;
  width: min(340px, calc(100vw - 16px));
  max-height: min(420px, calc(100vh - 16px));
  overflow: auto;
  padding: 8px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: var(--shadow);
}

.insult-menu-title {
  margin: 2px 8px 6px;
  color: var(--muted);
  font-size: 12px;
}

.insult-menu button {
  padding: 8px 10px;
  color: var(--ink);
  font-size: 13px;
  line-height: 1.35;
  text-align: left;
  background: transparent;
  border: 0;
  border-radius: 8px;
  cursor: pointer;
}

.insult-menu button:hover,
.insult-menu button.is-on {
  color: var(--danger);
  background: rgba(224, 122, 114, 0.12);
}

.insult-menu .insult-clear {
  margin-top: 4px;
  color: var(--muted);
  border-top: 1px solid var(--line);
  border-radius: 0;
}

.stage {
  display: flex;
  flex: 1;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 20px;
  min-height: 0;
  padding: 24px;
}

.stage:has(.screens:not([hidden])) {
  justify-content: flex-start;
}

.screens {
  width: min(1080px, 100%);
}

.screen {
  position: relative;
  margin: 0;
  overflow: hidden;
  background: #000;
  border: 1px solid var(--line);
  border-radius: 12px;
}

.screen:fullscreen {
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100%;
  margin: 0;
  border: 0;
  border-radius: 0;
  background: #000;
}

.screen:fullscreen video {
  flex: 1;
  width: 100%;
  height: 100%;
  max-height: none;
}

.screen + .screen { margin-top: 12px; }

.screen video {
  display: block;
  width: 100%;
  max-height: min(62vh, 720px);
  object-fit: contain;
  background: #000;
}

.screen figcaption {
  padding: 8px 12px;
  color: var(--muted);
  font-size: 13px;
  background: var(--surface);
}

.screen-expand {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 2;
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  padding: 0;
  color: #fff;
  background: rgba(12, 14, 18, 0.72);
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 8px;
  cursor: pointer;
}

.screen-expand:hover { background: rgba(12, 14, 18, 0.9); }

.screen-expand svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.screen-expand .shrink { display: none; }
.screen-expand.is-on .expand { display: none; }
.screen-expand.is-on .shrink { display: block; }

.stage,
.people,
.person,
.screen,
.screen video,
.screen figcaption,
.alone,
.topbar {
  cursor: default;
  user-select: none;
  -webkit-user-select: none;
}

.people {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 16px;
  width: min(960px, 100%);
}

.person {
  width: min(188px, 100%);
  padding: 20px 14px 16px;
  text-align: center;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
}

.avatar {
  --level: 0;
  position: relative;
  display: grid;
  place-items: center;
  width: 76px;
  height: 76px;
  margin: 0 auto 12px;
  border-radius: 50%;
  background: hsl(var(--hue) 14% 24%);
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.06);
  transition: box-shadow 80ms linear;
}

.person.speaking .avatar {
  box-shadow:
    0 0 0 1px rgba(109, 204, 164, 0.5),
    0 0 0 calc(5px + var(--level) * 10px) rgba(109, 204, 164, calc(0.12 + var(--level) * 0.28));
}

.initial {
  font-size: 26px;
  font-weight: 600;
}

.person strong, .person .status {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.person strong {
  font-size: 14px;
  font-weight: 600;
}

.status {
  min-height: 1.3em;
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}

.person.recording .avatar::after {
  content: "";
  position: absolute;
  top: 1px;
  right: 1px;
  width: 10px;
  height: 10px;
  background: var(--danger);
  border: 2px solid var(--surface);
  border-radius: 50%;
}

.person.speaking .status { color: var(--good); }
.person.muted .status { color: var(--danger); }

.alone {
  margin: 0;
  max-width: 36ch;
  text-align: center;
  font-size: 14px;
}

.footer {
  display: grid;
  justify-items: center;
  gap: 8px;
  padding: 14px 20px 16px;
  background: #0e1016;
  border-top: 1px solid var(--line);
}

.dock {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  width: min(920px, 100%);
  padding: 0;
  background: transparent;
  border: 0;
}

.ctrl {
  display: inline-flex;
  gap: 8px;
  align-items: center;
  min-height: 40px;
  padding: 0 12px;
  color: #d5d8e0;
  font-size: 13px;
  font-weight: 600;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 10px;
}

.ctrl svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.ctrl:hover { background: #242833; }

.ctrl.icon {
  justify-content: center;
  width: 40px;
  min-width: 40px;
  padding: 0;
}

.ctrl.is-off {
  color: #f0b4ae;
  background: #2a1717;
  border-color: rgba(224, 122, 114, 0.35);
}

.ctrl.is-live {
  color: #d7f5e8;
  background: #143028;
  border-color: rgba(109, 204, 164, 0.45);
}

#record svg {
  width: 22px;
  height: 22px;
  fill: #e4453c;
  stroke: none;
}

#record.is-rec {
  color: #ffd4cf;
  background: #3a1616;
  border-color: rgba(224, 122, 114, 0.72);
}

#record.is-rec svg { fill: #ff5c52; }

.ctrl.danger { color: #e7c4c0; }
.ctrl.danger:hover {
  color: #ffd8d4;
  background: #2a1717;
  border-color: rgba(224, 122, 114, 0.4);
}

.volume-pop, .noise-pop { position: relative; }

#volume-toggle .vol-off { display: none; }
#volume-toggle.is-quiet .vol-on { display: none; }
#volume-toggle.is-quiet .vol-off { display: block; }

.volume, .noise-slider {
  position: absolute;
  z-index: 5;
  bottom: calc(100% + 10px);
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 148px;
  padding: 10px 0;
  background: #1c2029;
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: var(--shadow);
}

.volume input, .noise-slider input {
  writing-mode: vertical-lr;
  direction: rtl;
  width: 28px;
  height: 124px;
  margin: 0;
  accent-color: #c5c8d0;
  cursor: pointer;
}

.dock-note { max-width: 52rem; text-align: center; }
.nowrap { white-space: nowrap; }
.banner { width: min(520px, 100%); }

button:focus-visible, input:focus-visible {
  outline: 2px solid rgba(255, 255, 255, 0.55);
  outline-offset: 2px;
}

@media (max-width: 640px) {
  .gate { padding: 24px 22px; }
  .card { padding: 28px; }

  .topbar {
    flex-wrap: nowrap;
    gap: 8px;
    min-height: 52px;
    padding: 0 14px;
  }

  .brand { flex: none; font-size: 14px; }
  .occupancy { flex: none; font-size: 12px; white-space: nowrap; }

  .lock {
    min-width: 0;
    margin-left: auto;
    overflow: hidden;
    font-size: 12px;
    white-space: nowrap;
    text-overflow: ellipsis;
  }

  .link-admin { padding: 12px 14px; }

  .stage {
    gap: 12px;
    padding: 16px 14px;
  }

  .people { gap: 10px; }

  .person {
    width: calc(50% - 5px);
    max-width: 176px;
    padding: 14px 8px 12px;
  }

  .avatar {
    width: 60px;
    height: 60px;
    margin-bottom: 8px;
  }

  .initial { font-size: 22px; }

  .footer {
    position: sticky;
    bottom: 0;
    z-index: 3;
    gap: 0;
    padding: 10px 12px calc(10px + env(safe-area-inset-bottom));
  }

  .dock-note { display: none; }

  .dock {
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
    gap: 8px;
    width: 100%;
  }

  .ctrl.icon {
    width: 100%;
    min-width: 0;
    height: 48px;
    justify-self: stretch;
  }

  .ctrl svg { width: 18px; height: 18px; }
  .screen video { max-height: 34vh; }
  .screen-expand { width: 44px; height: 44px; }
}

@media (prefers-reduced-motion: reduce) {
  .avatar { transition: none; }
}
