:root {
  color-scheme: light;
  --bg: #f8f8f2;
  --ink: #333333;
  --muted: #767676;
  --line: #d9d9d9;
  --panel: #ffffff;
  --soft: #ddf0ef;
  --brand: #4b3040;
  --brand-alt: #86647a;
  --accent: #4a9291;
  --accent-dark: #39706f;
  --focus: rgba(74, 146, 145, 0.24);
  --shadow: 10px 10px 24px rgba(35, 29, 39, 0.08);
}

:root {
  --bg: var(--theme-background, #f8f8f2);
  --ink: var(--theme-text, #333333);
  --brand: var(--theme-primary, #4b3040);
  --brand-alt: var(--theme-secondary, #86647a);
  --accent: var(--theme-accent, #4a9291);
  --logo: var(--theme-logo-image, none);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background: var(--bg);
  font-family: var(--theme-font-body, "Open Sans"), ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.centered {
  min-height: 100vh;
  display: grid;
  place-items: center;
  position: relative;
  padding: 96px 24px 32px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.94) 0%, rgba(248, 248, 242, 0.98) 100%),
    var(--bg);
}

.centered::before {
  content: "";
  display: block;
  position: absolute;
  top: 34px;
  left: 50%;
  width: min(220px, 58vw);
  height: 64px;
  transform: translateX(-50%);
  background: var(--logo) center / contain no-repeat;
  pointer-events: none;
}

.panel,
.sign-panel,
.speedtest-stage {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--theme-panel-radius, 0);
  box-shadow: var(--theme-panel-shadow, var(--shadow));
}

.panel {
  width: min(100%, 440px);
  min-height: auto;
  display: grid;
  align-content: center;
  padding: clamp(28px, 7vw, 46px);
}

.brand-mark {
  display: block;
  width: min(210px, 52vw);
  height: 60px;
  margin: 0 0 34px;
  overflow: hidden;
  color: transparent;
  background: var(--logo) left center / contain no-repeat;
}

.brand-mark::before {
  content: none;
}

.eyebrow {
  margin: 0 0 10px;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 400;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  max-width: 12ch;
  font-size: clamp(2.15rem, 5vw, 4rem);
  line-height: 0.94;
  font-weight: 700;
  color: var(--brand);
}

h2 {
  font-size: 1.25rem;
  line-height: 1.12;
  font-weight: 700;
  color: var(--brand);
}

.muted {
  max-width: 58ch;
  color: var(--muted);
  line-height: 1.55;
}

.stack {
  display: grid;
  gap: 12px;
  margin-top: 26px;
}

label {
  font-size: 0.86rem;
  font-weight: 700;
  color: var(--brand);
}

input {
  width: 100%;
  min-height: 48px;
  border: 1px solid var(--line);
  border-radius: 0;
  padding: 0 13px;
  color: var(--ink);
  font: inherit;
  background: #ffffff;
}

input:focus {
  outline: 3px solid var(--focus);
  border-color: var(--brand);
}

button,
.button-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 46px;
  border: 1px solid var(--accent);
  border-radius: var(--theme-button-radius, 999px);
  padding: 0 24px;
  color: #ffffff;
  background: var(--accent);
  font: inherit;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
  transition: background-color 180ms ease, border-color 180ms ease, color 180ms ease;
}

button:hover,
.button-link:hover {
  color: #ffffff;
  background: var(--accent-dark);
  border-color: var(--accent-dark);
}

.secondary {
  color: var(--brand);
  background: transparent;
  border-color: var(--brand);
}

.secondary:hover {
  color: #ffffff;
  background: var(--brand);
  border-color: var(--brand);
}

.topbar,
.speedtest-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 20px clamp(18px, 4vw, 48px);
  color: var(--ink);
  background:
    var(--logo) clamp(18px, 4vw, 48px) center / 180px auto no-repeat,
    #ffffff;
  border-bottom: 1px solid var(--line);
  box-shadow: 10px 10px 10px rgba(35, 29, 39, 0.06);
}

.topbar > div,
.speedtest-topbar > div {
  padding-left: 210px;
}

.topbar h1,
.speedtest-topbar h1 {
  font-size: clamp(1.55rem, 3.5vw, 2.7rem);
  color: var(--brand);
}

.topbar .eyebrow,
.speedtest-topbar .eyebrow {
  color: var(--brand-alt);
}

.topbar .secondary,
.speedtest-topbar .secondary {
  color: var(--brand);
  background: transparent;
  border-color: var(--brand);
}

.topbar .secondary:hover,
.speedtest-topbar .secondary:hover {
  color: #ffffff;
  background: var(--brand);
  border-color: var(--brand);
}

.review-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 16px;
  height: calc(100vh - 94px);
  padding: 16px;
}

