:root {
  --bg: #0a0a0b;
  --surface: #131316;
  --surface-elevated: #1a1a1f;
  --surface-hover: #222228;
  --border: #26262b;
  --border-light: #33333a;
  --text: #e4e4e7;
  --text-secondary: #a1a1aa;
  --text-tertiary: #52525b;
  --accent: #6366f1;
  --accent-hover: #4f46e5;
  --accent-soft: rgba(99, 102, 241, 0.15);
  --success: #10b981;
  --error: #ef4444;
  --radius: 10px;
  --radius-sm: 6px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: "SF Mono", "Fira Code", "Cascadia Code", Consolas, monospace;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

.container {
  max-width: 900px;
  margin: 0 auto;
  padding: 24px 20px 60px;
}

/* Header */
header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 32px;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

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

.logo h1 {
  font-size: 20px;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.history-count {
  font-size: 10px;
  background: var(--accent-soft);
  color: var(--accent);
  padding: 1px 6px;
  border-radius: 10px;
  font-weight: 600;
}

/* History */
.history-section {
  margin-bottom: 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.history-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
}

.history-header h3 {
  font-size: 14px;
  font-weight: 600;
}

.history-list {
  max-height: 400px;
  overflow-y: auto;
}

.history-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  transition: background 0.1s;
}

.history-item:last-child {
  border-bottom: none;
}

.history-item:hover {
  background: var(--surface-hover);
}

.history-item-info {
  flex: 1;
  cursor: pointer;
  min-width: 0;
}

.history-item-title {
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.history-item-meta {
  display: flex;
  gap: 10px;
  font-size: 11px;
  color: var(--text-tertiary);
  font-family: var(--mono);
  margin-top: 2px;
}

.history-engine {
  text-transform: capitalize;
  color: var(--accent);
}

.history-delete {
  flex-shrink: 0;
  padding: 4px !important;
  opacity: 0.5;
}

.history-delete:hover {
  opacity: 1;
  color: var(--error) !important;
}

.badge {
  font-size: 12px;
  color: var(--success);
  background: rgba(16, 185, 129, 0.12);
  padding: 4px 10px;
  border-radius: 20px;
  font-weight: 500;
}

/* Engine toggle */
.engine-toggle {
  display: flex;
  gap: 6px;
}

.engine-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  padding: 6px 12px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
  font-family: var(--font);
}

.engine-btn:hover:not(.disabled) {
  border-color: var(--border-light);
  color: var(--text);
}

.engine-btn.active {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent);
}

.engine-btn.disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.engine-status {
  font-size: 10px;
  opacity: 0.6;
  text-transform: uppercase;
}

/* Tabs */
.tabs {
  display: flex;
  gap: 2px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius) var(--radius) 0 0;
  padding: 4px;
  border-bottom: none;
}

.tabs button {
  flex: 1;
  background: none;
  border: none;
  color: var(--text-secondary);
  padding: 10px 16px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: all 0.15s;
  font-family: var(--font);
}

.tabs button:hover {
  color: var(--text);
  background: var(--surface-hover);
}

.tabs button.active {
  color: var(--text);
  background: var(--surface-elevated);
}

/* Tab content */
.tab-content {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 0 0 var(--radius) var(--radius);
  min-height: 280px;
  padding: 32px;
}

/* Drop zone */
.dropzone {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 216px;
  border: 2px dashed var(--border-light);
  border-radius: var(--radius);
  color: var(--text-tertiary);
  transition: all 0.2s;
  gap: 6px;
}

.dropzone.dragover {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
}

.dropzone:hover {
  border-color: var(--border-light);
  color: var(--text-secondary);
}

.dz-title {
  font-size: 15px;
  font-weight: 500;
  margin-top: 12px;
}

.dz-sub {
  font-size: 13px;
  color: var(--text-tertiary);
}

.dz-formats {
  font-size: 11px;
  color: var(--text-tertiary);
  margin-top: 12px;
  text-align: center;
  line-height: 1.5;
}

/* URL input */
.url-input form {
  display: flex;
  gap: 10px;
}

