:root {
  color-scheme: dark;
  --bg: #0f1216;
  --panel: #161b21;
  --panel-2: #1c232b;
  --line: #27313b;
  --ink: #eef2f6;
  --muted: #8d99a6;
  --temp: #f2a93b;
  --humid: #3fc1c9;
  --ok: #34c77b;
  --warn: #f2c14e;
  --bad: #ef5b5b;
  --radius: 14px;
  font-family: "Segoe UI Variable", "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
  background: var(--bg);
  color: var(--ink);
}

* { box-sizing: border-box; }
body { margin: 0; }
.page { margin: 0 auto; padding: 16px 16px 40px; }

h1, h2 { margin: 0; font-weight: 600; letter-spacing: -0.01em; }
h1 { font-size: 1.6rem; }
h2 { font-size: 1.05rem; }
p { margin: 0; }

.label { color: var(--muted); font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.08em; }
.sub, .muted { color: var(--muted); font-size: 0.86rem; }

.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--muted); margin-right: 6px; vertical-align: middle; }
.dot.online { background: var(--ok); box-shadow: 0 0 0 3px color-mix(in srgb, var(--ok) 25%, transparent); }
.dot.stale { background: var(--warn); }
.dot.offline { background: var(--bad); }

.cards {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
  margin-bottom: 16px;
}

.card, .panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.card { padding: 18px 20px; display: grid; gap: 8px; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel-2);
  font-size: 0.78rem;
  white-space: nowrap;
}
.status .dot { margin-right: 0; }
.status.online { color: var(--ok); border-color: color-mix(in srgb, var(--ok) 35%, var(--line)); }
.status.stale { color: var(--warn); border-color: color-mix(in srgb, var(--warn) 35%, var(--line)); }
.status.offline { color: var(--bad); border-color: color-mix(in srgb, var(--bad) 35%, var(--line)); }
.value { font-size: 2.2rem; font-weight: 600; line-height: 1.1; font-variant-numeric: tabular-nums; white-space: nowrap; }
.value.temp { color: var(--temp); }
.value.humid { color: var(--humid); }
.unit { font-size: 1rem; color: var(--muted); margin-left: 6px; font-weight: 500; }

.panel { padding: 18px 20px; margin-bottom: 16px; }
.panel-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.controls { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; }

.segmented { display: inline-flex; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.segmented button { background: transparent; color: var(--muted); border: 0; border-right: 1px solid var(--line); border-radius: 0; padding: 7px 14px; }
.segmented button:last-child { border-right: 0; }
.segmented button.active { background: var(--panel-2); color: var(--ink); }

.custom { display: flex; gap: 8px; align-items: center; }

input, select, textarea, button {
  font: inherit;
  color: var(--ink);
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px 12px;
}
button { cursor: pointer; background: var(--ink); color: #0f1216; border-color: var(--ink); font-weight: 600; }
button.ghost { background: transparent; color: var(--ink); border-color: var(--line); font-weight: 500; }

.chart-box { position: relative; height: 300px; }
.chart-box canvas { display: block; }
.chart-title { font-size: 1rem; margin-bottom: 12px; }
.toolbar { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.toolbar { --control-h: 38px; }
.toolbar input,
.toolbar .custom button { height: var(--control-h); padding-top: 0; padding-bottom: 0; line-height: 1; }
.toolbar .custom button { display: inline-flex; align-items: center; padding-inline: 16px; }
.toolbar .segmented { height: var(--control-h); align-items: stretch; }
.toolbar .segmented button { display: inline-flex; align-items: center; padding: 0 14px; line-height: 1; }
.empty { position: absolute; inset: 0; display: grid; place-items: center; color: var(--muted); pointer-events: none; }
.empty[hidden] { display: none; }

.ask { display: block; }
.ask textarea { width: 100%; resize: vertical; min-height: 64px; line-height: 1.5; }
#ask-button { padding: 0 28px; height: 38px; }
.answer {
  margin-top: 14px;
  padding: 16px 18px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-left: 3px solid var(--humid);
  border-radius: 10px;
  font-size: 1.02rem;
  line-height: 1.65;
  color: var(--ink);
}
.answer[hidden] { display: none; }
.answer.pending { color: var(--muted); border-left-color: var(--line); }
.answer p { margin: 0; }
.answer p + p, .answer p + ul, .answer ul + p { margin-top: 10px; }
.answer ul { margin: 8px 0 0; padding-left: 20px; }
.answer li { margin: 4px 0; }
.answer strong { color: #ffffff; font-weight: 600; }

.alert { background: color-mix(in srgb, var(--bad) 15%, var(--panel)); border: 1px solid var(--bad); padding: 10px 14px; border-radius: 10px; margin-bottom: 16px; }

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

@media (max-width: 640px) {
  .page { padding: 12px 16px 32px; }
  .cards { grid-template-columns: 1fr; }
  .chart-box { height: 300px; }
  .value { font-size: 1.9rem; }
  .custom {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
    width: 100%;
  }
  .custom input { min-width: 0; width: 100%; }
  .toolbar .custom button { grid-column: 1 / -1; justify-content: center; }
}
