:root {
  --bg: #0e1116;
  --panel: #161b22;
  --panel-2: #1c232d;
  --line: #2a323d;
  --text: #e7edf4;
  --muted: #8b98a9;
  --accent: #3b82f6;
  --live: #22c55e;
  --live-dim: #14532d;
  --warn: #f59e0b;
  --warn-dim: #4a3208;
  --bad: #ef4444;
  --bad-dim: #481b1b;
  --radius: 12px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}

* {
  box-sizing: border-box;
}

/* Several panels below set `display`, which would otherwise beat the user
   agent rule for [hidden] and leave the modal covering the page. */
[hidden] {
  display: none !important;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.45;
  -webkit-text-size-adjust: 100%;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

h1,
h2 {
  margin: 0;
  font-weight: 650;
}

.muted {
  color: var(--muted);
}
.small {
  font-size: 0.82rem;
}
.error-text {
  color: var(--bad);
  font-size: 0.9rem;
  margin: 0;
}

/* ------------------------------------------------------------------ login */

.login {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-card {
  width: min(360px, 100%);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 28px 24px;
  display: grid;
  gap: 14px;
}

.login-card h1 {
  font-size: 1.25rem;
}

/* ----------------------------------------------------------------- layout */

main {
  max-width: 780px;
  margin: 0 auto;
  padding: 16px 16px 48px;
  display: grid;
  gap: 16px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-top: 8px;
}

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

.topbar h1 {
  font-size: 1.05rem;
  letter-spacing: 0.01em;
}

.topbar-meta {
  display: flex;
  align-items: center;
  gap: 12px;
}

.clock {
  font-family: var(--mono);
  font-size: 0.9rem;
  color: var(--muted);
}

.dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--muted);
  transition: background 0.2s;
}
.dot.ok {
  background: var(--live);
}
.dot.busy {
  background: var(--accent);
}
.dot.bad {
  background: var(--bad);
}

/* ----------------------------------------------------------------- banner */

.banner {
  border-radius: var(--radius);
  padding: 20px;
  border: 1px solid var(--line);
  background: var(--panel);
}

.banner-state {
  font-size: 1.6rem;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.banner-detail {
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.95rem;
}

.banner-live {
  background: linear-gradient(180deg, rgba(34, 197, 94, 0.16), rgba(34, 197, 94, 0.05));
  border-color: rgba(34, 197, 94, 0.45);
}
.banner-live .banner-state {
  color: var(--live);
}

.banner-dropped {
  background: linear-gradient(180deg, rgba(239, 68, 68, 0.18), rgba(239, 68, 68, 0.05));
  border-color: rgba(239, 68, 68, 0.5);
}
.banner-dropped .banner-state {
  color: var(--bad);
}

.banner-upcoming {
  background: linear-gradient(180deg, rgba(59, 130, 246, 0.16), rgba(59, 130, 246, 0.05));
  border-color: rgba(59, 130, 246, 0.45);
}
.banner-upcoming .banner-state {
  color: var(--accent);
}

.banner-off .banner-state,
.banner-unknown .banner-state {
  color: var(--muted);
}

/* ------------------------------------------------------------------ cards */

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  display: grid;
  gap: 12px;
}

.card-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.card-title {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  font-weight: 600;
}

/* ----------------------------------------------------------------- on air */

.onair {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.onair-title {
  font-size: 1.15rem;
  font-weight: 600;
  overflow-wrap: anywhere;
}

.onair-sub {
  font-size: 0.85rem;
}

.onair-remaining {
  font-family: var(--mono);
  font-size: 1.3rem;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.progress {
  height: 5px;
  background: var(--panel-2);
  border-radius: 999px;
  overflow: hidden;
}

.progress-bar {
  height: 100%;
  width: 0;
  background: var(--accent);
  border-radius: 999px;
  transition: width 0.4s linear;
}

.schedule {
  display: grid;
  gap: 6px;
}

.schedule-row {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.88rem;
  padding: 7px 10px;
  background: var(--panel-2);
  border-radius: 8px;
  border-left: 3px solid var(--line);
}

.schedule-row.is-onair {
  border-left-color: var(--live);
}
.schedule-row.is-dropped {
  border-left-color: var(--bad);
}
.schedule-row.is-upcoming {
  border-left-color: var(--accent);
}

.schedule-time {
  font-family: var(--mono);
  color: var(--muted);
  white-space: nowrap;
}

.schedule-title {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.schedule-mount {
  font-family: var(--mono);
  font-size: 0.8rem;
  color: var(--muted);
}

/* ----------------------------------------------------------------- mounts */

.mounts {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 8px;
}

.mount {
  text-align: left;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
  color: var(--text);
  font: inherit;
  cursor: pointer;
  display: grid;
  gap: 3px;
  transition:
    border-color 0.15s,
    background 0.15s;
}

.mount:hover {
  border-color: #3d4756;
}

.mount.selected {
  border-color: var(--accent);
  background: rgba(59, 130, 246, 0.1);
}

.mount.up {
  border-left: 3px solid var(--live);
}
.mount.down {
  border-left: 3px solid #39414d;
}

.mount-name {
  font-family: var(--mono);
  font-size: 0.92rem;
  display: flex;
  align-items: center;
  gap: 7px;
}

.mount-state {
  font-size: 0.78rem;
  font-weight: 600;
}
.mount.up .mount-state {
  color: var(--live);
}
.mount.down .mount-state {
  color: var(--muted);
}

.mount-info {
  font-size: 0.75rem;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

/* What the encoder says it is sending, which is how a presenter confirms the
   mount is carrying their audio and not somebody else's. */
.mount-now {
  font-size: 0.72rem;
  color: #7dd3a0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.badge-scheduled {
  font-size: 0.62rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  background: rgba(59, 130, 246, 0.2);
  color: #93c5fd;
  border-radius: 4px;
  padding: 1px 5px;
  font-family: var(--font);
  font-weight: 700;
}

/* ----------------------------------------------------------------- fields */

.field-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.field {
  display: grid;
  gap: 5px;
  flex: 1;
  min-width: 180px;
}

.field-narrow {
  flex: 0 0 110px;
  min-width: 110px;
}

.field-label {
  font-size: 0.76rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
}

input,
select {
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  font: inherit;
  padding: 10px 12px;
  width: 100%;
  min-height: 44px;
}

input:focus,
select:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
  border-color: transparent;
}

/* ---------------------------------------------------------------- buttons */

.btn {
  border: 1px solid transparent;
  border-radius: 9px;
  font: inherit;
  font-weight: 600;
  padding: 12px 18px;
  min-height: 46px;
  cursor: pointer;
  color: var(--text);
  background: var(--panel-2);
  transition:
    filter 0.15s,
    opacity 0.15s;
}

.btn:hover:not(:disabled) {
  filter: brightness(1.15);
}
.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--live);
  color: #04240f;
}

.btn-secondary {
  background: var(--panel-2);
  border-color: var(--line);
}

.btn-ghost {
  background: transparent;
  border-color: var(--line);
  color: var(--muted);
}

.btn-danger {
  background: var(--bad);
  color: #fff;
}

.btn-sm {
  padding: 6px 12px;
  min-height: 34px;
  font-size: 0.85rem;
}

.actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.actions .btn {
  flex: 1;
  min-width: 140px;
}

/* ------------------------------------------------------------ readiness */

.ready {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-radius: 9px;
  font-size: 0.9rem;
  font-weight: 600;
  border: 1px solid var(--line);
  background: var(--panel-2);
}

.ready-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--muted);
  flex: 0 0 auto;
}

