:root {
  /* slate palette mirroring opendata.dev */
  --bg: #ffffff;
  --bg-alt: #f8fafc;
  --bg-pill: #f1f5f9;
  --border: #e2e8f0;
  --border-strong: #cbd5e1;
  --text: #334155;
  --text-strong: #0f172a;
  --text-muted: #64748b;
  --text-faint: #94a3b8;

  --accent: #10b981;
  --accent-strong: #059669;
  --accent-bg: #ecfdf5;
  --accent-border: #a7f3d0;

  --warn: #ea580c;
  --warn-bg: #fff7ed;
  --warn-border: #fed7aa;

  --pulse-add-bg: #d1fae5;
  --pulse-del-bg: #fee2e2;
  --pulse-del-text: #b91c1c;

  --json-key: #0f172a;
  --json-str: #059669;
  --json-num: #2563eb;
  --json-lit: #9333ea;
}

* { box-sizing: border-box; }

html, body {
  margin: 0; padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: 'JetBrains Mono', ui-monospace, Menlo, monospace;
  font-size: 13px;
  line-height: 1.55;
}

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

a { color: var(--text-strong); text-decoration: underline; text-underline-offset: 4px; }
a:hover { color: var(--accent-strong); }

.muted { color: var(--text-faint); font-weight: 400; }

/* ----- topbar ----- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  max-width: 1200px;
  width: 100%;
  margin: 0 auto;
  padding: 24px 32px 8px;
}
.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  color: var(--text-strong);
}
.logo-mark { color: var(--accent); }
.nav { display: flex; gap: 8px; font-size: 12px; }
.nav a {
  border: 1px solid var(--border);
  border-radius: 9999px;
  padding: 4px 12px;
  text-decoration: none;
  color: var(--text-muted);
}
.nav a:hover { color: var(--text-strong); border-color: var(--border-strong); }

.github-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding-right: 4px !important;
}
.github-link .gh-icon { color: var(--text-strong); flex-shrink: 0; }
.github-link .gh-stars {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  margin-left: 4px;
  padding: 1px 7px 1px 8px;
  border-left: 1px solid var(--border);
  font-variant-numeric: tabular-nums;
  color: var(--text-muted);
}
.github-link .star-icon { color: #eac54f; flex-shrink: 0; }
.github-link:hover .gh-stars { border-left-color: var(--border-strong); }

.intro {
  max-width: 1200px;
  width: 100%;
  margin: 0 auto;
  padding: 8px 32px 8px 36px;
  border-left: 2px solid var(--border-strong);
  margin-left: max(32px, calc((100vw - 1200px) / 2 + 32px));
  margin-right: max(32px, calc((100vw - 1200px) / 2 + 32px));
  color: var(--text);
  font-size: 13px;
  line-height: 1.65;
}
.intro p { margin: 0; }
.intro p + p { margin-top: 6px; color: var(--text-muted); }

.kill-btn {
  background: var(--bg);
  color: var(--pulse-del-text);
  border: 1px solid var(--pulse-del-text);
  border-radius: 9999px;
  padding: 3px 10px;
  font: inherit;
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.15s ease;
}
.kill-btn:hover { background: var(--pulse-del-bg); }
.kill-btn:disabled { opacity: 0.45; cursor: not-allowed; }
.kill-btn.dying {
  animation: shake 0.5s ease-in-out;
  background: var(--warn-bg);
  border-color: var(--warn);
  color: var(--warn);
}
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  10%, 50%, 90% { transform: translateX(-2px); }
  30%, 70% { transform: translateX(2px); }
}

/* ----- counters row ----- */
.counters-row {
  max-width: 1200px;
  width: calc(100% - 64px);
  margin: 12px auto 0;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}
