/* Live — dark only. It gets used in the dark, at the side of a stage. */

:root {
  --bg:          #000000;
  --surface:     #141416;
  --surface-2:   #1c1c1f;
  --surface-3:   #2a2a2e;
  --hairline:    rgba(255, 255, 255, 0.10);
  --hairline-2:  rgba(255, 255, 255, 0.16);

  --text:        #f5f5f7;
  --text-2:      rgba(235, 235, 245, 0.62);
  --text-3:      rgba(235, 235, 245, 0.32);

  --blue:        #0a84ff;
  --blue-dim:    rgba(10, 132, 255, 0.16);
  --red:         #ff453a;
  --red-dim:     rgba(255, 69, 58, 0.14);
  --amber:       #ff9f0a;
  --amber-dim:   rgba(255, 159, 10, 0.14);
  --green:       #30d158;

  --radius:      0;
  --radius-lg:   0;
  --topbar-h:    50px;
  --tabbar-h:    52px;

  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;

  color-scheme: dark;
}

* { box-sizing: border-box; }

/* Several elements below set `display`, which would otherwise beat the
   `hidden` attribute and leave empty strips in the layout. */
[hidden] { display: none !important; }

html, body {
  height: 100%;
  margin: 0;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
}

body.is-locked { overflow: hidden; }

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

::selection { background: var(--blue-dim); }

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

/* ------------------------------------------------------------- type bits */

.wordmark {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.14em;
  color: var(--text);
}

.booting {
  display: grid;
  place-content: center;
  gap: 16px;
  height: 100%;
  color: var(--text-2);
  text-align: center;
  padding: 24px;
}

.empty {
  margin: 0;
  padding: 28px 18px;
  color: var(--text-3);
  text-align: center;
  font-size: 14px;
}

/* --------------------------------------------------------------- controls */

.btn {
  appearance: none;
  border: 1px solid var(--hairline-2);
  background: var(--surface-2);
  color: var(--text);
  border-radius: var(--radius);
  padding: 10px 16px;
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
  transition: background 120ms ease, opacity 120ms ease;
}

.btn:hover { background: var(--surface-3); }
.btn:active { opacity: 0.7; }
.btn:disabled { opacity: 0.45; cursor: default; }

