:root {
  --bg: #ffffff;
  --bg-warm: #f7f7f7;
  --ink: #000000;
  --ink-soft: #1a1a1a;
  --ink-muted: #4d4d4d;
  --accent: #8c1515;
  --accent-soft: #b31b1b;
  --accent-glow: rgba(140, 21, 21, 0.12);
  --card: #ffffff;
  --card-border: #d9d9d9;
  --sidebar: #fafafa;
  --sidebar-border: #e6e6e6;
  --speaker-a: #3d6b99;
  --speaker-b: #7b5e9b;
  --speaker-c: #4a8f7a;
  --mono: "JetBrains Mono", monospace;
  --serif: "Open Sans", system-ui, sans-serif;
  --sans: "Open Sans", system-ui, sans-serif;
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: var(--sans);
  background: var(--bg);
  color: var(--ink);
  min-height: 100vh;
  line-height: 1.6;
}

.grain {
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0.015;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)'/%3E%3C/svg%3E");
  z-index: 9999;
}

.shell {
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr);
  min-height: 100vh;
  width: 100%;
}

.sidebar {
  background: var(--sidebar);
  border-right: 1px solid var(--sidebar-border);
  padding: 32px 24px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.sidebar-brand {
  display: flex;
  gap: 12px;
  align-items: center;
}

.brand-mark {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  object-fit: contain;
  display: block;
  background: transparent;
}

.sidebar h1 {
  margin: 0;
  font-family: var(--serif);
  font-size: 1.5rem;
}

.sidebar p {
  margin: 0;
  color: var(--ink-muted);
  font-size: 0.85rem;
}

.sidebar-upload {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.sidebar-upload-actions {
  display: grid;
  gap: 10px;
}

#file-input,
#folder-input {
  display: none;
}

.btn-primary {
  background: var(--ink);
  color: var(--bg);
  border: none;
  padding: 12px 16px;
  border-radius: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s var(--ease-out);
}

.btn-primary:hover {
  background: var(--accent);
  box-shadow: 0 10px 24px var(--accent-glow);
}

.sidebar-hint {
  font-size: 0.75rem;
  color: var(--ink-muted);
}

.sidebar-file-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  font-size: 0.7rem;
  color: var(--ink-muted);
}

.sidebar-file-list span {
  padding: 4px 8px;
  background: var(--bg-warm);
  border-radius: 999px;
  border: 1px solid var(--card-border);
}

.sidebar-section-title {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink-muted);
  margin-bottom: 8px;
}

.history-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.history-item {
  background: var(--card);
  border: 1px solid var(--card-border);
  border-left: 3px solid transparent;
  border-radius: 12px;
  padding: 10px 12px;
  display: flex;
  justify-content: space-between;
  gap: 8px;
  cursor: pointer;
  transition: all 0.2s var(--ease-out);
}

.history-item:hover {
  background: var(--bg-warm);
  border-left-color: var(--ink-muted);
}

.history-item.loading {
  cursor: default;
  opacity: 0.8;
}

.history-item.loading:hover {
  background: var(--card);
  border-left-color: transparent;
}

.history-item.active {
  border-color: var(--card-border);
  border-left-color: var(--accent);
  background: linear-gradient(90deg, var(--accent-glow) 0%, var(--card) 100%);
  box-shadow: 0 4px 12px var(--accent-glow);
}

.history-item.active:hover {
  border-left-color: var(--accent);
}

.history-name {
  font-size: 0.85rem;
  color: var(--ink);
  font-family: var(--mono);
}

.history-meta {
  font-size: 0.7rem;
  color: var(--ink-muted);
}

.history-actions {
  display: flex;
  gap: 6px;
}

.history-spinner {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 2px solid var(--card-border);
  border-top-color: var(--accent);
  animation: spin 0.9s linear infinite;
}

/* History item three-dot menu */
.history-actions {
  position: relative;
}

.history-menu-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border: none;
  background: transparent;
  border-radius: 6px;
  color: var(--ink-muted);
  cursor: pointer;
  opacity: 0;
  transition: all 0.15s;
}

.history-item:hover .history-menu-btn {
  opacity: 1;
}

.history-menu-btn:hover {
  background: var(--bg-warm);
  color: var(--ink);
}

.history-dropdown {
  position: absolute;
  top: 100%;
  right: 0;
  margin-top: 4px;
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
  overflow: hidden;
  z-index: 50;
  min-width: 100px;
}

