:root {
  color-scheme: light;
  --surface-0: #f4f4f1;
  --surface-1: #fcfcfb;
  --border: #e2e1dc;
  --grid: #ecebe7;
  --text-primary: #0b0b0b;
  --text-secondary: #52514e;
  --text-muted: #77766f;
  --accent: #2a78d6;
  --series-1: #2a78d6;
  --series-2: #eb6834;
  --series-3: #1baf7a;
  --warning: #b36b00;
}
@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) {
    color-scheme: dark;
    --surface-0: #111110;
    --surface-1: #1a1a19;
    --border: #2e2e2c;
    --grid: #262624;
    --text-primary: #f0efec;
    --text-secondary: #c3c2b7;
    --text-muted: #94938a;
    --accent: #3987e5;
    --series-1: #3987e5;
    --series-2: #d95926;
    --series-3: #199e70;
    --warning: #e0a030;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --surface-0: #111110;
  --surface-1: #1a1a19;
  --border: #2e2e2c;
  --grid: #262624;
  --text-primary: #f0efec;
  --text-secondary: #c3c2b7;
  --text-muted: #94938a;
  --accent: #3987e5;
  --series-1: #3987e5;
  --series-2: #d95926;
  --series-3: #199e70;
  --warning: #e0a030;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--surface-0);
  color: var(--text-primary);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  padding: env(safe-area-inset-top) 0 env(safe-area-inset-bottom);
}
main, .top, .foot { max-width: 1040px; margin: 0 auto; padding: 0 16px; }

.top {
  display: flex; flex-wrap: wrap; gap: 12px; align-items: center; justify-content: space-between;
  padding-top: 20px; padding-bottom: 12px;
}
h1 { font-size: 20px; margin: 0; letter-spacing: -0.01em; }

.range { display: flex; gap: 4px; background: var(--surface-1); border: 1px solid var(--border); border-radius: 10px; padding: 3px; }
.range button {
  border: 0; background: none; color: var(--text-secondary); font: inherit; font-size: 13px;
  padding: 6px 10px; border-radius: 7px; cursor: pointer; min-height: 32px;
}
.range button[aria-selected="true"] { background: var(--surface-0); color: var(--text-primary); font-weight: 600; }

.status { color: var(--text-muted); font-size: 13px; min-height: 1.45em; margin: 0 0 8px; }
.status.error { color: var(--warning); }

.token { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 16px; }
.token input { flex: 1 1 200px; padding: 8px 10px; border-radius: 8px; border: 1px solid var(--border); background: var(--surface-1); color: inherit; font: inherit; }
.token button { padding: 8px 14px; border-radius: 8px; border: 0; background: var(--accent); color: #fff; font: inherit; cursor: pointer; }

.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; margin-bottom: 16px; }
.card {
  background: var(--surface-1); border: 1px solid var(--border); border-radius: 14px; padding: 14px 16px;
}
.card h2 { margin: 0 0 4px; font-size: 14px; font-weight: 600; display: flex; align-items: center; gap: 8px; }
.card h2 .swatch { width: 10px; height: 10px; border-radius: 3px; flex: none; }
.card .temp { font-size: 34px; font-weight: 650; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.card .temp small { font-size: 16px; font-weight: 500; color: var(--text-secondary); }
.card dl { display: grid; grid-template-columns: auto 1fr; gap: 2px 12px; margin: 6px 0 0; font-size: 13px; }
.card dt { color: var(--text-muted); }
.card dd { margin: 0; color: var(--text-secondary); font-variant-numeric: tabular-nums; }
.card .stale { color: var(--warning); }

.charts { display: grid; gap: 12px; }
.chart { margin: 0; background: var(--surface-1); border: 1px solid var(--border); border-radius: 14px; padding: 12px 12px 4px; min-width: 0; }
.chart figcaption { font-size: 14px; font-weight: 600; margin: 0 4px 6px; }
.chart figcaption span { color: var(--text-muted); font-weight: 400; }

/* uPlot nei colori del tema */
.uplot { font-family: inherit; color: var(--text-secondary); }
.uplot .u-legend { font-size: 12px; text-align: left; padding: 4px; }
.uplot .u-legend .u-marker { border-radius: 3px; }
.uplot .u-legend th { font-weight: 500; color: var(--text-secondary); }
.uplot .u-legend td { color: var(--text-primary); font-variant-numeric: tabular-nums; }
.u-cursor-pt { border-color: var(--surface-1) !important; }

.foot { padding-top: 24px; padding-bottom: 32px; font-size: 13px; }
.foot a { color: var(--text-muted); }

[hidden] { display: none !important; }
