:root {
  --bg-0: #071018;
  --bg-1: #0c1a24;
  --ink: #eef5f7;
  --muted: #a8bcc6;
  --line: rgba(232, 241, 244, 0.12);
  --teal: #2ec4b6;
  --teal-deep: #14919b;
  --amber: #f4b942;
  --rose: #ff6b6b;
  --panel: rgba(12, 26, 36, 0.55);
  --glow: rgba(46, 196, 182, 0.28);
  --font-display: "DM Sans", sans-serif;
  --font-body: "DM Sans", sans-serif;
  --font-mono: "IBM Plex Mono", monospace;
  --radius: 18px;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --meter-size: min(320px, 48vh, 34vw);
  --shell-max: min(1400px, 96vw);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
  height: 100dvh;
}

body {
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 1rem;
  line-height: 1.5;
  font-optical-sizing: auto;
  background: var(--bg-0);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -2;
  background:
    radial-gradient(ellipse 80% 55% at 15% -10%, rgba(46, 196, 182, 0.22), transparent 55%),
    radial-gradient(ellipse 60% 45% at 90% 10%, rgba(244, 185, 66, 0.12), transparent 50%),
    radial-gradient(ellipse 70% 50% at 50% 110%, rgba(20, 145, 155, 0.18), transparent 55%),
    linear-gradient(160deg, var(--bg-0), var(--bg-1) 55%, #08141c);
}

body::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  opacity: 0.35;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(232, 241, 244, 0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(232, 241, 244, 0.03) 1px, transparent 1px);
  background-size: 48px 48px;
  mask-image: radial-gradient(ellipse 70% 60% at 50% 40%, black, transparent);
}

.shell {
  width: var(--shell-max);
  height: 100%;
  height: 100dvh;
  margin: 0 auto;
  padding: 0.85rem 0 0.65rem;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: nowrap;
  gap: 0.75rem;
  margin-bottom: 0.45rem;
  flex-shrink: 0;
  animation: rise 0.7s var(--ease) both;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  text-decoration: none;
  color: inherit;
}

.brand-mark {
  width: 2.1rem;
  height: 2.1rem;
  border-radius: 0.7rem;
  display: grid;
  place-items: center;
  background: linear-gradient(145deg, var(--teal), var(--teal-deep));
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.08), 0 8px 22px var(--glow);
}

.brand-mark svg {
  width: 1.15rem;
  height: 1.15rem;
  fill: none;
  stroke: #062027;
  stroke-width: 2.2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.brand-text {
  display: flex;
  flex-direction: column;
  gap: 0.05rem;
}

.brand-name {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.2rem;
  letter-spacing: -0.01em;
  line-height: 1.15;
}

.brand-tag {
  font-size: 0.8rem;
  color: var(--muted);
  line-height: 1.3;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  flex-wrap: nowrap;
  justify-content: flex-end;
  flex-shrink: 0;
}

.design-switch {
  display: inline-flex;
  align-items: center;
  gap: 0.15rem;
  padding: 0.18rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.03);
}

.design-switch a {
  color: var(--muted);
  text-decoration: none;
  font-size: 0.8rem;
  font-weight: 600;
  padding: 0.32rem 0.8rem;
  border-radius: 999px;
  transition: color 0.2s ease, background 0.2s ease;
}

.design-switch a:hover {
  color: var(--ink);
}

.design-switch a.is-active {
  color: #062027;
  background: var(--teal);
}

.powered {
  font-size: 0.8rem;
  color: var(--muted);
  line-height: 1.4;
}

.powered a {
  color: var(--teal);
  text-decoration: none;
}

.hero {
  display: grid;
  grid-template-columns: 1fr 1.05fr;
  gap: 1.25rem 3vw;
  align-items: center;
  flex: 1 1 auto;
  min-height: 0;
  animation: rise 0.85s var(--ease) 0.08s both;
}

.hero-copy h1 {
  margin: 0 0 0.5rem;
  font-family: var(--font-display);
  font-size: clamp(1.75rem, 3.2vw, 2.75rem);
  line-height: 1.15;
  letter-spacing: -0.02em;
  font-weight: 600;
}

.hero-copy h1 span {
  color: var(--teal);
}

.hero-copy p {
  margin: 0 0 1.1rem;
  max-width: 42ch;
  color: var(--muted);
  font-size: clamp(0.95rem, 1.15vw, 1.1rem);
  font-weight: 400;
  line-height: 1.45;
}