.history-dropdown.hidden {
  display: none;
}

.history-dropdown-item {
  display: block;
  width: 100%;
  padding: 8px 14px;
  border: none;
  background: transparent;
  text-align: left;
  font-size: 0.8rem;
  color: var(--ink);
  cursor: pointer;
  transition: background 0.15s;
}

.history-dropdown-item:hover {
  background: var(--bg-warm);
}

.history-dropdown-item.danger {
  color: #dc2626;
}

.history-dropdown-item.danger:hover {
  background: rgba(239, 68, 68, 0.1);
}

.workspace {
  padding: 32px 40px 140px;
  min-width: 0;
}

.workspace-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
}

.workspace-header h2 {
  margin: 0;
  font-family: var(--serif);
  font-size: 2rem;
}

.workspace-header p {
  margin: 4px 0 0;
  color: var(--ink-muted);
}

.btn-secondary {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--card-border);
  background: transparent;
  padding: 10px 16px;
  border-radius: 12px;
  color: var(--ink-soft);
  cursor: pointer;
  transition: all 0.2s var(--ease-out);
}

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

.drop-zone {
  margin-top: 24px;
  padding: 20px;
  border-radius: 16px;
  border: 1px dashed var(--card-border);
  background: var(--card);
  transition: all 0.3s var(--ease-out);
  cursor: pointer;
}

.drop-zone:hover {
  border-color: var(--accent-soft);
  background: var(--bg-warm);
}

.drop-zone.drag-over {
  border-color: var(--accent);
  box-shadow: 0 12px 30px var(--accent-glow);
}

.drop-inner {
  display: flex;
  align-items: center;
  gap: 20px;
}

.drop-icon {
  color: var(--accent);
}

.drop-inner h3 {
  margin: 0;
  font-size: 1rem;
}

.drop-inner p {
  margin: 4px 0 0;
  color: var(--ink-muted);
}

/* Progress section */
.progress-section {
  margin: 24px 0;
  padding: 24px 28px;
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: 16px;
}

.progress-section.hidden {
  display: none;
}

.progress-steps {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0;
  margin-bottom: 16px;
}

.progress-step {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  min-width: 80px;
}

.step-indicator {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--bg-warm);
  border: 2px solid var(--card-border);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s var(--ease-out);
  position: relative;
}

.step-number {
  font-family: var(--mono);
  font-size: 0.8rem;
  color: var(--ink-muted);
}

.step-check {
  position: absolute;
  color: #fff;
}

.step-check.hidden {
  display: none;
}

.step-label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--ink-muted);
}

.progress-step.active .step-indicator,
.progress-step.completed .step-indicator {
  background: var(--accent);
  border-color: var(--accent);
}

.progress-step.active .step-number {
  color: #fff;
}

.progress-step.completed .step-number {
  display: none;
}

.progress-step.completed .step-check {
  display: block;
}

.progress-connector {
  flex: 1;
  max-width: 60px;
  height: 2px;
  background: var(--card-border);
  margin: 0 6px;
  margin-bottom: 24px;
  position: relative;
}

.progress-connector::after {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  height: 100%;
  width: 0%;
  background: var(--accent);
  transition: width 0.3s var(--ease-out);
}

.progress-connector.filled::after {
  width: 100%;
}

.progress-bar-track {
  height: 4px;
  background: var(--bg-warm);
  border-radius: 2px;
}

.progress-bar-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--accent) 0%, var(--accent-soft) 100%);
  transition: width 0.3s var(--ease-out);
}

.progress-meta {
  margin-top: 10px;
  font-family: var(--mono);
  font-size: 0.75rem;
  text-align: center;
  color: var(--ink-muted);
}

.status-bar {
  display: none;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  border-radius: 12px;
  background: var(--bg-warm);
  margin: 16px 0;
}

.status-bar.visible {
  display: flex;
}

.status-pulse {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
  animation: pulse-dot 1.5s ease-in-out infinite;
}

.status-bar.error {
  background: #fef2f2;
}

.status-bar.error .status-pulse {
  background: #dc2626;
}

@keyframes pulse-dot {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.2); opacity: 0.7; }
}

/* Canvas header */
.canvas-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  background: linear-gradient(135deg, var(--accent-glow) 0%, transparent 100%);
  border: 1px solid var(--accent-soft);
  border-radius: 12px;
  margin-top: 20px;
}

