:root {
  --bg: #0b0618;
  --panel: #150b2e;
  --line: #2c1a55;
  --ink: #e8e0ff;
  --dim: #9b8ec4;
  --faint: #6b5d96;
  --cyan: #4ff0e4;
  --pink: #ff5fc8;
  --focus: #ffe066;

  /* Heat ramp, empty -> busiest. Interpolated in app.js.
     Ends in light pink rather than cyan on purpose: interpolating magenta to
     cyan in sRGB passes through a muted periwinkle, so mid counts looked hotter
     than high ones. These four rise steadily in both lightness and saturation,
     so a brighter cell always means more posts. Cyan stays the link colour. */
  --h0: #170d30;
  --h1: #241458;
  --h2: #5b21b6;
  --h3: #c93bd4;
  --h4: #ff9ceb;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.5 ui-sans-serif, system-ui, "Segoe UI", Roboto, sans-serif;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Layered glow, kept behind everything and out of the way of text. */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  background:
    radial-gradient(60vw 40vh at 15% -5%, #3d1b7a55, transparent 70%),
    radial-gradient(50vw 35vh at 90% 0%, #b0308c33, transparent 70%);
  pointer-events: none;
}

a { color: var(--cyan); text-decoration: none; }
a:hover { text-decoration: underline; }

:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

/* ---- bars ---- */

.bar {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px 18px;
  background: #0d0722cc;
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(6px);
  position: sticky;
  top: 0;
  z-index: 10;
  flex-wrap: wrap;
}

.foot {
  position: static;
  border-bottom: 0;
  border-top: 1px solid var(--line);
  margin-top: auto;
  color: var(--faint);
  font-size: 12px;
}

.home {
  font-weight: 600;
  letter-spacing: 0.06em;
  color: var(--ink);
}

.spacer { flex: 1; }

.stat { color: var(--dim); font-size: 13px; font-variant-numeric: tabular-nums; }

/* ---- search ---- */

.searchform { display: flex; }

.q {
  background: #ffffff0d;
  border: 1px solid var(--line);
  border-radius: 4px;
  color: var(--ink);
  font: inherit;
  font-size: 13px;
  padding: 5px 10px;
  width: 15em;
  max-width: 40vw;
}
.q::placeholder { color: var(--faint); }
.q:focus { border-color: var(--cyan); outline: none; background: #ffffff14; }

.sorts { display: flex; gap: 6px; align-items: center; margin: 0 0 16px; }
.sortbtn {
  background: none;
  border: 1px solid var(--line);
  color: var(--dim);
  border-radius: 3px;
  font: inherit;
  font-size: 12px;
  padding: 3px 10px;
  cursor: pointer;
}
.sortbtn:hover { color: var(--cyan); border-color: var(--cyan); }
.sortbtn[aria-pressed="true"] { background: var(--line); color: var(--ink); border-color: var(--h3); }

.hit { background: var(--h3); color: #fff; border-radius: 2px; padding: 0 1px; }

.progress { color: var(--faint); font-size: 12px; margin: 0 0 14px; }

.result {
  display: grid;
  grid-template-columns: 6.6em 1fr auto;
  gap: 12px;
  align-items: baseline;
  padding: 8px 12px;
  border-radius: 5px;
  background: #ffffff05;
  border: 1px solid transparent;
}
.result:hover { background: #ffffff0d; border-color: var(--line); }
.result .rdate { font-size: 12px; font-variant-numeric: tabular-nums; }

@media (max-width: 640px) {
  .result { grid-template-columns: 1fr; gap: 2px; }
  .q { width: 9em; }
}

.crumbs { display: flex; gap: 8px; align-items: center; color: var(--faint); font-size: 13px; }
.crumbs .sep { color: var(--faint); }

main { padding: 22px 18px 40px; max-width: 1100px; margin: 0 auto; width: 100%; }

h1 { font-size: 20px; margin: 0 0 4px; font-weight: 600; letter-spacing: 0.02em; }
h2 { font-size: 15px; margin: 26px 0 10px; font-weight: 600; color: var(--dim); }
.sub { color: var(--dim); font-size: 13px; margin: 0 0 20px; }

.loading, .empty { color: var(--dim); }

.error {
  border: 1px solid #a33;
  background: #2a0f1e;
  padding: 14px 16px;
  border-radius: 6px;
  max-width: 60ch;
}
.error code { color: var(--cyan); }

/* ---- overview: years x months ---- */

.years { display: flex; flex-direction: column; gap: 4px; }

.yearrow {
  display: grid;
  grid-template-columns: 3.4em repeat(12, 1fr) 5em;
  gap: 4px;
  align-items: center;
}

.yearlabel { color: var(--dim); font-size: 13px; font-variant-numeric: tabular-nums; }
.yeartotal { color: var(--faint); font-size: 12px; text-align: right; font-variant-numeric: tabular-nums; }

.monthhead {
  display: grid;
  grid-template-columns: 3.4em repeat(12, 1fr) 5em;
  gap: 4px;
  color: var(--faint);
  font-size: 11px;
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.monthhead span { text-align: center; }

.cell {
  display: block;
  border: 0;
  border-radius: 3px;
  padding: 0;
  height: 30px;
  cursor: pointer;
  color: var(--ink);
  font: inherit;
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  line-height: 30px;
  text-align: center;
  transition: transform 90ms ease, box-shadow 90ms ease;
}
.cell:hover { transform: scale(1.08); box-shadow: 0 0 0 1px var(--cyan); }
.cell[disabled] { cursor: default; opacity: 0.35; }
.cell[disabled]:hover { transform: none; box-shadow: none; }

/* ---- month view: day grid ---- */

.daygrid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 5px;
  max-width: 680px;
}

.dowhead {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 5px;
  max-width: 680px;
  color: var(--faint);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 6px;
}
.dowhead span { text-align: center; }

.day {
  position: relative;
  border: 0;
  border-radius: 4px;
  aspect-ratio: 1;
  cursor: pointer;
  color: var(--ink);
  font: inherit;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  transition: transform 90ms ease, box-shadow 90ms ease;
}
.day:hover { transform: scale(1.06); box-shadow: 0 0 0 1px var(--cyan); }
.day .dnum { font-size: 12px; color: #ffffffb0; }
.day .dcount { font-size: 14px; font-weight: 600; font-variant-numeric: tabular-nums; }
.day.blank { background: none; cursor: default; }
.day.blank:hover { transform: none; box-shadow: none; }
.day[disabled] { cursor: default; }
.day[disabled]:hover { transform: none; box-shadow: none; }
.day.today { box-shadow: 0 0 0 2px var(--pink); }

/* ---- post list ---- */

.posts { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 2px; }

.post {
  display: grid;
  grid-template-columns: 4.2em 1fr auto;
  gap: 12px;
  align-items: baseline;
  padding: 9px 12px;
  border-radius: 5px;
  background: #ffffff05;
  border: 1px solid transparent;
}
.post:hover { background: #ffffff0d; border-color: var(--line); }

.ptime { color: var(--faint); font-size: 12px; font-variant-numeric: tabular-nums; }
.ptitle { font-size: 14px; overflow-wrap: anywhere; }
.ptitle a { color: var(--ink); }
.ptitle a:hover { color: var(--cyan); }
.pmeta { color: var(--faint); font-size: 12px; margin-top: 3px; display: flex; gap: 10px; flex-wrap: wrap; }
.pmeta .host { color: var(--dim); }
.pmeta .flair { color: var(--pink); }
.pnums { color: var(--faint); font-size: 12px; text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }

.nsfw { color: #ff7a7a; border: 1px solid #7a2b2b; border-radius: 3px; padding: 0 4px; font-size: 10px; }
.removed { color: var(--faint); font-style: italic; }

.body {
  grid-column: 2 / -1;
  margin: 8px 0 0;
  padding: 10px 12px;
  background: #00000040;
  border-left: 2px solid var(--line);
  border-radius: 3px;
  color: var(--dim);
  font-size: 13px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  max-height: 22em;
  overflow: auto;
}

.bodybtn {
  background: none;
  border: 1px solid var(--line);
  color: var(--dim);
  border-radius: 3px;
  font: inherit;
  font-size: 11px;
  padding: 1px 6px;
  cursor: pointer;
}
.bodybtn:hover { color: var(--cyan); border-color: var(--cyan); }

/* ---- misc ---- */

.legend { display: flex; align-items: center; gap: 6px; color: var(--faint); font-size: 11px; margin: 14px 0 0; }
.legend .swatch { width: 22px; height: 11px; border-radius: 2px; }

.rowlinks { display: flex; gap: 14px; flex-wrap: wrap; margin: 0 0 18px; font-size: 13px; }

.onthis { display: flex; flex-direction: column; gap: 3px; }
.onthis-row { display: grid; grid-template-columns: 3.4em 1fr; gap: 10px; align-items: center; }
.onthis-row .yr { color: var(--dim); font-size: 13px; font-variant-numeric: tabular-nums; }
.onthis-row .barwrap { background: #ffffff08; border-radius: 3px; height: 20px; position: relative; }
.onthis-row .barfill { height: 100%; border-radius: 3px; min-width: 2px; }
.onthis-row .n { position: absolute; right: 6px; top: 0; line-height: 20px; font-size: 11px; color: var(--dim); font-variant-numeric: tabular-nums; }

@media (max-width: 640px) {
  .yearrow, .monthhead { grid-template-columns: 2.8em repeat(12, 1fr); }
  .yeartotal { display: none; }
  .monthhead span:last-child { display: none; }
  .post { grid-template-columns: 1fr; gap: 2px; }
  .pnums { text-align: left; }
  .body { grid-column: 1; }
}

@media (prefers-reduced-motion: reduce) {
  .cell, .day { transition: none; }
  .cell:hover, .day:hover { transform: none; }
}