.btn--primary {
  background: var(--blue);
  border-color: var(--blue);
  color: #fff;
}
.btn--primary:hover { background: #3a9bff; }

.btn--danger { color: var(--red); border-color: rgba(255, 69, 58, 0.35); }
.btn--danger:hover { background: var(--red-dim); }

.btn--quiet {
  background: none;
  border-color: transparent;
  color: var(--blue);
}
.btn--quiet:hover { background: var(--blue-dim); }

.btn--block { width: 100%; }
.btn--small { padding: 7px 12px; font-size: 14px; }

.iconbtn {
  appearance: none;
  border: none;
  background: none;
  color: var(--text-2);
  font-size: 17px;
  line-height: 1;
  width: 34px;
  height: 34px;
  border-radius: var(--radius);
  cursor: pointer;
}
.iconbtn:hover { background: var(--surface-2); color: var(--text); }
.iconbtn.is-admin { color: var(--blue); }

.chip {
  appearance: none;
  border: 1px solid var(--hairline-2);
  background: transparent;
  color: var(--text-2);
  border-radius: 0;
  padding: 6px 12px;
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  cursor: pointer;
}
.chip:hover { background: var(--surface-2); }
.chip.is-on {
  background: var(--blue);
  border-color: var(--blue);
  color: #fff;
}
.chip--fault { color: var(--red); border-color: rgba(255, 69, 58, 0.4); }
.chip--fault.is-on { background: var(--red); border-color: var(--red); color: #fff; }
.chip--urgent-toggle.is-on { background: var(--amber); border-color: var(--amber); color: #000; }
.chip--lg { padding: 11px 18px; font-size: 15px; }

.field {
  width: 100%;
  background: var(--surface-2);
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
  padding: 11px 13px;
  color: var(--text);
  font-size: 16px; /* 16px stops iOS zooming on focus */
}
.field::placeholder { color: var(--text-3); }
.field:focus {
  outline: none;
  border-color: var(--blue);
  background: var(--surface-3);
}
.field:disabled, .field[readonly] { color: var(--text-2); }
.field--mono { font-family: var(--mono); font-size: 15px; }
.field--area { resize: vertical; min-height: 60px; line-height: 1.5; }
.field--search { background: var(--surface-2); }
.field--code {
  font-family: var(--mono);
  font-size: 22px;
  letter-spacing: 0.16em;
  text-align: center;
  padding: 14px;
}

/* ------------------------------------------------------------ join screen */

.gate {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 24px 16px calc(24px + env(safe-area-inset-bottom));
}

.gate__card {
  width: 100%;
  max-width: 380px;
}

.gate__brand {
  display: flex;
  align-items: baseline;
  gap: 10px;
  padding-bottom: 20px;
  margin-bottom: 20px;
  border-bottom: 1px solid var(--hairline);
}

.gate__tagline { color: var(--text-3); font-size: 13px; }

.gate__form { display: grid; gap: 10px; }

.gate__label {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-3);
  margin-top: 8px;
}

.gate__showname { margin: 0; font-size: 17px; font-weight: 600; }
.gate__hint { margin: -2px 0 0; font-size: 13px; color: var(--text-3); }
.gate__error {
  margin: 4px 0 0;
  font-size: 14px;
  color: var(--red);
}

.gate__positions { display: flex; flex-wrap: wrap; gap: 8px; }

/* ------------------------------------------------------------------ shell */

.app {
  display: flex;
  flex-direction: column;
  height: 100dvh;
}

/* Fixed chrome. The board is the only part that flexes. */
.topbar,
.banner,
.tabbar { flex: none; }

.topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  height: var(--topbar-h);
  padding: 0 14px;
  padding-top: env(safe-area-inset-top);
  border-bottom: 1px solid var(--hairline);
  background: var(--surface);
}

.topbar__mid {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: baseline;
  gap: 10px;
}

.topbar__show {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-2);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.topbar__faults {
  flex: none;
  font-size: 12px;
  font-weight: 600;
  color: var(--red);
  background: var(--red-dim);
  padding: 2px 8px;
  border-radius: 0;
}

.topbar__right { display: flex; align-items: center; gap: 10px; }

.topbar__conn {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-3);
}
.topbar__conn.is-online { background: var(--green); }
.topbar__conn.is-offline { background: var(--amber); }

.topbar__online {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text-3);
  font-variant-numeric: tabular-nums;
}

.banner {
  padding: 8px 14px;
  font-size: 13px;
  display: flex;
  gap: 12px;
  justify-content: space-between;
  border-bottom: 1px solid var(--hairline);
}
.banner--offline { background: var(--amber-dim); color: var(--amber); }
.banner__queued { color: var(--text-2); white-space: nowrap; }

.board {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(320px, 400px);
  min-height: 0;
}

.panel {
  display: flex;
  flex-direction: column;
  min-height: 0;
  min-width: 0;
}

.mics__toolbar,
.chat__tabs,
.composer { flex: none; }

.mics__list,
.chat__body { flex: 1; min-height: 0; }

/* Holds the stream plus the floating jump-to-latest button. */
.chat__body {
  position: relative;
  display: flex;
}

.jump {
  position: absolute;
  right: 14px;
  bottom: 14px;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 34px;
  padding: 7px 12px;
  border: 1px solid var(--hairline-2);
  background: var(--surface-3);
  color: var(--text);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.6);
}
.jump:hover { background: var(--blue); border-color: var(--blue); color: #fff; }

.jump.is-new {
  background: var(--blue);
  border-color: var(--blue);
  color: #fff;
}

.jump__arrow { font-size: 14px; line-height: 1; }

.jump__count {
  font-variant-numeric: tabular-nums;
  font-family: var(--mono);
  font-size: 12px;
}

.chat__stream { flex: 1; }

.chat { border-left: 1px solid var(--hairline); }

/* ------------------------------------------------------------------- mics */

.mics__toolbar {
  display: flex;
  gap: 8px;
  align-items: center;
  padding: 10px 14px;
  border-bottom: 1px solid var(--hairline);
}
.mics__toolbar .field--search { flex: 1; }

.mics__list {
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  min-height: 0;
}

.mic {
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--hairline);
  cursor: pointer;
}
.mic:hover { background: var(--surface); }
.mic--fault { background: var(--red-dim); }
.mic--fault:hover { background: rgba(255, 69, 58, 0.2); }

