/* IMI Library — Review UI */
/* Design tokens match the pipeline GUI for visual consistency */

:root {
  --bg: #14110e;
  --bg2: #1e1914;
  --bg3: #271f17;
  --gold: #c9a04a;
  --gold-light: #e8c97a;
  --cream: #f2e8d8;
  --muted: #8a7a68;
  --border: rgba(201,160,74,0.2);
  --green: #6b8f71;
  --green-light: #a0d4a8;
  --red: #c45050;
  --red-light: #e08080;
  --blue: #4a7fa5;
}

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

/* Scrollbar styling */
* {
  scrollbar-width: thin;
  scrollbar-color: rgba(201,160,74,0.25) transparent;
}
*::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
*::-webkit-scrollbar-track {
  background: transparent;
}
*::-webkit-scrollbar-thumb {
  background: rgba(201,160,74,0.25);
  border-radius: 3px;
}
*::-webkit-scrollbar-thumb:hover {
  background: rgba(201,160,74,0.45);
}

html {
  overflow-y: scroll;
}
body {
  background: var(--bg);
  color: var(--cream);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  font-weight: 400;
  line-height: 1.6;
  min-height: 100vh;
}

.app-container {
  max-width: 960px;
  margin: 0 auto;
  padding: 0 24px;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Header */
.app-header {
  padding: 48px 0 32px;
  border-bottom: 1px solid var(--border);
}
.app-label {
  font-size: 11px;
  letter-spacing: 0.25em;
  text-transform: uppercase;
  color: var(--gold);
  font-weight: 600;
  margin-bottom: 6px;
}
.app-header h1 {
  font-size: 32px;
  font-weight: 700;
  line-height: 1.2;
  color: var(--cream);
  margin-bottom: 8px;
}
.gold { color: var(--gold-light); }
.app-sub {
  font-size: 14px;
  color: var(--muted);
  max-width: 500px;
}

/* Tabs */
.tabs {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--border);
  margin-top: 20px;
}
.tab {
  padding: 12px 24px;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--muted);
  font-size: 14px;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.2s;
}
.tab:hover { color: var(--cream); }
.tab.active {
  color: var(--gold-light);
  border-bottom-color: var(--gold);
}
.tab.disabled {
  color: var(--muted);
  opacity: 0.35;
  cursor: not-allowed;
}

/* Main */
.app-main {
  flex: 1;
  padding: 24px 0;
}

/* Views */
.view { display: none; }
.view.active { display: block; }
.app-main { min-height: 400px; }

/* Queue Header */
.queue-header {
  margin-bottom: 20px;
}
.queue-progress {
  font-size: 13px;
  color: var(--muted);
}

/* Recording Info Bar */
.recording-info {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: var(--bg3);
  border-radius: 8px;
  margin-bottom: 20px;
}
.recording-filename {
  font-size: 13px;
  font-weight: 600;
  color: var(--cream);
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.recording-duration {
  font-size: 12px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.mp3-link {
  font-size: 12px;
  color: var(--blue);
  text-decoration: none;
}
.mp3-link:hover { text-decoration: underline; }
.nav-controls {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}
.btn-nav {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--cream);
  font-size: 18px;
  font-family: inherit;
  cursor: pointer;
  line-height: 1;
  padding: 0;
}
.btn-nav:hover:not(:disabled) { border-color: var(--gold); color: var(--gold-light); }
.btn-nav:disabled { opacity: 0.3; cursor: not-allowed; }
.btn-nav-remove {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--cream);
  font-size: 11px;
  font-family: inherit;
  padding: 4px 10px;
  cursor: pointer;
  margin-left: 6px;
  white-space: nowrap;
}
.btn-nav-remove:hover:not(:disabled) { border-color: var(--gold); color: var(--gold-light); }
.btn-nav-remove:disabled { opacity: 0.3; cursor: not-allowed; }
.btn-sm { padding: 6px 12px; font-size: 12px; }
.queue-position {
  font-size: 11px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  min-width: 50px;
  text-align: center;
}
.btn-delete {
  padding: 4px 12px;
  background: none;
  border: 1px solid rgba(196,80,80,0.3);
  border-radius: 4px;
  color: var(--red);
  font-size: 11px;
  font-family: inherit;
  cursor: pointer;
  flex-shrink: 0;
}
.btn-delete:hover {
  background: rgba(196,80,80,0.15);
  border-color: var(--red);
}

