*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --bg: #0f172a;
  --surface: #1e293b;
  --surface-border: #334155;
  --text: #f1f5f9;
  --text-muted: #94a3b8;
  --radius: 12px;

  --cat-default: #2563eb;
}

body {
  font-family: system-ui, -apple-system, sans-serif;
  background-color: var(--bg);
  color: var(--text);
  min-height: 100vh;
  padding: 2rem 1.5rem;
}

.container {
  width: 100%;
  max-width: 800px;
  margin: 0 auto;
}

/* Header */
header {
  text-align: center;
  margin-bottom: 2.5rem;
}

header h1 {
  font-size: 2rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.subtitle {
  color: var(--text-muted);
  margin-top: 0.4rem;
  font-size: 1rem;
}

/* Main card */
main {
  background: var(--surface);
  border: 1px solid var(--surface-border);
  border-radius: var(--radius);
  padding: 2rem;
  min-height: 200px;
}

/* Loading / Error states */
.state-message {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  padding: 3rem 1rem;
  color: var(--text-muted);
  text-align: center;
}

.error-icon {
  font-size: 2.5rem;
  color: #ef4444;
}

/* Spinner */
@keyframes spin {
  to { transform: rotate(360deg); }
}

.spinner {
  width: 36px;
  height: 36px;
  border: 3px solid var(--surface-border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

/* Filter bar */
.timeline-filter {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 2rem;
}

.filter-chip {
  background: var(--bg);
  border: 1px solid var(--surface-border);
  border-radius: 999px;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 0.8rem;
  font-weight: 500;
  padding: 0.3rem 0.85rem;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.filter-chip.active {
  color: #fff;
}

/* Timeline list */
.timeline-list {
  list-style: none;
  position: relative;
  padding-left: 2rem;
}

.timeline-list::before {
  content: '';
  position: absolute;
  left: 0.45rem;
  top: 0.5rem;
  bottom: 0.5rem;
  width: 2px;
  background: var(--surface-border);
  border-radius: 2px;
}

/* Individual event */
.timeline-item {
  position: relative;
  padding-bottom: 2rem;
}

.timeline-item:last-child {
  padding-bottom: 0;
}

/* Dot on the line */
.timeline-item::before {
  content: '';
  position: absolute;
  left: -1.625rem;
  top: 0.35rem;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  border: 2px solid var(--bg);
  background: var(--dot-color, var(--cat-default));
}

.timeline-item.filtered-out {
  display: none;
}

/* Event card */
.event-card {
  background: var(--bg);
  border: 1px solid var(--surface-border);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
}

.event-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-bottom: 0.5rem;
}

.event-title {
  font-size: 1rem;
  font-weight: 600;
}

.event-title.past {
  text-decoration: line-through;
  color: var(--text-muted);
}

.event-category {
  border-radius: 999px;
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  padding: 0.2rem 0.65rem;
  text-transform: uppercase;
  white-space: nowrap;
  color: #fff;
  background: var(--dot-color, var(--cat-default));
}

.event-date {
  color: var(--text-muted);
  font-size: 0.8rem;
  margin-bottom: 0.5rem;
}

.event-completed-ago {
  color: var(--text-muted);
  font-size: 0.78rem;
  font-style: italic;
  margin-bottom: 0.5rem;
}

.event-countdown {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}

.cd-unit {
  background: var(--surface);
  border: 1px solid var(--surface-border);
  border-radius: 6px;
  display: flex;
  align-items: baseline;
  gap: 0.15rem;
  padding: 0.2rem 0.5rem;
}

.cd-value {
  font-size: 1rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.cd-label {
  color: var(--text-muted);
  font-size: 0.7rem;
}

.event-overdue {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-bottom: 0.5rem;
}

.overdue-label {
  color: #ef4444;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.event-overdue .cd-unit {
  border-color: rgba(239, 68, 68, 0.4);
}

.event-overdue .cd-value {
  color: #ef4444;
}

/* Overdue item — card highlight */
@keyframes pulse-dot {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.4; }
}

.timeline-item.overdue {
  --dot-color: #ef4444;
}

.timeline-item.overdue::before {
  animation: pulse-dot 1.5s ease-in-out infinite;
}

.timeline-item.overdue .event-card {
  background: rgba(239, 68, 68, 0.06);
  border-color: rgba(239, 68, 68, 0.5);
  border-left: 3px solid #ef4444;
}

.timeline-item.completed {
  --dot-color: #2563eb;
}

.timeline-item.completed .event-card {
  background: rgba(16, 185, 129, 0.06);
  border-color: rgba(16, 185, 129, 0.5);
  border-left: 3px solid #10b981;
}

.missed-dates {
  border-top: 1px solid var(--surface-border);
  margin-bottom: 0.5rem;
  padding-top: 0.5rem;
}

.missed-label {
  color: var(--text-muted);
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.missed-list {
  list-style: none;
  margin-top: 0.3rem;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.missed-list li {
  color: #ef4444;
  font-size: 0.82rem;
  padding-left: 0.75rem;
  position: relative;
}

.missed-list li::before {
  content: '✕';
  position: absolute;
  left: 0;
  font-size: 0.65rem;
  top: 0.1rem;
}

.event-description {
  color: var(--text-muted);
  font-size: 0.9rem;
  line-height: 1.6;
}

/* Button */
.btn {
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.95rem;
  font-weight: 600;
  padding: 0.6rem 1.4rem;
  transition: background 0.2s;
}

.btn-primary {
  background: var(--primary);
  color: #fff;
}

.btn-primary:hover {
  background: var(--primary-hover);
}

.hidden {
  display: none;
}
