﻿:root {
  --toggle-transition: 0.6s cubic-bezier(0.68, -0.6, 0.32, 1.6);
  --blue-active: rgba(0, 122, 255, 0.6);
  --red-stop: rgba(255, 59, 48, 0.6);
  --toggle-text-offset: 8px;
  --speaker-a-color: #4a9eff;
  --speaker-b-color: #ff9500;
  --speaker-a-bg: rgba(74, 158, 255, 0.07);
  --speaker-b-bg: rgba(255, 149, 0, 0.07);
}

html[data-theme="light"] {
  --bg-start: #fbfbfd;
  --bg-end: #f5f5f7;
  --ambient-1: rgba(255, 255, 255, 0.9);
  --ambient-2: rgba(100, 200, 255, 0.1);
  --ambient-cool-strong: rgba(0, 122, 255, 0.24);
  --ambient-cool-soft: rgba(64, 170, 255, 0.16);
  --ambient-warm-strong: rgba(255, 118, 46, 0.36);
  --ambient-warm-soft: rgba(255, 149, 0, 0.2);
  --panel: rgba(255, 255, 255, 0.6);
  --panel-soft: rgba(255, 255, 255, 0.4);
  --panel-bg: linear-gradient(180deg, rgba(255, 255, 255, 0.9), rgba(245, 245, 247, 0.7));
  --status-bg: linear-gradient(180deg, rgba(255, 255, 255, 0.8), rgba(245, 245, 247, 0.6));
  --audio-bg: rgba(255, 255, 255, 0.5);
  --chip: rgba(240, 240, 243, 0.6);
  --input-bg: rgba(255, 255, 255, 0.85);
  --ghost-bg: rgba(240, 240, 243, 0.7);
  --ghost-text: #636366;
  --text: #1d1d1f;
  --subtle: #86868b;
  --line: rgba(0, 0, 0, 0.08);
  --accent: #007aff;
  --accent-2: #ff9500;
  --glow: rgba(0, 122, 255, 0.15);
  --source-text: #1d1d1f;
  --translation-text: #004c84;
  --visualizer-bg: linear-gradient(180deg, rgba(245, 245, 247, 0.9), rgba(235, 235, 237, 0.7));
  --visualizer-grid: rgba(0, 122, 255, 0.1);
  --shadow: 0 28px 90px rgba(0, 0, 0, 0.1);
  --blue-active: rgba(0, 122, 255, 0.6);
  --red-stop: rgba(255, 59, 48, 0.6);
  --speaker-a-color: #1a7de8;
  --speaker-b-color: #e07600;
  --speaker-a-bg: rgba(26, 125, 232, 0.06);
  --speaker-b-bg: rgba(224, 118, 0, 0.06);
}

html[data-theme="dark"] {
  color-scheme: dark;
  --bg-start: #05070a;
  --bg-end: #111924;
  --ambient-1: rgba(26, 41, 59, 0.44);
  --ambient-2: rgba(53, 214, 255, 0.1);
  --ambient-cool-strong: rgba(53, 214, 255, 0.38);
  --ambient-cool-soft: rgba(74, 158, 255, 0.22);
  --ambient-warm-strong: rgba(255, 77, 70, 0.48);
  --ambient-warm-soft: rgba(255, 109, 74, 0.28);
  --panel: rgba(9, 13, 18, 0.88);
  --panel-soft: rgba(11, 16, 23, 0.92);
  --panel-bg: linear-gradient(180deg, rgba(14, 20, 30, 0.96), rgba(9, 13, 20, 0.88));
  --status-bg: linear-gradient(180deg, rgba(12, 19, 29, 0.94), rgba(8, 12, 18, 0.86));
  --audio-bg: rgba(9, 13, 20, 0.9);
  --chip: rgba(13, 20, 29, 0.9);
  --input-bg: rgba(8, 12, 18, 0.9);
  --ghost-bg: rgba(18, 25, 35, 0.92);
  --ghost-text: #d6e6f2;
  --text: #edf6ff;
  --subtle: #8ea3b6;
  --line: rgba(120, 160, 194, 0.18);
  --accent: #35d6ff;
  --accent-2: #ff6d4a;
  --glow: rgba(53, 214, 255, 0.18);
  --source-text: #eff7ff;
  --translation-text: #8cecff;
  --visualizer-bg: linear-gradient(180deg, rgba(7, 11, 17, 0.98), rgba(11, 18, 27, 0.92));
  --visualizer-grid: rgba(53, 214, 255, 0.14);
  --shadow: 0 36px 100px rgba(0, 0, 0, 0.44);
}

html[data-theme="light"] .expert-panel {
  background: linear-gradient(135deg, rgba(30, 36, 44, 0.55), rgba(18, 22, 28, 0.75)) !important;
  color: #ffffff;
  border-right: 1px solid rgba(255, 255, 255, 0.06);
  box-shadow:
    inset -1px 0 0 rgba(255, 255, 255, 0.04),
    30px 0 80px rgba(0, 0, 0, 0.35);
  backdrop-filter: blur(48px) saturate(200%);
  -webkit-backdrop-filter: blur(48px) saturate(200%);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  position: relative;
  isolation: isolate;
  font-family: "Aptos", "Segoe UI Variable", "Noto Sans SC", "PingFang SC", sans-serif;
  background:
    radial-gradient(circle at top left, var(--ambient-1), transparent 30%),
    radial-gradient(circle at bottom right, var(--ambient-2), transparent 24%),
    linear-gradient(135deg, var(--bg-start), var(--bg-end));
  color: var(--text);
  padding: 24px;
  transition: background 0.35s ease, color 0.25s ease;
}

.ambient-canvas {
  --ambient-base-opacity: 0.3;
  --ambient-focus-scale: 1;
  --ambient-audio-scale: 1;
  --ambient-audio-y: 0vh;
  --ambient-energy: 0;
  --ambient-jitter-x: 0px;
  --ambient-jitter-y: 0px;
  --ambient-ring-x: 0px;
  --ambient-ring-y: 0px;
  --ambient-counter-x: 0px;
  --ambient-counter-y: 0px;
  --ambient-ring-scale: 1;
  --ambient-ring-opacity: 0;
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  overflow: hidden;
  pointer-events: none;
  z-index: -1;
  opacity: calc(var(--ambient-base-opacity) + (var(--ambient-energy) * 0.2));
  background:
    radial-gradient(ellipse at 78% 28%, var(--ambient-warm-soft), transparent 34%),
    radial-gradient(ellipse at 18% 34%, var(--ambient-cool-soft), transparent 38%),
    linear-gradient(105deg, rgba(255, 255, 255, 0.032), transparent 28%, rgba(255, 109, 74, 0.05) 58%, transparent);
  background-blend-mode: screen, screen, screen;
  transform:
    scale(calc(var(--ambient-focus-scale) * var(--ambient-audio-scale)))
    translate3d(var(--ambient-jitter-x), calc(var(--ambient-audio-y) + var(--ambient-jitter-y)), 0);
  transform-origin: center 70%;
  transition: opacity 0.8s ease, filter 0.8s ease;
  will-change: transform, opacity, filter;
  /* Protect subtitles by fading out the most intense colors near the bottom edge. */
  -webkit-mask-image: linear-gradient(to bottom, black 50%, rgba(0, 0, 0, 0.4) 85%, transparent 100%);
  mask-image: linear-gradient(to bottom, black 50%, rgba(0, 0, 0, 0.4) 85%, transparent 100%);
}

.ambient-canvas::before,
.ambient-canvas::after {
  content: "";
  position: absolute;
  inset: clamp(48px, 9vw, 140px);
  border-radius: 999px;
  pointer-events: none;
  opacity: var(--ambient-ring-opacity);
  transform:
    translate3d(var(--ambient-ring-x), var(--ambient-ring-y), 0)
    scale(var(--ambient-ring-scale));
  will-change: transform, opacity;
}

.ambient-canvas::before {
  border: 1px solid color-mix(in srgb, var(--accent) 44%, transparent);
  box-shadow:
    inset 0 0 42px color-mix(in srgb, var(--accent) 20%, transparent),
    0 0 80px color-mix(in srgb, var(--accent) 18%, transparent);
  filter: blur(1px);
}

.ambient-canvas::after {
  inset: clamp(74px, 13vw, 210px);
  border: 1px solid rgba(255, 109, 74, 0.58);
  opacity: calc(var(--ambient-ring-opacity) * 0.78);
  transform:
    translate3d(var(--ambient-counter-x), var(--ambient-counter-y), 0)
    scale(calc(var(--ambient-ring-scale) + 0.04));
  box-shadow:
    inset 0 0 34px rgba(255, 109, 74, 0.18),
    0 0 72px rgba(255, 77, 70, 0.2);
  filter: blur(2.5px);
}

.ambient-blob {
  position: absolute;
  inset: -18vmax;
  width: auto;
  aspect-ratio: auto;
  border-radius: 0;
  filter: blur(82px) saturate(175%);
  opacity: 0.74;
  mix-blend-mode: screen;
  will-change: transform;
}

html[data-theme="light"] .ambient-blob {
  mix-blend-mode: multiply;
  opacity: 0.6;
}

.ambient-blob.blob-a {
  opacity: 0.62;
  background:
    conic-gradient(from 210deg at 42% 46%,
      transparent 0 15%,
      color-mix(in srgb, var(--accent) 44%, transparent) 22%,
      transparent 36%,
      color-mix(in srgb, var(--accent-2) 18%, transparent) 52%,
      transparent 68%,
      color-mix(in srgb, var(--accent) 30%, transparent) 82%,
      transparent 100%),
    linear-gradient(118deg, transparent 8%, color-mix(in srgb, var(--accent) 18%, transparent) 44%, transparent 78%);
  animation: aurora-drift-cold 18s ease-in-out infinite alternate;
}

.ambient-blob.blob-b {
  inset: -22vmax -16vmax;
  opacity: calc(0.64 + var(--ambient-energy) * 0.2);
  filter: blur(76px) saturate(190%);
  background:
    radial-gradient(ellipse at 72% 30%, var(--ambient-warm-strong), transparent 38%),
    linear-gradient(28deg,
      transparent 12%,
      var(--ambient-warm-strong) 32%,
      transparent 48%,
      var(--ambient-cool-soft) 66%,
      transparent 86%),
    conic-gradient(from 30deg at 58% 54%,
      transparent 0 25%,
      var(--ambient-warm-soft) 35%,
      transparent 48%,
      rgba(53, 214, 255, 0.16) 63%,
      transparent 100%);
  animation: aurora-drift-warm 21s ease-in-out infinite alternate;
}

.ambient-blob.blob-c {
  inset: -12vmax -24vmax;
  opacity: 0.36;
  background:
    linear-gradient(164deg,
      transparent 18%,
      color-mix(in srgb, var(--accent) 24%, transparent) 42%,
      transparent 57%,
      color-mix(in srgb, var(--accent-2) 32%, transparent) 75%,
      transparent 92%);
  animation: aurora-ribbon-cold 14s ease-in-out infinite alternate-reverse;
}

.ambient-blob.blob-d {
  inset: -24vmax;
  opacity: calc(0.42 + var(--ambient-energy) * 0.18);
  filter: blur(58px) saturate(190%);
  background:
    radial-gradient(ellipse at 18% 70%, var(--ambient-warm-soft), transparent 34%),
    linear-gradient(132deg,
      transparent 14%,
      rgba(255, 77, 70, 0.28) 40%,
      transparent 70%);
  animation: aurora-grain-drift 11s ease-in-out infinite alternate;
}

@keyframes aurora-drift-cold {
  0% { transform: translate3d(-4vw, -2vh, 0) rotate(-3deg) scale(1.02); }
  45% { transform: translate3d(4vw, 6vh, 0) rotate(4deg) scale(1.08); }
  100% { transform: translate3d(8vw, -4vh, 0) rotate(-1deg) scale(1.04); }
}

