:root {
  --base: #f6f0e8;
  --glow-a: rgba(198, 126, 74, 0.42);
  --glow-b: rgba(78, 121, 167, 0.28);
  --glow-c: rgba(192, 150, 96, 0.26);
  --glow-d: rgba(120, 78, 54, 0.20);
  --text: #231b17;
  --muted: #6f5d53;
  --line: #d8c8bb;
  --accent: #b85c2d;
  --ink: #fff7ef;
  --ok: #2f7a57;
  --warn: #a95d34;
  --idle: #aa998d;
  --panel: rgba(255, 247, 239, 0.84);
  --mono: "IBM Plex Mono", monospace;
  --sans: "Space Grotesk", sans-serif;
  --viewport-inset: 14px;
  --top-control-size: 34px;
}

:root[data-theme="light"] {
  --base: #f6f0e8;
  --glow-a: rgba(198, 126, 74, 0.42);
  --glow-b: rgba(78, 121, 167, 0.28);
  --glow-c: rgba(192, 150, 96, 0.26);
  --glow-d: rgba(120, 78, 54, 0.20);
  --text: #231b17;
  --muted: #6f5d53;
  --line: #d8c8bb;
  --accent: #b85c2d;
  --ink: #fff7ef;
  --ok: #2f7a57;
  --warn: #a95d34;
  --idle: #aa998d;
  --panel: rgba(255, 247, 239, 0.84);
}

:root[data-theme="dark"] {
  --base: #150f0c;
  --glow-a: rgba(153, 84, 40, 0.54);
  --glow-b: rgba(39, 69, 99, 0.44);
  --glow-c: rgba(120, 80, 40, 0.34);
  --glow-d: rgba(88, 48, 29, 0.32);
  --text: #f3e5d8;
  --muted: #bba18f;
  --line: #49372d;
  --accent: #ff8f52;
  --ink: #1b120e;
  --ok: #7fd4aa;
  --warn: #ffb088;
  --idle: #8c776a;
  --panel: rgba(28, 20, 16, 0.82);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  background: linear-gradient(
    132deg,
    color-mix(in srgb, var(--base) 92%, var(--glow-a) 8%),
    color-mix(in srgb, var(--base) 94%, var(--glow-b) 6%),
    color-mix(in srgb, var(--base) 93%, var(--glow-c) 7%),
    color-mix(in srgb, var(--base) 94%, var(--glow-d) 6%),
    color-mix(in srgb, var(--base) 92%, var(--glow-a) 8%)
  );
  background-size: 320% 320%;
  animation: baseDrift 14s ease-in-out infinite alternate;
  color: var(--text);
  font-family: var(--sans);
  min-height: 100vh;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 20vh 24px 170px;
  position: relative;
  overflow-x: hidden;
  isolation: isolate;
}

/* Soft atmospheric blob field — blurred so all edges dissolve */
body::before {
  content: "";
  position: fixed;
  inset: -25%;
  pointer-events: none;
  background:
    radial-gradient(ellipse 68% 54% at 14% 28%,  var(--glow-a), transparent 64%),
    radial-gradient(ellipse 60% 72% at 88% 72%,  var(--glow-b), transparent 64%),
    radial-gradient(ellipse 78% 48% at 72% 12%,  var(--glow-c), transparent 68%),
    radial-gradient(ellipse 52% 68% at 38% 88%,  var(--glow-d), transparent 64%);
  filter: blur(52px);
  animation: blobDrift 18s ease-in-out infinite alternate;
  z-index: -1;
}

@keyframes blobDrift {
  0%   { transform: translate3d(0%,    0%,   0) scale(1.00); }
  25%  { transform: translate3d(4.2%, -2.6%, 0) scale(1.04); }
  55%  { transform: translate3d(-3.2%, 4.6%, 0) scale(0.98); }
  80%  { transform: translate3d(5.2%,  2.1%, 0) scale(1.05); }
  100% { transform: translate3d(-2.1%, 5.1%, 0) scale(1.02); }
}

@keyframes baseDrift {
  0% { background-position: 0% 16%; }
  50% { background-position: 62% 88%; }
  100% { background-position: 100% 24%; }
}

.layout-shell {
  width: 100%;
}

.page {
  width: 100%;
  max-width: 760px;
  margin-left: auto;
  margin-right: auto;
  display: flex;
  flex-direction: column;
  gap: 28px;
}

.hero {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding-right: 52px;
}

.hero-title {
  max-width: none;
  font-size: clamp(1.9rem, 3.9vw, 2.65rem);
  line-height: 1;
  letter-spacing: -0.04em;
  font-weight: 700;
  white-space: nowrap;
}

.hero-copy {
  max-width: 34rem;
  font-size: clamp(1rem, 2vw, 1.18rem);
  line-height: 1.45;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.ecp-enabled-chip {
  display: inline-block;
  width: min(100%, 74px);
  max-width: 74px;
  height: auto;
  flex: 0 0 auto;
}

main {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.input-row {
  display: flex;
  gap: 8px;
}

.form-feedback {
  margin-top: 8px;
  min-height: 18px;
  font-size: 12px;
  line-height: 1.45;
  color: var(--muted);
}

.helper-copy {
  font-size: 12px;
  line-height: 1.5;
  color: var(--muted);
  max-width: 34rem;
}

.form-feedback.error {
  color: var(--warn);
}

.form-feedback.success {
  color: var(--ok);
}

input[type="url"] {
  flex: 1;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel);
  padding: 10px 12px;
  font: inherit;
  font-size: 14px;
  color: var(--text);
}

input[type="url"]:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 16%, transparent);
}

