/* ==============================================
   OmniTranscribe — Professional Light Theme
   
   Palette based on Wong (2011) colorblind-safe colors:
   Blue #0072B2, Orange #E69F00, Vermillion #D55E00,
   Reddish Purple #CC79A7, Bluish Green #009E73,
   Sky Blue #56B4E9, Yellow #F0E442
   ============================================== */

:root {
  /* Core surface palette — warm white */
  --bg: #ffffff;
  --bg-subtle: #f7f8fa;
  --bg-elevated: #f0f2f5;
  --ink: #1a1d26;
  --ink-secondary: #5f6577;
  --ink-muted: #9099ad;

  /* Accent — Stanford cardinal */
  --accent: #8c1515;
  --accent-hover: #a41d1d;
  --accent-subtle: rgba(140, 21, 21, 0.08);
  --accent-dim: rgba(140, 21, 21, 0.04);

  /* Surfaces & borders */
  --surface: #ffffff;
  --surface-raised: #f7f8fa;
  --border: #e2e5eb;
  --border-strong: #cdd1da;
  --border-dim: #eef0f3;

  /* Aliases */
  --bg-warm: var(--bg-subtle);
  --ink-soft: var(--ink);
  --accent-soft: var(--accent-hover);
  --accent-glow: var(--accent-subtle);
  --card: var(--surface);
  --card-border: var(--border);
  --sidebar: #f7f8fa;
  --sidebar-border: #e2e5eb;

  /* Colorblind-safe speaker palette (Wong 2011), darkened for light bg */
  --speaker-a: #0072B2;
  --speaker-b: #D55E00;
  --speaker-c: #009E73;

  /* Typography */
  --font-sans: "Open Sans", system-ui, -apple-system, sans-serif;
  --font-mono: "JetBrains Mono", "SF Mono", Consolas, monospace;
  --mono: var(--font-mono);
  --serif: var(--font-sans);
  --sans: var(--font-sans);

  /* Spacing */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-8: 32px;
  --space-10: 40px;

  /* Radius */
  --radius-xs: 4px;
  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-xl: 16px;

  /* Shadows */
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.08);
  --shadow-md: 0 4px 16px rgba(0,0,0,0.1);
  --shadow-lg: 0 12px 40px rgba(0,0,0,0.12);
  --shadow-glow: 0 0 20px rgba(140, 21, 21, 0.08);

  /* Animation */
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
  --transition-fast: 120ms var(--ease-out);
  --transition-base: 200ms var(--ease-out);
  --transition-slow: 350ms var(--ease-out);

  /* Layout */
  --sidebar-width: 260px;
  --sidebar-collapsed-width: 0px;
  --player-height: 72px;
  --toolbar-height: 48px;
}

/* =============================================
   RESET & BASE
   ============================================= */

*, *::before, *::after { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--ink);
  min-height: 100vh;
  line-height: 1.6;
  font-size: 13px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow: hidden;
}

::selection {
  background: var(--accent);
  color: #fff;
}

::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover { background: var(--border-strong); }

.grain { display: none; }
.hidden { display: none !important; }

/* Focus ring */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* =============================================
   LAYOUT
   ============================================= */

.shell {
  display: grid;
  grid-template-columns: var(--sidebar-width) minmax(0, 1fr);
  height: 100vh;
  transition: grid-template-columns var(--transition-slow);
}

.shell.sidebar-collapsed {
  grid-template-columns: 0px minmax(0, 1fr);
}
.shell.sidebar-collapsed .sidebar {
  transform: translateX(-100%);
  opacity: 0;
  pointer-events: none;
}

/* =============================================
   TOOLBAR (spans full width above workspace)
   ============================================= */

.toolbar {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  height: var(--toolbar-height);
  padding: 0 var(--space-4);
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  z-index: 100;
  flex-shrink: 0;
}

.sidebar-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border: none;
  background: transparent;
  color: var(--ink-muted);
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: all var(--transition-fast);
  flex-shrink: 0;
}
.sidebar-toggle:hover { background: var(--surface); color: var(--ink); }

.toolbar-left { display: flex; align-items: center; gap: var(--space-3); flex: 1; min-width: 0; }
.toolbar-center { display: flex; align-items: center; justify-content: center; }
.toolbar-right { display: flex; align-items: center; gap: var(--space-2); flex-shrink: 0; }

/* Search trigger button in toolbar */
.search-trigger {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: 6px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--ink-muted);
  font-size: 0.8rem;
  cursor: pointer;
  transition: all var(--transition-fast);
  min-width: 240px;
  user-select: none;
}
.search-trigger:hover { border-color: var(--border-strong); color: var(--ink-secondary); }
.search-trigger kbd {
  font-family: var(--font-mono);
  font-size: 0.65rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  padding: 1px 5px;
  margin-left: auto;
  color: var(--ink-muted);
}
.search-trigger svg { flex-shrink: 0; opacity: 0.5; }

/* Toolbar icon buttons */
.toolbar-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--ink-muted);
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: all var(--transition-fast);
}
.toolbar-btn:hover { background: var(--surface); color: var(--ink); border-color: var(--border); }
.toolbar-btn.active { background: var(--accent-subtle); color: var(--accent); border-color: var(--accent-subtle); }

/* =============================================
   SEARCH OVERLAY
   ============================================= */

.search-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.2);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: 15vh;
  z-index: 2000;
  backdrop-filter: blur(8px);
}
.search-overlay.hidden { display: none; }

.search-dialog {
  width: 560px;
  max-width: 90vw;
  background: var(--surface-raised);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  animation: search-appear 0.15s var(--ease-out);
}

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

.search-input-row {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-4) var(--space-5);
  border-bottom: 1px solid var(--border);
}

.search-input-row svg { color: var(--ink-muted); flex-shrink: 0; }

.search-input {
  flex: 1;
  border: none;
  background: transparent;
  font-size: 1rem;
  font-family: var(--font-sans);
  color: var(--ink);
  outline: none;
}
.search-input::placeholder { color: var(--ink-muted); }

.search-results {
  max-height: 400px;
  overflow-y: auto;
  padding: var(--space-2);
}

