:root {
  color-scheme: dark;
  --black: #050505;
  --ink: #101010;
  --paper: #f7f7f2;
  --soft: #d8d8d0;
  --muted: #8a8a82;
  --line: #2b2b29;
  --line-strong: #f4f4ef;
  --good: #f7f7f2;
  --warn: #bdbdb5;
  --shadow: rgba(0, 0, 0, .36);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Segoe UI", Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--black);
  color: var(--paper);
}

button,
select,
input {
  font: inherit;
}

button,
select,
input {
  border: 1px solid var(--line);
  background: var(--ink);
  color: var(--paper);
}

button {
  min-height: 44px;
  padding: 0 18px;
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: .42;
}

button:focus-visible,
select:focus-visible,
input:focus-visible {
  outline: 2px solid var(--paper);
  outline-offset: 3px;
}

h1,
h2,
p {
  margin: 0;
}

html {
  scroll-behavior: smooth;
}

a {
  color: inherit;
  text-decoration: none;
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 10;
  width: min(1180px, calc(100% - 32px));
  min-height: 76px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 22px;
  border-bottom: 1px solid var(--line);
  background: rgba(5, 5, 5, .92);
  backdrop-filter: blur(18px);
}

.app-only[hidden],
.auth-view[hidden] {
  display: none;
}

body[data-auth="guest"] .app-only,
body[data-auth="checking"] .app-only,
body[data-auth="authenticated"] .auth-view {
  display: none !important;
}

.auth-view {
  position: relative;
  overflow: hidden;
  overscroll-behavior: none;
  touch-action: pinch-zoom;
  min-height: 100vh;
  width: 100%;
  margin: 0;
  padding: 44px max(16px, calc((100vw - 1180px) / 2));
  display: grid;
  place-items: center;
}

.auth-canvas {
  position: fixed;
  inset: 0;
  z-index: 0;
  width: 100%;
  height: 100%;
  background: var(--black);
  pointer-events: none;
}

.auth-view::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  background:
    radial-gradient(circle at var(--pointer-x, 50%) var(--pointer-y, 50%), rgba(247, 247, 242, .12), transparent 22rem),
    linear-gradient(90deg, rgba(5, 5, 5, .08), rgba(5, 5, 5, .62) 48%, rgba(5, 5, 5, .12));
}

.auth-panel {
  position: relative;
  z-index: 2;
  width: 100%;
  min-height: min(760px, calc(100vh - 88px));
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(360px, 440px);
  align-items: center;
  gap: 56px;
  touch-action: auto;
}

.auth-brand {
  position: absolute;
  top: 28px;
  left: max(16px, calc((100vw - 1180px) / 2));
}

.auth-copy {
  display: grid;
  gap: 18px;
}

.auth-copy h1 {
  max-width: 760px;
  font-size: clamp(50px, 8vw, 104px);
}

.auth-copy p:not(.eyebrow) {
  max-width: 620px;
  color: var(--soft);
  font-size: clamp(17px, 2vw, 22px);
  line-height: 1.45;
}

.auth-card {
  position: relative;
  isolation: isolate;
  overflow: hidden;
  touch-action: manipulation;
  border: 1px solid var(--line);
  border-radius: 8px;
  background:
    linear-gradient(135deg, rgba(247, 247, 242, .075), rgba(247, 247, 242, .012) 32%, rgba(5, 5, 5, .52)),
    rgba(9, 9, 9, .34);
  -webkit-backdrop-filter: blur(26px) saturate(1.2);
  backdrop-filter: blur(26px) saturate(1.2);
  box-shadow:
    inset 0 1px 0 rgba(247, 247, 242, .22),
    inset 0 -1px 0 rgba(247, 247, 242, .06),
    0 28px 80px rgba(0, 0, 0, .42);
  padding: 22px;
  display: grid;
  gap: 20px;
}

.auth-card::before,
.auth-card::after {
  content: "";
  position: absolute;
  pointer-events: none;
}

.auth-card::before {
  inset: -1px;
  background:
    radial-gradient(circle at var(--pointer-x, 50%) var(--pointer-y, 50%), rgba(247, 247, 242, .18), transparent 18rem),
    linear-gradient(115deg, transparent 0%, rgba(247, 247, 242, .08) 34%, transparent 48%);
  opacity: .46;
  mix-blend-mode: screen;
  animation: glass-sheen 9s ease-in-out infinite alternate;
}

