:root {
  --bg: #000000;
  --es: #ffffff;
  --en: #ffe9a8;
  --other: #9a9a9a;
  --unknown: #ffffff;
  --muted: #888888;
  --ok: #7bd88f;
  --warn: #f0c674;
  --err: #ff6b6b;
  --panel: #141414;
  --border: #242424;
  --text: #dedede;
}

* {
  box-sizing: border-box;
}

[x-cloak] {
  display: none !important;
}

html,
body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg);
  color: #fff;
  font-family: "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
}

body {
  overflow: hidden;
}

#caption-root {
  position: fixed;
  inset: 0;
  background: var(--bg);
  overflow: hidden;
}

.caption-viewport {
  position: absolute;
  left: 0;
  right: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding-left: 4vw;
  padding-right: 4vw;
}

/* Default: use the whole screen. */
.caption-viewport.display-full {
  inset: 0;
  height: 100vh;
  height: 100dvh;
  justify-content: flex-end;
  padding-top: calc(4vh + env(safe-area-inset-top));
  padding-bottom: calc(4vh + env(safe-area-inset-bottom));
}

/* Optional: bottom third. */
.caption-viewport.display-bottom {
  bottom: 0;
  height: 33vh;
  height: 33dvh;
  min-height: 170px;
  justify-content: flex-end;
  padding-bottom: calc(3.5vh + env(safe-area-inset-bottom));
  -webkit-mask-image: linear-gradient(to bottom, transparent 0%, #000 22%, #000 100%);
  mask-image: linear-gradient(to bottom, transparent 0%, #000 22%, #000 100%);
}

/* Optional: top third. */
.caption-viewport.display-top {
  top: 0;
  height: 33vh;
  height: 33dvh;
  min-height: 170px;
  justify-content: flex-start;
  padding-top: calc(3.5vh + env(safe-area-inset-top));
  -webkit-mask-image: linear-gradient(to top, transparent 0%, #000 22%, #000 100%);
  mask-image: linear-gradient(to top, transparent 0%, #000 22%, #000 100%);
}

/* Keep the status pill out of top-anchored captions. */
#caption-root[data-display-mode="top"] .status {
  top: auto;
  bottom: calc(14px + env(safe-area-inset-bottom));
}

#lines,
#live {
  display: block;
  width: 100%;
}

.line,
#live {
  margin: 0;
  padding: 0;
  font-size: clamp(22px, 4.1vh, 62px);
  line-height: 1.22;
  font-weight: 600;
  letter-spacing: 0.005em;
  overflow-wrap: anywhere;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.95), 0 0 3px #000;
}

.line {
  margin-top: 0.38em;
  animation: caption-rise 160ms ease-out both;
}

#live {
  margin-top: 0.38em;
  opacity: 0.94;
}

#live:empty {
  margin-top: 0;
}

.lang-es {
  color: var(--es);
}

.lang-en {
  color: var(--en);
}

.lang-other {
  color: var(--other);
}

.lang-unknown {
  color: var(--unknown);
}

@keyframes caption-rise {
  from {
    opacity: 0;
    transform: translateY(5px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.caption-links {
  position: absolute;
  z-index: 2;
  top: calc(14px + env(safe-area-inset-top));
  left: calc(18px + env(safe-area-inset-left));
  display: flex;
  gap: 14px;
  font: 500 13px/1.2 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  letter-spacing: 0.02em;
  text-shadow: 0 1px 4px #000;
  user-select: none;
}

.caption-links a {
  color: #777;
  text-decoration: none;
  opacity: 0.9;
}

.caption-links a:hover,
.caption-links a:focus-visible {
  color: #bdbdbd;
}

.caption-links a.active {
  color: #fff;
  opacity: 1;
}

/* Keep the nav out of top-anchored captions. */
#caption-root[data-display-mode="top"] .caption-links {
  top: auto;
  bottom: calc(14px + env(safe-area-inset-bottom));
}

.status {
  position: absolute;
  z-index: 2;
  top: calc(14px + env(safe-area-inset-top));
  right: calc(18px + env(safe-area-inset-right));
  display: flex;
  align-items: center;
  gap: 8px;
  max-width: 46ch;
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(10, 10, 10, 0.55);
  color: #9a9a9a;
  font: 500 12px/1.2 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  letter-spacing: 0.02em;
  opacity: 0.8;
  user-select: none;
  pointer-events: none;
}

.status.status-dot-only {
  padding: 6px;
  gap: 0;
  /* Hovering the dot reveals the detail words, so the pill must take events. */
  pointer-events: auto;
}

.status.status-dot-only .status-text {
  display: none;
}

.status.status-dot-only:hover,
.status.status-dot-only:focus-within {
  gap: 7px;
  opacity: 1;
}

.status.status-dot-only:hover .status-text,
.status.status-dot-only:focus-within .status-text {
  display: inline;
}

.status .dot {
  width: 8px;
  height: 8px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: var(--muted);
  box-shadow: 0 0 8px currentColor;
}

.status.ok .dot {
  background: var(--ok);
  color: var(--ok);
}

.status.warn .dot {
  background: var(--warn);
  color: var(--warn);
}

.status.err .dot {
  background: var(--err);
  color: var(--err);
}

.status-text {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cursor-hidden,
.cursor-hidden * {
  cursor: none !important;
}

@media (prefers-reduced-motion: reduce) {
  .line {
    animation: none;
  }
}

/* ---------- status page ---------- */

body.status-page {
  overflow: auto;
  background: #0b0b0b;
  color: var(--text);
  font-family: "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
}

.status-page main {
  max-width: 980px;
  margin: 0 auto;
  padding: 34px 20px 72px;
}

.status-page h1 {
  margin: 0 0 4px;
  font-size: 26px;
  font-weight: 700;
  color: #fff;
  letter-spacing: -0.01em;
}

.status-page .subtitle {
  margin: 0 0 28px;
  color: var(--muted);
  font-size: 14px;
}

.status-page a {
  color: #9ecbff;
  text-decoration: none;
}

.status-page a:hover {
  text-decoration: underline;
}

.status-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 12px;
}

.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px 16px;
}

.card .label {
  margin-bottom: 6px;
  color: var(--muted);
  font: 600 11px/1.2 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.card .value {
  color: #f0f0f0;
  font-size: 17px;
  font-weight: 600;
  overflow-wrap: anywhere;
}

.card .value.mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 14px;
  font-weight: 500;
}

.ok {
  color: var(--ok);
}

.bad {
  color: var(--err);
}

.warn {
  color: var(--warn);
}

.status-page .error-box {
  margin-top: 14px;
  padding: 12px 14px;
  border: 1px solid #4a2424;
  border-radius: 10px;
  background: #1d1111;
  color: #ffb3b3;
  font: 500 13px/1.45 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  overflow-wrap: anywhere;
}

.status-page footer {
  margin-top: 28px;
  color: var(--muted);
  font-size: 13px;
}

@media (max-width: 640px) {
  .caption-links {
    gap: 12px;
    font-size: 12px;
  }

  .status {
    max-width: 38vw;
  }

  .caption-viewport {
    padding-left: 5vw;
    padding-right: 5vw;
  }

  .caption-viewport.display-bottom,
  .caption-viewport.display-top {
    height: 33vh;
  }

  .line,
  #live {
    font-size: clamp(20px, 4.6vh, 40px);
  }
}