.viewer {
  min-height: 420px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 0;
  background: #231d27;
}

iframe {
  width: 100%;
  height: 100%;
  border: 0;
}

.sign-panel {
  align-self: start;
  padding: 22px;
}

.sign-panel h2 {
  font-size: 1.6rem;
}

canvas {
  width: 100%;
  height: 150px;
  display: block;
  border: 1px solid var(--line);
  border-radius: 0;
  background: #ffffff;
  touch-action: none;
}

.speedtest-body {
  background: var(--bg);
}

.speedtest-layout {
  min-height: calc(100vh - 96px);
  display: grid;
  place-items: center;
  padding: clamp(18px, 4vw, 42px);
}

.speedtest-stage {
  width: min(100%, 920px);
  padding: clamp(24px, 5vw, 48px);
  overflow: hidden;
}

.speedtest-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 30px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--line);
}

.speedtest-head h2 {
  max-width: 590px;
  font-size: clamp(2rem, 5.6vw, 4.8rem);
  line-height: 0.92;
  font-weight: 700;
}

.phase {
  flex: 0 0 auto;
  min-width: 112px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--brand);
  background: var(--soft);
  font-size: 0.8rem;
  font-weight: 700;
  text-align: center;
}

.speed-readout {
  display: grid;
  grid-template-columns: minmax(210px, 290px) minmax(0, 1fr);
  align-items: center;
  gap: clamp(22px, 5vw, 50px);
  margin-bottom: 30px;
}

.speed-ring {
  --ring-fill: 0%;
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background:
    conic-gradient(from -90deg, var(--accent), var(--accent) var(--ring-fill), var(--soft) var(--ring-fill)),
    var(--soft);
  transition: background 160ms ease;
}

.speed-ring-core {
  width: 74%;
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  align-content: center;
  border-radius: 50%;
  background: var(--panel);
  border: 1px solid var(--line);
}

.speed-ring-core span {
  color: var(--brand);
  font-size: clamp(2.5rem, 7vw, 4.6rem);
  font-weight: 700;
  line-height: 0.9;
}

.speed-ring-core small,
.speed-summary p {
  color: var(--muted);
  font-weight: 700;
}

.speed-summary strong {
  display: block;
  margin-top: 4px;
  font-size: clamp(2.25rem, 5.8vw, 4.8rem);
  line-height: 0.92;
  font-weight: 700;
  color: var(--brand);
}

.progress-wrap {
  margin: 0 0 26px;
}

.progress-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 10px;
  color: var(--muted);
  font-weight: 700;
}

.progress-shell {
  width: 100%;
  height: 16px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--soft);
}

.progress-bar {
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: var(--accent);
  transition: width 160ms ease;
}

.metric-strip {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  border-block: 1px solid var(--line);
  margin: 0 0 22px;
}

.metric {
  min-height: 100px;
  display: grid;
  align-content: center;
  gap: 8px;
  padding: 18px 0;
}

.metric + .metric {
  padding-left: 22px;
  border-left: 1px solid var(--line);
}

.metric > span {
  color: var(--muted);
  font-weight: 700;
}

.metric strong {
  color: var(--brand);
  font-size: clamp(1.3rem, 3vw, 1.9rem);
  line-height: 1;
}

.actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 12px;
}

.speedtest-actions {
  margin: 0 0 14px;
}

.speedtest-actions button,
#speedtest-download {
  min-height: 52px;
  font-size: 1rem;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.status {
  min-height: 24px;
  color: var(--muted);
}

.hidden {
  display: none;
}

@media (max-width: 860px) {
  .centered {
    padding-top: 88px;
  }

  .centered::before {
    top: 28px;
    height: 38px;
    background-size: contain;
  }

  .panel {
    min-height: auto;
  }

  .topbar,
  .speedtest-topbar {
    align-items: flex-start;
    background-position: 18px 22px;
    background-size: 140px auto;
    padding-top: 76px;
  }

  .topbar > div,
  .speedtest-topbar > div {
    padding-left: 0;
  }

  .review-layout {
    grid-template-columns: 1fr;
    height: auto;
  }

  .viewer {
    height: 68vh;
  }

  .speedtest-head,
  .speed-readout {
    display: grid;
  }

  .phase {
    justify-self: start;
  }

  .speed-ring {
    width: min(100%, 250px);
  }

  .metric-strip {
    grid-template-columns: 1fr;
  }

  .metric + .metric {
    padding-left: 0;
    border-left: 0;
    border-top: 1px solid var(--line);
  }
}