.search-result {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background var(--transition-fast);
}
.search-result:hover { background: var(--accent-dim); }
.search-result.active { background: var(--accent-subtle); }

.search-result-time {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--ink-muted);
  white-space: nowrap;
  padding-top: 2px;
  min-width: 50px;
}

.search-result-text {
  font-size: 0.88rem;
  color: var(--ink);
  line-height: 1.5;
}
.search-result-text mark {
  background: var(--accent);
  color: #fff;
  border-radius: 2px;
  padding: 0 2px;
}

.search-result-speaker {
  font-size: 0.68rem;
  color: var(--ink-muted);
  margin-top: 2px;
}

.search-empty {
  padding: var(--space-8);
  text-align: center;
  color: var(--ink-muted);
  font-size: 0.85rem;
}

.search-footer {
  padding: var(--space-3) var(--space-4);
  border-top: 1px solid var(--border);
  display: flex;
  gap: var(--space-4);
  font-size: 0.7rem;
  color: var(--ink-muted);
}
.search-footer kbd {
  font-family: var(--font-mono);
  font-size: 0.62rem;
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: 3px;
  padding: 1px 4px;
}

/* =============================================
   SIDEBAR
   ============================================= */

.sidebar {
  background: var(--sidebar);
  border-right: 1px solid var(--sidebar-border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: transform var(--transition-slow), opacity var(--transition-slow);
}

.sidebar-scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: var(--space-5) var(--space-4);
  display: flex;
  flex-direction: column;
  gap: var(--space-5);
}

.sidebar-brand {
  display: flex;
  gap: var(--space-3);
  align-items: center;
  padding-bottom: var(--space-3);
}

.brand-mark {
  width: 34px;
  height: 34px;
  border-radius: var(--radius-sm);
  object-fit: contain;
}

.sidebar h1 {
  margin: 0;
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--ink);
}

.brand-affiliation {
  display: block;
  height: 16px;
  width: auto;
  margin-top: -2px;
  opacity: 0.5;
  filter: none;
  transition: opacity 0.15s ease;
}
.brand-affiliation:hover { opacity: 0.8; }

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

/* Upload actions */
.sidebar-upload {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.sidebar-upload-actions {
  display: grid;
  gap: var(--space-2);
}

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

.btn-primary {
  background: var(--accent);
  color: #fff;
  border: none;
  padding: var(--space-2) var(--space-4);
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 0.8rem;
  font-family: var(--font-sans);
  cursor: pointer;
  text-align: center;
  transition: all var(--transition-fast);
  position: relative;
  overflow: hidden;
}
.btn-primary:hover { background: var(--accent-hover); transform: translateY(-1px); box-shadow: var(--shadow-sm); }
.btn-primary:active { transform: translateY(0); }

.btn-secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  border: 1px solid var(--border);
  background: var(--surface);
  padding: var(--space-2) var(--space-4);
  border-radius: var(--radius-sm);
  color: var(--ink-secondary);
  font-size: 0.8rem;
  font-family: var(--font-sans);
  cursor: pointer;
  transition: all var(--transition-fast);
}
.btn-secondary:hover { border-color: var(--border-strong); color: var(--ink); background: var(--bg-elevated); }

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

.sidebar-file-list {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-1);
  font-size: 0.68rem;
  color: var(--ink-secondary);
}

.sidebar-file-list span {
  padding: 2px var(--space-2);
  background: var(--bg-elevated);
  border-radius: var(--radius-xs);
  border: 1px solid var(--border);
}

/* Library / History */
.sidebar-section {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.sidebar-section-title {
  font-size: 0.62rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--ink-muted);
  margin-bottom: var(--space-2);
  font-weight: 600;
}

.history-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  overflow-y: auto;
}

.history-item {
  background: transparent;
  border: 1px solid transparent;
  border-left: 2px solid transparent;
  border-radius: var(--radius-sm);
  padding: var(--space-2) var(--space-3);
  display: flex;
  justify-content: space-between;
  gap: var(--space-2);
  cursor: pointer;
  transition: all var(--transition-fast);
}

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

.history-item.loading { cursor: default; opacity: 0.5; }
.history-item.loading:hover { background: transparent; border-color: transparent; border-left-color: transparent; }

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

.history-name {
  font-size: 0.75rem;
  color: var(--ink);
  font-family: var(--font-mono);
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 145px;
}

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

.history-actions { position: relative; display: flex; gap: var(--space-1); }

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

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

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

.history-item:hover .history-menu-btn { opacity: 1; }
.history-menu-btn:hover { background: var(--surface); color: var(--ink); }

.history-dropdown {
  position: absolute;
  top: 100%;
  right: 0;
  margin-top: var(--space-1);
  background: var(--surface-raised);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-md);
  z-index: 50;
  min-width: 100px;
  overflow: hidden;
}

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

.history-dropdown-item {
  display: block;
  width: 100%;
  padding: var(--space-2) var(--space-3);
  border: none;
  background: transparent;
  text-align: left;
  font-size: 0.75rem;
  color: var(--ink);
  cursor: pointer;
  transition: background var(--transition-fast);
}
.history-dropdown-item:hover { background: var(--bg-elevated); }
.history-dropdown-item.danger { color: #ef4444; }
.history-dropdown-item.danger:hover { background: rgba(239,68,68,0.08); }

/* Session key section — pinned to sidebar bottom */
.sidebar-session {
  flex-shrink: 0;
  padding: var(--space-3) var(--space-4) var(--space-4);
  border-top: 1px solid var(--sidebar-border);
  background: var(--sidebar);
}

.session-header {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--ink-muted);
  margin-bottom: var(--space-2);
}

.session-label {
  font-size: 0.62rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 600;
}

