.portal-guide-section { background: var(--teal-soft); scroll-margin-top: 64px; }
.portal-guide-panel { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 24px; align-items: center; }
.portal-guide-panel h2 { margin: 6px 0 8px; font-size: clamp(1.6rem, 3vw, 2.2rem); }
.portal-guide-panel p { max-width: 38rem; color: var(--text-secondary); }
.portal-guide-panel .guide-kicker { color: var(--teal); }

@media (max-width: 560px) {
  .portal-guide-panel { grid-template-columns: 1fr; }
  .portal-guide-panel > a { justify-self: start; }
}

.guide-page, .classnode-site {
  --guide-ink: #1d655f;
  --guide-surface: #f0f6f3;
  background: var(--bg-primary);
}

[data-theme="dark"] :is(.guide-page, .classnode-site) {
  --guide-ink: #8ddad0;
  --guide-surface: #263633;
}

.guide-page [id] { scroll-margin-top: 85px; }
.guide-page [hidden] { display: none !important; }
.guide-page a:focus-visible,
.guide-page button:focus-visible,
.guide-page summary:focus-visible,
.guide-page input:focus-visible {
  outline: 2px solid var(--guide-ink);
  outline-offset: 4px;
}

.guide-page .guide-skip {
  position: fixed;
  z-index: 200;
  top: 8px;
  left: 12px;
  transform: translateY(-150%);
  padding: 6px 14px;
  background: var(--bg-card);
}
.guide-page .guide-skip:focus { transform: none; }

.guide-landing {
  padding: 108px 0 36px;
  background: var(--guide-surface);
  border-bottom: 1px solid var(--border);
}
.guide-intro {
  display: grid;
  grid-template-columns: 1fr minmax(230px, 350px);
  align-items: end;
  gap: 24px;
}
.guide-parent, .guide-secondary { color: var(--guide-ink); font-weight: 680; }
.guide-intro h1, .guide-doc-title h1 {
  font-size: clamp(2.15rem, 4.9vw, 3.4rem);
  letter-spacing: -.04em;
  line-height: 1.18;
  margin: 7px 0 12px;
}
.guide-intro p, .guide-doc-title p { color: var(--text-secondary); }
.guide-search { position: relative; }
.guide-search label { display: block; font-weight: 650; margin-bottom: 5px; }
.guide-search input {
  width: 100%;
  padding: 10px 14px;
  color: var(--text-primary);
  background: var(--bg-card);
  border: 1px solid var(--border-strong);
  border-radius: 9px;
  font: inherit;
}
.guide-search input::placeholder { color: var(--text-secondary); }
#guide-search-status {
  position: absolute;
  top: 100%;
  left: 0;
  font-size: .85rem;
}

