* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: 'Inter', 'Segoe UI', sans-serif;
  background: linear-gradient(180deg, #0f172a 0%, #111827 100%);
  color: #e5e7eb;
  min-height: 100vh;
}

.app-header {
  padding: 2rem 3rem 1.5rem;
  background: rgba(15, 23, 42, 0.8);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid rgba(148, 163, 184, 0.2);
}

.app-header h1 {
  margin: 0;
  font-size: 2.5rem;
  letter-spacing: 0.05em;
}

.app-header .tagline {
  margin: 0.5rem 0 0;
  color: #94a3b8;
}

.performance-notice {
  margin-top: 0.5rem;
}

.performance-notice small {
  color: #fbbf24;
  font-style: italic;
}

.app-shell {
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: 1.5rem;
  padding: 1.5rem 2rem 3rem;
}

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.panel {
  background: rgba(30, 41, 59, 0.7);
  border: 1px solid rgba(148, 163, 184, 0.15);
  border-radius: 16px;
  padding: 1.25rem;
  box-shadow: 0 20px 45px rgba(15, 23, 42, 0.35);
}

.panel h2 {
  margin: 0 0 1rem;
  font-size: 1.1rem;
  letter-spacing: 0.02em;
}

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

label {
  display: block;
  font-size: 0.9rem;
  margin-bottom: 0.35rem;
  color: #cbd5f5;
}

input[type="text"],
input[type="url"],
input[type="number"],
select,
textarea {
  width: 100%;
  padding: 0.6rem 0.75rem;
  border-radius: 10px;
  border: 1px solid rgba(148, 163, 184, 0.2);
  background: rgba(15, 23, 42, 0.6);
  color: #e5e7eb;
  font: inherit;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: #38bdf8;
  box-shadow: 0 0 0 2px rgba(56, 189, 248, 0.15);
}

textarea {
  resize: vertical;
}

input[type="range"] {
  width: 100%;
  margin: 0.5rem 0;
}

.hint {
  font-size: 0.8rem;
  color: #94a3b8;
}

.toggle {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-size: 0.9rem;
}

.radio-group {
  display: flex;
  gap: 0.75rem;
  margin-bottom: 0.5rem;
}

.radio-group input {
  margin-right: 0.35rem;
}