input[type="url"].invalid {
  border-color: var(--warn);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--warn) 16%, transparent);
}

input[type="url"].submitted {
  border-color: color-mix(in srgb, var(--ok) 44%, var(--line) 56%);
  background: color-mix(in srgb, var(--ok) 10%, var(--panel) 90%);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--ok) 14%, transparent);
}

input[type="url"].shake {
  animation: inputShake 0.32s ease;
}

@keyframes inputShake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-4px); }
  40% { transform: translateX(4px); }
  60% { transform: translateX(-3px); }
  80% { transform: translateX(3px); }
}

button {
  border: none;
  border-radius: 6px;
  padding: 10px 14px;
  font: inherit;
  font-size: 13px;
  cursor: pointer;
  background: var(--accent);
  color: var(--ink);
  white-space: nowrap;
  transition: transform 0.12s ease, filter 0.12s ease, opacity 0.12s ease;
}

button:hover { filter: brightness(0.96); }

button:active {
  transform: translateY(1px) scale(0.985);
}

button:disabled {
  opacity: 0.62;
  cursor: wait;
  filter: none;
}

#preflightButton {
  min-width: 110px;
}

#preflightButton.loading {
  transform: translateY(1px);
}

button.secondary {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--line);
}

.github-chip {
  position: fixed;
  top: 14px;
  left: 14px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 9px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel);
  color: var(--muted);
  font: 500 11px/1 var(--mono);
  text-decoration: none;
  backdrop-filter: blur(4px);
  z-index: 30;
  transition: color 0.15s, border-color 0.15s;
}

.github-chip:hover {
  color: var(--text);
  border-color: var(--accent);
}

.github-chip svg {
  width: 14px;
  height: 14px;
  fill: currentColor;
  flex-shrink: 0;
  display: block;
}

.command-chip {
  position: fixed;
  top: 49px;
  left: 14px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 9px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel);
  color: color-mix(in srgb, var(--text) 82%, var(--muted) 18%);
  font: 500 11px/1 var(--mono);
  letter-spacing: 0.01em;
  cursor: pointer;
  backdrop-filter: blur(4px);
  z-index: 30;
  transition: color 0.15s, border-color 0.15s;
}

.command-chip::before {
  content: "";
  width: 14px;
  height: 14px;
  background: url('./favicon-32.png') center/cover no-repeat;
  flex-shrink: 0;
  display: block;
}

.command-chip:hover {
  color: var(--text);
  border-color: var(--accent);
}

.command-chip:focus-visible {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 18%, transparent);
}

.theme-fab {
  position: fixed;
  top: var(--viewport-inset);
  right: var(--viewport-inset);
  width: var(--top-control-size);
  height: var(--top-control-size);
  border-radius: 50%;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--muted);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  z-index: 30;
}

.theme-fab svg {
  width: 16px;
  height: 16px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.8;
}

.checks {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px 0 0;
  border-top: 1px solid var(--line);
  transition: opacity 0.18s ease, transform 0.18s ease;
}

.check {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  color: var(--muted);
  padding: 7px 9px;
  border: 1px solid transparent;
  border-radius: 6px;
  transition: color 0.18s ease, border-color 0.18s ease, background 0.18s ease, transform 0.18s ease;
}

.check.active {
  color: var(--text);
  border-color: color-mix(in srgb, var(--line) 82%, var(--accent) 18%);
  background: color-mix(in srgb, var(--panel) 82%, transparent);
  transform: translateX(2px);
}

.check.pass {
  color: var(--text);
  border-color: color-mix(in srgb, var(--ok) 38%, var(--line) 62%);
  background: color-mix(in srgb, var(--ok) 10%, transparent);
}

.check.fail {
  color: var(--text);
  border-color: color-mix(in srgb, var(--warn) 42%, var(--line) 58%);
  background: color-mix(in srgb, var(--warn) 10%, transparent);
}

.indicator {
  position: relative;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

.indicator.idle { background: var(--idle); opacity: 0.75; }
.indicator.ok { background: var(--ok); }
.indicator.warn {
  background: transparent;
}

.indicator.warn::before,
.indicator.warn::after {
  content: "";
  position: absolute;
  top: 4px;
  left: -1px;
  width: 12px;
  height: 1.5px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--warn) 88%, white 12%);
  opacity: 0.92;
}

.indicator.warn::before {
  transform: rotate(45deg);
}

.indicator.warn::after {
  transform: rotate(-45deg);
}

.indicator.spin { background: var(--idle); animation: pulse 1s infinite; }

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

.hidden { display: none; }

@media (max-width: 760px) {
  body {
    padding: 108px 14px 40px;
  }

  .layout-shell {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 12px;
  }

  .page {
    max-width: none;
  }

  header {
    padding-right: 0;
  }

  .hero {
    gap: 10px;
  }

  .hero-title {
    font-size: clamp(1.35rem, 5.6vw, 1.85rem);
    white-space: nowrap;
  }

  .hero-copy,
  .helper-copy {
    max-width: none;
  }

  .input-row {
    flex-direction: column;
  }

  input[type="url"],
  #preflightButton {
    width: 100%;
  }

  .check {
    align-items: flex-start;
  }

  .github-chip {
    top: 12px;
    left: 12px;
    max-width: calc(100vw - 132px);
    overflow: hidden;
  }

  .github-chip span {
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .command-chip {
    top: 50px;
    left: 12px;
    max-width: calc(100vw - 24px);
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .theme-fab {
    top: 12px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .indicator.spin { animation: none; }
}
