:root {
  --bg: #0b0e13;
  --bg-elev-1: #11151c;
  --bg-elev-2: #161b24;
  --border: #232a36;
  --border-soft: #1a2029;
  --border-strong: #2e374a;

  --text: #e6edf3;
  --text-muted: #8b95a5;
  --text-dim: #5d6675;

  --accent: #7cc4ff;
  --accent-strong: #a5d6ff;
  --accent-dim: #2c4d6e;
  --accent-glow: rgba(124, 196, 255, 0.18);

  --success: #4dd693;
  --warning: #f3c969;
  --error: #ff7a7a;

  --sans: 'Geist', ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  --mono: 'Geist Mono', ui-monospace, 'SF Mono', Menlo, monospace;

  --radius: 10px;
  --radius-sm: 6px;
  --col: 44rem;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.55;
  font-feature-settings: 'kern', 'ss01';
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  min-height: 100vh;
  position: relative;
  overflow-x: hidden;
}

.bg-glow {
  position: fixed;
  pointer-events: none;
  inset: 0;
  z-index: 0;
  background:
    radial-gradient(ellipse 800px 500px at 50% -10%, rgba(124, 196, 255, 0.07), transparent 60%),
    radial-gradient(ellipse 500px 400px at 100% 100%, rgba(124, 196, 255, 0.04), transparent 60%);
}

main {
  position: relative;
  z-index: 1;
  max-width: var(--col);
  margin: 0 auto;
  padding: 7.5rem 1.5rem 6rem;
}

/* ========== Top bar ========== */

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  backdrop-filter: blur(12px) saturate(180%);
  -webkit-backdrop-filter: blur(12px) saturate(180%);
  background: rgba(11, 14, 19, 0.7);
  border-bottom: 1px solid transparent;
  transition: border-color 200ms ease;
}

.topbar.is-active {
  border-bottom-color: var(--border-soft);
}

.topbar-inner {
  max-width: var(--col);
  margin: 0 auto;
  padding: 0.85rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 2rem;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  font-weight: 500;
  letter-spacing: -0.01em;
}

.brand-mark {
  width: 14px;
  height: 14px;
  border-radius: 4px;
  background: linear-gradient(135deg, var(--accent), var(--accent-dim));
  box-shadow: 0 0 18px var(--accent-glow);
  flex-shrink: 0;
}

.brand-name {
  font-size: 0.92rem;
  color: var(--text);
}

.progress-cluster {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  flex: 1;
  max-width: 24rem;
  animation: fade-in 300ms ease;
}

.progress-track {
  flex: 1;
  height: 4px;
  background: var(--bg-elev-2);
  border-radius: 99px;
  overflow: hidden;
  position: relative;
}

.progress-bar {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--accent-dim), var(--accent));
  border-radius: 99px;
  transition: width 350ms cubic-bezier(0.22, 1, 0.36, 1);
  box-shadow: 0 0 12px var(--accent-glow);
}

.progress-label {
  font-family: var(--mono);
  font-size: 0.78rem;
  color: var(--text-muted);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

/* ========== Incompat banner ========== */

/* The [hidden] attribute must beat .incompat's display:flex specificity. */
.incompat[hidden] { display: none !important; }

.incompat {
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
  padding: 1.25rem 1.4rem 1.35rem;
  margin-bottom: 2.5rem;
  background: var(--bg-elev-1);
  border: 1px solid var(--border);
  border-left: 2px solid var(--warning);
  border-radius: var(--radius);
  color: var(--text);
  animation: rise 400ms cubic-bezier(0.22, 1, 0.36, 1);
}

.incompat-head {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  flex-wrap: wrap;
}

.incompat-tag {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-family: var(--mono);
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--warning);
  background: rgba(243, 201, 105, 0.07);
  border: 1px solid rgba(243, 201, 105, 0.25);
  border-radius: 99px;
  padding: 0.2rem 0.65rem 0.2rem 0.5rem;
}

.incompat-tag svg {
  width: 12px;
  height: 12px;
  flex-shrink: 0;
}

