/* IjwiLab TTS Studio — ElevenLabs-inspired generation dashboard */
.tts-studio {
  --studio-border: #2a2d36;
  --studio-panel: #12141a;
  --studio-elevated: #181b22;
  --studio-muted: #8b92a5;
  --studio-text: #eceef4;
  --studio-accent: #a78bfa;
  --studio-accent-soft: rgba(167, 139, 250, 0.14);
  --studio-radius: 14px;
  --studio-radius-sm: 10px;
  background: var(--studio-panel);
  border: 1px solid var(--studio-border);
  border-radius: var(--studio-radius);
  overflow: hidden;
  box-shadow: 0 8px 40px rgba(0, 0, 0, 0.45);
  margin-top: 1rem;
}

.tts-wallet-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.65rem;
  padding: 0.55rem 1.35rem;
  border-bottom: 1px solid var(--studio-border);
  background: #0f1116;
  font-size: 0.8125rem;
  color: var(--studio-muted);
}

.tts-wallet-bar strong { color: var(--studio-text); }

.tts-wallet-bar .wallet-free {
  color: #5eead4;
}

.tts-wallet-bar a.wallet-topup {
  color: #c4b5fd;
  font-weight: 600;
  text-decoration: none;
  padding: 0.25rem 0.65rem;
  border-radius: 999px;
  border: 1px solid rgba(167, 139, 250, 0.45);
  background: var(--studio-accent-soft);
}

.tts-wallet-bar a.wallet-topup:hover {
  filter: brightness(1.08);
}

.tts-studio-header {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  padding: 1.25rem 1.35rem 1rem;
  border-bottom: 1px solid var(--studio-border);
  background: linear-gradient(180deg, rgba(167, 139, 250, 0.06) 0%, transparent 100%);
}

.tts-studio-title {
  font-family: 'Sora', sans-serif;
  font-size: 1.125rem;
  font-weight: 600;
  color: var(--studio-text);
  margin: 0 0 0.25rem;
  letter-spacing: -0.02em;
}

.tts-studio-sub {
  font-size: 0.8125rem;
  color: var(--studio-muted);
  margin: 0;
  max-width: 36rem;
  line-height: 1.45;
}

.tts-lang-pills {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  padding: 0.25rem;
  background: #0c0d11;
  border: 1px solid var(--studio-border);
  border-radius: 999px;
}

.tts-lang-pills .tts-mode-tab {
  flex: 0 1 auto;
  border-radius: 999px;
  padding: 0.4rem 0.85rem;
  font-size: 0.8125rem;
  font-weight: 600;
  min-width: 0;
}

.tts-lang-pills .tts-mode-tab:has(input:checked) {
  background: var(--studio-accent-soft);
  color: #c4b5fd;
  box-shadow: inset 0 0 0 1px rgba(167, 139, 250, 0.45);
}

.tts-studio-grid {
  display: grid;
  grid-template-columns: 1fr;
  min-height: 0;
}

@media (min-width: 900px) {
  .tts-studio-grid {
    grid-template-columns: minmax(0, 1fr) minmax(280px, 340px);
  }
}

.tts-studio-main {
  padding: 1.1rem 1.35rem 1.35rem;
  border-bottom: 1px solid var(--studio-border);
  min-width: 0;
}

@media (min-width: 900px) {
  .tts-studio-main {
    border-bottom: none;
    border-right: 1px solid var(--studio-border);
  }
}

.tts-mode-bar {
  margin-bottom: 0.85rem;
}

.tts-mode-bar .tts-mode-switch {
  background: #0c0d11;
  border-color: var(--studio-border);
}

.tts-studio-editor-wrap {
  position: relative;
  margin-bottom: 0.75rem;
}

.tts-studio-editor-wrap label {
  display: block;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--studio-muted);
  margin-bottom: 0.45rem;
}

.tts-studio-editor {
  width: 100%;
  min-height: clamp(140px, 28vw, 220px);
  padding: 1rem 1.1rem;
  background: #0c0d11;
  border: 1px solid var(--studio-border);
  border-radius: var(--studio-radius-sm);
  color: var(--studio-text);
  font-family: inherit;
  font-size: 1rem;
  line-height: 1.55;
  resize: vertical;
  margin-bottom: 0;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.tts-studio-editor:focus {
  outline: none;
  border-color: rgba(167, 139, 250, 0.55);
  box-shadow: 0 0 0 3px var(--studio-accent-soft);
}

.tts-studio-footer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding-top: 0.5rem;
}

.tts-selected-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.35rem 0.65rem 0.35rem 0.4rem;
  background: var(--studio-elevated);
  border: 1px solid var(--studio-border);
  border-radius: 999px;
  font-size: 0.8125rem;
  color: var(--studio-text);
  min-width: 0;
}

.tts-selected-chip .voice-avatar {
  width: 28px;
  height: 28px;
  font-size: 0.7rem;
}

