:root {
  --solana: #9945ff;
  --evm: #8e76ff;
  --neutral: #f76b15;

  --bg: #ffffff;
  --surface: #f7f7f9;
  --line: #e4e4ea;
  --text: #1d1d22;
  --muted: #6c6c78;
  --faint: #a3a3ad;
  --today: #1d1d22;
  --on-today: #ffffff;
  --shadow: 0 1px 2px rgb(0 0 0 / 0.06), 0 4px 14px rgb(0 0 0 / 0.06);
  --tint: 14%;
  --ink-mix: black;
  --ink: 62%;

  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f0f12;
    --surface: #17171c;
    --line: #26262d;
    --text: #ececf1;
    --muted: #9a9aa6;
    --faint: #5c5c67;
    --today: #ececf1;
    --on-today: #0f0f12;
    --shadow: 0 1px 2px rgb(0 0 0 / 0.4), 0 6px 20px rgb(0 0 0 / 0.35);
    --tint: 22%;
    --ink-mix: white;
    --ink: 72%;
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --bg: #0f0f12;
  --surface: #17171c;
  --line: #26262d;
  --text: #ececf1;
  --muted: #9a9aa6;
  --faint: #5c5c67;
  --today: #ececf1;
  --on-today: #0f0f12;
  --shadow: 0 1px 2px rgb(0 0 0 / 0.4), 0 6px 20px rgb(0 0 0 / 0.35);
  --tint: 22%;
  --ink-mix: white;
  --ink: 72%;
  color-scheme: dark;
}