.mic__number {
  font-family: var(--mono);
  font-size: 19px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--text);
  text-align: right;
}

.mic__who { min-width: 0; display: grid; }

.mic__performer,
.mic__character,
.mic__note {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.mic__performer { font-size: 15px; }
.mic__character { font-size: 13px; color: var(--text-2); }
.mic__note { font-size: 13px; color: var(--amber); }
.mic__note::before { content: '↳ '; color: var(--text-3); }

.mic__rf {
  display: grid;
  justify-items: end;
  font-family: var(--mono);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  color: var(--text-2);
}
.mic__freq { color: var(--text-3); }

.status {
  appearance: none;
  border: 1px solid var(--hairline-2);
  background: transparent;
  color: var(--text-2);
  border-radius: var(--radius);
  min-width: 62px;
  padding: 8px 10px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  cursor: pointer;
}
.status--ok:hover { border-color: rgba(255, 69, 58, 0.5); color: var(--red); }
.status--fault {
  background: var(--red);
  border-color: var(--red);
  color: #fff;
}

/* ------------------------------------------------------------------- chat */

.chat__tabs {
  display: flex;
  gap: 4px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--hairline);
  overflow-x: auto;
  scrollbar-width: none;
}
.chat__tabs::-webkit-scrollbar { display: none; }

.tab {
  appearance: none;
  border: none;
  background: none;
  color: var(--text-2);
  border-radius: 0;
  padding: 6px 10px;
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
}
.tab:hover { background: var(--surface-2); }
.tab.is-on { background: var(--surface-3); color: var(--text); }

.tab__badge {
  background: var(--blue);
  color: #fff;
  border-radius: 0;
  padding: 0 6px;
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}

.chat__stream {
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  min-height: 0;
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.msg { max-width: 92%; }

.msg__meta {
  display: flex;
  gap: 8px;
  align-items: baseline;
  margin-bottom: 1px;
}

.msg__author {
  font-size: 12px;
  font-weight: 600;
  color: var(--blue);
}

.msg__time {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text-3);
  font-variant-numeric: tabular-nums;
}

.msg__body {
  font-size: 15px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.msg--mine { margin-left: auto; }
.msg--mine .msg__meta { justify-content: flex-end; }
.msg--mine .msg__author { color: var(--text-2); }
.msg--mine .msg__body { text-align: right; }

.msg--pending { opacity: 0.55; }

.msg--urgent {
  border-left: 3px solid var(--amber);
  background: var(--amber-dim);
  border-radius: 0 var(--radius) var(--radius) 0;
  padding: 6px 10px;
  max-width: 100%;
  margin-left: 0;
}
.msg--urgent .msg__body { text-align: left; }
.msg--urgent .msg__meta { justify-content: flex-start; }

.msg--system {
  max-width: 100%;
  display: flex;
  gap: 8px;
  align-items: baseline;
  padding: 6px 10px;
  border-left: 3px solid var(--red);
  background: var(--red-dim);
  border-radius: 0 var(--radius) var(--radius) 0;
  font-size: 13px;
  color: var(--text);
}

.micref {
  appearance: none;
  border: none;
  background: var(--blue-dim);
  color: var(--blue);
  border-radius: 0;
  padding: 0 5px;
  font-family: var(--mono);
  font-size: 13px;
  cursor: pointer;
}
.micref:hover { background: var(--blue); color: #fff; }

.composer {
  display: flex;
  gap: 8px;
  align-items: flex-end;
  padding: 10px 12px calc(10px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--hairline);
  background: var(--surface);
}

.composer__input {
  flex: 1;
  resize: none;
  background: var(--surface-2);
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
  padding: 10px 12px;
  font-size: 16px;
  line-height: 1.4;
  max-height: 140px;
}
.composer__input:focus { outline: none; border-color: var(--blue); }

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

/* ------------------------------------------------------------- tab bar */

.tabbar { display: none; }

/* ------------------------------------------------------------ sheet */

.overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(2px);
  display: grid;
  place-items: center;
  padding: 20px;
  z-index: 40;
}

.sheet {
  width: 100%;
  max-width: 460px;
  max-height: 86vh;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  background: var(--surface);
  border: 1px solid var(--hairline-2);
  border-radius: var(--radius-lg);
  overflow: hidden;
}
.sheet--wide { max-width: 620px; }
.sheet:focus { outline: none; }

.sheet__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--hairline);
}

