:root {
  --bg: #f7f8fb;
  --panel: #ffffff;
  --text: #1a1917;
  --muted: #746b64;
  --border: #e2ddd7;
  --accent: #c8352a;
  --accent-soft: #fbebe9;
  --green: #8f2a22;
  --green-soft: #f7e6e4;
  --nav: #1a1917;
  --nav-muted: #a89f98;
  --shadow: 0 20px 50px rgba(26, 25, 23, 0.08);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.6;
}

a {
  color: inherit;
}

code {
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
}

.skip-link {
  position: fixed;
  top: 8px;
  left: 8px;
  z-index: 20;
  transform: translateY(-140%);
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px 10px;
}

.skip-link:focus {
  transform: translateY(0);
}

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

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  background: var(--nav);
  color: #f9fafb;
  padding: 26px 20px;
  display: flex;
  flex-direction: column;
  gap: 28px;
  overflow-y: auto;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  color: #f9fafb;
  text-decoration: none;
}

.brand-mark {
  width: 38px;
  height: 38px;
  border-radius: 8px;
  overflow: hidden;
  flex-shrink: 0;
}

.brand-mark img {
  display: block;
  width: 100%;
  height: 100%;
}

.brand-name {
  display: block;
  font-weight: 750;
  line-height: 1.2;
}

.brand-subtitle,
.sidebar-note {
  display: block;
  color: var(--nav-muted);
  font-size: 0.84rem;
}

.nav-list {
  display: grid;
  gap: 6px;
}

.nav-group,
.nav-page {
  border-radius: 7px;
}

.nav-group summary {
  list-style: none;
  border-radius: 7px;
}

.nav-group summary::-webkit-details-marker {
  display: none;
}

.nav-page,
.nav-group summary a,
.nav-group > a {
  display: block;
  color: #e5e7eb;
  text-decoration: none;
  border-radius: 7px;
  padding: 9px 10px;
  font-size: 0.95rem;
}

.nav-page,
.nav-group summary a {
  font-weight: 700;
}

.nav-group > a {
  margin: 2px 0 0 12px;
  padding: 6px 10px;
  color: var(--nav-muted);
  font-size: 0.86rem;
}

.nav-group summary a::before {
  content: ">";
  display: inline-block;
  width: 16px;
  color: var(--nav-muted);
}

.nav-group[open] summary a::before {
  content: "v";
}

.nav-group summary a:hover,
.nav-page:hover,
.nav-page.active,
.nav-group > a:hover,
.nav-group.active summary a,
.nav-group > a.active {
  background: rgba(255, 255, 255, 0.1);
}

.nav-group.active summary a {
  color: #ffffff;
}

.nav-page.active,
.nav-group > a.active {
  color: #ffffff;
}

.sidebar-note {
  margin-top: auto;
  border-top: 1px solid rgba(255, 255, 255, 0.13);
  padding-top: 18px;
}

.content {
  min-width: 0;
  padding: 42px clamp(22px, 5vw, 72px) 72px;
}

.doc-section {
  max-width: 1100px;
  margin: 0 auto 34px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: clamp(24px, 4vw, 46px);
  scroll-margin-top: 24px;
}

.doc-section > :target {
  scroll-margin-top: 24px;
}

.doc-section [id] {
  scroll-margin-top: 24px;
}

.hero-section {
  padding-top: clamp(34px, 5vw, 58px);
}

.eyebrow {
  color: var(--green);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  margin-bottom: 8px;
  text-transform: uppercase;
}

h1,
h2 {
  line-height: 1.18;
  margin: 0;
}

h1 {
  max-width: 880px;
  font-size: clamp(2rem, 4vw, 3.2rem);
  letter-spacing: 0;
}

h2 {
  font-size: 1.05rem;
  margin-bottom: 8px;
}

h3 {
  line-height: 1.2;
  margin: 0;
}

.subsection-title {
  border-top: 1px solid var(--border);
  color: #1a1917;
  font-size: 1.35rem;
  margin-top: 30px;
  padding-top: 24px;
  scroll-margin-top: 24px;
}

.lead + .subsection-title {
  margin-top: 28px;
}

.inline-heading {
  color: #1a1917;
  font-size: 1.05rem;
  margin-top: 24px;
  margin-bottom: 8px;
}

p {
  margin: 0;
}

.lead {
  max-width: 820px;
  margin-top: 18px;
  color: #4a4139;
  font-size: 1.12rem;
}

.callout {
  margin: 24px 0;
  padding: 16px 18px;
  border: 1px solid #e3b8b2;
  background: var(--green-soft);
  border-radius: 8px;
}