.input {
  flex: 1;
  background: var(--surface-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  color: var(--text);
  font-size: 14px;
  font-family: var(--font);
  outline: none;
  transition: border-color 0.15s;
}

.input:focus {
  border-color: var(--accent);
}

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

.hint {
  font-size: 12px;
  color: var(--text-tertiary);
  margin-top: 10px;
}

/* Paste zone */
.paste-zone {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 216px;
  color: var(--text-tertiary);
  text-align: center;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  background: var(--surface-elevated);
  border: 1px solid var(--border-light);
  color: var(--text);
  padding: 10px 18px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
  font-family: var(--font);
  text-decoration: none;
}

.btn:hover {
  background: var(--surface-hover);
  border-color: var(--accent);
}

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

.btn-sm {
  padding: 6px 12px;
  font-size: 12px;
}

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: white;
}

.btn-primary:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
}

.btn-outline {
  background: transparent;
}

.btn-ghost {
  background: transparent;
  border-color: transparent;
  color: var(--text-secondary);
}

.btn-ghost:hover {
  color: var(--text);
  background: var(--surface-hover);
  border-color: transparent;
}

/* Processing */
.processing-section {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 300px;
}

.progress-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  width: 100%;
  max-width: 500px;
}

.spinner {
  width: 36px;
  height: 36px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

.progress-bar-container {
  width: 100%;
  height: 8px;
  background: var(--surface-elevated);
  border-radius: 4px;
  overflow: hidden;
  border: 1px solid var(--border);
}

.progress-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--accent-hover));
  border-radius: 4px;
  transition: width 0.5s ease;
  min-width: 2px;
}

.proc-text {
  color: var(--text-secondary);
  font-size: 14px;
  text-align: center;
}

.proc-eta {
  color: var(--text-tertiary);
  font-size: 12px;
  font-family: var(--mono);
}

/* Error */
.error-section {
  margin-bottom: 20px;
}

.error-card {
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(239, 68, 68, 0.08);
  border: 1px solid rgba(239, 68, 68, 0.25);
  border-radius: var(--radius);
  padding: 14px 16px;
  color: var(--error);
  font-size: 13px;
}

.error-card .btn {
  margin-left: auto;
  flex-shrink: 0;
}

/* Result */
.result-section {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

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

.result-header h2 {
  font-size: 18px;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.result-meta {
  display: flex;
  gap: 12px;
  font-size: 12px;
  color: var(--text-tertiary);
  font-family: var(--mono);
}

.result-controls {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
}

.audio-player {
  flex: 1;
  min-width: 240px;
  height: 36px;
}

.export-buttons {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

/* Transcript */
.transcript-body {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 8px 0;
  max-height: 600px;
  overflow-y: auto;
}

.utterance {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 8px 20px;
  transition: background 0.1s;
}

.utterance:hover {
  background: var(--surface-hover);
}

.utterance.speaker-change {
  margin-top: 6px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}

.timestamp {
  background: var(--surface-elevated);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  font-family: var(--mono);
  font-size: 11px;
  padding: 3px 7px;
  border-radius: 4px;
  cursor: pointer;
  flex-shrink: 0;
  transition: all 0.15s;
  font-family: var(--mono);
}

.timestamp:hover {
  color: var(--accent);
  border-color: var(--accent);
  background: var(--accent-soft);
}

.speaker {
  font-size: 10px;
  font-weight: 600;
  color: var(--accent);
  background: var(--accent-soft);
  padding: 2px 6px;
  border-radius: 3px;
  flex-shrink: 0;
  margin-top: 2px;
}

.utterance-text {
  font-size: 14px;
  line-height: 1.65;
  color: var(--text);
}

.plain-transcript {
  padding: 20px;
  font-size: 14px;
  line-height: 1.7;
  white-space: pre-wrap;
}

/* Scrollbar */
.transcript-body::-webkit-scrollbar {
  width: 6px;
}

.transcript-body::-webkit-scrollbar-track {
  background: transparent;
}

.transcript-body::-webkit-scrollbar-thumb {
  background: var(--border-light);
  border-radius: 3px;
}

.transcript-body::-webkit-scrollbar-thumb:hover {
  background: var(--text-tertiary);
}

/* Responsive */
@media (max-width: 600px) {
  .container {
    padding: 16px 12px 40px;
  }

  .tab-content {
    padding: 20px 16px;
  }

  .url-input form {
    flex-direction: column;
  }

  .result-controls {
    flex-direction: column;
    align-items: stretch;
  }

  .audio-player {
    width: 100%;
  }

  .export-buttons {
    justify-content: center;
  }

  .utterance {
    padding: 8px 14px;
  }

  .header-right {
    flex-wrap: wrap;
    justify-content: flex-end;
  }

  .history-item-meta {
    flex-wrap: wrap;
  }
}