.incompat h3 {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 500;
  letter-spacing: -0.012em;
  color: var(--text);
  line-height: 1.3;
}

.incompat p {
  margin: 0;
  font-size: 0.88rem;
  line-height: 1.6;
  color: var(--text-muted);
  max-width: 36rem;
}

.incompat em {
  font-style: normal;
  color: var(--text);
  font-family: var(--mono);
  font-size: 0.85em;
  background: var(--bg-elev-2);
  border: 1px solid var(--border);
  padding: 0.05em 0.4em;
  border-radius: 4px;
}

.incompat-browsers {
  list-style: none;
  margin: 0.15rem 0 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.incompat-browsers li {
  font-family: var(--mono);
  font-size: 0.78rem;
  color: var(--text);
  background: var(--bg-elev-2);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm);
  padding: 0.25rem 0.6rem;
  transition: border-color 180ms ease, color 180ms ease;
}

.incompat-browsers li:hover {
  border-color: var(--accent-dim);
  color: var(--accent);
}

/* When banner is shown, dim the steps so it's clear they're inert */
body.is-incompat .steps,
body.is-incompat .hero {
  opacity: 0.4;
  pointer-events: none;
  filter: saturate(0.6);
  transition: opacity 250ms ease, filter 250ms ease;
}

/* ========== Hero ========== */

.hero {
  margin-bottom: 4rem;
  animation: rise 600ms cubic-bezier(0.22, 1, 0.36, 1) backwards;
}

.hero h1 {
  font-size: clamp(2rem, 4.5vw, 2.85rem);
  font-weight: 600;
  letter-spacing: -0.025em;
  line-height: 1.1;
  margin: 0 0 1.1rem;
  color: var(--text);
  background: linear-gradient(180deg, var(--text) 60%, var(--text-muted));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.tagline {
  font-size: 1rem;
  color: var(--text-muted);
  max-width: 32rem;
  margin: 0;
  line-height: 1.55;
}

/* ========== Steps ========== */

.steps {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  margin-bottom: 3rem;
}

.step {
  background: var(--bg-elev-1);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  padding: 1.5rem 1.6rem;
  transition: border-color 250ms ease, transform 250ms ease, opacity 350ms ease;
  animation: rise 500ms cubic-bezier(0.22, 1, 0.36, 1) backwards;
}

.step:nth-child(1) { animation-delay: 80ms; }
.step:nth-child(2) { animation-delay: 140ms; }
.step:nth-child(3) { animation-delay: 200ms; }
.step:nth-child(4) { animation-delay: 260ms; }

.step:hover { border-color: var(--border); }

.step-head {
  display: flex;
  gap: 1.1rem;
  margin-bottom: 1.1rem;
  align-items: flex-start;
}

.step-num {
  font-family: var(--mono);
  font-size: 0.78rem;
  color: var(--accent);
  background: rgba(124, 196, 255, 0.08);
  border: 1px solid var(--accent-dim);
  padding: 0.18rem 0.5rem;
  border-radius: var(--radius-sm);
  flex-shrink: 0;
  letter-spacing: 0.04em;
  transition: background 200ms ease, color 200ms ease;
}

.step.is-done .step-num {
  color: var(--success);
  background: rgba(77, 214, 147, 0.08);
  border-color: rgba(77, 214, 147, 0.3);
}

.step-head h2 {
  font-size: 1.05rem;
  font-weight: 500;
  margin: 0 0 0.2rem;
  letter-spacing: -0.01em;
}

.step-head p {
  font-size: 0.88rem;
  color: var(--text-muted);
  margin: 0;
  line-height: 1.5;
}

.step-head code {
  font-family: var(--mono);
  font-size: 0.8em;
  background: var(--bg-elev-2);
  border: 1px solid var(--border);
  padding: 0.05em 0.4em;
  border-radius: 4px;
  color: var(--text);
}

/* ========== Buttons ========== */

.btn {
  appearance: none;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.6rem 1.05rem;
  border-radius: var(--radius-sm);
  font-family: var(--sans);
  font-size: 0.92rem;
  font-weight: 500;
  letter-spacing: -0.005em;
  cursor: pointer;
  transition: background 180ms ease, color 180ms ease, border-color 180ms ease, transform 100ms ease, box-shadow 200ms ease;
}

.btn svg {
  width: 14px;
  height: 14px;
  transition: transform 200ms ease;
}

.btn:hover svg { transform: translateX(2px); }
.btn:active { transform: translateY(1px); }
.btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.btn-primary {
  background: var(--bg-elev-2);
  color: var(--text);
  border: 1px solid var(--border);
}
.btn-primary:hover {
  background: var(--bg-elev-1);
  border-color: var(--border-strong);
}

.btn-accent {
  background: var(--accent);
  color: #051018;
  border: 1px solid var(--accent);
  box-shadow: 0 0 0 1px transparent, 0 6px 20px -8px var(--accent-glow);
}
.btn-accent:hover {
  background: var(--accent-strong);
  border-color: var(--accent-strong);
  box-shadow: 0 0 0 4px var(--accent-glow);
}

.btn:disabled {
  opacity: 0.55;
  cursor: progress;
  pointer-events: none;
}

.btn.is-done {
  background: transparent;
  border: 1px dashed var(--border);
  color: var(--text-muted);
}
.btn.is-done svg { display: none; }

/* ========== Hint (folder tree tutorial) ========== */

.hint {
  margin-top: 1.1rem;
  padding: 1rem 1.15rem 1.1rem;
  background: var(--bg);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm);
  animation: fade-in 350ms ease;
}

