.doc-grid {
  display: grid;
  grid-template-columns: minmax(0, var(--readcol)) var(--railcol);
  gap: var(--s8);
  align-items: start;
  justify-content: space-between;
  width: 100%;
  padding-bottom: var(--s8);
}

.doc-grid:not(:has(.toc-rail a[href^="#"])) {
  grid-template-columns: minmax(0, var(--readcol));
}

.doc-grid:not(:has(.toc-rail a[href^="#"])) > .vnc-doc-rail {
  display: none;
}

.toc-rail {
  position: sticky;
  top: calc(var(--header-h) + var(--s5));
  width: var(--railcol);
  border-left: 1px solid var(--line);
  padding-left: var(--s5);
  font-size: 14px;
}

@media (min-width: 1024px) {
  /* The inner nav cannot travel inside a column that shrink-wraps it. */
  .doc-grid.e-con:not(.vnc-tool-template) > .vnc-doc-rail.e-con {
    position: sticky;
    top: calc(var(--header-h) + var(--s5));
  }

  /* Tool facts scroll normally; only the contents widget sticks. */
  .doc-grid.e-con.vnc-tool-template > .vnc-doc-rail.e-con {
    align-self: stretch;
  }

  .doc-grid.e-con.vnc-tool-template > .vnc-doc-rail.e-con > .elementor-widget-vnc_toc_rail {
    position: sticky;
    top: calc(var(--header-h) + var(--s5));
    flex-grow: 0;
    align-self: start;
    margin-top: var(--s5);
  }
}

.toc-rail h2 {
  margin: 0 0 var(--s3);
  color: var(--muted);
  font-family: var(--font-display);
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.08em;
  line-height: 1.4;
  text-transform: uppercase;
}

.toc-rail ul,
.toc-mobile ul {
  display: grid;
  gap: var(--s2);
  margin: 0;
  padding: 0;
  list-style: none;
}

.toc-rail a,
.toc-mobile a {
  color: var(--muted);
  text-decoration: none;
}

.toc-rail a:hover,
.toc-mobile a:hover {
  color: var(--accent-ink);
  text-decoration: underline;
}

.toc-rail a:focus-visible,
.toc-mobile a:focus-visible,
.toc-mobile summary:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.toc-mobile {
  display: none;
  padding: var(--s3) var(--s4);
  border: 1px solid var(--line);
  border-radius: var(--r-card);
  background: var(--bg-raise);
}

.toc-mobile summary {
  color: var(--ink);
  cursor: pointer;
  font-family: var(--font-display);
  font-weight: 700;
}

.toc-mobile ul {
  margin-top: var(--s3);
}

.prose {
  min-width: 0;
  color: var(--text);
  font-family: var(--font-body);
  font-size: 17px;
  line-height: 1.65;
}

.prose > * {
  margin-bottom: 0;
}

.prose > * + * {
  margin-top: var(--s4);
}

.prose table {
  width: 100%;
  margin: var(--s5) 0;
  border-collapse: collapse;
  font-size: 15px;
}