.canvas-header.hidden {
  display: none;
}

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

.canvas-info svg {
  color: var(--accent);
  flex-shrink: 0;
}

.canvas-name {
  font-family: var(--sans);
  font-size: 1rem;
  font-weight: 600;
  color: var(--ink);
}

.canvas-meta {
  font-family: var(--mono);
  font-size: 0.75rem;
  color: var(--ink-muted);
}

/* Summary section (Gemini feature) */
.transcript-summary {
  margin-top: 24px;
  margin-bottom: 16px;
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: 14px;
  padding: 20px 24px;
  transition: all 0.2s var(--ease-out);
}

.transcript-summary.hidden {
  display: none;
}

.summary-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}

.summary-header h3 {
  margin: 0;
  font-family: var(--serif);
  font-size: 1.3rem;
  color: var(--ink);
}

.summary-badges {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}

.badge-group {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  align-items: center;
}

.badge-group:not(:empty)::before {
  content: "";
  width: 1px;
  height: 16px;
  background: var(--card-border);
  margin-right: 4px;
}

.badge-group:first-child:not(:empty)::before {
  display: none;
}

#language-badges .language-badge,
.summary-badge {
  font-size: 0.7rem;
  padding: 3px 8px;
  border-radius: 999px;
  font-family: var(--mono);
  font-weight: 500;
  text-transform: uppercase;
}

#language-badges .language-badge {
  background: var(--accent-glow);
  color: var(--accent);
}

.summary-badge.speaker-badge {
  background: rgba(99, 102, 241, 0.12);
  color: #6366f1;
}

.summary-badge.emotion-badge {
  background: rgba(16, 185, 129, 0.12);
  color: #10b981;
}

.summary-badge.emotion-badge.emotion-happy {
  background: rgba(16, 185, 129, 0.12);
  color: #10b981;
}

.summary-badge.emotion-badge.emotion-sad {
  background: rgba(59, 130, 246, 0.12);
  color: #3b82f6;
}

.summary-badge.emotion-badge.emotion-angry {
  background: rgba(239, 68, 68, 0.12);
  color: #ef4444;
}

.summary-badge.emotion-badge.emotion-neutral {
  background: rgba(156, 163, 175, 0.12);
  color: #6b7280;
}

.summary-content {
  font-family: var(--sans);
  font-size: 0.95rem;
  line-height: 1.7;
  color: var(--ink-soft);
  padding-top: 8px;
  border-top: 1px solid var(--card-border);
  white-space: pre-line;
}

/* View controls */
.view-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-top: 20px;
  padding: 12px 16px;
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: 10px;
}

.view-controls.hidden {
  display: none;
}

.view-toggle {
  display: flex;
  gap: 4px;
  background: var(--bg-warm);
  padding: 4px;
  border-radius: 8px;
}

.view-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border: none;
  background: transparent;
  color: var(--ink-muted);
  font-family: var(--sans);
  font-size: 0.85rem;
  font-weight: 500;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s var(--ease-out);
}

.view-btn:hover {
  color: var(--ink-soft);
  background: rgba(255, 255, 255, 0.5);
}

