:root {
  --bg: #0d1117;
  --panel: #161b22;
  --line: #262c36;
  --line-strong: #30363d;
  --text: #e6edf3;
  --text-2: #c1c7cf;
  --muted: #9198a1;
  --tip: #1c2128;
  --tip-line: #373e47;
  --up: #3fb950;
  --part: #d29922;
  --down: #f85149;
  --maint: #388bfd;
  --none: #30363d;
  color-scheme: dark;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, system-ui, -apple-system, "Segoe UI", sans-serif;
  font-variant-numeric: tabular-nums;
  -webkit-text-size-adjust: 100%;
  overflow-x: clip;
}

.page {
  max-width: 980px;
  margin: 0 auto;
  padding: 40px 16px 56px;
  display: flex;
  flex-direction: column;
  gap: 28px;
}

/* Header */
.top { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 16px; }
.titles { display: flex; flex-direction: column; gap: 4px; }
h1 { margin: 0; font-size: 22px; font-weight: 700; letter-spacing: -0.01em; }
.checkin { margin: 0; font-size: 14px; color: var(--muted); }
.range { display: flex; gap: 3px; padding: 3px; background: var(--panel); border: 1px solid var(--line-strong); border-radius: 8px; }
.range button {
  min-height: 36px; padding: 0 14px; border: 0; border-radius: 6px; cursor: pointer;
  font: inherit; font-size: 13px; font-weight: 600; background: transparent; color: var(--text-2);
}
.range button[aria-pressed="true"] { background: var(--text); color: var(--bg); }
.range button:focus-visible { outline: 2px solid var(--maint); outline-offset: 2px; }

/* Banner: server.kttr.eu only */
.banner { display: flex; align-items: center; gap: 16px; padding: 20px 22px; border-radius: 10px; border: 1px solid var(--line); background: var(--panel); }
.banner-icon { flex: 0 0 auto; width: 40px; height: 40px; border-radius: 50%; display: flex; align-items: center; justify-content: center; background: var(--none); }
.banner-icon svg { width: 22px; height: 22px; }
.banner-text { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.banner h2 { margin: 0; font-size: 18px; font-weight: 600; }
.banner p { margin: 0; font-size: 14px; color: var(--text-2); }
.banner p:empty { display: none; }
.tone-up { background: rgba(63, 185, 80, 0.10); border-color: rgba(63, 185, 80, 0.35); }
.tone-up .banner-icon { background: var(--up); }
.tone-warn { background: rgba(210, 153, 34, 0.10); border-color: rgba(210, 153, 34, 0.40); }
.tone-warn .banner-icon { background: var(--part); }
.tone-down { background: rgba(248, 81, 73, 0.10); border-color: rgba(248, 81, 73, 0.40); }
.tone-down .banner-icon { background: var(--down); }
.tone-maint { background: rgba(56, 139, 253, 0.10); border-color: rgba(56, 139, 253, 0.40); }
.tone-maint .banner-icon { background: var(--maint); }

/* Sections and panels */
.section { display: flex; flex-direction: column; gap: 10px; }
.section + .section { margin-top: 28px; }
.section h3 { margin: 0; font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.08em; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; }
.row { display: flex; flex-direction: column; gap: 10px; padding: 18px 20px; }
.row + .row { border-top: 1px solid var(--line); }
.row-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 16px; }
.row-name { display: flex; flex-wrap: wrap; align-items: baseline; gap: 10px; min-width: 0; }
.row-name strong { font-size: 15px; font-weight: 600; }
.row-name span { font-size: 13px; color: var(--muted); }
.row-meta { display: flex; align-items: center; gap: 16px; }
.ping { font-size: 13px; color: var(--muted); }
.ping b { color: var(--text); font-weight: 500; }
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 999px; font-size: 13px; font-weight: 600; }
.pill::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.pill.on { background: rgba(63, 185, 80, 0.15); color: #56d364; }
.pill.off { background: rgba(248, 81, 73, 0.15); color: #ff7b72; }
.row-foot { display: flex; justify-content: space-between; gap: 8px; font-size: 12px; color: var(--muted); }

/* History bars: one per 20 minutes, CSS-only tooltip on hover (tap toggles it on touch) */
.bars { display: flex; align-items: stretch; height: 34px; gap: 2px; }
.bars.dense { gap: 1px; }
.bar { position: relative; flex: 1 1 0; min-width: 0; border-radius: 2px; cursor: default; transition: filter 60ms linear; }
.bar:hover, .bar.open { filter: brightness(1.35); }
.k-u { background: var(--up); }
.k-p { background: var(--part); }
.k-d { background: var(--down); }
.k-m { background: var(--maint); }
.k-n { background: var(--none); }
.tip {
  position: absolute; bottom: calc(100% + 10px); left: 50%; z-index: 20;
  width: max-content; max-width: 240px; padding: 10px 12px; border-radius: 8px;
  background: var(--tip); border: 1px solid var(--tip-line); box-shadow: 0 8px 24px rgba(1, 4, 9, 0.6);
  font-size: 12px; line-height: 1.45; color: var(--text); text-align: left; white-space: normal;
  opacity: 0; visibility: hidden; pointer-events: none;
  transform: translate(-50%, 4px);
  transition: opacity 80ms ease-out, transform 80ms ease-out, visibility 0s linear 80ms;
}
.tip.l { left: -2px; transform: translate(0, 4px); }
.tip.r { left: auto; right: -2px; transform: translate(0, 4px); }
.bar:hover .tip, .bar.open .tip {
  opacity: 1; visibility: visible; transform: translate(-50%, 0);
  transition: opacity 80ms ease-out, transform 80ms ease-out, visibility 0s;
}
.bar:hover .tip.l, .bar:hover .tip.r, .bar.open .tip.l, .bar.open .tip.r { transform: translate(0, 0); }
.tip-when { display: block; color: var(--muted); }
.tip-state { display: flex; align-items: center; gap: 6px; margin-top: 4px; font-weight: 600; }
.tip-state i { width: 8px; height: 8px; border-radius: 2px; }
.tip-detail { display: block; margin-top: 2px; color: var(--text-2); }

/* Footer */
.foot { display: flex; flex-direction: column; gap: 14px; padding-top: 16px; border-top: 1px solid var(--line); }
.legend { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 8px 20px; font-size: 13px; color: var(--text-2); }
.legend li { display: flex; align-items: center; gap: 8px; }
.sw { width: 12px; height: 12px; border-radius: 2px; }
.foot p { margin: 0; font-size: 13px; color: var(--muted); line-height: 1.5; }

.error-note { margin: 0; padding: 12px 16px; border-radius: 8px; background: var(--panel); border: 1px solid var(--line); color: var(--text-2); font-size: 13px; }

@media (max-width: 640px) {
  .page { padding-top: 24px; gap: 22px; }
  .row { padding: 16px 14px; }
  .bars { height: 30px; }
}
