:root {
  color-scheme: dark;
  --bg: #07101f;
  --panel: #0d1728;
  --panel-2: #121e32;
  --line: rgba(148, 163, 184, .22);
  --text: #eef5ff;
  --muted: #9fb0c7;
  --primary: #1a3cff;
  --primary-2: #257bff;
  --accent: #00d1c1;
  --danger: #ff4d67;
  --shadow: 0 24px 70px rgba(0, 0, 0, .36);
  --radius: 8px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

[hidden] {
  display: none !important;
}

html { scroll-behavior: smooth; }

html {
  scroll-padding-top: 112px;
}

body {
  margin: 0;
  background:
    radial-gradient(circle at 85% 12%, rgba(0, 209, 193, .12), transparent 28rem),
    linear-gradient(135deg, #07101f 0%, #0b1324 52%, #08111f 100%);
  color: var(--text);
  min-height: 100vh;
}

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

button, input {
  font: inherit;
}

.wiki-shell {
  display: grid;
  grid-template-columns: 320px minmax(0, 1fr);
  min-height: 100vh;
}

.wiki-sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 20px;
  border-right: 1px solid var(--line);
  background: rgba(8, 16, 31, .86);
  backdrop-filter: blur(18px);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.brand {
  display: flex;
  align-items: center;
  min-height: 54px;
}

.brand img {
  width: 190px;
  max-width: 100%;
  display: block;
}

.sidebar-search {
  display: grid;
  gap: 8px;
}

.sidebar-search label,
.kicker,
.chapter-head em,
.screenshot-card figcaption {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.sidebar-search input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, .06);
  color: var(--text);
  padding: 12px 13px;
  outline: none;
}

.sidebar-search input:focus {
  border-color: rgba(0, 209, 193, .72);
  box-shadow: 0 0 0 3px rgba(0, 209, 193, .13);
}

.chapter-nav {
  overflow: auto;
  padding-right: 6px;
  display: grid;
  gap: 8px;
}

.chapter-nav a {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr);
  gap: 10px;
  padding: 10px;
  border-radius: var(--radius);
  color: var(--muted);
  border: 1px solid transparent;
}

.chapter-nav a:hover,
.chapter-nav a.is-active {
  background: rgba(26, 60, 255, .16);
  border-color: rgba(37, 123, 255, .38);
  color: var(--text);
}

.chapter-nav span {
  width: 28px;
  height: 28px;
  border-radius: 7px;
  display: grid;
  place-items: center;
  color: var(--accent);
  background: rgba(0, 209, 193, .12);
  font-size: 11px;
  font-weight: 900;
}

.chapter-nav strong {
  display: block;
  font-size: 13px;
  line-height: 1.25;
}

.chapter-nav em {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 11px;
  font-style: normal;
}

.wiki-main {
  min-width: 0;
  padding: 20px;
}

.topbar {
  min-height: 76px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(13, 23, 40, .78);
  box-shadow: var(--shadow);
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  position: sticky;
  top: 12px;
  z-index: 5;
  backdrop-filter: blur(18px);
}

.topbar h1 {
  margin: 3px 0 0;
  font-size: clamp(22px, 3vw, 34px);
  line-height: 1.05;
  letter-spacing: 0;
}

.top-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.pill,
.wiki-tools button {
  border: 1px solid rgba(37, 123, 255, .42);
  border-radius: var(--radius);
  background: linear-gradient(135deg, var(--primary), var(--primary-2));
  color: white;
  min-height: 40px;
  padding: 0 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  cursor: pointer;
}

.pill.ghost,
.wiki-tools button {
  background: rgba(255, 255, 255, .06);
  color: var(--text);
}

.pill.icon { min-width: 84px; }

.mobile-nav {
  display: none;
  width: 42px;
  height: 42px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, .07);
  padding: 10px;
}

.mobile-nav span {
  display: block;
  height: 2px;
  margin: 4px 0;
  border-radius: 2px;
  background: var(--text);
}

