:root {
  color-scheme: light dark;
  --bg: #f5f6f4;
  --surface: #ffffff;
  --ink: #1b2127;
  --muted: #59636d;
  --rule: #dfe3e5;
  --copper: #8f5326;      /* text-safe copper on light (≥4.5:1) */
  --copper-soft: #c38452; /* trend line */
  --up: #1d7347;
  --down: #b0383a;
  --focus: #8f5326;
  --radius: 14px;
  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111518;
    --surface: #182025;
    --ink: #e8ebed;
    --muted: #9ba6af;
    --rule: #2a343b;
    --copper: #dca274;
    --copper-soft: #c98a58;
    --up: #5ccb93;
    --down: #f2857a;
    --focus: #dca274;
  }
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 400 1rem/1.55 var(--font);
  font-feature-settings: "tnum" 1, "lnum" 1;
}
a { color: inherit; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 3px; border-radius: 4px; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.page {
  max-width: 40rem;
  margin-inline: auto;
  padding: clamp(1.25rem, 4vw, 2.5rem) clamp(1rem, 4vw, 1.5rem) 2rem;
  padding-top: max(clamp(1.25rem, 4vw, 2.5rem), env(safe-area-inset-top));
}

/* Masthead: a gold-to-copper hairline marks the brand; nothing louder. */
.masthead { padding-bottom: 1rem; margin-bottom: 1.25rem; border-bottom: 2px solid; border-image: linear-gradient(90deg, #b8892b, #8f5326 60%, transparent) 1; }
.masthead h1 { margin: 0; font-size: clamp(1.375rem, 4.5vw, 1.75rem); font-weight: 650; letter-spacing: -0.015em; line-height: 1.2; }
.tickers { margin: 0.375rem 0 0; display: flex; flex-wrap: wrap; gap: 0.25rem 1rem; color: var(--muted); font-size: 0.875rem; }
.tickers abbr { text-decoration: none; }

/* Quote */
.quote { background: var(--surface); border: 1px solid var(--rule); border-radius: var(--radius); padding: 1.25rem 1.25rem 1rem; }
.quote-label { margin: 0; color: var(--muted); font-size: 0.9375rem; }
.price { margin: 0.125rem 0 0; font-size: clamp(2.75rem, 13vw, 3.5rem); font-weight: 600; letter-spacing: -0.03em; line-height: 1.05; }
.price .ccy { font-size: 1rem; font-weight: 500; letter-spacing: 0; color: var(--muted); }
.change { margin: 0.375rem 0 0; font-size: 1.0625rem; font-weight: 600; color: var(--muted); }
.change.up { color: var(--up); }
.change.down { color: var(--down); }
.change .when { font-weight: 400; color: var(--muted); }
.asof { margin: 0.25rem 0 0; color: var(--muted); font-size: 0.875rem; min-height: 1.35em; }

.trend { margin: 1.25rem 0 0; }
.chart { position: relative; touch-action: pan-y; }
.chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart .grid { stroke: var(--rule); stroke-width: 1; stroke-dasharray: 2 3; }
.chart .baseline { stroke: var(--rule); stroke-width: 1; }
.chart .axis { fill: var(--muted); font-size: 11px; font-family: var(--font); }
.chart .area { fill: var(--copper-soft); opacity: 0.12; }
.chart .price-line { fill: none; stroke: var(--copper-soft); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart .last-dot { fill: var(--copper); stroke: var(--surface); stroke-width: 2; }
.chart .hover-dot { fill: var(--surface); stroke: var(--copper); stroke-width: 2; }
.chart .cross { stroke: var(--muted); stroke-width: 1; opacity: 0.5; }
.chart .vol { fill: var(--muted); opacity: 0.35; }
.chart .vol.up { fill: var(--up); opacity: 0.4; }
.chart .vol.down { fill: var(--down); opacity: 0.4; }
.chart-tip {
  position: absolute; top: -0.25rem; transform: translateY(-100%); white-space: nowrap; pointer-events: none;
  padding: 0.125rem 0.5rem; border-radius: 6px; font-size: 0.75rem;
  background: var(--ink); color: var(--surface);
}
.chart-dates { display: flex; justify-content: space-between; margin-top: 0.25rem; padding-right: 48px; color: var(--muted); font-size: 0.75rem; }
.trend figcaption { margin-top: 0.375rem; color: var(--muted); font-size: 0.8125rem; display: flex; justify-content: space-between; gap: 1rem; }

.secondary { margin: 1rem 0 0; padding-top: 0.875rem; border-top: 1px solid var(--rule); display: flex; flex-wrap: wrap; align-items: baseline; gap: 0.25rem 0.75rem; font-size: 0.9375rem; }
.secondary strong { font-weight: 600; }
.secondary .up { color: var(--up); }
.secondary .down { color: var(--down); }
.secondary .muted { color: var(--muted); font-size: 0.875rem; }

.note { margin: 0.75rem 0 0; padding: 0.5rem 0.75rem; border-left: 3px solid var(--copper); background: color-mix(in srgb, var(--copper) 8%, transparent); border-radius: 0 6px 6px 0; font-size: 0.875rem; }

/* Status row */
.status { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin: 1rem 0 2rem; color: var(--muted); font-size: 0.875rem; }
.status p { margin: 0; }
#refresh {
  font: inherit; font-weight: 600; color: var(--copper); background: transparent;
  border: 1px solid color-mix(in srgb, var(--copper) 45%, transparent); border-radius: 999px;
  padding: 0.5rem 1rem; min-height: 44px; cursor: pointer; flex-shrink: 0;
  transition: background-color 0.15s ease;
}
#refresh:hover { background: color-mix(in srgb, var(--copper) 10%, transparent); }
#refresh:disabled { opacity: 0.6; cursor: progress; }

/* News */
.news-head { display: flex; align-items: baseline; justify-content: space-between; flex-wrap: wrap; gap: 0.25rem 1rem; margin-bottom: 0.5rem; }
.news-head h2 { margin: 0; font-size: 1.25rem; font-weight: 650; letter-spacing: -0.01em; }
.source { color: var(--copper); font-size: 0.875rem; text-underline-offset: 3px; }
.releases { list-style: none; margin: 0; padding: 0; }
.releases li { border-bottom: 1px solid var(--rule); }
.releases a {
  display: grid; grid-template-columns: 5.25rem 1fr; gap: 0.25rem 0.875rem;
  padding: 0.875rem 0.25rem; text-decoration: none; border-radius: 6px;
}
.releases a:hover .title { text-decoration: underline; text-underline-offset: 3px; text-decoration-color: var(--copper); }
.releases time { color: var(--muted); font-size: 0.875rem; padding-top: 0.0625rem; white-space: nowrap; }
.releases .title { font-size: 1rem; line-height: 1.45; }
.releases .new { display: inline-block; margin-left: 0.5rem; padding: 0 0.4rem; border-radius: 4px; font-size: 0.75rem; font-weight: 650; color: var(--copper); border: 1px solid color-mix(in srgb, var(--copper) 50%, transparent); vertical-align: 0.1em; }
.releases .placeholder { padding: 1rem 0.25rem; color: var(--muted); }
@media (max-width: 30rem) {
  .releases a { grid-template-columns: 1fr; gap: 0.125rem; }
}

.foot { margin-top: 2.5rem; padding-bottom: 4.5rem; color: var(--muted); font-size: 0.8125rem; }
.foot p { margin: 0 0 0.5rem; max-width: 60ch; }
.supercat-credit { text-decoration: none; }
.supercat-credit:hover { text-decoration: underline; }

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
