:root {
  --bg-base: hsl(220, 18%, 6%);
  --bg-surface: hsl(220, 16%, 10%);
  --bg-elevated: hsl(220, 15%, 13%);
  --bg-control: hsl(220, 14%, 17%);
  --bg-control-hover: hsl(220, 14%, 21%);

  --border-subtle: hsla(220, 15%, 100%, 0.08);
  --border-strong: hsla(220, 15%, 100%, 0.15);

  --text-primary: hsl(210, 20%, 96%);
  --text-secondary: hsl(215, 14%, 68%);
  --text-muted: hsl(215, 12%, 48%);

  --brand-red: hsl(9, 97%, 55%);
  --brand-red-hover: hsl(9, 97%, 60%);
  --brand-red-soft: hsla(9, 97%, 55%, 0.14);

  --accent-amber: hsl(38, 95%, 56%);
  --accent-amber-soft: hsla(38, 95%, 56%, 0.14);

  --status-green: hsl(152, 76%, 45%);
  --status-green-soft: hsla(152, 76%, 45%, 0.15);

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;

  --font-sans: "Manrope", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;

  --shadow-card: 0 12px 32px -8px rgba(0, 0, 0, 0.55), 0 1px 0 0 rgba(255, 255, 255, 0.05) inset;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  background-color: var(--bg-base);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.5;
  min-height: 100vh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

/* Layout Container */
.app-shell {
  max-width: 1120px;
  margin: 0 auto;
  padding: 16px 16px 64px;
}

/* Header */
.top-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 16px;
  margin-bottom: 20px;
  border-bottom: 1px solid var(--border-subtle);
  flex-wrap: wrap;
}

.brand-group {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-mark {
  width: 40px;
  height: 40px;
  border-radius: 11px;
  background: var(--brand-red);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 19px;
  letter-spacing: -0.03em;
  box-shadow: 0 4px 16px hsla(9, 97%, 55%, 0.35);
  flex-shrink: 0;
}

.brand-titles h1 {
  font-size: 1.15rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1.2;
  color: var(--text-primary);
}

.brand-subtitle {
  font-size: 0.8rem;
  color: var(--text-secondary);
  margin-top: 2px;
}

.pc-mode-badge {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 6px 12px;
  border-radius: 999px;
  background: var(--status-green-soft);
  color: var(--status-green);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.01em;
}

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
}

/* URL Search & Input Card */
.url-panel {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 16px;
  box-shadow: var(--shadow-card);
  margin-bottom: 18px;
}

.url-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.input-row {
  display: flex;
  gap: 8px;
  width: 100%;
}

.input-wrapper {
  position: relative;
  flex: 1;
  display: flex;
  align-items: center;
}