.session-key-row {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.session-key-value {
  flex: 1;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--ink-secondary);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  padding: 4px 7px;
  letter-spacing: 0.04em;
  user-select: all;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.session-copy-btn {
  padding: 4px 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--ink-muted);
  font-family: var(--font-sans);
  font-size: 0.62rem;
  font-weight: 500;
  border-radius: var(--radius-xs);
  cursor: pointer;
  white-space: nowrap;
  transition: all var(--transition-fast);
}
.session-copy-btn:hover { border-color: var(--accent); color: var(--accent); }
.session-copy-btn.copied { background: var(--accent); border-color: var(--accent); color: #fff; }

.session-hint {
  margin: 4px 0 0;
  font-size: 0.62rem;
  color: var(--ink-muted);
  line-height: 1.4;
}

.session-restore-btn {
  display: block;
  width: 100%;
  margin-top: var(--space-2);
  padding: 5px var(--space-2);
  border: none;
  background: transparent;
  color: var(--ink-muted);
  font-family: var(--font-sans);
  font-size: 0.68rem;
  cursor: pointer;
  border-radius: var(--radius-xs);
  text-align: left;
  transition: all var(--transition-fast);
}
.session-restore-btn:hover { background: var(--bg-elevated); color: var(--ink-secondary); }

.session-restore-box {
  margin-top: var(--space-2);
  animation: slide-down 0.15s var(--ease-out);
}
.session-restore-box.hidden { display: none; }

.session-restore-input {
  width: 100%;
  padding: 6px 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  font-family: var(--font-mono);
  font-size: 0.72rem;
  background: var(--bg-elevated);
  color: var(--ink);
  transition: border-color var(--transition-fast);
}
.session-restore-input:focus { outline: none; border-color: var(--accent); }

.session-restore-actions {
  display: flex;
  gap: var(--space-2);
  margin-top: var(--space-2);
}

.session-btn-sm {
  padding: 4px 10px;
  font-size: 0.68rem;
}

/* Cite button */
.sidebar-cite {
  margin-top: auto;
  padding-top: var(--space-3);
  border-top: 1px solid var(--border);
}

.cite-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  width: 100%;
  padding: var(--space-2) var(--space-3);
  border: none;
  background: transparent;
  color: var(--ink-muted);
  font-family: var(--font-sans);
  font-size: 0.68rem;
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: all var(--transition-fast);
}
.cite-btn:hover { background: var(--bg-elevated); color: var(--ink-secondary); }
.cite-btn svg { flex-shrink: 0; }

.cite-box {
  margin-top: var(--space-2);
  padding: var(--space-3);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  animation: slide-down 0.15s var(--ease-out);
}
.cite-box.hidden { display: none; }

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

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

.cite-text {
  font-size: 0.72rem;
  line-height: 1.5;
  color: var(--ink-secondary);
  margin-bottom: var(--space-2);
}
.cite-text em { font-style: italic; }

.cite-copy {
  padding: 4px 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--ink-muted);
  font-family: var(--font-sans);
  font-size: 0.62rem;
  font-weight: 500;
  border-radius: var(--radius-xs);
  cursor: pointer;
  transition: all var(--transition-fast);
}
.cite-copy:hover { border-color: var(--accent); color: var(--accent); }
.cite-copy.copied { background: var(--accent); border-color: var(--accent); color: #fff; }

/* =============================================
   WORKSPACE (MAIN AREA)
   ============================================= */

.workspace {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-5) var(--space-6) 100px;
  min-width: 0;
  background: var(--bg);
}

.workspace-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--space-4);
  margin-bottom: var(--space-4);
}

.workspace-header h2 {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--ink);
}

.workspace-header p {
  margin: 2px 0 0;
  color: var(--ink-muted);
  font-size: 0.78rem;
}

/* Drop zone */
.drop-zone {
  padding: var(--space-8) var(--space-6);
  border-radius: var(--radius-md);
  border: 1px dashed var(--border-strong);
  background: var(--surface);
  transition: all var(--transition-base);
  cursor: pointer;
}

.drop-zone:hover {
  border-color: var(--accent);
  background: var(--accent-dim);
  box-shadow: var(--shadow-glow);
}

.drop-zone.drag-over {
  border-color: var(--accent);
  border-style: solid;
  background: var(--accent-dim);
  box-shadow: var(--shadow-glow);
}

.drop-inner {
  display: flex;
  align-items: center;
  gap: var(--space-5);
  justify-content: center;
}

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

.drop-inner h3 {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--ink);
}

.drop-inner p {
  margin: var(--space-1) 0 0;
  color: var(--ink-muted);
  font-size: 0.78rem;
}

/* =============================================
   PROGRESS SECTION
   ============================================= */

.progress-section {
  margin: var(--space-4) 0;
  padding: var(--space-5);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
}
.progress-section.hidden { display: none; }

.progress-steps {
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: var(--space-4);
}

.progress-step {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-2);
  min-width: 72px;
}

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

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

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

.step-label {
  font-size: 0.62rem;
  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);
  box-shadow: 0 0 12px rgba(140,21,21,0.2);
}
.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: 48px;
  height: 2px;
  background: var(--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: 3px;
  background: var(--bg-elevated);
  border-radius: 2px;
}

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

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

/* Status bar */
.status-bar {
  display: none;
  align-items: center;
  gap: 10px;
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-sm);
  background: var(--surface);
  border: 1px solid var(--border);
  margin: var(--space-3) 0;
}
.status-bar.visible { display: flex; }