.sheet__title { margin: 0; font-size: 16px; font-weight: 600; }

.sheet__close {
  appearance: none;
  border: none;
  background: none;
  color: var(--text-3);
  font-size: 15px;
  cursor: pointer;
  padding: 4px 6px;
  border-radius: 0;
}
.sheet__close:hover { color: var(--text); background: var(--surface-2); }

.sheet__body {
  overflow-y: auto;
  padding: 16px;
  display: grid;
  gap: 12px;
}

.sheet__row { display: grid; gap: 5px; }

.sheet__label {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--text-3);
}

.sheet__heading {
  margin: 8px 0 0;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--text-3);
}

.sheet__error { margin: 0; color: var(--red); font-size: 14px; }
.sheet__error:empty { display: none; }

.sheet__actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--hairline);
}

/* --------------------------------------------------------------- log */

.log { display: grid; gap: 2px; }

.log__row {
  display: grid;
  grid-template-columns: 62px minmax(0, 1fr);
  gap: 10px;
  padding: 5px 0;
  border-bottom: 1px solid var(--hairline);
  font-size: 13px;
}

.log__time { font-family: var(--mono); font-size: 11px; color: var(--text-3); }
.log__text { color: var(--text-2); }
.log__empty { margin: 0; color: var(--text-3); font-size: 13px; }

/* ---------------------------------------------------------- settings */

.settings { gap: 4px; }

.settings__block {
  display: grid;
  gap: 10px;
  padding: 16px 0;
  border-bottom: 1px solid var(--hairline);
}
.settings__block:last-child { border-bottom: none; }
.settings__block .btn { justify-self: start; }

.settings__note { margin: 0; font-size: 13px; color: var(--text-3); }
.settings__subheading { margin: 6px 0 0; font-size: 13px; color: var(--text-2); font-weight: 600; }
.settings__locked { margin: 0; font-size: 14px; color: var(--amber); }

.settings__check {
  display: flex;
  gap: 8px;
  align-items: center;
  font-size: 14px;
  color: var(--text-2);
}
.settings__check input { accent-color: var(--blue); width: 16px; height: 16px; }

.list-editor { display: grid; gap: 8px; }
.list-editor__row { display: flex; gap: 8px; }
.list-editor__row .field { flex: 1; }

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

.import__table {
  width: 100%;
  border-collapse: collapse;
  font-family: var(--mono);
  font-size: 12px;
}
.import__table th {
  text-align: left;
  font-weight: 600;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 4px 8px 4px 0;
  border-bottom: 1px solid var(--hairline);
}
.import__table td {
  padding: 4px 8px 4px 0;
  border-bottom: 1px solid var(--hairline);
  color: var(--text-2);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 130px;
}

.presence { display: grid; gap: 6px; }
.presence__row { display: flex; align-items: center; gap: 10px; font-size: 14px; }
.presence__name { flex: 1; }
.presence__state { font-size: 12px; color: var(--text-3); }

.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--surface-3);
  flex: none;
}
.dot--on { background: var(--green); }

