:root {
  --ink-0: #12141b;
  --ink-1: #191c25;
  --ink-2: #232733;
  --ink-3: #2f3442;
  --paper: #e9e6df;
  --dim: #858b9c;
  --brass: #d4a537;
  --brass-soft: rgba(212, 165, 55, 0.16);
  --rust: #c05a4e;
  --sans: ui-sans-serif, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --rail: 3px;
}

* { box-sizing: border-box; }

/* Author styles beat the browser's built-in [hidden] { display: none } rule,
   so any element given a display value below would ignore the hidden attribute.
   This restores it for all of them. Keep it above the layout rules. */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--ink-0);
  color: var(--paper);
  font-family: var(--sans);
  -webkit-font-smoothing: antialiased;
}

button, input, select { font: inherit; color: inherit; }

:focus-visible {
  outline: 2px solid var(--brass);
  outline-offset: 2px;
}

/* ------------------------------------------------------------------ entry */

.entry {
  min-height: 100dvh;
  display: flex;
  align-items: center;
  padding: 6vh 6vw;
}

.entry-inner {
  width: 100%;
  max-width: 34rem;
}

.wordmark {
  margin: 0 0 3.5rem;
  font-size: 0.9rem;
  font-weight: 600;
  letter-spacing: 0.18em;
  color: var(--dim);
}

/* The room name is the key to the door, so it gets to be the largest thing
   on the page and updates as you type. */
.plate {
  border-left: var(--rail) solid var(--brass);
  padding: 0.15em 0 0.15em 1.1rem;
  margin-bottom: 3rem;
  min-height: 3.2rem;
  display: flex;
  align-items: center;
}

.plate-name {
  font-size: clamp(2rem, 7vw, 3.4rem);
  font-weight: 300;
  letter-spacing: -0.03em;
  line-height: 1.05;
  word-break: break-word;
}

.plate-name.is-empty {
  color: var(--ink-3);
  font-style: italic;
}

.fields { display: grid; gap: 1.15rem; }

.field { display: grid; gap: 0.4rem; }

.field-label {
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--dim);
}

.field input, .field select {
  width: 100%;
  padding: 0.7rem 0.85rem;
  background: var(--ink-1);
  border: 1px solid var(--ink-3);
  border-radius: 5px;
  transition: border-color 0.15s;
}

.field input:focus, .field select:focus { border-color: var(--brass); }
.field input::placeholder { color: #4b5061; }

.knock {
  margin-top: 0.6rem;
  padding: 0.8rem 1.2rem;
  background: var(--brass);
  color: #17140b;
  font-weight: 650;
  border: 0;
  border-radius: 5px;
  cursor: pointer;
}

.knock:disabled { opacity: 0.5; cursor: progress; }
.knock-quiet { background: var(--ink-3); color: var(--paper); width: 100%; }

.error {
  margin: 0;
  padding: 0.6rem 0.8rem;
  background: rgba(192, 90, 78, 0.12);
  border-left: var(--rail) solid var(--rust);
  color: #f0b6ae;
  font-size: 0.9rem;
}

.fineprint {
  margin: 0.5rem 0 0;
  font-size: 0.8rem;
  line-height: 1.55;
  color: var(--dim);
  max-width: 46ch;
}

/* ------------------------------------------------------------------- call */

.call {
  height: 100dvh;
  display: grid;
  grid-template-rows: 1fr auto;
  overflow: hidden;
}

.stage {
  min-height: 0;
  padding: 0.5rem 0.5rem 0;
  display: grid;
  gap: 0.5rem;
  grid-auto-flow: column;
}

/* When a screen is being shared the stage takes the room and cameras shrink
   into a filmstrip along the bottom. */
.call.has-stage .grid {
  grid-template-columns: none;
  grid-auto-flow: column;
  grid-auto-columns: minmax(140px, 190px);
  height: 150px;
  overflow-x: auto;
  overflow-y: hidden;
}

.call.has-stage { grid-template-rows: 1fr auto auto; }

.grid {
  min-height: 0;
  padding: 0.5rem;
  display: grid;
  gap: 0.5rem;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 300px), 1fr));
  align-content: center;
}