.counter {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px;
  text-align: center;
}
.counter span {
  display: block;
  font-size: 22px;
  font-weight: 700;
  color: var(--text-strong);
  font-variant-numeric: tabular-nums;
}
.counter label {
  display: block;
  margin-top: 2px;
  color: var(--text-faint);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

/* Inline phase + countdown + progress bar inside the drains/min counter. */
.cycle-counter { padding-bottom: 8px; }
.cycle-meta {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 6px;
  margin-top: 6px;
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}
.cycle-phase {
  font-size: 10px !important;
  font-weight: 700 !important;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 1px 7px;
  border-radius: 9999px;
  background: var(--bg-pill);
  border: 1px solid var(--border);
  color: var(--text-muted) !important;
  display: inline-block !important;
}
.cycle-counter.accumulate .cycle-phase {
  color: var(--text-strong) !important;
  border-color: var(--border-strong);
}
.cycle-counter.drain .cycle-phase {
  background: var(--accent-bg);
  border-color: var(--accent-border);
  color: var(--accent-strong) !important;
}
.cycle-left {
  font-size: 11px !important;
  font-weight: 400 !important;
  color: var(--text-muted) !important;
  display: inline-block !important;
}
.cycle-bar {
  margin-top: 6px;
  width: 100%;
  height: 3px;
  background: var(--bg-pill);
  border-radius: 2px;
  overflow: hidden;
}
.cycle-bar-fill {
  height: 100%;
  width: 0%;
  background: var(--text-faint);
  transition: width 0.5s linear;
}
.cycle-counter.drain .cycle-bar-fill { background: var(--accent-strong); }

/* ----- main grid ----- */
main {
  flex: 1;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 24px;
  width: 100%;
  max-width: 1200px;
  margin: 16px auto 0;
  padding: 0 32px 24px;
  min-height: 0;
}

.col {
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-height: 0;
}

/* ----- panels ----- */
.panel {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 16px 18px;
}
.panel h2 {
  margin: 0;
  font-size: 13px;
  font-weight: 700;
  color: var(--text-strong);
}
.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  margin-bottom: 12px;
}

/* Scrollable panels (ticker, manifest) fill remaining vertical space */
.scroll-panel {
  flex: 1 1 0;
  min-height: 280px;
  display: flex;
  flex-direction: column;
}

/* ----- form ----- */
.form { display: flex; flex-direction: column; gap: 10px; }
textarea, input[type="text"], .form input:not([type]) {
  background: var(--bg);
  color: var(--text-strong);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px 10px;
  font: inherit;
  resize: vertical;
}
textarea { min-height: 56px; }
textarea:focus, .form input:focus {
  outline: none;
  border-color: var(--text-faint);
}

.az-picker { border: 0; padding: 0; margin: 0; display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.az-picker legend { color: var(--text-muted); padding: 0; margin-right: 4px; font-size: 12px; }
.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--border);
  border-radius: 9999px;
  padding: 3px 10px;
  cursor: pointer;
  user-select: none;
  font-size: 12px;
  color: var(--text-muted);
}
.pill input { accent-color: var(--accent-strong); margin: 0; }
.pill:has(input:checked) {
  background: var(--accent-bg);
  border-color: var(--accent-border);
  color: var(--accent-strong);
}

.form-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
button[type="submit"] {
  background: var(--text-strong);
  color: var(--bg);
  border: 0;
  padding: 8px 18px;
  border-radius: 9999px;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  flex-shrink: 0;
}
button[type="submit"]:hover { background: var(--accent-strong); }
button[type="submit"]:disabled { opacity: 0.5; cursor: not-allowed; }
.burst-btn {
  background: var(--bg);
  color: var(--text-strong);
  border: 1px solid var(--border-strong);
  padding: 7px 14px;
  border-radius: 9999px;
  font: inherit;
  font-weight: 700;
  font-size: 12px;
  cursor: pointer;
  flex-shrink: 0;
}
.burst-btn:hover { border-color: var(--accent-strong); color: var(--accent-strong); }
.burst-btn:disabled { opacity: 0.5; cursor: not-allowed; }

.status { margin: 0; min-height: 1em; color: var(--text-muted); font-size: 12px; flex: 1 1 100%; }
.status.bad { color: var(--pulse-del-text); }
.status.ok { color: var(--accent-strong); }

/* ----- filter pills ----- */
.filter-pills { display: flex; gap: 6px; margin-bottom: 8px; }
.filter-pill {
  background: var(--bg);
  color: var(--text-muted);
  border: 1px solid var(--border);
  border-radius: 9999px;
  padding: 3px 10px;
  font: inherit;
  font-size: 11px;
  cursor: pointer;
}
.filter-pill:hover { border-color: var(--border-strong); color: var(--text-strong); }
.filter-pill.active {
  background: var(--accent-bg);
  border-color: var(--accent-border);
  color: var(--accent-strong);
}

