:root {
  color-scheme: dark;
  --background: #0b0d0e;
  --surface: #151819;
  --border: #333838;
  --text: #f5f5ef;
  --muted: #a8b0aa;
  --quiet: #87918a;
  --gold: #d5bc80;
  --up: #96d9b5;
  --down: #e1a098;
}

* { box-sizing: border-box; }
html, body { width: 100%; height: 100%; margin: 0; }

body {
  overflow: hidden;
  background: var(--background);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased;
}

.dashboard {
  width: 100%;
  max-width: 440px;
  height: 100vh;
  height: 100dvh;
  margin: 0 auto;
  padding: max(8px, env(safe-area-inset-top)) 12px max(8px, env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 9px;
}

.topbar, .brand, .connection-status, .quote-line { display: flex; align-items: center; }
.topbar {
  min-height: 22px;
  justify-content: space-between;
  gap: 8px;
  padding-bottom: 5px;
  border-bottom: 1px solid var(--border);
}
.brand { gap: 8px; white-space: nowrap; }
.brand-mark { width: 7px; height: 7px; flex: 0 0 7px; background: var(--gold); transform: rotate(45deg); }
h1 { margin: 0; font-size: 11px; font-weight: 750; letter-spacing: .15em; }
.connection-status { gap: 6px; color: var(--up); font-size: 9px; font-weight: 750; letter-spacing: .1em; white-space: nowrap; }
.connection-status.is-connecting { color: var(--gold); }
.connection-status.is-error { color: var(--down); }
.status-dot { width: 6px; height: 6px; flex: 0 0 6px; border-radius: 50%; background: currentColor; }

.quote { min-width: 0; }
.quote-line { min-height: 51px; white-space: nowrap; line-height: 1; }
.currency { margin: 0 5px 6px 0; align-self: flex-end; font-size: 20px; font-weight: 500; letter-spacing: -.045em; }
.price { font-size: clamp(38px, 15vw, 53px); font-weight: 650; letter-spacing: -.075em; }
.price.changed { animation: price-flash .35s ease-out; }
.quote-unit { align-self: flex-end; margin: 0 0 6px 8px; color: var(--muted); font-size: 13px; }
.direction { margin-left: 7px; font-size: 14px; }
.direction.up { color: var(--up); }
.direction.down { color: var(--down); }
@keyframes price-flash { from { opacity: .56; } to { opacity: 1; } }

.market-data { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.market-card { min-width: 0; min-height: 46px; padding: 6px 9px; display: flex; flex-direction: column; gap: 3px; background: var(--surface); border: 1px solid var(--border); border-radius: 5px; }
.card-heading { color: var(--muted); font-size: 9px; font-weight: 650; letter-spacing: .09em; white-space: nowrap; }
.daily-label { margin-left: 4px; color: var(--quiet); font-size: 7px; letter-spacing: .03em; }
.card-value { overflow: hidden; color: var(--text); font-size: 16px; font-weight: 600; letter-spacing: -.03em; white-space: nowrap; }

.footer { display: flex; flex-direction: column; gap: 2px; }
.time-row { display: flex; align-items: baseline; gap: 5px; min-height: 12px; font-size: 10px; }
.time-row span { color: var(--quiet); }
.time-row time { color: var(--muted); white-space: nowrap; }
.attribution { align-self: flex-start; margin-top: 2px; color: var(--quiet); font-size: 9px; line-height: 1.2; text-decoration-color: #646e67; text-underline-offset: 2px; }
.attribution:hover { color: var(--text); }

@media (min-height: 360px) {
  .dashboard { padding: 20px; gap: 18px; }
  .topbar { min-height: 30px; padding-bottom: 10px; }
  h1 { font-size: 12px; }
  .connection-status { font-size: 10px; }
  .quote-line { min-height: 72px; }
  .currency { font-size: 27px; }
  .price { font-size: clamp(52px, 14vw, 74px); }
  .quote-unit { font-size: 15px; margin-bottom: 8px; }
  .market-card { min-height: 65px; padding: 10px 12px; gap: 7px; }
  .card-heading { font-size: 10px; }
  .card-value { font-size: 20px; }
  .footer { gap: 5px; }
  .time-row { font-size: 11px; }
  .attribution { margin-top: 7px; font-size: 10px; }
}

@media (max-width: 330px) {
  .dashboard { padding-left: 10px; padding-right: 10px; }
  .price { font-size: 14vw; }
  .currency { font-size: 18px; }
  .quote-unit { font-size: 12px; }
}

@media (max-height: 190px) {
  .dashboard { gap: 4px; padding-top: 4px; padding-bottom: 4px; }
  .quote-line { min-height: 44px; }
  .price { font-size: 40px; }
  .market-card { min-height: 42px; padding-top: 4px; padding-bottom: 4px; }
  .footer { gap: 0; }
}

@media (prefers-reduced-motion: reduce) { .price.changed { animation: none; } }