@keyframes aurora-drift-warm {
  0% { transform: translate3d(5vw, 3vh, 0) rotate(5deg) scale(1.05); }
  50% { transform: translate3d(-5vw, -4vh, 0) rotate(-4deg) scale(1.1); }
  100% { transform: translate3d(-8vw, 5vh, 0) rotate(2deg) scale(1.02); }
}

@keyframes aurora-ribbon-cold {
  0% { transform: translate3d(0, 6vh, 0) rotate(-8deg) scale(1.05); }
  100% { transform: translate3d(5vw, -5vh, 0) rotate(7deg) scale(1.12); }
}

@keyframes aurora-grain-drift {
  0% { transform: translate3d(-2vw, 0, 0) rotate(0deg); }
  100% { transform: translate3d(2vw, -3vh, 0) rotate(3deg); }
}

.app {
  width: min(1600px, 100%);
  margin: 0 auto;
  min-height: calc(100vh - 48px);
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  gap: 18px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 32px;
  box-shadow: var(--shadow);
  padding: 26px;
  backdrop-filter: blur(18px);
}

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

.brand-lockup {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.eyebrow {
  font-size: 12px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--subtle);
}

.brand-lockup strong {
  font-family: "Bahnschrift", "Aptos Display", "Aptos", sans-serif;
  font-size: 20px;
  letter-spacing: 0.01em;
}

.chrome-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.workspace {
  display: grid;
  grid-template-columns: 1fr;
  gap: 20px;
  flex: 1;
  min-height: 0;
}

.control-column,
.content-column {
  min-width: 0;
}

.control-panel,
.content-panel {
  border: 1px solid var(--line);
  border-radius: 28px;
  background: var(--panel-bg);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.12);
}

.control-panel {
  padding: 26px;
}

.content-panel {
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

h1 {
  margin: 0 0 8px;
  font-family: "Bahnschrift", "Aptos Display", "Aptos", sans-serif;
  font-size: clamp(28px, 4vw, 42px);
  letter-spacing: -0.03em;
}

.desc {
  margin: 0 0 20px;
  color: var(--subtle);
  line-height: 1.7;
}

.config-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.font-toolbar {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  margin: 18px 0 4px;
  padding: 14px;
  border-radius: 20px;
  background: var(--panel-soft);
  border: 1px solid var(--line);
}

.language-rules {
  margin-top: 18px;
  padding: 16px 18px;
  border-radius: 20px;
  background: var(--panel-soft);
  border: 1px solid var(--line);
  color: var(--subtle);
  font-size: 13px;
  line-height: 1.75;
}

.language-rules strong {
  display: block;
  margin-bottom: 8px;
  color: var(--text);
  font-size: 14px;
}

.language-rules ul {
  margin: 8px 0 0;
  padding-left: 18px;
}

.language-rules code {
  margin: 0 2px;
}

.term-panel {
  display: grid;
  gap: 10px;
  margin-top: 18px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
}

.term-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.term-panel-header strong {
  color: var(--text);
  font-size: 14px;
}

.compact-btn {
  width: auto;
  min-height: 34px;
  padding: 0 12px;
  border-radius: 8px;
  font-size: 12px;
}

.font-control label {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}

.font-value {
  font-size: 13px;
  color: var(--subtle);
  min-width: 42px;
  text-align: right;
}

.font-control input[type="range"] {
  padding: 0;
  background: transparent;
  border: 0;
  accent-color: var(--accent);
}

.grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  margin-bottom: 18px;
}

label {
  display: block;
  font-size: 14px;
  margin-bottom: 6px;
  color: var(--subtle);
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 12px 14px;
  background: var(--input-bg);
  color: var(--text);
  font-size: 15px;
  transition: border-color 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

input:focus,
select:focus,
textarea:focus,
button:focus-visible {
  outline: none;
  border-color: color-mix(in srgb, var(--accent) 70%, transparent);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 16%, transparent);
}

textarea {
  min-height: 104px;
  resize: vertical;
  line-height: 1.55;
}

.actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin: 20px 0;
}

button {
  border: 1px solid transparent;
  border-radius: 999px;
  padding: 13px 22px;
  cursor: pointer;
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  transition: transform 0.16s ease, opacity 0.16s ease, box-shadow 0.2s ease, background 0.2s ease;
  box-shadow: inset 0 -1px 0 rgba(0, 0, 0, 0.08);
}

button:hover {
  transform: translateY(-1px);
}

button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.primary {
  background: linear-gradient(135deg, var(--accent), color-mix(in srgb, var(--accent) 55%, white));
  color: #ffffff;
  box-shadow: 0 18px 38px color-mix(in srgb, var(--accent) 24%, transparent);
}

.danger {
  background: linear-gradient(135deg, var(--accent-2), color-mix(in srgb, var(--accent-2) 55%, white));
  color: #ffffff;
  box-shadow: 0 18px 38px color-mix(in srgb, var(--accent-2) 18%, transparent);
}

.ghost {
  background: var(--ghost-bg);
  color: var(--ghost-text);
  border-color: var(--line);
}

.chrome-btn {
  padding: 11px 18px;
  min-width: 126px;
}

.status {
  padding: 15px 18px;
  border-radius: 20px;
  border: 1px solid var(--line);
  background: var(--status-bg);
  min-height: 54px;
  line-height: 1.6;
  box-shadow: 0 14px 32px var(--glow);
}

.panels {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  flex: 1;
  min-height: 0;
}

.panel {
  border: 1px solid var(--line);
  border-radius: 26px;
  background: var(--panel-bg);
  padding: 18px 18px 20px;
  min-height: 280px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

.panel h2 {
  margin: 0 0 14px;
  font-size: 14px;
  font-weight: 700;
  color: var(--subtle);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.subtitle-card {
  margin: 0;
  padding: 18px 20px;
  border-radius: 24px;
  background: var(--chip);
  border: 1px solid rgba(18, 32, 42, 0.06);
  min-height: 240px;
  max-height: 420px;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  gap: 14px;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: color-mix(in srgb, var(--accent) 55%, transparent) rgba(18, 32, 42, 0.08);
}

.subtitle-card::-webkit-scrollbar {
  width: 10px;
}

.subtitle-card::-webkit-scrollbar-track {
  background: rgba(18, 32, 42, 0.06);
  border-radius: 999px;
}

.subtitle-card::-webkit-scrollbar-thumb {
  background: color-mix(in srgb, var(--accent) 50%, transparent);
  border-radius: 999px;
}

.subtitle-card::-webkit-scrollbar-thumb:hover {
  background: color-mix(in srgb, var(--accent) 66%, transparent);
}

.subtitle-line {
  white-space: pre-wrap;
  word-break: break-word;
  line-height: 1.75;
  font-size: var(--subtitle-size, 34px);
  letter-spacing: -0.03em;
  min-height: 78px;
  opacity: 1;
  transform: translateY(0);
  transition: color 0.25s ease, opacity 0.2s ease, transform 0.2s ease;
  will-change: opacity, transform;
}

.subtitle-line.source {
  color: var(--source-text);
  font-weight: 500;
}

.subtitle-line.translation {
  color: var(--translation-text);
  font-weight: 650;
}

.subtitle-line.is-refreshing {
  animation: subtitle-refresh 0.24s ease;
}

@keyframes subtitle-refresh {
  0% {
    opacity: 0.3;
    transform: translateY(8px);
  }
  100% {
    opacity: 1;
    transform: translateY(0);
  }
}

.audio-box {
  border: 1px dashed var(--line);
  border-radius: 24px;
  padding: 18px;
  background: var(--audio-bg);
  display: grid;
  gap: 14px;
}

.audio-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
}

.audio-heading {
  display: grid;
  gap: 6px;
}

.audio-heading strong {
  font-size: 18px;
  letter-spacing: -0.02em;
}

.mic-chip {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--chip);
  color: var(--subtle);
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
}

.mic-chip::before {
  content: "";
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: rgba(120, 140, 160, 0.65);
  box-shadow: 0 0 0 0 rgba(120, 140, 160, 0.28);
  transition: background 0.2s ease, box-shadow 0.2s ease;
}

.mic-chip[data-active="true"]::before {
  background: var(--accent);
  box-shadow: 0 0 0 8px color-mix(in srgb, var(--accent) 14%, transparent);
}

.visualizer-shell {
  position: relative;
  overflow: hidden;
  border-radius: 22px;
  border: 1px solid var(--line);
  background: var(--visualizer-bg);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06), 0 18px 40px var(--glow);
  padding: 12px;
}

#audioVisualizer {
  display: block;
  width: 100%;
  height: 124px;
}

.audio-box audio {
  width: 100%;
  margin-top: 2px;
}

.hint {
  color: var(--subtle);
  font-size: 13px;
  line-height: 1.6;
}

code {
  font-family: "Cascadia Code", "Consolas", monospace;
  font-size: 0.92em;
  background: color-mix(in srgb, var(--chip) 78%, transparent);
  padding: 0.16em 0.44em;
  border-radius: 999px;
}

.app.focus-mode .workspace {
  grid-template-columns: 1fr;
}

.app.focus-mode .control-column {
  display: none;
}

.app.focus-mode .content-column,
.app.focus-mode .content-panel {
  width: 100%;
}

body.focus-mode .ambient-canvas {
  --ambient-base-opacity: 0.94;
  --ambient-focus-scale: 1.05;
}

body.focus-mode .app {
  background: color-mix(in srgb, var(--panel) 72%, transparent);
  backdrop-filter: blur(24px);
}


.subtitle-placeholder {
  white-space: pre-wrap;
  word-break: break-word;
  line-height: 1.7;
  font-size: var(--placeholder-size, 34px);
  font-weight: 500;
  color: var(--text-secondary, var(--subtle));
  min-height: auto;
}

.bilingual-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: calc(var(--line-size, 34px) * 0.82);
  white-space: pre-wrap;
  word-break: break-word;
  transition: opacity 0.4s ease, transform 0.4s ease;
}

.bilingual-group:last-child {
  margin-bottom: 0;
}

/* WeChat-style speaker bubbles */
.bilingual-group[data-speaker="a"] {
  align-self: flex-start;
  max-width: 80%;
  padding: 10px 14px;
  border-radius: 4px 18px 18px 18px;
  background: var(--speaker-a-bg);
  border: 1px solid color-mix(in srgb, var(--speaker-a-color) 22%, transparent);
}

.bilingual-group[data-speaker="b"] {
  align-self: flex-end;
  max-width: 80%;
  padding: 10px 14px;
  border-radius: 18px 4px 18px 18px;
  background: var(--speaker-b-bg);
  border: 1px solid color-mix(in srgb, var(--speaker-b-color) 22%, transparent);
  text-align: right;
}

.bilingual-group[data-speaker="a"] .active-lyric {
  text-shadow:
    0 0 18px color-mix(in srgb, var(--speaker-a-color) 55%, transparent),
    0 0 6px  color-mix(in srgb, var(--speaker-a-color) 35%, transparent);
}

.bilingual-group[data-speaker="b"] .active-lyric {
  text-shadow:
    0 0 18px color-mix(in srgb, var(--speaker-b-color) 55%, transparent),
    0 0 6px  color-mix(in srgb, var(--speaker-b-color) 35%, transparent);
}

.bilingual-group[data-speaker="a"] .history-lyric {
  color: color-mix(in srgb, var(--speaker-a-color) 40%, var(--subtle));
}

.bilingual-group[data-speaker="b"] .history-lyric {
  color: color-mix(in srgb, var(--speaker-b-color) 40%, var(--subtle));
}

.bilingual-source,
.bilingual-translation {
  white-space: pre-wrap;
  word-break: break-word;
}

.bilingual-source > span,
.bilingual-translation > span {
  display: block;
  font-size: var(--line-size, 34px);
  transition: color 0.4s ease, opacity 0.4s ease, transform 0.4s ease, text-shadow 0.4s ease;
  will-change: opacity, transform, text-shadow;
}

