:root {
  color-scheme: light;
  --ink: #152331;
  --muted: #536576;
  --accent: #087e72;
  --accent-dark: #05645b;
  --accent-soft: #dff6ee;
  --border: #d5e0e6;
  --surface: #fff;
  --canvas: #f1f5f7;
  --night: #0b1722;
  --night-panel: #122331;
  --night-raised: #192d3b;
  --mint: #6af0c5;
  --gold: #ffd47c;
  --radius: 1.1rem;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background:
    radial-gradient(ellipse at 88% 7%, #dcece8 0, transparent 27rem),
    var(--canvas);
  color: var(--ink);
  font: 1rem/1.65 system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

a { color: var(--accent-dark); text-underline-offset: .2em; }
a:hover { color: #034c46; }

.site-header, main, footer { width: min(1200px, 100% - 3rem); margin: auto; }

.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1rem 1.5rem;
  padding: 1.1rem 0;
  border-bottom: 1px solid #d5e0e6;
}

.brand {
  color: var(--ink);
  font-size: 1.25rem;
  font-weight: 850;
  letter-spacing: -.045em;
  text-decoration: none;
}

.brand span { color: var(--accent); }
.site-header nav { display: flex; flex-wrap: wrap; gap: .5rem; }

.site-header nav a {
  padding: .45rem .75rem;
  border-radius: 999px;
  color: var(--muted);
  font-size: .88rem;
  font-weight: 700;
  text-decoration: none;
}

.site-header nav a:hover { background: #e4eeef; color: var(--ink); }

.badge {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  padding: .32rem .65rem;
  border: 1px solid #bce8d8;
  border-radius: 999px;
  background: var(--accent-soft);
  color: #125548;
  font-size: .72rem;
  font-weight: 800;
  letter-spacing: .045em;
  text-transform: uppercase;
}

.hero {
  max-width: 850px;
  padding: 3.4rem 0 2.2rem;
}

.eyebrow {
  margin: 0 0 .55rem;
  color: var(--accent-dark);
  font-size: .74rem;
  font-weight: 850;
  letter-spacing: .14em;
  text-transform: uppercase;
}

h1 {
  margin: 0 0 .85rem;
  font-size: clamp(2.7rem, 7vw, 5.2rem);
  line-height: .98;
  letter-spacing: -.065em;
}

h2 { margin: 0 0 1rem; font-size: 1.45rem; line-height: 1.25; letter-spacing: -.025em; }
h3 { font-size: 1.16rem; line-height: 1.4; }
h4 { margin-bottom: .5rem; }
p { margin: .6rem 0 1rem; }
.intro { max-width: 37ch; color: #344c5b; font-size: clamp(1.25rem, 2.5vw, 1.65rem); line-height: 1.35; }
.hero > p:last-child { max-width: 76ch; color: var(--muted); }

.tools { display: grid; grid-template-columns: .9fr 1.1fr; gap: 1.2rem; align-items: start; }
.card {
  min-width: 0;
  padding: clamp(1.25rem, 3vw, 2rem);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: 0 .5rem 1.8rem #1523310a;
}

label { display: block; margin-bottom: .5rem; font-weight: 750; }
input, textarea, button, select { font: inherit; }

input, textarea {
  width: 100%;
  min-width: 0;
  padding: .75rem .85rem;
  border: 1px solid #91a4b0;
  border-radius: .6rem;
  background: #fbfdfe;
  color: var(--ink);
}

input:focus, textarea:focus, select:focus { border-color: var(--accent); }
textarea { resize: vertical; font-family: ui-monospace, SFMono-Regular, Consolas, monospace; line-height: 1.55; }
.lookup-row { display: flex; gap: .65rem; }
.lookup-row input { flex: 1; }

button {
  min-height: 44px;
  padding: .65rem 1rem;
  border: 1px solid var(--accent);
  border-radius: .6rem;
  background: var(--accent);
  color: white;
  font-weight: 750;
  cursor: pointer;
  transition: background-color .15s ease, border-color .15s ease, transform .15s ease;
}

button:hover { border-color: var(--accent-dark); background: var(--accent-dark); }
button:active { transform: translateY(1px); }
button.secondary { background: transparent; color: var(--accent-dark); }
button.secondary:hover { background: var(--accent-soft); }
.actions { display: flex; flex-wrap: wrap; gap: .65rem; }
.hint, small { color: var(--muted); font-size: .85rem; }

.result {
  margin-top: 1.5rem;
  padding-top: 1.3rem;
  border-top: 1px solid var(--border);
  overflow-wrap: anywhere;
  scroll-margin-top: 1rem;
}

.measurements { margin: 1rem 0; }
.measurements div {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: .7rem 0;
  border-bottom: 1px solid #e2eaee;
}

dt small { display: block; }
dd { margin: 0; font-size: 1.2rem; font-weight: 780; white-space: nowrap; font-variant-numeric: tabular-nums; }
.guide { margin-top: 1.2rem; }
li { margin-bottom: .6rem; }
summary { padding: .55rem 0; color: var(--accent-dark); font-weight: 750; cursor: pointer; }
code { padding: .14rem .32rem; border-radius: .25rem; background: #edf3f5; overflow-wrap: anywhere; }

.notice {
  margin: 0 0 1.4rem;
  padding: 1.2rem 1.35rem;
  border: 1px solid #e2c476;
  border-left: .35rem solid #ad7917;
  border-radius: .7rem;
  background: #fff8e7;
}

.error { border-color: #d47f78; background: #fff1ef; }
.safety { margin-top: 1.2rem; }
footer { padding: 1.5rem 0 2.4rem; color: var(--muted); font-size: .85rem; }

:focus-visible { outline: 3px solid #a94e00; outline-offset: 3px; }
.skip-link { position: absolute; z-index: 5; top: -5rem; left: 1rem; padding: .7rem; background: white; }
.skip-link:focus { top: .5rem; }

.dashboard {
  --muted: #aebfca;
  --accent: var(--mint);
  position: relative;
  isolation: isolate;
  margin: 0 0 2rem;
  padding: clamp(1rem, 3vw, 2rem);
  overflow: hidden;
  border: 1px solid #29404f;
  border-radius: 1.35rem;
  background:
    radial-gradient(ellipse at 92% 0%, #1c4a49 0, transparent 25rem),
    linear-gradient(145deg, var(--night), #101f2b 72%);
  box-shadow: 0 1.5rem 3rem #14273620;
  color: #f2f7fa;
  scroll-margin-top: 1rem;
}

.dashboard::before {
  position: absolute;
  z-index: -1;
  top: 0;
  right: 2rem;
  width: 8rem;
  height: .2rem;
  background: linear-gradient(90deg, transparent, var(--mint), transparent);
  content: "";
}

.dashboard .eyebrow { color: var(--mint); }
.dashboard-heading { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: .8rem 1rem; margin-bottom: 1.3rem; }
.dashboard-heading h2 { margin: 0; font-size: clamp(1.5rem, 3vw, 2rem); letter-spacing: -.04em; }

.connection-pill {
  padding: .38rem .75rem;
  border: 1px solid #4c6270;
  border-radius: 999px;
  background: #152b38;
  color: #e1edf2;
  font-size: .78rem;
  font-weight: 750;
}

.connection-panel {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 1.25rem;
  padding: 1.15rem 1.25rem;
  border: 1px solid #344d5b;
  border-radius: .9rem;
  background: #132735d9;
}

.connection-panel h3 { margin: 0 0 .4rem; }
.connection-panel p { max-width: 65ch; margin: .35rem 0; }
.connection-panel .actions { align-content: center; flex-direction: column; justify-content: center; }

.dashboard button {
  border-color: var(--mint);
  background: var(--mint);
  color: #09231f;
  font-size: .9rem;
}

.dashboard button:hover { border-color: #a0ffdf; background: #a0ffdf; }
.dashboard button.secondary { border-color: #587382; background: transparent; color: #e3eef3; }
.dashboard button.secondary:hover { border-color: #8ba7b5; background: #203946; }
button:disabled, .dashboard button:disabled { border-color: #bac8c4; background: #dfe7e5; color: #566862; cursor: not-allowed; }
.dashboard button:disabled { border-color: #3c5361; background: #20333f; color: #a2b2bc; }

.data-source {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: .55rem 1rem;
  margin: 1.35rem 0 .8rem;
  color: #afc1cc;
  font-size: .78rem;
}

.data-source strong { color: var(--mint); font-size: .75rem; letter-spacing: .08em; }
.metric-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: .7rem; margin: 0; }

.metric {
  min-width: 0;
  padding: 1rem;
  border: 1px solid #2d4553;
  border-radius: .85rem;
  background: linear-gradient(155deg, #192e3b, #142633);
  box-shadow: inset 0 1px #ffffff08;
}

.metric dt { font-size: .88rem; font-weight: 700; }
.metric dt small { margin-top: .2rem; color: #95aab7; font-size: .68rem; font-weight: 500; }
.metric dd { margin-top: .5rem; white-space: normal; }
.metric-value { color: #f4fafb; font-size: clamp(1.65rem, 3vw, 2.4rem); font-variant-numeric: tabular-nums; letter-spacing: -.05em; }
.metric dd small { color: #afc1cc; font-size: .78rem; font-weight: 550; }
.metric-status { display: block; min-height: 1.3em; margin: .45rem 0 0; color: #aebfca; font-size: .72rem; font-weight: 500; }
.metric.is-stale { border-color: #8b7041; }
.metric.is-stale .metric-status { color: var(--gold); }
.gauge-label { margin: 0 0 .3rem; color: #aebfca; font-size: .68rem; }

.gauge-sensor {
  width: 100%;
  min-width: 0;
  min-height: 40px;
  margin-bottom: .65rem;
  padding: .35rem .45rem;
  border: 1px solid #4b6472;
  border-radius: .45rem;
  background: #10232f;
  color: #f2f7fa;
  font: inherit;
  font-size: .76rem;
}

.gauge-dial { display: block; width: 100%; max-width: 220px; margin: .1rem auto 0; overflow: visible; }
.gauge-track, .gauge-fill { fill: none; stroke-width: 12; }
.gauge-track { stroke: #334c5a; }
.gauge-fill { stroke: var(--mint); }
.metric.is-unavailable .gauge-fill { visibility: hidden; }
.metric.is-stale .gauge-fill { stroke: var(--gold); }
.gauge-scale { display: flex; justify-content: space-between; max-width: 220px; margin: .2rem auto .25rem; color: #aebfca; font-size: .68rem; font-weight: 500; }

.live-codes {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: .5rem 1rem;
  margin-top: 1.2rem;
  padding-top: 1.2rem;
  border-top: 1px solid #304855;
}

.live-codes h3 { margin: 0; }
.live-codes p { margin: .25rem 0; }
.live-codes > p, .live-codes ul { width: 100%; }
.live-codes ul:empty { display: none; }
.live-codes ul { margin: .5rem 0; font-family: ui-monospace, SFMono-Regular, Consolas, monospace; }
.connection-guide { margin-top: 1.2rem; padding-top: .8rem; border-top: 1px solid #304855; }
.dashboard code { background: #263e4c; color: #e4eff5; }
.dashboard :focus-visible { outline-color: var(--gold); }

@media (max-width: 950px) {
  .metric-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 850px) {
  .tools { grid-template-columns: 1fr; }
}

@media (max-width: 650px) {
  .site-header, main, footer { width: calc(100% - 2rem); }
  .site-header { gap: .6rem; }
  .site-header nav { order: 3; width: 100%; }
  .site-header nav a { padding: .4rem .6rem; }
  .hero { padding: 2.4rem 0 1.5rem; }
  .dashboard { border-radius: 1rem; }
  .connection-panel { grid-template-columns: 1fr; }
  .connection-panel .actions { flex-direction: row; }
  .connection-panel .actions button { flex: 1 1 150px; }
}

@media (max-width: 480px) {
  .lookup-row { flex-direction: column; }
  .lookup-row button { width: 100%; }
  .measurements div { align-items: flex-start; }
}

@media (max-width: 380px) {
  .metric-grid { grid-template-columns: 1fr; }
  .metric { display: grid; grid-template-columns: minmax(0, 1fr) minmax(6rem, .9fr); column-gap: .5rem; }
  .metric dt { grid-column: 1; }
  .metric dd { grid-column: 2; grid-row: 1; text-align: right; }
  .gauge-label { text-align: left; }
  .gauge-dial, .gauge-scale { display: none; }
  .metric-status { text-align: right; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { transition-duration: .01ms !important; }
}
