/* ---------------------------------------------------------------------------
   Big Mens Events — shared foundation
   Same brand world as bigmensboard/bigmensdraft: dark-committed, slime-green
   accent, violet secondary, mono eyebrows, sharp small radii. This page does
   not do a light theme — the brand is dark, full stop.
--------------------------------------------------------------------------- */

@font-face {
  font-family: "Cabinet Grotesk";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("/fonts/cabinet-grotesk-400.woff2") format("woff2");
}

@font-face {
  font-family: "Cabinet Grotesk";
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url("/fonts/cabinet-grotesk-500.woff2") format("woff2");
}

@font-face {
  font-family: "Cabinet Grotesk";
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url("/fonts/cabinet-grotesk-700.woff2") format("woff2");
}

@font-face {
  font-family: "Cabinet Grotesk";
  font-style: normal;
  font-weight: 800;
  font-display: swap;
  src: url("/fonts/cabinet-grotesk-800.woff2") format("woff2");
}

:root {
  /* Tells the browser to render native controls (the date/time/month picker
     glyphs, select popups, scrollbars) dark — otherwise Chrome draws those
     icons near-black on our dark fields and they vanish. */
  color-scheme: dark;

  /* Grounds */
  --void: #050507;
  --deep: #0a0a0e;
  --panel: #101016;
  --raised: #16161f;
  --line: #23232e;
  --line-hot: rgba(173, 255, 0, 0.22);

  /* Brand */
  --slime: #adff00;
  --slime-deep: #39ec22;
  --violet: #6821ff;
  --violet-mid: #844aff;
  --violet-pale: #a87eff;

  /* Text */
  --ink: #f3f4ef;
  --muted: #8e9089;
  --faint: #5a5c57;

  /* Semantic state — outside the brand ramp on purpose, so "error" never
     reads as "on brand". */
  --warn: #ffb020;
  --crit: #e5544b;
  --crit-bg: color-mix(in srgb, var(--crit) 16%, var(--deep));

  --display: "Roc Grotesk", "Cabinet Grotesk", "Segoe UI", system-ui, sans-serif;
  --mono: "Roc Grotesk", "Cabinet Grotesk", "Segoe UI", system-ui, sans-serif;

  /* Type scale — 1.25 minor third off a 16px base. */
  --t-xs: 0.7rem;
  --t-sm: 0.8rem;
  --t-base: 0.95rem;
  --t-md: 1.2rem;
  --t-lg: 1.55rem;
  --t-xl: 2.1rem;
  --t-2xl: 3rem;

  --r-sm: 8px;
  --r-md: 12px;
  /* Deliberately small. The left accent's crescent is drawn by this radius
     (see --accent-w), so a larger value fattens and rounds the stroke instead
     of leaving it a slim taper. 4px is the value the chips have always used. */
  --r-chip: 4px;

  /* Calendar grid geometry, shared between the CSS below and the multi-day
     bar positioning in app.js (buildSpanChip). A single-day chip is laid out
     by the grid inside a cell's padding; a spanning bar is absolutely
     positioned over the whole week. They only line up if both work from the
     same column width, gutter and cell padding — hence tokens rather than
     numbers duplicated across two files. */
  --week-gap: 1px;
  --cell-pad-x: 6px;

  /* Width of the type-colour accent every event entry carries down its left
     edge, as a real `border-left`. A border on a rounded box tapers as it
     meets its zero-width neighbours, so it draws a slim crescent that hugs
     the corner — which is the look we want. An inset box-shadow (tried, and
     reverted) stays the full 3px for most of the height and only curves at
     the very ends, which reads as a fat lozenge rather than a stroke.
     Used identically on .chip, .agenda-event and .upcoming-item. */
  --accent-w: 3px;
  --gut: clamp(16px, 3vw, 40px);

  --dur: 0.15s;
}

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

body {
  margin: 0;
  background: var(--void);
  color: var(--ink);
  font-family: var(--display);
  font-size: var(--t-base);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 {
  margin: 0;
  font-weight: 700;
  letter-spacing: -0.02em;
  text-wrap: balance;
}

p {
  margin: 0;
}

ol, ul {
  margin: 0;
  padding: 0;
  list-style: none;
}

button, input, select, textarea {
  font-family: inherit;
  color: inherit;
}

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

.num {
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
}

.eyebrow {
  font-family: var(--mono);
  font-size: var(--t-xs);
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--faint);
}

/* --- Buttons ------------------------------------------------------------ */

.primary-btn,
.ghost-btn,
.danger-btn,
.icon-btn {
  appearance: none;
  cursor: pointer;
  font-family: var(--display);
  font-size: var(--t-sm);
  font-weight: 600;
  border-radius: var(--r-md);
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--ink);
  padding: 9px 16px;
  transition: border-color var(--dur), color var(--dur), background var(--dur), transform var(--dur);
}

.primary-btn {
  background: var(--slime);
  border-color: var(--slime);
  color: #0a0d00;
}

.primary-btn:hover {
  background: var(--slime-deep);
  border-color: var(--slime-deep);
}