.view-btn.active {
  background: var(--card);
  color: var(--ink);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.view-btn svg {
  flex-shrink: 0;
}

.highlight-selector {
  display: flex;
  align-items: center;
  gap: 8px;
}

.highlight-selector label {
  font-size: 0.85rem;
  color: var(--ink-muted);
}

.highlight-selector select {
  padding: 8px 12px;
  border: 1px solid var(--card-border);
  border-radius: 6px;
  background: var(--card);
  font-family: var(--sans);
  font-size: 0.85rem;
  color: var(--ink);
  cursor: pointer;
  transition: border-color 0.15s var(--ease-out);
}

.highlight-selector select:hover {
  border-color: var(--ink-muted);
}

.highlight-selector select:focus {
  outline: none;
  border-color: var(--accent);
}

/* Transcript container */
.transcript {
  margin-top: 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* Flow mode */
.transcript.flow-mode {
  gap: 0;
}

.transcript.flow-mode .flow-container {
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: 14px;
  padding: 24px 28px;
  font-family: var(--serif);
  font-size: 1.25rem;
  line-height: 2;
}

.flow-chunk {
  display: inline;
  padding: 2px 4px;
  margin: 0 1px;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.15s var(--ease-out);
}

.flow-chunk:hover {
  filter: brightness(0.95);
}

.flow-chunk.active {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

/* Chunk highlight colors (rainbow palette) */
.highlight-chunk-0 { background: rgba(239, 68, 68, 0.15); }
.highlight-chunk-1 { background: rgba(249, 115, 22, 0.15); }
.highlight-chunk-2 { background: rgba(234, 179, 8, 0.15); }
.highlight-chunk-3 { background: rgba(34, 197, 94, 0.15); }
.highlight-chunk-4 { background: rgba(6, 182, 212, 0.15); }
.highlight-chunk-5 { background: rgba(59, 130, 246, 0.15); }
.highlight-chunk-6 { background: rgba(139, 92, 246, 0.15); }
.highlight-chunk-7 { background: rgba(236, 72, 153, 0.15); }

/* Speaker highlight colors */
.highlight-speaker-0 { background: rgba(61, 107, 153, 0.2); }
.highlight-speaker-1 { background: rgba(123, 94, 155, 0.2); }
.highlight-speaker-2 { background: rgba(74, 143, 122, 0.2); }
.highlight-speaker-3 { background: rgba(196, 93, 62, 0.2); }
.highlight-speaker-4 { background: rgba(180, 83, 9, 0.2); }

/* Language highlight colors */
.highlight-lang-en { background: rgba(59, 130, 246, 0.15); }
.highlight-lang-es { background: rgba(234, 179, 8, 0.15); }
.highlight-lang-fr { background: rgba(139, 92, 246, 0.15); }
.highlight-lang-de { background: rgba(34, 197, 94, 0.15); }
.highlight-lang-zh { background: rgba(239, 68, 68, 0.15); }
.highlight-lang-ja { background: rgba(236, 72, 153, 0.15); }
.highlight-lang-ko { background: rgba(6, 182, 212, 0.15); }
.highlight-lang-ar { background: rgba(249, 115, 22, 0.15); }
.highlight-lang-hi { background: rgba(168, 85, 247, 0.15); }
.highlight-lang-pt { background: rgba(16, 185, 129, 0.15); }
.highlight-lang-ru { background: rgba(99, 102, 241, 0.15); }
.highlight-lang-default { background: rgba(156, 163, 175, 0.15); }

/* Emotion highlight colors */
.highlight-emotion-happy { background: rgba(34, 197, 94, 0.2); }
.highlight-emotion-sad { background: rgba(59, 130, 246, 0.2); }
.highlight-emotion-angry { background: rgba(239, 68, 68, 0.2); }
.highlight-emotion-neutral { background: rgba(156, 163, 175, 0.15); }

/* Flow chunk tooltip */
.flow-chunk[data-tooltip]:hover::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%);
  padding: 6px 10px;
  background: var(--ink);
  color: var(--bg);
  font-family: var(--sans);
  font-size: 0.75rem;
  border-radius: 6px;
  white-space: nowrap;
  z-index: 100;
  pointer-events: none;
}

.flow-chunk {
  position: relative;
}

.segment {
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: 14px;
  padding: 20px 24px;
  transition: all 0.2s var(--ease-out);
}

.segment:hover {
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.06);
  transform: translateY(-2px);
}

.segment.selected {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-glow), 0 6px 18px rgba(0, 0, 0, 0.08);
}

.segment-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}

.speaker-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.speaker-badge::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: currentColor;
}

.speaker-0 { background: rgba(61, 107, 153, 0.12); color: var(--speaker-a); }
.speaker-1 { background: rgba(123, 94, 155, 0.12); color: var(--speaker-b); }
.speaker-2 { background: rgba(74, 143, 122, 0.12); color: var(--speaker-c); }

/* Language badge (Gemini feature) */
.language-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 0.65rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  background: rgba(196, 93, 62, 0.08);
  color: var(--accent);
  border: 1px solid rgba(196, 93, 62, 0.2);
  font-family: var(--mono);
  margin-left: 8px;
}

/* Emotion indicator (Gemini feature) */
.emotion-indicator {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 0.65rem;
  font-weight: 500;
  text-transform: capitalize;
  background: rgba(0, 0, 0, 0.04);
  border: 1px solid var(--card-border);
  margin-left: 8px;
  font-family: var(--mono);
}

