/* 58 / 42 Interactive Mandarin Shadowing Studio */

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

.studio-topbar {
  padding: 12px 18px;
  border-bottom: 1px solid var(--border-subtle);
  background: var(--bg-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.studio-title-group {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.studio-title-group h2 {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.studio-toggle-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.toggle-pill {
  height: 30px;
  padding: 0 10px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--border-subtle);
  background: var(--bg-surface);
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.toggle-pill.is-on {
  background: var(--cta-dark);
  border-color: var(--cta-dark);
  color: var(--cta-dark-text);
}

.studio-split {
  display: grid;
  grid-template-columns: 58% minmax(0, 1fr);
  min-height: 490px;
}

.studio-page-shell .studio-split {
  min-height: calc(100dvh - 185px);
}

.studio-left {
  padding: 18px 20px;
  border-right: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  gap: 14px;
}

/* Stage Viewport */
.player-stage {
  position: relative;
  aspect-ratio: 16 / 9;
  border-radius: var(--radius-lg);
  overflow: hidden;
  background: #0f172a;
  box-shadow: var(--shadow-sm);
}

.player-stage video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.scene-canvas-backdrop {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.scene-canvas-backdrop > svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.stage-top-meta {
  position: relative;
  z-index: 2;
  padding: 12px 14px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

.stage-pill {
  padding: 4px 10px;
  border-radius: var(--radius-pill);
  background: rgba(15, 23, 42, 0.72);
  backdrop-filter: blur(8px);
  color: #ffffff;
  font-size: 11.5px;
  font-weight: 600;
}

.stage-speaking-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: var(--radius-pill);
  background: rgba(229, 72, 77, 0.9);
  color: #ffffff;
  font-size: 11.5px;
  font-weight: 700;
}

.stage-caption-overlay {
  position: relative;
  z-index: 2;
  margin: auto 18px 18px;
  padding: 12px 16px;
  border-radius: var(--radius-md);
  background: rgba(15, 23, 42, 0.78);
  backdrop-filter: blur(10px);
  color: #ffffff;
  text-align: center;
}

.stage-caption-overlay .cn-line {
  font-family: var(--font-cn);
  font-size: 20px;
  font-weight: 600;
  line-height: 1.9;
}

.stage-caption-overlay .en-line {
  font-size: 13px;
  color: #cbd5e1;
  margin-top: 2px;
}

/* Playback Controls Bar */
.player-controls-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  padding: 10px 14px;
  border-radius: var(--radius-md);
  background: var(--bg-subtle);
  border: 1px solid var(--border-subtle);
}

.ctrl-btn {
  height: 34px;
  padding: 0 11px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
  background: var(--bg-surface);
  color: var(--text-primary);
  font-size: 13px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.ctrl-btn:hover:not(:disabled) {
  border-color: var(--border-strong);
  background: var(--bg-surface-2);
}

.ctrl-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.ctrl-btn.is-active {
  background: var(--brand-primary-soft);
  border-color: var(--brand-primary-border);
  color: var(--brand-primary);
}

.ctrl-play-btn {
  background: var(--cta-dark);
  border-color: var(--cta-dark);
  color: var(--cta-dark-text);
  min-width: 96px;
  justify-content: center;
}

.ctrl-play-btn:hover {
  background: var(--cta-dark-hover) !important;
}

.progress-track {
  flex: 1;
  min-width: 110px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.progress-rail {
  flex: 1;
  height: 6px;
  border-radius: var(--radius-pill);
  background: var(--border-subtle);
  overflow: hidden;
  cursor: pointer;
}

.progress-fill {
  height: 100%;
  background: var(--brand-primary);
  border-radius: var(--radius-pill);
  transition: width 0.2s linear;
}

.time-code {
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: var(--text-muted);
}

/* Shadowing Recorder Bar (Style C signature) */
.shadow-recorder-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
  background: var(--bg-surface);
  flex-wrap: wrap;
}

.waveform-canvas {
  flex: 1;
  min-width: 120px;
  height: 36px;
  border-radius: var(--radius-sm);
  background: var(--bg-subtle);
}

.record-cta {
  height: 38px;
  padding: 0 16px;
  border-radius: var(--radius-md);
  border: 0;
  background: var(--brand-primary);
  color: #ffffff;
  font-size: 13.5px;
  font-weight: 650;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  box-shadow: 0 4px 12px rgba(229, 72, 77, 0.25);
}

.record-cta.recording {
  background: #dc2626;
  animation: pulse-rec 1.1s infinite;
}

@keyframes pulse-rec {
  0%, 100% { box-shadow: 0 0 0 0 rgba(220, 38, 38, 0.45); }
  50% { box-shadow: 0 0 0 8px rgba(220, 38, 38, 0); }
}

.recorder-status {
  font-size: 12px;
  color: var(--text-muted);
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

/* Right 42% Panel */
.studio-right {
  position: relative;
  display: flex;
  flex-direction: column;
  min-width: 0;
  background: var(--bg-surface);
}

.tone-legend-bar {
  padding: 11px 18px;
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  font-size: 12px;
  font-weight: 600;
}

.tone-legend-items {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.tone-legend-items span {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.tone-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

.tone-dot.t1 { background: var(--tone-1); }
.tone-dot.t2 { background: var(--tone-2); }
.tone-dot.t3 { background: var(--tone-3); }
.tone-dot.t4 { background: var(--tone-4); }

.studio-tabs {
  padding: 0 18px;
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  gap: 16px;
}

.studio-tabs button {
  padding: 11px 2px;
  border: 0;
  border-bottom: 2px solid transparent;
  background: transparent;
  color: var(--text-muted);
  font-size: 13.5px;
  font-weight: 600;
}

.studio-tabs button.active {
  color: var(--brand-primary);
  border-bottom-color: var(--brand-primary);
}

.studio-scroll {
  flex: 1;
  overflow-y: auto;
  max-height: 460px;
  padding: 12px 14px 20px;
}

.studio-page-shell .studio-scroll {
  max-height: calc(100dvh - 300px);
}

/* Subtitle Line Cards */
.subtitle-card {
  width: 100%;
  text-align: left;
  padding: 13px 14px;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  background: transparent;
  transition: background 0.15s, border-color 0.15s;
  margin-bottom: 6px;
}

.subtitle-card:hover {
  background: var(--bg-subtle);
}

.subtitle-card.is-current {
  background: var(--bg-subtle);
  border-color: var(--border-strong);
  box-shadow: var(--shadow-xs);
}

.subtitle-card-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
}

.subtitle-idx {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-faint);
}

.subtitle-actions-inline {
  display: flex;
  align-items: center;
  gap: 4px;
}

.mini-icon-btn {
  border: 1px solid var(--border-subtle);
  background: var(--bg-surface);
  color: var(--text-muted);
  border-radius: 6px;
  height: 24px;
  padding: 0 7px;
  font-size: 11.5px;
}

.mini-icon-btn:hover {
  color: var(--text-primary);
  border-color: var(--border-strong);
}

.mini-icon-btn.saved {
  color: var(--brand-primary);
  border-color: var(--brand-primary-border);
  background: var(--brand-primary-soft);
}

/* Chinese + Pinyin Ruby Tokens */
.cn-tokens {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 4px 7px;
  font-family: var(--font-cn);
  line-height: 1.4;
}

.size-s .cn-tokens { font-size: 17px; }
.size-m .cn-tokens { font-size: 21px; }
.size-l .cn-tokens { font-size: 26px; }

.word-token {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  padding: 2px 4px;
  border-radius: 6px;
  cursor: pointer;
  border: 1px solid transparent;
  transition: background 0.12s, border-color 0.12s;
}

.word-token:hover {
  background: var(--brand-primary-soft);
  border-color: var(--brand-primary-border);
}

.word-token.is-spoken {
  background: var(--brand-primary-soft);
  box-shadow: inset 0 -2px 0 var(--brand-primary);
}

.word-token.is-punct {
  cursor: default;
  padding: 2px 0;
}

.word-token.is-punct:hover {
  background: transparent;
  border-color: transparent;
}

.py-row {
  display: inline-flex;
  gap: 2px;
  font-family: var(--font-sans);
  font-size: 11.5px;
  font-weight: 600;
  line-height: 1.2;
  letter-spacing: 0.01em;
}

.size-l .py-row { font-size: 13px; }
.size-s .py-row { font-size: 10.5px; }

.hanzi-row {
  display: inline-flex;
  line-height: 1.25;
}

.use-tone-colors .t-1 { color: var(--tone-1); }
.use-tone-colors .t-2 { color: var(--tone-2); }
.use-tone-colors .t-3 { color: var(--tone-3); }
.use-tone-colors .t-4 { color: var(--tone-4); }
.use-tone-colors .t-5 { color: var(--tone-5); }

.stage-caption-overlay .use-tone-colors .t-1 { color: #fca5a5; }
.stage-caption-overlay .use-tone-colors .t-2 { color: #fcd34d; }
.stage-caption-overlay .use-tone-colors .t-3 { color: #5eead4; }
.stage-caption-overlay .use-tone-colors .t-4 { color: #93c5fd; }
.stage-caption-overlay .use-tone-colors .t-5 { color: #cbd5e1; }

.subtitle-en {
  margin-top: 6px;
  font-size: 13.5px;
  color: var(--text-secondary);
}

/* Tap Dictionary Floating Popover */
.dict-popover {
  position: absolute;
  right: 14px;
  bottom: 14px;
  z-index: 20;
  width: min(340px, calc(100% - 28px));
  padding: 16px;
  border-radius: var(--radius-lg);
  background: var(--bg-popover);
  border: 1px solid var(--border-strong);
  box-shadow: var(--shadow-lg);
}

.dict-popover[hidden] {
  display: none;
}

.dict-pop-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 8px;
}

.dict-pop-word {
  font-family: var(--font-cn);
  font-size: 24px;
  font-weight: 700;
  line-height: 1.2;
}

.dict-pop-py {
  font-size: 14px;
  font-weight: 600;
  margin-top: 2px;
}

.dict-pop-pos {
  display: inline-block;
  margin-top: 6px;
  padding: 2px 7px;
  border-radius: 6px;
  background: var(--bg-subtle);
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 700;
}

.dict-pop-gloss {
  margin: 8px 0 12px;
  font-size: 14px;
  color: var(--text-primary);
}

.dict-pop-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

/* Pro Preview Paywall Overlay */
.preview-gate-card {
  margin: 12px 0;
  padding: 22px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--brand-primary-border);
  background: var(--brand-primary-soft);
  text-align: center;
}

.preview-gate-card h3 {
  margin: 0 0 6px;
  font-size: 18px;
}

.preview-gate-card p {
  margin: 0 0 14px;
  font-size: 13.5px;
  color: var(--text-secondary);
}

/* Responsive Studio */
@media (max-width: 980px) {
  .studio-split {
    grid-template-columns: 1fr;
  }
  .studio-left {
    border-right: 0;
    border-bottom: 1px solid var(--border-subtle);
  }
  .studio-scroll {
    max-height: 420px;
  }
  .studio-page-shell .studio-scroll {
    max-height: none;
  }
}