.ghost-btn:hover {
  color: var(--slime);
  border-color: var(--faint);
}

.danger-btn {
  background: transparent;
  border-color: var(--crit);
  color: var(--crit);
}

.danger-btn:hover {
  background: color-mix(in srgb, var(--crit) 20%, transparent);
}

.icon-btn {
  padding: 6px 12px;
  font-size: var(--t-md);
  line-height: 1;
}

.primary-btn[disabled],
.ghost-btn[disabled] {
  opacity: 0.5;
  cursor: not-allowed;
}

/* --- App shell / topbar -------------------------------------------------- */

.shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 12px 24px;
  padding: 12px var(--gut);
  background: color-mix(in srgb, var(--void) 88%, transparent);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
}

@media (max-width: 860px) {
  .topbar {
    grid-template-columns: 1fr;
    justify-items: start;
  }
}

/* The brand is the supplied lockup image and nothing else — no text wordmark,
   no eyebrow. */
.brand {
  display: flex;
  align-items: center;
  justify-self: start;
}

.brand-wordmark {
  display: block;
  height: 44px;
  width: auto;
}

.monthnav {
  display: flex;
  align-items: center;
  justify-self: center;
  gap: 8px;
}

.monthnav-label {
  min-width: 12ch;
  text-align: center;
  font-size: var(--t-sm);
  font-weight: 600;
  color: var(--ink);
}

.topbar-actions {
  display: flex;
  align-items: center;
  justify-self: end;
  flex-wrap: nowrap;
  gap: 12px;
}

.topbar-actions .primary-btn,
.topbar-actions .ghost-btn {
  white-space: nowrap;
}

@media (max-width: 860px) {
  .topbar-actions {
    flex-wrap: wrap;
  }
}

#mod-btn.is-active {
  border-color: var(--slime);
  color: var(--slime);
}

.icon-label-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.btn-icon {
  width: 14px;
  height: 14px;
  flex: none;
}

/* --- Legend --------------------------------------------------------------- */

.legend {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  padding: 12px var(--gut);
  border-bottom: 1px solid var(--line);
}

.legend-label {
  display: flex;
  align-items: center;
  font-size: var(--t-xs);
  color: var(--muted);
}

.legend-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

/* Mobile-only control; the chips are always visible on desktop. */
.filters-toggle {
  display: none;
  appearance: none;
  cursor: pointer;
  align-items: center;
  gap: 6px;
  padding: 7px 12px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--ink);
  font-family: var(--display);
  font-size: var(--t-xs);
  font-weight: 600;
}

.filters-count {
  font-family: var(--mono);
  color: var(--slime);
}

.filters-toggle[aria-expanded="true"] {
  border-color: color-mix(in srgb, var(--slime) 40%, var(--line));
}

/* Sections of the mobile schedule. "Running now" is the one that earns colour —
   it is the only group whose contents are happening as you look at it. */
.agenda-day-head.is-live .date {
  color: var(--slime);
}

.agenda-earlier {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.agenda-earlier-btn {
  appearance: none;
  cursor: pointer;
  align-self: start;
  padding: 8px 14px;
  background: transparent;
  border: 1px dashed var(--line);
  border-radius: 999px;
  color: var(--muted);
  font-family: var(--display);
  font-size: var(--t-xs);
  font-weight: 600;
}

.agenda-earlier-btn:hover {
  color: var(--ink);
  border-color: var(--faint);
}

.agenda-earlier-days {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.legend-chip {
  appearance: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  color: var(--muted);
  font-size: var(--t-xs);
  font-weight: 600;
  transition: border-color var(--dur), color var(--dur), background var(--dur), opacity var(--dur);
}

.legend-chip .dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--c, var(--slime));
  flex: none;
}

.legend-chip[aria-pressed="true"] {
  color: var(--ink);
  background: var(--raised);
  border-color: color-mix(in srgb, var(--c, var(--line)) 25%, transparent);
}

.legend-chip[aria-pressed="false"] {
  opacity: 0.45;
}

.legend-chip:hover {
  opacity: 1;
  color: var(--ink);
}

/* Text CTA, not a filled button — pushed to the far right of the filters
   row so it reads as a standalone action, not another filter chip. Sits
   fine wrapped onto its own line on mobile since .legend already wraps. */
.export-btn {
  appearance: none;
  cursor: pointer;
  margin-left: auto;
  padding: 6px 4px;
  background: transparent;
  border: 0;
  color: var(--ink);
  font-family: var(--display);
  font-size: var(--t-xs);
  font-weight: 600;
  transition: color var(--dur);
}

.export-btn:hover {
  color: var(--slime);
}

.export-btn[disabled] {
  opacity: 0.5;
  cursor: not-allowed;
}

/* --- Layout ---------------------------------------------------------------- */

.layout {
  flex: 1;
  display: grid;
  /* Sidebar grows a little with the viewport so a 1440p/4K monitor doesn't
     leave a fixed 300px rail next to a very wide calendar. */
  grid-template-columns: minmax(0, 1fr) clamp(300px, 21vw, 400px);
  gap: 24px;
  padding: 24px var(--gut) 40px;
  /* Was a hard 1440px cap, which left big empty gutters on wide monitors.
     Still bounded so the 7 columns never stretch absurdly on ultrawides. */
  max-width: min(2400px, 100%);
  margin: 0 auto;
  width: 100%;
  align-items: start;
}

