:root {
  --bg: #07080f;
  --surface: #10121c;
  --line: #2a3148;
  --text: #d8e0ea;
  --muted: #8a96a8;
  --faint: #6b7588;
  --accent: #7ea8ff;
  --accent-dim: rgba(126, 168, 255, 0.16);
  --ok: #86efac;
  --warn: #f5c56b;
  --lock: #f0906b;
  --font: "IBM Plex Mono", ui-monospace, "Courier New", monospace;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100dvh;
}

body {
  display: flex;
  flex-direction: column;
  font-family: var(--font);
  font-size: 0.875rem;
  line-height: 1.45;
  color: var(--text);
  background: var(--bg);
  position: relative;
}

a {
  color: var(--accent);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

button,
code {
  font-family: inherit;
}

.glow {
  position: fixed;
  border-radius: 50%;
  filter: blur(88px);
  pointer-events: none;
  z-index: 0;
  opacity: 0.5;
}

.glow--a {
  width: min(32rem, 80vw);
  height: min(32rem, 80vw);
  top: -8rem;
  left: -6rem;
  background: radial-gradient(circle, rgba(58, 95, 200, 0.28) 0%, transparent 68%);
}

.glow--b {
  width: min(26rem, 70vw);
  height: min(26rem, 70vw);
  right: -5rem;
  bottom: 12%;
  background: radial-gradient(circle, rgba(126, 168, 255, 0.14) 0%, transparent 70%);
}

.top,
main,
.foot {
  position: relative;
  z-index: 1;
}

.top {
  display: flex;
  justify-content: center;
  align-items: center;
  position: relative;
  border-bottom: 1px solid var(--line);
  padding: 0.75rem 6.75rem;
}

.auth-home {
  position: absolute;
  left: 1.25rem;
  top: 50%;
  transform: translateY(-50%);
  display: inline-flex;
  align-items: center;
  gap: 0.65rem;
  color: var(--text);
  font-size: 0.9rem;
  font-weight: 500;
  letter-spacing: 0.02em;
  text-decoration: none;
  white-space: nowrap;
}

.auth-home:hover {
  text-decoration: none;
}

.top nav {
  position: absolute;
  right: 1.25rem;
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  align-items: center;
  gap: 0.65rem;
}

.top nav a {
  color: var(--muted);
  font-size: 0.8125rem;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.65rem;
  color: var(--text);
  font-size: 0.9rem;
  font-weight: 500;
  letter-spacing: 0.02em;
  text-decoration: none;
}

.brand:hover,
.brand strong {
  text-decoration: none;
  font-weight: 500;
}

.mark {
  width: 1.55rem;
  height: 1.55rem;
  border-radius: 0.4rem;
  display: grid;
  place-items: center;
  font-size: 0.52rem;
  font-weight: 800;
  letter-spacing: -0.04em;
  color: #fff;
  background: linear-gradient(135deg, #3a5fc8 0%, #243a7a 100%);
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.08);
}

.mark--auth {
  background: linear-gradient(135deg, #3b82f6 0%, #8b5cf6 55%, #10b981 100%);
  font-size: 0.72rem;
}

.ghost {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 0.4rem;
  padding: 0.28rem 0.6rem;
  cursor: pointer;
}

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

.ghost:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.ghost:disabled:hover {
  color: var(--muted);
  border-color: var(--line);
}

.ghost--go {
  color: var(--text);
  border-color: var(--accent);
}

.session-chip {
  font-size: 0.72rem;
  color: var(--ok);
  border: 1px solid rgba(134, 239, 172, 0.35);
  border-radius: 999px;
  padding: 0.18rem 0.55rem;
}

main {
  flex: 1;
  padding: 1.1rem 1.1rem 2rem;
  min-width: 0;
}

.lead {
  margin: 0 0 0.45rem;
  max-width: 52rem;
}

.how {
  margin: 0 0 1.1rem;
  max-width: 46rem;
}

.how h1 {
  margin: 0 0 0.55rem;
  font-size: 1rem;
  font-weight: 600;
}

.how ol {
  margin: 0;
  padding-left: 1.2rem;
  color: var(--muted);
  display: grid;
  gap: 0.35rem;
}

.how li {
  padding-left: 0.2rem;
}

.how strong {
  color: var(--text);
  font-weight: 500;
}

.how-tip {
  margin: 0.7rem 0 0;
  color: var(--faint);
  font-size: 0.78rem;
}

.rail-wrap {
  padding: 0.35rem 0.55rem 1.1rem;
  overflow: visible;
}

.rail {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1.55rem 1.45rem;
  overflow: visible;
}

.stage {
  position: relative;
  min-width: 0;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 0.7rem;
  padding: 0.7rem 0.75rem 0.55rem;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 0.28rem;
  min-height: 8.6rem;
  overflow: visible;
}

.stage:hover,
.stage:focus-visible {
  border-color: var(--accent);
  outline: none;
}

.stage-arrow {
  position: absolute;
  z-index: 3;
  pointer-events: none;
  width: 1.4rem;
  height: 1.4rem;
  color: #7af6ff;
  filter: drop-shadow(0 0 4px #3de7ff) drop-shadow(0 0 12px rgba(61, 231, 255, 0.7));
  animation: flow-arrow 2.4s ease-in-out infinite;
}

.stage-arrow svg {
  width: 100%;
  height: 100%;
  display: block;
  overflow: visible;
}

.stage-arrow path {
  fill: none;
  stroke: currentColor;
  stroke-width: 2.4;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.stage[data-arrow="right"] .stage-arrow {
  top: 50%;
  left: 100%;
  transform: translate(18%, -50%);
}

.stage[data-arrow="left"] .stage-arrow {
  top: 50%;
  right: 100%;
  transform: translate(-18%, -50%);
}

.stage[data-arrow="down"] .stage-arrow {
  left: 50%;
  top: 100%;
  transform: translate(-50%, 18%);
}

@keyframes flow-arrow {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.55;
  }
}

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

.stage--extra {
  border-style: dashed;
  background: rgba(126, 168, 255, 0.05);
}

.stage--lock {
  box-shadow: inset 0 0 0 1px rgba(240, 144, 107, 0.35);
}

.stage-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.35rem;
}

.stage-plus {
  flex-shrink: 0;
  width: 1.55rem;
  height: 1.55rem;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: var(--bg);
  color: var(--accent);
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
  padding: 0;
}

.stage-plus:hover {
  border-color: var(--accent);
  background: var(--accent-dim);
}

.stage-num {
  font-size: 0.68rem;
  color: var(--faint);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.stage-mark {
  width: 2rem;
  height: 2rem;
  border-radius: 0.4rem;
  display: grid;
  place-items: center;
  font-size: 0.7rem;
  font-weight: 600;
  background: var(--accent-dim);
  color: var(--accent);
}

.stage-title {
  font-weight: 600;
  font-size: 0.92rem;
}

.stage-role {
  color: var(--muted);
  font-size: 0.75rem;
}

.stage-status {
  margin-top: auto;
  font-size: 0.7rem;
  color: var(--faint);
}

.stage-status::before {
  content: "";
  display: inline-block;
  width: 0.45rem;
  height: 0.45rem;
  border-radius: 50%;
  margin-right: 0.4rem;
  background: var(--faint);
  vertical-align: 0.05rem;
}

.stage[data-status="idle"] .stage-status::before {
  background: var(--faint);
}

.stage[data-status="ready"] .stage-status::before {
  background: var(--accent);
}

.stage[data-status="lock"] .stage-status::before {
  background: var(--lock);
}

.edge {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 2.6rem;
  flex: 0 0 2.6rem;
  position: relative;
}

.edge::before {
  content: "";
  width: 100%;
  height: 1px;
  background: var(--line);
  position: absolute;
  top: 50%;
}

.plus {
  position: relative;
  z-index: 1;
  width: 1.55rem;
  height: 1.55rem;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: var(--bg);
  color: var(--accent);
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
  padding: 0;
}

.plus:hover {
  border-color: var(--accent);
  background: var(--accent-dim);
}

.ghost--run:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.65rem 0.9rem;
  margin: 0 0 1rem;
}

.tmpl {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  color: var(--muted);
  font-size: 0.78rem;
}

.tmpl select,
.insp-body input,
.insp-body select,
.insp-body textarea {
  font-family: inherit;
  font-size: 0.8rem;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 0.4rem;
  padding: 0.28rem 0.45rem;
}

.policy {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin: 0;
  padding: 0;
}

.policy li {
  font-size: 0.7rem;
  color: var(--warn);
  border: 1px solid rgba(245, 197, 107, 0.35);
  border-radius: 999px;
  padding: 0.12rem 0.5rem;
}

.insp-body textarea {
  width: 100%;
  min-height: 4.2rem;
  resize: vertical;
}

.insp-body .field {
  display: grid;
  gap: 0.2rem;
}

.hint {
  margin: 0.8rem 0 0;
  color: var(--muted);
  font-size: 0.78rem;
}

.toolbar-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.45rem;
  margin-left: auto;
}

.foot {
  display: flex;
  justify-content: center;
  align-items: center;
  flex-shrink: 0;
  padding: 0.75rem 1.25rem 1.25rem;
  border-top: 1px solid var(--line);
  font-size: 0.75rem;
  color: var(--muted);
  text-align: center;
}

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

.foot a:hover {
  color: var(--text);
  text-decoration: none;
}

.overlay {
  position: fixed;
  inset: 0;
  z-index: 20;
  background: rgba(4, 6, 12, 0.72);
  display: grid;
  place-items: center;
  padding: 1rem;
}

.overlay[hidden] {
  display: none;
}

.sheet {
  width: min(40rem, 100%);
  max-height: min(86dvh, 44rem);
  overflow: auto;
  background: #0e111a;
  border: 1px solid var(--line);
  border-radius: 0.8rem;
  padding: 1rem 1.05rem 1.15rem;
}

.sheet--narrow {
  width: min(26rem, 100%);
}

.sheet--wiz {
  width: min(38rem, 100%);
}

.wiz-step {
  margin: 0 0 0.2rem;
  font-size: 0.68rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--faint);
}

