/* ── HISTORY PANEL ── */
#history-panel {
  position: fixed;
  top: 0; right: 0;
  width: min(420px, 100vw);
  height: 100%;
  background: var(--white);
  z-index: 400;
  display: flex;
  flex-direction: column;
  box-shadow: -8px 0 40px rgba(0, 0, 0, 0.18);
  transform: translateX(100%);
  transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1);
  overflow: hidden;
}

#history-panel.open {
  transform: translateX(0);
  animation: slideInRight 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Backdrop */
#history-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  z-index: 390;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s;
}

#history-backdrop.visible {
  opacity: 1;
  pointer-events: all;
}

/* ── PANEL HEADER ── */
.history-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 20px 16px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.history-header-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--near-black);
}

.history-close {
  background: none;
  border: none;
  font-size: 22px;
  color: var(--warm-gray);
  cursor: pointer;
  line-height: 1;
  padding: 4px;
  transition: color 0.2s;
}

.history-close:hover { color: var(--near-black); }

/* ── PANEL BODY ── */
.history-body {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  -webkit-overflow-scrolling: touch;
}

/* ── STATS GRID ── */
.stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--warm-white);
  border-radius: 12px;
  padding: 14px 12px;
  text-align: center;
  transition: transform 0.2s, box-shadow 0.2s;
}

.stat-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 16px rgba(232, 53, 42, 0.1);
}

.stat-card-num {
  font-size: 28px;
  font-weight: 700;
  color: var(--red);
  line-height: 1;
}

.stat-card-label {
  font-size: 11px;
  color: var(--warm-gray);
  margin-top: 4px;
  line-height: 1.3;
}

.stat-card.streak .stat-card-num { font-size: 22px; }

/* ── HISTORY DAYS ── */
.history-day-header {
  font-size: 13px;
  font-weight: 700;
  color: var(--warm-gray);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin: 20px 0 10px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border);
}

.history-day-header:first-of-type { margin-top: 0; }

/* ── HISTORY ENTRY CARDS ── */
.history-entry {
  background: var(--warm-white);
  border-radius: 12px;
  padding: 12px 14px;
  margin-bottom: 10px;
  cursor: pointer;
  border: 1px solid var(--border);
  transition: box-shadow 0.2s;
}

.history-entry:hover {
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.06);
}

.history-entry-header {
  display: flex;
  align-items: flex-start;
  gap: 10px;
}

.history-entry-task {
  flex: 1;
  font-size: 14px;
  font-weight: 600;
  color: var(--near-black);
  word-break: break-word;
}

.history-entry-meta {
  display: flex;
  gap: 12px;
  margin-top: 5px;
  font-size: 12px;
  color: var(--warm-gray);
}

.history-entry-tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.history-entry-notes {
  font-size: 12px;
  color: var(--warm-gray);
  margin-top: 10px;
  padding-top: 8px;
  border-top: 1px solid var(--border);
  line-height: 1.6;
  display: none;
}

.history-entry.expanded .history-entry-notes { display: block; }

.history-expand-icon {
  font-size: 12px;
  color: var(--warm-gray);
  transition: transform 0.2s;
  flex-shrink: 0;
}

.history-entry.expanded .history-expand-icon { transform: rotate(180deg); }

/* ── EMPTY STATE ── */
.history-empty {
  text-align: center;
  padding: 60px 20px;
  color: var(--warm-gray);
}

.history-empty-icon { font-size: 48px; margin-bottom: 12px; }
.history-empty-text { font-size: 15px; line-height: 1.6; }
