.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 12px;
  background: var(--toolbar-bg);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  gap: 8px;
  min-height: 42px;
}

.toolbar-left {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.toolbar-right {
  display: flex;
  align-items: center;
  gap: 10px;
  overflow: hidden;
  flex-shrink: 0;
}

.toolbar-btn {
  position: relative;
  background: none;
  border: 1px solid var(--border);
  border-radius: 5px;
  color: var(--text-secondary);
  font-size: 12px;
  font-family: var(--font-sans);
  padding: 4px 11px;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s, background 0.15s;
  white-space: nowrap;
}

.toolbar-btn:hover:not(:disabled) {
  color: var(--text-primary);
  border-color: var(--text-muted);
}

.toolbar-btn.active {
  border-color: var(--accent);
  color: var(--accent);
  background: rgba(167, 139, 95, 0.1);
}

.toolbar-btn:disabled {
  opacity: 0.4;
  cursor: default;
}

.toolbar-btn-clear {
  border-color: transparent;
  color: var(--text-muted);
  font-size: 11px;
}

.toolbar-btn-clear:hover:not(:disabled) {
  color: var(--text-primary);
  border-color: var(--border);
}

.toolbar-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--accent);
  color: #1a1208;
  font-size: 10px;
  font-weight: 700;
  border-radius: 8px;
  padding: 0 5px;
  min-width: 16px;
  height: 16px;
  margin-left: 6px;
}

.toolbar-dirty {
  color: var(--accent);
  font-size: 14px;
  flex-shrink: 0;
}

.toolbar-filename {
  color: var(--text-muted);
  font-size: 11px;
  font-family: var(--font-serif);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  width: 180px;
}

.toolbar-fontsize {
  display: flex;
  align-items: center;
  gap: 2px;
  flex-shrink: 0;
}

.toolbar-fontsize-btn {
  background: none;
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text-muted);
  font-size: 11px;
  font-family: var(--font-sans);
  padding: 2px 6px;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
  white-space: nowrap;
  line-height: 1.4;
}

.toolbar-fontsize-btn:hover:not(:disabled) {
  color: var(--text-primary);
  border-color: var(--text-muted);
}

.toolbar-fontsize-btn:disabled {
  opacity: 0.3;
  cursor: default;
}

.toolbar-wordcount {
  color: var(--text-muted);
  font-size: 11px;
  font-family: var(--font-sans);
  white-space: nowrap;
  flex-shrink: 0;
  cursor: default;
}

.toolbar-wordcount-sep {
  margin: 0 3px;
  opacity: 0.5;
}

.toolbar-selection-wordcount {
  color: var(--text-muted);
  font-size: 11px;
  font-family: var(--font-sans);
  white-space: nowrap;
  flex-shrink: 0;
  cursor: default;
  opacity: 0.6;
  letter-spacing: 0.02em;
}

/* ── Outline toggle button ───────────────────────────────────────── */
.toolbar-btn-outline {
  padding: 4px 8px;
  font-size: 14px;
  line-height: 1;
  flex-shrink: 0;
}

/* ── Analyze dropdown button ─────────────────────────────────────── */
.toolbar-analyze-btn {
  min-width: 90px;
}

.toolbar-analyze-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--accent);
  color: #1a1208;
  font-size: 10px;
  font-weight: 700;
  border-radius: 8px;
  padding: 0 5px;
  min-width: 16px;
  height: 16px;
  margin-left: 6px;
}

/* Dropdown menu scoped overrides */
.toolbar-analyze-menu .context-menu-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}

.toolbar-analyze-menu .context-menu-item.active {
  color: var(--accent);
}

.toolbar-analyze-count {
  color: var(--accent);
  font-size: 11px;
  font-weight: 600;
  flex-shrink: 0;
}

/* ── Stats button ────────────────────────────────────────────────── */
.toolbar-btn-stats {
  padding: 4px 7px;
  font-size: 13px;
  line-height: 1;
  flex-shrink: 0;
  letter-spacing: -0.02em;
}

/* ── Sentence stats popover ──────────────────────────────────────── */
.toolbar-stats-popover {
  position: fixed;
  z-index: 1000;
  background: var(--panel-bg, var(--toolbar-bg));
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 14px 16px 12px;
  width: 300px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.35);
}

