/* Visual style follows the original listener: light or dark from the system,
   captions filling the screen, a frosted bar at the bottom. */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
[hidden] { display: none !important; }

:root {
  --bg: #ffffff;
  --text: #111111;
  --text-muted: rgba(0, 0, 0, 0.4);
  --text-faint: rgba(0, 0, 0, 0.45);
  --text-subtle: rgba(0, 0, 0, 0.55);
  --text-ghost: rgba(0, 0, 0, 0.25);
  --text-dim: rgba(0, 0, 0, 0.15);
  --bar-bg: rgba(255, 255, 255, 0.85);
  --bar-border: rgba(0, 0, 0, 0.08);
  --dialog-bg: #ffffff;
  --size: 22px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #000000;
    --text: #ffffff;
    --text-muted: rgba(255, 255, 255, 0.45);
    --text-faint: rgba(255, 255, 255, 0.5);
    --text-subtle: rgba(255, 255, 255, 0.6);
    --text-ghost: rgba(255, 255, 255, 0.3);
    --text-dim: rgba(255, 255, 255, 0.2);
    --bar-bg: rgba(0, 0, 0, 0.85);
    --bar-border: rgba(255, 255, 255, 0.08);
    --dialog-bg: #171717;
  }
}

html, body { height: 100%; width: 100%; overflow: hidden; }