.emotion-happy {
  background: rgba(74, 222, 128, 0.12);
  color: #16a34a;
  border-color: rgba(74, 222, 128, 0.3);
}

.emotion-sad {
  background: rgba(59, 130, 246, 0.12);
  color: #2563eb;
  border-color: rgba(59, 130, 246, 0.3);
}

.emotion-angry {
  background: rgba(239, 68, 68, 0.12);
  color: #dc2626;
  border-color: rgba(239, 68, 68, 0.3);
}

.emotion-neutral {
  background: rgba(156, 163, 175, 0.12);
  color: #6b7280;
  border-color: rgba(156, 163, 175, 0.3);
}

.segment-time {
  font-family: var(--mono);
  font-size: 0.75rem;
  color: var(--ink-muted);
  margin-left: auto;
}

.segment-text {
  font-family: var(--serif);
  font-size: 1.2rem;
  line-height: 1.8;
}

/* Segment text block for non-word-level transcripts (Gemini) */
.segment-text-block {
  display: inline;
}

/* Translation display (Gemini feature) */
.segment-translation {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px dashed var(--card-border);
  font-family: var(--sans);
  font-size: 0.9rem;
  line-height: 1.6;
  color: var(--ink-muted);
  font-style: italic;
}

.segment-translation::before {
  content: "Translation: ";
  font-weight: 600;
  color: var(--ink-soft);
  font-style: normal;
}

.word {
  padding: 2px 4px;
  margin: 0 1px;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.15s var(--ease-out);
  display: inline-block;
}

.word:hover {
  background: var(--accent);
  color: #fff;
  transform: translateY(-1px);
}

.word.playing {
  background: var(--accent-glow);
  color: var(--accent);
}

.word.editing {
  background: #fff;
  color: var(--ink);
  outline: 2px solid var(--accent);
  box-shadow: 0 6px 16px var(--accent-glow);
}

.word.editing:focus {
  outline: 2px solid var(--accent);
}

.player-bar {
  position: fixed;
  bottom: 0;
  left: 300px;
  right: 0;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0) 0%, var(--bg) 20%);
  padding: 24px 32px 16px;
  transform: translateY(100%);
  transition: transform 0.4s var(--ease-out);
  z-index: 120;
}

.player-bar.visible {
  transform: translateY(0);
}

.player-inner {
  max-width: 720px;
  margin: 0 auto;
  background: var(--ink);
  border-radius: 14px;
  padding: 10px 18px;
  display: flex;
  align-items: center;
  gap: 14px;
}

.player-btn {
  background: transparent;
  border: none;
  color: var(--bg);
  cursor: pointer;
  padding: 6px;
}

.player-time {
  font-family: var(--mono);
  font-size: 0.75rem;
  color: var(--ink-muted);
  min-width: 40px;
}

.player-progress {
  flex: 1;
  position: relative;
  height: 24px;
  display: flex;
  align-items: center;
}

.progress-bg {
  width: 100%;
  height: 4px;
  background: rgba(255, 255, 255, 0.2);
  border-radius: 2px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: var(--accent);
  width: 0%;
}

.progress-input {
  position: absolute;
  inset: 0;
  width: 100%;
  opacity: 0;
  cursor: pointer;
}

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

  .sidebar {
    border-right: none;
    border-bottom: 1px solid var(--sidebar-border);
  }

  .player-bar {
    left: 0;
  }

  .waveform-panel {
    left: 0;
  }
}

/* Upload Options Modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  backdrop-filter: blur(4px);
}

.modal-overlay.hidden {
  display: none;
}

.modal {
  background: var(--card);
  border-radius: 16px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.2);
  max-width: 420px;
  width: 90%;
  animation: modal-appear 0.2s var(--ease-out);
}

@keyframes modal-appear {
  from {
    opacity: 0;
    transform: scale(0.95) translateY(10px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px 24px;
  border-bottom: 1px solid var(--card-border);
}

.modal-header h3 {
  margin: 0;
  font-family: var(--serif);
  font-size: 1.3rem;
}

.modal-close {
  background: none;
  border: none;
  font-size: 1.5rem;
  color: var(--ink-muted);
  cursor: pointer;
  padding: 4px 8px;
  line-height: 1;
  transition: color 0.2s;
}

.modal-close:hover {
  color: var(--ink);
}

.modal-body {
  padding: 24px;
}

.form-group {
  margin-bottom: 20px;
}

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

.form-group label {
  display: block;
  margin-bottom: 8px;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--ink-soft);
}

.form-group select {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--card-border);
  border-radius: 10px;
  font-family: var(--sans);
  font-size: 0.95rem;
  background: var(--bg);
  color: var(--ink);
  cursor: pointer;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.form-group select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  padding: 16px 24px;
  border-top: 1px solid var(--card-border);
  background: var(--bg-warm);
  border-radius: 0 0 16px 16px;
}

/* Export Dropdown */
.export-dropdown {
  position: relative;
}

