/* Checkpoint history panel (ui/history-panel.js) — anchored under the
   toolbar, glass style to match the stage furniture. */

#ec-history-panel {
  position: absolute;
  top: 64px;
  right: 16px;
  width: 300px;
  max-height: calc(100% - 96px);
  display: flex;
  flex-direction: column;
  z-index: 30;
  font-family: var(--font-ui);
}
#ec-history-panel[hidden] {
  display: none;
}

.ec-history-header {
  display: flex;
  align-items: baseline;
  gap: 8px;
  padding: 12px 14px 8px;
  border-bottom: 1px solid var(--line);
}
.ec-history-title {
  font-weight: 700;
  font-size: 13px;
  color: var(--text);
}
.ec-history-free {
  font-size: 10.5px;
  color: var(--muted);
  font-weight: 600;
  flex: 1;
}
.ec-history-close {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
  padding: 2px 4px;
}
.ec-history-close:hover { color: var(--text); }

.ec-history-status {
  padding: 6px 14px;
  font-size: 11px;
  font-weight: 600;
  color: var(--ok, #7fc98b);
}

.ec-history-body {
  overflow-y: auto;
  padding: 6px 8px 10px;
}
.ec-history-empty {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.5;
  padding: 4px 6px;
}

.ec-history-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 6px;
  border-radius: 8px;
}
.ec-history-row:hover {
  background: rgba(255, 255, 255, 0.04);
}
.ec-history-text {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 1px;
}
.ec-history-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.ec-history-meta {
  font-size: 10.5px;
  color: var(--muted);
}
.ec-history-restore {
  flex: none;
  padding: 4px 9px;
  font-size: 11px;
  font-weight: 600;
  font-family: var(--font-ui);
  color: var(--text);
  background: rgba(236, 154, 60, 0.09);
  border: 1px solid rgba(236, 154, 60, 0.3);
  border-radius: 7px;
  cursor: pointer;
  transition: background 0.14s ease, border-color 0.14s ease;
}
.ec-history-restore:hover {
  background: rgba(236, 154, 60, 0.18);
  border-color: rgba(236, 154, 60, 0.55);
}
.ec-history-delete {
  flex: none;
  background: none;
  border: none;
  color: var(--muted);
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
  padding: 2px 4px;
  opacity: 0;
  transition: opacity 0.14s ease, color 0.14s ease;
}
.ec-history-row:hover .ec-history-delete,
.ec-history-delete:focus-visible {
  opacity: 1;
}
.ec-history-delete:hover { color: #e08a7a; }

.ec-history-foot {
  padding: 8px 14px 10px;
  border-top: 1px solid var(--line);
  font-size: 10px;
  color: var(--muted);
  line-height: 1.4;
}

@media (max-width: 900px) {
  #ec-history-panel {
    position: fixed;
    top: auto;
    right: 8px;
    left: 8px;
    bottom: calc(44vh + 8px);
    width: auto;
    max-height: 42vh;
  }
  #app.chat-collapsed #ec-history-panel {
    bottom: 64px;
    max-height: 60vh;
  }
}

@media (pointer: coarse) {
  .ec-history-restore,
  .ec-history-close,
  .ec-history-delete {
    min-width: 44px;
    min-height: 44px;
  }
  .ec-history-delete {
    opacity: 1; /* no hover on touch — keep it visible */
  }
}
