/* The rettui web UI's look: same colours, font, radii and panels. */
@font-face {
  font-family: "FiraCode Nerd Font";
  src: url("fonts/FiraCodeNerdFont-Regular-Text.woff2") format("woff2");
  font-weight: 300 500;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "FiraCode Nerd Font";
  src: url("fonts/FiraCodeNerdFont-Bold-Text.woff2") format("woff2");
  font-weight: 600 800;
  font-style: normal;
  font-display: swap;
}

:root {
  --bg: #16161e;
  --panel: #1c1c26;
  --raised: #24243a;
  --selected: #2a2a3a;
  --border: #3b3b4f;
  --text: #dcdce4;
  --dim: #9a9aae;
  --accent: #4fd6e0;
  --green: #3fcf8e;
  --yellow: #f2d45c;
  --red: #f26d6d;
  --green-bg: #3fcf8e;
  --yellow-bg: #f2d45c;
  --red-bg: #f26d6d;
  --grey-bg: #b4b4c0;
  --on-accent: #0b0b10;
  --sunken: #14141c;
  --sans: "FiraCode Nerd Font", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "FiraCode Nerd Font", ui-monospace, Menlo, Consolas, monospace;
  color-scheme: dark;
}
:root[data-theme=light] {
  --bg: #f3f3f6;
  --panel: #ffffff;
  --raised: #ebebf1;
  --selected: #dde3f1;
  --border: #c8c8d4;
  --text: #1b1b24;
  --dim: #5d5d6e;
  --accent: #006a73;
  --green: #146c42;
  --yellow: #7a5800;
  --red: #c02626;
  --on-accent: #ffffff;
  --sunken: #f0f0f4;
  color-scheme: light;
}
:root[data-theme=light] .wordmark { filter: invert(1) hue-rotate(180deg); }

* { box-sizing: border-box; }

html, body { margin: 0; background: var(--bg); color: var(--text); }
body {
  min-height: 100vh;
  font: 14px/1.45 var(--sans);
  font-variant-ligatures: none;
  font-feature-settings: "calt" 0, "liga" 0;
  display: flex;
  flex-direction: column;
}

a { color: var(--accent); }
a:hover { text-decoration: none; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
a.panel:focus-visible, .btn:focus-visible { outline-offset: 3px; }

button {
  font: inherit;
  color: inherit;
  background: var(--raised);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 4px 10px;
  cursor: pointer;
  white-space: nowrap;
}
button:hover { border-color: var(--accent); }
#theme-toggle { display: none; }
.js #theme-toggle { display: inline-block; }

.wrap { width: 100%; max-width: 900px; margin: 0 auto; padding-inline: 16px; }

header.top { border-bottom: 1px solid var(--border); background: var(--bg); }
header.top .wrap { display: flex; align-items: center; gap: 16px; padding-top: 12px; padding-bottom: 12px; flex-wrap: wrap; }
.brand { display: flex; align-items: center; margin-right: auto; }
.brand .wordmark { display: block; height: 20px; width: auto; }
nav.links { display: flex; gap: 14px; }
nav.links a { color: var(--dim); text-decoration: none; padding: 4px 0; border-bottom: 2px solid transparent; }
nav.links a:hover { color: var(--text); }
nav.links a[aria-current=page] { color: var(--text); border-bottom-color: var(--accent); }

main { flex: 1; padding-top: 28px; padding-bottom: 40px; }
h1, h2, h3 { margin: 0; line-height: 1.25; }
h2 { font-size: 16px; margin: 32px 0 12px; }
p { margin: 0 0 12px; }

.hero { text-align: center; padding: 24px 0 8px; }
.hero .wordmark { display: block; height: 72px; width: auto; max-width: 100%; margin: 0 auto 16px; }
.hero h1 { font-size: 22px; text-wrap: balance; max-width: 24em; margin: 0 auto 8px; }
.hero p { text-wrap: balance; color: var(--dim); font-size: 16px; max-width: 34em; margin: 0 auto 20px; }
.actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px 10px; }

.btn {
  display: inline-block;
  padding: 6px 14px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--raised);
  color: var(--text);
  text-decoration: none;
}
.btn:hover { border-color: var(--accent); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); font-weight: 600; }

.grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.panel { background: var(--panel); border: 1px solid var(--border); border-radius: 6px; padding: 12px 14px; }
.panel h3 { font-size: 14px; margin-bottom: 4px; }
.panel p { color: var(--dim); margin: 0; }
a.panel { display: block; color: inherit; text-decoration: none; }
a.panel:hover { border-color: var(--accent); }
a.panel h3 { color: var(--accent); }