/* Fieldset */
.fieldset {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
  margin-bottom: 16px;
}
.fieldset.compact {
  padding: 14px 16px;
  margin-bottom: 12px;
}
.fieldset legend {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--gold);
  padding: 0 8px;
}

/* Form elements */
.form-group {
  margin-bottom: 10px;
}
.form-row {
  display: flex;
  gap: 12px;
}
.form-group.half { flex: 1; }
.form-row-3 {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 10px;
}
.form-row-4 {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 10px;
}
.form-label {
  display: block;
  font-size: 12px;
  font-weight: 500;
  color: var(--cream);
  margin-bottom: 4px;
}
.validation-highlight { border-color: #c45050 !important; }
.form-input, .form-select, .form-textarea {
  width: 100%;
  padding: 8px 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--cream);
  font-size: 14px;
  font-family: inherit;
  outline: none;
  transition: border-color 0.2s;
}
.form-input:focus, .form-select:focus, .form-textarea:focus {
  border-color: var(--gold);
}
.form-input.sm, .form-select.sm, .form-textarea.sm {
  padding: 6px 10px;
  font-size: 13px;
}
.form-select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath d='M3 5l3 3 3-3' fill='none' stroke='%238a7a68' stroke-width='1.5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 32px;
}
.form-select option {
  background: var(--bg2);
  color: var(--cream);
}
.form-textarea {
  resize: vertical;
  min-height: 60px;
}
input[type="checkbox"] {
  accent-color: var(--gold);
  width: 16px;
  height: 16px;
  vertical-align: middle;
  margin-right: 6px;
}

/* Chapters list */
.chapters-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.chapter-item {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 10px 12px;
}
.chapter-headline-input {
  font-size: 13px;
  font-weight: 500;
  margin-bottom: 4px;
}
.chapter-summary-input {
  font-size: 12px;
  min-height: 40px;
  margin-bottom: 4px;
}
.chapter-time {
  font-size: 11px;
  color: var(--gold);
  font-variant-numeric: tabular-nums;
}

/* Quotes list */
.quotes-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.quote-item {
  background: var(--bg);
  border-left: 3px solid var(--gold);
  padding: 8px 12px;
  font-size: 13px;
  font-style: italic;
  color: var(--cream);
}
.quote-speaker {
  font-style: normal;
  font-size: 11px;
  color: var(--muted);
  margin-top: 4px;
}

/* Speaker map */
.speaker-map {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.speaker-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  background: var(--bg);
  border-radius: 6px;
}
.speaker-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--gold);
  min-width: 80px;
}
.speaker-name-input {
  flex: 1;
  padding: 6px 10px;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--cream);
  font-size: 13px;
  font-family: inherit;
  outline: none;
}
.speaker-name-input:focus { border-color: var(--gold); }
.speaker-confidence {
  font-size: 11px;
  color: var(--muted);
}

/* Autocomplete dropdown */
.autocomplete-list {
  position: absolute;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 6px;
  max-height: 200px;
  overflow-y: auto;
  z-index: 100;
  box-shadow: 0 4px 12px rgba(0,0,0,0.4);
}
.autocomplete-item {
  padding: 8px 12px;
  font-size: 13px;
  cursor: pointer;
  color: var(--cream);
}
.autocomplete-item:hover, .autocomplete-item.selected {
  background: var(--bg3);
  color: var(--gold-light);
}

/* Action buttons */
.form-actions {
  display: flex;
  gap: 10px;
  margin-top: 24px;
  margin-bottom: 16px;
}
.btn {
  padding: 12px 24px;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.2s;
}
.btn:disabled { opacity: 0.4; cursor: not-allowed; }
.btn-primary {
  background: var(--gold);
  color: var(--bg);
  font-weight: 600;
  flex: 1;
}
.btn-primary:hover:not(:disabled) { background: var(--gold-light); }
.btn-secondary {
  background: var(--bg3);
  color: var(--cream);
  border: 1px solid var(--border);
}
.btn-secondary:hover:not(:disabled) { border-color: var(--gold); }
.btn-danger {
  background: var(--bg3);
  color: var(--red);
  border: 1px solid var(--red);
}
.btn-danger:hover:not(:disabled) { background: var(--red); color: var(--cream); }
.btn-ghost {
  background: none;
  color: var(--muted);
  border: 1px solid transparent;
}
.btn-ghost:hover { color: var(--cream); border-color: var(--border); }

