:root {
  --accent: #007b5e;
  --accent-dark: #005f48;
  --accent-soft: #e6f4ef;
  --bg: #ffffff;
  --surface: #fbfbfa;
  --border: #e5e7eb;
  --text: #1a1f2b;
  --text-muted: #5c6370;
  --up: #0e8a4a;
  --down: #c1322c;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.04), 0 4px 12px rgba(0, 0, 0, 0.04);
  --radius: 10px;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, "Helvetica Neue",
    Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--sans);
  color: var(--text);
  background: var(--bg);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a {
  color: var(--accent-dark);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

.container {
  max-width: 1120px;
  margin: 0 auto;
  padding: 0 20px;
}

/* ---------- Header ---------- */
.site-header {
  border-bottom: 1px solid var(--border);
  background: var(--bg);
  position: sticky;
  top: 0;
  z-index: 20;
}

.site-header .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 14px;
  padding-bottom: 14px;
  gap: 20px;
  flex-wrap: wrap;
}

.brand {
  font-weight: 700;
  font-size: 1.05rem;
  color: var(--text);
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.brand:hover {
  text-decoration: none;
}

.brand-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  background: var(--accent);
  color: #fff;
  border-radius: 8px;
  font-weight: 700;
  font-size: 0.9rem;
  letter-spacing: 0.5px;
}

.site-nav {
  display: flex;
  gap: 18px;
}

.site-nav a {
  color: var(--text-muted);
  font-size: 0.95rem;
}

/* ---------- Ticker ---------- */
.ticker {
  border-top: 1px solid var(--border);
  background: var(--surface);
  overflow-x: auto;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
}

.ticker-inner {
  display: inline-flex;
  gap: 8px;
  padding: 10px 20px;
}

.ticker-item {
  display: inline-flex;
  align-items: baseline;
  gap: 8px;
  padding: 6px 12px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 0.85rem;
}

.ticker-item .pair {
  font-weight: 600;
  color: var(--text-muted);
  letter-spacing: 0.3px;
}

.ticker-item .rate {
  font-family: var(--mono);
  font-weight: 600;
}

.ticker-item .chg {
  font-family: var(--mono);
  font-size: 0.8rem;
}

.chg.up {
  color: var(--up);
}

.chg.down {
  color: var(--down);
}

/* ---------- Hero / typography ---------- */
h1,
h2,
h3 {
  line-height: 1.2;
  color: var(--text);
}

h1 {
  font-size: clamp(1.6rem, 2.6vw + 1rem, 2.4rem);
  margin: 32px 0 10px;
  letter-spacing: -0.01em;
}

h2 {
  font-size: 1.35rem;
  margin: 40px 0 16px;
  letter-spacing: -0.01em;
}

h3 {
  font-size: 1.05rem;
  margin: 0 0 4px;
}

.lede {
  font-size: 1.05rem;
  color: var(--text-muted);
  max-width: 72ch;
  margin: 0 0 30px;
}

.breadcrumbs {
  margin: 22px 0 0;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.breadcrumbs a {
  color: var(--text-muted);
}

.breadcrumbs span {
  margin: 0 4px;
  color: #b5b8c0;
}

/* ---------- Controls ---------- */
.controls {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}

.pair-tabs,
.timeframe-group {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 4px;
}

.pair-tabs button,
.timeframe-group button {
  font: inherit;
  font-size: 0.82rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  background: transparent;
  color: var(--text-muted);
  border: 0;
  padding: 7px 14px;
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}

.pair-tabs button:hover,
.timeframe-group button:hover {
  color: var(--text);
}

.pair-tabs button.is-active,
.timeframe-group button.is-active {
  background: var(--accent);
  color: #fff;
  box-shadow: var(--shadow);
}

/* ---------- Chart section ---------- */
.chart-section {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow);
  margin-bottom: 24px;
}

.chart-wrap {
  position: relative;
  height: clamp(280px, 45vh, 460px);
}

.chart-footnote {
  margin-top: 10px;
  font-size: 0.78rem;
  color: var(--text-muted);
}

/* ---------- Stats grid ---------- */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
  margin-bottom: 30px;
}

.stat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
}

.stat-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 4px;
}