.download-link {
  color: var(--accent);
  font-weight: 800;
  text-decoration: none;
}

.download-link:hover {
  text-decoration: underline;
}

.pelorus-callout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 148px;
  align-items: center;
  gap: 18px;
}

.pelorus-callout img {
  display: block;
  width: 148px;
  height: auto;
}

.two-column {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
  margin-top: 24px;
}

.two-column > div,
.concept-grid article {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 18px;
  background: #faf9f7;
}

.api-table {
  width: 100%;
  border-collapse: collapse;
  margin: 18px 0 24px;
  font-size: 0.92rem;
}

.api-table th,
.api-table td {
  border: 1px solid var(--border);
  padding: 10px 12px;
  text-align: left;
  vertical-align: top;
}

.api-table th {
  background: #faf9f7;
  color: #1a1917;
  font-size: 0.82rem;
  text-transform: uppercase;
}

.api-table td:first-child {
  width: 48%;
}

.api-table code {
  white-space: normal;
  word-break: break-word;
}

.concept-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  margin-top: 28px;
}

.concept-grid p,
.two-column p {
  color: var(--muted);
  font-size: 0.95rem;
}

.concept-layer-model {
  display: grid;
  gap: 12px;
  margin-top: 28px;
}

.concept-layer {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #faf9f7;
  padding: 18px;
}

.concept-layer-header {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  text-align: center;
}

.concept-layer-header > div {
  min-width: 0;
}

.concept-layer-header p {
  color: var(--muted);
  font-size: 0.95rem;
}

.concept-icon {
  width: 38px;
  height: 38px;
  border-radius: 8px;
  display: inline-grid;
  place-items: center;
  flex: 0 0 auto;
  font-weight: 850;
}

.concept-badge {
  border-radius: 999px;
  display: inline-grid;
  place-items: center;
  min-height: 42px;
  padding: 8px 18px;
  font-weight: 850;
  line-height: 1.15;
  text-align: center;
}

.cluster-icon,
.extract-icon {
  background: var(--green-soft);
  color: var(--green);
  border: 1px solid #e3b8b2;
}

.intent-icon {
  background: var(--accent-soft);
  color: #8f2a22;
  border: 1px solid #e0b48a;
}

.chunk-icon {
  background: #faf9f7;
  color: #5c5049;
  border: 1px solid #ded7d0;
}

.cluster-layer {
  margin-left: clamp(28px, 8vw, 120px);
  margin-right: clamp(28px, 8vw, 120px);
  background: var(--green-soft);
  border-color: #e3b8b2;
}

.intent-layer {
  margin-left: clamp(12px, 4vw, 56px);
  margin-right: clamp(12px, 4vw, 56px);
  background: #faf0e4;
  border-color: #e0b48a;
}

.chunk-layer {
  background: #faf9f7;
}

.cluster-band,
.intent-row,
.chunk-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
  margin-top: 16px;
}

.cluster-band span,
.intent-row span {
  border-radius: 6px;
  padding: 8px 12px;
  font-size: 0.9rem;
  font-weight: 700;
}

.cluster-band span {
  background: #ffffff;
  color: var(--green);
  border: 1px solid #e3b8b2;
}

.intent-row span {
  background: #ffffff;
  color: #8f2a22;
  border: 1px solid #e0b48a;
}

.chunk-row span {
  width: 58px;
  height: 42px;
  border: 1px solid #ded7d0;
  border-radius: 6px;
  background: #ffffff;
  display: grid;
  align-content: center;
  gap: 5px;
  padding: 8px;
}

.chunk-row i {
  display: block;
  height: 3px;
  border-radius: 999px;
  background: #ded7d0;
}

.chunk-row i:nth-child(1) {
  width: 100%;
}

.chunk-row i:nth-child(2) {
  width: 74%;
}

.chunk-row i:nth-child(3) {
  width: 46%;
}

.chunk-row span:nth-child(3n + 1) i:nth-child(2) {
  width: 86%;
}

.chunk-row span:nth-child(3n + 2) i:nth-child(3) {
  width: 62%;
}

.chunk-row span:nth-child(4n) i:nth-child(1) {
  width: 82%;
}

.extract-anatomy {
  margin-top: 28px;
}

