:root{
  --bg: #ffffff;
  --bgSoft: #f8fafc;
  --text: #111827;
  --muted: #6b7280;
  --line: #e5e7eb;

  --accent: #2563eb;
  --accent2: #1d4ed8;

  --max: 1180px;
  --content: 1020px;

  --radius: 18px;

  --shadow: 0 10px 26px rgba(17,24,39,.08);
  --shadow2: 0 16px 44px rgba(17,24,39,.12);
}

*{ box-sizing: border-box; }

html{
  scroll-behavior: smooth;
  scroll-padding-top: 96px;
}

body{
  margin: 0;
  background:
    radial-gradient(1200px 600px at 20% -10%, rgba(37,99,235,.08), transparent 60%),
    radial-gradient(900px 500px at 90% 0%, rgba(37,99,235,.06), transparent 55%),
    var(--bg);
  color: var(--text);
  font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  line-height: 1.7;
}

.wrap{
  max-width: var(--max);
  margin: 0 auto;
  padding: 30px 22px;
}

.skip{
  position: absolute;
  left: -9999px;
  top: 10px;
  background: #000;
  color: #fff;
  padding: 8px 10px;
  border-radius: 10px;
}
.skip:focus{ left: 12px; }

/* Sticky header */
.header{
  position: sticky;
  top: 0;
  z-index: 10;
  background: rgba(255,255,255,.90);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid rgba(229,231,235,.85);
  transition: box-shadow .18s ease, background .18s ease;
}

.headerWrap{
  padding-top: 16px;
  padding-bottom: 12px;
}

/* Key fix: do NOT use display:none (causes jump). Use max-height + opacity */
.top{
  display: flex;
  gap: 18px;
  align-items: flex-start;
  justify-content: space-between;
  flex-wrap: wrap;

  overflow: hidden;
  max-height: 260px;
  opacity: 1;
  transition: max-height .22s ease, opacity .18s ease, margin .18s ease;
}

/* Compact mode */
.header.compact{
  background: rgba(255,255,255,.92);
  box-shadow: 0 10px 28px rgba(17,24,39,.10);
}
.header.compact .top{
  max-height: 0;
  opacity: 0;
  margin: 0;
  pointer-events: none;
}