.status-pulse {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent);
  animation: pulse-dot 1.5s ease-in-out infinite;
  flex-shrink: 0;
}
.status-text { font-size: 0.82rem; color: var(--ink-secondary); }
.status-bar.error { background: rgba(239,68,68,0.08); border-color: rgba(239,68,68,0.2); }
.status-bar.error .status-pulse { background: #ef4444; }
.status-bar.error .status-text { color: #ef4444; }

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

/* =============================================
   CANVAS HEADER
   ============================================= */

.canvas-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  padding: 0;
  background: transparent;
  border: none;
  border-radius: 0;
}
.canvas-header.hidden { display: none; }

/* Canvas header in workspace (fallback for old layout) */
.workspace > .canvas-header {
  padding: var(--space-2) var(--space-4);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  margin-bottom: var(--space-3);
}

.canvas-info {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

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

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

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

/* =============================================
   SUMMARY
   ============================================= */

.transcript-summary {
  margin-bottom: var(--space-3);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--space-4);
}
.transcript-summary.hidden { display: none; }

.summary-header {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin-bottom: var(--space-3);
  flex-wrap: wrap;
}

.summary-header h3 {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 600;
}

.summary-badges {
  display: flex;
  gap: var(--space-2);
  flex-wrap: wrap;
  align-items: center;
}

.badge-group {
  display: flex;
  gap: var(--space-1);
  flex-wrap: wrap;
  align-items: center;
}

.badge-group:not(:empty)::before {
  content: "";
  width: 1px;
  height: 12px;
  background: var(--border);
  margin-right: var(--space-1);
}
.badge-group:first-child:not(:empty)::before { display: none; }

/* Badges — colorblind-safe colors */
#language-badges .language-badge,
.summary-badge {
  font-size: 0.62rem;
  padding: 2px 6px;
  border-radius: var(--radius-xs);
  font-family: var(--font-mono);
  font-weight: 500;
  text-transform: uppercase;
}

#language-badges .language-badge,
.language-badge {
  background: rgba(77, 184, 232, 0.1);
  color: var(--speaker-a);
}

.summary-badge.speaker-badge {
  background: rgba(77, 184, 232, 0.1);
  color: var(--speaker-a);
}

.summary-badge.emotion-badge {
  background: rgba(60, 198, 144, 0.1);
  color: var(--speaker-c);
}
.summary-badge.emotion-badge.emotion-happy {
  background: rgba(60, 198, 144, 0.1);
  color: var(--speaker-c);
}
.summary-badge.emotion-badge.emotion-sad {
  background: rgba(77, 184, 232, 0.1);
  color: var(--speaker-a);
}
.summary-badge.emotion-badge.emotion-angry {
  background: rgba(232, 128, 64, 0.1);
  color: var(--speaker-b);
}
.summary-badge.emotion-badge.emotion-neutral {
  background: rgba(130, 140, 168, 0.1);
  color: var(--ink-muted);
}

.summary-content {
  font-size: 0.85rem;
  line-height: 1.7;
  color: var(--ink-secondary);
  padding-top: var(--space-2);
  border-top: 1px solid var(--border);
  white-space: pre-line;
}

/* =============================================
   VIEW CONTROLS
   ============================================= */

.view-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  margin-bottom: var(--space-3);
  padding: var(--space-2) var(--space-3);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}
.view-controls.hidden { display: none; }

.view-toggle {
  display: flex;
  gap: 2px;
  background: var(--bg-elevated);
  padding: 2px;
  border-radius: var(--radius-sm);
}

.view-btn {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 5px var(--space-3);
  border: none;
  background: transparent;
  color: var(--ink-muted);
  font-family: var(--font-sans);
  font-size: 0.72rem;
  font-weight: 500;
  border-radius: var(--radius-xs);
  cursor: pointer;
  transition: all var(--transition-fast);
}
.view-btn:hover { color: var(--ink-secondary); }
.view-btn.active { background: var(--surface-raised); color: var(--ink); box-shadow: var(--shadow-sm); }
.view-btn svg { flex-shrink: 0; }

.translation-toggle {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  cursor: pointer;
  font-size: 0.72rem;
  color: var(--ink-muted);
  user-select: none;
  padding: 4px 8px;
  border-radius: var(--radius-xs);
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  transition: all var(--transition-fast);
}
.translation-toggle:hover { border-color: var(--border-strong); color: var(--ink-secondary); }
.translation-toggle input[type="checkbox"] {
  accent-color: var(--accent);
  margin: 0;
  cursor: pointer;
}
.translation-toggle.active {
  border-color: var(--accent);
  background: var(--accent-dim);
  color: var(--accent);
}

.highlight-selector {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}
.highlight-selector label {
  font-size: 0.72rem;
  color: var(--ink-muted);
  white-space: nowrap;
}
.highlight-selector select {
  padding: 5px 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  background: var(--bg-elevated);
  font-family: var(--font-sans);
  font-size: 0.75rem;
  color: var(--ink);
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  padding-right: 24px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%23525a72'%3E%3Cpath d='M2 4l4 4 4-4'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 6px center;
}
.highlight-selector select:focus { outline: none; border-color: var(--accent); }

/* =============================================
   TRANSCRIPT — FLOW & BOX MODES
   ============================================= */

.transcript {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.transcript.flow-mode { gap: 0; }

.transcript.flow-mode .flow-container {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--space-5) var(--space-6);
  font-family: var(--font-sans);
  font-size: 1rem;
  line-height: 2;
}

.flow-chunk {
  display: inline;
  padding: 2px 4px;
  margin: 0 1px;
  border-radius: 3px;
  cursor: pointer;
  position: relative;
  transition: all var(--transition-fast);
}
.flow-chunk:hover { filter: brightness(1.15); }
.flow-chunk.active { outline: 2px solid var(--accent); outline-offset: 0; }
.flow-chunk.editing {
  display: inline-block;
  outline: 2px solid var(--accent);
  outline-offset: 1px;
  background: var(--bg-elevated) !important;
  color: var(--ink);
  filter: none;
  min-width: 2ch;
  cursor: text;
  caret-color: var(--ink);
  -webkit-caret-color: var(--ink);
}
.flow-chunk.editing:focus {
  outline: 2px solid var(--accent);
  caret-color: var(--ink);
  -webkit-caret-color: var(--ink);
}

/* Tooltip */
.flow-chunk[data-tooltip]:hover::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
  padding: 5px 10px;
  background: var(--surface-raised);
  color: var(--ink);
  font-size: 0.68rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  white-space: nowrap;
  z-index: 100;
  pointer-events: none;
  box-shadow: var(--shadow-md);
}

/* Box mode segments */
.segment {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 3px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--space-4);
  transition: all var(--transition-fast);
}
.segment:hover { border-left-color: var(--ink-muted); background: var(--bg-elevated); }
.segment.selected { border-left-color: var(--accent); background: var(--accent-dim); }

.segment-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2);
  margin-bottom: var(--space-2);
}

/* Colorblind-safe speaker badges */
.speaker-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: var(--radius-xs);
  font-size: 0.62rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.speaker-badge::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}