.extract-shell {
  border: 1px solid #e3b8b2;
  border-radius: 8px;
  border-color: #e3b8b2;
  background: linear-gradient(180deg, #ffffff, var(--green-soft));
  padding: 0 0 22px;
  overflow: hidden;
}

.extract-shell-title {
  display: flex;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid #e3b8b2;
  background: rgba(255, 255, 255, 0.82);
  padding: 18px 22px;
}

.extract-shell-title p {
  color: var(--muted);
  font-size: 0.92rem;
}

.extract-parts {
  display: grid;
  gap: 12px;
  margin: 20px 22px 0;
}

.extract-parts div {
  border-top: 1px solid rgba(15, 118, 110, 0.18);
  background: rgba(255, 255, 255, 0.56);
  padding: 16px 2px 4px;
}

.extract-parts div:first-child {
  border-top: 0;
}

.extract-parts strong,
.extract-parts span {
  display: block;
}

.extract-parts strong {
  color: #1a1917;
  margin-bottom: 4px;
}

.extract-parts span {
  color: var(--muted);
  font-size: 0.9rem;
}

.extract-parts em {
  display: block;
  color: #5c5049;
  font-size: 0.88rem;
  font-style: normal;
  margin-top: 8px;
}

.attachment-diagram {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
  margin-top: 28px;
}

.attachment-path {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #faf9f7;
  padding: 18px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 42px minmax(0, 1fr);
  align-items: center;
  gap: 0;
}

.attachment-target,
.attachment-extract {
  min-height: 138px;
  border-radius: 8px;
  padding: 16px;
  display: grid;
  align-content: center;
  text-align: center;
}

.attachment-target strong,
.attachment-extract strong,
.attachment-target span,
.attachment-extract span,
.attachment-target em,
.attachment-extract em {
  display: block;
}

.attachment-target strong,
.attachment-extract strong {
  color: #1a1917;
  font-size: 1rem;
  margin-bottom: 8px;
}

.attachment-target span,
.attachment-extract span {
  color: #1a1917;
  font-weight: 800;
  font-size: 1rem;
  margin-bottom: 6px;
}

.attachment-target em,
.attachment-extract em {
  color: var(--muted);
  font-size: 0.9rem;
  font-style: normal;
}

.intent-target {
  border: 1px solid #e0b48a;
  background: var(--accent-soft);
}

.cluster-target {
  border: 1px solid #e3b8b2;
  background: var(--green-soft);
}

.attachment-extract {
  border: 1px solid #e2ddd7;
  background: #ffffff;
}

.attachment-link {
  height: 2px;
  background: #ded7d0;
  position: relative;
}

.attachment-link::after {
  content: "";
  position: absolute;
  right: -1px;
  top: -4px;
  width: 10px;
  height: 10px;
  border-right: 2px solid #ded7d0;
  border-top: 2px solid #ded7d0;
  transform: rotate(45deg);
}

.diagram-image {
  display: block;
  width: 100%;
  min-width: 760px;
  height: auto;
}

.diagram {
  margin: 30px 0 0;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: linear-gradient(180deg, #ffffff, #faf9f7);
  padding: 18px;
  overflow-x: auto;
}

figcaption {
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 700;
  margin-bottom: 14px;
}

.flow-diagram {
  display: grid;
  grid-template-columns: minmax(100px, 1fr) 28px minmax(110px, 1fr) 28px minmax(140px, 1fr) 28px minmax(130px, 1fr) 28px minmax(120px, 1fr) 28px minmax(120px, 1fr);
  align-items: center;
  min-width: 900px;
}

.flow-step {
  border: 1px solid var(--border);
  background: #fff;
  border-radius: 8px;
  padding: 12px 14px;
  min-height: 48px;
  display: grid;
  place-items: center;
  text-align: center;
  font-weight: 650;
}

.flow-step.start {
  background: #faf0e4;
}

.flow-step.accent {
  border-color: #e0b48a;
  background: var(--accent-soft);
  color: #8f2a22;
}

.flow-step.muted {
  background: #faf9f7;
  color: #5c5049;
}

.flow-link {
  height: 2px;
  background: #ded7d0;
  position: relative;
}

.flow-link::after {
  content: "";
  position: absolute;
  right: -1px;
  top: -4px;
  width: 10px;
  height: 10px;
  border-right: 2px solid #ded7d0;
  border-top: 2px solid #ded7d0;
  transform: rotate(45deg);
}

.corpus-layer-diagram {
  display: grid;
  gap: 14px;
}

.corpus-layer-diagram .query-node {
  justify-self: center;
}

.query-node.small {
  min-width: 132px;
  padding: 10px 16px;
}

.match-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.diagram-node {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #ffffff;
  padding: 16px;
  min-height: 122px;
  display: grid;
  align-content: center;
  gap: 6px;
}

.diagram-node strong {
  color: #1a1917;
}

.diagram-node span {
  color: var(--muted);
  font-size: 0.94rem;
}

.diagram-node.source {
  background: #faf9f7;
}

.diagram-node.intent {
  border-color: #e0b48a;
  background: var(--accent-soft);
}

.diagram-node.intent strong {
  color: #8f2a22;
}

.diagram-node.extract {
  border-color: #e3b8b2;
  background: var(--green-soft);
}

.diagram-node.extract strong {
  color: var(--green);
}

.corpus-base {
  border: 1px solid #ded7d0;
  border-radius: 8px;
  background: #faf9f7;
  padding: 18px;
  text-align: center;
  display: grid;
  gap: 4px;
}

.corpus-base strong {
  color: #1a1917;
}

.corpus-base span {
  color: var(--muted);
  font-size: 0.94rem;
}

.tier-diagram {
  display: grid;
  gap: 16px;
}

.query-node {
  width: fit-content;
  min-width: 150px;
  margin: 0 auto;
  border: 1px solid #e0b48a;
  background: #faf0e4;
  color: #8f2a22;
  border-radius: 999px;
  padding: 12px 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  font-weight: 800;
  position: relative;
}

.query-node::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: -17px;
  width: 2px;
  height: 17px;
  background: #ded7d0;
}

.query-icon {
  width: 18px;
  height: 18px;
  border: 2px solid currentColor;
  border-radius: 50%;
  position: relative;
  flex: 0 0 auto;
}

.query-icon::after {
  content: "";
  position: absolute;
  width: 8px;
  height: 2px;
  right: -6px;
  bottom: -3px;
  background: currentColor;
  transform: rotate(45deg);
}

.tier-stack {
  display: grid;
  gap: 12px;
}

.tier-row {
  border: 1px solid var(--border);
  background: #ffffff;
  border-radius: 8px;
  padding: 15px 16px;
}

.tier-row.primary {
  border-color: #e3b8b2;
  background: var(--green-soft);
}

.tier-row.accent {
  border-color: #e0b48a;
  background: var(--accent-soft);
}

.tier-row span {
  display: block;
  font-weight: 800;
  margin-bottom: 4px;
}

.tier-row p {
  color: var(--muted);
  font-size: 0.95rem;
}

.term-list {
  margin: 24px 0 0;
  padding-left: 20px;
  color: #4a4139;
}

.term-list li + li {
  margin-top: 12px;
}

.term-list strong {
  color: var(--green);
}

.term-list.compact-list {
  margin-top: 12px;
}

.table-wrap {
  overflow-x: auto;
  margin-top: 24px;
}

table {
  width: 100%;
  min-width: 700px;
  border-collapse: collapse;
}

th,
td {
  border-bottom: 1px solid var(--border);
  padding: 13px 12px;
  text-align: left;
  vertical-align: top;
}

th {
  color: #5c5049;
  font-size: 0.83rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

td {
  color: #4a4139;
}

.code-sample {
  margin: 24px 0 0;
  border: 1px solid #e0b48a;
  border-radius: 8px;
  background: #1a1917;
  color: #e5e7eb;
  padding: 16px 18px;
  overflow-x: auto;
  line-height: 1.55;
  font-size: 0.9rem;
}

@media (max-width: 980px) {
  .docs-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: relative;
    height: auto;
  }

  .nav-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .concept-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .attachment-diagram {
    grid-template-columns: 1fr;
  }

  .extract-anatomy {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 680px) {
  .content {
    padding: 18px 14px 42px;
  }

  .doc-section {
    padding: 22px 16px;
  }

  .nav-list,
  .two-column,
  .attachment-path,
  .concept-grid,
  .extract-parts,
  .pelorus-callout,
  .tier-diagram,
  .match-row {
    grid-template-columns: 1fr;
  }

  .pelorus-callout img {
    justify-self: center;
    width: 132px;
  }

  .cluster-layer,
  .intent-layer {
    margin-left: 0;
    margin-right: 0;
  }

  .attachment-link {
    width: 2px;
    height: 28px;
    justify-self: center;
  }

  .attachment-link::after {
    right: -4px;
    top: 17px;
    transform: rotate(135deg);
  }
}

/* GTA additions: section labels and coming-soon entries */
.nav-label {
  margin: 18px 10px 6px;
  color: var(--nav-muted);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.09em;
  text-transform: uppercase;
}

.nav-soon {
  color: var(--nav-muted);
  cursor: default;
  opacity: 0.75;
}

.nav-soon:hover {
  color: var(--nav-muted);
  background: none;
}

.nav-soon .soon-tag {
  font-size: 0.68rem;
  opacity: 0.8;
  margin-left: 6px;
}