@media (max-width: 1080px) {
  .layout {
    grid-template-columns: minmax(0, 1fr);
  }
}

.calendar-wrap {
  min-width: 0;
  align-self: stretch;
  display: flex;
  flex-direction: column;
}

/* --- Calendar grid ---------------------------------------------------------- */

.weekday-row {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 1px;
  padding: 0 0 6px;
}

.weekday-row span {
  font-family: var(--mono);
  font-size: var(--t-xs);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--faint);
  text-align: center;
}

.calendar-grid {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  gap: 1px;
  background: var(--line);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  overflow: hidden;
}

/* One row per week: a 7-column grid of day cells (unchanged below) plus an
   absolutely-positioned overlay carrying only the multi-day spanning bars
   (see .week-spans). Row height keeps the same responsive floor the single
   grid used to give every row via grid-auto-rows: minmax(...,1fr) — min-height
   is the floor, flex-grow fills any extra vertical space, and the row still
   grows past that floor if a tall stack of spanning bars needs more room. */
.calendar-week {
  position: relative;
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: var(--week-gap);
  background: var(--line);
  flex: 1 1 clamp(104px, 11.5vh, 190px);
  min-height: clamp(104px, 11.5vh, 190px);
  flex-shrink: 0;
}

.day-cell {
  position: relative;
  background: var(--deep);
  padding: 6px var(--cell-pad-x) 8px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.day-cell.is-outside {
  background: var(--void);
}

.day-cell.is-outside .day-num,
.day-cell.is-outside .chip {
  opacity: 0.4;
}

.day-cell.is-today {
  /* Softer than a full-strength slime rule — the disc on the date number is
     the primary "today" cue, so the cell edge only needs to hint. */
  outline: 1px solid color-mix(in srgb, var(--slime) 35%, transparent);
  outline-offset: -1px;
  z-index: 1;
}

.day-cell-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.day-num {
  font-family: var(--mono);
  font-size: var(--t-xs);
  color: var(--muted);
}

/* Today's number sits in a slime disc with the numeral knocked out dark —
   #0a0d00 is the same on-slime ink the primary button uses. */
.day-cell.is-today .day-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 999px;
  background: var(--slime);
  color: #0a0d00;
  font-weight: 700;
}

.day-add-btn {
  appearance: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--slime);
  border-radius: var(--r-sm);
  width: 18px;
  height: 18px;
  padding: 0;
  line-height: 1;
  font-size: var(--t-sm);
  opacity: 0;
  transition: opacity var(--dur), color var(--dur), border-color var(--dur);
}

.day-cell:hover .day-add-btn,
.day-add-btn:focus-visible {
  opacity: 1;
}

.day-add-btn:hover {
  color: var(--slime);
  border-color: var(--slime);
}

.day-chips {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-height: 0;
  overflow: hidden;
}

.chip {
  appearance: none;
  cursor: pointer;
  display: block;
  width: 100%;
  text-align: left;
  border: 0;
  /* Full-strength type colour — this accent matches the legend dot, not the
     softened 25% stroke used for outlines. See --accent-w for why this is a
     border rather than an inset shadow. */
  border-left: var(--accent-w) solid var(--c, var(--slime));
  background-color: color-mix(in srgb, var(--c, var(--slime)) 16%, var(--panel));
  color: var(--ink);
  border-radius: var(--r-chip);
  padding: 2px 6px;
  font-size: 0.68rem;
  line-height: 1.3;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: transform var(--dur), background-color var(--dur);
}

.chip:hover {
  transform: translateY(-1px);
  background-color: color-mix(in srgb, var(--c, var(--slime)) 26%, var(--panel));
}

.chip .chip-host {
  color: var(--muted);
}

/* Continuation days (event started on an earlier cell) get a subtler,
   striped treatment so the eye reads "this keeps going" at a glance. */
/* (3) A bar cut by a week boundary keeps the same fill and text as its first
   segment; only its cut edge changes — squared off, and with no left accent
   on a continued-from-the-left segment, so the run reads as one continuous
   line instead of a separate chip with a clipped corner. */
.chip.is-cont-left {
  /* No accent on a segment continued from the previous week — the run already
     started, so re-stamping the cap there would read as a second event. */
  border-left: 0;
  border-top-left-radius: 0;
  border-bottom-left-radius: 0;
  padding-left: 6px;
}

.chip.is-cont-right {
  border-top-right-radius: 0;
  border-bottom-right-radius: 0;
}

/* Read-only WiseOldMan competitions render in their mapped type's colour and
   share the same SOLID left accent as a hand-made event. They used to get a
   dashed one, but a dash pattern down a 6px-radius edge gets bitten into by
   the corner curve at both ends, so the bar read as broken rather than as a
   deliberate dash — and it was the only accent in the app that didn't run the
   full height. The "WOM" tag beside the title (itself dash-outlined) is the
   read-only signal now. */