/* Shown above the ticker only while the consumer is in accumulate phase, */
/* so a user who just submitted understands why their tweet hasn't shown up. */
.ticker-notice {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  margin-bottom: 8px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg-pill);
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.4;
}
.ticker-notice[hidden] { display: none; }
.ticker-notice strong { color: var(--text-strong); font-weight: 700; }
.ticker-notice-dot {
  width: 8px;
  height: 8px;
  border-radius: 9999px;
  background: var(--text-faint);
  flex-shrink: 0;
  animation: ticker-notice-pulse 1.4s ease-in-out infinite;
}
@keyframes ticker-notice-pulse {
  0%, 100% { opacity: 0.4; }
  50% { opacity: 1; }
}

/* ----- ticker ----- */
.ticker {
  list-style: none;
  margin: 0;
  padding: 0 4px 0 0;
  flex: 1 1 0;
  min-height: 0;
  overflow-y: auto;
}
.ticker::-webkit-scrollbar { width: 8px; }
.ticker::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }
.ticker .empty {
  padding: 16px 0;
  color: var(--text-faint);
  font-style: italic;
  text-align: center;
}
.ticker .tweet {
  padding: 10px 0;
  border-top: 1px solid var(--border);
  animation: fadein 0.4s ease-out;
}
.ticker .tweet:first-child { border-top: 0; }
.ticker .tweet.mine {
  background: var(--accent-bg);
  margin: 0 -8px;
  padding-left: 8px;
  padding-right: 8px;
  border-radius: 6px;
  border-top-color: transparent;
}
.ticker .tweet.mine + .tweet { border-top-color: transparent; }
.ticker .tweet.hidden { display: none; }
.ticker .tweet .text {
  color: var(--text-strong);
  word-break: break-word;
}
.ticker .tweet .meta {
  margin-top: 4px;
  color: var(--text-faint);
  font-size: 11px;
  word-break: break-all;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.ticker .tweet .meta .loc {
  color: var(--text-muted);
}
.ticker .tweet .seed-badge,
.ticker .tweet .you-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: var(--bg-pill);
  border: 1px solid var(--border);
  border-radius: 9999px;
  padding: 0 7px;
  height: 16px;
  vertical-align: 1px;
  font-size: 10px;
  color: var(--text-muted);
  margin-right: 8px;
}
.ticker .tweet .you-badge {
  background: var(--accent-bg);
  border-color: var(--accent-border);
  color: var(--accent-strong);
  font-weight: 700;
}
.ticker .tweet .seed-badge::before {
  content: "";
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--accent);
}
@keyframes fadein {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ----- manifest JSON ----- */
.manifest {
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 12px 14px;
  margin: 0;
  flex: 1 1 0;
  min-height: 0;
  overflow: auto;
  font-size: 12px;
  line-height: 1.7;
  color: var(--text);
}
.manifest::-webkit-scrollbar { width: 8px; height: 8px; }
.manifest::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }
.manifest code { font-family: inherit; }

.manifest .json-key { color: var(--json-key); font-weight: 500; }
.manifest .json-str { color: var(--json-str); }
.manifest .json-num { color: var(--json-num); }
.manifest .json-lit { color: var(--json-lit); }
.manifest .epoch-line.bumped {
  background: var(--warn-bg);
  border-radius: 4px;
  animation: epoch-flash 1.6s ease-out;
}
@keyframes epoch-flash {
  0% { background: var(--warn-bg); }
  100% { background: transparent; }
}
.manifest .entry { display: inline; transition: background 0.25s ease; border-radius: 4px; }
.manifest .entry.pulse-add { background: var(--pulse-add-bg); }
.manifest .entry.pulse-del { background: var(--pulse-del-bg); color: var(--pulse-del-text); }
.manifest .entry.pulse-mine { box-shadow: 0 0 0 2px var(--accent-border) inset; }
.manifest .entry.pulse-del .json-key,
.manifest .entry.pulse-del .json-str,
.manifest .entry.pulse-del .json-num { opacity: 0.55; }