.bilingual-source > span {
  color: var(--text-secondary, var(--subtle));
  line-height: 1.45;
}

.bilingual-translation > span {
  color: var(--accent);
  font-weight: 600;
  line-height: 1.3;
}

.history-lyric {
  opacity: 1;
}

.active-lyric {
  opacity: 0.65;
}

.timeline-marker-group {
  margin-top: calc(var(--line-size, 34px) * -0.18);
  margin-bottom: calc(var(--line-size, 34px) * 0.46);
}

.speaker-change-marker,
.silence-marker {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  padding: 5px 8px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 700;
}

.speaker-change-marker {
  border: 1px solid color-mix(in srgb, var(--accent) 32%, transparent);
  background: color-mix(in srgb, var(--accent) 10%, transparent);
  color: var(--accent);
}

.silence-marker {
  border: 1px solid rgba(255, 196, 87, 0.32);
  background: rgba(255, 196, 87, 0.1);
  color: color-mix(in srgb, var(--accent-2) 58%, var(--subtle));
}

.lang-change-marker {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  padding: 5px 8px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 700;
  margin-bottom: 2px;
  border: 1px solid rgba(50, 215, 75, 0.32);
  background: rgba(50, 215, 75, 0.1);
  color: #26a83a;
}

body.focus-mode .lang-change-marker {
  border-color: rgba(50, 215, 75, 0.3);
  background: rgba(50, 215, 75, 0.08);
  color: rgba(50, 215, 75, 0.88);
}

.top-glass-bar {
  --glass-bar-background: rgba(4, 8, 14, 0.12);
  --glass-bar-border: rgba(255, 255, 255, 0.12);
  --glass-bar-shadow: 0 clamp(22px, 4vw, 40px) clamp(54px, 8vw, 84px) rgba(0, 0, 0, 0.26);
  --glass-bar-highlight: inset 0 1px 0 rgba(255, 255, 255, 0.16);
  --dropdown-surface: rgba(10, 13, 20, 0.66);
  --dropdown-surface-elevated: rgba(18, 21, 30, 0.82);
  --dropdown-border: rgba(255, 255, 255, 0.16);
  --dropdown-border-strong: rgba(255, 255, 255, 0.28);
  --dropdown-text-primary: rgba(255, 255, 255, 0.98);
  --dropdown-text-secondary: rgba(255, 255, 255, 0.64);
  --dropdown-scroll-track: rgba(255, 255, 255, 0.06);
  --dropdown-scroll-thumb: rgba(255, 255, 255, 0.26);
  --source-menu-accent: #37d6ff;
  --target-menu-accent: #ff7a8c;
  --active-menu-accent: #37d6ff;
  position: fixed;
  top: 0;
  left: 0;
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  padding:
    calc(env(safe-area-inset-top, 0px) + clamp(24px, 3vw, 38px))
    clamp(28px, 6vw, 96px)
    clamp(18px, 2vw, 24px);
  border-bottom: none;
  background: transparent !important;
  box-shadow: none;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
  pointer-events: none;
}

.language-select-shell {
  display: grid;
  align-items: center;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  gap: clamp(18px, 2vw, 30px);
  width: min(100%, 1400px);
  pointer-events: auto;
}

.language-dropdown-block {
  display: grid;
  gap: clamp(10px, 1vw, 14px);
  min-width: 0;
}

.dropdown-label {
  padding-inline: clamp(10px, 1.2vw, 14px);
  color: var(--dropdown-text-secondary);
  font-size: clamp(0.72rem, 0.64rem + 0.34vw, 0.86rem);
  font-weight: 850;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.native-language-value {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  border: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
}

.custom-dropdown {
  position: relative;
  min-width: 0;
  --trigger-menu-accent: var(--active-menu-accent);
}

#sourceDropdown {
  --trigger-menu-accent: var(--source-menu-accent);
}

#targetDropdown {
  --trigger-menu-accent: var(--target-menu-accent);
}

.dropdown-trigger {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: clamp(12px, 1.4vw, 20px);
  min-height: clamp(64px, 6vw, 78px);
  padding: clamp(18px, 1.8vw, 24px) clamp(22px, 2.4vw, 32px);
  border: 1px solid rgba(255, 255, 255, 0.13) !important;
  border-radius: clamp(24px, 2vw, 30px);
  background:
    linear-gradient(135deg, color-mix(in srgb, var(--trigger-menu-accent) 22%, transparent), transparent 62%),
    rgba(12, 18, 26, 0.62) !important;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.1),
    0 14px 36px rgba(0, 0, 0, 0.24) !important;
  backdrop-filter: blur(22px) saturate(170%);
  -webkit-backdrop-filter: blur(22px) saturate(170%);
  color: var(--dropdown-text-primary);
  -webkit-text-fill-color: rgba(255, 255, 255, 0.95);
  font-size: clamp(1.04rem, 0.88rem + 0.58vw, 1.22rem);
  font-weight: 800;
  line-height: 1.2;
  letter-spacing: 0;
  cursor: pointer;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  transition:
    border-color 0.18s ease,
    background 0.18s ease,
    box-shadow 0.18s ease,
    transform 0.18s ease;
}

.dropdown-trigger:hover,
.dropdown-trigger[aria-expanded="true"] {
  border-color: color-mix(in srgb, var(--trigger-menu-accent) 50%, rgba(255, 255, 255, 0.2)) !important;
  background:
    linear-gradient(135deg, color-mix(in srgb, var(--trigger-menu-accent) 30%, transparent), transparent 64%),
    rgba(16, 22, 31, 0.72) !important;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.14),
    0 18px 42px rgba(0, 0, 0, 0.28),
    0 0 32px color-mix(in srgb, var(--trigger-menu-accent) 16%, transparent) !important;
}

.dropdown-trigger::after {
  content: "";
  width: clamp(11px, 1vw, 14px);
  aspect-ratio: 1;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  flex: 0 0 auto;
  opacity: 0.72;
  transform: translateY(-15%) rotate(45deg);
}

.dropdown-menu {
  position: absolute;
  top: calc(100% + clamp(14px, 1.4vw, 20px));
  left: 0;
  right: 0;
  display: grid;
  gap: clamp(8px, 0.8vw, 12px);
  padding: clamp(8px, 0.9vw, 12px) !important;
  max-height: clamp(248px, 32vh, 320px);
  overflow-y: auto;
  border: 1px solid rgba(255, 255, 255, 0.1) !important;
  border-radius: clamp(22px, 2vw, 28px);
  background: rgba(11, 13, 21, 0.4) !important;
  box-shadow:
    0 22px 54px rgba(0, 0, 0, 0.36),
    inset 0 1px 0 rgba(255, 255, 255, 0.08) !important;
  backdrop-filter: blur(28px) saturate(160%) !important;
  -webkit-backdrop-filter: blur(28px) saturate(160%) !important;
  opacity: 1;
  visibility: visible;
  transform: translateY(0) scale(1);
  transform-origin: top center;
  transition: opacity 0.24s ease, transform 0.24s ease, visibility 0.24s ease;
  scrollbar-width: thin;
  scrollbar-color: var(--dropdown-scroll-thumb) var(--dropdown-scroll-track);
}

.dropdown-menu.hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: translateY(clamp(6px, 1vw, 10px)) scale(0.98);
}

.dropdown-menu::-webkit-scrollbar {
  width: clamp(7px, 0.8vw, 9px);
}

.dropdown-menu::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.06) !important;
  border-radius: 999px;
}

.dropdown-menu::-webkit-scrollbar-thumb {
  border: 2px solid transparent !important;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.45) !important;
  background-clip: padding-box !important;
}

.dropdown-menu::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.65) !important;
}

.dropdown-item {
  position: relative;
  display: flex;
  align-items: center;
  min-height: clamp(56px, 4.8vw, 64px);
  padding: clamp(16px, 1.2vw, 20px) clamp(18px, 1.6vw, 24px);
  border: 1px solid rgba(255, 255, 255, 0.08) !important;
  border-radius: clamp(16px, 1.6vw, 20px);
  background: rgba(20, 20, 28, 0.76) !important;
  backdrop-filter: blur(18px) saturate(160%) !important;
  -webkit-backdrop-filter: blur(18px) saturate(160%) !important;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.18) !important;
  color: var(--dropdown-text-primary);
  text-shadow: 0 2px 12px rgba(0, 0, 0, 0.6);
  font-size: clamp(0.98rem, 0.86rem + 0.42vw, 1.12rem);
  font-weight: 800;
  line-height: 1.2;
  cursor: pointer;
  transition:
    transform 0.18s ease,
    background 0.18s ease,
    border-color 0.18s ease,
    box-shadow 0.18s ease,
    color 0.18s ease,
    text-shadow 0.18s ease;
  -webkit-tap-highlight-color: transparent;
}

.dropdown-item:hover {
  transform: translateY(-1px);
  border-color: rgba(255, 255, 255, 0.18) !important;
  background: rgba(35, 36, 46, 0.84) !important;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.18),
    0 12px 22px rgba(0, 0, 0, 0.2) !important;
}

.dropdown-item.is-selected,
.dropdown-item[aria-selected="true"] {
  border-color: color-mix(in srgb, var(--active-menu-accent) 70%, rgba(255, 255, 255, 0.22)) !important;
  background:
    linear-gradient(135deg, color-mix(in srgb, var(--active-menu-accent) 44%, transparent), transparent 78%),
    color-mix(in srgb, var(--active-menu-accent) 42%, rgba(12, 18, 26, 0.78)) !important;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.22),
    0 16px 34px rgba(0, 0, 0, 0.28),
    0 0 30px color-mix(in srgb, var(--active-menu-accent) 16%, transparent) !important;
  color: #f5fbff;
}

.dropdown-item.is-selected::after,
.dropdown-item[aria-selected="true"]::after {
  content: "";
  width: clamp(0.58rem, 0.46rem + 0.3vw, 0.76rem);
  aspect-ratio: 1;
  margin-left: auto;
  border-radius: 999px;
  background: rgba(236, 252, 255, 0.96);
  box-shadow: 0 0 0 clamp(5px, 0.4vw, 7px) color-mix(in srgb, var(--active-menu-accent) 34%, transparent);
  opacity: 0.96;
}

.language-direction-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: clamp(50px, 4vw, 60px);
  height: clamp(50px, 4vw, 60px);
  border: 1px solid rgba(255, 255, 255, 0.12) !important;
  border-radius: 50%;
  background: rgba(18, 16, 28, 0.62) !important;
  color: rgba(255, 255, 255, 0.78);
  flex: 0 0 auto;
  margin-top: clamp(24px, 2.2vw, 34px);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.1),
    0 12px 28px rgba(0, 0, 0, 0.24) !important;
  backdrop-filter: blur(22px) saturate(170%);
  -webkit-backdrop-filter: blur(22px) saturate(170%);
  cursor: pointer;
  transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275), background 0.2s ease, color 0.2s ease;
  padding: 0;
}

.language-direction-btn:hover {
  background: rgba(255, 255, 255, 0.15) !important;
  color: #ffffff;
  transform: scale(1.08);
}

.language-direction-btn:active {
  transform: scale(0.95);
}

.language-direction-btn.is-swapping svg {
  animation: spin-swap 0.4s cubic-bezier(0.68, -0.6, 0.32, 1.6);
}

@keyframes spin-swap {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(180deg); }
}

body.expert-mode-active .top-glass-bar {
  background: rgba(0, 0, 0, 0.48);
}

.bottom-player-bar {
  position: fixed;
  left: 50%;
  bottom: clamp(18px, 4vh, 32px);
  z-index: 10000;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 16px;
  width: min(calc(100vw - 24px), 1120px);
  padding: 14px 18px;
  border: none;
  border-radius: 999px;
  background: transparent;
  box-shadow: none;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
  pointer-events: none;
  transform: translateX(-50%);
}

