:root {
  --bg: #0b0d10;
  --panel: #12161b;
  --panel-2: #0f1317;
  --line: #1f262e;
  --text: #e6edf3;
  --muted: #8b98a5;
  --accent: #6ee7b7;
  --accent-dim: #2f6f5a;
  --warn: #fbbf24;
  --err: #f87171;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

.wrap {
  max-width: 940px;
  margin: 0 auto;
  padding: 40px 20px 40px;
}

/* ---------- header + 3D scene ---------- */

.head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 28px;
}

.head-copy { min-width: 0; }

.head h1 {
  font-size: 1.6rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  margin: 0 0 8px;
}

.head .pi {
  color: var(--accent);
  font-family: "Iowan Old Style", Georgia, "Times New Roman", serif;
  font-style: italic;
  margin-right: 2px;
}

.head .sub {
  margin: 0;
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.55;
  max-width: 52ch;
}

.scene {
  flex: 0 0 auto;
  width: 148px;
  height: 148px;
  perspective: 620px;
  perspective-origin: 50% 50%;
}

.orb {
  position: relative;
  width: 100%;
  height: 100%;
  transform-style: preserve-3d;
  animation: orb-spin 22s linear infinite;
  will-change: transform;
}

.ring {
  position: absolute;
  inset: 8px;
  border-radius: 50%;
  border: 1px solid rgba(110, 231, 183, 0.42);
  transform-style: preserve-3d;
}

.ring-a { transform: rotateX(72deg) rotateZ(0deg); animation: ring-a 14s linear infinite; }
.ring-b { transform: rotateY(72deg) rotateX(18deg); border-color: rgba(110, 231, 183, 0.26); animation: ring-b 19s linear infinite; }
.ring-c { inset: 26px; transform: rotateX(38deg) rotateY(38deg); border-color: rgba(139, 152, 165, 0.35); animation: ring-c 26s linear infinite; }

.core {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: "Iowan Old Style", Georgia, serif;
  font-style: italic;
  font-size: 2.5rem;
  color: var(--accent);
  transform: translateZ(26px);
  text-shadow: 0 0 18px rgba(110, 231, 183, 0.45);
  animation: core-pulse 4.5s ease-in-out infinite;
}

.mote {
  position: absolute;
  top: 50%;
  left: 50%;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.72rem;
  color: rgba(201, 214, 226, 0.72);
  transform-style: preserve-3d;
}

.m1 { animation: mote-1 11s linear infinite; }
.m2 { animation: mote-2 13s linear infinite; }
.m3 { animation: mote-3 17s linear infinite; }
.m4 { animation: mote-4 15s linear infinite; }
.m5 { animation: mote-5 21s linear infinite; }
.m6 { animation: mote-6 9s linear infinite; }

@keyframes orb-spin {
  from { transform: rotateY(0deg) rotateX(6deg); }
  to   { transform: rotateY(360deg) rotateX(6deg); }
}

@keyframes ring-a {
  from { transform: rotateX(72deg) rotateZ(0deg); }
  to   { transform: rotateX(72deg) rotateZ(360deg); }
}

@keyframes ring-b {
  from { transform: rotateY(72deg) rotateX(18deg) rotateZ(0deg); }
  to   { transform: rotateY(72deg) rotateX(18deg) rotateZ(-360deg); }
}

@keyframes ring-c {
  from { transform: rotateX(38deg) rotateY(38deg) rotateZ(0deg); }
  to   { transform: rotateX(38deg) rotateY(38deg) rotateZ(360deg); }
}

@keyframes core-pulse {
  0%, 100% { opacity: 0.85; }
  50%      { opacity: 1; }
}