h1{
  margin: 0;
  font-size: 36px;
  line-height: 1.10;
  letter-spacing: -0.03em;
  background: linear-gradient(180deg, #0f172a 0%, #111827 60%, rgba(17,24,39,.85) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.meta{
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  margin-top: 12px;
  color: var(--muted);
  font-size: 14px;
}
.meta b{ color: var(--text); font-weight: 650; }

.actions{
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  padding-top: 6px;
}

.btn{
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 40px;
  padding: 0 14px;
  border-radius: 999px;
  border: 1px solid rgba(229,231,235,.9);
  background: #fff;
  color: var(--text);
  text-decoration: none;
  font-weight: 650;
  font-size: 14px;
  box-shadow: 0 10px 22px rgba(17,24,39,.06);
  transition: transform .16s ease, box-shadow .16s ease, border-color .16s ease;
}
.btn:hover{
  transform: translateY(-1px);
  border-color: #d1d5db;
  box-shadow: 0 16px 34px rgba(17,24,39,.10);
}
.btn.primary{
  border-color: transparent;
  background: linear-gradient(180deg, var(--accent), var(--accent2));
  color: #fff;
  box-shadow: 0 14px 28px rgba(37,99,235,.22);
}
.btn.primary:hover{
  box-shadow: 0 18px 40px rgba(37,99,235,.28);
}

/* Nav */
.nav{
  display: flex;
  gap: 10px;
  flex-wrap: nowrap;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  padding: 10px 0 2px;
}
.nav::-webkit-scrollbar{ height: 6px; }
.nav::-webkit-scrollbar-thumb{ background: rgba(17,24,39,.12); border-radius: 999px; }

.nav a{
  white-space: nowrap;
  color: var(--muted);
  text-decoration: none;
  font-weight: 650;
  font-size: 14px;
  padding: 8px 10px;
  border-radius: 12px;
  border: 1px solid transparent;
  transition: background .16s ease, color .16s ease, border-color .16s ease;
}
.nav a:hover{
  background: rgba(248,250,252,.9);
  color: var(--text);
  border-color: rgba(229,231,235,.9);
}
.nav a.active{
  color: var(--accent2);
  background: rgba(37,99,235,.08);
  border-color: rgba(37,99,235,.20);
}

/* Make anchor jumps look correct even with sticky header */
.section{ scroll-margin-top: 110px; }

/* Content width: text/images/grids equal */
.section > h2,
.section > h3,
.section > h4,
.section > p,
.section > .badges,
.section > .grid2,
.section > .grid3,
.section > .figure,
.section > .gallery,
.section > .details,
.section > .callouts,
.section > .code,
.section > pre{
  max-width: var(--content);
  margin-left: auto;
  margin-right: auto;
}

/* Section blocks (less “stacked text”) */
.section{
  position: relative;
  padding: 26px 0;
  margin: 18px 0;
}
.section::before{
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: -10px;
  bottom: -10px;
  background: rgba(248,250,252,.72);
  border: 1px solid rgba(229,231,235,.9);
  border-radius: 22px;
  box-shadow: 0 10px 26px rgba(17,24,39,.05);
  z-index: -1;
}
.section:nth-of-type(odd)::before{
  background: rgba(255,255,255,.86);
}

/* Cooler headings */
h2{
  margin: 0 0 12px;
  font-size: 22px;
  letter-spacing: -0.015em;
  position: relative;
  padding-left: 14px;
}
h2::before{
  content: "";
  position: absolute;
  left: 0;
  top: .25em;
  bottom: .25em;
  width: 4px;
  border-radius: 999px;
  background: linear-gradient(180deg, var(--accent), var(--accent2));
}

h3{
  margin: 18px 0 10px;
  font-size: 17px;
  letter-spacing: -0.01em;
  color: #0f172a;
}
h4{
  margin: 18px 0 10px;
  font-size: 13px;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: rgba(17,24,39,.72);
}
p{
  margin: 10px 0;
  font-size: 15.7px;
  color: rgba(17,24,39,.95);
}

/* Badges */
.badges{
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 14px;
}
.badge{
  font-size: 13px;
  color: var(--muted);
  background: rgba(248,250,252,.95);
  border: 1px solid rgba(229,231,235,.9);
  padding: 6px 10px;
  border-radius: 999px;
}

/* Grids / Cards */
.grid2{
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  margin-top: 14px;
}
.grid3{
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  margin-top: 14px;
}

.card{
  background: rgba(255,255,255,.92);
  border: 1px solid rgba(229,231,235,.9);
  border-radius: var(--radius);
  padding: 14px;
  box-shadow: var(--shadow);
  transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease;
}
.card:hover{
  transform: translateY(-2px);
  box-shadow: var(--shadow2);
  border-color: #d1d5db;
}
.card p{ color: var(--muted); }

/* Figures */
.figure{
  margin: 14px auto 0;
  border: 1px solid rgba(229,231,235,.9);
  border-radius: var(--radius);
  overflow: hidden;
  background: rgba(255,255,255,.95);
  box-shadow: var(--shadow);
  transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease;
}
.figure:hover{
  transform: translateY(-2px);
  box-shadow: var(--shadow2);
  border-color: #d1d5db;
}
.figure img{
  width: 100%;
  height: auto;
  display: block;
  background: #fff;
}
.figure figcaption{
  padding: 10px 12px;
  font-size: 13px;
  color: var(--muted);
  border-top: 1px solid rgba(229,231,235,.9);
  background: rgba(248,250,252,.85);
}

/* Code blocks */
.code{
  margin-top: 14px;
  background: #0f172a;
  color: #e5e7eb;
  border-radius: var(--radius);
  padding: 14px;
  overflow: auto;
  font-size: 13px;
  line-height: 1.55;
  border: 1px solid rgba(255,255,255,.08);
  box-shadow: var(--shadow);
}
code{
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
}

/* Footer */
.footer{
  padding: 16px 0 6px;
  color: var(--muted);
  text-align: center;
  font-size: 14px;
}

/* Responsive */
@media (max-width: 1000px){
  :root{ --content: 100%; }
}

@media (max-width: 900px){
  h1{ font-size: 28px; }
  .grid2, .grid3{ grid-template-columns: 1fr; }
}