.speaker-0 { background: rgba(77,184,232,0.12); color: #4db8e8; }
.speaker-1 { background: rgba(232,128,64,0.12); color: #e88040; }
.speaker-2 { background: rgba(60,198,144,0.12); color: #3cc690; }
.speaker-3 { background: rgba(204,121,167,0.12); color: #CC79A7; }
.speaker-4 { background: rgba(230,159,0,0.12); color: #E69F00; }

/* Language badge */
.language-badge {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 2px 6px;
  border-radius: var(--radius-xs);
  font-size: 0.58rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  background: rgba(77,184,232,0.08);
  color: #4db8e8;
  border: 1px solid rgba(77,184,232,0.15);
  font-family: var(--font-mono);
  margin-left: var(--space-2);
}

/* Emotion indicator — colorblind-safe */
.emotion-indicator {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 2px 6px;
  border-radius: var(--radius-xs);
  font-size: 0.58rem;
  font-weight: 500;
  text-transform: capitalize;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  margin-left: var(--space-2);
  font-family: var(--font-mono);
}
.emotion-happy  { background: rgba(60,198,144,0.08); color: #3cc690; border-color: rgba(60,198,144,0.2); }
.emotion-sad    { background: rgba(77,184,232,0.08); color: #4db8e8; border-color: rgba(77,184,232,0.2); }
.emotion-angry  { background: rgba(232,128,64,0.08); color: #e88040; border-color: rgba(232,128,64,0.2); }
.emotion-neutral { background: rgba(130,140,168,0.08); color: #828ca8; border-color: rgba(130,140,168,0.2); }

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

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

.segment-text-block { display: inline; }

.segment-translation {
  margin-top: var(--space-2);
  padding-top: var(--space-2);
  border-top: 1px dashed var(--border);
  font-size: 0.82rem;
  line-height: 1.6;
  color: var(--ink-muted);
  font-style: italic;
}
.segment-translation::before {
  content: "Translation: ";
  font-weight: 600;
  color: var(--ink-secondary);
  font-style: normal;
}

/* Clickable words */
.word {
  padding: 1px 3px;
  margin: 0 1px;
  border-radius: 3px;
  cursor: pointer;
  display: inline-block;
  transition: all var(--transition-fast);
}
.word:hover { background: var(--accent); color: #fff; }
.word.playing { background: var(--accent-subtle); color: var(--accent); }
.word.editing {
  background: var(--bg-elevated);
  color: var(--ink);
  outline: 2px solid var(--accent);
  box-shadow: 0 0 12px rgba(140,21,21,0.2);
  caret-color: var(--ink);
}
.word.editing:focus { outline: 2px solid var(--accent); caret-color: var(--ink); }

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

.player-bar {
  position: fixed;
  bottom: 0;
  left: var(--sidebar-width);
  right: 0;
  background: linear-gradient(180deg, transparent 0%, var(--bg) 30%);
  padding: var(--space-5) var(--space-5) var(--space-3);
  transform: translateY(100%);
  transition: transform 0.3s var(--ease-out), left var(--transition-slow);
  z-index: 120;
}
.player-bar.visible { transform: translateY(0); }
.shell.sidebar-collapsed ~ .player-bar,
.shell.sidebar-collapsed + .player-bar { left: 0; }

.player-inner {
  max-width: 700px;
  margin: 0 auto;
  background: var(--surface-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 8px var(--space-4);
  display: flex;
  align-items: center;
  gap: var(--space-3);
  box-shadow: var(--shadow-lg);
}

.player-btn {
  background: transparent;
  border: none;
  color: var(--ink-secondary);
  cursor: pointer;
  padding: var(--space-1);
  border-radius: var(--radius-sm);
  transition: all var(--transition-fast);
  display: flex;
  align-items: center;
  justify-content: center;
}
.player-btn:hover { color: var(--ink); background: rgba(0,0,0,0.05); }

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

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

.progress-bg {
  width: 100%;
  height: 3px;
  background: var(--border);
  border-radius: 2px;
  overflow: hidden;
  transition: height 0.15s ease;
}
.player-progress:hover .progress-bg { height: 5px; }

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

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

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

.speed-btn {
  min-width: 34px;
  height: 24px;
  padding: 0 5px;
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  border-radius: var(--radius-xs);
  color: var(--ink-muted);
  font-family: var(--font-mono);
  font-size: 0.65rem;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition-fast);
}
.speed-btn:hover { border-color: var(--border-strong); color: var(--ink); }

.speed-menu {
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--surface-raised);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg);
  z-index: 200;
  min-width: 56px;
  overflow: hidden;
}
.speed-menu.hidden { display: none; }

.speed-option {
  display: block;
  width: 100%;
  padding: 6px 12px;
  border: none;
  background: transparent;
  color: var(--ink-secondary);
  font-family: var(--font-mono);
  font-size: 0.78rem;
  text-align: center;
  cursor: pointer;
  transition: background var(--transition-fast);
}
.speed-option:hover { background: var(--bg-elevated); color: var(--ink); }
.speed-option.active { background: var(--accent-dim); color: var(--accent); font-weight: 600; }

/* Skip buttons */
#skip-back, #skip-forward { opacity: 0.6; }
#skip-back:hover, #skip-forward:hover { opacity: 1; }

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

/* =============================================
   MODALS
   ============================================= */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.25);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  backdrop-filter: blur(8px);
}
.modal-overlay.hidden { display: none; }

.modal {
  background: var(--surface-raised);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  max-width: 420px;
  width: 90%;
  animation: modal-appear 0.2s var(--ease-out);
}

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

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--space-4) var(--space-5);
  border-bottom: 1px solid var(--border);
}
.modal-header h3 { margin: 0; font-size: 1rem; font-weight: 600; }

.modal-close {
  background: none;
  border: none;
  font-size: 1.25rem;
  color: var(--ink-muted);
  cursor: pointer;
  padding: var(--space-1);
  transition: color var(--transition-fast);
}
.modal-close:hover { color: var(--ink); }

.modal-body { padding: var(--space-5); }

.form-group { margin-bottom: var(--space-4); }
.form-group:last-child { margin-bottom: 0; }
.form-group label {
  display: block;
  margin-bottom: var(--space-2);
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--ink-secondary);
}
.form-group select,
.form-group input {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: var(--font-sans);
  font-size: 0.85rem;
  background: var(--bg-elevated);
  color: var(--ink);
}
.form-group select:focus,
.form-group input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-dim);
}
.form-group select option {
  background: var(--surface-raised);
  color: var(--ink);
}
.form-hint {
  display: block;
  margin-top: 3px;
  font-size: 0.72rem;
  color: var(--ink-faint, #999);
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-5);
  border-top: 1px solid var(--border);
  background: var(--bg-elevated);
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}

/* Password modal */
/* ── Auth Overlay ── */
.auth-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: none;
  align-items: center;
  justify-content: center;
  background: var(--bg, #f5f5f4);
}
.auth-overlay.visible { display: flex; }

.auth-card {
  width: 100%;
  max-width: 380px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 32px 28px 24px;
  box-shadow: 0 8px 30px rgba(0,0,0,0.08);
}

.auth-title {
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--ink);
  margin: 0 0 4px;
}