.hint-text {
  margin: 0 0 0.85rem;
  font-size: 0.85rem;
  line-height: 1.55;
  color: var(--text-muted);
}

.hint-text em {
  font-style: italic;
  color: var(--text);
}

.hint-text code {
  font-family: var(--mono);
  font-size: 0.85em;
  background: var(--bg-elev-2);
  border: 1px solid var(--border);
  padding: 0.05em 0.4em;
  border-radius: 4px;
  color: var(--text);
}

.hint-tree {
  font-family: var(--mono);
  font-size: 0.8rem;
  line-height: 1.65;
  color: var(--text-muted);
  background: transparent;
  margin: 0;
  padding: 0.65rem 0.85rem;
  border-left: 2px solid var(--border);
  white-space: pre;
  overflow-x: auto;
}

.hint-tree .hint-pick {
  color: var(--accent);
  background: rgba(124, 196, 255, 0.06);
  padding: 0.05em 0.4em;
  border-radius: 4px;
  border: 1px solid var(--accent-dim);
}

.hint-tree .hint-arrow {
  color: var(--accent);
  font-style: normal;
  margin-left: 0.4rem;
  opacity: 0.85;
}

.hint-tree .hint-rule {
  color: var(--text-dim);
}

.hint-tree .hint-folder {
  color: var(--text);
}

.hint-tree .hint-slash {
  color: var(--text-dim);
}

.hint-tree .hint-leaf {
  color: var(--text-muted);
  opacity: 0.8;
}

/* When source is picked, fade the hint away */
.step.is-done .hint { display: none; }

/* ========== Manifest ========== */

.manifest {
  margin-top: 1.5rem;
  border-top: 1px solid var(--border-soft);
  padding-top: 1.25rem;
  animation: fade-in 300ms ease;
}

.manifest-summary {
  font-family: var(--mono);
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-bottom: 0.85rem;
  font-variant-numeric: tabular-nums;
}

.manifest-list {
  list-style: none;
  margin: 0;
  padding: 0;
  font-family: var(--mono);
  font-size: 0.78rem;
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  max-height: 14rem;
  overflow-y: auto;
  padding-right: 0.4rem;
}

.manifest-list::-webkit-scrollbar { width: 6px; }
.manifest-list::-webkit-scrollbar-track { background: transparent; }
.manifest-list::-webkit-scrollbar-thumb { background: var(--border); border-radius: 99px; }