.url-input {
  width: 100%;
  height: 48px;
  background: var(--bg-base);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  padding: 0 96px 0 14px;
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 0.95rem;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.url-input:focus {
  outline: none;
  border-color: var(--brand-red);
  box-shadow: 0 0 0 3px var(--brand-red-soft);
}

.url-input::placeholder {
  color: var(--text-muted);
}

.paste-btn {
  position: absolute;
  right: 6px;
  height: 36px;
  padding: 0 11px;
  background: var(--bg-control);
  color: var(--text-secondary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  transition: background 0.15s ease, color 0.15s ease;
}

.paste-btn:hover {
  background: var(--bg-control-hover);
  color: var(--text-primary);
}

.translate-submit-btn {
  height: 48px;
  padding: 0 22px;
  background: var(--brand-red);
  color: #fff;
  border: none;
  border-radius: var(--radius-md);
  font-family: var(--font-sans);
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  white-space: nowrap;
  transition: background 0.15s ease, transform 0.1s ease;
  box-shadow: 0 4px 14px hsla(9, 97%, 55%, 0.3);
}

.translate-submit-btn:hover {
  background: var(--brand-red-hover);
}

.translate-submit-btn:active {
  transform: translateY(1px);
}

.translate-submit-btn:disabled {
  opacity: 0.6;
  cursor: wait;
}

/* Language & Quick Options Row */
.options-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding-top: 4px;
}

.lang-selectors {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.lang-label {
  font-size: 0.78rem;
  color: var(--text-secondary);
  font-weight: 600;
}

.lang-select {
  height: 34px;
  padding: 0 10px;
  background: var(--bg-elevated);
  color: var(--text-primary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  font-family: var(--font-sans);
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
}

.lang-arrow {
  color: var(--text-muted);
  font-size: 0.85rem;
}

/* Demo Chips */
.demo-strip {
  display: flex;
  align-items: center;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 2px;
  scrollbar-width: none;
}

.demo-strip::-webkit-scrollbar {
  display: none;
}

.demo-strip-label {
  font-size: 0.76rem;
  color: var(--text-muted);
  font-weight: 600;
  white-space: nowrap;
}

.demo-chip {
  height: 30px;
  padding: 0 11px;
  background: var(--bg-elevated);
  color: var(--text-secondary);
  border: 1px solid var(--border-subtle);
  border-radius: 999px;
  font-size: 0.76rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all 0.15s ease;
}

.demo-chip:hover {
  background: var(--bg-control-hover);
  color: var(--text-primary);
  border-color: var(--border-strong);
}

.demo-chip.active {
  background: var(--brand-red-soft);
  color: var(--brand-red);
  border-color: hsla(9, 97%, 55%, 0.4);
}

/* Status Banner / Waiting Countdown */
.status-banner {
  display: none;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  border-radius: var(--radius-md);
  margin-bottom: 16px;
  font-size: 0.88rem;
  font-weight: 600;
}

.status-banner.visible {
  display: flex;
}

.status-banner.loading {
  background: var(--accent-amber-soft);
  border: 1px solid hsla(38, 95%, 56%, 0.35);
  color: var(--accent-amber);
}

.status-banner.error {
  background: hsla(0, 85%, 55%, 0.14);
  border: 1px solid hsla(0, 85%, 55%, 0.35);
  color: hsl(0, 90%, 70%);
}

.status-banner.ready {
  background: var(--status-green-soft);
  border: 1px solid hsla(152, 76%, 45%, 0.35);
  color: var(--status-green);
}

.spinner {
  width: 16px;
  height: 16px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: spin 0.75s linear infinite;
  flex-shrink: 0;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* Main Workspace Grid */
.workspace-grid {
  display: grid;
  grid-template-columns: 1fr 380px;
  gap: 18px;
  align-items: start;
}

/* Left Column: Video + Transport + Mixer */
.player-column {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.video-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-card);
}

.video-stage {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  background: #000;
}

#youtube-player {
  width: 100%;
  height: 100%;
  border: 0;
  display: block;
}

/* Mobile Tap-to-Start Overlay for guaranteed Audio + Video Sync */
.sync-start-overlay {
  position: absolute;
  inset: 0;
  background: rgba(8, 10, 15, 0.78);
  backdrop-filter: blur(6px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 20px;
  text-align: center;
  z-index: 10;
  transition: opacity 0.2s ease;
}

.sync-start-overlay.hidden {
  display: none;
}

.big-start-btn {
  padding: 14px 26px;
  border-radius: 999px;
  background: var(--brand-red);
  color: #fff;
  border: none;
  font-family: var(--font-sans);
  font-size: 1rem;
  font-weight: 800;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  box-shadow: 0 8px 28px hsla(9, 97%, 55%, 0.45);
  transition: transform 0.15s ease, background 0.15s ease;
}

.big-start-btn:hover {
  background: var(--brand-red-hover);
  transform: scale(1.03);
}

.overlay-hint {
  font-size: 0.82rem;
  color: var(--text-secondary);
  max-width: 360px;
}

/* Live Subtitle Bar under Video */
.live-subtitle-bar {
  min-height: 62px;
  padding: 12px 16px;
  background: hsl(220, 20%, 8%);
  border-top: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 3px;
}

.live-sub-ru {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.35;
}

.live-sub-orig {
  font-size: 0.8rem;
  color: var(--text-secondary);
  line-height: 1.3;
}

/* Custom Unified Transport Controls */
.transport-bar {
  padding: 12px 16px;
  background: var(--bg-surface);
  border-top: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.timeline-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.time-readout {
  font-family: var(--font-mono);
  font-size: 0.76rem;
  color: var(--text-secondary);
  min-width: 42px;
}

.seek-slider {
  flex: 1;
  height: 6px;
  accent-color: var(--brand-red);
  cursor: pointer;
}

.transport-buttons-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
}

.transport-left, .transport-right {
  display: flex;
  align-items: center;
  gap: 6px;
}

.ctrl-btn {
  height: 36px;
  padding: 0 12px;
  background: var(--bg-elevated);
  color: var(--text-primary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  font-family: var(--font-sans);
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: background 0.15s ease;
}

.ctrl-btn:hover {
  background: var(--bg-control-hover);
}

.ctrl-btn.primary-play {
  background: var(--brand-red);
  border-color: transparent;
  color: #fff;
  padding: 0 16px;
}

.ctrl-btn.primary-play:hover {
  background: var(--brand-red-hover);
}

/* Studio Audio Mixer Card (PC Translation Experience) */
.mixer-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 18px;
  box-shadow: var(--shadow-card);
  display: flex;
  flex-direction: column;
  gap: 16px;
}

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

.mixer-title-group h2 {
  font-size: 1rem;
  font-weight: 800;
  letter-spacing: -0.01em;
}

.mixer-title-group p {
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.voice-meter-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 5px 11px;
  background: var(--bg-base);
  border: 1px solid var(--border-subtle);
  border-radius: 999px;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--text-secondary);
}

.meter-bars {
  display: inline-flex;
  align-items: flex-end;
  gap: 2px;
  height: 12px;
}

.meter-bar {
  width: 3px;
  height: 3px;
  background: var(--status-green);
  border-radius: 2px;
  transition: height 0.08s ease;
}

/* 3 Audio Mode Tabs */
.mode-selector-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.mode-card-btn {
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 12px;
  text-align: left;
  color: var(--text-primary);
  cursor: pointer;
  transition: all 0.15s ease;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.mode-card-btn:hover {
  background: var(--bg-control);
}

.mode-card-btn.active {
  background: var(--brand-red-soft);
  border-color: var(--brand-red);
}

.mode-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}

.mode-name {
  font-size: 0.85rem;
  font-weight: 800;
}

.mode-tag {
  font-size: 0.68rem;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 4px;
  background: hsla(255, 100%, 100%, 0.08);
  color: var(--text-secondary);
}

.mode-card-btn.active .mode-tag {
  background: var(--brand-red);
  color: #fff;
}

.mode-desc {
  font-size: 0.74rem;
  color: var(--text-secondary);
  line-height: 1.3;
}

/* Volume Sliders */
.sliders-container {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 14px;
  background: var(--bg-base);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
}

.channel-row {
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.channel-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.channel-label {
  font-size: 0.84rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px;
}

.channel-badge {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 6px;
  background: var(--bg-elevated);
  color: var(--text-primary);
}

.channel-badge.muted-badge {
  background: var(--status-green-soft);
  color: var(--status-green);
}

.slider-track-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.vol-slider {
  flex: 1;
  height: 6px;
  accent-color: var(--brand-red);
  cursor: pointer;
}

.quick-vol-pills {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.vol-pill {
  padding: 4px 9px;
  border-radius: 6px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  font-family: var(--font-mono);
  font-size: 0.73rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
}

.vol-pill:hover {
  color: var(--text-primary);
  background: var(--bg-control);
}

.vol-pill.active {
  background: var(--brand-red);
  color: #fff;
  border-color: var(--brand-red);
}

/* Sync Offset & Download Footer */
.mixer-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding-top: 4px;
}

.sync-offset-group {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.78rem;
  color: var(--text-secondary);
}

.offset-readout {
  font-family: var(--font-mono);
  color: var(--text-primary);
  font-weight: 700;
  min-width: 48px;
  text-align: center;
}

.download-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.action-link-btn {
  height: 34px;
  padding: 0 12px;
  border-radius: var(--radius-sm);
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  color: var(--text-primary);
  font-size: 0.78rem;
  font-weight: 700;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  transition: background 0.15s ease;
}

.action-link-btn:hover {
  background: var(--bg-control-hover);
}

/* Right Column: Subtitles & Mobile Browser Helper */
.side-column {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.transcript-card, .bookmarklet-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 16px;
  box-shadow: var(--shadow-card);
}

.transcript-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border-subtle);
  margin-bottom: 10px;
}

.transcript-header h3 {
  font-size: 0.92rem;
  font-weight: 800;
}

.sub-mode-toggle {
  display: flex;
  background: var(--bg-base);
  padding: 2px;
  border-radius: 7px;
  border: 1px solid var(--border-subtle);
}

.sub-tab-btn {
  padding: 4px 8px;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-size: 0.72rem;
  font-weight: 700;
  border-radius: 5px;
  cursor: pointer;
}

.sub-tab-btn.active {
  background: var(--bg-control);
  color: var(--text-primary);
}

.transcript-list {
  max-height: 410px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding-right: 4px;
}

.cue-item {
  padding: 9px 11px;
  border-radius: var(--radius-sm);
  background: var(--bg-base);
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.15s ease;
  display: flex;
  gap: 10px;
  align-items: flex-start;
}

.cue-item:hover {
  border-color: var(--border-strong);
  background: var(--bg-elevated);
}

.cue-item.active {
  background: var(--brand-red-soft);
  border-color: hsla(9, 97%, 55%, 0.45);
}

.cue-time {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--brand-red);
  font-weight: 600;
  padding-top: 2px;
  flex-shrink: 0;
}

.cue-texts {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.cue-ru {
  font-size: 0.84rem;
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1.35;
}

.cue-orig {
  font-size: 0.75rem;
  color: var(--text-secondary);
  line-height: 1.3;
}

.empty-transcript {
  padding: 28px 12px;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.84rem;
}

/* Bookmarklet Card for native Mobile Yandex Browser */
.bookmarklet-card h3 {
  font-size: 0.9rem;
  font-weight: 800;
  margin-bottom: 6px;
}

.bookmarklet-card p {
  font-size: 0.78rem;
  color: var(--text-secondary);
  margin-bottom: 10px;
  line-height: 1.4;
}

.code-copy-box {
  display: flex;
  gap: 8px;
  align-items: center;
}

.code-snippet {
  flex: 1;
  background: var(--bg-base);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--accent-amber);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Responsive Breakpoints */
@media (max-width: 920px) {
  .workspace-grid {
    grid-template-columns: 1fr;
  }

  .mode-selector-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 600px) {
  .app-shell {
    padding: 12px 10px 48px;
  }

  .input-row {
    flex-direction: column;
  }

  .translate-submit-btn {
    width: 100%;
  }

  .top-header {
    padding-bottom: 12px;
    margin-bottom: 14px;
  }
}
