:root {
  --cell: 12px;
  --gap: 5px;
  --bg: #090b0a;
  --surface: rgba(17, 22, 19, 0.72);
  --ink: #f3f7f4;
  --muted: #7d8a82;
  --line: rgba(211, 255, 224, 0.1);
  --empty: #18201b;
  --l1: #174b31;
  --l2: #087c49;
  --l3: #00b86b;
  --l4: #72f2a7;
  --accent: #72f2a7;
  --accent-2: #47d7ff;
  --glow: rgba(80, 242, 160, 0.18);
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-synthesis: none;
  color-scheme: dark;
}

html[data-palette="ultraviolet"] {
  --bg: #0c0912; --surface: rgba(24, 16, 36, 0.72); --ink: #faf6ff; --muted: #968ba5;
  --line: rgba(232, 205, 255, 0.1); --empty: #21172c; --l1: #462463; --l2: #7434a6;
  --l3: #b446da; --l4: #ff7be5; --accent: #f28cff; --accent-2: #8f7cff; --glow: rgba(220, 93, 255, 0.2);
}

html[data-palette="cobalt"] {
  --bg: #070b13; --surface: rgba(13, 22, 38, 0.76); --ink: #f4f8ff; --muted: #77879f;
  --line: rgba(197, 222, 255, 0.1); --empty: #121e2e; --l1: #173c62; --l2: #175f9e;
  --l3: #198dd0; --l4: #66d9ff; --accent: #66d9ff; --accent-2: #5577ff; --glow: rgba(61, 164, 255, 0.2);
}

html[data-palette="solar"] {
  --bg: #120b07; --surface: rgba(35, 20, 12, 0.74); --ink: #fff8ef; --muted: #a28c7c;
  --line: rgba(255, 225, 194, 0.1); --empty: #2a1c15; --l1: #60321e; --l2: #a44722;
  --l3: #e56b29; --l4: #ffc55c; --accent: #ffc55c; --accent-2: #ff5c67; --glow: rgba(255, 137, 47, 0.2);
}

html[data-palette="mono"] {
  --bg: #0b0b0b; --surface: rgba(22, 22, 22, 0.78); --ink: #f5f5f1; --muted: #858582;
  --line: rgba(255, 255, 255, 0.1); --empty: #20201f; --l1: #3e3e3b; --l2: #696966;
  --l3: #a2a29d; --l4: #eeeeea; --accent: #eeeeea; --accent-2: #9d9d98; --glow: rgba(255, 255, 255, 0.13);
}

* { box-sizing: border-box; }

html, body { min-height: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  display: grid;
  grid-template-rows: auto 1fr auto;
  overflow-x: hidden;
  background:
    radial-gradient(70rem 44rem at 74% -18%, color-mix(in srgb, var(--accent-2) 14%, transparent), transparent 62%),
    radial-gradient(54rem 38rem at 18% 112%, color-mix(in srgb, var(--accent) 10%, transparent), transparent 68%),
    var(--bg);
  color: var(--ink);
  transition: background-color 320ms ease, color 320ms ease;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0.23;
  background-image: linear-gradient(var(--line) 1px, transparent 1px), linear-gradient(90deg, var(--line) 1px, transparent 1px);
  background-size: 72px 72px;
  mask-image: linear-gradient(to bottom, black, transparent 78%);
}

a { color: inherit; text-decoration: none; }

.topbar, footer {
  position: relative;
  z-index: 2;
  width: min(1180px, calc(100% - 48px));
  margin-inline: auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.topbar { height: 88px; justify-content: flex-start; }

.wordmark {
  display: inline-flex;
  align-items: center;
  gap: 11px;
  font-size: 13px;
  font-weight: 620;
  letter-spacing: -0.01em;
}

.wordmark-mark {
  width: 10px;
  height: 10px;
  border: 2px solid var(--accent);
  border-radius: 3px;
  transform: rotate(45deg);
  box-shadow: 0 0 18px var(--accent);
}

main {
  position: relative;
  z-index: 1;
  min-width: 0;
  width: min(1180px, calc(100% - 48px));
  margin: auto;
  padding: clamp(36px, 7vh, 80px) 0 clamp(42px, 7vh, 80px);
}

.graph-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 24px;
}