.cta-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.65rem;
  margin-bottom: 0.65rem;
}

.start-btn {
  appearance: none;
  border: 0;
  cursor: pointer;
  font-family: var(--font-body);
  font-weight: 600;
  font-size: clamp(0.95rem, 1.15vw, 1.1rem);
  letter-spacing: 0;
  color: #062027;
  background: linear-gradient(135deg, var(--teal), #5eead4 55%, var(--amber));
  background-size: 180% 180%;
  padding: 0.85rem 1.55rem;
  border-radius: 999px;
  min-width: 11rem;
  transition: transform 0.25s var(--ease), box-shadow 0.25s var(--ease), background-position 0.4s ease;
  box-shadow: 0 10px 24px var(--glow);
}

.start-btn:hover {
  transform: translateY(-2px);
  background-position: 100% 50%;
}

.start-btn:active {
  transform: translateY(0);
}

.start-btn.running {
  color: #fff;
  background: linear-gradient(135deg, var(--rose), #ff8e72);
  box-shadow: 0 10px 22px rgba(255, 107, 107, 0.28);
}

.start-btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 500;
  line-height: 1.35;
}

.status-dot {
  width: 0.5rem;
  height: 0.5rem;
  border-radius: 50%;
  background: var(--muted);
  box-shadow: 0 0 0 0 rgba(46, 196, 182, 0.4);
}

.status-pill.live .status-dot {
  background: var(--teal);
  animation: pulse 1.4s ease-out infinite;
}

.status-pill.done .status-dot {
  background: var(--amber);
}

.ip-line {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  line-height: 1.4;
  color: var(--muted);
  min-height: 1.2em;
  word-break: break-word;
}

.stage {
  position: relative;
  display: grid;
  place-items: center;
  justify-items: center;
  align-content: center;
  min-height: 0;
  height: 100%;
  width: 100%;
}

.orbit {
  position: absolute;
  width: calc(var(--meter-size) * 1.35);
  aspect-ratio: 1;
  border-radius: 50%;
  border: 1px solid var(--line);
  background:
    radial-gradient(circle at 50% 50%, rgba(46, 196, 182, 0.08), transparent 55%);
  animation: spin 28s linear infinite;
}

.orbit::before,
.orbit::after {
  content: "";
  position: absolute;
  border-radius: 50%;
  background: var(--teal);
  box-shadow: 0 0 16px var(--glow);
}

.orbit::before {
  width: 7px;
  height: 7px;
  top: 12%;
  left: 62%;
}

.orbit::after {
  width: 5px;
  height: 5px;
  bottom: 18%;
  left: 22%;
  background: var(--amber);
  box-shadow: 0 0 14px rgba(244, 185, 66, 0.45);
}

.meter-wrap {
  position: relative;
  width: var(--meter-size);
  aspect-ratio: 1;
  display: grid;
  place-items: center;
}

.meter-wrap canvas {
  width: 100%;
  height: 100%;
  display: block;
}

.meter-core {
  position: absolute;
  inset: 22%;
  border-radius: 50%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  background: rgba(7, 16, 24, 0.72);
  border: 1px solid var(--line);
  backdrop-filter: blur(8px);
}

.meter-label {
  font-size: 0.75rem;
  font-weight: 500;
  letter-spacing: 0.02em;
  color: var(--muted);
}

.meter-value {
  font-family: var(--font-display);
  font-size: clamp(1.85rem, 5vh, 3rem);
  font-weight: 700;
  letter-spacing: -0.01em;
  line-height: 1.1;
  margin: 0.1rem 0;
  font-variant-numeric: tabular-nums;
}

.meter-unit {
  font-family: var(--font-body);
  font-size: clamp(0.8rem, 1.1vw, 0.95rem);
  font-weight: 500;
  color: var(--teal);
}

.metrics {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.75rem 1.25rem;
  margin-top: 0.65rem;
  flex-shrink: 0;
  animation: rise 0.9s var(--ease) 0.16s both;
}

.metric {
  padding: 0.7rem 0.85rem;
  border-top: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.03), transparent);
}

.metric-name {
  display: block;
  font-size: clamp(0.8rem, 1vw, 0.95rem);
  font-weight: 500;
  letter-spacing: 0.01em;
  color: var(--muted);
  margin-bottom: 0.3rem;
  line-height: 1.3;
}