.auth-card::after {
  inset: 1px;
  border: 1px solid rgba(247, 247, 242, .06);
  border-radius: 7px;
}

.auth-card > * {
  position: relative;
  z-index: 1;
}

@keyframes glass-sheen {
  from {
    transform: translate3d(-4%, -2%, 0) scale(1.03);
  }

  to {
    transform: translate3d(4%, 2%, 0) scale(1.06);
  }
}

.auth-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  border: 1px solid rgba(247, 247, 242, .12);
  border-radius: 6px;
  background: rgba(5, 5, 5, .18);
  box-shadow: inset 0 1px 0 rgba(247, 247, 242, .08);
  overflow: hidden;
}

.auth-tab {
  min-width: 0;
  border: 0;
  background: transparent;
  color: var(--muted);
}

.auth-tab + .auth-tab {
  border-left: 1px solid rgba(247, 247, 242, .1);
}

.auth-tab.active {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, .96), rgba(218, 218, 210, .92));
  color: var(--black);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, .72),
    0 8px 28px rgba(247, 247, 242, .08);
}

.auth-form {
  display: grid;
  gap: 14px;
}

.auth-form[hidden] {
  display: none;
}

.auth-form input {
  width: 100%;
  min-height: 46px;
  padding: 0 12px;
  border-radius: 5px;
  font-size: 16px;
  border-color: rgba(247, 247, 242, .1);
  background:
    linear-gradient(180deg, rgba(247, 247, 242, .026), rgba(5, 5, 5, .14)),
    rgba(5, 5, 5, .24);
  box-shadow:
    inset 0 1px 0 rgba(247, 247, 242, .08),
    inset 0 -1px 0 rgba(0, 0, 0, .32);
}

.auth-submit {
  width: 100%;
  margin-top: 6px;
}