.cta {
  margin: 12px 0 0;
  font-size: 11px;
  color: var(--text-faint);
  flex-shrink: 0;
}
.cta code {
  background: var(--bg-pill);
  border: 1px solid var(--border);
  padding: 1px 6px;
  border-radius: 4px;
  color: var(--text-strong);
}

/* ----- hover-overs ----- */
.hint {
  cursor: help;
  border-bottom: 1px dotted var(--text-faint);
}
.hint:hover { border-bottom-color: var(--text-strong); }

/* Pills have their own 4-sided border — restore the bottom edge so .hint */
/* doesn't replace it with a dotted line. */
.pill.hint {
  cursor: pointer;
  border-bottom-color: var(--border);
  border-bottom-style: solid;
}
.pill.hint:has(input:checked) { border-bottom-color: var(--accent-border); }

/* Inside the JSON pre, no underline (it would clash with quote glyphs) — */
/* just a hover background. */
.manifest .json-key.hint {
  border-bottom: 0;
  border-radius: 3px;
  padding: 0 2px;
  margin: 0 -2px;
  transition: background 0.12s ease;
}
.manifest .json-key.hint:hover { background: var(--bg-pill); }

/* Buttons that are also .hint shouldn't get a dotted underline either — */
/* they have their own visual affordance. */
.kill-btn.hint, .burst-btn.hint { border-bottom-style: solid; }

/* Standalone "?" help mark — used when a button shouldn't itself carry */
/* a tooltip (avoids hover-on-action confusion). */
.help-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  border-radius: 9999px;
  border: 1px solid var(--border-strong);
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 700;
  line-height: 1;
  border-bottom-style: solid;
}
.help-mark:hover { color: var(--text-strong); border-color: var(--text-strong); }

/* Legend dots already have their own visual styling — keep .hint's */
/* underline off and use cursor:help on the wrapper instead. */
.legend-item.hint { border-bottom: 0; }

.tooltip {
  position: fixed;
  z-index: 1000;
  max-width: 300px;
  background: var(--text-strong);
  color: #f8fafc;
  padding: 8px 10px;
  border-radius: 6px;
  font-size: 11px;
  line-height: 1.55;
  pointer-events: none;
  opacity: 0;
  transform: translateY(4px);
  transition: opacity 0.12s ease, transform 0.12s ease;
  box-shadow: 0 6px 24px rgba(15, 23, 42, 0.18);
  white-space: normal;
  font-weight: 400;
}
.tooltip.visible {
  opacity: 1;
  transform: translateY(0);
}
.tooltip code {
  background: rgba(255, 255, 255, 0.12);
  padding: 0 4px;
  border-radius: 3px;
  font-family: inherit;
  font-size: 10px;
}

/* ----- pulse legend ----- */
.legend {
  display: flex;
  gap: 14px;
  margin-bottom: 8px;
  font-size: 11px;
  color: var(--text-muted);
  align-items: center;
}
.legend-item { display: inline-flex; align-items: center; gap: 6px; }
.legend .dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  flex-shrink: 0;
}
.legend .dot-add { background: var(--pulse-add-bg); border: 1px solid var(--accent-strong); }
.legend .dot-del { background: var(--pulse-del-bg); border: 1px solid var(--pulse-del-text); }

/* ----- footer ----- */
.foot {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 16px 32px 24px;
  font-size: 12px;
  color: var(--text-faint);
  border-top: 1px solid var(--border);
  margin-top: 8px;
}
.foot a { color: var(--text-faint); }
.foot a:hover { color: var(--text-strong); }

.discord-link {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}
.discord-link .discord-icon { color: #5865F2; flex-shrink: 0; }
.discord-link:hover .discord-icon { color: var(--text-strong); }

/* ----- responsive ----- */
@media (max-width: 900px) {
  main { grid-template-columns: 1fr; }
  /* Mobile: ticker first (most engaging), manifest second. */
  .col:last-of-type { order: 2; }
  .manifest-panel { max-height: 80vh; min-height: 60vh; }
}
@media (max-width: 540px) {
  .counters-row { grid-template-columns: repeat(3, 1fr); gap: 6px; }
  .counter span { font-size: 18px; }
}