footer { border-top: 1px solid var(--border); color: var(--dim); font-size: 12px; }
footer .wrap { padding-top: 14px; padding-bottom: 14px; display: flex; gap: 8px 16px; flex-wrap: wrap; justify-content: center; text-align: center; }

/* Status page */
.banner { border: 1px solid var(--border); border-left-width: 6px; border-radius: 6px; background: var(--panel); padding: 12px 14px; }
.banner h1 { font-size: 18px; }
.banner p { color: var(--dim); margin: 4px 0 0; }
.banner.up { border-left-color: var(--green); }
.banner.degraded { border-left-color: var(--yellow); }
.banner.down { border-left-color: var(--red); }
.banner.unknown { border-left-color: var(--dim); }

.hosts { list-style: none; margin: 16px 0 0; padding: 0; display: grid; gap: 12px; }
.host { background: var(--panel); border: 1px solid var(--border); border-radius: 6px; padding: 12px 14px; }
.host-head { display: flex; justify-content: space-between; align-items: center; gap: 8px 12px; flex-wrap: wrap; }
.host-name { font-weight: 600; overflow-wrap: anywhere; }
.pill { display: inline-block; border-radius: 6px; padding: 1px 8px; font-weight: 600; color: #0b0b10; background: var(--grey-bg); }
.pill.up { background: var(--green-bg); }
.pill.down { background: var(--red-bg); }
.stats { display: flex; flex-wrap: wrap; gap: 4px 20px; margin: 8px 0; color: var(--dim); font-size: 13px; }
.stats b { color: var(--text); font-weight: 500; }
.node-stats { margin-top: -2px; }
.node-stats.unavailable, .node-stats .muted { font-style: italic; }
.bar { display: flex; gap: 2px; height: 24px; background: var(--sunken); border-radius: 6px; padding: 3px; overflow: hidden; }
.bar span { flex: 1 1 0; min-width: 0; border-radius: 2px; background: var(--border); align-self: center; height: 40%; }
/* Down checks are taller than up checks, so they show without colour. */
.bar span.up { background: var(--green); }
.bar span.down { background: var(--red); align-self: stretch; height: auto; }
.host.loading { color: var(--dim); }
.stale .banner, .stale .hosts { opacity: 0.6; }
.bar-note { color: var(--dim); font-size: 13px; margin-top: 4px; }
.note { color: var(--dim); font-size: 13px; margin-top: 16px; }

/* Names, badges and proxy groups */
.host-title { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 10px; min-width: 0; }
.host-addr { color: var(--dim); font-size: 12px; overflow-wrap: anywhere; font-weight: 400; }
.badge { display: inline-block; font-size: 11px; line-height: 1.5; padding: 0 7px; border: 1px solid var(--border); border-radius: 999px; color: var(--dim); white-space: nowrap; font-weight: 500; }
.badge.proxy { color: var(--accent); border-color: var(--accent); }
.host.proxy { border-color: var(--accent); }
.group { margin-top: 12px; padding: 8px 0 0 12px; border-left: 3px solid var(--accent); }
.group h3 { font-size: 14px; }
.group .stats { margin: 6px 0 4px; }
.group .note { margin: 4px 0 0; }
.group .partial { color: var(--yellow); }
.members { list-style: none; margin: 12px 0 0; padding: 0; display: grid; gap: 10px; }
.host.member { background: var(--bg); }
.viewbar { display: flex; align-items: center; gap: 8px; margin: 12px 0 0; }
.viewbar[hidden] { display: none; }
.viewbar select { font: inherit; color: var(--text); background: var(--raised); border: 1px solid var(--border); border-radius: 6px; padding: 4px 8px; min-width: 0; max-width: 100%; }
.viewbar select:hover { border-color: var(--accent); }

/* Node details */
.detail-btn { margin: 4px 0 8px; font-size: 13px; }
dialog.detail {
  background: var(--panel); color: var(--text); border: 1px solid var(--border); border-radius: 6px;
  padding: 14px 16px; width: min(860px, calc(100% - 16px)); max-height: calc(100vh - 16px);
  overflow-y: auto; overscroll-behavior: contain;
}
dialog.detail::backdrop { background: rgba(0, 0, 0, 0.6); }
.detail-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.detail-head h2 { margin: 0; font-size: 16px; overflow-wrap: anywhere; }
.range { display: flex; gap: 6px; margin: 12px 0 4px; }
.range button[aria-pressed=true] { background: var(--accent); border-color: var(--accent); color: var(--on-accent); font-weight: 600; }
.detail-section { margin-top: 20px; }
.detail-section h3 { font-size: 14px; margin-bottom: 8px; padding-bottom: 4px; border-bottom: 1px solid var(--border); }
.detail-section h4 { font-size: 13px; margin: 12px 0 4px; color: var(--dim); font-weight: 500; }
.facts { display: grid; grid-template-columns: max-content 1fr; gap: 2px 16px; margin: 0; }
.facts dt { color: var(--dim); }
.facts dd { margin: 0; overflow-wrap: anywhere; }
.versions { margin: 0; padding-left: 18px; }
.detail .muted { color: var(--dim); }
.detail .note { margin-top: 8px; }
.empty { margin: 16px 0 0; padding: 10px 12px; border: 1px dashed var(--border); border-radius: 6px; background: var(--sunken); }
.total { margin: 0 0 8px; }
.shares { list-style: none; margin: 8px 0 0; padding: 0; display: grid; gap: 4px; }
.shares li { display: grid; grid-template-columns: 12px minmax(0, 1fr) auto 4.5em; gap: 8px; align-items: center; }
.shares .muted { text-align: right; }
.shares b { font-weight: 500; text-align: right; }
.chart { margin: 12px 0 0; }
.chart svg, .detail-section > svg { display: block; max-width: 100%; }
.plot { position: relative; }
/* Vertical drags still scroll the page; sideways drags move the guide. */
.plot svg { touch-action: pan-y; }
.plot svg:focus-visible { outline-offset: 0; border-radius: 4px; }
.sr-only { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.tip {
  position: absolute; left: 0; top: 0; z-index: 2; pointer-events: none; white-space: nowrap;
  background: var(--raised); color: var(--text); border: 1px solid var(--border); border-radius: 6px;
  padding: 6px 8px; font-size: 12px; box-shadow: 0 2px 10px rgba(0, 0, 0, 0.35);
}
.tip[hidden] { display: none; }
.tip-time { color: var(--dim); margin-bottom: 4px; }
.tip-rows { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.tip-rows li { display: grid; grid-template-columns: 22px auto auto; gap: 6px; align-items: center; }
.tip-rows b { font-weight: 500; text-align: right; margin-left: 8px; }
.tip-rows b.muted { color: var(--dim); font-style: italic; }
.guide { stroke: var(--dim); stroke-width: 1; pointer-events: none; }
.hp, .hp.d1, .hp.d2 { stroke: var(--panel); stroke-width: 2; stroke-dasharray: none; pointer-events: none; }
.legend { list-style: none; margin: 0 0 4px; padding: 0; display: flex; flex-wrap: wrap; gap: 2px 14px; font-size: 13px; }
.legend li { display: inline-flex; align-items: center; gap: 6px; }
.chart-note { color: var(--dim); font-size: 12px; margin-top: 4px; }
.chart text { fill: var(--dim); font: 11px var(--mono); }
.chart .grid { stroke: var(--border); stroke-width: 1; stroke-dasharray: 2 3; }
.chart .axis { stroke: var(--dim); stroke-width: 1; }
.ln { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.dot { stroke: none; }
.d1 { stroke-dasharray: 6 3; }
.d2 { stroke-dasharray: 2 3; }
.ln.c1 { stroke: var(--accent); } .dot.c1, .hp.c1, .fill.c1 { fill: var(--accent); }
.ln.c2 { stroke: var(--green); } .dot.c2, .hp.c2, .fill.c2 { fill: var(--green); }
.ln.c3 { stroke: var(--yellow); } .dot.c3, .hp.c3, .fill.c3 { fill: var(--yellow); }
.ln.c4 { stroke: var(--text); } .dot.c4, .hp.c4, .fill.c4 { fill: var(--text); }
.fill.c5 { fill: var(--dim); }
.bar-bg { fill: var(--sunken); }
.detail-body svg[role=img] { display: block; }

@media (max-width: 520px) {
  dialog.detail { padding: 12px; }
  .range button, #detail-close, .detail-btn, .viewbar select { min-height: 40px; }
  .viewbar { flex-wrap: wrap; }
  .group { padding-left: 8px; }
  .range { gap: 8px; }
  header.top .wrap { gap: 4px 12px; }
  .brand { min-height: 40px; }
  nav.links { order: 3; flex: 1 0 100%; gap: 0 4px; }
  nav.links a { display: inline-flex; align-items: center; min-height: 40px; padding: 0 8px; }
  .brand { margin-right: auto; }
  #theme-toggle { min-height: 40px; }
  .btn { min-height: 44px; display: inline-flex; align-items: center; }
  .hero .wordmark { height: 54px; }
  .hero p { font-size: 14px; }
  .bar { gap: 1px; }
}

.hero .hub { margin: 32px auto 0; font-size: 13px; color: var(--dim); word-break: break-all; }
.hero .hub .copy { cursor: copy; }
.hero .hub .copied { color: var(--green); margin-left: 6px; }
.detail-head h2 .host-addr { margin-left: 10px; }
