/* === STT Page Layout (split view) === */
.split {
  display: flex;
  gap: 2rem;
  margin-top: 1.5rem;
  flex-wrap: wrap; /* allows stacking on small screens */
}

.split .left,
.split .right {
  flex: 1 1 320px; /* grow, shrink, min-width */
  display: flex;
  flex-direction: column;
  gap: 1.2rem;
}

.split .right section.card {
  flex: 1;
  display: flex;
  flex-direction: column;
}

.split .right pre.result {
  flex: 1;
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1rem;
  margin-top: 0.8rem;
  font-family: "Fira Code", monospace;
  color: var(--ink);
  overflow-y: auto;
  min-height: 220px;
  max-height: 420px;
}

/* === STT page: wider canvas + bigger game title === */
.container {
  max-width: 1120px;
  background: linear-gradient(
    135deg,
    rgba(255, 255, 255, 0.02),
    rgba(255, 255, 255, 0.01)
  );
  border: 1px solid var(--border);
  backdrop-filter: blur(20px);
  border-radius: 18px;
}

/* === Equalizer (recording visualizer) === */
.viz-wrap {
  margin-top: 0.8rem;
  padding: 0.85rem 0.9rem;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: linear-gradient(
    135deg,
    rgba(255, 255, 255, 0.08),
    rgba(255, 255, 255, 0.04)
  );
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.28),
    inset 0 0 18px rgba(0, 0, 0, 0.25);
  backdrop-filter: blur(14px);
}
.viz-head {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin-bottom: 0.5rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.viz-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #fff, var(--neon-blue));
  box-shadow: 0 0 10px var(--neon-blue), 0 0 20px rgba(0, 255, 255, 0.45);
  animation: vizPulse 1.8s ease-in-out infinite;
}
@keyframes vizPulse {
  0%,
  100% {
    transform: scale(1);
    opacity: 0.85;
  }
  50% {
    transform: scale(1.25);
    opacity: 1;
  }
}
.viz-title {
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--ink);
}
.viz-mini {
  margin-left: auto;
  font-size: 0.68rem;
  padding: 0.18rem 0.44rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  color: var(--muted);
  background: linear-gradient(
    135deg,
    rgba(255, 255, 255, 0.1),
    rgba(255, 255, 255, 0.05)
  );
}
.viz-label {
  color: var(--muted);
  font-size: 0.9rem;
  letter-spacing: 0.3px;
}
.viz {
  position: relative;
  height: 52px;
  display: grid;
  align-items: end;
  grid-template-columns: repeat(var(--bar-count, 40), 1fr);
  gap: 3px;
  padding: 6px 8px;
  border-radius: 10px;
  border: 1px solid transparent;
  overflow: hidden;
  contain: layout paint;
}
.viz .bar {
  width: 100%;
  height: 6px;
  border-radius: 6px 6px 2px 2px;
  background: linear-gradient(180deg, var(--neon-blue), var(--neon-purple));
  box-shadow: 0 0 10px rgba(0, 255, 255, 0.22);
  transition: height 0.07s linear;
}
.recording-active .viz {
  border-color: var(--neon-blue);
  box-shadow: 0 0 20px rgba(0, 255, 255, 0.12),
    inset 0 0 20px rgba(0, 0, 0, 0.25);
}
/* === Player card (audio + caption) === */
.player {
  margin-top: 1rem;
  padding: 0.9rem;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: linear-gradient(
    135deg,
    rgba(255, 255, 255, 0.08),
    rgba(255, 255, 255, 0.04)
  );
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.28),
    inset 0 0 18px rgba(0, 0, 0, 0.18);
  backdrop-filter: blur(14px);
}
.player-head {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  margin-bottom: 0.5rem;
}
.player-icon {
  filter: drop-shadow(0 0 8px rgba(0, 255, 255, 0.25));
}
.player-title {
  font-size: 0.8rem;
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink);
}
.player audio {
  width: 100%;
  margin-top: 0.2rem;
  border-radius: 10px;
  outline: none;
  filter: drop-shadow(0 6px 18px rgba(0, 0, 0, 0.35));
  background: transparent;
}