.eyebrow {
  display: flex;
  align-items: center;
  gap: 9px;
  margin: 0;
  color: var(--muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 10px;
  letter-spacing: 0.13em;
  text-transform: uppercase;
}

.pulse {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 0 var(--glow);
  animation: pulse 2.8s ease-out infinite;
}

@keyframes pulse { 55%, 100% { box-shadow: 0 0 0 8px transparent; } }

.summary {
  margin: 0;
  color: var(--muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 10px;
  letter-spacing: 0.02em;
}

.summary span { color: var(--ink); font-variant-numeric: tabular-nums; }

.graph-card {
  position: relative;
  min-width: 0;
  padding: 28px 30px 22px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: linear-gradient(145deg, color-mix(in srgb, var(--surface) 96%, var(--accent) 4%), var(--surface));
  box-shadow: 0 32px 90px -52px var(--glow), inset 0 1px rgba(255,255,255,0.025);
  backdrop-filter: blur(18px);
}

.graph-scroll { max-width: 100%; overflow-x: auto; padding: 3px 2px 13px; scrollbar-width: thin; scrollbar-color: var(--line) transparent; }
.graph-scroll::-webkit-scrollbar { height: 5px; }
.graph-scroll::-webkit-scrollbar-thumb { background: var(--line); border-radius: 9px; }

.graph-layout {
  display: grid;
  grid-template-columns: 20px max-content;
  grid-template-rows: 14px max-content;
  gap: 8px 9px;
  min-width: max-content;
}

.months {
  display: grid;
  grid-template-columns: repeat(var(--weeks, 53), var(--cell));
  gap: var(--gap);
  color: var(--muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 9px;
  line-height: 12px;
}

.month { overflow: visible; white-space: nowrap; }

.weekdays {
  display: grid;
  grid-template-rows: repeat(7, var(--cell));
  gap: var(--gap);
  color: var(--muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 8px;
  line-height: var(--cell);
}

.heatmap {
  display: grid;
  grid-template-rows: repeat(7, var(--cell));
  grid-auto-flow: column;
  grid-auto-columns: var(--cell);
  gap: var(--gap);
}

.day, .legend i {
  display: block;
  width: var(--cell);
  height: var(--cell);
  border: 0;
  border-radius: 3px;
  background: var(--empty);
  transition: transform 130ms ease, box-shadow 160ms ease, background-color 260ms ease;
}

.day { padding: 0; appearance: none; }
.day[data-level="1"], .legend i[data-level="1"] { background: var(--l1); }
.day[data-level="2"], .legend i[data-level="2"] { background: var(--l2); }
.day[data-level="3"], .legend i[data-level="3"] { background: var(--l3); }
.day[data-level="4"], .legend i[data-level="4"] { background: var(--l4); }
.day.future { visibility: hidden; }
.day:not(.future):hover, .day:not(.future):focus-visible { transform: scale(1.55); box-shadow: 0 0 18px var(--glow); outline: 1px solid var(--accent); z-index: 3; }

.graph-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 20px;
  margin-top: 14px;
  color: var(--muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 9px;
  letter-spacing: 0.04em;
}

.graph-meta p { margin: 0; }
.legend { display: flex; align-items: center; gap: 5px; }
.legend i { width: 8px; height: 8px; border-radius: 2px; }

.tooltip {
  position: fixed;
  z-index: 20;
  pointer-events: none;
  transform: translate(-50%, calc(-100% - 12px));
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  box-shadow: 0 12px 30px rgba(0,0,0,.3);
  color: var(--ink);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 10px;
  white-space: nowrap;
  backdrop-filter: blur(14px);
}

footer {
  min-height: 92px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 9px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.palettes { display: flex; align-items: center; gap: 7px; }
.palettes button {
  width: 26px;
  height: 26px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 50%;
  background: transparent;
  cursor: pointer;
}
.palettes button i { width: 10px; height: 10px; border-radius: 50%; background: linear-gradient(135deg, #72f2a7, #47d7ff); }
.palettes button[data-palette="ultraviolet"] i { background: linear-gradient(135deg, #f28cff, #8f7cff); }
.palettes button[data-palette="cobalt"] i { background: linear-gradient(135deg, #66d9ff, #5577ff); }
.palettes button[data-palette="solar"] i { background: linear-gradient(135deg, #ffc55c, #ff5c67); }
.palettes button[data-palette="mono"] i { background: linear-gradient(135deg, #eeeeea, #666); }
.palettes button[aria-pressed="true"] { border-color: var(--accent); box-shadow: 0 0 14px var(--glow); }
.palettes button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

@media (max-width: 680px) {
  .topbar, footer, main { width: min(100% - 30px, 1180px); }
  .topbar { height: 72px; }
  main { padding-top: 32px; }
  .graph-header { align-items: flex-start; flex-direction: column; gap: 10px; margin-bottom: 20px; }
  .graph-card { padding: 22px 18px 18px; border-radius: 16px; }
  .graph-meta { align-items: flex-end; }
  .legend span { display: none; }
  footer { min-height: 82px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; scroll-behavior: auto !important; }
}