.bottom-player-bar * {
  pointer-events: auto;
}

.player-bar-spacer {
  min-height: 1px;
}

.player-center-controls {
  grid-column: 2;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
}

.player-nav-btn,
.player-toggle-btn,
.player-audio-toggle-btn,
.expert-toggle-btn {
  border: 1px solid rgba(255, 255, 255, 0.14);
  color: #ffffff;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.2s ease, background 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}

.player-nav-btn,
.player-audio-toggle-btn,
.expert-toggle-btn {
  min-height: 44px;
  padding: 0 16px;
  border-radius: 999px;
  background: rgba(12, 18, 26, 0.5);
  font-size: 13px;
  backdrop-filter: blur(16px) saturate(180%);
  -webkit-backdrop-filter: blur(16px) saturate(180%);
  border: 1px solid rgba(255, 255, 255, 0.12);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
}

.player-audio-toggle-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  padding: 0;
  color: rgba(255, 255, 255, 0.72);
}

.player-audio-toggle-btn[aria-pressed="true"] {
  color: #ffffff;
  background: color-mix(in srgb, var(--blue-active) 72%, rgba(12, 18, 26, 0.62));
  border-color: rgba(255, 255, 255, 0.24);
  box-shadow: 0 10px 24px rgba(56, 189, 248, 0.22);
}

.speaker-icon {
  width: 19px;
  height: 19px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.player-audio-toggle-btn .speaker-icon-on {
  display: none;
}

.player-audio-toggle-btn[aria-pressed="true"] .speaker-icon-on {
  display: block;
}

.player-audio-toggle-btn[aria-pressed="true"] .speaker-icon-off {
  display: none;
}

.player-toggle-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 60px;
  padding: 0 24px;
  border-radius: 999px;
  background-color: var(--blue-active);
  border-color: rgba(255, 255, 255, 0.22);
  box-shadow: 0 14px 28px rgba(56, 189, 248, 0.28);
  font-size: 16px;
  color: #ffffff;
  backdrop-filter: blur(16px) saturate(180%);
  -webkit-backdrop-filter: blur(16px) saturate(180%);
  transition:
    background-color var(--toggle-transition),
    border-color var(--toggle-transition),
    box-shadow var(--toggle-transition),
    transform var(--toggle-transition);
}

.toggle-icon {
  width: 18px;
  height: 18px;
  fill: currentColor;
  flex: 0 0 auto;
}

.morph-path {
  transition: d var(--toggle-transition);
}

.player-toggle-btn .btn-text {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 4ch;
  line-height: 1;
}

.player-toggle-btn .btn-text[data-label-idle][data-label-active] {
  color: transparent;
}

.player-toggle-btn .btn-text::before,
.player-toggle-btn .btn-text::after {
  position: absolute;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #ffffff;
  opacity: 0;
  filter: blur(6px);
  transform: translateY(var(--toggle-text-offset)) scale(0.94);
  transition:
    opacity var(--toggle-transition),
    transform var(--toggle-transition),
    filter var(--toggle-transition);
  pointer-events: none;
}

.player-toggle-btn .btn-text::before {
  content: attr(data-label-idle);
}

.player-toggle-btn .btn-text::after {
  content: attr(data-label-active);
}

.player-toggle-btn:not(.is-recording) {
  background-color: var(--blue-active);
  color: white;
}

.player-toggle-btn:not(.is-recording) .morph-path {
  d: path("M 8,5 L 19,12 L 19,12 L 8,19 Z");
}

.player-toggle-btn:not(.is-recording) .btn-text::before {
  opacity: 1;
  filter: blur(0);
  transform: translateY(0) scale(1);
}

.player-toggle-btn:not(.is-recording) .btn-text::after {
  opacity: 0;
  filter: blur(6px);
  transform: translateY(calc(var(--toggle-text-offset) * -1)) scale(0.94);
}

.player-toggle-btn.is-recording {
  background-color: var(--red-stop);
  color: white;
  box-shadow: 0 14px 28px rgba(255, 77, 109, 0.32);
  transform: scale(1.05);
}

.player-toggle-btn.is-recording .morph-path {
  d: path("M 6,6 L 18,6 L 18,18 L 6,18 Z");
}

.player-toggle-btn.is-recording .btn-text::before {
  opacity: 0;
  filter: blur(6px);
  transform: translateY(var(--toggle-text-offset)) scale(0.94);
}

.player-toggle-btn.is-recording .btn-text::after {
  opacity: 1;
  filter: blur(0);
  transform: translateY(0) scale(1);
}

.expert-toggle-btn {
  grid-column: 3;
  justify-self: end;
}

.player-nav-btn:hover,
.player-toggle-btn:hover,
.player-audio-toggle-btn:hover,
.expert-toggle-btn:hover {
  transform: translateY(-1px);
}

.expert-toggle-btn[aria-pressed="true"] {
  background: rgba(255, 255, 255, 0.16);
  border-color: rgba(255, 255, 255, 0.24);
}

.expert-panel {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 20000;
  display: flex;
  flex-direction: column;
  gap: 18px;
  width: min(400px, 92vw);
  height: 100vh;
  padding: 22px 20px 28px;
  overflow-y: auto;
  background: linear-gradient(135deg, rgba(16, 24, 34, 0.65), rgba(6, 10, 14, 0.85)) !important;
  border-right: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow:
    inset -1px 0 0 rgba(255, 255, 255, 0.05),
    30px 0 80px rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(48px) saturate(200%);
  -webkit-backdrop-filter: blur(48px) saturate(200%);
  transform: translateX(-100%);
  opacity: 0;
  pointer-events: none;
  transition: transform 0.3s ease, opacity 0.3s ease;
}

body.expert-mode-active .expert-panel {
  transform: translateX(0);
  opacity: 1;
  pointer-events: auto;
}

.expert-panel .chrome-bar {
  position: relative;
  display: flex;
  padding: 0 0 18px;
  border: 0;
  background: transparent;
  box-shadow: none;
}

.expert-panel .control-column {
  display: block;
  width: 100%;
}

body.focus-mode .expert-panel .control-column {
  display: block !important;
}

.expert-panel .control-panel {
  width: 100%;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}

.expert-panel .config-grid,
.expert-panel .font-toolbar {
  grid-template-columns: 1fr;
}

body.focus-mode .ambient-canvas {
  --ambient-base-opacity: 1;
  --ambient-focus-scale: 1.12;
  filter: saturate(calc(1.12 + var(--ambient-energy, 0) * 0.48));
}

body.focus-mode {
  padding: 0;
  overflow: hidden;
  background: #05090d;
}

body.focus-mode .app {
  width: 100vw;
  min-height: 100vh;
  margin: 0;
  padding: 0;
  gap: 0;
  border: 0;
  border-radius: 0;
  box-shadow: none;
  background: transparent;
  backdrop-filter: none;
}

body.focus-mode .workspace,
body.focus-mode .content-column,
body.focus-mode .content-panel {
  width: 100%;
  height: 100vh;
  min-height: 100vh;
  margin: 0;
}

body.focus-mode .workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
}

body.focus-mode .content-column {
  display: flex;
}

body.focus-mode .content-panel {
  display: flex;
  flex-direction: column;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  justify-content: center;
}

body.focus-mode .panels {
  display: flex;
  align-items: stretch;
  justify-content: center;
  width: 100%;
  height: 100%;
  margin: 0;
  gap: 0;
}

body.focus-mode .panel {
  display: flex;
  flex: 1;
  flex-direction: column;
  min-height: 0;
  max-width: 1180px;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}

body.focus-mode .panel h2 {
  display: none !important;
}

body.focus-mode .audio-box {
  position: fixed;
  left: -9999px;
  top: -9999px;
  display: block !important;
  width: 320px;
  height: 180px;
  opacity: 0;
  pointer-events: none;
  overflow: hidden;
}

body.focus-mode #bilingualSubtitleCard {
  position: relative; /* Fix 1: Establish correct offsetParent for JS offsetTop calculations */
  flex: 1;
  width: min(100%, 980px);
  max-width: 980px;
  height: 100%;
  min-height: 0;
  max-height: none;
  margin: 0 auto;
  padding: clamp(136px, 18vh, 190px) clamp(28px, 5vw, 72px) clamp(200px, 30vh, 350px);
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  scrollbar-width: none;
  overflow-anchor: none;
  scroll-behavior: auto; /* Fix 2: Remove CSS smooth scrolling to prevent animation collisions with JS */
}

body.focus-mode #bilingualSubtitleCard::-webkit-scrollbar {
  display: none;
}

body.focus-mode .subtitle-placeholder {
  width: 100%;
  text-align: center;
  color: rgba(255, 255, 255, 0.7);
  font-size: clamp(22px, 3.5vw, 48px);
  /* Center the placeholder in the visible viewport */
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  pointer-events: none;
  padding: 0 clamp(20px, 6vw, 48px);
  line-height: 1.6;
  z-index: 0;
}

body.focus-mode .bilingual-group {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  margin-bottom: calc(var(--line-size, 34px) * 0.92);
  gap: clamp(10px, 1.6vh, 18px);
  white-space: pre-wrap;
  word-break: break-word;
  text-align: left;
  transform-origin: center;
}

body.focus-mode .bilingual-source > span,
body.focus-mode .bilingual-translation > span {
  color: #ffffff;
  letter-spacing: -0.04em;
  white-space: pre-wrap;
  word-break: break-word;
}

body.focus-mode .history-lyric {
  opacity: 0.35;
  color: rgba(255, 255, 255, 0.92);
}

body.focus-mode .active-lyric {
  opacity: 1;
  color: #ffffff;
  font-weight: 800;
  text-shadow: 0 0 calc(var(--line-size, 34px) * 0.4) rgba(255, 255, 255, 0.28);
  transform: scale(1.02);
  display: inline-block;
}

body.focus-mode .timeline-marker-group {
  margin-top: calc(var(--line-size, 34px) * -0.2);
  margin-bottom: calc(var(--line-size, 34px) * 0.52);
}

body.focus-mode .speaker-change-marker {
  margin-bottom: 2px;
  border-color: rgba(255, 255, 255, 0.2);
  background: rgba(255, 255, 255, 0.08);
  color: rgba(255, 255, 255, 0.75);
}

body.focus-mode .silence-marker {
  margin-bottom: 2px;
  border-color: rgba(255, 196, 87, 0.3);
  background: rgba(255, 196, 87, 0.08);
  color: rgba(255, 225, 170, 0.88);
}

body.focus-mode .bilingual-group[data-speaker="a"],
body.focus-mode .bilingual-group[data-speaker="b"] {
  background: transparent;
  border-color: transparent;
  max-width: 100%;
}

body.focus-mode .bilingual-group[data-speaker="b"] {
  align-self: flex-end;
  text-align: right;
}

body.focus-mode .bilingual-group[data-speaker="a"] .active-lyric {
  text-shadow:
    0 0 calc(var(--line-size, 34px) * 0.4) rgba(255, 255, 255, 0.28),
    0 0 18px color-mix(in srgb, var(--speaker-a-color) 45%, transparent);
}

body.focus-mode .bilingual-group[data-speaker="b"] .active-lyric {
  text-shadow:
    0 0 calc(var(--line-size, 34px) * 0.4) rgba(255, 255, 255, 0.28),
    0 0 18px color-mix(in srgb, var(--speaker-b-color) 45%, transparent);
}

.session-event-strip {
  position: fixed;
  left: 50%;
  top: clamp(86px, 12vh, 122px);
  z-index: 26005;
  max-width: min(calc(100vw - 24px), 520px);
  padding: 10px 14px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 8px;
  background: rgba(6, 10, 14, 0.58);
  color: #ffffff;
  box-shadow: 0 18px 44px rgba(0, 0, 0, 0.32);
  backdrop-filter: blur(12px) saturate(140%);
  -webkit-backdrop-filter: blur(12px) saturate(140%);
  font-size: 13px;
  font-weight: 700;
  line-height: 1.35;
  text-align: center;
  transform: translateX(-50%);
  opacity: 1;
  pointer-events: none;
  transition: opacity 0.24s ease, transform 0.24s ease;
}