/* Validation error */
.validation-error {
  padding: 10px 14px;
  background: rgba(196,80,80,0.1);
  border: 1px solid rgba(196,80,80,0.3);
  border-radius: 6px;
  color: var(--red-light);
  font-size: 13px;
  margin-bottom: 12px;
}

/* Current status badge */
.current-status {
  text-align: center;
  font-size: 12px;
  color: var(--muted);
  padding: 8px;
}
.current-status .badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.badge.draft {
  background: rgba(201,160,74,0.12);
  border: 1px solid rgba(201,160,74,0.3);
  color: var(--gold);
}
.badge.published {
  background: rgba(107,143,113,0.15);
  border: 1px solid rgba(107,143,113,0.4);
  color: var(--green-light);
}

/* Queue empty state */
.queue-empty {
  text-align: center;
  padding: 60px 20px;
}
.empty-icon {
  font-size: 48px;
  color: var(--green);
  margin-bottom: 16px;
}
.queue-empty h2 {
  font-size: 20px;
  margin-bottom: 8px;
}
.queue-empty p {
  color: var(--muted);
  font-size: 14px;
}

/* Queue View */
.list-filters {
  margin-bottom: 16px;
}
.list-filters .form-input {
  margin-bottom: 10px;
}

.list-table {
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}
.list-header {
  display: grid;
  grid-template-columns: 1fr 140px 120px 30px;
  padding: 8px 12px;
  font-size: 10px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  background: var(--bg3);
  border-bottom: 1px solid var(--border);
}
.list-rows {
  max-height: 500px;
  overflow-y: auto;
}
.list-row {
  display: grid;
  grid-template-columns: 1fr 140px 120px 30px;
  padding: 8px 12px;
  font-size: 12px;
  border-bottom: 1px solid rgba(201,160,74,0.08);
  transition: background 0.15s;
  align-items: center;
}
.list-row:hover { background: var(--bg3); }
.list-row .lr-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--cream);
  cursor: pointer;
}
.list-row .lr-name:hover { color: var(--gold-light); }
.list-row .lr-date {
  color: var(--muted);
  font-size: 11px;
}
.list-header .lh-date {
  text-align: center;
  padding-right: 50px;
}
.list-row .lr-date {
  text-align: center;
  padding-right: 20px;
}
.list-header .lh-action {
  text-align: center;
  padding-right: 30px;
}
.list-row .lr-action {
  text-align: center;
}
.lh-sortable {
  cursor: pointer;
  user-select: none;
}
.lh-sortable:hover { color: var(--cream); }
.sort-arrow {
  font-size: 8px;
  opacity: 0.7;
  color: var(--cream);
  margin-left: 2px;
}
.sort-arrow.active {
  opacity: 1;
  color: var(--gold-light);
}

.list-pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  margin-top: 12px;
}
.page-info {
  font-size: 12px;
  color: var(--muted);
}

/* Chapter row (inline: time | speaker | summary) */
.chapter-row {
  display: grid;
  grid-template-columns: 70px 120px 1fr;
  gap: 6px;
  align-items: center;
  margin-bottom: 6px;
}
.chapter-time-display {
  font-size: 11px;
  color: var(--gold);
  font-variant-numeric: tabular-nums;
}
.chapter-speaker-input {
  padding: 5px 8px;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--cream);
  font-size: 12px;
  font-family: inherit;
  outline: none;
}
.chapter-speaker-input:focus { border-color: var(--gold); }
.chapter-summary-inline {
  padding: 5px 8px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--cream);
  font-size: 12px;
  font-family: inherit;
  outline: none;
}
.chapter-summary-inline:focus { border-color: var(--gold); }

/* Meta split row (dropdowns left, checkboxes right) */
.meta-row-split {
  display: flex;
  align-items: end;
  gap: 10px;
  margin-bottom: 8px;
  flex-wrap: wrap;
}
.meta-left {
  display: flex;
  gap: 10px;
  flex: 1;
  flex-wrap: wrap;
  min-width: 0;
}
.meta-left .form-group { margin-bottom: 0; flex: 1; min-width: 120px; }
.meta-right {
  display: flex;
  align-items: center;
  gap: 12px;
  padding-bottom: 4px;
  flex-shrink: 0;
}

