:root {
  color-scheme: dark;
  --bg: #080808;
  --panel: #191919;
  --surface: #111111;
  --line: #353535;
  --control-line: #626262;
  --text: #f7f5ef;
  --muted: #bdb9af;
  --accent: #f9c30c;
  --accent-ink: #151006;
  --accent-hover: #ffda57;
  --accent-wash: #352a13;
  --danger: #ffb1aa;
  font-family: "Avenir Next", "Segoe UI", system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; min-height: 100svh; }
button, select, input { font: inherit; }
a { color: inherit; }
a:hover { color: var(--accent); }
button, select { cursor: pointer; }
:disabled { cursor: default; opacity: .58; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 4px; }
h1, h2, h3, p, dl, dd { margin: 0; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }

.site-header { background: var(--bg); border-bottom: 1px solid var(--line); }
.header-inner, .site-footer { display: flex; align-items: center; justify-content: space-between; gap: 1rem; max-width: 1152px; margin: auto; min-height: 74px; padding: .7rem 1.5rem; }
.brand { position: relative; display: block; flex: none; width: 7rem; height: 3.6rem; overflow: hidden; }
.brand img { position: absolute; inset: 50% auto auto 50%; width: 11rem; height: auto; transform: translate(-50%, -50%); }

.listener { display: flex; flex-direction: column; background: radial-gradient(ellipse at 50% 14%, #251d0d 0, var(--bg) 62%); }
.listener-main { width: min(100% - 2rem, 490px); margin: 0 auto; padding: clamp(2.25rem, 6vh, 4.75rem) 0 2.25rem; flex: 1; }
.intro { text-align: center; margin-bottom: 1.9rem; }
.eyebrow, .label { color: var(--accent); font-size: .82rem; font-weight: 750; letter-spacing: .13em; line-height: 1.4; }
h1 { font-size: clamp(2.12rem, 5vw, 3.2rem); font-weight: 750; line-height: 1.06; letter-spacing: -.055em; }
.intro h1 { font-size: clamp(2.9rem, 8.6vw, 5.75rem); margin: .65rem 0 .85rem; line-height: .98; }
.intro p, .headphones, .login-card p, .master-heading p:not(.eyebrow) { color: var(--muted); line-height: 1.5; }
.headphones { text-align: center; margin: 1.45rem auto 0; font-size: .94rem; }
.site-footer { width: 100%; min-height: 62px; border-top: 1px solid var(--line); font-size: .8rem; color: var(--muted); }
.site-footer span { letter-spacing: .08em; font-weight: 650; }

.player { padding: clamp(1rem, 4vw, 1.55rem); border: 1px solid var(--line); border-radius: 20px; background: var(--panel); box-shadow: 0 12px 45px #0006; }
.player-header { display: flex; gap: .8rem; align-items: center; }
.player-icon { display: inline-flex; flex: none; align-items: center; justify-content: center; gap: 3px; width: 44px; height: 44px; border-radius: 9px; background: var(--accent-wash); }
.player-icon i { width: 3px; height: 11px; border-radius: 3px; background: var(--accent); }
.player-icon i:nth-child(2), .player-icon i:nth-child(4) { height: 17px; }
.player-icon i:nth-child(3) { height: 24px; }
.service { flex: 1; min-width: 0; }
.service .label { color: var(--muted); font-size: .75rem; }
.service h2 { font-size: 1.12rem; overflow-wrap: anywhere; }
.pill { display: inline-flex; align-items: center; justify-content: center; gap: .4rem; width: max-content; max-width: 48%; padding: .43rem .62rem; border: 1px solid var(--line); border-radius: 999px; color: var(--muted); font-size: .875rem; line-height: 1.15; font-weight: 650; background: var(--surface); }
.pill i { width: .42rem; height: .42rem; background: currentColor; border-radius: 50%; flex: none; }
.pill[data-state="LIVE"] { color: var(--accent); background: var(--accent-wash); border-color: #8a6b20; }
.pill[data-state="ERROR"] { color: var(--danger); border-color: #9d6966; }
.player-status { color: var(--muted); line-height: 1.45; margin: .95rem 0 1.2rem; min-height: 1.45em; }
.audio-language { display: grid; gap: .45rem; }
.field { display: grid; gap: .4rem; color: var(--muted); font-size: .9rem; font-weight: 650; min-width: 0; }
.field input, select { width: 100%; min-width: 0; min-height: 44px; padding: .68rem .85rem; color: var(--text); background: var(--surface); border: 1px solid var(--control-line); border-radius: 8px; }
select { appearance: none; padding-right: 2rem; background-image: linear-gradient(45deg, transparent 48%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 48%, transparent 50%); background-size: 6px 6px, 6px 6px; background-position: right 16px center, right 10px center; background-repeat: no-repeat; }
.interface-label { width: 9rem; }
.primary, .secondary { border-radius: 9px; padding: .65rem 1rem; font-weight: 750; min-height: 44px; }
.primary { background: var(--accent); color: var(--accent-ink); border: 1px solid var(--accent); }
.primary:hover:enabled { background: var(--accent-hover); }
.secondary { color: var(--text); background: var(--surface); border: 1px solid var(--control-line); }
.secondary:hover:enabled { border-color: var(--accent); }
.danger { color: var(--danger); }
.listen-button { display: flex; align-items: center; justify-content: center; gap: .65rem; width: 100%; min-height: 53px; margin-top: .7rem; font-size: 1rem; }
.play-icon { width: 0; height: 0; border: .43em solid transparent; border-left: .68em solid currentColor; border-right: 0; }
.play-icon.is-playing { width: .68em; height: .8em; border: 0; border-left: .2em solid currentColor; border-right: .2em solid currentColor; }
.volume { display: flex; align-items: center; gap: .75rem; font-size: .9rem; color: var(--muted); margin-top: 1.1rem; }
.volume input { flex: 1; min-width: 0; height: 32px; accent-color: var(--accent); }
.volume output { width: 3.1em; text-align: right; font-variant-numeric: tabular-nums; }

.master-main { width: min(1110px, 100% - 2rem); margin: 2.65rem auto; }
.master-heading, .header-actions, .controls { display: flex; align-items: center; gap: .55rem; flex-wrap: wrap; }
.header-actions { gap: .85rem; }
.header-actions a { font-size: .9rem; }
.master-heading { justify-content: space-between; margin: 1.5rem 0; }
.master-heading h1, .login-card h1 { margin: .48rem 0 .75rem; }
.metrics { display: grid; grid-template-columns: repeat(auto-fit, minmax(145px, 1fr)); gap: .65rem; margin-bottom: 1.1rem; }
.metrics div { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: .9rem; }
.metrics dt { color: var(--muted); font-size: .875rem; margin-bottom: .35rem; }
.metrics dd { font-weight: 750; }
.master-grid { display: grid; grid-template-columns: minmax(0, 2fr) minmax(265px, 1fr); gap: 1.1rem; align-items: start; }
.master-stack { display: grid; gap: 1.1rem; }
.console h2 { font-size: 1.15rem; margin-bottom: .95rem; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: .85rem; padding: 0; margin: 0; border: none; min-width: 0; }
.sermon-controls, .meter-wrap, .current-event { margin-top: 1rem; border-top: 1px solid var(--line); padding-top: .85rem; }
.meter-wrap label, .meter-wrap p, .current-event p, details, .qr-warning { font-size: .9rem; color: var(--muted); }
meter { display: block; width: 100%; height: 22px; margin: .2rem 0; accent-color: var(--accent); }
meter::-webkit-meter-bar { background: var(--surface); border-color: var(--control-line); }
meter::-webkit-meter-optimum-value, meter::-webkit-meter-suboptimum-value { background: var(--accent); }
meter::-webkit-meter-even-less-good-value { background: var(--danger); }
meter::-moz-meter-bar { background: var(--accent); }
.console .field + .controls { margin-top: .75rem; }
details { margin-top: .8rem; }
details .field { margin-top: .65rem; }
.qr-card img { display: block; padding: .32rem; background: white; border-radius: 8px; margin: .55rem 0 .9rem; }
.qr-card a { color: var(--accent); }
.qr-warning { margin-top: .5rem; }
.notice { padding: .78rem 1rem; border-radius: 8px; border: 1px solid var(--line); background: var(--surface); margin: 1rem auto; }
.notice[data-error="true"] { color: var(--danger); }
.login-card { width: min(100%, 430px); margin: clamp(1rem, 12vh, 7rem) auto 0; }
.login-card .eyebrow { color: var(--accent); }
.login-card form { display: grid; gap: .85rem; margin-top: 1.3rem; }
.login-card + .notice { max-width: 430px; }
.users-main { max-width: 820px; }
.users-main .console + .console { margin-top: 1rem; }
#invite-form { display: grid; gap: 1rem; }
#invite-form button { justify-self: start; }
.user-list { display: grid; gap: .75rem; padding: 0; margin: 0; list-style: none; }
.user-list li { display: flex; align-items: center; justify-content: space-between; gap: .75rem; flex-wrap: wrap; border-top: 1px solid var(--line); padding-top: .75rem; }
.user-list p { color: var(--muted); margin-top: .25rem; overflow-wrap: anywhere; }
.user-list li > div { min-width: 0; }
.activation-link { display: inline-block; margin-top: 1rem; color: var(--accent); }
.authenticator-setup, .recovery-panel { margin-top: 1rem; }
#back-to-login { margin-top: .75rem; }
.authenticator-setup img { display: block; max-width: 100%; height: auto; margin: .75rem 0; border-radius: 8px; }
.authenticator-setup code { color: var(--accent); overflow-wrap: anywhere; user-select: all; }
.recovery-panel h2 { font-size: 1.2rem; margin-bottom: .5rem; }
.recovery-panel ul { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: .5rem; padding: 0; list-style: none; }
.recovery-panel li { background: var(--surface); border: 1px solid var(--line); border-radius: 6px; padding: .5rem; }

@media (max-width: 710px) {
  .master-grid { grid-template-columns: 1fr; }
}
@media (max-width: 420px) {
  .form-grid { grid-template-columns: 1fr; }
  .header-inner, .site-footer { padding-inline: 1rem; }
}