.auth-status {
  min-height: 22px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.auth-status[data-tone="error"] {
  color: #f1b8b8;
}

.auth-status[data-tone="success"] {
  color: var(--paper);
}

.site-brand,
.site-nav {
  display: flex;
  align-items: center;
}

.site-brand {
  gap: 13px;
  font-size: 18px;
}

.site-brand .brand-mark {
  width: 34px;
  height: 34px;
}

.site-brand .brand-mark::before {
  width: 14px;
  height: 14px;
}

.site-nav {
  gap: 6px;
}

.site-nav [hidden] {
  display: none !important;
}

.site-nav a {
  min-height: 40px;
  display: inline-flex;
  align-items: center;
  padding: 0 14px;
  border: 1px solid transparent;
  color: var(--muted);
}

.nav-button {
  min-height: 40px;
  padding: 0 14px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
}

.nav-button:hover,
.nav-button:focus-visible {
  border-color: var(--line);
  color: var(--paper);
  outline: 0;
}

.site-nav a:hover,
.site-nav a:focus-visible {
  border-color: var(--line);
  color: var(--paper);
  outline: 0;
}

.site-intro {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  min-height: calc(100vh - 76px);
  padding: 58px 0 28px;
  display: grid;
  align-content: center;
  gap: 18px;
}

.site-intro h1 {
  max-width: 900px;
  font-size: clamp(48px, 8vw, 108px);
}

.site-intro p:not(.eyebrow) {
  max-width: 680px;
  color: var(--soft);
  font-size: clamp(17px, 2vw, 22px);
  line-height: 1.45;
}

.intro-action {
  width: max-content;
  margin-top: 18px;
}

.tool-shell[hidden] {
  display: none;
}

.admin-view[hidden] {
  display: none;
}

.admin-view {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 42px 0 56px;
  display: grid;
  gap: 18px;
}

.admin-head {
  min-height: 132px;
  padding: 24px;
  border: 1px solid var(--line);
  background: #090909;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
}

.admin-head h2 {
  margin-top: 6px;
  font-size: clamp(38px, 6vw, 74px);
  font-weight: 500;
  line-height: .95;
}

.admin-events {
  display: grid;
  gap: 10px;
}

.admin-empty,
.admin-event {
  border: 1px solid var(--line);
  background: #070707;
}

.admin-empty {
  min-height: 120px;
  display: grid;
  place-items: center;
  color: var(--muted);
}

.admin-event {
  padding: 16px;
  display: grid;
  gap: 14px;
}

.admin-event-top {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 18px;
}

.admin-event-top strong,
.admin-event-top small {
  display: block;
}

.admin-event-top small {
  margin-top: 4px;
  color: var(--muted);
}

.admin-event-top span {
  padding: 6px 9px;
  border: 1px solid var(--line);
  color: var(--soft);
  font-size: 12px;
}

.admin-event.failed .admin-event-top span {
  border-color: #795151;
  color: #f1b8b8;
}

.admin-event dl {
  margin: 0;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1px;
  background: var(--line);
  border: 1px solid var(--line);
}

.admin-event dl div {
  min-width: 0;
  padding: 12px;
  background: #090909;
}

.admin-event dl .wide {
  grid-column: 1 / -1;
}

.admin-event dt {
  margin: 0 0 7px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .12em;
  text-transform: uppercase;
}

.admin-event dd {
  margin: 0;
  color: var(--soft);
  font-size: 13px;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.admin-event dd a {
  color: var(--paper);
  text-decoration: underline;
  text-underline-offset: 3px;
}

.shell {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0 56px;
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(360px, .85fr);
  grid-template-areas:
    "hero details"
    "metrics details"
    "settings settings";
  gap: 18px;
}

.hero,
.details,
.settings,
.metric {
  border: 1px solid var(--line);
  background: #090909;
}

.hero {
  grid-area: hero;
  min-height: 560px;
  padding: 30px;
  display: grid;
  align-content: space-between;
  gap: 32px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 16px;
}

.brand-mark {
  width: 42px;
  height: 42px;
  border: 2px solid var(--paper);
  display: inline-grid;
  place-items: center;
}

.brand-mark::before {
  content: "";
  width: 18px;
  height: 18px;
  border-left: 2px solid var(--paper);
  border-bottom: 2px solid var(--paper);
  transform: rotate(-45deg) translate(2px, -2px);
}

.eyebrow {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .18em;
  text-transform: uppercase;
}

h1,
.hero h2 {
  margin-top: 8px;
  font-size: clamp(42px, 7vw, 92px);
  font-weight: 600;
  line-height: .92;
  letter-spacing: 0;
}

.details h2 {
  margin-top: 6px;
  font-size: 24px;
  font-weight: 500;
}

.test-panel {
  display: grid;
  justify-items: start;
  gap: 22px;
}

.dial {
  position: relative;
  width: min(360px, 76vw);
  aspect-ratio: 1;
}

.dial svg {
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}

.dial-track,
.dial-progress {
  fill: none;
  stroke-width: 10;
}

.dial-track {
  stroke: #191916;
}

.dial-progress {
  stroke: var(--paper);
  stroke-linecap: square;
  stroke-dasharray: 653.45;
  stroke-dashoffset: 653.45;
  transition: stroke-dashoffset .22s linear;
}

.dial[data-state="running"] .dial-progress {
  filter: drop-shadow(0 0 18px rgba(247, 247, 242, .2));
}

.dial-content {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  text-align: center;
}

.dial-content span,
.dial-content small,
.metric span,
.metric small,
.summary-band span,
.history-meta {
  color: var(--muted);
}

.dial-content strong {
  margin-top: 8px;
  font-size: clamp(58px, 12vw, 108px);
  font-weight: 500;
  line-height: .9;
  font-variant-numeric: tabular-nums;
}

.dial-content small {
  margin-top: 6px;
  font-size: 15px;
}

.actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.run-button {
  min-width: 144px;
  border-color: var(--paper);
  border-radius: 5px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, .98), rgba(221, 221, 214, .94));
  color: var(--black);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  font-weight: 700;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, .76),
    0 16px 44px rgba(247, 247, 242, .08);
}

.run-dot {
  width: 8px;
  height: 8px;
  background: var(--black);
  display: inline-block;
}

.ghost-button {
  background: transparent;
}

.status {
  max-width: 520px;
  color: var(--soft);
  line-height: 1.55;
}

.metrics {
  grid-area: metrics;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 18px;
}

.metric {
  min-height: 128px;
  padding: 18px;
  display: grid;
  align-content: space-between;
}

.metric strong {
  margin-top: 12px;
  font-size: clamp(28px, 4vw, 48px);
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}

.details {
  grid-area: details;
  padding: 22px;
  display: grid;
  align-content: start;
  gap: 24px;
}

.summary-band {
  display: grid;
  grid-template-columns: 1fr 1fr;
  border: 1px solid var(--line);
}