.export-dropdown .btn-secondary {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.dropdown-arrow {
  transition: transform 0.2s;
}

.export-dropdown.open .dropdown-arrow {
  transform: rotate(180deg);
}

.export-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: 12px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
  min-width: 220px;
  z-index: 100;
  overflow: hidden;
  animation: dropdown-appear 0.15s var(--ease-out);
}

.export-menu.hidden {
  display: none;
}

@keyframes dropdown-appear {
  from {
    opacity: 0;
    transform: translateY(-8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.export-option {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  width: 100%;
  padding: 12px 16px;
  border: none;
  background: transparent;
  cursor: pointer;
  text-align: left;
  transition: background 0.15s;
}

.export-option:hover {
  background: var(--bg-warm);
}

.export-option:not(:last-child) {
  border-bottom: 1px solid var(--card-border);
}

.export-format {
  font-family: var(--mono);
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--ink);
}

.export-desc {
  font-size: 0.75rem;
  color: var(--ink-muted);
  margin-top: 2px;
}

/* Cite this tool section */
.sidebar-cite {
  margin-top: auto;
  padding-top: 16px;
  border-top: 1px solid var(--sidebar-border);
}

.cite-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  width: 100%;
  padding: 8px 12px;
  border: none;
  background: transparent;
  color: var(--ink-muted);
  font-family: var(--sans);
  font-size: 0.75rem;
  cursor: pointer;
  border-radius: 6px;
  transition: all 0.15s var(--ease-out);
}

.cite-btn:hover {
  background: var(--bg-warm);
  color: var(--ink-soft);
}

.cite-btn svg {
  flex-shrink: 0;
}

.cite-box {
  margin-top: 10px;
  padding: 12px 14px;
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: 10px;
  animation: cite-expand 0.2s var(--ease-out);
}

.cite-box.hidden {
  display: none;
}

@keyframes cite-expand {
  from {
    opacity: 0;
    transform: translateY(-4px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.cite-label {
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink-muted);
  margin-bottom: 6px;
}

.cite-text {
  font-family: var(--sans);
  font-size: 0.8rem;
  line-height: 1.5;
  color: var(--ink-soft);
  margin-bottom: 10px;
}

.cite-text em {
  font-style: italic;
}

.cite-copy {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 6px 12px;
  border: 1px solid var(--card-border);
  background: var(--bg);
  color: var(--ink-muted);
  font-family: var(--sans);
  font-size: 0.7rem;
  font-weight: 500;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s var(--ease-out);
}

.cite-copy:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.cite-copy.copied {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

/* =============================================
   WAVEFORM/SPECTROGRAM PANEL
   ============================================= */

.waveform-panel {
  position: fixed;
  bottom: 80px;
  left: 300px;
  right: 0;
  background: var(--card);
  border: 1px solid var(--card-border);
  border-bottom: none;
  border-radius: 16px 16px 0 0;
  box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.08);
  z-index: 119;
  transform: translateY(calc(100% + 100px));
  transition: transform 0.35s var(--ease-out);
  overflow: hidden;
}

.waveform-panel.visible {
  transform: translateY(0);
}

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

.waveform-tabs {
  display: flex;
  gap: 4px;
  background: var(--card);
  padding: 4px;
  border-radius: 8px;
  border: 1px solid var(--card-border);
}

.waveform-tab {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border: none;
  background: transparent;
  color: var(--ink-muted);
  font-family: var(--sans);
  font-size: 0.8rem;
  font-weight: 500;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s var(--ease-out);
}

.waveform-tab:hover {
  color: var(--ink-soft);
  background: var(--bg-warm);
}

.waveform-tab.active {
  background: var(--ink);
  color: var(--bg);
}

.waveform-controls {
  display: flex;
  gap: 6px;
}

.waveform-ctrl-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border: 1px solid var(--card-border);
  background: var(--card);
  border-radius: 8px;
  color: var(--ink-muted);
  cursor: pointer;
  transition: all 0.15s var(--ease-out);
}

.waveform-ctrl-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-glow);
}