/* === Caption chip (gaming HUD style) === */
.caption-chip {
  margin: 0.8rem 0 0;
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--neon-green);
  letter-spacing: 0.02em;
  padding: 0.45rem 0.9rem;
  border-radius: 6px 6px 2px 2px;
  background: rgba(0, 255, 128, 0.08);
  box-shadow: 0 0 12px rgba(0, 255, 128, 0.25),
    inset 0 0 8px rgba(0, 255, 128, 0.15);
  position: relative;
  overflow: hidden;
}
.caption-chip code {
  font-family: "Fira Code", monospace;
  color: var(--neon-yellow);
  font-size: 0.9rem;
}
/* glowing pulse line that slides across */
.caption-chip::after {
  content: "";
  position: absolute;
  top: 0;
  left: -40%;
  width: 40%;
  height: 100%;
  background: linear-gradient(
    120deg,
    transparent,
    rgba(0, 255, 128, 0.3),
    transparent
  );
  animation: chipShine 3s infinite;
}

@keyframes chipShine {
  0% {
    left: -40%;
  }
  60% {
    left: 120%;
  }
  100% {
    left: 120%;
  }
}
.caption-chip .chip-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #fff, var(--neon-pink));
  box-shadow: 0 0 10px rgba(255, 0, 128, 0.35);
}
@keyframes chipPulse {
  0%,
  100% {
    transform: scale(1);
    opacity: 0.8;
  }
  50% {
    transform: scale(1.3);
    opacity: 1;
  }
}
.split .right pre.result {
  min-height: 280px;
  max-height: 520px;
}

.recording-active #recordBtn {
  box-shadow: 0 0 18px rgba(0, 255, 255, 0.35);
}

/* Force dark neon look for audio element */
audio {
  width: 100%;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--bg3), rgba(0, 255, 128, 0.15));
  box-shadow: 0 0 12px rgba(0, 255, 128, 0.25) inset;
  accent-color: var(--neon-green);
  filter: hue-rotate(85deg) saturate(1.4);
}
.audio-frame {
  position: relative;
  border-radius: 12px;
  padding: 6px;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--bg3), rgba(0, 255, 128, 0.15));
  box-shadow: 0 0 18px rgba(0, 255, 128, 0.35);
  overflow: hidden;
}
.audio-frame audio {
  width: 100%;
  background: transparent;
  accent-color: var(--neon-green);
  border-radius: 8px;
}
.audio-frame .audio-overlay {
  border-radius: 8px;
  position: absolute;
  inset: 0;
  pointer-events: none;
  box-shadow: inset 0 0 18px rgba(0, 255, 128, 0.35);
}

/* Neon upload button */
.upload-btn {
  display: inline-block;
  padding: 0.7rem 1.4rem;
  border-radius: 12px;
  font-weight: 600;
  cursor: pointer;
  text-align: center;
  letter-spacing: 0.03em;

  background: linear-gradient(
    135deg,
    rgba(0, 255, 128, 0.15),
    rgba(0, 255, 128, 0.05)
  );
  color: var(--neon-green);
  border: 1px solid var(--neon-green);

  box-shadow: 0 0 12px rgba(0, 255, 128, 0.3),
    inset 0 0 10px rgba(0, 255, 128, 0.12);
  transition: all 0.25s ease;
}

.upload-btn:hover {
  background: linear-gradient(
    135deg,
    rgba(0, 255, 128, 0.25),
    rgba(0, 255, 128, 0.1)
  );
  box-shadow: 0 0 18px rgba(0, 255, 128, 0.5),
    inset 0 0 12px rgba(0, 255, 128, 0.18);
}

.upload-btn:active {
  transform: scale(0.97);
}

/* Filename preview */
.file-name {
  margin-top: 0.6rem;
  font-size: 0.9rem;
  font-style: italic;
  color: var(--neon-green);
  text-shadow: 0 0 6px rgba(0, 255, 128, 0.6);
}

.actions {
  display: flex;
  gap: 0.6rem;
  align-items: center;
}
.ghost {
  padding: 0.6rem 0.9rem;
  border-radius: 10px;
  background: transparent;
  color: var(--ink);
  border: 1px solid var(--border);
  pointer-events: auto;
  position: relative;
  z-index: 2;
  cursor: pointer;
}
.ghost:hover {
  border-color: var(--neon-blue);
  box-shadow: 0 0 12px rgba(0, 255, 255, 0.2);
}