.archive { display: grid; gap: 4px; }
.archive__row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 0;
  border-bottom: 1px solid var(--hairline);
}
.archive__count { display: block; font-size: 14px; }
.archive__meta { display: block; font-size: 12px; color: var(--text-3); }
.archive__done { font-size: 12px; color: var(--green); }

/* --------------------------------------------------- page alert */

.pagealert {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: grid;
  place-items: center;
  padding: 24px;
  text-align: center;
  background: var(--red);
  color: #fff;
  animation: pagepulse 1s ease-in-out infinite;
}

@keyframes pagepulse {
  0%, 100% { background: #d70015; }
  50%      { background: #ff453a; }
}

.pagealert__inner { display: grid; gap: 10px; max-width: 520px; }

.pagealert__label {
  margin: 0;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.3em;
  opacity: 0.85;
}

.pagealert__from {
  margin: 0;
  font-size: clamp(34px, 12vw, 64px);
  font-weight: 700;
  line-height: 1.05;
}

.pagealert__body {
  margin: 0;
  font-size: clamp(17px, 5vw, 22px);
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.pagealert__time {
  margin: 0;
  font-family: var(--mono);
  font-size: 14px;
  opacity: 0.8;
}

.pagealert__hint {
  margin: 12px 0 0;
  font-size: 14px;
  opacity: 0.75;
}

.btn--page {
  color: var(--red);
  border-color: rgba(255, 69, 58, 0.45);
  background: transparent;
}
.btn--page:hover { background: var(--red-dim); }

/* A page must still read as urgent for anyone who cannot take the flashing. */
@media (prefers-reduced-motion: reduce) {
  .pagealert { animation: none; background: #d70015; }
}

/* ------------------------------------------------- channel visibility */

.channel-edit {
  display: grid;
  gap: 8px;
  padding: 10px;
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
  background: var(--surface-2);
}

.channel-edit__who { display: grid; gap: 6px; }

.channel-edit__label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-3);
}

.channel-edit__chips { display: flex; flex-wrap: wrap; gap: 6px; }

.gate__positions .chip { display: inline-flex; align-items: center; gap: 8px; }

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

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(24px + env(safe-area-inset-bottom));
  transform: translate(-50%, 12px);
  background: var(--surface-3);
  border: 1px solid var(--hairline-2);
  color: var(--text);
  padding: 10px 16px;
  border-radius: 0;
  font-size: 14px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 160ms ease, transform 160ms ease;
  z-index: 60;
  max-width: calc(100vw - 32px);
  text-align: center;
}
.toast.is-on { opacity: 1; transform: translate(-50%, 0); }
.toast--error { border-color: rgba(255, 69, 58, 0.5); color: var(--red); }

/* -------------------------------------------------------------- narrow */

@media (max-width: 860px) {
  .board {
    grid-template-columns: 1fr;
  }

  .board > .panel { display: none; }
  .board[data-view="mics"] > .mics,
  .board[data-view="chat"] > .chat { display: flex; }

  .chat { border-left: none; }

  .tabbar {
    display: grid;
    grid-template-columns: 1fr 1fr;
    height: var(--tabbar-h);
    padding-bottom: env(safe-area-inset-bottom);
    border-top: 1px solid var(--hairline);
    background: var(--surface);
  }

  .tabbar__btn {
    appearance: none;
    border: none;
    background: none;
    color: var(--text-3);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
  }
  .tabbar__btn.is-on { color: var(--blue); }

  .tabbar__badge {
    background: var(--blue);
    color: #fff;
    border-radius: 0;
    padding: 0 6px;
    font-size: 11px;
    font-variant-numeric: tabular-nums;
  }

  .composer { padding-bottom: 10px; }

  .overlay { padding: 0; align-items: end; }
  .sheet {
    max-width: none;
    max-height: 92vh;
    border-radius: 0;
    border-bottom: none;
  }
}

@media (max-width: 420px) {
  .mic { grid-template-columns: 40px minmax(0, 1fr) auto; gap: 10px; }
  .mic__rf { display: none; }
  .mics__toolbar { flex-wrap: wrap; }
}

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