.waveform-canvas-container {
  position: relative;
  height: 200px;
  background: linear-gradient(180deg, #1a1a2e 0%, #16213e 100%);
  overflow: hidden;
}

#waveform-canvas,
#spectrogram-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

#spectrogram-canvas.hidden {
  display: none;
}

.waveform-playhead {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 2px;
  background: var(--accent);
  z-index: 10;
  pointer-events: none;
  left: 0;
  box-shadow: 0 0 8px var(--accent);
}

.waveform-playhead::before {
  content: "";
  position: absolute;
  top: -4px;
  left: 50%;
  transform: translateX(-50%);
  width: 0;
  height: 0;
  border-left: 6px solid transparent;
  border-right: 6px solid transparent;
  border-top: 8px solid var(--accent);
}

.waveform-segments {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.waveform-segment {
  position: absolute;
  top: 0;
  bottom: 24px;
  background: rgba(140, 21, 21, 0.15);
  border-left: 2px solid var(--accent);
  border-right: 2px solid var(--accent);
  pointer-events: auto;
  cursor: pointer;
  transition: background 0.15s;
}

.waveform-segment:hover {
  background: rgba(140, 21, 21, 0.25);
}

.waveform-segment-label {
  position: absolute;
  bottom: 100%;
  left: 4px;
  font-size: 0.65rem;
  color: var(--bg);
  background: var(--accent);
  padding: 2px 6px;
  border-radius: 4px 4px 0 0;
  white-space: nowrap;
  max-width: 100px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.waveform-segment-handle {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 8px;
  cursor: ew-resize;
  pointer-events: auto;
  z-index: 5;
}

.waveform-segment-handle.left {
  left: -4px;
}

.waveform-segment-handle.right {
  right: -4px;
}

.waveform-segment-handle:hover {
  background: rgba(140, 21, 21, 0.5);
}

.waveform-time-ruler {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 24px;
  background: rgba(0, 0, 0, 0.4);
  display: flex;
  align-items: center;
}

.waveform-time-mark {
  position: absolute;
  bottom: 0;
  color: rgba(255, 255, 255, 0.6);
  font-family: var(--mono);
  font-size: 0.65rem;
  transform: translateX(-50%);
}

.waveform-time-mark::before {
  content: "";
  position: absolute;
  bottom: 14px;
  left: 50%;
  width: 1px;
  height: 6px;
  background: rgba(255, 255, 255, 0.3);
}

/* =============================================
   ENHANCED PLAYER BAR
   ============================================= */

.player-bar {
  position: fixed;
  bottom: 0;
  left: 300px;
  right: 0;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0) 0%, var(--bg) 20%);
  padding: 24px 32px 16px;
  transform: translateY(100%);
  transition: transform 0.4s var(--ease-out);
  z-index: 120;
}

.player-inner {
  max-width: 800px;
  margin: 0 auto;
  background: var(--ink);
  border-radius: 14px;
  padding: 10px 18px;
  display: flex;
  align-items: center;
  gap: 12px;
}

/* Speed Control */
.player-speed {
  position: relative;
}

.speed-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 40px;
  height: 28px;
  padding: 0 8px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: rgba(255, 255, 255, 0.1);
  border-radius: 6px;
  color: var(--bg);
  font-family: var(--mono);
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s var(--ease-out);
}

.speed-btn:hover {
  background: rgba(255, 255, 255, 0.2);
  border-color: rgba(255, 255, 255, 0.4);
}

.speed-menu {
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
  overflow: hidden;
  z-index: 200;
  min-width: 70px;
}

.speed-menu.hidden {
  display: none;
}

.speed-option {
  display: block;
  width: 100%;
  padding: 10px 16px;
  border: none;
  background: transparent;
  color: var(--ink);
  font-family: var(--mono);
  font-size: 0.85rem;
  text-align: center;
  cursor: pointer;
  transition: background 0.15s;
}

.speed-option:hover {
  background: var(--bg-warm);
}

.speed-option.active {
  background: var(--accent-glow);
  color: var(--accent);
  font-weight: 600;
}

/* Skip Buttons */
#skip-back,
#skip-forward {
  opacity: 0.7;
  transition: opacity 0.15s;
}