.manifest-list li {
  display: grid;
  grid-template-columns: 2.2rem 1fr auto auto;
  gap: 0.85rem;
  padding: 0.3rem 0.4rem;
  align-items: baseline;
  border-radius: 4px;
  color: var(--text);
}

.manifest-list li::before {
  content: counter(catalog, decimal-leading-zero);
  counter-increment: catalog;
  color: var(--text-dim);
}
.manifest-list { counter-reset: catalog; }

.manifest-list .m-name {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.manifest-list .m-kind {
  color: var(--accent);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  opacity: 0.7;
}
.manifest-list .m-size {
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

/* ========== Status text ========== */

.warning {
  margin-top: 1rem;
  padding: 0.75rem 0.9rem;
  background: rgba(255, 122, 122, 0.05);
  border: 1px solid rgba(255, 122, 122, 0.18);
  border-radius: var(--radius-sm);
  color: var(--error);
  font-size: 0.88rem;
  line-height: 1.5;
}

.muted {
  margin-top: 0.85rem;
  font-size: 0.85rem;
  color: var(--text-muted);
}
.muted code {
  font-family: var(--mono);
  font-size: 0.85em;
  background: var(--bg-elev-2);
  border: 1px solid var(--border);
  padding: 0.05em 0.35em;
  border-radius: 4px;
  color: var(--text);
}

/* ========== Ledger ========== */

.ledger {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.ledger-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.6rem 1rem;
  padding: 0.85rem 1rem;
  background: var(--bg-elev-2);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm);
  font-size: 0.88rem;
  align-items: center;
  position: relative;
  overflow: hidden;
  transition: border-color 220ms ease, background 220ms ease;
}

.ledger-row .l-name {
  font-family: var(--mono);
  font-size: 0.82rem;
  color: var(--text);
  word-break: break-all;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ledger-row .l-state {
  font-size: 0.75rem;
  font-weight: 500;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-dim);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.ledger-row .l-notes {
  grid-column: 1 / -1;
  font-family: var(--mono);
  font-size: 0.74rem;
  color: var(--text-muted);
  margin: 0;
}

.ledger-row .l-detail {
  grid-column: 1 / -1;
  font-family: var(--mono);
  font-size: 0.72rem;
  color: var(--text-dim);
  white-space: pre-wrap;
  max-height: 5em;
  overflow-y: auto;
  margin: 0;
  padding-left: 0.6rem;
  border-left: 1px solid var(--border);
}

.ledger-row .row-bar {
  position: absolute;
  bottom: 0;
  left: 0;
  height: 2px;
  background: var(--accent);
  width: 0%;
  transition: width 250ms ease;
  box-shadow: 0 0 8px var(--accent-glow);
  opacity: 0;
}

.ledger-row.is-running {
  border-color: var(--accent-dim);
}
.ledger-row.is-running .row-bar { opacity: 1; }
.ledger-row.is-running .l-state { color: var(--accent); }

.ledger-row.is-done {
  border-color: rgba(77, 214, 147, 0.18);
}
.ledger-row.is-done .l-state { color: var(--success); }
.ledger-row.is-done .row-bar { background: var(--success); opacity: 0.3; width: 100% !important; }

.ledger-row.is-failed {
  border-color: rgba(255, 122, 122, 0.25);
}
.ledger-row.is-failed .l-state { color: var(--error); }
.ledger-row.is-failed .row-bar { background: var(--error); opacity: 0.3; width: 100% !important; }

/* ========== Finish state ========== */

.finish {
  margin-top: 3rem;
  animation: rise 500ms cubic-bezier(0.22, 1, 0.36, 1);
}

.finish-card {
  background: linear-gradient(180deg, var(--bg-elev-1), var(--bg-elev-2));
  border: 1px solid rgba(77, 214, 147, 0.25);
  border-radius: var(--radius);
  padding: 2rem 2rem 1.75rem;
  display: flex;
  gap: 1.4rem;
  align-items: flex-start;
  position: relative;
  overflow: hidden;
}

.finish-card.is-partial {
  border-color: rgba(243, 201, 105, 0.3);
}

.finish-card::before {
  content: '';
  position: absolute;
  inset: -1px;
  border-radius: inherit;
  padding: 1px;
  background: linear-gradient(135deg, rgba(77, 214, 147, 0.5), transparent 60%);
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  pointer-events: none;
}

.finish-card.is-partial::before {
  background: linear-gradient(135deg, rgba(243, 201, 105, 0.5), transparent 60%);
}

.finish-check {
  width: 52px;
  height: 52px;
  color: var(--success);
  flex-shrink: 0;
  filter: drop-shadow(0 0 12px rgba(77, 214, 147, 0.35));
}
.finish-card.is-partial .finish-check { color: var(--warning); filter: drop-shadow(0 0 12px rgba(243, 201, 105, 0.35)); }

.finish-circle {
  stroke-dasharray: 151;
  stroke-dashoffset: 151;
  animation: draw-circle 500ms cubic-bezier(0.22, 1, 0.36, 1) 100ms forwards;
}

.finish-tick {
  stroke-dasharray: 50;
  stroke-dashoffset: 50;
  animation: draw-tick 350ms cubic-bezier(0.22, 1, 0.36, 1) 500ms forwards;
}

.finish-text { flex: 1; }

.finish-text h3 {
  font-size: 1.3rem;
  font-weight: 600;
  letter-spacing: -0.015em;
  margin: 0 0 0.2rem;
}

.finish-text p {
  color: var(--text-muted);
  margin: 0 0 1.1rem;
  font-size: 0.95rem;
}

.finish-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.65rem;
  margin: 0;
}

.finish-stats div {
  background: var(--bg);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm);
  padding: 0.65rem 0.85rem;
}