body {
  display: flex;
  flex-direction: column;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Inter', Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

button { font-family: inherit; }

/* Captions: newest at the bottom, just above the bar. */
.feed {
  flex: 1;
  overflow-y: auto;
  padding: 24px 24px calc(120px + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: 20px;
}
.feed > :first-child { margin-top: auto; }
.feed { overflow-anchor: none; }

/* ?debug */
.debug {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  max-height: 35vh;
  overflow-y: auto;
  z-index: 150;
  padding: 6px 10px;
  padding-top: max(6px, env(safe-area-inset-top));
  font: 11px/1.4 ui-monospace, Menlo, monospace;
  color: #9fef9f;
  background: rgba(0, 0, 0, 0.85);
  white-space: pre-wrap;
}

/* A paragraph is speech between pauses; each phrase sits on its own line. */
.para {
  font-size: var(--size);
  line-height: 1.5;
  color: var(--text-ghost);
  font-weight: 400;
  transition: color 0.3s ease;
}
.para.recent { color: var(--text-subtle); }
.para.current { color: var(--text-subtle); }

.line { display: block; margin-bottom: 0.35em; } /* one sentence; its phrases flow inline */
.seg { transition: color 0.3s ease, text-shadow 0.3s ease; }

/* The line being spoken. Shadow instead of a heavier weight, so the text
   doesn't re-wrap and push everything below it. */
.seg.speaking { color: var(--text); text-shadow: 0.4px 0 0 currentColor, -0.4px 0 0 currentColor; }

/* Captions-only languages: all text full strength, in-progress text dimmed. */
.captions-only .para { color: var(--text); font-weight: 600; transition: none; }
.captions-only .para:not(.current):not(.recent) { color: var(--text-subtle); }
.inflight { opacity: 0.6; }

.empty-state {
  margin: auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  min-height: 60vh;
  justify-content: center;
}
.empty-text { font-size: 18px; color: var(--text-faint); text-align: center; }
.empty-pulse {
  width: 40px;
  height: 4px;
  background: var(--text-dim);
  border-radius: 2px;
  animation: pulse 2s ease-in-out infinite;
}
@keyframes pulse { 0%, 100% { opacity: 0.3; } 50% { opacity: 1; } }

.back-live {
  position: fixed;
  left: 50%;
  bottom: calc(96px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  z-index: 90;
  padding: 8px 16px;
  border-radius: 18px;
  border: 1px solid var(--bar-border);
  background: var(--bar-bg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  color: var(--text);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}

/* Bottom bar */
.bottom-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 24px calc(16px + env(safe-area-inset-bottom));
  background: var(--bar-bg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-top: 1px solid var(--bar-border);
  z-index: 100;
}
.bottom-left { display: flex; align-items: center; gap: 12px; }
.bottom-info { display: flex; flex-direction: column; gap: 2px; }
.bottom-label { font-size: 14px; font-weight: 600; color: var(--text); }
.bottom-duration { font-size: 12px; color: var(--text-faint); }
.bottom-right { display: flex; align-items: center; gap: 4px; }

.status-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.status-dot.live { background: #22c55e; }
.status-dot.waiting { background: #9ca3af; animation: dot-pulse-slow 3s ease-in-out infinite; }
.status-dot.reconnecting { background: #f59e0b; animation: dot-pulse 1.5s ease-in-out infinite; }
.status-dot.connecting {
  background: transparent;
  border: 1.5px solid #9ca3af;
  border-top-color: #374151;
  animation: spin 0.75s linear infinite;
}
.status-dot.not-found { background: #6b7280; }
.status-dot.ended { background: #9ca3af; }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes dot-pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.3; } }
@keyframes dot-pulse-slow { 0%, 100% { opacity: 0.8; } 50% { opacity: 0.3; } }

.lang-toggle {
  display: flex;
  align-items: center;
  gap: 6px;
  height: 36px;
  padding: 0 12px;
  border-radius: 18px;
  border: 1px solid var(--bar-border);
  background: transparent;
  color: var(--text-subtle);
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
  transition: color 0.2s, border-color 0.2s;
}
.lang-toggle:hover { color: var(--text); border-color: var(--text-ghost); }
.lang-code { letter-spacing: 0.05em; }

.audio-toggle {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: none;
  background: transparent;
  color: var(--text-subtle);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.2s;
}
.audio-toggle:hover { color: var(--text); }

/* Language dialog */
.dialog-backdrop {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(0, 0, 0, 0.5);
}
.dialog {
  position: relative;
  width: 100%;
  max-width: 420px;
  padding: 24px;
  border-radius: 12px;
  background: var(--dialog-bg);
  border: 1px solid var(--bar-border);
  color: var(--text);
}
.dialog h2 { font-size: 16px; font-weight: 600; }
.dialog-hint { margin-top: 4px; font-size: 14px; color: var(--text-muted); }
.dialog-close {
  position: absolute;
  top: 12px;
  right: 14px;
  border: none;
  background: none;
  color: var(--text-muted);
  font-size: 22px;
  cursor: pointer;
}
#pickerList { display: flex; flex-direction: column; gap: 4px; margin-top: 16px; }
.dialog-section {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-faint);
  padding: 16px 16px 4px;
}
#pickerList .dialog-section:first-child { padding-top: 8px; }
.lang-option {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-radius: 8px;
  border: none;
  background: transparent;
  cursor: pointer;
  text-align: left;
  font-size: 15px;
  color: var(--text-muted);
  transition: background 0.15s, color 0.15s;
}
.lang-option:hover { background: var(--text-dim); color: var(--text); }
.lang-option[aria-selected="true"] { font-weight: 600; color: var(--text); }
.lang-option small { font-size: 11px; opacity: 0.4; text-transform: uppercase; letter-spacing: 0.05em; }
.sizes { display: flex; gap: 8px; padding: 4px 16px 0; }
.sizes button {
  flex: 1;
  height: 36px;
  border-radius: 18px;
  border: 1px solid var(--bar-border);
  background: transparent;
  color: var(--text-subtle);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}

/* Translation failed: the original line, shown so nothing is missing. */
.seg.untranslated { font-style: italic; opacity: 0.6; }

/* Campus screen: the church link with several campuses */
.choosing-campus .feed, .choosing-campus .bottom-bar, .choosing-campus .back-live { display: none; }
.campus-screen {
  flex: 1; overflow-y: auto; padding: 32px 24px;
  max-width: 480px; width: 100%; margin: 0 auto;
  display: flex; flex-direction: column; justify-content: center; /* centred on the screen */
}
.campus-screen h1 { font-size: 24px; font-weight: 600; letter-spacing: -0.01em; color: var(--text); }
.campus-screen p { margin-top: 6px; font-size: 15px; color: var(--text-muted); }
.campus-list { display: flex; flex-direction: column; gap: 8px; margin-top: 28px; }
.campus-option {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 16px 18px; border-radius: 12px; border: 1px solid var(--bar-border);
  color: var(--text); text-decoration: none; font-size: 17px; font-weight: 500;
  transition: background 0.15s;
}
.campus-option:hover { background: var(--text-dim); }
.campus-option:not(.live) { color: var(--text-muted); }
.campus-state { display: flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 500; color: var(--text-muted); white-space: nowrap; }
.campus-option.live .campus-state { color: var(--text); }
.status-dot.idle { background: var(--text-dim); }
.bottom-label.linked { cursor: pointer; }

.campus-back {
  position: fixed; z-index: 50; top: calc(12px + env(safe-area-inset-top)); left: 12px;
  display: flex; align-items: center; gap: 4px; height: 34px; padding: 0 14px 0 8px; border-radius: 17px;
  border: 1px solid var(--bar-border); background: var(--bar-bg);
  -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px);
  color: var(--text-subtle); font: inherit; font-size: 14px; font-weight: 500; cursor: pointer;
  transition: color 0.15s;
}
.campus-back:hover { color: var(--text); }
.choosing-campus .campus-back { display: none; }