.chip-wom-tag {
  display: inline-block;
  margin-left: 4px;
  vertical-align: middle;
  font-family: var(--mono);
  font-size: 0.55rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  padding: 0 4px;
  border-radius: 3px;
  border: 1px dashed var(--c, var(--slime));
  color: var(--c, var(--slime));
}

.chip-more {
  appearance: none;
  cursor: pointer;
  border: 0;
  background: transparent;
  color: var(--faint);
  font-family: var(--mono);
  font-size: var(--t-xs);
  text-align: left;
  padding: 2px 6px;
}

.chip-more:hover {
  color: var(--slime);
}

/* A multi-day event renders as ONE continuous bar spanning the days it
   covers within a week row (see computeWeekSpans/buildSpanChip in app.js),
   instead of a repeated chip in every cell it touches. The overlay sits on
   top of that week's day cells; pointer-events are re-enabled per-bar so
   the per-day "+" add-event button underneath stays clickable everywhere a
   bar isn't. */
.week-spans {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  pointer-events: none;
  z-index: 2;
}

.chip.chip-span {
  position: absolute;
  box-sizing: border-box;
  display: flex;
  align-items: center;
  gap: 4px;
  pointer-events: auto;
}

.chip-span-label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1 1 auto;
  min-width: 0;
}

/* Understated "keeps going" marker at a bar's cut edge — paired with the
   squared-off edge above, it's the only cue that the run continues into the
   neighbouring week. */
.chip-span-caret {
  flex: none;
  color: var(--c, var(--slime));
  font-weight: 700;
}

/* --- Agenda (mobile) ------------------------------------------------------- */

.agenda-list {
  display: none;
  flex-direction: column;
  gap: 18px;
}

.agenda-day {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.agenda-day-head {
  display: flex;
  align-items: baseline;
  gap: 8px;
  padding-bottom: 4px;
  border-bottom: 1px solid var(--line);
}

.agenda-day-head .date {
  font-size: var(--t-sm);
  font-weight: 700;
}

.agenda-day-head.is-today .date {
  color: var(--slime);
}

.agenda-event {
  appearance: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  text-align: left;
  padding: 10px 12px;
  background-color: var(--panel);
  border: 1px solid var(--line);
  /* Same accent as .chip, so a row's left cap matches its grid chip. */
  border-left: var(--accent-w) solid var(--c, var(--slime));
  border-radius: var(--r-sm);
}

.agenda-event .info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

/* Row for the title text + (WOM rows only) the small "WOM" tag beside it. */
.title-line {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.agenda-event .title,
.upcoming-item .title {
  flex: 1;
  min-width: 0;
  font-size: var(--t-sm);
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.wom-tag {
  flex: none;
  font-family: var(--mono);
  font-size: 0.6rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  padding: 1px 5px;
  border-radius: 4px;
  border: 1px dashed var(--c, var(--slime));
  color: var(--c, var(--slime));
}

.agenda-event .meta {
  font-family: var(--mono);
  font-size: var(--t-xs);
  color: var(--muted);
}

.agenda-empty {
  color: var(--faint);
  font-size: var(--t-sm);
  padding: 24px 0;
  text-align: center;
}

/* --- Upcoming panel --------------------------------------------------------- */

/* The bounty card and the upcoming panel share one sticky column so the
   bounty card can sit directly above Upcoming without splitting the grid
   into a third track. */
.sidebar {
  display: flex;
  flex-direction: column;
  gap: 24px;
  position: sticky;
  top: 84px;
}

@media (max-width: 1080px) {
  .sidebar {
    position: static;
  }
}

.upcoming {
  background: var(--deep);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: 16px 18px;
}

.upcoming-title {
  padding-bottom: 10px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 12px;
}

.upcoming-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.upcoming-item {
  display: flex;
  gap: 10px;
  padding: 10px;
  background-color: var(--panel);
  border: 1px solid var(--line);
  /* See .chip / .agenda-event — one accent mechanism across all three. */
  border-left: var(--accent-w) solid var(--c, var(--slime));
  border-radius: var(--r-sm);
  cursor: pointer;
  appearance: none;
  width: 100%;
  text-align: left;
}

.upcoming-item .info {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.upcoming-item .meta {
  font-family: var(--mono);
  font-size: var(--t-xs);
  color: var(--muted);
}

.upcoming-empty {
  color: var(--faint);
  font-size: var(--t-sm);
}

/* --- Live bounty widget ------------------------------------------------------ */

/* Reuses the .upcoming panel chrome (ground, border, radius, padding) so the
   two read as one family sitting in the sidebar. It only exists while a
   bounty is actually running — app.js renders nothing at all otherwise — and
   splits into a panel per bounty when several overlap. */
.bounty-card {
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--deep);
  color: inherit;
  padding: 16px 18px;
}

/* Matches the "Upcoming" heading, which is an <h2> and so inherits weight 700. */
.bounty-card-eyebrow {
  display: block;
  margin-bottom: 12px;
  font-weight: 700;
}

.bounty-card-body {
  display: flex;
  flex-direction: column;
}

/* Two or more concurrent bounties share the widget's width. auto-fit rather
   than a fixed 2 columns, so a third bounty wraps to a second row instead of
   shrinking every panel past legibility. Each panel gets its own outline
   rather than a divider between siblings: a `+ .bounty-panel { border-left }`
   rule can't tell "next column" from "first panel of the next row", and
   stamps a stray rule down the widget's own left edge once there are three. */
.bounty-card-body.is-split {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 10px;
}

.bounty-card-body.is-split .bounty-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  padding: 12px 10px;
  transition: border-color var(--dur);
}

.bounty-card-body.is-split .bounty-panel:hover {
  border-color: var(--faint);
}

/* The clickable body of one bounty. `position: relative` anchors the
   "Claimed" stamp; the stamp is a sibling of .bounty-panel-content precisely
   so the dimming below never touches it. */
.bounty-panel {
  position: relative;
  display: block;
  width: 100%;
  min-width: 0;
  appearance: none;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  text-align: center;
  padding: 0;
  cursor: pointer;
}

.bounty-panel-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  transition: opacity var(--dur), filter var(--dur);
}

.bounty-panel:hover .bounty-panel-content {
  opacity: 0.85;
}

/* Claimed: the content recedes (it's history now) but stays legible enough to
   recognise which bounty went, and the stamp sits over the top in the
   semantic crit red rather than a brand colour. */
.bounty-panel.is-claimed .bounty-panel-content {
  opacity: 0.28;
  filter: grayscale(0.7);
}

.bounty-panel.is-claimed:hover .bounty-panel-content {
  opacity: 0.4;
}

.bounty-claimed-stamp {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) rotate(-8deg);
  pointer-events: none;
  font-size: var(--t-md);
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--crit);
  border: 2px solid var(--crit);
  border-radius: var(--r-sm);
  padding: 2px 12px;
  background: color-mix(in srgb, var(--void) 70%, transparent);
  white-space: nowrap;
}

