:root {
  color-scheme: light;
  --surface-1:      #fcfcfb;
  --page-plane:     #f9f9f7;
  --text-primary:   #0b0b0b;
  --text-secondary: #52514e;
  --text-muted:     #898781;
  --gridline:       #e1e0d9;
  --baseline:       #c3c2b7;
  --border:         rgba(11, 11, 11, 0.10);

  /* diverging pair: panic (red) <-> gloat (blue), neutral gray midpoint */
  --panic:          #e34948;
  --panic-track:    #f6d9d9;
  --gloat:          #2a78d6;
  --gloat-track:    #d3e3f8;
  --neutral:        #898781;
  --neutral-track:  #f0efec;

  /* sequential blue, for the history line */
  --series-line:    #2a78d6;
}

@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) {
    color-scheme: dark;
    --surface-1:      #1a1a19;
    --page-plane:     #0d0d0d;
    --text-primary:   #ffffff;
    --text-secondary: #c3c2b7;
    --text-muted:     #898781;
    --gridline:       #2c2c2a;
    --baseline:       #383835;
    --border:         rgba(255, 255, 255, 0.10);

    --panic:          #e66767;
    --panic-track:    #4a2626;
    --gloat:          #3987e5;
    --gloat-track:    #1c344f;
    --neutral:        #c3c2b7;
    --neutral-track:  #383835;

    --series-line:    #3987e5;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --surface-1:      #1a1a19;
  --page-plane:     #0d0d0d;
  --text-primary:   #ffffff;
  --text-secondary: #c3c2b7;
  --text-muted:     #898781;
  --gridline:       #2c2c2a;
  --baseline:       #383835;
  --border:         rgba(255, 255, 255, 0.10);

  --panic:          #e66767;
  --panic-track:    #4a2626;
  --gloat:          #3987e5;
  --gloat-track:    #1c344f;
  --neutral:        #c3c2b7;
  --neutral-track:  #383835;

  --series-line:    #3987e5;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  background: var(--page-plane);
  color: var(--text-primary);
}

.page {
  max-width: 880px;
  margin: 0 auto;
  padding: 24px 16px 64px;
}

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

header.top h1 {
  font-size: 20px;
  margin: 0;
}

.site-logo {
  display: block;
  height: 36px;
  width: auto;
}

/* logo art is dark ink on transparent; flip it for dark backgrounds */
@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) .site-logo {
    filter: invert(1);
  }
}
:root[data-theme="dark"] .site-logo {
  filter: invert(1);
}

header.top p {
  margin: 4px 0 0;
  color: var(--text-secondary);
  font-size: 13px;
}

#theme-toggle {
  border: 1px solid var(--border);
  background: var(--surface-1);
  color: var(--text-secondary);
  border-radius: 6px;
  padding: 6px 10px;
  font-size: 12px;
  cursor: pointer;
}

.card {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 20px;
  margin-bottom: 20px;
}

.card h2 {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-secondary);
  margin: 0 0 16px;
}

/* hero + meter */
.hero {
  display: flex;
  align-items: baseline;
  gap: 12px;
  margin-bottom: 18px;
}

.hero .value {
  font-size: 56px;
  font-weight: 600;
  line-height: 1;
}

.hero .label-group {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 16px;
  color: var(--text-primary);
}

.hero .dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

.hero .meta {
  margin-left: auto;
  text-align: right;
  font-size: 12px;
  color: var(--text-muted);
}

.meter-track {
  position: relative;
  height: 10px;
  border-radius: 6px;
  background: linear-gradient(
    to right,
    var(--panic) 0%,
    var(--panic-track) 35%,
    var(--neutral-track) 50%,
    var(--gloat-track) 65%,
    var(--gloat) 100%
  );
  margin: 12px 0 8px;
}

.meter-marker {
  position: absolute;
  top: -5px;
  width: 4px;
  height: 20px;
  background: var(--text-primary);
  border-radius: 2px;
  transform: translateX(-2px);
}

.meter-ticks {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  color: var(--text-muted);
}

.breakdown {
  margin-top: 10px;
  font-size: 12px;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

/* filters */
.filters {
  display: flex;
  gap: 6px;
  margin-bottom: 12px;
}

.filters button {
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-secondary);
  border-radius: 6px;
  padding: 5px 10px;
  font-size: 12px;
  cursor: pointer;
}

.filters button[aria-pressed="true"] {
  background: var(--gloat-track);
  color: var(--text-primary);
  border-color: var(--gloat);
}

/* chart */
#chart-wrap {
  position: relative;
}

#history-chart {
  width: 100%;
  height: auto;
  display: block;
  overflow: visible;
}

.chart-tooltip {
  position: absolute;
  pointer-events: none;
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 6px 10px;
  font-size: 12px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
  transform: translate(-50%, -110%);
  white-space: nowrap;
  display: none;
}

.chart-tooltip .tt-value {
  font-weight: 600;
  color: var(--text-primary);
}

.chart-tooltip .tt-date {
  color: var(--text-muted);
}

/* ads + affiliate */
.ad-slot {
  border: 1px dashed var(--border);
  border-radius: 10px;
  padding: 8px;
  margin-bottom: 20px;
  text-align: center;
}

.ad-slot-label {
  display: block;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.sponsored-card .sponsored-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.sponsored-card .sponsored-list li {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 8px;
}

.sponsored-card a {
  color: var(--gloat);
  font-weight: 600;
  text-decoration: none;
}

.sponsored-card a:hover {
  text-decoration: underline;
}

.sponsored-card .disclosure {
  font-size: 11px;
  color: var(--text-muted);
}

.button-link {
  border: 1px solid var(--border);
  background: var(--surface-1);
  color: var(--text-secondary);
  border-radius: 6px;
  padding: 6px 10px;
  font-size: 12px;
  text-decoration: none;
}

.policy-card h2 {
  font-size: 15px;
  margin: 20px 0 8px;
}

.policy-card h2:first-child {
  margin-top: 0;
}

.policy-card p {
  color: var(--text-secondary);
  font-size: 13px;
  line-height: 1.6;
  margin: 0 0 12px;
}

.policy-card a {
  color: var(--gloat);
}

.site-footer {
  margin-top: 8px;
  padding-top: 16px;
  border-top: 1px solid var(--gridline);
  color: var(--text-muted);
  font-size: 11px;
  line-height: 1.5;
  text-align: center;
}

.site-footer p {
  margin: 0 0 6px;
}

.site-footer a {
  color: var(--text-secondary);
}

.empty-state {
  color: var(--text-muted);
  font-size: 13px;
  padding: 24px 0;
  text-align: center;
}

/* tweets table */
table.tweets {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

table.tweets th {
  text-align: left;
  color: var(--text-muted);
  font-weight: 500;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  padding: 6px 8px;
  border-bottom: 1px solid var(--gridline);
}

table.tweets td {
  padding: 8px;
  border-bottom: 1px solid var(--gridline);
  vertical-align: top;
}

table.tweets tr:last-child td {
  border-bottom: none;
}

.tweet-text {
  color: var(--text-primary);
}

.tweet-link {
  display: inline-block;
  margin-top: 2px;
  font-size: 0.85em;
  color: var(--text-muted);
  text-decoration: none;
}

.tweet-link:hover {
  color: var(--text-primary);
  text-decoration: underline;
}

.score-cell {
  display: flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.score-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.date-cell {
  color: var(--text-muted);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