.toolbar-stats-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}

.toolbar-stats-title {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.toolbar-stats-close {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 16px;
  padding: 0;
  line-height: 1;
  opacity: 0.6;
  transition: opacity 0.15s;
}

.toolbar-stats-close:hover {
  opacity: 1;
}

.toolbar-stats-summary {
  font-size: 12px;
  color: var(--text-secondary);
  margin-bottom: 12px;
  display: flex;
  gap: 16px;
}

.toolbar-stats-summary strong {
  color: var(--text-primary);
  font-weight: 600;
}

.toolbar-stats-chart {
  display: flex;
  align-items: flex-end;
  gap: 1px;
  margin-bottom: 5px;
}

.toolbar-stats-bar {
  flex: 1;
  min-height: 0;
  border-radius: 1px 1px 0 0;
  background: var(--text-muted);
  opacity: 0.3;
  transition: opacity 0.1s;
  cursor: default;
}

.toolbar-stats-bar.target {
  background: var(--accent);
  opacity: 0.65;
}

.toolbar-stats-bar:hover {
  opacity: 0.9 !important;
}

.toolbar-stats-axis {
  display: flex;
  justify-content: space-between;
  font-size: 9px;
  color: var(--text-muted);
  opacity: 0.55;
  margin-bottom: 12px;
}

.toolbar-stats-axis-target {
  color: var(--accent);
  opacity: 1;
}

.toolbar-stats-outliers {
  border-top: 1px solid var(--border);
  padding-top: 10px;
}

.toolbar-stats-outliers-title {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 7px;
}

.toolbar-stats-outliers-list {
  max-height: 140px;
  overflow-y: auto;
}

.toolbar-stats-outlier {
  display: flex;
  gap: 8px;
  align-items: baseline;
  padding: 2px 0;
}

.toolbar-stats-outlier-wc {
  font-size: 10px;
  color: var(--text-muted);
  flex-shrink: 0;
  font-variant-numeric: tabular-nums;
  min-width: 22px;
}

.toolbar-stats-outlier-text {
  font-size: 11px;
  font-family: var(--font-serif);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text-secondary);
}

.toolbar-stats-outlier-text.short {
  opacity: 0.6;
}

.toolbar-stats-outlier-more {
  font-size: 10px;
  color: var(--text-muted);
  padding: 3px 0;
  opacity: 0.6;
}

/* ── Paragraph rhythm popover ────────────────────────────────────── */
.toolbar-rhythm-popover {
  position: fixed;
  z-index: 1000;
  background: var(--panel-bg, var(--toolbar-bg));
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 14px 16px 12px;
  width: 260px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.35);
}

.toolbar-rhythm-list {
  max-height: 280px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 3px;
  margin-bottom: 10px;
  padding-right: 2px;
}

.toolbar-rhythm-row {
  display: flex;
  align-items: center;
  gap: 7px;
  cursor: default;
}

.toolbar-rhythm-bar {
  height: 8px;
  border-radius: 2px;
  opacity: 0.75;
  flex-shrink: 0;
  transition: opacity 0.1s;
}

.toolbar-rhythm-row:hover .toolbar-rhythm-bar {
  opacity: 1;
}

.toolbar-rhythm-count {
  font-size: 10px;
  font-variant-numeric: tabular-nums;
  opacity: 0.8;
  flex-shrink: 0;
}

.toolbar-rhythm-legend {
  display: flex;
  gap: 6px;
  border-top: 1px solid var(--border);
  padding-top: 9px;
  flex-wrap: wrap;
}

.toolbar-rhythm-legend-item {
  display: flex;
  align-items: center;
  gap: 3px;
  font-size: 9px;
  color: var(--text-muted);
  cursor: default;
}

.toolbar-rhythm-legend-swatch {
  width: 10px;
  height: 10px;
  border-radius: 2px;
  opacity: 0.75;
}

/* ── Story Bible toolbar ─────────────────────────────────────────── */
.toolbar-bible-label {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  text-transform: uppercase;
  margin-right: 2px;
  align-self: center;
}

.toolbar-btn-bible {
  color: var(--accent);
}

.toolbar-btn-bible:hover:not(:disabled) {
  border-color: var(--accent);
  color: var(--accent);
  background: color-mix(in srgb, var(--accent) 10%, transparent);
}