/* Tags row */
.tags-row {
  display: flex;
  align-items: center;
  gap: 4px 10px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}
.tag-check {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 13px;
  color: var(--cream);
  cursor: pointer;
  white-space: nowrap;
}
.tag-check input[type="checkbox"] {
  width: 14px;
  height: 14px;
}
.score-key {
  font-weight: 400;
  font-size: 12px;
  color: var(--muted);
  margin-left: 4px;
}
.celebration-inline {
  max-width: 180px;
  margin-left: -4px;
}
.reviewer-inline {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-left: auto;
}
.reviewer-inline .form-label {
  margin-bottom: 0;
  white-space: nowrap;
}

/* Title label + suggestion on same line */
.title-label-row {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 4px;
}
.title-label-row .form-label { margin-bottom: 0; }
.title-suggestion {
  font-size: 11px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 60%;
}
.title-suggestion em {
  color: var(--gold);
  font-style: italic;
}
.btn-accept {
  display: inline-block;
  padding: 2px 10px;
  margin-left: 6px;
  background: var(--bg3);
  border: 1px solid var(--gold);
  border-radius: 4px;
  color: var(--gold-light);
  font-size: 11px;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  vertical-align: middle;
}
.btn-accept:hover {
  background: var(--gold);
  color: var(--bg);
}