/* fullscreen reader */
.result.fullscreen {
  position: fixed;
  inset: 6vh 6vw;
  z-index: 9998;
  max-height: unset;
  height: auto;
  background: rgba(0, 0, 0, 0.85);
  border: 1px solid var(--border);
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.6);
}

/* Make the card a containing block for the overlay */
.transcript-card {
  position: relative;
  overflow: visible;
}

/* --- Language / Confidence strip --- */
.langbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem 1rem;
  align-items: center;
  margin: 0.8rem 0 0.6rem;
}
.pill {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.32rem 0.6rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: linear-gradient(
    135deg,
    rgba(255, 255, 255, 0.1),
    rgba(255, 255, 255, 0.05)
  );
  font-size: 0.9rem;
  letter-spacing: 0.02em;
  color: var(--ink);
  box-shadow: 0 0 10px rgba(0, 0, 0, 0.25);
}
.pill-lang {
  border-color: var(--neon-blue);
  box-shadow: 0 0 12px rgba(0, 255, 255, 0.18);
}
.pill-lang .flag {
  font-size: 1.05rem;
  filter: drop-shadow(0 0 6px rgba(0, 255, 255, 0.25));
}
.pill-lang .code {
  font-size: 0.78rem;
  opacity: 0.85;
  padding: 0.1rem 0.4rem;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.06);
}

/* Confidence meter */
.confidence {
  min-width: 220px;
  flex: 1 1 220px;
}
.conf-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  color: var(--muted);
  font-size: 0.82rem;
  margin-bottom: 0.25rem;
}
.conf-bar {
  height: 10px;
  border-radius: 999px;
  overflow: hidden;
  position: relative;
  border: 1px solid var(--border);
  background: linear-gradient(
    180deg,
    rgba(255, 255, 255, 0.06),
    rgba(255, 255, 255, 0.02)
  );
  box-shadow: inset 0 0 10px rgba(0, 0, 0, 0.35);
}
.conf-bar span {
  display: block;
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--neon-green), var(--neon-blue));
  box-shadow: 0 0 12px rgba(0, 255, 128, 0.35);
  transition: width 0.35s ease;
}

.pill-meta {
  border-color: var(--neon-purple);
  color: var(--neon-purple);
  background: rgba(128, 0, 255, 0.08);
}

/* ---------- STT: responsive ---------- */
@media (max-width: 1024px) {
  .container {
    max-width: 920px;
  }
}

@media (max-width: 820px) {
  .container {
    max-width: 720px;
    padding: 0 0.75rem;
  }
  .split {
    gap: 1.25rem;
  }
  .title-game {
    font-size: clamp(2.2rem, 1.1rem + 5vw, 3.6rem);
  }
}

@media (max-width: 640px) {
  /* stack the columns cleanly */
  .split {
    gap: 1rem;
  }
  .split .left,
  .split .right {
    flex: 1 1 100%;
  }

  /* tighter cards */
  .card {
    padding: 0.85rem;
    border-radius: 12px;
  }
  .controls {
    flex-wrap: wrap;
  }

  /* buttons: comfy finger targets */
  .actions {
    gap: 0.5rem;
    flex-wrap: wrap;
  }
  .actions > button {
    flex: 1 1 46%;
    min-width: 130px;
  }

  /* transcript box */
  .result {
    min-height: 240px;
    max-height: 60vh;
    font-size: 0.98rem;
    padding: 0.9rem;
  }

  /* expand overlay only over the card with mobile margins */
  .transcript-card.is-expanded .card-expand {
    inset: -8px;
  }
  .expand-shell {
    padding: 0.7rem;
  }
  .expand-head {
    padding-bottom: 0.35rem;
  }

  /* language strip wraps nicely */
  .langbar {
    gap: 0.5rem 0.75rem;
  }
  .confidence {
    min-width: 180px;
    flex: 1 1 180px;
  }

  /* visualizer: shorter + denser */
  .viz {
    height: 44px;
    gap: 2px;
    padding: 6px;
  }
  .viz .bar {
    border-radius: 5px 5px 2px 2px;
  }
}