.content {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.tabs {
  display: inline-flex;
  background: rgba(30, 41, 59, 0.6);
  border-radius: 999px;
  padding: 0.4rem;
  width: fit-content;
  border: 1px solid rgba(148, 163, 184, 0.2);
}

.tab {
  border: none;
  background: transparent;
  color: #94a3b8;
  padding: 0.6rem 1.2rem;
  border-radius: 999px;
  font: inherit;
  cursor: pointer;
  transition: all 0.2s ease;
}

.tab.active {
  background: linear-gradient(135deg, #38bdf8 0%, #818cf8 100%);
  color: #0f172a;
  font-weight: 600;
}

.tab-panel {
  display: none;
}

.tab-panel.active {
  display: block;
}

.form-row {
  display: flex;
  gap: 0.75rem;
}

.form-row input {
  flex: 1;
}

.list {
  margin-top: 1rem;
  display: grid;
  gap: 0.75rem;
}

.list-grid {
  margin-top: 1.5rem;
  display: grid;
  gap: 1.25rem;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  align-items: start;
}

.list-section {
  background: rgba(15, 23, 42, 0.4);
  border: 1px solid rgba(148, 163, 184, 0.18);
  border-radius: 16px;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.list-section-header {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.list-section-header h3 {
  margin: 0;
  font-size: 1rem;
  letter-spacing: 0.02em;
}

.list-hint {
  margin: 0;
  font-size: 0.85rem;
  color: #9ca3af;
}

.list-item {
  padding: 0.75rem;
  border-radius: 12px;
  background: rgba(15, 23, 42, 0.55);
  border: 1px solid rgba(148, 163, 184, 0.15);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
}

.list-item button {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  transition: all 0.2s ease;
}

.list-item button.loading {
  pointer-events: none;
  opacity: 0.75;
}

.list-item button.loading::before {
  content: '';
  width: 0.9rem;
  height: 0.9rem;
  border-radius: 50%;
  border: 2px solid rgba(148, 163, 184, 0.4);
  border-top-color: #38bdf8;
  animation: spin 0.8s linear infinite;
}

.list-item button.success {
  background: rgba(34, 197, 94, 0.18);
  border-color: rgba(34, 197, 94, 0.35);
  color: #86efac;
}

.list-item button.error {
  background: rgba(248, 113, 113, 0.18);
  border-color: rgba(248, 113, 113, 0.35);
  color: #fca5a5;
}

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

.list-item.selected {
  border-color: rgba(56, 189, 248, 0.6);
  box-shadow: 0 0 0 2px rgba(56, 189, 248, 0.15);
}

.empty-state {
  padding: 1rem;
  text-align: center;
  border: 1px dashed rgba(148, 163, 184, 0.25);
  border-radius: 12px;
  color: #94a3b8;
  font-size: 0.9rem;
  background: rgba(15, 23, 42, 0.35);
}

.actions {
  display: flex;
  gap: 1rem;
  align-items: center;
}

button {
  border: none;
  border-radius: 10px;
  padding: 0.65rem 1.1rem;
  font: inherit;
  cursor: pointer;
  color: #0f172a;
  background: #e2e8f0;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

button.primary {
  background: linear-gradient(135deg, #38bdf8 0%, #818cf8 100%);
  color: #0f172a;
  font-weight: 600;
}

button.secondary {
  background: rgba(148, 163, 184, 0.2);
  color: #e5e7eb;
}

button.danger {
  background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
  color: #fef2f2;
  font-weight: 600;
}

button:hover {
  transform: translateY(-1px);
  box-shadow: 0 10px 25px rgba(15, 23, 42, 0.25);
}

.status-text {
  color: #eab308;
  font-size: 0.9rem;
  transition: color 0.3s ease;
}

.status-text[data-tone="success"] {
  color: #22c55e;
}

.status-text[data-tone="error"] {
  color: #ef4444;
}

.status-text[data-tone="warning"] {
  color: #f59e0b;
}

.status-text[data-tone="info"] {
  color: #3b82f6;
}

.progress-container {
  margin-top: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.progress-bar {
  width: 100%;
  height: 8px;
  background: rgba(148, 163, 184, 0.2);
  border-radius: 4px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #38bdf8 0%, #818cf8 100%);
  width: 0%;
  transition: width 0.3s ease;
  border-radius: 4px;
}

#transcript-container {
  max-height: 420px;
  overflow: auto;
  border-radius: 12px;
  background: rgba(15, 23, 42, 0.4);
  border: 1px solid rgba(148, 163, 184, 0.15);
}

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

.utterance-item {
  padding: 0.85rem 1rem;
  border-bottom: 1px solid rgba(148, 163, 184, 0.1);
  transition: background 0.2s ease;
}

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

.utterance-item.active {
  background: rgba(56, 189, 248, 0.15);
  border-left: 3px solid #38bdf8;
}

.utterance-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.timestamp {
  font-size: 0.8rem;
  color: #94a3b8;
  min-width: 70px;
}

.speaker-tag {
  font-size: 0.75rem;
  padding: 0.1rem 0.5rem;
  border-radius: 999px;
  background: rgba(129, 140, 248, 0.2);
  border: 1px solid rgba(129, 140, 248, 0.4);
  font-weight: 500;
  letter-spacing: 0.01em;
}

.editable-speaker {
  cursor: pointer;
  transition: all 0.2s ease;
}

.editable-speaker:hover {
  filter: brightness(1.15);
  transform: scale(1.05);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.speaker-edit-input {
  font-size: 0.75rem;
  padding: 0.1rem 0.5rem;
  border-radius: 999px;
  background: rgba(30, 41, 59, 0.9);
  border: 1px solid rgba(129, 140, 248, 0.8);
  color: #e5e7eb;
  width: 120px;
  text-align: center;
}

.speaker-edit-input:focus {
  outline: none;
  border-color: rgba(129, 140, 248, 1);
}

.utterance-actions {
  margin-left: auto;
  display: flex;
  gap: 0.5rem;
}

.edit-btn {
  background: rgba(148, 163, 184, 0.2);
  color: #e5e7eb;
  padding: 0.3rem 0.6rem;
  font-size: 0.85rem;
}

.utterance-text {
  margin-top: 0.4rem;
  line-height: 1.5;
}

.edit-area {
  margin-top: 0.6rem;
  display: grid;
  gap: 0.5rem;
}

.edit-area textarea {
  width: 100%;
}

.edit-controls {
  display: flex;
  gap: 0.5rem;
}

.summary {
  min-height: 120px;
  background: rgba(15, 23, 42, 0.5);
  border-radius: 12px;
  padding: 1rem;
  border: 1px solid rgba(148, 163, 184, 0.15);
  line-height: 1.6;
}

.summary h1, .summary h2, .summary h3 {
  margin-top: 1.5rem;
  margin-bottom: 0.5rem;
  color: #e2e8f0;
}

.summary h1 { font-size: 1.5rem; }
.summary h2 { font-size: 1.25rem; }
.summary h3 { font-size: 1.1rem; }

.summary p {
  margin-bottom: 1rem;
}

.summary strong {
  font-weight: 600;
  color: #f1f5f9;
}

.summary em {
  font-style: italic;
  color: #cbd5e1;
}

.summary code {
  background: rgba(100, 116, 139, 0.3);
  padding: 0.125rem 0.25rem;
  border-radius: 4px;
  font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
  font-size: 0.9em;
}

.summary pre {
  background: rgba(15, 23, 42, 0.8);
  padding: 1rem;
  border-radius: 8px;
  overflow-x: auto;
  margin: 1rem 0;
}

.summary pre code {
  background: none;
  padding: 0;
}

.summary ul, .summary ol {
  margin: 1rem 0;
  padding-left: 1.5rem;
}

.summary li {
  margin-bottom: 0.25rem;
}

.summary a {
  color: #60a5fa;
  text-decoration: underline;
}

.summary a:hover {
  color: #93c5fd;
}

.title-display {
  min-height: 40px;
  background: rgba(15, 23, 42, 0.5);
  border-radius: 12px;
  padding: 1rem;
  border: 1px solid rgba(148, 163, 184, 0.15);
  font-size: 1.25rem;
  font-weight: 600;
  color: #f1f5f9;
  text-align: center;
}

.title-display:empty::before {
  content: "No title generated";
  color: #64748b;
  font-weight: 400;
  font-style: italic;
}

.export-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 0.75rem;
  align-items: end;
}

#diarization-metrics,
#speaker-breakdown {
  display: grid;
  gap: 0.75rem;
}

.metric-card {
  padding: 0.75rem;
  border-radius: 12px;
  background: rgba(15, 23, 42, 0.5);
  border: 1px solid rgba(148, 163, 184, 0.1);
}

.hidden {
  display: none !important;
}

/* ==================== Custom Audio Player ==================== */

.audio-player-panel {
  width: 100%;
}

.custom-audio-player {
  width: 100%;
}

#audio-player {
  display: none; /* Hide native player, use custom controls */
}

.player-controls {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.5rem;
  background: rgba(15, 23, 42, 0.5);
  border-radius: 12px;
  border: 1px solid rgba(148, 163, 184, 0.2);
}

.play-pause-btn {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: none;
  background: linear-gradient(135deg, #38bdf8 0%, #818cf8 100%);
  color: #0f172a;
  font-size: 1.2rem;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.play-pause-btn:hover {
  transform: scale(1.05);
  box-shadow: 0 0 20px rgba(56, 189, 248, 0.4);
}

.play-pause-btn:active {
  transform: scale(0.95);
}

.play-icon,
.pause-icon {
  display: block;
  line-height: 1;
}

.time-display {
  font-size: 0.9rem;
  color: #94a3b8;
  min-width: 45px;
  text-align: center;
  font-variant-numeric: tabular-nums;
  flex-shrink: 0;
}

.timeline-container {
  flex: 1;
  position: relative;
  height: 48px;
  min-width: 0;
}

.waveform-canvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  border-radius: 8px;
  background: rgba(15, 23, 42, 0.6);
  pointer-events: none;
}

.timeline-bar {
  position: relative;
  width: 100%;
  height: 100%;
  cursor: pointer;
  border-radius: 8px;
  overflow: hidden;
  background: rgba(15, 23, 42, 0.6);
}

.timeline-progress {
  position: absolute;
  top: 0;
  left: 0;
  height: 100%;
  background: linear-gradient(90deg, rgba(56, 189, 248, 0.3) 0%, rgba(129, 140, 248, 0.3) 100%);
  pointer-events: none;
  transition: width 0.1s linear;
  z-index: 1;
}

.timeline-segments {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 2;
}

.timeline-segment {
  position: absolute;
  height: 100%;
  opacity: 0.4;
  transition: opacity 0.2s ease;
  border-right: 1px solid rgba(0, 0, 0, 0.2);
}

.timeline-segment:hover {
  opacity: 0.6;
}

.timeline-segment.active {
  opacity: 0.8;
  box-shadow: inset 0 0 10px rgba(255, 255, 255, 0.2);
}

.timeline-handle {
  position: absolute;
  top: 50%;
  left: 0;
  transform: translate(-50%, -50%);
  width: 16px;
  height: 16px;
  background: #38bdf8;
  border: 2px solid #0f172a;
  border-radius: 50%;
  pointer-events: none;
  z-index: 3;
  box-shadow: 0 0 10px rgba(56, 189, 248, 0.6);
  transition: transform 0.1s ease;
}

.timeline-bar:hover .timeline-handle {
  transform: translate(-50%, -50%) scale(1.2);
}

.volume-control {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-shrink: 0;
}

.volume-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: none;
  background: rgba(148, 163, 184, 0.2);
  color: #e5e7eb;
  font-size: 1rem;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

.volume-btn:hover {
  background: rgba(148, 163, 184, 0.3);
}

.volume-slider {
  width: 80px;
  height: 4px;
  -webkit-appearance: none;
  appearance: none;
  background: rgba(148, 163, 184, 0.3);
  border-radius: 2px;
  outline: none;
}

.volume-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 14px;
  height: 14px;
  background: #38bdf8;
  border-radius: 50%;
  cursor: pointer;
  transition: all 0.2s ease;
}

.volume-slider::-webkit-slider-thumb:hover {
  transform: scale(1.2);
  box-shadow: 0 0 10px rgba(56, 189, 248, 0.6);
}

.volume-slider::-moz-range-thumb {
  width: 14px;
  height: 14px;
  background: #38bdf8;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  transition: all 0.2s ease;
}

.volume-slider::-moz-range-thumb:hover {
  transform: scale(1.2);
  box-shadow: 0 0 10px rgba(56, 189, 248, 0.6);
}

/* Speaker colors are now applied dynamically via JavaScript (30 colors palette) */

@media (max-width: 1100px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    order: 2;
  }

  .content {
    order: 1;
  }
  
  .player-controls {
    flex-wrap: wrap;
  }
  
  .timeline-container {
    order: 10;
    width: 100%;
    flex-basis: 100%;
  }
}