.bounty-panel.is-compact .bounty-claimed-stamp {
  font-size: var(--t-sm);
  letter-spacing: 0.08em;
  padding: 2px 8px;
}

/* One item image, or a row of them when a bounty names several drops. */
.bounty-item-images {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  flex-wrap: wrap;
  width: 100%;
}

.bounty-item-image {
  width: 120px;
  height: 120px;
  flex: none;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Several items have to share the panel's width, so they drop to a thumbnail
   size — same again, smaller, inside a split widget. */
.bounty-item-images.is-multi .bounty-item-image {
  width: 64px;
  height: 64px;
}

.bounty-panel.is-compact .bounty-item-image {
  width: 76px;
  height: 76px;
}

.bounty-panel.is-compact .bounty-item-images.is-multi .bounty-item-image {
  width: 48px;
  height: 48px;
}

.bounty-item-image img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

.bounty-card-placeholder {
  width: 100%;
  height: 100%;
  border-radius: var(--r-sm);
  background: var(--panel);
  border: 1px solid var(--line);
}

.bounty-card-info {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
  width: 100%;
}

.bounty-card-title {
  font-size: var(--t-md);
  font-weight: 700;
  color: var(--violet-mid);
  overflow-wrap: anywhere;
}

.bounty-panel.is-compact .bounty-card-title {
  font-size: var(--t-base);
}

.bounty-card-source,
.bounty-card-meta {
  font-family: var(--mono);
  font-size: var(--t-xs);
  color: var(--muted);
  overflow-wrap: anywhere;
}

.bounty-card-prize {
  font-family: var(--mono);
  font-size: var(--t-sm);
  font-weight: 700;
  color: var(--slime);
}

/* --- Dialogs ----------------------------------------------------------------- */

dialog.dialog {
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--deep);
  color: var(--ink);
  padding: 22px 24px;
  width: min(90vw, 480px);
  max-height: 85vh;
  overflow-y: auto;
}

dialog.dialog-sm { width: min(90vw, 380px); }
dialog.dialog-md { width: min(90vw, 460px); }
dialog.dialog-lg { width: min(92vw, 560px); }

dialog.dialog::backdrop {
  background: color-mix(in srgb, var(--void) 70%, transparent);
  backdrop-filter: blur(3px);
}

.dialog-title {
  font-size: var(--t-lg);
  margin-bottom: 6px;
}

.dialog-sub {
  color: var(--muted);
  font-size: var(--t-sm);
  margin-bottom: 16px;
}

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.details-mod-actions {
  display: flex;
  gap: 10px;
  margin-right: auto;
}

/* --- Forms ------------------------------------------------------------------- */

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 14px;
  border: 0;
  padding: 0;
}

/* display:flex above would otherwise defeat the hidden attribute, leaving an
   empty subtype select visible for types that don't take one. */
.field[hidden],
[hidden] {
  display: none !important;
}