.hero-panel {
  margin-top: 18px;
  border: 1px solid var(--line);
  border-radius: 22px;
  background:
    linear-gradient(135deg, rgba(26, 60, 255, .28), rgba(0, 209, 193, .10)),
    rgba(13, 23, 40, .72);
  padding: clamp(22px, 4vw, 42px);
  min-height: 230px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 260px;
  gap: 22px;
  align-items: center;
  overflow: hidden;
}

.hero-copy p {
  max-width: 850px;
  margin: 0;
  color: #dbe8ff;
  font-size: clamp(17px, 2vw, 22px);
  line-height: 1.55;
}

.hero-status {
  margin-top: 18px;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--accent);
  font-weight: 900;
}

.pulse {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 0 rgba(0, 209, 193, .65);
  animation: pulse 1.8s infinite;
}

@keyframes pulse {
  70% { box-shadow: 0 0 0 14px rgba(0, 209, 193, 0); }
  100% { box-shadow: 0 0 0 0 rgba(0, 209, 193, 0); }
}

.hero-card {
  min-height: 190px;
  border: 1px solid rgba(255, 255, 255, .14);
  border-radius: 18px;
  background: rgba(255, 255, 255, .08);
  display: grid;
  place-items: center;
  text-align: center;
  padding: 22px;
}

.hero-card img {
  width: 78px;
  margin-bottom: 12px;
}

.hero-card strong {
  font-size: 22px;
}

.hero-card span {
  color: var(--muted);
  font-weight: 700;
}

.quickstart {
  margin-top: 18px;
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 12px;
}

.quickstart article,
.chapter,
.wiki-tools {
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(13, 23, 40, .74);
}

.quickstart article {
  padding: 16px;
}

.quickstart span {
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: rgba(0, 209, 193, .12);
  color: var(--accent);
  font-weight: 900;
}

.quickstart h2 {
  margin: 14px 0 8px;
  font-size: 16px;
}

.quickstart p,
.wiki-tools p,
.chapter-text p,
.tips,
.control-list span {
  color: var(--muted);
  line-height: 1.55;
}

.wiki-tools {
  margin-top: 18px;
  padding: 12px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.wiki-tools p {
  margin: 0 0 0 auto;
  max-width: 720px;
  font-size: 13px;
}

.chapters {
  margin-top: 18px;
  display: grid;
  gap: 12px;
}

.chapter {
  overflow: hidden;
  scroll-margin-top: 112px;
}

.chapter-head {
  width: 100%;
  border: 0;
  background: transparent;
  color: var(--text);
  padding: 16px;
  display: grid;
  grid-template-columns: 52px minmax(0, 1fr) 38px;
  gap: 14px;
  text-align: left;
  align-items: center;
  cursor: pointer;
}

.chapter-number {
  width: 46px;
  height: 46px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, rgba(26, 60, 255, .8), rgba(0, 209, 193, .45));
  font-weight: 950;
}

.chapter-head strong {
  display: block;
  margin-top: 4px;
  font-size: clamp(18px, 2.1vw, 26px);
  letter-spacing: 0;
}

.chapter-toggle {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--accent);
  font-size: 24px;
}

.chapter-head[aria-expanded="true"] .chapter-toggle {
  transform: rotate(45deg);
}

.chapter-body {
  border-top: 1px solid var(--line);
  padding: 18px;
}

.chapter-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(360px, 43%);
  gap: 18px;
}

.chapter-text {
  display: grid;
  gap: 18px;
}

.chapter-text section {
  padding: 16px;
  border: 1px solid rgba(148, 163, 184, .16);
  border-radius: 14px;
  background: rgba(255, 255, 255, .035);
}

.chapter-text h3 {
  margin: 0 0 10px;
  font-size: 14px;
  color: #dce8ff;
}

.chapter-text p {
  margin: 0 0 10px;
}

.chapter-text p:last-child { margin-bottom: 0; }

