/* Page Title */
h1 {
  font-size: 1.1rem;
  margin-bottom: 1rem;
  color: var(--text-main);
}

/* Tabs Container - Segmented Control Style */
.tabs {
  display: flex;
  background: var(--bg-card);
  padding: 4px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  margin-bottom: 1.5rem;
  gap: 4px;
  width: fit-content;
}

.tabs button {
  background: transparent;
  border: none;
  padding: 0.5rem 1.25rem;
  border-radius: 6px;
  color: var(--text-muted);
  font-weight: 500;
}

.tabs button:hover {
  color: var(--text-main);
  background: rgba(0, 0, 0, 0.05);
}

.tabs button.active {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

/* Panels */
.panel {
  display: none;
  animation: fadeIn 0.3s ease;
}
.panel.active {
  display: block;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(5px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Input Area */
#rawText,
#processedText {
  width: 100%;
  background: var(--bg-input);
  color: var(--text-main);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  resize: vertical;
  box-sizing: border-box;
  font-family: var(--font-ui);
  line-height: 1.6;
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.05);
}

#rawText:focus {
  outline: 2px solid var(--primary);
  border-color: transparent;
}

/* Control Bar (Action Bar) */
.tts-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 1rem;
  margin-top: 1rem;
  padding: 1rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.tts-controls label {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
}

.tts-controls select {
  padding: 0.6rem 2rem 0.6rem 0.75rem;
  background-color: var(--bg-input);
  color: var(--text-main);
  border: 1px solid var(--border);
  border-radius: 6px;
  min-width: 140px;
  cursor: pointer;
  /* Custom arrow styling can be tricky, basic is fine for now */
}

#generate {
  margin-left: auto; /* Pushes button to the right */
  background-color: var(--primary);
  color: white;
  border: none;
  padding: 0.6rem 1.5rem;
  border-radius: 6px;
  font-weight: 600;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

#generate:hover {
  background-color: var(--primary-hover);
  transform: translateY(-1px);
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.15);
}

#generate:disabled {
  opacity: 0.7;
  cursor: wait;
  transform: none;
}

/* Spinner */
#spinner {
  display: none;
  font-size: 0.9rem;
  color: var(--text-muted);
  align-self: center;
}

/* READ ALONG CONTAINER */
#read {
  background: var(--bg-card);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  overflow: hidden; /* Contains the header/footer */
}

#read h2 {
  margin: 0;
  padding: 1rem;
  font-size: 1.1rem;
  border-bottom: 1px solid var(--border);
  background: var(--bg-body);
  color: var(--text-muted);
  font-weight: 600;
}

#readAlongContainer {
  height: 50vh;
  overflow-y: auto;
  padding: 2rem;
  font-family: var(--font-read);
  font-size: 1rem;
  line-height: 1.8;
  color: var(--text-main);
  scroll-behavior: smooth;
}

/* Read Along Words */
.rl-token {
  cursor: pointer;
  padding: 2px 0;
  border-radius: 3px;
  transition: background-color 0.15s, color 0.15s;
}

.rl-token:hover {
  background-color: rgba(0, 0, 0, 0.05);
  color: var(--primary);
}

/* The Active Highlight */
.rl-token.highlight {
  background-color: var(--accent);
  color: var(--text-main);
  box-shadow: 0 0 0 0px var(--accent); /* slight spread */
}

/* Toolbar below Read Along */
.ra-toolbar {
  border-top: 1px solid var(--border);
  padding: 1rem;
  background: var(--bg-body);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 1.5rem;
}

.ra-toolbar label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text-main);
}

.ra-toolbar select {
  padding: 0.3rem 0.5rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--bg-card);
  color: var(--text-main);
}

.muted {
  margin-left: auto;
  font-size: 0.85rem;
  color: var(--text-muted);
  font-style: italic;
}

/* Audio Player styling */
#player {
  width: 100%;
  margin-top: 0.5rem;
  border-radius: 8px;
  outline: none;
}
/* Enhance webkit audio player if possible */
audio::-webkit-media-controls-panel {
  background-color: var(--bg-body);
}