.field-label {
  font-family: var(--mono);
  font-size: var(--t-xs);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.field-optional {
  text-transform: none;
  letter-spacing: 0;
  color: var(--faint);
}

.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.field input[type="text"],
.field input[type="password"],
.field input[type="date"],
.field input[type="time"],
.field input[type="month"],
.field input[type="number"],
.field select,
.field textarea {
  appearance: none;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  color: var(--ink);
  padding: 9px 10px;
  font-size: var(--t-sm);
  font-family: var(--display);
  width: 100%;
}

/* Every single-line control in a field row is pinned to the same height.
   Left to themselves, <select> and <input type="date"> lay their inner text
   out differently (the select ignores the inherited line-height, the date
   input adds a picker button), so "Start time" ended up a couple of pixels
   shorter than "Date" sitting right beside it. Excludes textarea, which is
   free to grow, and input[type=color], which has its own swatch sizing. */
.field input[type="text"],
.field input[type="password"],
.field input[type="date"],
.field input[type="time"],
.field input[type="month"],
.field input[type="number"],
.field select {
  height: 40px;
  line-height: 1.4;
}

.field textarea {
  resize: vertical;
  font-family: var(--display);
}

.field input:focus-visible,
.field select:focus-visible,
.field textarea:focus-visible {
  outline: 2px solid var(--slime);
  outline-offset: 1px;
}

.field-error {
  color: var(--crit);
  font-size: var(--t-xs);
  background: var(--crit-bg);
  border: 1px solid color-mix(in srgb, var(--crit) 40%, var(--line));
  border-radius: var(--r-sm);
  padding: 8px 10px;
  margin-bottom: 10px;
}

.convert-hint {
  font-family: var(--mono);
  font-size: var(--t-xs);
  color: var(--slime);
  margin: -6px 0 14px;
  min-height: 1em;
}

/* Static (non-live) helper text under a field — e.g. the BIG Bounty month
   input's "runs 1st -> end of month" hint. Unlike .convert-hint this isn't a
   live conversion, so it stays faint rather than slime-coloured. */
.field-hint {
  font-family: var(--mono);
  font-size: var(--t-xs);
  color: var(--faint);
  margin: -6px 0 14px;
}

/* Trailing unit adornment (the "M" on the Prize field). */
.field-adorned {
  position: relative;
}

/* Needs to match the specificity of `.field input[type="text"]` above (and sit
   after it) or the shorthand padding there wins and text runs under the "M". */
.field-adorned input[type="text"] {
  padding-right: 30px;
}

.field-adorn {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  font-family: var(--mono);
  font-size: var(--t-sm);
  color: var(--muted);
  pointer-events: none;
}

/* --- Bounty items (BIG Bounty item list + wiki picker) ------------------------ */

/* A bounty can name several drops, so its items are a stack of rows rather
   than one fixed drop-name/item-source pair. Each row is [name + source] with
   a remove button, and the row is a grid so the remove button never squeezes
   the fields on a narrow dialog. */
.bounty-items {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 10px;
}

.bounty-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: start;
  gap: 8px;
}

.bounty-item-fields {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr);
  gap: 8px;
  min-width: 0;
}

/* Matches .day-add-btn's quiet square-icon language, sized to line up with
   the 40px field height beside it. */
.bounty-item-remove {
  appearance: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  flex: none;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  background: transparent;
  color: var(--muted);
  font-size: var(--t-md);
  line-height: 1;
  transition: color var(--dur), border-color var(--dur);
}

.bounty-item-remove:hover {
  color: var(--crit);
  border-color: var(--crit);
}

.bounty-item-add {
  align-self: start;
}

.bounty-items-hint {
  margin-top: 0;
}

@media (max-width: 560px) {
  .bounty-item-fields {
    grid-template-columns: minmax(0, 1fr);
  }
}

.combobox {
  position: relative;
}

.combobox-listbox {
  position: absolute;
  z-index: 20;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  max-height: 220px;
  overflow-y: auto;
  background: var(--raised);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
}

.combobox-option {
  padding: 8px 10px;
  font-size: var(--t-sm);
  cursor: pointer;
}

.combobox-option.is-active,
.combobox-option:hover {
  background: color-mix(in srgb, var(--slime) 14%, transparent);
  color: var(--slime);
}

.type-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 8px;
}

.type-card {
  appearance: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--r-md); /* matches the legend filter chips */
  color: var(--muted);
  font-size: var(--t-xs);
  font-weight: 600;
  text-align: left;
  transition: border-color var(--dur), color var(--dur), background var(--dur);
}

.type-card .dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--c, var(--slime));
  flex: none;
}

.type-card[aria-checked="true"] {
  color: var(--ink);
  background: var(--raised);
  border-color: color-mix(in srgb, var(--c, var(--slime)) 25%, transparent);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--c, var(--slime)) 25%, transparent);
}

.duration-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.pill {
  appearance: none;
  cursor: pointer;
  padding: 7px 12px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  color: var(--muted);
  font-size: var(--t-xs);
  font-weight: 600;
  transition: border-color var(--dur), color var(--dur), background var(--dur);
}

.pill[aria-pressed="true"] {
  color: #0a0d00;
  background: var(--slime);
  border-color: var(--slime);
}

.pill:hover {
  color: var(--ink);
  border-color: var(--faint);
}