/* Utterance Table */
.utterance-table {
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
}
.utterance-header {
  display: grid;
  grid-template-columns: 60px 60px 120px 1fr 60px;
  gap: 6px;
  padding: 8px 10px;
  font-size: 11px;
  font-weight: 600;
  color: var(--cream);
  letter-spacing: 0.03em;
  background: var(--bg3);
  border-bottom: 1px solid var(--border);
  align-items: center;
}
.utterance-rows {
  max-height: 400px;
  overflow-y: auto;
}
.utterance-row {
  display: grid;
  grid-template-columns: 60px 60px 120px 1fr 60px;
  gap: 6px;
  padding: 5px 10px;
  font-size: 12px;
  border-bottom: 1px solid rgba(201,160,74,0.06);
  align-items: start;
}
.utterance-row:nth-child(even) { background: rgba(30,25,20,0.4); }
.utterance-row.merged { background: rgba(201,160,74,0.08); }
.btn-merge {
  background: var(--bg3);
  border: 1px solid var(--gold);
  border-radius: 4px;
  color: var(--gold-light);
  font-size: 11px;
  font-weight: 500;
  font-family: inherit;
  padding: 3px 8px;
  cursor: pointer;
  white-space: nowrap;
  justify-self: end;
}
.btn-merge:hover:not(:disabled) { background: var(--gold); color: var(--bg); }
.btn-merge:disabled { opacity: 0.3; cursor: not-allowed; }
.btn-split {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--cream);
  font-size: 11px;
  font-family: inherit;
  padding: 3px 8px;
  cursor: pointer;
  white-space: nowrap;
  justify-self: end;
}
.btn-split:hover { border-color: var(--gold); color: var(--gold-light); }
.ur-merge-check {
  width: 16px;
  height: 16px;
  cursor: pointer;
  justify-self: end;
  margin-top: 2px;
}
.ur-merge-cell { width: 16px; justify-self: end; }
.utterance-loading {
  padding: 20px;
  text-align: center;
  color: var(--muted);
  font-size: 13px;
}
.ur-time {
  font-size: 11px;
  color: var(--gold);
  font-variant-numeric: tabular-nums;
  padding-top: 2px;
}
.ur-speaker-input {
  padding: 3px 6px;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 3px;
  color: var(--cream);
  font-size: 11px;
  font-family: inherit;
  outline: none;
  width: 100%;
}
.ur-speaker-input:focus { border-color: var(--gold); }
.ur-text {
  font-size: 12px;
  color: var(--cream);
  line-height: 1.5;
  cursor: pointer;
}
.ur-text.truncated {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.ur-text.expanded {
  white-space: normal;
}

/* Collapsible sections */
.collapsible {
  border: 1px solid var(--border);
  border-radius: 12px;
  margin-bottom: 12px;
  overflow: hidden;
}
.collapsible-header {
  padding: 14px 16px;
  font-size: 13px;
  font-weight: 600;
  color: var(--cream);
  cursor: pointer;
  background: var(--bg2);
  list-style: none;
}
.collapsible-header::before {
  content: "\25B6";
  font-size: 10px;
  color: var(--muted);
  transition: transform 0.2s;
  display: inline-block;
  margin-right: 10px;
}
.collapsible[open] .collapsible-header::before {
  transform: rotate(90deg);
}
.collapsible-header::-webkit-details-marker { display: none; }
.collapsible-header:hover { background: var(--bg3); }
.collapsible-count {
  font-weight: 400;
  color: var(--muted);
  margin-left: 6px;
}
.collapsible[open] .collapsible-header {
  border-bottom: 1px solid var(--border);
}
.collapsible > *:not(summary) {
  padding: 12px 16px;
}

/* Footer */
.app-footer {
  padding: 20px 0;
  border-top: 1px solid var(--border);
  font-size: 11px;
  color: var(--muted);
}

/* Loading spinner */
.loading {
  text-align: center;
  padding: 40px;
  color: var(--muted);
}

/* Toast notification */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  padding: 12px 20px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  z-index: 200;
  animation: slideIn 0.3s ease;
}
.toast.success { background: var(--green); color: #fff; }
.toast.error { background: var(--red); color: #fff; }
.toast.undo { background: var(--bg3); color: var(--cream); border: 1px solid var(--border); }
.undo-btn {
  background: var(--gold);
  color: var(--bg);
  border: none;
  border-radius: 4px;
  padding: 3px 10px;
  margin-left: 10px;
  font-size: 12px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
}
.undo-btn:hover { background: var(--gold-light); }

@keyframes slideIn {
  from { transform: translateY(20px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

/* Library Tab */
#library-view.active {
  display: flex !important;
  gap: 0;
  height: calc(100vh - 120px);
}
.library-sidebar {
  width: 280px;
  min-width: 120px;
  max-width: 500px;
  flex-shrink: 0;
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: relative;
  transition: width 0.2s ease, min-width 0.2s ease, opacity 0.2s ease;
  overflow: hidden;
}
.library-sidebar.collapsed {
  width: 0;
  min-width: 0;
  opacity: 0;
  border-right: none;
  pointer-events: none;
}
.lib-divider {
  width: 8px;
  cursor: col-resize;
  background: transparent;
  flex-shrink: 0;
  position: relative;
  transition: background 0.15s;
  display: flex;
  align-items: center;
  justify-content: center;
}
.lib-divider::after {
  content: "⋮";
  color: var(--muted);
  font-size: 14px;
  letter-spacing: 0;
  pointer-events: none;
  opacity: 0.5;
}
.lib-divider:hover, .lib-divider.dragging {
  background: rgba(201,160,74,0.15);
}
.lib-divider:hover::after, .lib-divider.dragging::after {
  color: var(--gold);
  opacity: 1;
}
.ur-speaker-label {
  font-size: 11px;
  color: var(--gold-light);
  min-width: 60px;
}
.library-detail {
  flex: 1;
  padding: 0 0 0 20px;
  overflow-y: auto;
  min-width: 0;
}
.lib-sidebar-header {
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.lib-search-wrap {
  position: relative;
}
.lib-search-wrap input {
  width: 100%;
  padding-right: 28px;
}
.lib-search-clear {
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  color: var(--muted);
  font-size: 16px;
  cursor: pointer;
  padding: 2px 4px;
  line-height: 1;
}
.lib-search-clear:hover { color: var(--cream); }
.lib-result-count {
  font-size: 11px;
  color: var(--gold);
  padding: 0 2px;
  display: none;
}
.lib-result-count.active {
  display: block;
}
.library-sidebar.filtered {
  background: rgba(201,160,74,0.03);
}
.lib-advanced-toggle {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 11px;
  cursor: pointer;
  text-align: left;
  padding: 0;
  font-family: inherit;
}
.lib-advanced-toggle:hover { color: var(--cream); }
.lib-filter-title {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--gold);
  font-weight: 600;
  margin-bottom: 4px;
}
.lib-sort-options {
  display: flex;
  gap: 4px;
}
.lib-sort-btn {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--muted);
  font-size: 11px;
  font-family: inherit;
  cursor: pointer;
  padding: 4px 8px;
  display: flex;
  align-items: center;
  gap: 4px;
  transition: border-color 0.15s, color 0.15s;
}
.lib-sort-btn:hover { color: var(--cream); border-color: var(--gold); }
.lib-sort-btn.active { color: var(--gold-light); border-color: var(--gold); }
.lib-sort-arrow {
  font-size: 8px;
  opacity: 0.4;
}
.lib-sort-btn.active .lib-sort-arrow { opacity: 1; }
.lib-sort-bar {
  padding: 6px 12px;
  border-bottom: 1px solid var(--border);
}
.lib-search-banner {
  background: rgba(201,160,74,0.15);
  border: 1px solid var(--gold);
  border-radius: 6px;
  color: var(--gold-light);
  padding: 10px 16px;
  margin-bottom: 12px;
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  gap: 8px;
}
.lib-search-banner-title {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 0.02em;
  white-space: nowrap;
  flex: 1;
}
.lib-search-banner .btn {
  flex-shrink: 0;
  flex-grow: 0;
}
.lib-sort-options { flex-wrap: wrap; }
/* Narrow sidebar: hide duration, stack sort buttons */
.sidebar-narrow .lib-row-duration { display: none; }
.sidebar-narrow .lib-sort-options { flex-direction: column; }
.sidebar-narrow .lib-sort-btn { width: 100%; }
.lib-sidebar-list {
  flex: 1;
  overflow-y: auto;
}
.lib-rows {
  flex: 1;
  overflow-y: auto;
}
.lib-row {
  padding: 8px 12px;
  font-size: 12px;
  cursor: pointer;
  border-bottom: 1px solid rgba(201,160,74,0.08);
  transition: background 0.15s;
}
.lib-row:hover { background: var(--bg3); }
.lib-row.active { background: var(--bg3); border-left: 2px solid var(--gold); }
.lib-row-name {
  color: var(--cream);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.lib-row-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 2px;
}
.lib-row-date {
  font-size: 10px;
  color: var(--muted);
}
.lib-row-duration {
  font-size: 10px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.lib-sidebar-footer {
  padding: 8px 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-top: 1px solid var(--border);
}
.lib-pagination {
  display: flex;
  align-items: center;
  gap: 2px;
  font-size: 12px;
}
.lib-pagination button {
  min-width: 28px;
  height: 28px;
  padding: 0 4px;
  background: none;
  border: 1px solid transparent;
  border-radius: 4px;
  color: var(--muted);
  font-size: 12px;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.lib-pagination button:hover:not(:disabled) {
  background: var(--bg3);
  color: var(--cream);
}
.lib-pagination button.active {
  background: var(--gold);
  color: var(--bg);
  font-weight: 600;
  border-color: var(--gold);
}
.lib-pagination button:disabled {
  opacity: 0.3;
  cursor: default;
}
.lib-pagination .page-ellipsis {
  color: var(--muted);
  padding: 0 2px;
}
.lib-collapse-btn {
  position: absolute;
  bottom: 8px;
  right: -12px;
  width: 24px;
  height: 24px;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 50%;
  color: var(--muted);
  font-size: 10px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1;
}
.lib-collapse-btn:hover { color: var(--cream); border-color: var(--gold); }
.lib-expand-btn {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--muted);
  font-size: 12px;
  cursor: pointer;
  padding: 8px 4px;
  align-self: flex-start;
  margin-top: 12px;
}
.lib-expand-btn:hover { color: var(--cream); border-color: var(--gold); }
.lib-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 300px;
  text-align: center;
}
.lib-actions-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 0 16px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 16px;
}
.lib-actions-bar .recording-filename { flex: 1; }
.lib-edit-controls {
  display: flex;
  gap: 8px;
}

/* Responsive */
@media (max-width: 600px) {
  .app-header { padding: 32px 0 24px; }
  .app-header h1 { font-size: 26px; }
  .form-row { flex-direction: column; gap: 0; }
  .form-actions { flex-direction: column; }
  .recording-info { flex-direction: column; align-items: flex-start; }
}