.finish-stats dt {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-dim);
  margin: 0 0 0.1rem;
}

.finish-stats dd {
  margin: 0;
  font-family: var(--mono);
  font-size: 1.05rem;
  font-weight: 500;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

.finish-errors {
  margin-top: 1rem;
  font-size: 0.82rem;
  color: var(--text-muted);
}
.finish-errors summary {
  cursor: pointer;
  color: var(--error);
  user-select: none;
}
.finish-errors summary:hover { text-decoration: underline; }
.finish-errors pre {
  font-family: var(--mono);
  font-size: 0.72rem;
  color: var(--text-muted);
  background: var(--bg);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm);
  padding: 0.65rem 0.85rem;
  overflow-x: auto;
  margin-top: 0.5rem;
  max-height: 20em;
  overflow-y: auto;
  white-space: pre-wrap;
  word-break: break-all;
}

/* ========== Footer ========== */

.footer {
  margin-top: 4rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border-soft);
  font-size: 0.78rem;
  color: var(--text-dim);
  text-align: center;
  line-height: 1.6;
}

.footer a {
  color: var(--text-muted);
  text-decoration: none;
  border-bottom: 1px dotted var(--text-dim);
}
.footer a:hover { color: var(--accent); border-bottom-color: var(--accent); }

/* ========== Animations ========== */

@keyframes rise {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes fade-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}
@keyframes draw-circle {
  to { stroke-dashoffset: 0; }
}
@keyframes draw-tick {
  to { stroke-dashoffset: 0; }
}

/* ========== Responsive ========== */

@media (max-width: 600px) {
  main { padding: 6rem 1rem 4rem; }
  .topbar-inner { padding: 0.75rem 1rem; gap: 0.85rem; }
  .progress-cluster { max-width: 14rem; }
  .step { padding: 1.2rem 1.1rem; }
  .step-head { gap: 0.85rem; }
  .finish-card { flex-direction: column; padding: 1.5rem 1.25rem; }
  .finish-stats { grid-template-columns: 1fr; }
  .ledger-row { grid-template-columns: 1fr; }
  .ledger-row .l-state { justify-self: start; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}
