:root {
  color-scheme: dark;
  font-family: -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
  --base: #0b1729;
  --text: #f0f6ff;
  --muted: #b7c9df;
  --cold: #bfe8ff;
  --fresh: #a0e8d2;
  --attention: #ffdaaa;
  --line: #54708b;
  --edge: #cadfff36;
  --home-line: #ffd4af;
  --plot-guide: #a9ddff1a;
  --glass-body: linear-gradient(145deg, #294560ba 0%, #13253edb 60%, #13263ce8 100%);
  --glass-shadow: 0 16px 38px #03091554, inset 0 1px 0 #e7f5ff20;
  background: var(--base);
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(ellipse at 12% 3%, #345a85 0%, transparent 48%),
    radial-gradient(ellipse at 92% 12%, #403b68 0%, transparent 42%),
    radial-gradient(ellipse at 87% 78%, #123d50 0%, transparent 43%),
    #0b1729;
  background-attachment: fixed;
}
h1, h2, h3, p, dl, dd { margin: 0; }
h1 { font-size: clamp(1.52rem, 5.8vw, 1.9rem); line-height: 1; letter-spacing: -.049em; }
h2 { font-size: .94rem; font-weight: 670; letter-spacing: -.013em; }
button { font: inherit; color: inherit; cursor: pointer; }
button:focus-visible { outline: 2px solid var(--cold); outline-offset: 3px; }
button:disabled { opacity: .6; cursor: wait; }
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.shell {
  display: grid;
  gap: 15px;
  max-width: 960px;
  margin-inline: auto;
  padding: max(12px, env(safe-area-inset-top)) max(12px, env(safe-area-inset-right))
    max(22px, env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left));
}
.glass {
  background: var(--glass-body);
  border: 1px solid var(--edge);
  box-shadow: var(--glass-shadow);
}
.secondary, dt { color: var(--muted); font-size: .78rem; line-height: 1.35; }
.topbar {
  position: sticky;
  top: max(6px, env(safe-area-inset-top));
  z-index: 1;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 7px 10px;
  padding: 10px 10px 10px 15px;
  border-radius: 25px;
  background: linear-gradient(122deg, #416082 0%, #273755 58%, #243349 100%);
}
@supports ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  .topbar {
    background: linear-gradient(122deg, #5b7d9d5c 0%, #27425a42 53%, #5a5b8445 100%), #14253dd4;
    -webkit-backdrop-filter: blur(24px) saturate(155%);
    backdrop-filter: blur(24px) saturate(155%);
  }
}
@media (prefers-reduced-transparency: reduce) {
  .topbar {
    background: #243b56;
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
  }
}
#timestamp { margin-top: 4px; font-size: .73rem; }
.top-actions { display: flex; align-items: center; gap: 7px; min-width: 0; }
.power-status, #refresh {
  border: 1px solid #d4ecff33;
  box-shadow: inset 0 1px 0 #e7f5ff22, 0 3px 8px #080f2340;
  background: linear-gradient(148deg, #e4f4ff21, #b1ceff0b 90%);
  border-radius: 99px;
}
.power-status {
  display: flex;
  align-items: center;
  gap: 5px;
  min-height: 34px;
  padding: 0 9px;
  color: var(--fresh);
  white-space: nowrap;
  font-size: .74rem;
  font-weight: 650;
}
.power-status[data-source="battery"] { color: #ffdaa9; }
.power-status[data-source="unknown"], .power-status[data-stale="true"] { color: var(--muted); }
.power-status[data-low="true"] { color: var(--attention); }
.power-icon { flex: 0 0 16px; height: 16px; position: relative; }
.power-icon::before, .power-icon::after { content: ""; position: absolute; }
.power-status[data-source="adapter"] .power-icon {
  background: linear-gradient(currentColor, currentColor) center 11px / 1px 4px no-repeat;
}
.power-status[data-source="adapter"] .power-icon::before {
  inset: 5px 3px 4px;
  border: 1.4px solid currentColor;
  border-radius: 2px 2px 4px 4px;
}
.power-status[data-source="adapter"] .power-icon::after {
  inset: 2px auto auto 5px;
  width: 1.4px;
  height: 4px;
  background: currentColor;
  box-shadow: 4.6px 0 currentColor;
}
.power-status[data-source="battery"] .power-icon {
  background: linear-gradient(currentColor, currentColor) 3px center / 7px 4px no-repeat;
}
.power-status[data-source="battery"][data-low="true"] .power-icon { background-size: 2.5px 4px; }
.power-status[data-source="battery"] .power-icon::before {
  inset: 4px 2px 4px 0;
  border: 1.3px solid currentColor;
  border-radius: 2px;
}
.power-status[data-source="battery"] .power-icon::after {
  inset: 6px 0 6px auto;
  width: 1.4px;
  border-radius: 0 1px 1px 0;
  background: currentColor;
}
.power-status[data-source="unknown"] .power-icon::before {
  inset: 3px;
  border: 1.3px solid currentColor;
  border-radius: 50%;
}
.power-status[data-source="unknown"] .power-icon::after {
  inset: 7px 5.5px auto;
  height: 1px;
  background: currentColor;
}
#refresh {
  width: 44px;
  flex: 0 0 44px;
  height: 44px;
  display: grid;
  place-items: center;
  padding: 0;
  color: #e2f4ff;
  font-size: 1.37rem;
  line-height: 1;
}
#refresh span { padding-bottom: 2px; }
.battery-warning {
  grid-column: 1 / -1;
  padding-top: 6px;
  border-top: 1px solid #ffd4af35;
  color: var(--attention);
  font-size: .76rem;
}
.notice {
  padding: 10px 13px;
  border: 1px solid #ffd4af45;
  border-radius: 13px;
  background: #362c3b;
  color: var(--attention);
  font-size: .84rem;
  line-height: 1.4;
}

.current {
  --weather-haze: #73c4ff39;
  --weather-rim: #b9dcff23;
  display: grid;
  min-width: 0;
  border-radius: 30px;
  background:
    radial-gradient(ellipse at 3% 0%, var(--weather-haze), transparent 61%),
    radial-gradient(ellipse at 98% 0%, var(--weather-rim), transparent 53%),
    var(--glass-body);
}
.current[data-sky="3"] { --weather-rim: #ffc78939; }
.current[data-sky="4"] { --weather-rim: #c1a9ff3b; }
.current[data-sky="5"] { --weather-haze: #b1e2ff55; }
.outside { padding: 19px clamp(15px, 5vw, 26px) 16px; }
.outside-heading { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.outside-conditions { display: flex; align-items: flex-end; justify-content: space-between; gap: 6px; margin-top: 12px; }
.temperature {
  color: var(--text);
  font-size: clamp(3.15rem, 15.4vw, 6.3rem);
  font-weight: 540;
  line-height: .93;
  letter-spacing: -.095em;
  white-space: nowrap;
}
.degree {
  position: relative;
  top: .16em;
  margin-inline-start: .22em;
  color: var(--cold);
  font-size: .34em;
  font-weight: 650;
  letter-spacing: -.02em;
  vertical-align: top;
}
.outside-humidity { display: grid; gap: 3px; padding-bottom: 2px; text-align: right; white-space: nowrap; }
.outside-humidity strong { font-size: clamp(1.09rem, 5vw, 1.48rem); font-weight: 640; }
.freshness {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--fresh);
  font-size: .73rem;
  text-align: right;
}
.freshness::before {
  content: "";
  flex: 0 0 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  box-shadow: 0 0 9px currentColor;
}
.freshness[data-warning="true"] { color: var(--attention); }
.range { margin-top: 17px; }
.track {
  position: relative;
  height: 4px;
  border-radius: 3px;
  background: linear-gradient(90deg, #72a8ee 0%, #b5e4f8 43%, #e8ddbf 68%, #dfa483 100%);
  box-shadow: inset 0 1px 0 #fff5;
}
#needle {
  position: absolute;
  left: var(--position, 0%);
  top: 50%;
  width: 11px;
  height: 11px;
  transform: translate(-50%, -50%);
  border: 2px solid #263d55;
  border-radius: 50%;
  background: #f6fbff;
  box-shadow: 0 1px 5px #080f23a0;
}
.range-labels { position: relative; display: flex; justify-content: space-between; margin-top: 6px; color: var(--muted); font-size: .69rem; }
.range-labels span:nth-child(2) { position: absolute; left: 42.85%; transform: translateX(-50%); }

.current-aside { display: grid; margin: 0 clamp(12px, 4vw, 22px); border-block: 1px solid var(--edge); }
.inside {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 9px;
  padding: 13px 3px;
  border-bottom: 1px solid var(--edge);
}
.inside dl { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 7px clamp(12px, 4vw, 22px); text-align: right; }
.inside dd { margin-top: 2px; font-size: 1.05rem; font-weight: 640; white-space: nowrap; }
.forecast { padding: 13px 3px; }
.forecast-value { display: flex; align-items: center; gap: 10px; margin-top: 6px; }
.forecast-icon {
  flex: 0 0 41px;
  height: 41px;
  display: grid;
  place-items: center;
  border-radius: 15px;
  background: linear-gradient(150deg, var(--weather-rim), #a6c2ed09);
  border: 1px solid #cfe7ff30;
  font-size: 1.48rem;
  line-height: 1;
}
#forecast-condition { font-size: 1.14rem; font-weight: 665; letter-spacing: -.025em; line-height: 1.15; }
#forecast-horizon:not(:empty) { margin-top: 3px; }
#pressure-trend:not(:empty) { margin-top: 6px; }
.metrics {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 5px;
  padding: 12px clamp(12px, 4vw, 22px) 16px;
}
.metrics div { display: grid; grid-template-rows: 1fr auto; padding-inline: 3px; }
.metrics div + div { border-left: 1px solid var(--edge); padding-inline-start: 8px; }
.metrics dd { margin-top: 3px; font-size: .98rem; font-weight: 645; white-space: nowrap; }

.history { min-width: 0; padding: 17px clamp(12px, 4vw, 22px) 19px; border-radius: 27px; }
.history h2 { font-size: 1.18rem; font-weight: 690; letter-spacing: -.031em; }
.history-heading .secondary { margin-top: 3px; }
.extremes { width: 100%; margin-top: 8px; border-collapse: collapse; table-layout: fixed; font-size: .84rem; }
.extremes th, .extremes td { padding: 9px 3px; text-align: start; overflow-wrap: anywhere; }
.extremes thead th { color: var(--muted); font-size: .77rem; font-weight: 600; }
.extremes tbody tr { border-top: 1px solid var(--edge); }
.extremes tbody th { font-weight: 600; }
.extremes td { color: var(--cold); font-weight: 660; }
.extremes th[data-incomplete="true"]::after { content: " *"; color: var(--attention); }
#extremes-coverage { margin-top: 3px; }
.history-empty { margin-top: 12px; padding: 14px 0 0; border-top: 1px solid var(--edge); }
.history-days {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 2px;
  margin: 13px 0 11px;
  padding: 3px;
  border: 1px solid #bdd8ff24;
  border-radius: 15px;
  background: #0b183d5c;
  box-shadow: inset 0 1px 2px #080d1a50;
}
.history-days button {
  min-width: 0;
  min-height: 42px;
  padding: 3px 0;
  border: 1px solid transparent;
  border-radius: 11px;
  background: transparent;
  font-size: .71rem;
}
.history-days span { display: block; margin-bottom: 2px; color: var(--muted); }
.history-days button[aria-pressed="true"] {
  border-color: #cfe8ff55;
  background: linear-gradient(145deg, #a5cdf043, #a6cffe1c 90%);
  box-shadow: inset 0 1px 0 #eef9ff37, 0 2px 6px #070f2840;
  font-weight: 700;
}
@media (hover: hover) {
  #refresh:hover:not(:disabled), .history-days button:hover:not([aria-pressed="true"]) { background-color: #d0e8ff18; }
}
.plots { display: grid; gap: 12px; }
.plot { min-width: 0; }
.plot + .plot { padding-top: 13px; border-top: 1px solid var(--edge); }
.plot h3 { margin-bottom: 2px; font-size: .91rem; font-weight: 665; }
.plot h3 span { margin-inline-start: 3px; color: var(--muted); font-size: .72rem; font-weight: 500; }
.plot canvas { display: block; width: 100%; height: 127px; }
.plot-values { display: flex; flex-wrap: wrap; gap: 4px 16px; margin: 1px 8px 0 24px; }
.plot-values div { display: flex; align-items: baseline; gap: 5px; }
.plot-values dt { display: flex; align-items: center; gap: 4px; white-space: nowrap; }
.plot-values dt::before { content: ""; display: block; width: 12px; border-top: 2px solid var(--home-line); }
.plot-values .outside-series dt::before { border-color: var(--cold); border-top-style: dashed; }
.plot-values dd { font-size: .83rem; font-weight: 640; white-space: nowrap; }

@media (min-width: 700px) {
  .shell { gap: 20px; padding-inline: 30px; }
  .topbar { padding: 13px 14px 13px 20px; }
  .top-actions { gap: 10px; }
  .power-status { padding-inline: 12px; font-size: .8rem; }
  #timestamp { font-size: .78rem; }
  .current {
    grid-template-areas: "outside aside" "metrics aside";
    grid-template-columns: minmax(0, 1.48fr) minmax(0, 1fr);
    grid-template-rows: 1fr auto;
  }
  .outside { grid-area: outside; padding: 25px 28px 15px; }
  .outside-conditions { margin-top: 23px; }
  .range { margin-top: 24px; }
  .current-aside { grid-area: aside; align-content: center; margin: 0; padding: 10px 22px; border: 0; border-inline-start: 1px solid var(--edge); }
  .inside { padding-block: 13px 16px; }
  .forecast { padding-block: 15px 12px; }
  .metrics { grid-area: metrics; margin-inline: 28px; padding: 11px 0 23px; border-top: 1px solid var(--edge); }
  .metrics div:first-child { padding-inline-start: 0; }
  .metrics div + div { padding-inline-start: 12px; }
  .history { padding: 21px 24px; }
  .history-heading { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
  .history-days { max-width: 455px; margin-inline: auto; }
  .plots { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 19px; }
  .plot + .plot { padding: 0 0 0 19px; border: 0; border-inline-start: 1px solid var(--edge); }
  .plot canvas { height: 142px; }
}

@media (max-width: 460px) {
  .topbar { grid-template-columns: minmax(0, 1fr) fit-content(65%); }
  .top-actions { justify-self: end; max-width: 100%; }
  .power-status { min-width: 0; white-space: normal; line-height: 1.2; padding-block: 3px; }
  #power-source { min-width: 0; overflow-wrap: anywhere; }
}