#skip-back:hover,
#skip-forward:hover {
  opacity: 1;
}

/* Toggle Waveform Button */
#toggle-waveform {
  margin-left: auto;
  opacity: 0.7;
  transition: all 0.15s;
}

#toggle-waveform:hover {
  opacity: 1;
}

#toggle-waveform[aria-pressed="true"] {
  opacity: 1;
  color: var(--accent);
}

/* =============================================
   KEYBOARD SHORTCUTS MODAL
   ============================================= */

.shortcuts-modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  backdrop-filter: blur(4px);
}

.shortcuts-modal.hidden {
  display: none;
}

.shortcuts-content {
  background: var(--card);
  border-radius: 16px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.2);
  max-width: 600px;
  width: 90%;
  max-height: 80vh;
  overflow: hidden;
  animation: modal-appear 0.2s var(--ease-out);
}

.shortcuts-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px 24px;
  border-bottom: 1px solid var(--card-border);
}

.shortcuts-header h3 {
  margin: 0;
  font-family: var(--serif);
  font-size: 1.3rem;
}

.shortcuts-body {
  padding: 24px;
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 24px;
  max-height: 60vh;
  overflow-y: auto;
}

.shortcuts-group h4 {
  margin: 0 0 12px;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--ink-muted);
}

.shortcut {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 0;
}

.shortcut kbd {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 24px;
  height: 24px;
  padding: 0 6px;
  background: var(--bg-warm);
  border: 1px solid var(--card-border);
  border-radius: 4px;
  font-family: var(--mono);
  font-size: 0.7rem;
  color: var(--ink);
}

.shortcut span {
  font-size: 0.85rem;
  color: var(--ink-soft);
}

/* =============================================
   INLINE TIMESTAMP EDITOR
   ============================================= */

.timestamp-editor {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 8px;
  background: var(--card);
  border: 2px solid var(--accent);
  border-radius: 6px;
  box-shadow: 0 4px 12px var(--accent-glow);
}

.timestamp-input {
  width: 70px;
  padding: 4px 6px;
  border: 1px solid var(--card-border);
  border-radius: 4px;
  font-family: var(--mono);
  font-size: 0.8rem;
  text-align: center;
  background: var(--bg);
}

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

.timestamp-separator {
  color: var(--ink-muted);
  font-size: 0.8rem;
}

.timestamp-actions {
  display: flex;
  gap: 4px;
  margin-left: 4px;
}

.timestamp-action-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.15s;
}

.timestamp-action-btn.save {
  background: var(--accent);
  color: #fff;
}

.timestamp-action-btn.save:hover {
  background: var(--accent-soft);
}

.timestamp-action-btn.cancel {
  background: var(--bg-warm);
  color: var(--ink-muted);
}

.timestamp-action-btn.cancel:hover {
  background: var(--card-border);
  color: var(--ink);
}

/* Editable timestamp in segment meta */
.segment-time.editable {
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 4px;
  transition: all 0.15s;
}

.segment-time.editable:hover {
  background: var(--accent-glow);
  color: var(--accent);
}

.segment-time.editing {
  background: transparent;
}

/* =============================================
   AUTO-SCROLL INDICATOR
   ============================================= */

.auto-scroll-indicator {
  position: fixed;
  bottom: 100px;
  right: 24px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: 999px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  font-size: 0.8rem;
  color: var(--ink-muted);
  cursor: pointer;
  z-index: 110;
  opacity: 0;
  transform: translateY(10px);
  transition: all 0.2s var(--ease-out);
  pointer-events: none;
}

.auto-scroll-indicator.visible {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

.auto-scroll-indicator:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.auto-scroll-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
}

.auto-scroll-indicator.paused .auto-scroll-dot {
  background: var(--ink-muted);
}

/* =============================================
   RESPONSIVE ADJUSTMENTS
   ============================================= */

@media (max-width: 900px) {
  .waveform-panel {
    left: 0;
    border-radius: 16px 16px 0 0;
  }

  .shortcuts-body {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 600px) {
  .player-inner {
    padding: 8px 12px;
    gap: 8px;
  }

  #skip-back,
  #skip-forward {
    display: none;
  }

  .speed-btn {
    min-width: 32px;
    font-size: 0.7rem;
  }

  .waveform-canvas-container {
    height: 150px;
  }
}