.session-event-strip[data-variant="muted"] {
  border-color: rgba(255, 196, 87, 0.28);
  color: #ffe0a6;
}

.session-event-strip[data-variant="speaker"] {
  border-color: rgba(88, 170, 255, 0.3);
  color: #c8e4ff;
}

.session-event-strip.hidden {
  opacity: 0;
  transform: translate(-50%, -14px);
}

.scroll-console {
  position: fixed;
  left: 50%;
  top: clamp(92px, 13vh, 124px);
  z-index: 10000;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 999px;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.09), rgba(255, 255, 255, 0.035)),
    rgba(4, 8, 12, 0.34);
  color: #ffffff;
  box-shadow:
    0 14px 34px rgba(0, 0, 0, 0.2),
    inset 0 1px 0 rgba(255, 255, 255, 0.08);
  backdrop-filter: blur(18px) saturate(160%);
  -webkit-backdrop-filter: blur(18px) saturate(160%);
  transform: translateX(-50%);
  opacity: 1;
  transition: opacity 0.3s ease, transform 0.3s ease;
  pointer-events: auto;
}

.scroll-console.hidden {
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, -20px);
}

.scroll-console .hidden {
  opacity: 0;
  pointer-events: none;
  transform: scale(0.92);
}

.scroll-status-text {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-width: 138px;
  padding: 0 8px 0 10px;
  color: rgba(255, 255, 255, 0.82);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0;
  white-space: nowrap;
}

.scroll-status-text::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 999px;
  background: var(--accent);
  box-shadow: 0 0 12px color-mix(in srgb, var(--accent) 78%, transparent);
  flex: 0 0 auto;
}

.scroll-console button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  min-height: 32px;
  padding: 0 10px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.06);
  color: #ffffff;
  font-size: 11px;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  transition: background 0.2s ease, border-color 0.2s ease, transform 0.2s ease, opacity 0.3s ease;
}

.scroll-console button:hover {
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(255, 255, 255, 0.2);
  transform: translateY(-1px);
}

.scroll-console button:active {
  transform: translateY(0);
}

.scroll-console .btn-lock[aria-pressed="true"] {
  background: rgba(255, 196, 87, 0.16);
  border-color: rgba(255, 196, 87, 0.32);
  color: #ffe0a6;
}

.scroll-console .btn-live {
  background: color-mix(in srgb, var(--accent) 20%, rgba(255, 255, 255, 0.05));
  border-color: color-mix(in srgb, var(--accent) 36%, transparent);
}

.scroll-console .btn-return.hidden {
  max-width: 0;
  margin: 0;
  padding-left: 0;
  padding-right: 0;
  border-width: 0;
  overflow: hidden;
}

.toast-notification {
  position: fixed;
  left: 50%;
  top: clamp(96px, 12vh, 132px);
  z-index: 26010;
  width: min(calc(100vw - 24px), 640px);
  padding: clamp(12px, 1.6vw, 16px) clamp(16px, 2vw, 22px);
  border: 1px solid rgba(255, 143, 92, 0.34);
  border-radius: clamp(18px, 2vw, 24px);
  background: rgba(6, 10, 14, 0.56);
  color: rgba(255, 192, 163, 0.98);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.16),
    0 18px 44px rgba(0, 0, 0, 0.34);
  backdrop-filter: blur(14px) saturate(150%);
  -webkit-backdrop-filter: blur(14px) saturate(150%);
  font-size: clamp(0.92rem, 0.82rem + 0.34vw, 1rem);
  font-weight: 700;
  line-height: 1.4;
  letter-spacing: 0.01em;
  text-align: center;
  transform: translate(-50%, 0);
  opacity: 1;
  pointer-events: none;
  transition: opacity 0.28s ease, transform 0.28s ease;
}

.toast-hidden {
  opacity: 0;
  transform: translate(-50%, -18px);
}

body.focus-mode.mouse-idle:not(.expert-mode-active),
body.focus-mode.mouse-idle:not(.expert-mode-active) * {
  cursor: none !important;
}


@media (min-width: 1180px) {
  body {
    padding: 18px;
  }

  .app {
    width: calc(100vw - 36px);
    min-height: calc(100vh - 36px);
    padding: 20px;
  }

  .workspace {
    grid-template-columns: minmax(320px, 430px) minmax(0, 1fr);
    align-items: stretch;
  }

  .control-column,
  .content-column {
    display: flex;
  }

  .control-panel,
  .content-panel {
    width: 100%;
  }

  .subtitle-card {
    min-height: 420px;
    max-height: none;
    height: min(58vh, 720px);
  }

  body.focus-mode .app {
    width: 100vw;
    min-height: 100vh;
    padding: 0;
  }

  body.focus-mode .content-panel,
  body.focus-mode .content-column,
  body.focus-mode .workspace {
    width: 100%;
    height: 100vh;
    min-height: 100vh;
  }

  body.focus-mode #bilingualSubtitleCard {
    height: 100%;
  }
}

@media (max-width: 860px) {
  .audio-header {
    flex-direction: column;
  }

  .top-glass-bar {
    padding-inline: clamp(14px, 4vw, 24px);
  }

  .language-select-shell {
    grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
    gap: 8px;
  }

  .bottom-player-bar {
    width: calc(100vw - 24px);
    grid-template-columns: 1fr auto 1fr;
    border-radius: 999px;
  }

  .player-center-controls {
    flex-wrap: nowrap;
    gap: 8px;
  }

  .scroll-console {
    top: clamp(118px, 18vh, 154px);
    width: auto;
    max-width: calc(100vw - 24px);
    flex-wrap: wrap;
    justify-content: center;
    padding: 7px;
  }

  .scroll-status-text {
    width: auto;
    min-width: 0;
    text-align: center;
  }

  .expert-panel {
    width: min(440px, 100vw);
  }
}

@media (max-width: 760px) {
  body {
    padding: 12px;
  }

  .app {
    padding: 14px;
    border-radius: 22px;
  }

  .chrome-bar {
    flex-direction: column;
    align-items: stretch;
  }

  .chrome-actions {
    justify-content: stretch;
  }

  .chrome-btn {
    flex: 1;
  }

  .control-panel,
  .content-panel {
    padding: 16px;
    border-radius: 22px;
  }

  .grid,
  .panels,
  .config-grid {
    grid-template-columns: 1fr;
  }

  .font-toolbar {
    grid-template-columns: 1fr;
  }

  .actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  button {
    width: 100%;
  }

  .player-nav-btn,
  .player-toggle-btn,
  .player-audio-toggle-btn,
  .expert-toggle-btn {
    width: auto;
  }

  .subtitle-line {
    font-size: 24px;
    min-height: 60px;
  }

  .subtitle-card {
    max-height: 320px;
  }

  #audioVisualizer {
    height: 104px;
  }
}

@media (max-width: 640px) {
  .top-glass-bar {
    padding: calc(env(safe-area-inset-top, 0px) + 8px) 12px 12px;
  }

  .dropdown-label {
    display: none;
  }

  .dropdown-trigger {
    min-height: 40px;
    padding: 8px 10px;
    font-size: 0.85rem;
    border-radius: 14px;
  }

  .language-direction-btn {
    width: 36px;
    height: 36px;
  }
  .language-direction-btn svg {
    width: 16px;
    height: 16px;
  }

  .bottom-player-bar {
    padding: 8px 12px;
    bottom: 16px;
  }

  .player-toggle-btn {
    min-height: 48px;
    width: auto;
    padding: 0 16px;
    font-size: 14px;
  }

  .player-nav-btn,
  .player-audio-toggle-btn,
  .expert-toggle-btn {
    width: auto;
    min-height: 36px;
    min-width: 36px;
    padding: 0 12px;
    font-size: 12px;
    justify-content: center;
  }

  .player-audio-toggle-btn {
    padding: 0;
  }

  body.focus-mode #bilingualSubtitleCard {
    width: 100%;
    /* Fix 3: Increase bottom padding so the last line can physically reach the vertical center */
    padding: clamp(80px, 12vh, 100px) 16px clamp(200px, 30vh, 320px);
  }
}

/* --- Theme Toggle Icon Styles --- */
.theme-toggle {
  position: relative;
  width: 42px;
  height: 42px;
  min-width: unset !important;
  padding: 0 !important;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50% !important;
  overflow: hidden;
}

.theme-toggle svg {
  position: absolute;
  width: 20px;
  height: 20px;
  transition: transform 0.4s cubic-bezier(0.68, -0.6, 0.32, 1.6), opacity 0.4s ease;
}

html[data-theme="light"] .sun-icon {
  opacity: 0;
  transform: rotate(-90deg) scale(0.5);
}

html[data-theme="light"] .moon-icon {
  opacity: 1;
  transform: rotate(0) scale(1);
}

html[data-theme="dark"] .sun-icon {
  opacity: 1;
  transform: rotate(0) scale(1);
}

html[data-theme="dark"] .moon-icon {
  opacity: 0;
  transform: rotate(90deg) scale(0.5);
}

.more-options-wrapper {
  position: relative;
  grid-column: 3;
  justify-self: end;
}

.more-options-menu {
  position: absolute;
  bottom: calc(100% + 14px);
  right: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-width: min(360px, calc(100vw - 32px));
  padding: 8px;
  background: rgba(12, 18, 26, 0.75);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 18px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.3);
  backdrop-filter: blur(24px) saturate(180%);
  -webkit-backdrop-filter: blur(24px) saturate(180%);
  transform-origin: bottom right;
  transition: opacity 0.2s cubic-bezier(0.16, 1, 0.3, 1), transform 0.2s cubic-bezier(0.16, 1, 0.3, 1), visibility 0.2s;
}

html[data-theme="light"] .more-options-menu {
  background: rgba(255, 255, 255, 0.75);
  border: 1px solid rgba(0, 0, 0, 0.08);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.1);
}

.more-options-menu.hidden {
  opacity: 0;
  transform: scale(0.9) translateY(10px);
  visibility: hidden;
  pointer-events: none;
}

.more-menu-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 18px;
  width: 100%;
  min-width: 200px;
  border: none;
  border-radius: 12px;
  background: transparent;
  color: var(--text);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s ease, transform 0.1s ease;
}

.more-menu-item span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

.more-menu-item:hover {
  background: rgba(255, 255, 255, 0.1);
  transform: scale(0.98);
}

html[data-theme="light"] .more-menu-item:hover {
  background: rgba(0, 0, 0, 0.05);
}

.menu-icon-wrapper {
  position: relative;
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.menu-icon-wrapper svg {
  position: absolute;
  width: 18px;
  height: 18px;
  transition: transform 0.4s cubic-bezier(0.68, -0.6, 0.32, 1.6), opacity 0.4s ease;
}

.auth-modal {
  position: fixed;
  inset: 0;
  z-index: 27000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(8, 10, 16, 0.34);
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  backdrop-filter: blur(28px) saturate(145%);
  -webkit-backdrop-filter: blur(28px) saturate(145%);
  transition: opacity 0.18s ease, visibility 0.18s ease;
}

.auth-modal.hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.auth-dialog,
.auth-gate-card {
  color: var(--text);
  font-family: "Segoe UI Variable", "Aptos", "Noto Sans SC", "Microsoft YaHei", sans-serif;
}

.auth-dialog {
  position: relative;
  width: min(100%, 420px);
  padding: 30px;
  border: 1px solid color-mix(in srgb, var(--line) 78%, rgba(255, 255, 255, 0.28));
  border-radius: 12px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.12), transparent 42%),
    color-mix(in srgb, var(--panel) 88%, transparent);
  box-shadow:
    0 22px 70px rgba(0, 0, 0, 0.34),
    inset 0 1px 0 rgba(255, 255, 255, 0.18);
  transform: translateY(0) scale(1);
  transition: transform 0.18s ease;
  backdrop-filter: blur(30px) saturate(150%);
  -webkit-backdrop-filter: blur(30px) saturate(150%);
}