.auth-subtitle {
  font-size: 0.82rem;
  color: var(--ink-secondary);
  margin: 0 0 20px;
}

.auth-card .form-group { margin-bottom: 14px; }

.auth-error {
  color: #ef4444;
  font-size: 0.8rem;
  margin: 0 0 10px;
  padding: 8px 10px;
  background: #fef2f2;
  border: 1px solid #fecaca;
  border-radius: var(--radius-sm);
}
.auth-error.hidden { display: none; }

.auth-submit {
  width: 100%;
  padding: 10px;
  font-size: 0.9rem;
  font-weight: 600;
  margin-top: 4px;
}

.auth-switch {
  text-align: center;
  font-size: 0.8rem;
  color: var(--ink-secondary);
  margin: 16px 0 0;
}

.auth-switch-btn {
  background: none;
  border: none;
  color: var(--accent);
  font-weight: 600;
  cursor: pointer;
  font-size: 0.8rem;
  padding: 0;
}
.auth-switch-btn:hover { text-decoration: underline; }

/* ── Segment Context Menu ── */
.ctx-menu {
  position: fixed;
  z-index: 10000;
  min-width: 200px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: 0 8px 24px rgba(0,0,0,0.14);
  padding: 6px 0;
  font-size: 0.8rem;
}
.ctx-menu.hidden { display: none; }

.ctx-group { padding: 6px 12px; }
.ctx-label { font-size: 0.68rem; font-weight: 600; color: var(--ink-secondary); text-transform: uppercase; letter-spacing: 0.04em; margin-bottom: 4px; }

.ctx-input {
  width: 100%;
  padding: 5px 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: var(--font-sans);
  font-size: 0.8rem;
  background: var(--bg);
  color: var(--ink);
}
.ctx-input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-dim); }

.ctx-options { display: flex; gap: 4px; flex-wrap: wrap; }
.ctx-option {
  padding: 3px 10px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--bg);
  color: var(--ink);
  font-size: 0.75rem;
  cursor: pointer;
  transition: all 0.1s;
}
.ctx-option:hover { border-color: var(--accent); color: var(--accent); }
.ctx-option.selected { background: var(--accent); color: #fff; border-color: var(--accent); }

.ctx-divider { height: 1px; background: var(--border); margin: 4px 0; }

.ctx-action {
  display: block;
  width: 100%;
  text-align: left;
  padding: 6px 12px;
  background: none;
  border: none;
  font-size: 0.8rem;
  color: #ef4444;
  cursor: pointer;
}
.ctx-action:hover { background: #fef2f2; }

/* Export dropdown */
.export-dropdown { position: relative; }
.export-dropdown .btn-secondary { gap: 5px; padding: 5px 10px; font-size: 0.75rem; }

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

.export-menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  background: var(--surface-raised);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg);
  min-width: 200px;
  z-index: 100;
  overflow: hidden;
  animation: slide-down 0.15s var(--ease-out);
}
.export-menu.hidden { display: none; }

.export-option {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  width: 100%;
  padding: var(--space-3) var(--space-4);
  border: none;
  background: transparent;
  cursor: pointer;
  text-align: left;
  transition: background var(--transition-fast);
}
.export-option:hover { background: var(--bg-elevated); }
.export-option:not(:last-child) { border-bottom: 1px solid var(--border); }

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

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

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

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

.shortcuts-content {
  background: var(--surface-raised);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  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: var(--space-4) var(--space-5);
  border-bottom: 1px solid var(--border);
}
.shortcuts-header h3 { margin: 0; font-size: 1rem; font-weight: 600; }

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

.shortcuts-group h4 {
  margin: 0 0 var(--space-2);
  font-size: 0.62rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--ink-muted);
  font-weight: 600;
}

.shortcut {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-1) 0;
}

.shortcut kbd {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 22px;
  height: 22px;
  padding: 0 var(--space-2);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  font-family: var(--font-mono);
  font-size: 0.62rem;
  color: var(--ink-secondary);
}

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

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

.waveform-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  margin: 0 calc(-1 * var(--space-2)) var(--space-4);
  overflow: hidden;
  position: sticky;
  top: 0;
  z-index: 20;
}
.waveform-panel.collapsed .waveform-canvas-container { display: none; }
.waveform-panel.collapsed .waveform-text-tier { display: none; }
.waveform-panel.collapsed #waveform-collapse svg { transform: rotate(180deg); }

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

.waveform-tabs { display: flex; gap: 0; }

.waveform-tab {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-3);
  border: none;
  border-bottom: 2px solid transparent;
  background: transparent;
  color: var(--ink-muted);
  font-family: var(--font-sans);
  font-size: 0.72rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition-fast);
}
.waveform-tab:hover { color: var(--ink); }
.waveform-tab.active { color: var(--ink); border-bottom-color: var(--accent); }

.waveform-controls { display: flex; gap: var(--space-1); }

