:root {
  --bg: #0e0f12;
  --bg-soft: #13151a;
  --panel: #181b21;
  --line: #262a33;
  --text: #e8eaee;
  --muted: #9aa2ad;
  --accent: #5b8def;
  --ok: #6fcf97;
  --warn: #f2c94c;
  --err: #eb5757;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.65 system-ui, "Segoe UI", "Microsoft YaHei", "PingFang SC", sans-serif;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); }

.hero {
  padding: 76px 20px 52px;
  text-align: center;
  background:
    radial-gradient(60% 120% at 50% -20%, rgba(91, 141, 239, .16), transparent 62%),
    linear-gradient(180deg, #12141a 0%, var(--bg) 100%);
  border-bottom: 1px solid var(--line);
}

.hero h1 {
  margin: 0 0 12px;
  font-size: clamp(24px, 4.6vw, 42px);
  letter-spacing: .4px;
}

.hero .sub {
  margin: 0 auto;
  max-width: 720px;
  color: var(--muted);
  font-size: clamp(13.5px, 1.6vw, 16px);
}

.steps {
  list-style: none;
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 10px;
  max-width: 1080px;
  margin: 30px auto 26px;
  padding: 0;
}

.step {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px 10px;
  text-align: left;
  font-size: 12px;
  color: var(--muted);
}

.step b {
  display: block;
  margin-bottom: 4px;
  color: var(--text);
  font-size: 13px;
}

.cta {
  display: inline-block;
  margin-top: 6px;
  padding: 11px 26px;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  text-decoration: none;
  font-size: 14.5px;
  transition: transform .15s ease, box-shadow .15s ease;
}

.cta:hover {
  transform: translateY(-1px);
  box-shadow: 0 8px 22px rgba(91, 141, 239, .35);
}

.section {
  max-width: 1200px;
  margin: 0 auto;
  padding: 52px 20px 12px;
}

.section h2 {
  margin: 0 0 8px;
  font-size: 22px;
}

.section .lead {
  margin: 0 0 20px;
  color: var(--muted);
  font-size: 13.5px;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
}

.seg {
  display: flex;
  gap: 4px;
  padding: 4px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
}

.seg button {
  border: 0;
  background: transparent;
  color: var(--muted);
  padding: 7px 16px;
  border-radius: 9px;
  cursor: pointer;
  font-size: 13.5px;
  line-height: 1.35;
  transition: background .15s ease, color .15s ease;
}

.seg button small {
  display: block;
  font-size: 11px;
  color: var(--muted);
}

.seg button.on {
  background: #2b3446;
  color: #fff;
}

.seg button.on small { color: #bcd0f7; }

.btn {
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--text);
  padding: 9px 16px;
  border-radius: 9px;
  cursor: pointer;
  font-size: 13.5px;
}

.btn:hover { background: #22262e; }

.btn.on {
  background: #2b3446;
  border-color: #3b4a66;
}

.stage {
  position: relative;
  border: 1px solid var(--line);
  border-radius: 14px;
  overflow: hidden;
  background: #14161a;
}

#viewport {
  height: min(72vh, 640px);
  min-height: 380px;
}

#viewport canvas { display: block; }

#hud {
  position: absolute;
  top: 12px;
  left: 12px;
  max-width: min(430px, calc(100% - 24px));
  padding: 10px 12px;
  background: rgba(10, 12, 16, .74);
  border: 1px solid rgba(255, 255, 255, .09);
  border-radius: 10px;
  backdrop-filter: blur(6px);
  font-size: 13px;
  line-height: 1.7;
}

.hud-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-weight: 600;
}

#hudToggle {
  border: 1px solid rgba(255, 255, 255, .18);
  background: rgba(255, 255, 255, .06);
  color: #dfe3ea;
  width: 24px;
  height: 24px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
}

#hud.collapsed #hudBody { display: none; }

#layoutInfo { margin-top: 4px; }

#layoutInfo .meta {
  color: var(--muted);
  font-size: 12px;
  margin-left: 6px;
}

.badge {
  display: inline-block;
  padding: 1px 9px;
  border-radius: 999px;
  font-size: 12px;
}

.badge.ok { background: rgba(111, 207, 151, .16); color: var(--ok); }
.badge.warn { background: rgba(242, 201, 76, .16); color: var(--warn); }
.badge.err { background: rgba(235, 87, 87, .16); color: var(--err); }

#issues { margin-top: 2px; }

#issues .issue {
  cursor: pointer;
  padding: 2px 4px;
  border-radius: 4px;
  font-size: 12px;
  color: #c6ccd6;
}

