:root {
  --bg: #070b16;
  --panel: rgba(17, 24, 43, 0.72);
  --panel-border: rgba(148, 163, 184, 0.14);
  --text: #e6ebf5;
  --muted: #8b97ad;
  --ok: #34d399;
  --warn: #fbbf24;
  --bad: #f87171;
  --accent: #94a3b8;
  --accent-soft: rgba(148, 163, 184, 0.18);
  --radius: 18px;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --sans: Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

/* Region themes */
body[data-region="us-east-1"] { --accent: #ff9900; --accent-soft: rgba(255, 153, 0, 0.18); }
body[data-region="us-west-2"] { --accent: #22d3ee; --accent-soft: rgba(34, 211, 238, 0.18); }

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.5;
  transition: background-color 0.6s;
}
.mono { font-family: var(--mono); }
.muted { color: var(--muted); font-weight: 400; }

/* ---------- Backdrop ---------- */
.backdrop { position: fixed; inset: 0; overflow: hidden; z-index: -1; }
.orb {
  position: absolute; border-radius: 50%; filter: blur(90px); opacity: 0.55;
  background: var(--accent); transition: background 0.8s;
  animation: drift 18s ease-in-out infinite alternate;
}
.orb-a { width: 520px; height: 520px; top: -160px; left: -120px; }
.orb-b { width: 420px; height: 420px; bottom: -180px; right: -80px; opacity: 0.3; animation-delay: -6s; }
.grid-lines {
  position: absolute; inset: 0;
  background-image:
    linear-gradient(rgba(148,163,184,0.05) 1px, transparent 1px),
    linear-gradient(90deg, rgba(148,163,184,0.05) 1px, transparent 1px);
  background-size: 44px 44px;
  mask-image: radial-gradient(ellipse at center, black 30%, transparent 75%);
}
@keyframes drift { to { transform: translate(80px, 60px) scale(1.1); } }

/* ---------- Layout ---------- */
.topbar {
  display: flex; justify-content: space-between; align-items: center; gap: 16px;
  padding: 18px 32px; font-size: 14px;
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 600; letter-spacing: 0.01em; }
.brand-mark {
  width: 14px; height: 14px; border-radius: 4px; background: var(--accent);
  box-shadow: 0 0 18px var(--accent); transition: background 0.6s, box-shadow 0.6s;
}
.host { color: var(--muted); font-family: var(--mono); font-size: 13px; }
.wrap { max-width: 1180px; margin: 0 auto; padding: 8px 32px 40px; }

.card {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius);
  padding: 22px 24px;
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.35);
}
.card h2 { margin: 0; font-size: 15px; font-weight: 600; letter-spacing: 0.01em; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 16px; }
.hint { margin: -6px 0 14px; color: var(--muted); font-size: 13px; }