html[data-theme="light"] .auth-dialog {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.88), rgba(244, 247, 252, 0.82)),
    color-mix(in srgb, var(--panel) 84%, transparent);
  box-shadow:
    0 26px 70px rgba(33, 45, 66, 0.22),
    inset 0 1px 0 rgba(255, 255, 255, 0.95);
}

.auth-modal.hidden .auth-dialog {
  transform: translateY(10px) scale(0.985);
}

.auth-close-btn {
  position: absolute;
  top: 10px;
  right: 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 32px;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 6px;
  background: transparent;
  color: color-mix(in srgb, var(--text) 72%, transparent);
  box-shadow: none;
}

.auth-close-btn:hover {
  background: #c42b1c;
  color: #ffffff;
  transform: none;
}

.auth-header {
  padding-right: 32px;
}

.auth-eyebrow {
  margin: 0 0 10px;
  color: var(--accent);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.auth-header h2 {
  margin: 0;
  font-family: "Segoe UI Variable Display", "Segoe UI Variable", "Aptos Display", sans-serif;
  font-size: 25px;
  font-weight: 650;
  line-height: 1.18;
}

.auth-header p:not(.auth-eyebrow) {
  margin: 10px 0 0;
  color: var(--subtle);
  font-size: 14px;
  line-height: 1.55;
}

.auth-form {
  display: grid;
  gap: 10px;
  margin-top: 24px;
}

.auth-form label,
.auth-gate-field label {
  color: color-mix(in srgb, var(--text) 68%, transparent);
  font-size: 12px;
  font-weight: 600;
}

.auth-form input,
.auth-gate-field input {
  min-height: 44px;
  border: 1px solid color-mix(in srgb, var(--line) 82%, transparent);
  border-bottom-color: color-mix(in srgb, var(--text) 32%, transparent);
  border-radius: 6px;
  background: color-mix(in srgb, var(--input-bg) 92%, rgba(255, 255, 255, 0.08));
  color: var(--text);
  font-size: 15px;
  line-height: 1.2;
  padding: 10px 12px;
  box-shadow: inset 0 -1px 0 transparent;
  transition: border-color 0.16s ease, box-shadow 0.16s ease, background 0.16s ease;
}

.auth-form input:focus,
.auth-gate-field input:focus {
  border-color: color-mix(in srgb, var(--line) 82%, transparent);
  border-bottom-color: var(--accent);
  box-shadow: inset 0 -2px 0 var(--accent);
}

.auth-error,
.auth-gate-service-error {
  padding: 10px 12px;
  border: 1px solid rgba(196, 43, 28, 0.28);
  border-radius: 6px;
  background: rgba(196, 43, 28, 0.12);
  color: #ff8b7f;
  font-size: 13px;
  font-weight: 600;
  line-height: 1.4;
}

.auth-gate-service-error.hidden,
.auth-gate-form.hidden {
  display: none;
}

html[data-theme="light"] .auth-error,
html[data-theme="light"] .auth-gate-service-error {
  color: #a4262c;
}

.auth-error.hidden {
  display: none;
}

.auth-actions,
.auth-gate-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 12px;
}

.auth-actions button,
.auth-gate-actions button {
  min-height: 42px;
  padding: 0 14px;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 600;
  box-shadow: none;
}

.auth-actions .primary,
.auth-gate-actions .primary {
  border-color: color-mix(in srgb, var(--accent) 76%, #ffffff);
  background: linear-gradient(180deg, color-mix(in srgb, var(--accent) 92%, white), var(--accent));
  box-shadow: 0 8px 20px color-mix(in srgb, var(--accent) 22%, transparent);
}

.auth-actions .ghost,
.auth-gate-actions .ghost {
  border-color: color-mix(in srgb, var(--line) 88%, transparent);
  background: color-mix(in srgb, var(--ghost-bg) 86%, transparent);
  color: var(--text);
}

.auth-actions button:hover,
.auth-gate-actions button:hover {
  transform: none;
  filter: brightness(1.04);
}

/* Auth gate */
.auth-gate {
  position: fixed;
  inset: 0;
  z-index: 26900;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background:
    linear-gradient(135deg, rgba(0, 103, 192, 0.28), rgba(19, 22, 32, 0.92) 44%, rgba(255, 109, 74, 0.2)),
    linear-gradient(180deg, color-mix(in srgb, var(--bg-start) 76%, transparent), var(--bg-end));
  opacity: 1;
  transition: opacity 0.28s ease;
}

html[data-theme="light"] .auth-gate {
  background:
    linear-gradient(135deg, rgba(0, 103, 192, 0.16), rgba(247, 249, 253, 0.92) 48%, rgba(255, 149, 0, 0.14)),
    linear-gradient(180deg, #f8fbff, #eef3f8);
}

body.auth-gate-hiding .auth-gate {
  opacity: 0;
  pointer-events: none;
}

body.auth-checking .auth-gate {
  opacity: 0;
  pointer-events: none;
}

body.authenticated .auth-gate {
  display: none;
}

.auth-gate-card {
  position: relative;
  width: min(100%, 420px);
  margin: 0;
  padding: 34px 34px 30px;
  border: 1px solid color-mix(in srgb, var(--line) 76%, rgba(255, 255, 255, 0.28));
  border-radius: 12px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.12), transparent 38%),
    color-mix(in srgb, var(--panel) 86%, transparent);
  box-shadow:
    0 28px 90px rgba(0, 0, 0, 0.36),
    inset 0 1px 0 rgba(255, 255, 255, 0.18);
  overflow: hidden;
  backdrop-filter: blur(34px) saturate(155%);
  -webkit-backdrop-filter: blur(34px) saturate(155%);
}

html[data-theme="light"] .auth-gate-card {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.88), rgba(244, 247, 252, 0.8)),
    color-mix(in srgb, var(--panel) 82%, transparent);
  box-shadow:
    0 30px 80px rgba(33, 45, 66, 0.2),
    inset 0 1px 0 rgba(255, 255, 255, 0.95);
}

.auth-gate-card::before {
  content: "";
  position: absolute;
  inset: 0 0 auto;
  height: 3px;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
}

.auth-gate-brand {
  text-align: left;
  margin-bottom: 28px;
}

.auth-gate-logo {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  border: 1px solid color-mix(in srgb, var(--accent) 38%, rgba(255, 255, 255, 0.35));
  border-radius: 10px;
  background:
    linear-gradient(135deg, color-mix(in srgb, var(--accent) 24%, transparent), color-mix(in srgb, var(--accent-2) 18%, transparent)),
    rgba(255, 255, 255, 0.08);
  color: var(--text);
  font-size: 13px;
  font-weight: 750;
  letter-spacing: 0.04em;
  margin-bottom: 18px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.22);
}

.auth-gate-title {
  margin: 0 0 8px;
  color: var(--text);
  font-family: "Segoe UI Variable Display", "Segoe UI Variable", "Aptos Display", sans-serif;
  font-size: 28px;
  font-weight: 650;
  line-height: 1.16;
}

.auth-gate-subtitle {
  margin: 0;
  color: var(--subtle);
  font-size: 14px;
  line-height: 1.55;
}

.auth-gate-service-error {
  margin-bottom: 18px;
  text-align: left;
}

.auth-gate-form {
  display: flex;
  flex-direction: column;
  gap: 13px;
}

.auth-gate-field {
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.history-modal {
  position: fixed;
  inset: 0;
  z-index: 32000;
  display: block;
  padding: clamp(28px, 5vw, 72px);
  background:
    radial-gradient(circle at 18% 14%, rgba(55, 214, 255, 0.22), transparent 36%),
    radial-gradient(circle at 84% 18%, rgba(255, 122, 140, 0.26), transparent 38%),
    linear-gradient(180deg, #020407, #05070d 68%, #030407);
  backdrop-filter: blur(26px) saturate(145%);
  -webkit-backdrop-filter: blur(26px) saturate(145%);
  color: var(--text);
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.28) transparent;
}

.history-modal.hidden {
  display: none;
}

.history-dialog {
  position: relative;
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
  gap: clamp(22px, 3vw, 34px);
  width: min(1040px, 100%);
  min-height: calc(100dvh - clamp(56px, 10vw, 144px));
  margin: 0 auto;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--text);
  box-shadow: none;
  overflow: visible;
}

html[data-theme="light"] .history-dialog {
  background:
    radial-gradient(circle at 12% 0%, rgba(0, 185, 107, 0.13), transparent 40%),
    radial-gradient(circle at 88% 8%, rgba(255, 122, 140, 0.1), transparent 36%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.94), rgba(245, 247, 252, 0.82)),
    color-mix(in srgb, var(--panel) 90%, transparent);
  box-shadow: 0 30px 90px rgba(36, 52, 76, 0.22);
}

.history-dialog::before {
  display: none;
}

.history-dialog::after {
  display: none;
}

.history-dialog > * {
  position: relative;
  z-index: 1;
}

.history-dialog .auth-close-btn {
  position: absolute;
  top: 4px;
  right: 0;
  z-index: 3;
  width: 46px;
  height: 46px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.06);
  color: rgba(255, 255, 255, 0.8);
}

.history-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: clamp(18px, 3vw, 40px);
  padding: clamp(44px, 6vw, 70px) 56px 0 0;
}

.history-title-block {
  max-width: 780px;
}

.history-eyebrow {
  margin: 0 0 10px;
  color: var(--accent);
  font-size: clamp(0.72rem, 0.64rem + 0.28vw, 0.86rem);
  font-weight: 900;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.history-header h2 {
  margin: 0;
  color: var(--text);
  font-family: "Segoe UI Variable Display", "Segoe UI Variable", "Aptos Display", sans-serif;
  font-size: clamp(3.1rem, 2.1rem + 4vw, 5.8rem);
  font-weight: 850;
  letter-spacing: 0;
  line-height: 1;
}

.history-header p:not(.history-eyebrow) {
  margin: 14px 0 0;
  color: var(--subtle);
  font-size: clamp(1rem, 0.86rem + 0.5vw, 1.34rem);
  font-weight: 800;
  line-height: 1.46;
}

.history-header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 6px;
}

.history-header-actions .compact-btn {
  min-height: 54px;
  padding: 0 22px;
  border-radius: 16px;
  border-color: rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.1);
  font-weight: 900;
}