#issues .issue:hover { background: rgba(255, 255, 255, .1); }

.hud-row { margin-top: 6px; display: flex; gap: 6px; }

.hud-row button {
  border: 1px solid #4a4f5a;
  border-radius: 6px;
  background: #2a2d33;
  color: #eee;
  padding: 3px 12px;
  cursor: pointer;
  font-size: 12.5px;
}

.hud-row button:hover { background: #3a3e46; }

.hud-row button.on { background: #4a6fa5; }

#loading {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(14, 15, 18, .68);
  color: #cfd4db;
  font-size: 14px;
  letter-spacing: .5px;
}

.hint {
  margin: 10px 2px 0;
  color: var(--muted);
  font-size: 12.5px;
}

.semantics {
  margin-top: 14px;
  padding: 12px 14px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-left: 3px solid var(--accent);
  border-radius: 10px;
  font-size: 13px;
  color: #c6ccd6;
}

.proc-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
}

.proc-card {
  margin: 0;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
}

.proc-imgs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2px;
  background: #0b0c0f;
}

.proc-imgs img {
  width: 100%;
  display: block;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  background: #fff;
}

.proc-card figcaption {
  padding: 10px 12px 12px;
  font-size: 12.5px;
  color: var(--muted);
}

.proc-card figcaption b {
  display: block;
  margin-bottom: 2px;
  color: var(--text);
  font-size: 13px;
}

.proc-card figcaption .step-no {
  display: inline-block;
  margin-right: 6px;
  color: var(--accent);
}

.stat-cards {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
  margin-bottom: 24px;
}

.stat {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 18px 12px;
  text-align: center;
}

.stat b {
  display: block;
  font-size: clamp(26px, 3.4vw, 36px);
  color: #fff;
}

.stat span {
  color: var(--muted);
  font-size: 13px;
}

.library-cols {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr);
  gap: 26px;
  align-items: start;
}

.bar-row {
  display: grid;
  grid-template-columns: 128px 1fr 46px;
  align-items: center;
  gap: 10px;
  margin: 9px 0;
  font-size: 13px;
}

.bar-label small {
  display: block;
  color: var(--muted);
  font-size: 11px;
}

.bar-track {
  height: 10px;
  background: #1d2129;
  border-radius: 999px;
  overflow: hidden;
}

.bar-track i {
  display: block;
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, #3f6ad8, #6fcf97);
}

.bar-num { text-align: right; color: var(--muted); }

.sub-list { list-style: none; margin: 8px 0 0; padding: 0; font-size: 13px; }
.sub-list li { display: flex; justify-content: space-between; padding: 5px 2px; border-bottom: 1px dashed var(--line); color: var(--muted); }
.sub-list li b { color: var(--text); font-weight: 500; }

.side-title { margin: 0 0 4px; font-size: 14px; color: var(--text); }
.side-note { margin: 0; color: var(--muted); font-size: 12.5px; }

.flow {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin: 6px 0 0;
}

.flow span {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 8px 16px;
  font-size: 13px;
}

.flow i { color: var(--muted); font-style: normal; }

.stack-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 14px;
  margin-top: 18px;
}

.stack-item {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 14px 16px;
  font-size: 13px;
  color: var(--muted);
}

.stack-item b { display: block; color: var(--text); margin-bottom: 4px; font-size: 13.5px; }

footer {
  margin-top: 48px;
  border-top: 1px solid var(--line);
  padding: 26px 20px 42px;
  text-align: center;
  color: var(--muted);
  font-size: 12.5px;
}

footer p { margin: 4px 0; }

@media (max-width: 980px) {
  .steps { grid-template-columns: repeat(3, 1fr); }
  .proc-grid { grid-template-columns: repeat(2, 1fr); }
  .library-cols { grid-template-columns: 1fr; }
}

@media (max-width: 720px) {
  .hero { padding: 54px 16px 40px; }
  .section { padding: 40px 16px 8px; }
  #viewport { height: 62vh; min-height: 320px; }
  .stat-cards { grid-template-columns: 1fr; gap: 10px; }
  #hud { font-size: 12.5px; max-width: calc(100% - 20px); }
  .bar-row { grid-template-columns: 96px 1fr 40px; }
}

@media (max-width: 560px) {
  .steps { grid-template-columns: repeat(2, 1fr); }
  .proc-grid { grid-template-columns: 1fr; }
  .toolbar { flex-direction: column; align-items: stretch; }
  .seg { justify-content: center; }
}