/* ---------- Hero ---------- */
.hero {
  display: grid; grid-template-columns: 1fr 260px; align-items: center; gap: 24px;
  padding: 36px 40px; margin-bottom: 22px;
  border-color: color-mix(in srgb, var(--accent) 35%, transparent);
}
.eyebrow { margin: 0; text-transform: uppercase; letter-spacing: 0.14em; font-size: 12px; color: var(--muted); }
.region-code {
  margin: 6px 0 2px; font-size: clamp(44px, 7vw, 84px); line-height: 1.05; font-weight: 800;
  letter-spacing: -0.03em; font-family: var(--mono);
  background: linear-gradient(120deg, #fff 10%, var(--accent) 90%);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.region-name { margin: 0 0 18px; font-size: 20px; color: var(--muted); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 12px; border-radius: 999px; font-size: 13px;
  background: rgba(148, 163, 184, 0.1); border: 1px solid var(--panel-border); color: var(--text);
}
.chip-state { font-weight: 600; }
.chip-state::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.chip-state.ok { color: var(--ok); background: rgba(52, 211, 153, 0.12); border-color: rgba(52, 211, 153, 0.35); }
.chip-state.warn { color: var(--warn); background: rgba(251, 191, 36, 0.12); border-color: rgba(251, 191, 36, 0.35); }
.chip-state.bad { color: var(--bad); background: rgba(248, 113, 113, 0.12); border-color: rgba(248, 113, 113, 0.35); }

.globe { position: relative; width: 220px; height: 220px; margin-left: auto; }
.globe-core {
  position: absolute; inset: 70px; border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #fff 0%, var(--accent) 45%, transparent 75%);
  box-shadow: 0 0 60px var(--accent); transition: box-shadow 0.6s;
}
.globe-ring {
  position: absolute; inset: 0; border-radius: 50%;
  border: 1px solid color-mix(in srgb, var(--accent) 55%, transparent);
  animation: ping 3.6s cubic-bezier(0.2, 0.6, 0.3, 1) infinite;
}
.globe-ring.r2 { animation-delay: 1.2s; }
.globe-ring.r3 { animation-delay: 2.4s; }
@keyframes ping { from { transform: scale(0.35); opacity: 1; } to { transform: scale(1); opacity: 0; } }

/* ---------- Cards grid ---------- */
.cards { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 22px; }
.topology, .guestbook, .fleet { grid-column: span 2; }

.badge {
  font-size: 12px; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase;
  padding: 4px 10px; border-radius: 999px; background: rgba(148, 163, 184, 0.12); color: var(--muted);
}
.badge.ok { background: rgba(52, 211, 153, 0.14); color: var(--ok); }
.badge.warn { background: rgba(251, 191, 36, 0.14); color: var(--warn); }
.badge.bad { background: rgba(248, 113, 113, 0.14); color: var(--bad); }

/* ---------- Topology ---------- */
.topo { display: grid; grid-template-columns: 1fr 1.4fr 1fr; align-items: center; gap: 12px; margin: 6px 0 18px; }
.node {
  display: flex; flex-direction: column; gap: 4px; padding: 16px 18px; border-radius: 14px;
  background: rgba(2, 6, 23, 0.55); border: 1px solid var(--panel-border); transition: border-color 0.4s, box-shadow 0.4s;
}
.node.here { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.node-region { font-size: 17px; font-weight: 700; }
.node-role { font-size: 13px; color: var(--muted); }
.node-fs { font-size: 12px; color: var(--muted); }

.link { display: flex; flex-direction: column; align-items: center; gap: 8px; }
.link-track {
  position: relative; width: 100%; height: 6px; border-radius: 6px; overflow: hidden;
  background: repeating-linear-gradient(90deg, rgba(148,163,184,0.25) 0 10px, transparent 10px 18px);
}
.link-track span {
  position: absolute; top: 0; width: 22%; height: 100%; border-radius: 6px; opacity: 0;
  background: linear-gradient(90deg, transparent, var(--accent), transparent);
}
.link[data-dir="right"] .link-track span { opacity: 1; animation: flow-right 2.2s linear infinite; }
.link[data-dir="left"] .link-track span { opacity: 1; animation: flow-left 2.2s linear infinite; }
.link-track span:nth-child(2) { animation-delay: -0.73s !important; }
.link-track span:nth-child(3) { animation-delay: -1.46s !important; }
@keyframes flow-right { from { left: -25%; } to { left: 100%; } }
@keyframes flow-left { from { left: 100%; } to { left: -25%; } }
.link-label { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.08em; text-align: center; }

.facts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 24px; margin: 0; }
.facts.stacked { grid-template-columns: 1fr; }
.facts div { display: flex; flex-direction: column; gap: 2px; }
.facts dt { font-size: 12px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); }
.facts dd { margin: 0; font-size: 15px; }

/* ---------- Fleet ---------- */
.chip-server { font-family: var(--mono); color: var(--accent); border-color: color-mix(in srgb, var(--accent) 40%, transparent); }
.fleet-table { display: grid; gap: 6px; }
.fleet-row {
  display: grid; grid-template-columns: 0.7fr 1fr 1.6fr 1.4fr 1.5fr 0.9fr 1fr; align-items: center; gap: 10px;
  padding: 10px 14px; border-radius: 10px; font-size: 14px;
  background: rgba(2, 6, 23, 0.45); border: 1px solid var(--panel-border); transition: border-color 0.4s;
}
.fleet-row.self { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); }
.fleet-header { background: transparent; border: 0; padding-top: 0; padding-bottom: 0; font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); }
.fleet-pair { font-family: var(--mono); font-weight: 700; }
.fleet-dir { font-family: var(--mono); font-size: 13px; }
.fleet-dir .arrow { display: inline-block; color: var(--accent); animation: nudge 1.4s ease-in-out infinite; }
@keyframes nudge { 50% { transform: translateX(3px); } }
.fleet-row .badge { justify-self: start; }