.duration-custom {
  margin-top: 10px;
}

/* --- Manage types dialog ------------------------------------------------------ */

.types-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 46vh;
  overflow-y: auto;
  margin-bottom: 4px;
}

.types-empty {
  color: var(--faint);
  font-size: var(--t-sm);
  padding: 16px 0;
  text-align: center;
}

.type-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
}

.type-row .swatch {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--c, var(--slime));
  flex: none;
}

.type-row .info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.type-row .label {
  font-size: var(--t-sm);
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.type-row .subtype-summary {
  font-family: var(--mono);
  font-size: var(--t-xs);
  color: var(--muted);
}

.type-row .actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: none;
}

/* Colour picker + "has a picker?" checkbox in the type editor. */

.field input[type="color"] {
  appearance: none;
  cursor: pointer;
  width: 64px;
  height: 38px;
  padding: 3px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
}

.field input[type="color"]::-webkit-color-swatch-wrapper {
  padding: 0;
}

.field input[type="color"]::-webkit-color-swatch {
  border: 0;
  border-radius: var(--r-sm);
}

.checkbox-field {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 14px;
}

.checkbox-field input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--slime);
  cursor: pointer;
}

.checkbox-field .field-label {
  cursor: pointer;
}

/* --- Event details popover --------------------------------------------------- */

.details-type-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  border-radius: 999px;
  font-family: var(--mono);
  font-size: var(--t-xs);
  letter-spacing: 0.04em;
  background: transparent;
  /* Stroke and label both take the full-strength type colour — the same value
     the legend's bullet dot uses, not the softened 25% outline mix. */
  color: var(--c, var(--slime));
  font-weight: 700;
  border: 1px solid var(--c, var(--slime));
  margin-bottom: 10px;
}

.details-title {
  font-size: var(--t-lg);
  margin-bottom: 12px;
}

.details-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 8px;
  font-size: var(--t-sm);
}

/* One fact per card — host, times, duration, prize each get their own box. */
.detail-card {
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 9px 11px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  min-width: 0;
}

.details-grid dt {
  font-family: var(--mono);
  font-size: var(--t-xs);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--faint);
}

.details-grid dd {
  margin: 0;
  color: var(--ink);
  overflow-wrap: anywhere;
}

.details-grid dd.detail-prize {
  color: var(--slime);
  font-weight: 700;
}

/* The "Status" row when a bounty has been claimed — same red the widget's
   stamp uses, so the two read as the same state. */
.details-grid dd.detail-claimed {
  color: var(--crit);
  font-weight: 700;
}

/* Labelled free-text block below the facts grid — used for Event Info and
   Rules (each only rendered when present). */
.details-block {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.details-block-label {
  display: block;
  font-family: var(--mono);
  font-size: var(--t-xs);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--faint);
  margin-bottom: 4px;
}

.details-block-text {
  font-size: var(--t-sm);
  color: var(--ink);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

/* "View on WiseOldMan" — the read-only link out to the synced competition. */
.details-wom-link-wrap {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.details-wom-link {
  color: var(--slime);
  font-size: var(--t-sm);
  font-weight: 600;
  text-decoration: none;
  border-bottom: 1px solid color-mix(in srgb, var(--slime) 40%, transparent);
}

.details-wom-link:hover {
  border-bottom-color: var(--slime);
}

.confirm-delete {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--crit);
  font-size: var(--t-sm);
}

/* --- Day popover --------------------------------------------------------------- */

.day-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 50vh;
  overflow-y: auto;
}

/* --- Toasts ---------------------------------------------------------------------- */

.toast-stack {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
  pointer-events: none;
}

.toast {
  pointer-events: auto;
  padding: 10px 18px;
  border-radius: var(--r-sm);
  background: var(--raised);
  border: 1px solid var(--line);
  color: var(--ink);
  font-size: var(--t-sm);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
  animation: toast-in 0.2s ease-out;
}

.toast.is-error {
  border-color: color-mix(in srgb, var(--crit) 50%, var(--line));
  color: var(--crit);
}

.toast.is-success {
  border-color: color-mix(in srgb, var(--slime) 50%, var(--line));
}

@keyframes toast-in {
  from { opacity: 0; transform: translateY(8px); }
}

/* --- Footer ---------------------------------------------------------------------- */

.foot {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 12px;
  padding: 24px var(--gut) 40px;
  font-size: var(--t-xs);
  color: var(--faint);
}

.foot a {
  color: var(--muted);
  text-decoration: none;
  border-bottom: 1px solid var(--line);
}

.foot a:hover {
  color: var(--slime);
  border-color: var(--slime);
}

/* --- Mobile (<=720px): agenda list replaces the grid, upcoming panel folds
   into it ---------------------------------------------------------------- */

/* --- Phones ------------------------------------------------------------------
   The month grid is unreadable at this width, so it is replaced by the
   schedule (see renderAgenda). The header is also put on a strict diet: it
   used to eat ~350px — nearly half a phone screen — before a single event,
   between a 44px wordmark, a full-width month row, four labelled buttons and
   three rows of filter chips. Everything below works that down to roughly a
   third of it. */