.history-status {
  min-height: 0;
  max-width: 250px;
  padding: 10px 12px;
  border: 1px solid color-mix(in srgb, var(--accent) 28%, transparent);
  border-radius: 999px;
  background: color-mix(in srgb, var(--accent) 12%, transparent);
  color: color-mix(in srgb, var(--text) 88%, var(--accent));
  font-size: 12px;
  font-weight: 800;
  line-height: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.history-status:empty {
  display: none;
}

.history-summary {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}

.history-summary-chip {
  min-width: 0;
  padding: 16px 18px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 22px;
  background:
    linear-gradient(135deg, color-mix(in srgb, var(--accent) 10%, transparent), transparent 64%),
    rgba(255, 255, 255, 0.11);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

.history-summary-label {
  display: block;
  margin-bottom: 5px;
  color: var(--subtle);
  font-size: 10px;
  font-weight: 900;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.history-summary-chip strong {
  display: block;
  overflow: hidden;
  color: var(--text);
  font-size: clamp(1rem, 0.92rem + 0.3vw, 1.16rem);
  font-weight: 850;
  line-height: 1.15;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.history-layout {
  display: block;
  min-height: 0;
}

.history-list,
.history-detail-shell {
  min-height: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  overflow: visible;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}

.history-list {
  display: flex;
  flex-direction: column;
  gap: 16px;
  max-width: 920px;
  overflow: visible;
  padding: 0;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.32) rgba(255, 255, 255, 0.06);
}

.history-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px 18px;
  align-items: center;
  width: 100%;
  min-height: 112px;
  padding: 22px 24px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 28px;
  background: rgba(255, 255, 255, 0.11);
  color: var(--text);
  text-align: left;
  box-shadow: none;
  transition:
    transform 0.18s ease,
    border-color 0.18s ease,
    background 0.18s ease,
    box-shadow 0.18s ease;
}

.history-item:hover,
.history-item.active {
  transform: translateY(-1px);
  border-color: color-mix(in srgb, var(--accent) 46%, rgba(255, 255, 255, 0.16));
  background:
    linear-gradient(135deg, color-mix(in srgb, var(--accent) 18%, transparent), transparent 66%),
    rgba(255, 255, 255, 0.06);
  box-shadow: 0 14px 30px rgba(0, 0, 0, 0.22);
}

.history-item.active {
  background:
    linear-gradient(135deg, color-mix(in srgb, var(--accent) 28%, transparent), transparent 70%),
    rgba(255, 255, 255, 0.075);
}

.history-item-title {
  grid-column: 1;
  overflow: hidden;
  color: var(--text);
  font-size: clamp(1.35rem, 1rem + 1.2vw, 2rem);
  font-weight: 900;
  line-height: 1.15;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.history-item-meta {
  grid-column: 1;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.history-item-meta span,
.history-item-route,
.history-time {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  min-height: 24px;
  padding: 0 9px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.045);
  color: var(--subtle);
  font-size: 11px;
  font-weight: 850;
  line-height: 1;
}

.history-item-route {
  grid-column: 1;
  color: color-mix(in srgb, var(--accent) 68%, var(--text));
}

.history-item-play {
  grid-column: 2;
  grid-row: 1 / span 3;
  display: grid;
  place-items: center;
  width: clamp(56px, 6vw, 76px);
  height: clamp(56px, 6vw, 76px);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.14);
  color: #ffffff;
  font-size: clamp(1.4rem, 1rem + 1vw, 2rem);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.12);
}

.history-meta {
  color: var(--subtle);
  font-size: 13px;
  font-weight: 700;
  line-height: 1.35;
}

.history-detail-shell {
  display: flex;
  flex-direction: column;
  max-width: 960px;
}

.history-empty {
  margin: auto;
  padding: 26px;
  color: var(--subtle);
  text-align: center;
  font-size: clamp(1rem, 0.9rem + 0.35vw, 1.15rem);
  line-height: 1.35;
}

.history-empty p {
  margin: 0;
}

.history-empty-orb {
  display: grid;
  place-items: center;
  width: 88px;
  height: 88px;
  margin: 0 auto 18px;
  border: 1px solid color-mix(in srgb, var(--accent) 32%, rgba(255, 255, 255, 0.12));
  border-radius: 999px;
  background:
    radial-gradient(circle, color-mix(in srgb, var(--accent) 24%, transparent), transparent 68%),
    rgba(255, 255, 255, 0.045);
}

.history-empty-orb span {
  width: 28px;
  height: 28px;
  border: 2px solid color-mix(in srgb, var(--accent) 70%, rgba(255, 255, 255, 0.42));
  border-left-color: transparent;
  border-radius: 999px;
}

.history-empty.hidden {
  display: none;
}

.history-detail {
  display: grid;
  grid-template-rows: auto auto auto minmax(0, 1fr);
  gap: clamp(20px, 3vw, 32px);
  min-height: 0;
  padding: 0;
}

.history-detail.hidden {
  display: none;
}

.history-detail-heading h3 {
  margin: 0 0 10px;
  color: var(--text);
  font-size: clamp(2rem, 1.4rem + 2.8vw, 4.2rem);
  font-weight: 900;
  line-height: 1.12;
  text-wrap: balance;
}

.history-player-card {
  padding: 12px 16px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 28px;
  background: rgba(255, 255, 255, 0.12);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

.history-audio {
  width: 100%;
  display: block;
  color-scheme: dark;
}

.history-detail-tabs {
  display: flex;
  align-items: flex-end;
  gap: clamp(28px, 5vw, 72px);
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
}

.history-detail-tabs button {
  width: auto;
  padding: 0 0 18px;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--subtle);
  box-shadow: none;
  font-size: clamp(1.25rem, 1rem + 1vw, 2rem);
  font-weight: 900;
}

.history-detail-tabs button.active {
  color: var(--text);
  box-shadow: inset 0 -4px 0 currentColor;
}

.history-timeline {
  display: flex;
  flex-direction: column;
  gap: 22px;
  min-height: 0;
  overflow-y: visible;
  padding-right: 0;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.32) rgba(255, 255, 255, 0.06);
}

.history-timeline-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 14px;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--text);
  box-shadow: none;
  text-align: left;
  transition:
    transform 0.18s ease,
    border-color 0.18s ease,
    background 0.18s ease,
    box-shadow 0.18s ease;
}

.history-timeline-row:hover {
  transform: none;
  border-color: transparent;
  background: transparent;
}

.history-timeline-row.active {
  border-color: transparent;
  background: transparent;
  box-shadow: none;
}

.history-timeline-text {
  grid-column: 1;
  grid-row: 1;
  display: grid;
  gap: 8px;
}

.history-source {
  color: var(--text);
  font-size: clamp(1.55rem, 1.1rem + 1.7vw, 2.7rem);
  font-weight: 900;
  line-height: 1.22;
}

.history-translation {
  color: var(--subtle);
  font-size: clamp(1.05rem, 0.9rem + 0.5vw, 1.32rem);
  font-weight: 800;
  line-height: 1.35;
}

html[data-theme="light"] .history-list,
html[data-theme="light"] .history-detail-shell {
  background: rgba(255, 255, 255, 0.72);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.8),
    0 18px 46px rgba(35, 50, 72, 0.12);
}

html[data-theme="light"] .history-item,
html[data-theme="light"] .history-timeline-row,
html[data-theme="light"] .history-player-card,
html[data-theme="light"] .history-summary-chip {
  background: rgba(255, 255, 255, 0.58);
}