.ready-armed {
  border-color: rgba(34, 197, 94, 0.5);
  background: rgba(34, 197, 94, 0.1);
  color: var(--live);
}
.ready-armed .ready-dot {
  background: var(--live);
  box-shadow: 0 0 0 4px rgba(34, 197, 94, 0.18);
}

.ready-bad {
  border-color: rgba(239, 68, 68, 0.5);
  background: rgba(239, 68, 68, 0.1);
  color: var(--bad);
}
.ready-bad .ready-dot {
  background: var(--bad);
}

.ready-unknown {
  color: var(--muted);
}
.ready-unknown .ready-dot {
  background: var(--accent);
}

/* ------------------------------------------------------------- duration */

.duration {
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 12px 14px;
  margin: 0;
  display: grid;
  gap: 10px;
}

.duration legend {
  padding: 0 6px;
}

.radio {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.95rem;
  cursor: pointer;
}

.radio input[type="radio"] {
  width: auto;
  min-height: 0;
  margin: 0;
  accent-color: var(--accent);
}

.inline-number {
  width: 80px;
  min-height: 38px;
  padding: 6px 8px;
  text-align: center;
}

/* ----------------------------------------------------------------- probe */

.probe {
  border-radius: 9px;
  padding: 12px 14px;
  font-size: 0.9rem;
  border: 1px solid var(--line);
  background: var(--panel-2);
  display: grid;
  gap: 4px;
}

.probe.ok {
  border-color: rgba(34, 197, 94, 0.5);
  background: rgba(34, 197, 94, 0.09);
}
.probe.fail {
  border-color: rgba(239, 68, 68, 0.5);
  background: rgba(239, 68, 68, 0.09);
}

.probe-head {
  font-weight: 650;
}
.probe.ok .probe-head {
  color: var(--live);
}
.probe.fail .probe-head {
  color: var(--bad);
}

.probe-detail {
  color: var(--muted);
  overflow-wrap: anywhere;
}

/* ----------------------------------------------------------------- alerts */

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

.alert {
  border-radius: 9px;
  padding: 11px 14px;
  font-size: 0.9rem;
  border: 1px solid var(--line);
  background: var(--panel);
}

.alert-warn {
  border-color: rgba(245, 158, 11, 0.45);
  background: rgba(245, 158, 11, 0.1);
}

.alert-error {
  border-color: rgba(239, 68, 68, 0.5);
  background: rgba(239, 68, 68, 0.1);
}

/* ---------------------------------------------------------------- history */

.history {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 6px;
  font-size: 0.85rem;
}

.history li {
  display: flex;
  gap: 10px;
  padding: 6px 0;
  border-bottom: 1px solid var(--line);
}

.history li:last-child {
  border-bottom: none;
}

.history-time {
  font-family: var(--mono);
  color: var(--muted);
  white-space: nowrap;
}

/* ------------------------------------------------------------------ modal */

.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  display: grid;
  place-items: center;
  padding: 20px;
  z-index: 50;
}

.modal-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 22px;
  width: min(420px, 100%);
  display: grid;
  gap: 14px;
}

.modal-card h2 {
  font-size: 1.15rem;
}

.modal-body {
  font-size: 0.92rem;
  color: var(--muted);
  display: grid;
  gap: 8px;
}

.modal-body strong {
  color: var(--text);
}

.modal-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}

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

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 12px 18px;
  font-size: 0.9rem;
  max-width: min(520px, calc(100vw - 32px));
  z-index: 60;
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.45);
}

.toast.ok {
  border-color: rgba(34, 197, 94, 0.55);
}
.toast.bad {
  border-color: rgba(239, 68, 68, 0.55);
}

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