@media (max-width: 720px) {
  .weekday-row,
  .calendar-grid {
    display: none;
  }

  .agenda-list {
    display: flex;
  }

  .layout {
    /* One column, and the live-bounty widget moves ABOVE the schedule — it is
       the most glanceable thing on the page and used to sit below a whole
       month of events where nobody would scroll to it. */
    grid-template-columns: minmax(0, 1fr);
    padding: 16px var(--gut) 88px; /* bottom room for the compose button */
    gap: 16px;
    /* .layout is flex:1 inside a full-height shell, so it usually has spare
       vertical space. Grid's default align-content spreads that across the row
       tracks — which meant that with no bounty running, the empty widget row
       still swallowed ~124px and pushed the schedule to mid-screen. Pack the
       rows to the top instead. */
    align-content: start;
  }

  /* No bounty running: take the wrapper out of the flow entirely rather than
     leaving a zero-height box contributing a gap. */
  #bounty-card-wrap:empty {
    display: none;
  }

  .sidebar {
    order: -1;
    gap: 16px;
  }

  .upcoming {
    /* Redundant now the schedule opens at today and leads with what's live. */
    display: none;
  }

  .field-row {
    grid-template-columns: 1fr;
  }

  .topbar {
    padding: 8px var(--gut);
    grid-template-columns: auto 1fr;
    gap: 6px 8px;
    justify-items: stretch;
    /* backdrop-filter makes an element a containing block for its
       position:fixed descendants, which pinned the compose button to the
       header instead of the viewport. A solid bar costs nothing here and is
       cheaper to composite on a phone anyway. */
    backdrop-filter: none;
    background: var(--void);
  }

  /* Explicit placement: brand and actions share row 1, month nav owns row 2.
     Left to auto-placement the actions land on a third row by themselves. */
  .brand {
    grid-column: 1;
    grid-row: 1;
  }

  .topbar-actions {
    grid-column: 2;
    grid-row: 1;
  }

  .monthnav {
    grid-column: 1 / -1;
    grid-row: 2;
  }

  .brand-wordmark {
    height: 28px;
  }

  /* Buttons collapse to their icons; the labels are the bulk of the width and
     each icon is still a 40px tap target. */
  .topbar-actions {
    justify-self: end;
    gap: 6px;
  }

  .topbar-actions .btn-label,
  .export-btn .btn-label {
    display: none;
  }

  .topbar-actions .ghost-btn {
    width: 40px;
    height: 40px;
    padding: 0;
    justify-content: center;
  }

  .topbar-actions .btn-icon,
  .export-btn .btn-icon {
    width: 18px;
    height: 18px;
  }

  .monthnav {
    justify-content: space-between;
    width: 100%;
  }

  .monthnav-label {
    min-width: 0;
    flex: 1;
    text-align: center;
  }

  /* "+ New event" becomes a floating compose button rather than competing for
     header space — it is the one action a mod takes repeatedly. */
  #new-event-btn {
    position: fixed;
    right: var(--gut);
    bottom: 20px;
    z-index: 60;
    width: 56px;
    height: 56px;
    padding: 0;
    border-radius: 50%;
    font-size: 0;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.5);
  }

  #new-event-btn::after {
    content: "+";
    font-size: 1.9rem;
    line-height: 1;
    font-weight: 400;
  }

  /* Filters fold away behind their toggle. */
  .legend {
    padding: 8px var(--gut);
    gap: 8px;
  }

  .legend-label {
    display: none;
  }

  .filters-toggle {
    display: inline-flex;
  }

  .legend-chips {
    display: none;
    width: 100%;
    padding-top: 4px;
  }

  .legend-chips.is-open {
    display: flex;
  }

  .export-btn {
    padding: 0;
    width: 40px;
    height: 40px;
    justify-content: center;
  }

  /* The bounty widget is a hero block on desktop; on a phone that was ~570px
     of mostly empty space before the schedule. Lay it out sideways and shrink
     the thumbnail so it reads as a banner, not a page. */
  .bounty-card {
    padding: 12px 14px;
  }

  .bounty-card-eyebrow {
    margin-bottom: 8px;
  }

  .bounty-card-body:not(.is-split) .bounty-panel-content {
    flex-direction: row;
    align-items: center;
    gap: 12px;
    text-align: left;
  }

  .bounty-card-body:not(.is-split) .bounty-item-images {
    width: auto;
    flex: none;
  }

  .bounty-card-body:not(.is-split) .bounty-item-image {
    width: 56px;
    height: 56px;
  }

  .bounty-card-body:not(.is-split) .bounty-card-info {
    text-align: left;
    gap: 2px;
  }

  .bounty-card-body:not(.is-split) .bounty-card-title {
    font-size: var(--t-base);
  }

  /* Day headings stay visible while you scroll their events. */
  .agenda-day-head {
    position: sticky;
    top: 0;
    z-index: 2;
    background: var(--void);
    padding-top: 6px;
  }

  .agenda-list {
    gap: 22px;
  }
}

/* --- Reduced motion -------------------------------------------------------------- */

@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}