.stat-value {
  font-family: var(--mono);
  font-size: 1.15rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.stat-sub {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 2px;
}

/* ---------- On This Day ---------- */
.on-this-day {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  background: var(--accent-soft);
  margin-bottom: 40px;
}

.on-this-day h2 {
  margin-top: 0;
}

.otd-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px;
  margin-top: 10px;
}

.otd-card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
}

.otd-card .label {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.otd-card .rate {
  font-family: var(--mono);
  font-size: 1.4rem;
  font-weight: 600;
  margin: 4px 0;
}

.otd-card .date {
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* ---------- Year grid ---------- */
.year-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 14px;
  margin: 10px 0 40px;
}

.year-card {
  display: block;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  color: var(--text);
  transition: transform 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}

.year-card:hover {
  border-color: var(--accent);
  box-shadow: var(--shadow);
  text-decoration: none;
  transform: translateY(-1px);
}

.year-card .year {
  font-weight: 700;
  font-size: 1.4rem;
  letter-spacing: -0.01em;
}

.year-card .chg {
  float: right;
  font-family: var(--mono);
  font-weight: 600;
  font-size: 0.9rem;
}

.year-card .hilo {
  font-family: var(--mono);
  font-size: 0.85rem;
  color: var(--text-muted);
  margin: 8px 0 6px;
}

.year-card .event {
  font-size: 0.8rem;
  color: var(--text-muted);
  min-height: 2.2em;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

/* ---------- Tables ---------- */
.table-scroll {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
}

.month-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
  font-variant-numeric: tabular-nums;
}

.month-table th,
.month-table td {
  padding: 10px 12px;
  text-align: right;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.month-table th:first-child,
.month-table td:first-child {
  text-align: left;
  font-weight: 600;
}

.month-table thead th {
  background: var(--surface);
  position: sticky;
  top: 0;
  font-weight: 600;
  color: var(--text-muted);
  letter-spacing: 0.03em;
}

.month-table tbody tr:last-child td {
  border-bottom: 0;
}

/* ---------- Summary / events ---------- */
.summary-card {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  margin-bottom: 20px;
}

.events-timeline {
  list-style: none;
  padding: 0;
  margin: 0 0 30px;
}

.events-timeline li {
  padding: 12px 14px;
  border-left: 3px solid var(--accent);
  background: var(--surface);
  border-radius: 0 var(--radius) var(--radius) 0;
  margin-bottom: 10px;
}

.events-timeline .ev-date {
  font-family: var(--mono);
  font-size: 0.78rem;
  color: var(--text-muted);
}

.events-timeline .ev-label {
  display: block;
  font-weight: 600;
  margin-top: 2px;
}

.events-timeline .ev-meta {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 4px;
}

.badge {
  display: inline-block;
  font-size: 0.72rem;
  padding: 2px 8px;
  border-radius: 999px;
  font-weight: 600;
  text-transform: capitalize;
  letter-spacing: 0.03em;
}

.badge.bullish {
  background: #e2f5ea;
  color: var(--up);
}

.badge.bearish {
  background: #fbe5e3;
  color: var(--down);
}

.badge.neutral {
  background: var(--surface);
  color: var(--text-muted);
  border: 1px solid var(--border);
}

.adjacent-years {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin: 32px 0 40px;
  flex-wrap: wrap;
}

.adjacent-years a {
  padding: 12px 18px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  flex: 1 1 160px;
  text-align: center;
  font-weight: 600;
  color: var(--text);
}

.adjacent-years a:hover {
  border-color: var(--accent);
  text-decoration: none;
}

/* ---------- Footer ---------- */
.site-footer {
  border-top: 1px solid var(--border);
  margin-top: 60px;
  padding: 30px 0 40px;
  background: var(--surface);
  color: var(--text-muted);
  font-size: 0.85rem;
}

.site-footer .disclaimer {
  margin-top: 6px;
  font-size: 0.78rem;
  color: #8a8f99;
}

/* ---------- Responsive ---------- */
@media (max-width: 640px) {
  .site-header .container {
    padding-top: 10px;
    padding-bottom: 10px;
  }
  .controls {
    gap: 10px;
  }
  .pair-tabs button,
  .timeframe-group button {
    padding: 6px 10px;
    font-size: 0.78rem;
  }
  .stat-value {
    font-size: 1rem;
  }
}