/* Motifs orbit on the XZ plane; translate3d keeps them on the GPU. */
@keyframes mote-1 {
  from { transform: rotateY(0deg) translateX(62px) rotateY(0deg); }
  to   { transform: rotateY(360deg) translateX(62px) rotateY(-360deg); }
}
@keyframes mote-2 {
  from { transform: rotateY(60deg) translateX(58px) rotateY(-60deg); }
  to   { transform: rotateY(420deg) translateX(58px) rotateY(-420deg); }
}
@keyframes mote-3 {
  from { transform: rotateY(120deg) translateX(66px) rotateY(-120deg); }
  to   { transform: rotateY(480deg) translateX(66px) rotateY(-480deg); }
}
@keyframes mote-4 {
  from { transform: rotateY(180deg) translateX(54px) rotateY(-180deg); }
  to   { transform: rotateY(540deg) translateX(54px) rotateY(-540deg); }
}
@keyframes mote-5 {
  from { transform: rotateY(240deg) translateX(64px) rotateY(-240deg); }
  to   { transform: rotateY(600deg) translateX(64px) rotateY(-600deg); }
}
@keyframes mote-6 {
  from { transform: rotateY(300deg) translateX(50px) rotateY(-300deg); }
  to   { transform: rotateY(660deg) translateX(50px) rotateY(-660deg); }
}

/* Stop painting when the tab is hidden — phones get their battery back. */
body.anim-paused .orb,
body.anim-paused .ring,
body.anim-paused .core,
body.anim-paused .mote { animation-play-state: paused; }

/* ---------- panel ---------- */

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 20px;
}

.stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 14px;
}

.stat {
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
  min-width: 0;
}

.label {
  display: block;
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin-bottom: 4px;
}

.value {
  font-size: 0.95rem;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: flex;
  align-items: center;
  gap: 6px;
}

.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--muted);
  flex: 0 0 auto;
  transition: background 0.2s ease;
}

.dot.live { background: var(--accent); box-shadow: 0 0 8px var(--accent-dim); }
.dot.polling { background: var(--warn); }
.dot.offline { background: var(--err); }

.tickbar {
  height: 3px;
  border-radius: 2px;
  background: var(--line);
  overflow: hidden;
  margin-bottom: 14px;
}

.tickbar i {
  display: block;
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--accent-dim), var(--accent));
  transition: width 0.25s linear;
}

.digits-box {
  position: relative;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 10px;
  height: 360px;
  overflow: hidden;
}

.digits-fade {
  position: absolute;
  inset: 0 0 auto 0;
  height: 44px;
  background: linear-gradient(var(--panel-2), rgba(15, 19, 23, 0));
  pointer-events: none;
}

.digits {
  height: 100%;
  overflow-y: auto;
  padding: 16px;
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
  font-size: 1rem;
  line-height: 1.75;
  letter-spacing: 0.02em;
  word-break: break-all;
  color: #9fb0c0;
  scrollbar-width: thin;
  scrollbar-color: var(--line) transparent;
  -webkit-overflow-scrolling: touch;
}

.digits::-webkit-scrollbar { width: 8px; }
.digits::-webkit-scrollbar-thumb { background: var(--line); border-radius: 4px; }

.digits .fresh {
  color: var(--accent);
  text-shadow: 0 0 10px rgba(110, 231, 183, 0.25);
}

.digits .head-dot { color: #c9d6e2; }

.foot {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-top: 14px;
  font-size: 0.78rem;
  color: var(--muted);
  flex-wrap: wrap;
}

.err { color: var(--err); }

.credit {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-top: 22px;
  font-size: 0.78rem;
  letter-spacing: 0.02em;
  color: var(--muted);
}

.credit strong { color: #c9d6e2; font-weight: 600; }

.credit-dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 8px var(--accent-dim);
}

/* ---------- responsive ---------- */

@media (max-width: 700px) {
  .wrap { padding: 26px 14px 32px; }
  .head { flex-direction: column-reverse; align-items: flex-start; gap: 10px; }
  .scene { width: 116px; height: 116px; align-self: center; }
  .core { font-size: 2rem; }
  .stats { grid-template-columns: 1fr; }
  .digits-box { height: 320px; }
  .digits { font-size: 0.92rem; }
  .head h1 { font-size: 1.35rem; }
}

/* Respect the OS "reduce motion" switch, and keep low-end phones cool. */
@media (prefers-reduced-motion: reduce) {
  .orb, .ring, .core, .mote { animation: none; }
  .tickbar i { transition: none; }
}