.tile {
  position: relative;
  min-height: 0;
  background: var(--ink-1);
  border: 2px solid transparent;
  border-radius: 8px;
  overflow: hidden;
  transition: border-color 0.12s ease-out;
}

/* The one loud element in the interface: who is talking. */
.tile.speaking {
  border-color: var(--brass);
  box-shadow: 0 0 0 1px var(--brass-soft), 0 0 22px -6px var(--brass);
}

.tile video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  background: var(--ink-1);
}

.tile.screen video { object-fit: contain; background: #000; }
.tile.mirror video { transform: scaleX(-1); }
.tile.no-video video { visibility: hidden; }

.tile-initial {
  position: absolute;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  font-size: clamp(1.8rem, 5vw, 3rem);
  font-weight: 300;
  color: var(--ink-3);
  background: var(--ink-1);
}

.tile.no-video .tile-initial { display: flex; }

.tile-bar {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.4rem 0.55rem;
  font-size: 0.78rem;
  background: linear-gradient(transparent, rgba(9, 10, 14, 0.82));
}

.tile-name { font-weight: 600; }
.tile-flag { color: var(--rust); }
.tile-stats { margin-left: auto; color: var(--dim); font-variant-numeric: tabular-nums; }
.tile-stats[hidden] { display: none; }

.tile-status {
  position: absolute;
  top: 0.5rem; left: 0.55rem;
  padding: 0.15rem 0.45rem;
  border-radius: 3px;
  background: rgba(9, 10, 14, 0.75);
  font-size: 0.72rem;
  color: var(--brass);
}

.tile-status[hidden] { display: none; }

/* ---------------------------------------------------------------- console */

.console {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
  padding: 0.55rem 0.9rem calc(0.55rem + env(safe-area-inset-bottom));
  background: var(--ink-1);
  border-top: 1px solid var(--ink-2);
}

.console-meta {
  display: flex;
  align-items: baseline;
  gap: 0.6rem;
  min-width: 0;
}

.meta-room {
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 12rem;
}

.meta-count { font-size: 0.82rem; color: var(--dim); white-space: nowrap; }

.console-actions {
  display: flex;
  gap: 0.4rem;
  margin-left: auto;
  flex-wrap: wrap;
}

.ctl {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.55rem 0.8rem;
  background: var(--ink-2);
  border: 1px solid transparent;
  border-radius: 5px;
  cursor: pointer;
  white-space: nowrap;
}

.ctl:hover { background: var(--ink-3); }

/* aria-pressed marks the "off" state for mic and camera. */
.ctl[aria-pressed="true"] {
  background: rgba(192, 90, 78, 0.18);
  border-color: var(--rust);
  color: #f0b6ae;
}

#btn-screen[aria-pressed="true"] {
  background: var(--brass-soft);
  border-color: var(--brass);
  color: var(--brass);
}

.ctl-leave { background: var(--rust); color: #1a0e0c; font-weight: 650; }
.ctl-leave:hover { background: #d16a5e; }

.ctl-glyph { font-size: 1rem; line-height: 1; }

/* ------------------------------------------------------------ panel/toast */

.panel {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 1.5rem;
  background: rgba(9, 10, 14, 0.72);
  z-index: 20;
}

.panel-card {
  width: min(30rem, 100%);
  max-height: 85dvh;
  overflow-y: auto;
  display: grid;
  gap: 1.05rem;
  padding: 1.5rem;
  background: var(--ink-1);
  border: 1px solid var(--ink-3);
  border-radius: 9px;
}

.panel-card h2 { margin: 0; font-size: 1.15rem; font-weight: 600; }

.check {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  font-size: 0.9rem;
  color: var(--dim);
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 5.5rem;
  transform: translateX(-50%);
  padding: 0.6rem 1rem;
  background: var(--ink-2);
  border: 1px solid var(--ink-3);
  border-radius: 5px;
  font-size: 0.88rem;
  z-index: 30;
}

@media (max-width: 620px) {
  .ctl-text { display: none; }
  .ctl { padding: 0.6rem 0.7rem; }
  .ctl-leave .ctl-text { display: inline; }
  .console-meta { width: 100%; }
  .console-actions { margin-left: 0; width: 100%; justify-content: space-between; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
