.error-history-root {
  position: fixed;
  right: max(12px, env(safe-area-inset-right, 0px));
  bottom: max(20px, env(safe-area-inset-bottom, 0px));
  z-index: 1360;
  pointer-events: none;
}

.error-history-trigger {
  pointer-events: auto;
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 44px;
  min-height: 44px;
  padding: 0;
  border-radius: 999px;
  border: 1px solid rgba(248, 113, 113, 0.35);
  background: rgba(17, 24, 39, 0.92);
  color: #fecaca;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.35);
  cursor: pointer;
}

.error-history-trigger:focus-visible {
  outline: 2px solid #38bdf8;
  outline-offset: 2px;
}

.error-history-icon {
  display: block;
}

.error-history-badge {
  position: absolute;
  top: 2px;
  right: 2px;
  min-width: 18px;
  height: 18px;
  padding: 0 4px;
  border-radius: 999px;
  background: #ef4444;
  color: #fff;
  font-size: 0.68rem;
  font-weight: 600;
  line-height: 18px;
  text-align: center;
}

.error-history-dialog {
  border: none;
  padding: 0;
  margin: auto;
  max-width: min(420px, calc(100vw - 24px));
  width: 100%;
  background: transparent;
  color: #e5e7eb;
  pointer-events: auto;
}

.error-history-dialog::backdrop {
  background: rgba(2, 6, 23, 0.72);
}

.error-history-panel {
  margin: 0;
  border-radius: 16px;
  border: 1px solid rgba(248, 113, 113, 0.28);
  background: #0f172a;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.55);
  max-height: min(70vh, 520px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.error-history-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px 10px;
  border-bottom: 1px solid rgba(148, 163, 184, 0.2);
}

.error-history-title {
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
}

.error-history-close,
.error-history-clear {
  min-width: 44px;
  min-height: 44px;
}

.error-history-footer {
  display: flex;
  justify-content: flex-end;
  padding: 8px 12px 12px;
  border-top: 1px solid rgba(148, 163, 184, 0.15);
}

.error-history-empty {
  margin: 0;
  padding: 20px 16px 24px;
  color: #94a3b8;
  font-size: 0.92rem;
}

.error-history-list {
  list-style: none;
  margin: 0;
  padding: 8px 0 12px;
  overflow: auto;
  flex: 1 1 auto;
  min-height: 0;
}

.error-history-item {
  padding: 10px 16px;
  border-bottom: 1px solid rgba(148, 163, 184, 0.12);
}

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

.error-history-time {
  display: block;
  font-size: 0.78rem;
  color: #94a3b8;
  margin-bottom: 4px;
}

.error-history-message {
  margin: 0;
  font-size: 0.92rem;
  line-height: 1.45;
  overflow-wrap: anywhere;
  word-break: break-word;
  white-space: pre-wrap;
}

@media (max-width: 960px) {
  .error-history-root.error-history-surface-admin {
    top: auto;
    bottom: calc(var(--mobile-tab-height, 56px) + 16px);
    right: auto;
    left: max(10px, env(safe-area-inset-left, 0px));
  }

  /* Explore bad toast (mobile chrome overlay) shares the bottom band — leave the trigger slot clear. */
  .explore-undo-toast.is-bad.is-mobile-chrome-overlay {
    left: max(68px, calc(env(safe-area-inset-left, 0px) + 58px));
    right: max(12px, env(safe-area-inset-right, 0px));
    transform: none;
    width: auto;
    max-width: none;
    bottom: calc(var(--mobile-tab-height, 56px) + 16px);
  }
}

.error-history-root.error-history-surface-family {
  top: max(12px, env(safe-area-inset-top, 0px));
  bottom: auto;
  left: max(12px, env(safe-area-inset-left, 0px));
  right: auto;
  z-index: 70;
}

.error-history-root[data-history-empty="true"] .error-history-trigger {
  display: none;
}