.wiz-nav {
  display: flex;
  justify-content: space-between;
  gap: 0.6rem;
  margin-top: 1rem;
  padding-top: 0.85rem;
  border-top: 1px solid var(--line);
}

.wiz-confirm {
  border: 1px solid var(--line);
  border-radius: 0.55rem;
  padding: 0.85rem 0.9rem;
  background: var(--surface);
}

.wiz-confirm p {
  margin: 0 0 0.45rem;
}

.wiz-prompt {
  width: 100%;
  min-height: 4.2rem;
  resize: vertical;
  margin-top: 0.35rem;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 0.45rem;
  padding: 0.55rem 0.65rem;
  font-family: inherit;
  font-size: 0.82rem;
}

.sheet-head {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.35rem;
}

.sheet-head h2 {
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
}

.sheet-x {
  margin-left: auto;
  background: transparent;
  border: 1px solid var(--line);
  color: var(--text);
  width: 2rem;
  height: 2rem;
  border-radius: 0.4rem;
  cursor: pointer;
}

.sheet-lead {
  margin: 0 0 0.9rem;
  color: var(--muted);
  font-size: 0.78rem;
}

.catalog {
  display: grid;
  gap: 0.5rem;
}

.cat-item {
  text-align: left;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 0.55rem;
  padding: 0.7rem 0.75rem;
  color: var(--text);
  cursor: pointer;
  display: grid;
  grid-template-columns: 2.1rem 1fr;
  gap: 0.35rem 0.7rem;
}