.control-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.control-list div {
  border: 1px solid rgba(148, 163, 184, .16);
  border-radius: 12px;
  padding: 12px;
  background: rgba(7, 16, 31, .42);
}

.control-list strong {
  display: block;
  margin-bottom: 5px;
  color: var(--accent);
}

.expected {
  color: #dbe8ff !important;
  font-weight: 700;
}

.tips {
  margin: 0;
  padding-left: 20px;
}

.tips li + li { margin-top: 8px; }

.screenshot-card {
  margin: 0;
  align-self: start;
  position: sticky;
  top: 110px;
  border: 1px solid rgba(148, 163, 184, .20);
  border-radius: 18px;
  background: rgba(7, 16, 31, .55);
  padding: 10px;
}

.screenshot-card button {
  border: 0;
  padding: 0;
  width: 100%;
  display: block;
  border-radius: 12px;
  overflow: hidden;
  background: #08101c;
  cursor: zoom-in;
}

.screenshot-card img {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 10;
  object-fit: cover;
  object-position: top left;
}

.screenshot-card figcaption {
  padding: 10px 4px 2px;
}

.empty-state {
  border: 1px solid rgba(255, 77, 103, .35);
  border-radius: 14px;
  padding: 18px;
  color: #ffd5dc;
  background: rgba(255, 77, 103, .08);
}

.lightbox {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: rgba(2, 6, 23, .88);
  padding: 34px;
  display: grid;
  place-items: center;
}

.lightbox button {
  position: fixed;
  top: 18px;
  right: 18px;
  width: 44px;
  height: 44px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--text);
  font-size: 28px;
}

.lightbox img {
  max-width: 96vw;
  max-height: 90vh;
  border-radius: 12px;
  box-shadow: var(--shadow);
}

@media (max-width: 1180px) {
  .wiki-shell { grid-template-columns: 1fr; }
  .wiki-sidebar {
    position: fixed;
    z-index: 20;
    transform: translateX(-104%);
    transition: transform .2s ease;
    width: min(86vw, 340px);
  }
  body.nav-open .wiki-sidebar { transform: translateX(0); }
  .mobile-nav { display: block; }
  .quickstart { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .chapter-grid { grid-template-columns: 1fr; }
  .screenshot-card { position: static; }
}

@media (max-width: 760px) {
  .wiki-main { padding: 10px; }
  .topbar {
    top: 8px;
    border-radius: 14px;
    align-items: flex-start;
    flex-wrap: wrap;
  }
  .top-actions {
    width: 100%;
    justify-content: stretch;
  }
  .top-actions .pill {
    flex: 1 1 auto;
    min-width: 0;
  }
  .hero-panel {
    grid-template-columns: 1fr;
    border-radius: 16px;
  }
  .hero-card {
    min-height: 130px;
  }
  .quickstart { grid-template-columns: 1fr; }
  .wiki-tools {
    align-items: stretch;
    flex-wrap: wrap;
  }
  .wiki-tools button {
    flex: 1;
  }
  .wiki-tools p {
    margin-left: 0;
  }
  .chapter-head {
    grid-template-columns: 44px minmax(0, 1fr) 34px;
    gap: 10px;
    padding: 12px;
  }
  .chapter-number {
    width: 40px;
    height: 40px;
  }
  .chapter-body { padding: 12px; }
  .control-list { grid-template-columns: 1fr; }
  .lightbox { padding: 12px; }
}

@media print {
  body {
    background: white;
    color: #111827;
  }
  .wiki-shell { display: block; }
  .wiki-sidebar,
  .top-actions,
  .mobile-nav,
  .wiki-tools,
  .lightbox {
    display: none !important;
  }
  .wiki-main { padding: 0; }
  .topbar,
  .chapter,
  .hero-panel,
  .quickstart article {
    box-shadow: none;
    border-color: #d1d5db;
    background: white;
    color: #111827;
  }
  .chapter-body[hidden] { display: block; }
  .chapter-grid { grid-template-columns: 1fr; }
  .screenshot-card { position: static; break-inside: avoid; }
}
