@font-face { font-family: Inter; font-style: normal; font-weight: 400; font-display: swap; src: url('./inter-400.woff2') format('woff2'); }
@font-face { font-family: Inter; font-style: normal; font-weight: 500; font-display: swap; src: url('./inter-500.woff2') format('woff2'); }

:root {
  color-scheme: light;
  --paper: #f5f5f1;
  --surface: #fff;
  --soft: #eeefeb;
  --ink: #202522;
  --muted: #626b65;
  --line: #e3e6e1;
  --line-strong: #c7ccc6;
  --accent: #b94b22;
  --accent-ink: #873715;
  --band: #e6a184;
  --positive: #26714e;
  --exchange: #7d857f;
  --tip: #202522;
  font: 400 14px/1.45 Inter, Arial, sans-serif;
  color: var(--ink);
  font-synthesis: none;
}

* { box-sizing: border-box; }
html { background: var(--paper); -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent; }
body { margin: 0; font-variant-numeric: tabular-nums; }
button, select, a { font: inherit; color: inherit; touch-action: manipulation; }
a { color: var(--accent-ink); text-underline-offset: 3px; }
a:hover { color: var(--accent); }
:where(a, button, select, [tabindex]):focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
.visually-hidden { position: absolute; width: 1px; height: 1px; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.skip-link { position: absolute; top: -80px; left: 12px; z-index: 5; padding: 12px 16px; background: var(--surface); color: var(--ink); }
.skip-link:focus { top: 12px; }

/* header */
.top { height: 58px; display: flex; align-items: center; gap: 16px; padding-inline: max(24px, calc((100vw - 1232px) / 2)); border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; min-height: 44px; }
.brand img { display: block; }
.product { padding-inline-start: 16px; border-inline-start: 1px solid var(--line-strong); color: var(--muted); font-size: 13px; }

main { width: min(100%, 1280px); margin: 0 auto; padding: 20px 24px 40px; }

/* ticker picker: one row of 18 on desktop, two rows of 9 on tablets, a native select on phones */
.ticker-tabs { display: grid; grid-template-columns: repeat(18, minmax(0, 1fr)); gap: 2px; padding: 3px; border: 1px solid var(--line); border-radius: 7px; background: var(--soft); }
.ticker-tabs:empty { height: 46px; }
.ticker-tabs a { min-width: 0; min-height: 38px; display: grid; place-items: center; padding: 0 4px; border-radius: 5px; color: var(--muted); font-size: 13px; font-weight: 500; text-decoration: none; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ticker-tabs a:hover { background: #f8f8f5; color: var(--ink); }
.ticker-tabs a[aria-current='page'] { background: var(--surface); color: var(--ink); box-shadow: 0 1px 2px #2025221f; }
.ticker-select { display: none; }
.ticker-select select { width: 100%; min-height: 44px; padding: 0 40px 0 14px; border: 1px solid var(--line-strong); border-radius: 7px; appearance: none; background: var(--surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5 6 6.5l5-5' fill='none' stroke='%23626b65' stroke-width='1.6'/%3E%3C/svg%3E") no-repeat right 15px center; color: var(--ink); font-size: 15px; font-weight: 500; cursor: pointer; }

/* notice */
.notice { margin: 16px 0 0; padding: 10px 14px; border-radius: 6px; background: #f6e7dd; color: #6d3218; font-size: 13px; }

/* quote */
.quote { padding: 28px 0 22px; }
.quote-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.quote h1 { min-width: 0; margin: 0; font-size: 20px; line-height: 1.25; font-weight: 500; letter-spacing: -.02em; text-wrap: balance; }
.quote .name { color: var(--muted); font-weight: 400; }
.button { min-height: 40px; padding: 0 14px; border: 1px solid var(--line-strong); border-radius: 6px; background: var(--surface); font-size: 13px; font-weight: 500; white-space: nowrap; cursor: pointer; transition: background-color .15s, border-color .15s; }
.button:hover:not(:disabled) { background: #f8f8f5; border-color: #929b94; }
.button:disabled { color: var(--muted); cursor: default; }
.button .count { margin-inline-start: 4px; color: var(--muted); }
.price { margin: 14px 0 6px; font-size: clamp(48px, 6.4vw, 76px); line-height: 1; font-weight: 500; letter-spacing: -.045em; white-space: nowrap; }
.price .sigma { margin-inline-start: .35em; color: var(--muted); font-size: max(16px, .32em); font-weight: 400; letter-spacing: -.01em; }
.price.is-stale { color: var(--exchange); }
.price.is-empty { color: var(--exchange); }
.compare { margin: 0; min-height: 20px; color: var(--muted); font-size: 14px; }
.compare .delta { color: var(--ink); font-weight: 500; }
.compare .flag { color: var(--accent-ink); font-weight: 500; }

/* skeletons */
.skeleton { display: inline-block; border-radius: 6px; background: #ecede8; }
.price .skeleton { width: min(320px, 70%); }
.compare .skeleton { width: min(280px, 60%); }
.chart-skeleton { display: block; width: 100%; height: 100%; }

/* chart card */
.chart-card { border: 1px solid var(--line); border-radius: 8px; background: var(--surface); }
.chart-bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 8px 10px 0 16px; }
.ranges { display: flex; gap: 2px; padding: 3px; border-radius: 7px; background: var(--soft); }
.ranges button { min-width: 48px; min-height: 34px; padding: 0 10px; border: 0; border-radius: 5px; background: transparent; color: var(--muted); font-size: 13px; font-weight: 500; cursor: pointer; }
.ranges button:hover { color: var(--ink); }
.ranges button[aria-pressed='true'] { background: var(--surface); color: var(--ink); box-shadow: 0 1px 2px #2025221f; }
.chart-figure { position: relative; margin: 0; padding: 4px 16px 10px; }
.chart { position: relative; height: clamp(304px, calc(30vw + 44px), 424px); touch-action: pan-y; transition: opacity .2s; }
.chart.is-loading { opacity: .55; }
.chart-svg { display: block; overflow: visible; }
.chart-empty { height: 100%; display: grid; place-items: center; color: var(--muted); font-size: 13px; }
.grid { stroke: var(--line); stroke-width: 1; }
.axis { fill: var(--muted); font-size: 11px; }
.line-chain { fill: none; stroke: var(--accent); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.line-exchange { fill: none; stroke: var(--exchange); stroke-width: 1.25; stroke-linejoin: round; }
.band-chain { fill: var(--band); fill-opacity: .32; }
.source-bars { fill: var(--exchange); fill-opacity: .55; }
.cross-line { stroke: var(--ink); stroke-opacity: .28; stroke-width: 1; }
.dot-chain { fill: var(--accent); stroke: var(--surface); stroke-width: 2; }
.dot-exchange { fill: var(--exchange); stroke: var(--surface); stroke-width: 2; }
.tip { position: absolute; top: 8px; left: 16px; z-index: 2; min-width: 190px; padding: 9px 12px; border-radius: 9px; background: var(--tip); color: #fff; font-size: 12px; box-shadow: 0 10px 28px -8px #20252266; pointer-events: none; }
.tip-time { margin-bottom: 6px; color: #c9cec9; }
.tip-row { display: flex; align-items: center; gap: 7px; line-height: 1.7; }
.tip-row .tip-value { margin-inline-start: auto; padding-inline-start: 16px; font-weight: 500; }
.legend { min-width: 0; margin: 0; display: flex; flex-wrap: wrap; align-items: center; gap: 4px 18px; color: var(--muted); font-size: 12px; }
.legend > span { display: inline-flex; align-items: center; gap: 8px; }
.key { display: inline-block; width: 16px; height: 2px; border-radius: 1px; background: var(--accent); }
.key-band { height: 10px; border-radius: 2px; background: var(--band); opacity: .45; }
.key-exchange { height: 1.5px; background: var(--exchange); }
.tip .key-exchange { background: #b3b9b4; }
.tip .key-sources { height: 8px; width: 3px; margin-inline: 6.5px; background: #b3b9b4; }
.tip .key-chain { background: var(--band); }

/* stale or failed refresh: keep the last data, dimmed */
.is-stale .quote, .is-stale .chart-card { opacity: .55; }

/* footer */
.foot { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 24px; margin-top: 20px; color: var(--muted); font-size: 12px; }
.foot .links { display: flex; gap: 16px; margin-inline-start: auto; }

/* sources dialog */
#sources { width: min(560px, calc(100vw - 32px)); max-height: min(86dvh, 760px); padding: 0; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); color: var(--ink); box-shadow: 0 16px 52px #20252230; overscroll-behavior: contain; }
#sources::backdrop { background: #20252259; }
.dialog-head { position: sticky; top: 0; display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; padding: 18px 20px 14px; border-bottom: 1px solid var(--line); background: var(--surface); }
.dialog-head h2 { margin: 0; font-size: 18px; font-weight: 500; letter-spacing: -.02em; }
.muted { margin: 2px 0 0; color: var(--muted); font-size: 13px; }
.source-list { margin: 0; padding: 4px 20px 12px; list-style: none; }
.source { display: flex; justify-content: space-between; gap: 16px; padding: 11px 0; border-bottom: 1px solid var(--line); }
.source:last-child { border-bottom: 0; }
.source > div { display: flex; flex-direction: column; min-width: 0; }
.source-name { font-weight: 500; overflow-wrap: anywhere; }
.source-sub { color: var(--muted); font-size: 12px; }
.source-right { align-items: flex-end; text-align: right; flex-shrink: 0; max-width: 50%; }
.source-price { font-weight: 500; }
.source.is-excluded .source-name, .source.is-excluded .source-price { color: var(--muted); font-weight: 400; }

@media (max-width: 1100px) {
  .ticker-tabs { grid-template-columns: repeat(9, minmax(0, 1fr)); }
}
@media (max-width: 600px) {
  .top { height: 54px; padding-inline: 16px; gap: 12px; }
  main { padding: 14px 16px 32px; }
  .ticker-tabs { display: none; }
  .ticker-select { display: block; }
  .quote { padding: 22px 0 18px; }
  .quote h1 { font-size: 18px; }
  .chart-bar { padding: 6px 6px 0 10px; }
  .chart-figure { padding: 4px 10px 8px; }
  .tip { left: 10px; }
  .foot .links { margin-inline-start: 0; }
  .dialog-head, .source-list { padding-inline: 16px; }
}
@media (prefers-reduced-motion: reduce) {
  .chart, .button { transition: none; }
}