/* Each event's colour, plus the text colour that reads on a solid fill. */
[data-chain="solana"] { --c: var(--solana); --on: #ffffff; }
[data-chain="evm"] { --c: var(--evm); --on: #ffffff; }
[data-chain="neutral"] { --c: var(--neutral); --on: #1f1203; }

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 400 15px/1.45 Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  font-feature-settings: "cv11", "ss01";
  -webkit-font-smoothing: antialiased;
}

button { font: inherit; color: inherit; }

/* ── Header ─────────────────────────────────────────── */

.top {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px 32px;
  max-width: 1400px;
  margin: 0 auto;
  padding: 32px 24px 20px;
}

.brand h1 {
  margin: 0;
  font-size: clamp(28px, 4vw, 40px);
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.05;
}

.brand .mark { color: var(--muted); font-weight: 500; }

.sub {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 15px;
}

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 18px;
  margin: 0;
  padding: 0;
  list-style: none;
  color: var(--muted);
  font-size: 13px;
}

.legend li { display: flex; align-items: center; gap: 7px; }

.swatch {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 3px;
  background: var(--c);
}

/* ── Month grid ─────────────────────────────────────── */

main { max-width: 1400px; margin: 0 auto; padding: 0 24px; }

.month {
  border: 1px solid var(--line);
  border-radius: 14px;
  overflow: hidden;
  background: var(--bg);
}

.dow {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  border-bottom: 1px solid var(--line);
}

.dow span {
  padding: 10px 0 8px;
  text-align: center;
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

/* Day cells draw the grid; events are stacked on top by app.js (stackWeek). */
.week {
  position: relative;
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  /* Three rows fill the screen, like Google Calendar's month view, and grow
     to fit whatever is stacked in them. */
  min-height: max(148px, calc((100vh - 250px) / 3), var(--content, 0px));
  border-bottom: 1px solid var(--line);
}

.week:last-child { border-bottom: 0; }

.cell { border-left: 1px solid var(--line); }
.cell.sun { border-left: 0; }
.cell.past { background: var(--surface); }

.num {
  display: flex;
  justify-content: center;
  align-items: center;
  padding-top: 6px;
  pointer-events: none;
}

.num .n {
  min-width: 26px;
  height: 26px;
  padding: 0 7px;
  border-radius: 13px;
  display: inline-grid;
  place-items: center;
  font-size: 12.5px;
  font-weight: 500;
}

.cell.today .n { background: var(--today); color: var(--on-today); font-weight: 600; }
.cell.past .n { color: var(--faint); }

/* Events: all share the button reset; tiers differ in weight. */
.ev {
  position: absolute;
  z-index: 1;
  min-width: 0;
  margin: 0;
  border: 0;
  text-align: left;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  overflow: hidden;
  white-space: nowrap;
}

.ev:focus-visible { outline: 2px solid var(--text); outline-offset: 1px; }

.ev .ev-title { overflow: hidden; text-overflow: ellipsis; }
.ev .ev-time { font-variant-numeric: tabular-nums; opacity: 0.8; flex: none; }

/* Major: the event's artwork over a solid strip in its chain colour. */
.ev-major {
  flex-direction: column;
  align-items: stretch;
  gap: 0;
  padding: 0;
  border-radius: 9px;
  background: var(--c);
  color: var(--on);
  box-shadow: var(--shadow);
  white-space: normal;
  transition: transform 120ms ease, box-shadow 120ms ease;
}

.ev-major .ev-img { display: block; height: 84px; flex: none; background-color: var(--surface); }

.ev-major .ev-label {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 2px;
  min-height: 52px;
  padding: 7px 11px 8px;
}

.ev-major .ev-title {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -0.01em;
  line-height: 1.2;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.ev-major .ev-meta {
  font-size: 12px;
  font-weight: 500;
  opacity: 0.85;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

.ev-major:hover { transform: translateY(-1px); }

/* Square artwork: a thumbnail beside the title instead of a banner. */
.ev-major.thumb { flex-direction: row; align-items: center; }
.ev-major.thumb .ev-img { width: 52px; height: 52px; margin: 6px 0 6px 6px; border-radius: 6px; }
.ev-major.thumb .ev-label { min-height: 64px; }
.ev-major:hover .ev-img { filter: brightness(1.04); }

/* Medium: a tinted bar, like a Google all-day event. */
.ev-medium {
  height: 24px;
  padding: 0 9px;
  border-radius: 6px;
  background: color-mix(in srgb, var(--c) var(--tint), var(--bg));
  color: color-mix(in srgb, var(--c) var(--ink), var(--ink-mix));
  box-shadow: inset 3px 0 0 var(--c);
  font-size: 12.5px;
  font-weight: 600;
}

.ev-medium:hover { background: color-mix(in srgb, var(--c) calc(var(--tint) + 8%), var(--bg)); }

/* Low: a dot and a line of small text, like a timed Google event. */
.ev-low {
  align-items: flex-start;
  padding: 2px 6px;
  line-height: 16px;
  white-space: normal;
  border-radius: 5px;
  background: transparent;
  color: var(--muted);
  font-size: 11.5px;
  font-weight: 500;
  gap: 5px;
}

.ev-low .dot { width: 7px; height: 7px; margin-top: 4.5px; border-radius: 50%; background: var(--c); flex: none; }
.ev-low .ev-title { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.ev-low:hover { background: var(--surface); color: var(--text); }

/* Pieces that carry on from/into the next row lose their rounded end. */
.ev.cont-l { border-top-left-radius: 0; border-bottom-left-radius: 0; box-shadow: none; }
.ev.cont-r { border-top-right-radius: 0; border-bottom-right-radius: 0; }
.ev-medium.cont-l { box-shadow: none; }
.ev-major.cont-l, .ev-major.cont-r { box-shadow: none; }

/* ── Agenda (phones) ────────────────────────────────── */

.agenda { display: none; }

.a-day { display: grid; grid-template-columns: 56px 1fr; gap: 12px; padding: 14px 0; border-top: 1px solid var(--line); }
.a-list { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.a-day:first-child { border-top: 0; }
.a-day.past { opacity: 0.55; }

.a-date {
  margin: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  font-size: 12px;
  font-weight: 500;
  color: var(--muted);
  line-height: 1.2;
}

.a-date .a-num { font-size: 24px; font-weight: 600; color: var(--text); letter-spacing: -0.02em; }
.a-date small { display: block; font-size: 11px; text-align: center; }

.a-ev {
  display: flex;
  flex-direction: column;
  gap: 1px;
  width: 100%;
  border: 0;
  text-align: left;
  cursor: pointer;
}

.a-title { font-weight: 600; }
.a-meta { font-size: 12.5px; opacity: 0.85; }

.a-major { padding: 12px 14px; border-radius: 11px; background: var(--c); color: var(--on); box-shadow: var(--shadow); overflow: hidden; }
.a-major .a-img { display: block; width: calc(100% + 28px); margin: -12px -14px 10px; aspect-ratio: 1200 / 630; background-color: var(--surface); }
.a-major.thumb { display: grid; grid-template-columns: 48px 1fr; column-gap: 12px; align-items: center; }
.a-major.thumb .a-img { grid-row: span 2; margin: 0; width: 48px; height: 48px; aspect-ratio: auto; border-radius: 6px; }
.a-major .a-title { font-size: 17px; font-weight: 700; letter-spacing: -0.01em; }

.a-medium {
  padding: 8px 12px;
  border-radius: 8px;
  background: color-mix(in srgb, var(--c) var(--tint), var(--bg));
  color: color-mix(in srgb, var(--c) var(--ink), var(--ink-mix));
  box-shadow: inset 3px 0 0 var(--c);
}

.a-low { padding: 4px 2px 4px 18px; background: transparent; position: relative; color: var(--muted); }
.a-low::before { content: ""; position: absolute; left: 4px; top: 11px; width: 7px; height: 7px; border-radius: 50%; background: var(--c); }
.a-low .a-title { font-weight: 500; font-size: 14px; color: var(--text); }

/* ── Detail dialog ──────────────────────────────────── */

dialog {
  width: min(460px, calc(100vw - 32px));
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--bg);
  color: var(--text);
  box-shadow: 0 24px 60px rgb(0 0 0 / 0.3);
  overflow: hidden;
}

dialog::backdrop { background: rgb(10 10 14 / 0.45); backdrop-filter: blur(2px); }

dialog::before { content: ""; display: block; height: 6px; background: var(--c); }
dialog.has-banner::before { display: none; }
dialog.has-banner .close-row { position: absolute; top: 0; right: 0; }
dialog.has-banner .close { background: rgb(0 0 0 / 0.45); color: #fff; }

.d-banner { margin: 0 -24px 18px; aspect-ratio: 1200 / 630; border-bottom: 4px solid var(--c); }

.close-row { display: flex; justify-content: flex-end; padding: 8px 8px 0; margin: 0; }

.close {
  width: 34px;
  height: 34px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 15px;
}

.close:hover { background: var(--surface); color: var(--text); }

#detail-body { padding: 0 24px 24px; }

.d-chain { display: flex; align-items: center; gap: 7px; margin: 0; color: var(--muted); font-size: 12.5px; font-weight: 500; }

.d-head { display: flex; align-items: center; gap: 12px; margin: 6px 0 14px; }
.d-thumb { width: 56px; height: 56px; flex: none; border-radius: 8px; }
#detail-body h2 { margin: 0; font-size: 22px; letter-spacing: -0.02em; line-height: 1.2; }

.d-facts { display: grid; grid-template-columns: 56px 1fr; gap: 6px 12px; margin: 0 0 14px; font-size: 14px; }
.d-facts dt { color: var(--muted); }
.d-facts dd { margin: 0; }

.d-blurb { margin: 0 0 18px; color: var(--muted); font-size: 14px; }

.d-links { display: flex; flex-wrap: wrap; gap: 8px; }

.btn {
  display: inline-flex;
  align-items: center;
  height: 36px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 18px;
  color: var(--text);
  text-decoration: none;
  font-size: 13.5px;
  font-weight: 500;
}

.btn:hover { background: var(--surface); }
.btn.primary { background: var(--c); border-color: var(--c); color: var(--on); font-weight: 600; }
.btn.primary:hover { filter: brightness(1.06); }

/* ── Footer ─────────────────────────────────────────── */

.foot {
  max-width: 1400px;
  margin: 0 auto;
  padding: 20px 24px 40px;
  color: var(--muted);
  font-size: 13px;
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 4px 24px;
}

.foot p { margin: 0; }
.foot strong { color: var(--text); font-weight: 600; }

/* ── Small screens: agenda instead of the grid ──────── */

@media (max-width: 760px) {
  .top { padding: 24px 16px 12px; }
  main { padding: 0 16px; }
  .foot { padding: 20px 16px 32px; }
  .month { display: none; }
  .agenda { display: block; }
}

@media (min-width: 761px) and (max-width: 1040px) {
  .ev-major .ev-label { padding: 6px 9px 7px; }
  .ev-major .ev-img { height: 64px; }
  .ev-major .ev-title { font-size: 13.5px; }
  .ev-low .ev-time { display: none; }
}