.metric-value {
  font-family: var(--font-display);
  font-size: clamp(1.45rem, 2.2vw, 2.15rem);
  font-weight: 600;
  letter-spacing: -0.01em;
  line-height: 1.15;
  font-variant-numeric: tabular-nums;
}

.metric-unit {
  margin-left: 0.25rem;
  font-family: var(--font-body);
  font-size: clamp(0.8rem, 1vw, 0.95rem);
  font-weight: 500;
  color: var(--muted);
}

.metric.active .metric-value {
  color: var(--teal);
}

.progress {
  margin-top: 0.4rem;
  height: 3px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.06);
  overflow: hidden;
  flex-shrink: 0;
}

.progress > span {
  display: block;
  height: 100%;
  width: 0%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--teal-deep), var(--teal), var(--amber));
  transition: width 0.25s linear;
}

.foot {
  margin-top: 0.45rem;
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 0.5rem;
  color: var(--muted);
  font-size: 0.8rem;
  line-height: 1.4;
  border-top: 1px solid var(--line);
  padding-top: 0.45rem;
  flex-shrink: 0;
}

.foot a {
  color: var(--teal);
  text-decoration: none;
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes pulse {
  0% {
    box-shadow: 0 0 0 0 rgba(46, 196, 182, 0.45);
  }
  70% {
    box-shadow: 0 0 0 10px rgba(46, 196, 182, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(46, 196, 182, 0);
  }
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* Extra-compact for short laptop viewports (desktop only) */
@media (max-height: 820px) and (min-width: 901px) {
  :root {
    --meter-size: min(260px, 42vh, 28vw);
  }

  .shell {
    padding: 0.55rem 0 0.45rem;
  }

  .hero {
    gap: 0.85rem 2.5vw;
  }

  .hero-copy h1 {
    font-size: clamp(1.45rem, 2.6vw, 2.1rem);
  }

  .hero-copy p {
    font-size: 0.925rem;
    margin-bottom: 0.75rem;
  }

  .start-btn {
    padding: 0.7rem 1.25rem;
    font-size: 0.95rem;
  }

  .metric {
    padding: 0.5rem 0.65rem;
  }

  .metric-value {
    font-size: clamp(1.3rem, 1.8vw, 1.65rem);
  }

  .metrics {
    gap: 0.5rem 1rem;
    margin-top: 0.45rem;
  }
}

@media (max-height: 700px) and (min-width: 901px) {
  :root {
    --meter-size: min(210px, 36vh, 24vw);
  }

  .hero-copy p {
    display: none;
  }

  .brand-tag {
    display: none;
  }
}

@media (max-width: 900px) {
  :root {
    --meter-size: min(248px, calc(100vw - 2.5rem), 42vh);
    --shell-max: 100%;
  }

  html,
  body {
    height: auto;
    min-height: 100%;
    min-height: 100dvh;
  }

  body {
    overflow-x: hidden;
    overflow-y: auto;
  }

  .shell {
    width: 100%;
    max-width: 100%;
    height: auto;
    min-height: 100dvh;
    overflow: visible;
    overflow-x: hidden;
    padding: 0.75rem 1rem 1.15rem;
    padding-left: max(1rem, env(safe-area-inset-left));
    padding-right: max(1rem, env(safe-area-inset-right));
    justify-content: space-between;
    gap: 0.85rem;
  }

  /* Single-row header: brand left, switcher top-right */
  .topbar {
    flex-wrap: nowrap;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0;
  }

  .brand {
    min-width: 0;
    gap: 0.4rem;
    flex: 1 1 auto;
  }

  .brand-mark {
    width: 1.65rem;
    height: 1.65rem;
    border-radius: 0.5rem;
    flex-shrink: 0;
  }

  .brand-mark svg {
    width: 0.95rem;
    height: 0.95rem;
  }

  .brand-name {
    font-size: 1rem;
  }

  .brand-tag {
    display: none;
  }

  .topbar-right {
    gap: 0;
    flex: 0 0 auto;
    margin-left: auto;
  }

  .powered {
    display: none;
  }

  .design-switch {
    padding: 0.08rem;
    gap: 0;
  }

  .design-switch a {
    font-size: 0.66rem;
    padding: 0.3rem 0.5rem;
    line-height: 1.2;
  }

  .hero {
    grid-template-columns: 1fr;
    flex: 1 1 auto;
    gap: 1.15rem;
    align-content: space-evenly;
    justify-items: center;
    min-height: 0;
  }

  .hero-copy {
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.85rem;
    width: 100%;
  }

  .hero-copy h1 {
    font-size: clamp(1.35rem, 5.8vw, 1.85rem);
    margin: 0;
    line-height: 1.2;
  }

  .hero-copy p {
    display: none;
  }

  .cta-row {
    justify-content: center;
    flex-direction: column;
    align-items: center;
    gap: 0.75rem;
    margin: 0;
    width: 100%;
  }

  .start-btn {
    font-size: 0.95rem;
    padding: 0.75rem 1.35rem;
    min-height: 44px;
    min-width: 9.5rem;
  }

  .status-pill {
    font-size: 0.85rem;
    justify-content: center;
  }

  .ip-line {
    text-align: center;
    font-size: 0.74rem;
    min-height: 0;
    margin: 0;
    opacity: 0.9;
    line-height: 1.45;
  }

  .ip-line.is-empty {
    display: none;
  }

  .stage {
    order: -1;
    min-height: 0;
    width: 100%;
    display: grid;
    place-items: center;
    margin: 0;
    flex-shrink: 0;
  }

  .orbit {
    width: calc(var(--meter-size) * 1.22);
  }

  .meter-wrap {
    max-width: 100%;
  }

  .meter-value {
    font-size: clamp(1.55rem, 7vw, 2.15rem);
  }

  .meter-label {
    font-size: 0.68rem;
  }

  .meter-unit {
    font-size: 0.75rem;
  }

  .metrics {
    grid-template-columns: repeat(2, 1fr);
    gap: 0;
    margin-top: 0.35rem;
    border-top: 1px solid var(--line);
  }

  .metric {
    padding: 0.7rem 0.75rem;
    min-width: 0;
    border-top: 0;
    background: transparent;
  }

  .metric:nth-child(1),
  .metric:nth-child(2) {
    border-bottom: 1px solid rgba(232, 241, 244, 0.08);
  }

  .metric:nth-child(odd) {
    border-right: 1px solid rgba(232, 241, 244, 0.08);
  }

  .metric-name {
    font-size: 0.72rem;
    margin-bottom: 0.15rem;
    letter-spacing: 0.02em;
    text-transform: uppercase;
  }

  .metric-value {
    font-size: 1.35rem;
    letter-spacing: -0.02em;
  }

  .metric-unit {
    font-size: 0.72rem;
  }

  .progress {
    margin-top: 0;
  }

  .foot {
    margin-top: 0;
    font-size: 0.7rem;
    gap: 0.35rem 0.75rem;
  }

  .foot > span {
    min-width: 0;
    max-width: 100%;
    overflow-wrap: anywhere;
  }
}

@media (max-width: 480px) {
  :root {
    --meter-size: min(220px, calc(100vw - 2rem), 38vh);
  }

  .shell {
    gap: 0.95rem;
    padding-bottom: 1.25rem;
  }

  .hero {
    gap: 1.25rem;
  }

  .hero-copy {
    gap: 0.95rem;
  }

  .cta-row {
    gap: 0.8rem;
  }

  .design-switch a {
    font-size: 0.62rem;
    padding: 0.28rem 0.42rem;
  }

  .hero-copy h1 {
    font-size: clamp(1.25rem, 6vw, 1.55rem);
  }

  .metric {
    padding: 0.65rem 0.65rem;
  }

  .metric-value {
    font-size: 1.22rem;
  }

  .metric-unit {
    font-size: 0.68rem;
  }

  .foot {
    flex-direction: column;
    align-items: flex-start;
    font-size: 0.66rem;
    gap: 0.4rem;
  }
}

/* Wide + tall desktop: fill viewport, larger gauge */
@media (min-width: 901px) and (min-height: 820px) {
  :root {
    --meter-size: min(380px, 52vh, 36vw);
  }

  .brand-name {
    font-size: 1.35rem;
  }

  .status-pill {
    font-size: 1rem;
  }
}

@media (min-width: 1200px) and (min-height: 900px) {
  :root {
    --meter-size: min(420px, 54vh, 32vw);
  }

  .hero {
    gap: 1.5rem 4vw;
  }

  .meter-label {
    font-size: 0.85rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
  }
}