@media (max-width: 900px) {
  .history-dialog {
    height: calc(100dvh - 32px);
    grid-template-rows: auto auto minmax(0, 1fr);
  }

  .history-header {
    flex-direction: column;
    gap: 14px;
  }

  .history-header-actions {
    width: 100%;
    justify-content: space-between;
  }

  .history-summary {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .history-layout {
    grid-template-columns: 1fr;
    grid-template-rows: minmax(160px, 0.38fr) minmax(0, 1fr);
  }
}

@media (max-width: 640px) {
  .history-modal {
    padding: 12px;
  }

  .history-dialog {
    width: 100%;
    height: calc(100dvh - 24px);
    padding: 20px 16px 16px;
    border-radius: 22px;
  }

  .history-header {
    padding-right: 40px;
  }

  .history-header h2 {
    font-size: 30px;
  }

  .history-header-actions {
    align-items: stretch;
  }

  .history-header-actions .compact-btn {
    flex: 0 0 auto;
  }

  .history-summary {
    grid-template-columns: 1fr 1fr;
  }

  .history-summary-chip {
    padding: 10px 11px;
  }

  .history-list {
    padding: 10px;
  }

  .history-item {
    padding: 13px;
  }

  .history-detail {
    padding: 14px;
  }

  .history-timeline-row {
    grid-template-columns: 1fr;
    gap: 9px;
  }
}

@media (max-width: 520px) {
  .auth-modal,
  .auth-gate,
  .history-modal {
    padding: 16px;
  }

  .auth-dialog,
  .auth-gate-card,
  .history-dialog {
    width: 100%;
    padding: 28px 22px 22px;
  }

  .history-dialog {
    height: calc(100dvh - 32px);
    grid-template-rows: auto auto minmax(0, 1fr);
  }

  .history-layout {
    grid-template-columns: 1fr;
    grid-template-rows: minmax(120px, 0.36fr) minmax(0, 1fr);
  }

  .history-header {
    padding-right: 34px;
  }

  .auth-header h2,
  .auth-gate-title,
  .history-header h2 {
    font-size: 24px;
  }

  .auth-actions,
  .auth-gate-actions {
    grid-template-columns: 1fr;
  }
}

/* Route-style recording history page */
body.history-route-active {
  overflow: hidden;
}

.history-modal {
  display: block;
  padding: clamp(30px, 5vw, 68px) clamp(24px, 7vw, 86px);
  background:
    radial-gradient(circle at 12% 6%, rgba(41, 207, 232, 0.24), transparent 34%),
    radial-gradient(circle at 88% 8%, rgba(255, 86, 103, 0.22), transparent 36%),
    linear-gradient(180deg, #000205 0%, #05070c 58%, #020305 100%);
  color: #f5f8ff;
  overflow-y: auto;
}

.history-modal.hidden {
  display: none;
}

.history-dialog {
  display: flex;
  flex-direction: column;
  gap: clamp(24px, 3vw, 38px);
  width: min(980px, 100%);
  min-height: calc(100dvh - clamp(60px, 10vw, 136px));
  height: auto;
  margin: 0 auto;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  overflow: visible;
}

html[data-theme="light"] .history-modal {
  background:
    radial-gradient(circle at 12% 8%, rgba(25, 191, 217, 0.18), transparent 34%),
    radial-gradient(circle at 88% 8%, rgba(255, 96, 112, 0.16), transparent 34%),
    linear-gradient(180deg, #f7fbff 0%, #edf2f7 58%, #f8fafc 100%);
}

html[data-theme="light"] .history-dialog {
  background: transparent;
  box-shadow: none;
}

.history-dialog .auth-close-btn {
  top: 0;
  left: 0;
  right: auto;
  width: 52px;
  height: 52px;
  border: 0;
  background: transparent;
  color: color-mix(in srgb, var(--text) 86%, white);
  box-shadow: none;
}

.history-dialog .auth-close-btn:hover {
  background: rgba(255, 255, 255, 0.08);
}

.history-header {
  position: relative;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: clamp(18px, 4vw, 48px);
  padding: clamp(78px, 8vw, 112px) 0 0;
}

.history-title-block {
  max-width: 760px;
}

.history-eyebrow {
  margin: 0 0 12px;
  color: color-mix(in srgb, var(--accent) 82%, white);
  font-size: clamp(0.72rem, 0.64rem + 0.28vw, 0.86rem);
  font-weight: 900;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.history-header h2 {
  max-width: 18ch;
  margin: 0;
  color: var(--text);
  font-family: "Segoe UI Variable Display", "Segoe UI Variable", "Aptos Display", sans-serif;
  font-size: clamp(3.6rem, 2.4rem + 4.8vw, 6.2rem);
  font-weight: 900;
  letter-spacing: 0;
  line-height: 0.95;
  text-wrap: balance;
}

.history-modal.history-detail-open .history-header h2 {
  max-width: 18ch;
  font-size: clamp(2.9rem, 2.1rem + 3vw, 4.8rem);
  line-height: 1.08;
}

.history-header p:not(.history-eyebrow) {
  margin: 18px 0 0;
  color: color-mix(in srgb, var(--subtle) 86%, white);
  font-size: clamp(1.15rem, 0.96rem + 0.7vw, 1.55rem);
  font-weight: 850;
  line-height: 1.38;
}

.history-header-actions {
  position: absolute;
  top: 2px;
  right: 0;
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0;
}

.history-header-actions .compact-btn {
  min-height: 44px;
  padding: 0 18px;
  border: 1px solid rgba(255, 255, 255, 0.13);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
  font-weight: 900;
}

.history-status {
  max-width: min(42vw, 260px);
  min-height: 0;
  padding: 10px 12px;
  border: 1px solid color-mix(in srgb, var(--accent) 32%, transparent);
  border-radius: 999px;
  background: color-mix(in srgb, var(--accent) 13%, transparent);
  color: color-mix(in srgb, var(--text) 82%, var(--accent));
  font-size: 12px;
  font-weight: 850;
  line-height: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.history-status:empty {
  display: none;
}

.history-summary {
  display: flex;
  gap: 14px;
  width: min(100%, 940px);
  overflow-x: auto;
  padding-bottom: 2px;
  scrollbar-width: none;
}

.history-summary::-webkit-scrollbar {
  display: none;
}

.history-summary-chip {
  flex: 0 0 auto;
  min-width: min(255px, 68vw);
  min-height: 76px;
  padding: 16px 24px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 24px;
  background: rgba(255, 255, 255, 0.13);
  box-shadow: none;
}

.history-summary-chip:first-child {
  position: relative;
  min-width: 132px;
  padding-left: 64px;
}

.history-summary-chip:first-child::before {
  content: "";
  position: absolute;
  left: 22px;
  top: 50%;
  width: 28px;
  height: 22px;
  border: 3px solid currentColor;
  border-radius: 6px;
  color: color-mix(in srgb, var(--text) 72%, var(--subtle));
  transform: translateY(-50%);
}

.history-summary-chip:first-child::after {
  content: "";
  position: absolute;
  left: 30px;
  top: 50%;
  width: 12px;
  height: 12px;
  border: 3px solid currentColor;
  border-radius: 999px;
  color: color-mix(in srgb, var(--text) 72%, var(--subtle));
  box-shadow: 12px 0 0 -3px currentColor;
  transform: translateY(-50%);
}

.history-summary-label {
  display: block;
  margin: 0 0 6px;
  color: color-mix(in srgb, var(--subtle) 82%, white);
  font-size: 0.72rem;
  font-weight: 900;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.history-summary-chip strong {
  display: block;
  overflow: hidden;
  color: var(--text);
  font-size: clamp(1.15rem, 1rem + 0.6vw, 1.55rem);
  font-weight: 900;
  line-height: 1.12;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.history-layout {
  display: block;
  min-height: 0;
}

.history-modal:not(.history-detail-open) .history-detail-shell {
  display: none;
}

.history-modal.history-detail-open .history-summary,
.history-modal.history-detail-open .history-list {
  display: none;
}

.history-list,
.history-detail-shell {
  min-height: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  overflow: visible;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}

.history-list {
  display: flex;
  flex-direction: column;
  gap: 18px;
  width: min(100%, 860px);
  padding: 0 0 92px;
}

.history-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 9px 18px;
  align-items: center;
  width: 100%;
  min-height: 118px;
  padding: 24px 28px;
  border: 1px solid rgba(255, 255, 255, 0.07);
  border-radius: 28px;
  background: rgba(255, 255, 255, 0.105);
  color: var(--text);
  text-align: left;
  box-shadow: none;
  transition:
    transform 0.18s ease,
    border-color 0.18s ease,
    background 0.18s ease,
    box-shadow 0.18s ease;
}

.history-item:hover,
.history-item.active {
  transform: translateY(-1px);
  border-color: color-mix(in srgb, var(--accent) 48%, rgba(255, 255, 255, 0.14));
  background:
    linear-gradient(135deg, color-mix(in srgb, var(--accent) 16%, transparent), transparent 68%),
    rgba(255, 255, 255, 0.13);
  box-shadow: 0 20px 38px rgba(0, 0, 0, 0.22);
}

.history-item-title {
  grid-column: 1;
  overflow: hidden;
  color: var(--text);
  font-size: clamp(1.55rem, 1.16rem + 1.28vw, 2.24rem);
  font-weight: 900;
  line-height: 1.1;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.history-item-meta {
  grid-column: 1;
  display: flex;
  flex-wrap: wrap;
  gap: 7px 12px;
}

.history-item-meta span,
.history-item-route {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  min-height: auto;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: color-mix(in srgb, var(--subtle) 84%, white);
  font-size: clamp(0.92rem, 0.82rem + 0.32vw, 1.08rem);
  font-weight: 850;
  line-height: 1.15;
}

.history-item-route {
  grid-column: 1;
  color: color-mix(in srgb, var(--accent) 62%, var(--text));
}

.history-item-play {
  grid-column: 2;
  grid-row: 1 / span 3;
  display: grid;
  place-items: center;
  width: clamp(62px, 6vw, 86px);
  height: clamp(62px, 6vw, 86px);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.16);
  color: #ffffff;
  font-size: clamp(1.42rem, 1.05rem + 1vw, 2rem);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.13);
}

.history-detail-shell {
  display: flex;
  flex-direction: column;
  width: min(100%, 960px);
  max-width: 960px;
}

.history-detail {
  display: flex;
  flex-direction: column;
  gap: clamp(24px, 3vw, 36px);
  min-height: 0;
  padding: 0 0 8px;
}

.history-detail.hidden,
.history-empty.hidden {
  display: none;
}

.history-modal.history-detail-open .history-detail-heading,
.history-modal.history-detail-open .history-detail-empty {
  display: none;
}

.history-player-card {
  order: 3;
  position: sticky;
  bottom: 18px;
  z-index: 5;
  margin-top: 8px;
  padding: 14px 18px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.18);
  box-shadow:
    0 18px 48px rgba(0, 0, 0, 0.36),
    inset 0 1px 0 rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(22px) saturate(150%);
  -webkit-backdrop-filter: blur(22px) saturate(150%);
}

.history-audio {
  display: block;
  width: 100%;
  min-height: 44px;
  color-scheme: dark;
}

.history-detail-tabs {
  order: 1;
  display: flex;
  align-items: flex-end;
  gap: clamp(30px, 6vw, 82px);
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
}

.history-detail-tabs button {
  width: auto;
  min-height: 62px;
  padding: 0 0 18px;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: color-mix(in srgb, var(--subtle) 82%, white);
  box-shadow: none;
  font-size: clamp(1.55rem, 1.14rem + 1.25vw, 2.35rem);
  font-weight: 900;
}

.history-detail-tabs button.active {
  color: var(--text);
  box-shadow: inset 0 -4px 0 currentColor;
}

.history-detail-tabs button:disabled {
  opacity: 0.48;
}

.history-timeline {
  order: 2;
  display: flex;
  flex-direction: column;
  gap: clamp(28px, 4vw, 48px);
  min-height: 0;
  padding: 12px 0 128px;
  overflow: visible;
}

.history-timeline-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) max-content;
  gap: 12px clamp(18px, 4vw, 42px);
  align-items: start;
  width: 100%;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--text);
  box-shadow: none;
  text-align: left;
}

.history-timeline-row:hover,
.history-timeline-row.active {
  transform: none;
  border-color: transparent;
  background: transparent;
  box-shadow: none;
}

.history-timeline-text {
  grid-column: 1;
  grid-row: 1;
  display: grid;
  gap: 10px;
  min-width: 0;
}

.history-time {
  grid-column: 2;
  grid-row: 1;
  align-self: start;
  display: block;
  width: auto;
  min-height: auto;
  padding: 8px 0 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: color-mix(in srgb, var(--subtle) 78%, white);
  font-size: clamp(1.25rem, 1rem + 0.95vw, 2rem);
  font-weight: 900;
  line-height: 1;
  white-space: nowrap;
}

.history-speaker {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  min-height: 38px;
  padding: 0 18px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--accent) 22%, rgba(0, 0, 0, 0.56));
  color: color-mix(in srgb, var(--text) 90%, var(--accent));
  font-size: clamp(0.96rem, 0.84rem + 0.38vw, 1.16rem);
  font-weight: 900;
}

.history-timeline-row.active .history-speaker {
  background: color-mix(in srgb, var(--accent) 34%, rgba(0, 0, 0, 0.5));
}

.history-source {
  color: var(--text);
  font-size: clamp(1.8rem, 1.22rem + 1.9vw, 3.05rem);
  font-weight: 900;
  line-height: 1.16;
  overflow-wrap: anywhere;
}

.history-translation {
  color: color-mix(in srgb, var(--subtle) 82%, white);
  font-size: clamp(1.06rem, 0.92rem + 0.5vw, 1.36rem);
  font-weight: 820;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.history-empty {
  margin: 0;
  padding: 28px 0;
  color: color-mix(in srgb, var(--subtle) 84%, white);
  text-align: left;
  font-size: clamp(1.1rem, 0.96rem + 0.45vw, 1.28rem);
  font-weight: 800;
}

.history-empty-orb {
  display: none;
}

html[data-theme="light"] .history-summary-chip,
html[data-theme="light"] .history-item,
html[data-theme="light"] .history-player-card {
  background: rgba(255, 255, 255, 0.7);
  box-shadow: 0 18px 42px rgba(41, 59, 86, 0.12);
}

html[data-theme="light"] .history-list,
html[data-theme="light"] .history-detail-shell,
html[data-theme="light"] .history-timeline-row {
  background: transparent;
  box-shadow: none;
}

@media (min-width: 901px) {
  .history-summary {
    overflow-x: visible;
  }

  .history-summary-chip,
  .history-summary-chip:first-child {
    flex: 1 1 0;
    min-width: 0;
  }
}

@media (max-width: 900px) {
  .history-modal {
    padding: 28px 26px 40px;
  }

  .history-dialog {
    width: 100%;
    min-height: calc(100dvh - 68px);
    height: auto;
    padding: 0;
    border-radius: 0;
  }

  .history-header {
    flex-direction: column;
    gap: 14px;
    padding-top: 74px;
  }

  .history-header-actions {
    justify-content: flex-end;
    width: auto;
  }

  .history-list {
    width: 100%;
  }
}

@media (max-width: 640px) {
  .history-modal {
    padding: 22px 18px 30px;
  }

  .history-dialog {
    min-height: calc(100dvh - 52px);
    gap: 24px;
  }

  .history-dialog .auth-close-btn {
    width: 46px;
    height: 46px;
  }

  .history-header {
    padding-top: 78px;
  }

  .history-header h2 {
    max-width: 9ch;
    font-size: clamp(3.1rem, 2.45rem + 3vw, 4.15rem);
  }

  .history-modal.history-detail-open .history-header h2 {
    display: -webkit-box;
    max-width: 100%;
    overflow: hidden;
    font-size: clamp(2.05rem, 1.78rem + 1.35vw, 2.42rem);
    line-height: 1.12;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 3;
  }

  .history-header-actions .compact-btn {
    min-height: 42px;
    padding: 0 14px;
  }

  .history-summary-chip {
    min-width: min(250px, 72vw);
    min-height: 70px;
    border-radius: 22px;
  }

  .history-item {
    min-height: 104px;
    padding: 20px 18px 20px 20px;
    border-radius: 24px;
  }

  .history-item-title {
    font-size: clamp(1.32rem, 1.08rem + 1.15vw, 1.7rem);
  }

  .history-item-play {
    width: 58px;
    height: 58px;
  }

  .history-detail-tabs button {
    min-height: 54px;
    font-size: clamp(1.28rem, 1.05rem + 1vw, 1.66rem);
  }

  .history-timeline-row {
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 10px 14px;
  }

  .history-modal.history-detail-open .history-timeline {
    max-height: max(220px, calc(100dvh - 594px));
    overflow-y: auto;
    padding-right: 4px;
    scrollbar-width: none;
  }

  .history-modal.history-detail-open .history-timeline::-webkit-scrollbar {
    display: none;
  }

  .history-source {
    font-size: clamp(1.58rem, 1.16rem + 1.8vw, 2.08rem);
  }

  .history-time {
    padding-top: 8px;
    font-size: clamp(1.08rem, 0.94rem + 0.65vw, 1.34rem);
  }

  .history-player-card {
    bottom: 12px;
    padding: 12px;
  }
}

@media (max-width: 420px) {
  .history-header-actions {
    gap: 8px;
  }

  .history-status {
    max-width: 142px;
  }

  .history-summary-chip {
    min-width: 220px;
  }

  .history-item {
    grid-template-columns: minmax(0, 1fr) 52px;
  }

  .history-item-play {
    width: 52px;
    height: 52px;
  }
}