.waveform-ctrl-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: var(--radius-xs);
  color: var(--ink-muted);
  cursor: pointer;
  transition: all var(--transition-fast);
}
.waveform-ctrl-btn:hover { border-color: var(--border-strong); color: var(--ink); }
.waveform-ctrl-btn.active { background: var(--accent-dim); border-color: var(--accent); color: var(--accent); }

/* CSS Tooltips for toolbar buttons */
.waveform-ctrl-btn[data-tip] {
  position: relative;
}
.waveform-ctrl-btn[data-tip]::after {
  content: attr(data-tip);
  position: absolute;
  top: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
  padding: 4px 8px;
  background: var(--ink);
  color: var(--bg);
  font-size: 0.62rem;
  font-family: var(--font-sans);
  font-weight: 500;
  white-space: nowrap;
  border-radius: 4px;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.15s;
  z-index: 300;
}
.waveform-ctrl-btn[data-tip]:hover::after {
  opacity: 1;
}

.waveform-canvas-container {
  position: relative;
  height: 240px;
  background: #ffffff;
  overflow: hidden;
}

#waveform-canvas,
#spectrogram-canvas {
  position: absolute;
  top: 0; left: 0;
  width: 100%;
  height: calc(100% - 24px);
  z-index: 1;
}
#spectrogram-canvas { z-index: 2; }
#spectrogram-canvas.hidden,
#waveform-canvas.hidden { display: none; }

.waveform-playhead {
  position: absolute;
  top: 0;
  bottom: 20px;
  width: 2px;
  background: var(--accent);
  z-index: 50;
  pointer-events: none;
  left: 0;
  box-shadow: 0 0 8px rgba(140,21,21,0.4);
}
.waveform-playhead::before {
  content: "";
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 8px;
  height: 8px;
  background: var(--accent);
  border-radius: 0 0 2px 2px;
}

.waveform-segments {
  position: absolute;
  top: 0; left: 0; right: 0;
  bottom: 24px;
  pointer-events: none;
  z-index: 10;
}

.waveform-segment {
  position: absolute;
  top: 0; bottom: 0;
  background: rgba(0,0,0,0.02);
  border-left: 1px solid rgba(0,0,0,0.12);
  border-right: 1px solid rgba(0,0,0,0.12);
  pointer-events: auto;
  cursor: pointer;
  transition: background 0.1s ease;
}
.waveform-segment:hover { background: rgba(0,0,0,0.06); border-color: var(--accent); }
.waveform-segment:nth-child(odd) { background: rgba(140,21,21,0.04); }
.waveform-segment:nth-child(odd):hover { background: rgba(140,21,21,0.08); }

.waveform-segment-label { display: none; }
.waveform-segment-text { display: none; }

/* ── Text tier below spectrogram/waveform (Praat-style) ── */
.waveform-text-tier {
  position: relative;
  height: 34px;
  background: var(--surface);
  border-top: 1px solid var(--border);
  overflow: hidden;
  user-select: none;
  flex-shrink: 0;
}
.waveform-text-tier:empty { display: none; }

.tier-cell {
  position: absolute;
  top: 0; bottom: 0;
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 0 5px;
  border-right: 1px solid var(--border);
  font-size: 0.68rem;
  font-weight: 500;
  color: var(--ink-muted, #555);
  overflow: hidden;
  cursor: pointer;
  transition: background 0.1s ease;
}
.tier-cell:first-child { border-left: 1px solid var(--border); }
.tier-cell:hover { background: rgba(140,21,21,0.06); }
.tier-cell:nth-child(odd) { background: rgba(140,21,21,0.02); }
.tier-cell:nth-child(odd):hover { background: rgba(140,21,21,0.08); }

.tier-speaker {
  font-size: 0.52rem;
  font-weight: 600;
  color: #fff;
  background: rgba(140,21,21,0.72);
  padding: 1px 5px;
  border-radius: 3px;
  flex-shrink: 0;
  white-space: nowrap;
}

.tier-text {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}
.tier-cell:hover .tier-text {
  white-space: normal;
  word-break: break-word;
}

.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(0,0,0,0.1); }

.waveform-time-ruler {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  height: 24px;
  background: var(--bg-subtle);
  border-top: 1px solid var(--border);
  z-index: 60;
}

.waveform-time-mark {
  position: absolute;
  bottom: 0;
  color: var(--ink-muted);
  font-family: var(--font-mono);
  font-size: 0.58rem;
  transform: translateX(-50%);
}

.waveform-separator {
  width: 1px;
  height: 18px;
  background: var(--border);
  margin: 0 4px;
}

/* Spectrogram settings popover */
.spectrogram-settings-wrap {
  position: relative;
}