.guide-hub { padding-top: 28px; padding-bottom: 64px; }
.guide-feature {
  display: grid;
  grid-template-columns: 1.25fr 1fr;
  align-items: center;
  gap: 26px;
  background: #17433e;
  color: #fff;
  border-radius: 18px;
  padding: clamp(22px, 4vw, 40px);
}
.guide-feature h2 { font-size: clamp(1.35rem, 3vw, 1.95rem); line-height: 1.35; }
.guide-feature p { color: #d5e9e5; margin-top: 8px; }
.guide-primary {
  display: inline-block;
  background: #ffe0c6;
  color: #512b19;
  font-weight: 730;
  border-radius: 7px;
  padding: 9px 16px;
  margin: 18px 15px 0 0;
}
.guide-feature .guide-secondary { color: #f3f8f6; text-decoration: underline; text-underline-offset: .25em; }
.guide-feature a:focus-visible { outline-color: #ffe0c6; }
.guide-route { list-style: none; counter-reset: route; display: grid; gap: 12px; }
.guide-route li { counter-increment: route; display: flex; align-items: center; gap: 10px; }
.guide-route li::before {
  content: counter(route);
  display: grid;
  place-items: center;
  background: #ffffff19;
  width: 29px;
  height: 29px;
  flex: none;
  border-radius: 50%;
  color: #ffe0c6;
  font-size: .86rem;
}
.guide-catalog {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 22px 52px;
  margin-top: 30px;
}
.guide-catalog .guide-category { padding: 0; }
.guide-category ul, .guide-in-page ul { list-style: none; }
.guide-catalog li { border-bottom: 1px solid var(--border); }
.guide-catalog li a { display: block; padding: 11px 8px; border-radius: 6px; }
.guide-catalog strong, .guide-catalog span { display: block; }
.guide-catalog span { color: var(--text-secondary); font-size: .92rem; }
.guide-catalog a:hover, .guide-catalog li:target { background: var(--guide-surface); }
.guide-catalog li:target strong { color: var(--guide-ink); }

.guide-doc {
  display: grid;
  grid-template-columns: 226px minmax(0, 1fr) 145px;
  grid-template-areas: "crumb crumb crumb" "side title toc" "side article toc";
  grid-template-rows: auto auto 1fr;
  align-items: start;
  gap: 16px clamp(20px, 3vw, 40px);
  padding-top: 93px;
  padding-bottom: 65px;
}
.guide-crumb { grid-area: crumb; display: flex; align-items: center; gap: 9px; font-size: .9rem; color: var(--text-secondary); }
.guide-crumb a, .guide-chapter a:not(.guide-shot a) { color: var(--guide-ink); }
.guide-doc-title { grid-area: title; border-bottom: 1px solid var(--border); padding-bottom: 20px; }
.guide-doc-title h1 { font-size: clamp(1.8rem, 3.9vw, 2.65rem); }
.guide-sidebar { grid-area: side; }
.guide-in-page { grid-area: toc; border-left: 1px solid var(--border); padding-left: 12px; }
.guide-sidebar, .guide-in-page { position: sticky; top: 80px; max-height: calc(100vh - 94px); overflow-y: auto; }
.guide-sidebar {
  border: 1px solid var(--border);
  border-radius: 13px;
  background: var(--bg-card);
  padding: 10px;
}
.guide-sidebar summary, .guide-detail summary { cursor: pointer; }
.guide-tree-title,
.guide-branch > summary {
  display: grid;
  align-items: center;
  list-style: none;
}
.guide-sidebar summary::-webkit-details-marker { display: none; }
.guide-tree-title {
  grid-template-columns: 1fr auto;
  padding: 7px 8px;
  font-weight: 750;
}
.guide-tree-title::after,
.guide-branch > summary::after {
  content: "";
  width: 6px;
  height: 6px;
  border-right: 1.5px solid currentColor;
  border-bottom: 1.5px solid currentColor;
  transform: rotate(-45deg);
  margin: 0 3px;
}
.guide-sidebar details[open] > summary::after { transform: rotate(45deg); }
.guide-tree {
  display: grid;
  gap: 3px;
  border-top: 1px solid var(--border);
  padding-top: 7px;
  margin-top: 4px;
}
.guide-branch > summary {
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 7px;
  padding: 8px 6px;
  border-radius: 7px;
  color: var(--text-primary);
  font-size: .88rem;
  font-weight: 650;
  line-height: 1.35;
}
.guide-branch > summary:hover,
.guide-branch:has([aria-current="page"]) > summary {
  background: var(--guide-surface);
  color: var(--guide-ink);
}
.guide-branch-number {
  color: var(--text-secondary);
  font-size: .76rem;
  font-variant-numeric: tabular-nums;
}
.guide-branch ul {
  list-style: none;
  border-left: 1px solid var(--border-strong);
  margin: 4px 0 4px 13px;
  padding-left: 8px;
}
.guide-branch li { position: relative; }
.guide-branch li::before {
  content: "";
  border-top: 1px solid var(--border-strong);
  width: 8px;
  position: absolute;
  left: -8px;
  top: 16px;
}
.guide-branch a, .guide-in-page a {
  display: block;
  border-radius: 6px;
  padding: 7px 8px;
  font-size: .87rem;
  line-height: 1.45;
}
.guide-branch a:hover, .guide-in-page a:hover {
  background: var(--guide-surface);
  color: var(--guide-ink);
}
.guide-branch [aria-current="page"] {
  background: var(--guide-surface);
  color: var(--guide-ink);
  box-shadow: inset 2px 0 var(--teal);
  font-weight: 700;
}
.guide-in-page > p { font-weight: 730; }
.guide-in-page ul { margin-top: 5px; }
.guide-chapter { grid-area: article; font-size: 1.04rem; line-height: 1.82; min-width: 0; }
.guide-chapter > h3 { font-size: 1.28rem; line-height: 1.4; margin: 20px 0 9px; }
.guide-chapter > h3:first-child { margin-top: 3px; }
.guide-path { color: var(--text-secondary); font-size: .93rem; }
.guide-steps { padding-left: 1.55em; }
.guide-steps li { margin: 9px 0; padding-left: .15em; }
.guide-steps li::marker { color: var(--guide-ink); font-weight: 700; }
.guide-three { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 9px; margin-top: 18px; }
.guide-three > div, .guide-detail {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 11px 13px;
}
.guide-three h4 { font-size: 1rem; }
.guide-three p, .guide-options dd { color: var(--text-secondary); font-size: .95rem; }
.guide-options > div { border-top: 1px solid var(--border); padding: 11px 0; }
.guide-options dt, .guide-detail summary { font-weight: 690; }
.guide-detail { margin-top: 11px; }
.guide-detail ul { padding-left: 1.3em; }
.guide-detail p, .guide-detail li { margin-top: 6px; }
.guide-note, .guide-check, .guide-motion {
  margin: 18px 0;
  padding: 14px 16px;
  background: var(--guide-surface);
  border-radius: 9px;
}
.guide-note { border-left: 3px solid var(--teal); }
.guide-check h3 { font-size: 1rem; color: var(--guide-ink); }
.guide-related { display: flex; flex-wrap: wrap; gap: 8px 17px; margin-top: 5px; font-size: .93rem; }
.guide-related a, .guide-note a { text-decoration: underline; text-underline-offset: .22em; }

.guide-shot { margin: 15px 0 20px; max-width: 100%; }
.guide-shot a { display: block; width: fit-content; max-width: 100%; cursor: zoom-in; }
.guide-shot img,
.guide-viewer img {
  display: block;
  max-width: 100%;
  height: auto;
  border: 1px solid var(--border-strong);
  border-radius: 14px;
}
.guide-shot img { max-height: 400px; object-fit: contain; width: auto; }
.guide-shot img[src$="/setup.webp"], .guide-viewer img.guide-setup-crop {
  border: 0;
  border-radius: 0;
  clip-path: inset(1% round 9% / 7.3%);
}
.guide-shot figcaption { color: var(--text-secondary); font-size: .86rem; margin-top: 5px; }
.guide-figure-pair { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; align-items: start; }
.guide-motion {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px 15px;
}
.guide-motion p { font-size: .88rem; color: var(--text-secondary); }
.guide-media-button, .guide-viewer button {
  display: inline-block;
  background: var(--bg-card);
  color: var(--guide-ink);
  border: 1px solid var(--border-strong);
  border-radius: 7px;
  font: inherit;
  font-size: .9rem;
  padding: 6px 11px;
  cursor: pointer;
}
.guide-next {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: end;
  gap: 10px 18px;
  border-top: 1px solid var(--border);
  margin-top: 25px;
  padding-top: 14px;
  font-size: .93rem;
}
.guide-next span { display: block; color: var(--text-secondary); }

.guide-viewer {
  position: fixed;
  inset: 0;
  margin: auto;
  max-width: min(94vw, 980px);
  max-height: 92vh;
  padding: 12px;
  border: 1px solid var(--border-strong);
  border-radius: 16px;
  background: var(--bg-card);
  color: var(--text-primary);
}
.guide-viewer::backdrop { background: #172822c9; }
.guide-viewer form { display: flex; align-items: center; justify-content: end; gap: 9px; margin-bottom: 10px; }
.guide-viewer img { max-height: 74vh; object-fit: contain; margin: auto; }

@media (max-width: 930px) {
  .guide-doc {
    grid-template-columns: 205px minmax(0, 1fr);
    grid-template-areas: "crumb crumb" "side title" "side toc" "side article";
    grid-template-rows: auto auto auto 1fr;
  }
  .guide-in-page { position: static; padding-left: 10px; max-height: none; }
  .guide-in-page ul { display: flex; flex-wrap: wrap; }
}
@media (max-width: 650px) {
  .guide-page .container { padding-inline: 18px; }
  .guide-landing { padding-block: 87px 28px; }
  .guide-intro, .guide-feature, .guide-catalog { grid-template-columns: minmax(0, 1fr); }
  .guide-catalog { gap: 16px; }
  .guide-doc {
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas: "crumb" "side" "title" "toc" "article";
    padding-top: 80px;
  }
  .guide-sidebar { position: static; max-height: none; padding: 4px 8px; }
  .guide-doc-title { padding-bottom: 14px; }
  .guide-three, .guide-figure-pair { grid-template-columns: minmax(0, 1fr); gap: 5px; }
}
@media (prefers-reduced-motion: reduce) {
  html:has(.guide-page) { scroll-behavior: auto; }
}
.portal-guide-panel .guide-kicker { font-size: .8rem; font-weight: 750; letter-spacing: .09em; }

/* System overview and chapter index */
.guide-system-overview {
  padding: 0 0 26px;
}
.guide-system-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 14px 22px;
  margin-bottom: 14px;
}
.guide-system-heading h2,
.guide-contents > h2 {
  font-size: clamp(1.4rem, 3.3vw, 1.9rem);
  line-height: 1.3;
}
.guide-system-heading p,
.guide-contents > p {
  color: var(--text-secondary);
  margin-top: 6px;
}
.guide-system-heading > a { flex: none; text-decoration: underline; text-underline-offset: .25em; }
.guide-system-flow {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  list-style: none;
}
.guide-system-flow a {
  display: flex;
  flex-direction: column;
  height: 100%;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-top: 3px solid var(--teal);
  border-radius: 8px;
  background: var(--bg-card);
}
.guide-system-flow a:hover { background: var(--guide-surface); }
.guide-system-flow small { font-size: .82rem; color: var(--guide-ink); }
.guide-system-flow strong { line-height: 1.4; margin: 4px 0; }
.guide-system-flow span,
.guide-category-lead { font-size: .9rem; color: var(--text-secondary); }
.guide-contents { padding: 32px 0 0; }
.guide-contents .guide-catalog { margin-top: 18px; }
.guide-catalog h3 {
  font-size: 1.18rem;
  line-height: 1.4;
  display: flex;
  gap: 9px;
  align-items: baseline;
  padding: 9px 0 4px;
}
.guide-catalog .guide-chapter-number {
  color: var(--guide-ink);
  font-variant-numeric: tabular-nums;
  font-size: .85rem;
}
.guide-category-lead { border-bottom: 1px solid var(--border-strong); padding-bottom: 9px; }
.guide-role-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}
.guide-role-grid > div {
  background: var(--guide-surface);
  border-radius: 8px;
  padding: 12px 14px;
}
.guide-role-grid dt,
.guide-reference dt { font-weight: 700; }
.guide-role-grid dt { color: var(--guide-ink); }
.guide-reference > div {
  display: grid;
  grid-template-columns: minmax(105px, .4fr) 1fr;
  gap: 4px 14px;
  padding: 9px 0;
  border-bottom: 1px solid var(--border);
}
.guide-reference dd,
.guide-role-grid dd { color: var(--text-secondary); font-size: .96rem; }
.guide-overview-doc > h3:not(:first-child) {
  margin-top: 24px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
}
@media (max-width: 950px) {
  .guide-system-flow { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 650px) {
  .guide-system-heading { align-items: start; flex-direction: column; }
  .guide-system-flow a { padding: 9px; }
  .guide-role-grid, .guide-reference > div { grid-template-columns: minmax(0, 1fr); }
}
