/* ============ History ============ */
.history-toolbar {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 8px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.history-search {
  flex: 1;
  background: var(--bg-mid);
  border: 1px solid var(--border);
  color: var(--text-primary);
  padding: 4px 8px;
  border-radius: 3px;
  font-size: 12px;
  outline: none;
}

.history-search:focus {
  border-color: var(--accent);
}

.history-count {
  font-size: 11px;
  color: var(--text-muted);
  white-space: nowrap;
}

.history-filter-btn {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 24px;
  background: var(--bg-mid);
  border: 1px solid var(--border);
  border-radius: 3px;
  cursor: pointer;
  flex-shrink: 0;
  user-select: none;
  color: var(--text-muted);
}

.history-filter-btn:hover {
  border-color: var(--accent);
  color: var(--text-primary);
}

.history-filter-btn.active {
  color: var(--accent);
  border-color: var(--accent);
}

.history-filter-btn .material-symbols-outlined {
  font-size: 18px;
}

.history-filter-popup {
  display: none;
  position: absolute;
  top: 100%;
  right: 0;
  z-index: 100;
  min-width: 150px;
  background: var(--bg-mid);
  border: 1px solid var(--border);
  border-radius: 4px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.3);
  padding: 4px 0;
  margin-top: 4px;
}

.history-filter-popup.open {
  display: block;
}

.history-filter-option {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  font-size: 12px;
  color: var(--text-primary);
  cursor: pointer;
  white-space: nowrap;
}

.history-filter-option:hover {
  background: var(--bg-hover);
}

.history-filter-option.active {
  color: var(--accent);
  background: var(--bg-hover);
}

.history-filter-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.history-list {
  flex: 1;
  overflow-y: auto;
  padding-right: 4px;
}

.history-group {
  border-bottom: 1px solid var(--border);
}

.history-group-header {
  padding: 5px 10px;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  background: var(--bg-header);
  position: sticky;
  top: 0;
  z-index: 2;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.history-entry {
  border-bottom: 1px solid rgba(255,255,255,0.03);
}

.history-entry:last-child {
  border-bottom: none;
}

.history-entry.expanded {
  background: rgba(74, 144, 217, 0.04);
}

.history-summary {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  cursor: pointer;
  transition: background 0.1s;
}

.history-summary:hover {
  background: var(--bg-hover);
}

.history-time {
  font-family: 'SF Mono', 'Consolas', monospace;
  font-size: 11px;
  color: var(--text-muted);
  width: 38px;
  flex-shrink: 0;
}

.history-project {
  font-size: 11px;
  color: var(--accent);
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 120px;
  flex-shrink: 0;
}

.history-summary-text {
  flex: 1;
  font-size: 12px;
  color: var(--text-primary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.history-expand-icon {
  font-size: 10px;
  color: var(--text-muted);
  width: 14px;
  text-align: center;
  flex-shrink: 0;
}

.history-detail {
  display: none;
  padding: 0;
  border-top: none;
}

.history-detail.open {
  display: block;
}

.history-elements {
  display: flex;
  flex-direction: column;
}

.history-element-row {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px 4px 58px;
  font-size: 12px;
  border-top: 1px solid rgba(255,255,255,0.04);
  transition: background 0.15s;
}

.history-element-row:hover {
  background: rgba(74, 144, 217, 0.06);
}

.history-element-row.restoring {
  background: rgba(80, 176, 112, 0.12);
}

.he-time {
  font-family: 'SF Mono', 'Consolas', monospace;
  font-size: 10px;
  color: var(--text-muted);
  width: 50px;
  flex-shrink: 0;
}

.he-name {
  font-size: 11px;
  font-weight: 500;
  width: 130px;
  flex-shrink: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.he-color-drums    { color: #e06060; }
.he-color-bass     { color: #5a9cf0; }
.he-color-synth    { color: #60c080; }
.he-color-fx       { color: #e0a040; }
.he-color-vocal    { color: #c080d0; }
.he-color-master   { color: #50c0d0; }
.he-color-structure { color: #999999; }

.he-change {
  flex: 1;
  color: var(--text-secondary);
  font-size: 11px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.he-restore-btn {
  flex-shrink: 0;
  background: var(--bg-light);
  border: 1px solid var(--border);
  color: var(--text-primary);
  border-radius: 3px;
  padding: 2px 8px;
  font-size: 10px;
  cursor: pointer;
  transition: background 0.1s, border-color 0.1s;
}

.he-restore-btn:hover {
  background: var(--accent);
  border-color: var(--accent-hover);
  color: #fff;
}

.he-restore-btn:disabled {
  background: var(--success);
  border-color: var(--success);
  color: #fff;
  cursor: default;
}