/* very small phones */
@media (max-width: 380px) {
  .actions > button {
    flex-basis: 100%;
  }
  .upload-btn {
    width: 100%;
    text-align: center;
  }
  .file-name {
    font-size: 0.85rem;
  }
  .viz-head .viz-title {
    font-size: 0.72rem;
  }
  .player {
    padding: 0.7rem;
  }
  .audio-frame {
    padding: 4px;
  }
}

/* === Video page elements === */
.video-frame {
  margin-top: 0.8rem;
  position: relative;
  padding: 6px;
  border-radius: 14px;
  background: linear-gradient(
    135deg,
    rgba(0, 255, 128, 0.08),
    rgba(0, 255, 128, 0.02)
  );
  border: 1px solid var(--neon-green);
  box-shadow: 0 0 18px rgba(0, 255, 128, 0.35);
  overflow: hidden;
}
.video-frame video {
  width: 100%;
  max-width: 950px;
  max-height: 920px; /* keep it from being too tall */
  margin: 0 auto;
  display: block;
  object-fit: contain; /* avoid distortion */
  border-radius: 10px;
  background: transparent;
  accent-color: var(--neon-green);
}
.video-frame .video-overlay {
  position: absolute;
  inset: 0;
  pointer-events: none;
  border-radius: inherit;
  box-shadow: inset 0 0 18px rgba(0, 255, 128, 0.35);
}

.meta-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.6rem 0.8rem;
  margin-top: 0.7rem;
}
.meta-item {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}
.meta-item .k {
  font-size: 0.82rem;
  color: var(--muted);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.1rem 0.4rem;
  background: rgba(255, 255, 255, 0.06);
}
.meta-item .v {
  font-weight: 600;
  color: var(--ink);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Progress row */
.progress {
  margin-top: 0.9rem;
}
.progress-head {
  display: flex;
  justify-content: space-between;
  color: var(--muted);
  font-size: 0.88rem;
  margin-bottom: 0.25rem;
}
.progress-bar {
  height: 10px;
  border-radius: 999px;
  overflow: hidden;
  position: relative;
  border: 1px solid var(--border);
  background: linear-gradient(
    180deg,
    rgba(255, 255, 255, 0.06),
    rgba(255, 255, 255, 0.02)
  );
  box-shadow: inset 0 0 10px rgba(0, 0, 0, 0.35);
}
.progress-bar span {
  display: block;
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--neon-blue), var(--neon-green));
  box-shadow: 0 0 12px rgba(0, 255, 255, 0.35);
  transition: width 0.25s linear;
}

/* Responsive tweaks */
@media (max-width: 800px) {
  .meta-grid {
    grid-template-columns: 1fr;
  }
}

/* Reuse transcript card overlay styles from STT */
.transcript-card {
  position: relative;
  overflow: visible;
}
.transcript-card.is-expanded .card-expand {
  display: block;
}
.card-expand {
  display: none;
  position: absolute;
  inset: -14px;
  z-index: 30;
  border-radius: 16px;
  background: rgba(10, 10, 16, 0.95);
  border: 1px solid var(--border);
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.55);
}
.expand-shell {
  height: 100%;
  display: grid;
  grid-template-rows: auto 1fr;
  padding: 0.9rem;
}
.expand-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.8rem;
  padding-bottom: 0.4rem;
  border-bottom: 1px solid var(--border);
}
.result.expanded {
  margin-top: 0.7rem;
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1rem 1.1rem;
  line-height: 1.55;
  font-size: 1.05rem;
  height: 100%;
  max-height: none;
  overflow: auto;
}
.transcript-card.is-expanded > *:not(.card-expand) {
  filter: blur(1px) brightness(0.85);
  transition: filter 0.15s ease;
}

/* live dictation interim text style */
#interimOut {
  color: var(--muted);
  border-top: 1px dashed var(--border);
  margin-top: 0.5rem;
  padding-top: 0.5rem;
}

/* viz LIVE badge look */
.viz-mini {
  color: var(--muted);
}