.tts-selected-chip strong {
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tts-selected-chip span.voice-accent-lbl {
  color: var(--studio-muted);
  font-size: 0.6875rem;
  display: none;
}

@media (min-width: 480px) {
  .tts-selected-chip span.voice-accent-lbl { display: inline; }
}

.tts-char-count {
  font-size: 0.75rem;
  color: var(--studio-muted);
  font-variant-numeric: tabular-nums;
}

.tts-studio-actions {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  margin-left: auto;
}

.tts-studio .btn-generate {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  min-height: 44px;
  padding: 0 1.35rem;
  background: linear-gradient(135deg, #8b5cf6, #a78bfa);
  color: #0c0a12;
  border: none;
  border-radius: 999px;
  font-family: inherit;
  font-size: 0.9375rem;
  font-weight: 700;
  cursor: pointer;
  transition: filter 0.2s, transform 0.05s, box-shadow 0.2s;
  white-space: nowrap;
}

.tts-studio .btn-generate:hover {
  filter: brightness(1.06);
  box-shadow: 0 0 24px rgba(167, 139, 250, 0.35);
}

.tts-studio .btn-generate:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  box-shadow: none;
}

.tts-studio .btn-generate.loading {
  pointer-events: none;
  animation: studio-btn-pulse 1.5s ease-in-out infinite;
}

@keyframes studio-btn-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(167, 139, 250, 0.2); }
  50% { box-shadow: 0 0 0 8px rgba(167, 139, 250, 0); }
}

/* Voice library panel */
.tts-voice-panel {
  display: flex;
  flex-direction: column;
  min-height: 280px;
  max-height: none;
  background: #0f1116;
}

@media (min-width: 900px) {
  .tts-voice-panel {
    max-height: 720px;
  }
}

.voice-panel-head {
  padding: 1rem 1.1rem 0.65rem;
  border-bottom: 1px solid var(--studio-border);
  flex-shrink: 0;
}

.voice-panel-head h3 {
  font-family: 'Sora', sans-serif;
  font-size: 0.8125rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--studio-muted);
  margin: 0 0 0.35rem;
}

.voice-panel-head p {
  font-size: 0.75rem;
  color: var(--studio-muted);
  margin: 0;
  opacity: 0.85;
}

.voice-library {
  flex: 1;
  overflow-y: auto;
  padding: 0.65rem 0.75rem 1rem;
  scrollbar-width: thin;
  scrollbar-color: #3f4450 transparent;
}

.voice-group {
  margin-bottom: 1.1rem;
}

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

.voice-group-label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.6875rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--studio-muted);
  margin: 0 0 0.5rem 0.35rem;
}

.voice-group-label::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--studio-border);
}

.voice-group-cards {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.voice-tile {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  width: 100%;
  padding: 0.55rem 0.65rem;
  background: var(--studio-elevated);
  border: 1px solid transparent;
  border-radius: var(--studio-radius-sm);
  color: var(--studio-text);
  font-family: inherit;
  text-align: left;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s, box-shadow 0.15s;
  -webkit-tap-highlight-color: transparent;
}

.voice-tile:hover {
  border-color: var(--studio-border);
  background: #1e2129;
}

.voice-tile.selected {
  border-color: rgba(167, 139, 250, 0.55);
  background: var(--studio-accent-soft);
  box-shadow: inset 0 0 0 1px rgba(167, 139, 250, 0.25);
}

.voice-avatar {
  flex-shrink: 0;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.875rem;
  font-weight: 700;
  color: #fff;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.25);
}

.voice-tile-body {
  flex: 1;
  min-width: 0;
}

.voice-tile-name {
  display: block;
  font-size: 0.875rem;
  font-weight: 600;
  line-height: 1.25;
  color: var(--studio-text);
}

.voice-tile-meta {
  display: block;
  font-size: 0.6875rem;
  color: var(--studio-muted);
  margin-top: 0.1rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.voice-tile-check {
  flex-shrink: 0;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2px solid var(--studio-border);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.15s, border-color 0.15s, background 0.15s;
}

.voice-tile.selected .voice-tile-check {
  opacity: 1;
  border-color: #a78bfa;
  background: #a78bfa;
}

.voice-tile.selected .voice-tile-check svg {
  display: block;
}

.voice-tile-check svg {
  display: none;
  width: 10px;
  height: 10px;
  stroke: #0c0a12;
  stroke-width: 3;
}

.tts-studio-output {
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--studio-border);
}

.tts-studio-output label {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--studio-muted);
}

.tts-studio[data-tts-mode="standard"] #tts-clone-panel { display: none; }
.tts-studio[data-tts-mode="clone"] #tts-standard-voice-hint { display: none; }
.tts-studio[data-tts-mode="clone"] .tts-voice-panel { opacity: 0.45; pointer-events: none; }

.try-intro.compact {
  margin-bottom: 0.25rem;
}

.try-intro.compact h2 {
  font-size: 1.25rem;
  margin-bottom: 0.35rem;
}

.wrap.studio-wrap {
  max-width: 1180px;
}

#try .try-engine-note,
#try .try-lab-link {
  font-size: 0.8125rem;
}
