:root {
  --bg: #08080c;
  --text: #e4e2dd;
  --muted: #6b6b7a;
  --dim: #2a2a38;
  --future: #111118;
  --empty: #1a1a28;
  --accent: #7c6bf0;
  --glass: rgba(12, 12, 18, 0.85);
  --cell: 11px;
  --gap: 2px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { background: var(--bg); }

body {
  font-family: "Inter", system-ui, sans-serif;
  color: var(--text);
  background: var(--bg);
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

/* ── HUD ─────────────────────────────────────────── */

.hud {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 20px;
  background: linear-gradient(to bottom, var(--bg) 60%, transparent);
  pointer-events: none;
}

.hud > * { pointer-events: auto; }

.hud-left {
  display: flex;
  align-items: baseline;
  gap: 12px;
}

.hud-age {
  font-family: "JetBrains Mono", monospace;
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.02em;
}

.hud-detail {
  font-size: 0.72rem;
  color: var(--muted);
  font-family: "JetBrains Mono", monospace;
}

.hud-btn {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 6px;
  padding: 5px 14px;
  font: 500 0.72rem/1.4 "Inter", sans-serif;
  color: var(--muted);
  cursor: pointer;
  transition: all 0.2s;
  backdrop-filter: blur(12px);
}

.hud-btn:hover, .hud-btn.active {
  color: var(--text);
  border-color: rgba(255, 255, 255, 0.2);
  background: rgba(255, 255, 255, 0.1);
}

/* ── Legend drawer ────────────────────────────────── */

.legend-drawer {
  position: fixed;
  top: 48px;
  right: 12px;
  z-index: 40;
  max-height: calc(100vh - 64px);
  overflow-y: auto;
  background: var(--glass);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 12px;
  padding: 12px;
  width: 260px;
  scrollbar-width: thin;
  scrollbar-color: var(--dim) transparent;
  animation: fadeIn 0.15s ease;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(-6px); }
  to { opacity: 1; transform: translateY(0); }
}

.legend-inner {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.leg {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 10px;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.15s;
  user-select: none;
}

.leg:hover { background: rgba(255, 255, 255, 0.04); }
.leg.active { background: rgba(255, 255, 255, 0.07); }

.leg-dot {
  width: 12px;
  height: 12px;
  border-radius: 3px;
  flex-shrink: 0;
}

.leg-text {
  flex: 1;
  min-width: 0;
}

.leg-name {
  font-size: 0.75rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.leg-meta {
  font-size: 0.62rem;
  color: var(--muted);
  font-family: "JetBrains Mono", monospace;
  margin-top: 1px;
}

.leg-pct {
  font-size: 0.65rem;
  font-family: "JetBrains Mono", monospace;
  color: var(--muted);
  flex-shrink: 0;
}

/* ── Grid viewport ───────────────────────────────── */

.grid-viewport {
  width: 100vw;
  min-height: 100vh;
  overflow-x: auto;
  overflow-y: auto;
  padding: 52px 0 24px;
  display: flex;
  justify-content: center;
}

.grid {
  display: grid;
  grid-template-columns: 44px repeat(52, var(--cell)) 28px;
  grid-auto-rows: var(--cell);
  gap: var(--gap);
  padding: 0 16px;
  width: fit-content;
}

/* ── Year labels ─────────────────────────────────── */

.yr {
  grid-column: 1;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding-right: 8px;
  font: 500 9px/1 "JetBrains Mono", monospace;
  color: transparent;
  transition: color 0.2s;
  user-select: none;
}

.yr.show { color: var(--dim); }
.yr.decade { color: var(--muted); }

.grid:hover .yr.show { color: var(--muted); }
.grid:hover .yr.decade { color: var(--text); }

/* ── Age labels ──────────────────────────────────── */

.ag {
  display: flex;
  align-items: center;
  padding-left: 6px;
  font: 500 8px/1 "JetBrains Mono", monospace;
  color: transparent;
  transition: color 0.2s;
  user-select: none;
}

.ag.show { color: var(--dim); }
.grid:hover .ag.show { color: var(--muted); }

/* ── Week cells ──────────────────────────────────── */

.w {
  border-radius: 2px;
  transition: transform 0.08s ease, box-shadow 0.12s ease;
  cursor: crosshair;
}

.w:hover {
  transform: scale(2.4);
  z-index: 10;
  position: relative;
  box-shadow: 0 0 12px rgba(255, 255, 255, 0.12);
}

.w-now {
  border-radius: 3px;
  animation: pulse 2.5s ease-in-out infinite;
  outline: 2px solid #fff;
  outline-offset: -1px;
}

@keyframes pulse {
  0%, 100% { box-shadow: 0 0 4px rgba(255, 255, 255, 0.3); }
  50% { box-shadow: 0 0 14px rgba(255, 255, 255, 0.7); }
}

/* Filter state */
.grid.filtered .w { opacity: 0.08; }
.grid.filtered .w.hl { opacity: 1; }

/* ── Tooltip ─────────────────────────────────────── */

.tip {
  position: fixed;
  z-index: 100;
  pointer-events: none;
  background: var(--glass);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 10px;
  padding: 10px 14px;
  font-size: 0.73rem;
  line-height: 1.5;
  color: var(--text);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.5);
  max-width: 200px;
}

.tip-date {
  font-family: "JetBrains Mono", monospace;
  font-size: 0.65rem;
  color: var(--muted);
}

.tip-event {
  font-weight: 700;
  margin-top: 2px;
}

.tip-sub {
  font-size: 0.62rem;
  color: var(--muted);
  margin-top: 2px;
  font-family: "JetBrains Mono", monospace;
}

/* ── Responsive ──────────────────────────────────── */

@media (max-width: 768px) {
  :root { --cell: 8px; --gap: 1.5px; }

  .grid { grid-template-columns: 32px repeat(52, var(--cell)) 22px; padding: 0 6px; }
  .yr { font-size: 7px; padding-right: 4px; }
  .ag { font-size: 7px; padding-left: 4px; }
  .hud { padding: 10px 12px; }
  .legend-drawer { width: 220px; right: 8px; }
}

@media (max-width: 480px) {
  :root { --cell: 5.5px; --gap: 1px; }

  .grid { grid-template-columns: 24px repeat(52, var(--cell)) 18px; padding: 0 2px; }
  .yr { font-size: 6px; padding-right: 3px; }
  .ag { font-size: 6px; }
  .w:hover { transform: scale(1.8); }
  .legend-drawer { width: 200px; }
}