.summary-band div {
  min-height: 96px;
  padding: 16px;
  display: grid;
  align-content: space-between;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.summary-band div:nth-child(2n) {
  border-right: 0;
}

.summary-band div:nth-last-child(-n + 2) {
  border-bottom: 0;
}

.summary-band strong {
  font-size: 22px;
  font-weight: 500;
}

.history-head,
.history-actions,
.history-list li,
.history-numbers,
.settings {
  display: flex;
  align-items: center;
}

.history-head {
  justify-content: space-between;
  gap: 16px;
}

.history-actions {
  gap: 8px;
}

.history-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 8px;
}

.history-list li {
  min-height: 76px;
  gap: 14px;
  padding: 12px;
  border: 1px solid var(--line);
  background: #070707;
}

.rank {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  border: 1px solid var(--paper);
  font-variant-numeric: tabular-nums;
}

.history-title {
  display: block;
  font-size: 15px;
  font-weight: 600;
}

.history-meta {
  display: block;
  margin-top: 5px;
  font-size: 12px;
}

.history-numbers {
  margin-left: auto;
  gap: 10px;
  color: var(--soft);
  font-size: 13px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.history-empty {
  min-height: 120px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  color: var(--muted);
}

.settings {
  grid-area: settings;
  justify-content: space-between;
  gap: 16px;
  padding: 18px;
}

label,
.duration-toggle legend {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .14em;
  text-transform: uppercase;
}

select {
  min-width: 220px;
  min-height: 44px;
  padding: 0 12px;
  border-radius: 0;
}

.toggle {
  display: flex;
  align-items: center;
  gap: 10px;
  text-transform: none;
  letter-spacing: 0;
  color: var(--soft);
}

.toggle input {
  width: 20px;
  height: 20px;
  accent-color: var(--paper);
}

.duration-toggle {
  margin: 0;
  padding: 0;
  border: 0;
  display: grid;
  gap: 8px;
}

.duration-toggle legend {
  margin: 0 0 8px;
  padding: 0;
}

.duration-toggle label {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 56px;
  min-height: 44px;
  border: 1px solid var(--line);
  color: var(--paper);
  background: var(--ink);
  letter-spacing: 0;
  text-transform: none;
}

.duration-toggle {
  grid-template-columns: repeat(4, minmax(48px, 1fr));
}

.duration-toggle legend {
  grid-column: 1 / -1;
}

.duration-toggle input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.duration-toggle label:has(input:checked) {
  background: var(--paper);
  color: var(--black);
  border-color: var(--paper);
}

.duration-toggle label:focus-within {
  outline: 2px solid var(--paper);
  outline-offset: 3px;
}

@media (max-width: 980px) {
  .shell {
    grid-template-columns: 1fr;
    grid-template-areas:
      "hero"
      "metrics"
      "details"
      "settings";
  }

  .hero {
    min-height: 520px;
  }

  .metrics {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 640px) {
  .site-header {
    width: min(100% - 20px, 1180px);
    align-items: flex-start;
    flex-direction: column;
    padding: 14px 0;
  }

  .auth-view {
    padding: 24px 10px;
    place-items: start;
  }

  .auth-panel {
    min-height: calc(100vh - 48px);
    grid-template-columns: 1fr;
    align-content: center;
    gap: 28px;
    padding-top: 72px;
  }

  .auth-brand {
    top: 18px;
    left: 10px;
  }

  .auth-card {
    padding: 16px;
  }

  .site-nav {
    width: 100%;
  }

  .site-nav a {
    flex: 1;
    justify-content: center;
    padding: 0 8px;
  }

  .site-intro {
    width: min(100% - 20px, 1180px);
    padding: 32px 0 12px;
  }

  .shell {
    width: min(100% - 20px, 1180px);
    padding: 10px 0;
    gap: 10px;
  }

  .hero,
  .details,
  .settings,
  .metric {
    padding: 16px;
  }

  .hero {
    min-height: auto;
  }

  .metrics,
  .summary-band {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .summary-band div,
  .summary-band div:nth-child(2n),
  .summary-band div:nth-last-child(-n + 2) {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .summary-band div:last-child {
    border-bottom: 0;
  }

  .settings {
    align-items: stretch;
    flex-direction: column;
  }

  select {
    width: 100%;
    min-width: 0;
  }

  .history-list li {
    align-items: flex-start;
  }

  .history-numbers {
    display: grid;
    gap: 4px;
  }

  .admin-view {
    width: min(100% - 20px, 1180px);
    padding: 10px 0;
  }

  .admin-head {
    align-items: stretch;
    flex-direction: column;
    padding: 16px;
  }

  .admin-event dl {
    grid-template-columns: 1fr;
  }
}