.spectrogram-settings-panel {
  position: absolute;
  top: 100%;
  right: 0;
  margin-top: 6px;
  z-index: 200;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: 0 4px 16px rgba(0,0,0,0.12);
  padding: 10px 14px;
  width: 220px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.spectrogram-settings-panel.hidden { display: none; }

.spect-setting label {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 0.68rem;
  font-family: var(--font-sans);
  color: var(--ink-muted);
  white-space: nowrap;
}
.spect-setting label span {
  font-weight: 600;
  color: var(--ink);
  min-width: 28px;
  text-align: right;
}
.spect-setting input[type="range"] {
  width: 100%;
  height: 4px;
  accent-color: var(--accent);
  margin-top: 2px;
}
.spect-setting input[type="checkbox"] {
  accent-color: var(--accent);
}

/* Timestamp editor */
.timestamp-editor {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 6px;
  background: var(--surface-raised);
  border: 2px solid var(--accent);
  border-radius: var(--radius-sm);
  box-shadow: 0 0 12px rgba(140,21,21,0.15);
}

.timestamp-input {
  width: 68px;
  padding: 3px 5px;
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  font-family: var(--font-mono);
  font-size: 0.72rem;
  text-align: center;
  background: var(--bg-elevated);
  color: var(--ink);
}
.timestamp-input:focus { outline: none; border-color: var(--accent); }

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

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

.timestamp-action-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border: none;
  border-radius: var(--radius-xs);
  cursor: pointer;
  transition: all var(--transition-fast);
}
.timestamp-action-btn.save { background: var(--accent); color: #fff; }
.timestamp-action-btn.save:hover { background: var(--accent-hover); }
.timestamp-action-btn.cancel { background: var(--bg-elevated); color: var(--ink-muted); }
.timestamp-action-btn.cancel:hover { background: var(--border); color: var(--ink); }

.segment-time.editable {
  cursor: pointer;
  padding: 2px 5px;
  border-radius: var(--radius-xs);
  transition: all var(--transition-fast);
}
.segment-time.editable:hover { background: var(--accent-dim); color: var(--accent); }
.segment-time.editing { background: transparent; }

/* Auto-scroll */
.auto-scroll-indicator {
  position: fixed;
  bottom: 90px;
  right: 20px;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  background: var(--surface-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-md);
  font-size: 0.72rem;
  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: 6px; height: 6px; border-radius: 50%; background: var(--accent); }
.auto-scroll-indicator.paused .auto-scroll-dot { background: var(--ink-muted); }

/* Selection region */
.waveform-selection {
  position: absolute;
  top: 0; bottom: 24px;
  background: rgba(140,21,21,0.1);
  border-left: 2px solid var(--accent);
  border-right: 2px solid var(--accent);
  display: none;
  z-index: 15;
  cursor: grab;
}
.waveform-selection.active { display: block; }

/* Word boundaries */
.waveform-words { position: absolute; top: 0; bottom: 24px; left: 0; right: 0; z-index: 8; }
.waveform-word {
  position: absolute;
  top: 0; bottom: 0;
  border-left: 1px dashed rgba(0,0,0,0.15);
  border-right: 1px dashed rgba(0,0,0,0.15);
  background: transparent;
  cursor: pointer;
}
.waveform-word:hover { background: rgba(0,0,0,0.04); }
.waveform-word.selected { background: rgba(140,21,21,0.1); border-color: var(--accent); }

.waveform-word-label {
  position: absolute;
  bottom: 28px; left: 50%;
  transform: translateX(-50%);
  background: var(--surface);
  color: var(--ink);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  font-size: 9px;
  font-family: var(--font-mono);
  padding: 2px 4px;
  border-radius: 3px;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
}
.waveform-word:hover .waveform-word-label,
.waveform-word.selected .waveform-word-label { opacity: 1; }

.waveform-word-handle {
  position: absolute;
  top: 0; bottom: 0;
  width: 6px;
  cursor: ew-resize;
  z-index: 20;
}
.waveform-word-handle.left { left: -3px; }
.waveform-word-handle.right { right: -3px; }
.waveform-word-handle:hover::after {
  content: "";
  position: absolute;
  top: 0; bottom: 0;
  left: 50%; width: 2px;
  transform: translateX(-50%);
  background: var(--accent);
}

.waveform-cursor-info {
  position: absolute;
  top: 6px; right: 6px;
  background: var(--surface);
  color: var(--ink-secondary);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  padding: 4px 8px;
  border-radius: var(--radius-xs);
  font-size: 10px;
  font-family: var(--font-mono);
  display: flex;
  gap: 10px;
  z-index: 100;
  pointer-events: none;
}

.waveform-freq-axis {
  position: absolute;
  left: 0; top: 0; bottom: 24px;
  width: 36px;
  background: var(--bg-subtle);
  border-right: 1px solid var(--border);
  display: none;
  padding: 0 2px;
  font-size: 8px;
  font-family: var(--font-mono);
  color: var(--ink-muted);
  z-index: 50;
  pointer-events: none;
}
.waveform-panel[data-view="spectrogram"] .waveform-freq-axis,
.waveform-panel[data-view="both"] .waveform-freq-axis { display: block; }

.freq-mark {
  text-align: right;
  padding-right: 3px;
  line-height: 1;
  white-space: nowrap;
}

/* IPA Picker */
.ipa-picker {
  position: fixed;
  bottom: 90px; right: 16px;
  width: 340px;
  max-height: 380px;
  background: var(--surface-raised);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  z-index: 1000;
  overflow: hidden;
}
.ipa-picker.hidden { display: none; }

.ipa-picker-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--space-2) var(--space-3);
  border-bottom: 1px solid var(--border);
  font-weight: 600;
  font-size: 0.82rem;
}

.ipa-picker-close {
  background: none;
  border: none;
  font-size: 18px;
  color: var(--ink-muted);
  cursor: pointer;
  transition: color var(--transition-fast);
}
.ipa-picker-close:hover { color: var(--ink); }

.ipa-picker-tabs {
  display: flex;
  border-bottom: 1px solid var(--border);
}

.ipa-tab {
  flex: 1;
  padding: 6px 10px;
  background: none;
  border: none;
  font-size: 0.68rem;
  color: var(--ink-muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: all var(--transition-fast);
}
.ipa-tab:hover { color: var(--ink); background: var(--bg-elevated); }
.ipa-tab.active { color: var(--accent); border-bottom-color: var(--accent); }

.ipa-picker-grid {
  display: grid;
  grid-template-columns: repeat(10, 1fr);
  gap: 3px;
  padding: var(--space-2);
  max-height: 260px;
  overflow-y: auto;
}

.ipa-char {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  font-size: 14px;
  font-family: "Doulos SIL", "Charis SIL", "Gentium Plus", "DejaVu Sans", sans-serif;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  cursor: pointer;
  color: var(--ink);
  transition: all var(--transition-fast);
}
.ipa-char:hover { background: var(--accent-dim); border-color: var(--accent); transform: scale(1.1); }
.ipa-char:active { transform: scale(0.95); }

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

@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { border-right: none; border-bottom: 1px solid var(--border); max-height: 50vh; }
  .player-bar { left: 0; }
  .waveform-panel { margin: 0 var(--space-2) var(--space-2); border-radius: var(--radius-sm); }
  .shortcuts-body { grid-template-columns: 1fr; }
  .toolbar { display: none; }
  .search-trigger { min-width: auto; }
}

@media (max-width: 600px) {
  .player-inner { padding: 6px 10px; gap: 6px; }
  #skip-back, #skip-forward { display: none; }
  .waveform-canvas-container { height: 150px; }
  .search-dialog { width: 95vw; }
}