.prose th,
.prose td {
  padding: var(--s3) var(--s4);
  border: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

.prose td,
.prose table tbody > tr:nth-child(odd) > td,
.prose table tbody tr:hover > td {
  background: none;
}

.prose th,
.prose table tbody > tr:nth-child(odd) > th,
.prose table tbody tr:hover > th {
  background: var(--panel);
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 14px;
}

/* Outrank Hello's thead:first-child tr:first-child cell border. */
.prose table thead:first-child tr:first-child th,
.prose table thead:first-child tr:first-child td,
.prose table caption + thead tr:first-child th,
.prose table caption + thead tr:first-child td,
.prose table colgroup + thead tr:first-child th,
.prose table colgroup + thead tr:first-child td {
  border-block-start: 1px solid var(--line);
}

.prose h2 {
  margin-top: var(--s7);
  padding-top: var(--s5);
  border-top: 1px solid var(--line-soft);
  color: var(--ink);
  font-family: var(--font-display);
  font-size: 30px;
  line-height: 1.2;
}

/* Legal template: first prose heading only. */
.elementor-element-7a1e0001 .prose > h2:first-child {
  margin-top: 0;
  padding-top: var(--s4);
}

.prose h3 {
  margin-top: var(--s6);
  color: var(--ink);
  font-family: var(--font-display);
  font-size: 21px;
  line-height: 1.3;
}

.prose ul,
.prose ol {
  padding-left: var(--s5);
}

.prose li + li {
  margin-top: var(--s2);
}

.prose .lead {
  color: var(--ink);
  font-size: 19px;
}

.prose a {
  color: var(--accent-ink);
}

.prose :is(p, li, td, dt, dd) a:not(.btn):not(.button),
.spec-card dd a {
  text-decoration: underline;
  text-underline-offset: 0.15em;
}

.spec-card dd > a {
  align-items: center;
  display: inline-flex;
  min-height: 24px;
}

.prose a:hover {
  color: var(--accent);
}

.prose a:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* Registered seeded images and the HTML-only RFB message diagram. */
.prose .seeded-image,
.prose .rfb-diagram {
  box-sizing: border-box;
  min-width: 0;
  max-width: 100%;
  margin: var(--s5) 0;
  border: 1px solid var(--line);
  border-radius: var(--r-card);
  background: var(--bg);
  color: var(--text);
  overflow-wrap: anywhere;
}

.seeded-image img {
  display: block;
  max-width: 100%;
  height: auto;
  margin-inline: auto;
}

.seeded-image--mark img {
  max-width: calc(100% - var(--s4) - var(--s4));
  margin: var(--s5) auto;
}

.seeded-image figcaption {
  color: var(--text);
  padding: var(--s3) var(--s4);
  border-top: 1px solid var(--line);
}

.seeded-image__attribution {
  display: block;
  margin-top: var(--s2);
}

.seeded-image__attribution a {
  text-decoration: underline;
  text-underline-offset: 0.15em;
}

.prose .rfb-diagram {
  padding: var(--s4);
}

.rfb-diagram figcaption,
.rfb-diagram__phase > p {
  color: var(--ink);
  font-family: var(--font-display);
  font-weight: 700;
}

.rfb-diagram__note,
.rfb-diagram__phase,
.rfb-diagram__alternative {
  margin-top: var(--s4);
}

.rfb-diagram__endpoints {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--s3);
  padding-block: var(--s3);
  border-block: 1px solid var(--line);
  color: var(--ink);
}

.rfb-diagram__endpoints > :last-child {
  text-align: right;
}

.prose .rfb-diagram__steps {
  margin: 0;
  padding: 0;
  list-style: none;
}

.rfb-diagram__step {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: var(--s1);
  padding: var(--s3);
  border-inline: 1px solid var(--line);
  background: var(--bg-raise);
}

.rfb-diagram__message {
  min-width: 0;
  color: var(--ink);
  font-family: var(--font-mono);
  white-space: normal;
}

.rfb-diagram__direction,
.rfb-diagram__detail {
  font-size: 0.875em;
}

.rfb-diagram__arrow {
  position: relative;
  display: block;
  margin-block: var(--s2);
  border-top: 2px solid var(--accent-ink);
}

.rfb-diagram__arrow::before,
.rfb-diagram__arrow::after {
  position: absolute;
  top: 0;
  width: var(--s2);
  height: var(--s2);
  border: solid var(--accent-ink);
  border-width: 2px 2px 0 0;
}

.rfb-diagram__step--to-server .rfb-diagram__arrow::after,
.rfb-diagram__step--both .rfb-diagram__arrow::after {
  right: 0;
  transform: translateY(-60%) rotate(45deg);
  content: "";
}

.rfb-diagram__step--to-viewer .rfb-diagram__arrow::before,
.rfb-diagram__step--both .rfb-diagram__arrow::before {
  left: 0;
  transform: translateY(-60%) rotate(-135deg);
  content: "";
}

.rfb-diagram__alternative summary {
  padding-block: var(--s2);
  color: var(--ink);
  cursor: pointer;
}

.rfb-diagram__alternative summary:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.diagram-slot,
.photo-slot {
  margin: var(--s5) 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--r-card);
}

.diagram-slot .slot-body,
.photo-slot .slot-body {
  display: flex;
  min-height: 220px;
  align-items: center;
  justify-content: center;
  padding: var(--s6);
  background: var(--bg-raise);
  text-align: center;
}

.slot-label {
  max-width: 420px;
  margin: 0;
  padding: var(--s3) var(--s4);
  border: 1px solid var(--line);
  border-radius: var(--r-ctl);
  background: var(--bg);
  color: var(--muted);
  font-size: 14px;
  line-height: 1.5;
}

.slot-label strong {
  display: block;
  margin-bottom: var(--s2);
  color: var(--ink);
  font-family: var(--font-display);
}

.slot-composed {
  position: relative;
  min-height: 260px;
  margin: var(--s5) 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--r-card);
  background: var(--bg-deep);
}

.slot-composed::before {
  position: absolute;
  inset: var(--s5) var(--s5) var(--s9);
  border: 1px solid var(--line);
  border-block-width: 1px 0;
  content: "";
}

.slot-composed::after {
  position: absolute;
  top: var(--s5);
  bottom: var(--s9);
  left: 50%;
  border-left: 1px solid var(--line);
  content: "";
}