/* ---------- Heartbeats ---------- */
.beats { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; }
.beat { display: grid; grid-template-columns: 110px 1fr 90px; align-items: center; gap: 12px; }
.beat-region { font-family: var(--mono); font-weight: 600; }
.beat-bar { height: 8px; border-radius: 8px; background: rgba(148,163,184,0.15); overflow: hidden; }
.beat-bar i { display: block; height: 100%; border-radius: 8px; background: var(--ok); transition: width 0.6s, background 0.6s; }
.beat-age { text-align: right; font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }

/* ---------- Guestbook ---------- */
.entry-form { display: grid; grid-template-columns: 180px 1fr auto; gap: 10px; }
.entry-form input {
  min-width: 0; padding: 11px 14px; border-radius: 10px; font: inherit; color: var(--text);
  background: rgba(2, 6, 23, 0.6); border: 1px solid var(--panel-border); outline: none;
}
.entry-form input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.entry-form button {
  padding: 11px 18px; border: 0; border-radius: 10px; font: inherit; font-weight: 600; cursor: pointer;
  color: #0b1020; background: var(--accent); transition: filter 0.2s, opacity 0.2s, background 0.6s;
}
.entry-form button:hover { filter: brightness(1.1); }
.entry-form button:disabled { opacity: 0.45; cursor: not-allowed; }
.form-msg { min-height: 20px; margin: 8px 0 4px; font-size: 13px; color: var(--muted); }
.form-msg.bad { color: var(--bad); }
.form-msg.ok { color: var(--ok); }

.entries { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; max-height: 340px; overflow-y: auto; }
.entry {
  display: grid; grid-template-columns: auto 1fr auto; gap: 12px; align-items: baseline;
  padding: 10px 14px; border-radius: 10px; background: rgba(2, 6, 23, 0.45); border: 1px solid var(--panel-border);
  animation: rise 0.35s ease-out;
}
.entry-region {
  font-family: var(--mono); font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 6px;
  background: rgba(148,163,184,0.15);
}
.entry-region.us-east-1 { color: #ff9900; background: rgba(255,153,0,0.14); }
.entry-region.us-west-2 { color: #22d3ee; background: rgba(34,211,238,0.14); }
.entry-body { min-width: 0; overflow-wrap: anywhere; }
.entry-name { font-weight: 600; margin-right: 6px; }
.entry-time { font-size: 12px; color: var(--muted); white-space: nowrap; }
.empty { color: var(--muted); font-size: 14px; padding: 8px 2px; }
@keyframes rise { from { opacity: 0; transform: translateY(4px); } }

/* ---------- Footer ---------- */
.foot { display: flex; justify-content: center; align-items: center; gap: 10px; padding: 0 0 28px; color: var(--muted); font-size: 13px; }
.pulse { width: 8px; height: 8px; border-radius: 50%; background: var(--ok); }
.pulse.beat-now { animation: blip 0.6s ease-out; }
.pulse.stale { background: var(--bad); }
@keyframes blip { from { box-shadow: 0 0 0 0 rgba(52,211,153,0.7); } to { box-shadow: 0 0 0 10px rgba(52,211,153,0); } }

/* ---------- Responsive ---------- */
@media (max-width: 860px) {
  .hero { grid-template-columns: 1fr; padding: 28px; }
  .hero-right { display: none; }
  .cards { grid-template-columns: 1fr; }
  .topology, .guestbook, .fleet { grid-column: span 1; }
  .fleet-row { grid-template-columns: 1fr 1fr; }
  .fleet-header { display: none; }
  .topo { grid-template-columns: 1fr; }
  .entry-form { grid-template-columns: 1fr; }
  .topbar, .wrap { padding-left: 18px; padding-right: 18px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