.cat-item:hover {
  border-color: var(--accent);
}

.cat-item.is-on {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent);
}

.cat-item .mark {
  grid-row: 1 / span 3;
  align-self: start;
}

.cat-title {
  font-weight: 600;
}

.cat-desc {
  color: var(--muted);
  font-size: 0.75rem;
  grid-column: 2;
}

.cat-why {
  color: var(--faint);
  font-size: 0.72rem;
  grid-column: 2;
  line-height: 1.35;
}

.cat-vendor {
  color: var(--faint);
  font-weight: 400;
  font-size: 0.75rem;
}

.insp-body {
  display: grid;
  gap: 0.55rem;
  color: var(--muted);
}

.insp-body dt {
  color: var(--faint);
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.insp-body dd {
  margin: 0.15rem 0 0;
  color: var(--text);
}

.danger {
  margin-top: 0.6rem;
  background: transparent;
  border: 1px solid rgba(240, 144, 107, 0.45);
  color: var(--lock);
  border-radius: 0.4rem;
  padding: 0.4rem 0.6rem;
  cursor: pointer;
}

@media (max-width: 1100px) {
  .rail {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 800px) {
  .rail {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 720px) {
  .top {
    justify-content: space-between;
    padding: 0.75rem 1.25rem;
  }

  .auth-home,
  .top nav {
    position: static;
    transform: none;
  }

  .toolbar-actions {
    margin-left: 0;
  }
}

@media (max-width: 520px) {
  .rail {
    grid-template-columns: 1fr;
  }
}