.slot-composed .slot-caption {
  position: absolute;
  inset: auto 0 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(180px, auto);
  gap: var(--s1) var(--s4);
  align-items: end;
  padding: var(--s3) var(--s4);
  border-top: 1px solid var(--line);
  background: var(--bg);
}

.slot-composed .slot-kicker {
  grid-column: 1 / -1;
  color: var(--accent-ink);
  font-family: var(--font-mono);
  font-size: 11.5px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.slot-composed .slot-subject {
  color: var(--ink);
  font-weight: 600;
}

.slot-composed .slot-note {
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 11.5px;
}

@media (min-width: 900px) and (max-width: 1083px) {
  .doc-grid {
    grid-template-columns: minmax(0, calc(100% - var(--railcol) - var(--s5))) var(--railcol);
    gap: var(--s5);
  }
}

@media (max-width: 1023px) {
  .doc-grid,
  .doc-grid.e-con.vnc-tool-template:has(.spec-card) {
    grid-template-columns: minmax(0, 1fr);
    gap: var(--s5);
  }

  .toc-rail:not(.elementor-widget-table-of-contents) {
    display: none;
  }

  .vnc-doc-rail {
    order: -1;
  }

  .toc-rail.elementor-widget-table-of-contents {
    position: static;
    width: 100%;
    border-left: 0;
    padding-left: 0;
  }

  .toc-mobile {
    display: block;
  }
}

@media (max-width: 899px) {
  .prose {
    font-size: 16px;
  }

  .prose h2 {
    font-size: 24px;
  }

  .prose h3 {
    font-size: 19px;
  }
}

.quick-links {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s2);
  margin-top: var(--s4);
}

.quick-links a {
  min-height: 40px;
  display: inline-flex;
  align-items: center;
}

/* The shared tag styles elsewhere are limited to community widgets. */
.quick-links a.tag {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--accent-ink);
  background: var(--accent-wash);
  border: 1px solid var(--line);
  border-radius: var(--s1);
  padding: 1px 7px;
  text-decoration: none;
  white-space: nowrap;
}

.quick-links a.tag:hover {
  border-color: var(--accent);
  color: var(--accent-ink);
}

.vnc-reading-template .article-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--s2) var(--s4);
  color: var(--muted);
  font-size: 14px;
}

/* Single Page Doc only: what-is-vnc.html:123 inline metadata overrides. */
[data-id="d0c50001"] .vnc-reading-template .article-meta {
  margin-top: var(--s4);
  margin-bottom: 0;
  padding-bottom: 0;
  border-bottom: 0;
}

@media (max-width: 599px) {
  .vnc-doc-reading .prose pre,
  .vnc-doc-reading .prose .pre-copy-wrap > pre {
    max-width: 100%;
    overflow-x: auto;
    overflow-wrap: normal;
    white-space: pre;
  }

  .threat-model-table-wrap,
  .posture-table-wrap {
    overflow: visible;
  }

  .threat-model-table,
  .posture-table {
    border-collapse: separate;
    border-spacing: 0;
  }

  .threat-model-table thead,
  .posture-table thead {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    overflow: hidden;
    border: 0;
    clip: rect(0 0 0 0);
    white-space: nowrap;
  }

  .threat-model-table tbody,
  .posture-table tbody {
    display: grid;
    gap: var(--s4);
  }

  .threat-model-table tbody tr,
  .posture-table tbody tr {
    display: block;
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: var(--r-card);
    background: var(--bg);
  }

  .prose .threat-model-table tbody th,
  .prose .threat-model-table tbody td,
  .prose .posture-table tbody th,
  .prose .posture-table tbody td {
    display: block;
    width: 100%;
    padding: var(--s3) var(--s4);
    border: 0;
  }

  .prose .threat-model-table tbody th,
  .prose .posture-table tbody th {
    border-bottom: 1px solid var(--line);
  }

  .prose .threat-model-table tbody td + td,
  .prose .posture-table tbody td + td {
    border-top: 1px solid var(--line-soft);
  }

  .threat-model-table tbody td::before,
  .posture-table tbody td::before {
    display: block;
    margin-bottom: var(--s2);
    color: var(--muted);
    content: attr(data-label);
    font-family: var(--font-display);
    font-size: 13px;
    font-weight: 700;
  }

  .diagram-slot .slot-body,
  .photo-slot .slot-body {
    min-height: 180px;
    padding: var(--s5);
  }

  .slot-composed .slot-caption {
    grid-template-columns: minmax(0, 1fr);
  }
}

/* W5-FIX-41: these classes survive the document seed extractor. */
.prose .threat-model-table caption,
.prose .posture-table caption {
  caption-side: bottom;
  padding-top: var(--s3);
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 12.5px;
  text-align: left;
}

.prose .evidence-tier {
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 0.82em;
  white-space: nowrap;
}
