:root {
  --bg: #1a1a2e;
  --surface: #16213e;
  --accent: #0f3460;
  --text: #eaeaea;
  --muted: #a0a0a0;
  --success: #4ecca3;
  --error: #e94560;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

#app {
  max-width: 640px;
  margin: 0 auto;
  padding: 1rem;
  min-height: 100vh;
}

header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
}

header h1 {
  margin: 0;
  font-size: 1.5rem;
}

#user-info {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

#user-email {
  font-size: 0.9rem;
  color: var(--muted);
}

.hidden {
  display: none !important;
}

button, input[type="submit"] {
  background: var(--accent);
  color: var(--text);
  border: none;
  padding: 0.5rem 1rem;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.95rem;
}

button:hover, input[type="submit"]:hover {
  background: #1a4a7a;
}

input[type="email"], input[type="password"] {
  width: 100%;
  padding: 0.6rem;
  margin-bottom: 0.5rem;
  border: 1px solid var(--accent);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
}

#auth-section {
  background: var(--surface);
  padding: 1.5rem;
  border-radius: 10px;
}

#auth-section h2 {
  margin-top: 0;
  margin-bottom: 1rem;
}

.auth-links {
  margin-top: 1rem;
}

.auth-links a {
  color: var(--success);
  text-decoration: none;
}

.auth-links a:hover {
  text-decoration: underline;
}

.error {
  color: var(--error);
  margin-top: 0.5rem;
}

.upload-zone {
  border: 2px dashed var(--accent);
  border-radius: 10px;
  padding: 2rem;
  text-align: center;
  margin-bottom: 1.5rem;
  cursor: pointer;
  transition: background 0.2s;
}

.upload-zone:hover, .upload-zone.dragover {
  background: var(--surface);
}

#documents-list h3 {
  margin-bottom: 0.75rem;
}

#documents {
  list-style: none;
  padding: 0;
  margin: 0;
}

#documents li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem;
  background: var(--surface);
  margin-bottom: 0.5rem;
  border-radius: 8px;
}

#documents li:hover {
  background: var(--accent);
}

#documents .doc-name {
  cursor: pointer;
  flex: 1;
}

#documents .doc-actions button {
  padding: 0.25rem 0.5rem;
  font-size: 0.85rem;
  margin-left: 0.25rem;
}

#reader-panel {
  margin-top: 1.5rem;
  padding: 1rem;
  background: var(--surface);
  border-radius: 10px;
}

#reader-panel h3 {
  margin-top: 0;
}

.tts-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 1rem;
  margin: 1rem 0;
}

.tts-controls label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

#rate-slider {
  width: 80px;
}

#voice-select {
  padding: 0.4rem 0.6rem;
  background: var(--accent);
  color: var(--text);
  border: none;
  border-radius: 6px;
  min-width: 140px;
}

.voice-hint {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.2rem;
  height: 1.2rem;
  font-size: 0.75rem;
  font-weight: bold;
  color: var(--muted);
  background: var(--accent);
  border-radius: 50%;
  cursor: help;
}

.playback-buttons {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.playback-buttons button {
  padding: 0.5rem 0.75rem;
}

#progress-section {
  margin: 1rem 0;
}

.progress-header {
  display: flex;
  justify-content: space-between;
  font-size: 0.9rem;
  color: var(--muted);
  margin-bottom: 0.25rem;
}

#progress-slider {
  width: 100%;
  height: 6px;
  cursor: pointer;
  accent-color: var(--success);
}

.chapters-section {
  margin: 0.5rem 0;
}

#chapters-toggle {
  padding: 0.35rem 0.75rem;
  font-size: 0.9rem;
}

.chapters-nav {
  max-height: 180px;
  overflow-y: auto;
  margin-top: 0.5rem;
  background: var(--bg);
  border-radius: 6px;
  padding: 0.5rem;
}

.chapters-nav ul {
  list-style: none;
  padding: 0;
  margin: 0;
}

.chapters-nav li {
  padding: 0.4rem 0.6rem;
  cursor: pointer;
  border-radius: 4px;
  font-size: 0.9rem;
}

.chapters-nav li:hover {
  background: var(--accent);
}

.chapters-nav li.current-chapter {
  background: var(--success);
  color: var(--bg);
}

.prompter {
  max-height: 280px;
  overflow-y: auto;
  padding: 1rem;
  background: var(--bg);
  border-radius: 8px;
  margin: 1rem 0;
  line-height: 1.6;
  font-size: 1rem;
}

.prompter span.chunk {
  transition: background 0.2s, color 0.2s;
  padding: 2px 4px;
  border-radius: 2px;
  cursor: pointer;
}

.prompter span.chunk:hover {
  background: var(--accent);
}

.prompter span.chunk.active {
  background: var(--success);
  color: var(--bg);
}

.prompter span.chunk.past {
  color: var(--muted);
}

.hint {
  color: var(--muted);
  font-size: 0.9rem;
}

footer {
  margin-top: 2rem;
  text-align: center;
  font-size: 0.8rem;
  color: var(--muted);
}
