:root {
  --ink: #0d0d0d;
  --paper: #f5f0e8;
  --cream: #ede7d5;
  --accent: #c0392b;
  --accent2: #1a6b4a;
  --accent3: #1c4d8c;
  --muted: #6b6355;
  --border: #c9bfa8;
  --code-bg: #1e1e2e;
  --code-text: #cdd6f4;
  --tag-bg: #e8e0ce;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; }

img,
svg,
video {
  max-width: 100%;
  height: auto;
}

body {
  background: var(--paper);
  color: var(--ink);
  font-family: 'DM Sans', sans-serif;
  font-size: 17px;
  line-height: 1.75;
  overflow-x: hidden;
}

body::before {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0.04;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)'/%3E%3C/svg%3E");
  z-index: 1000;
}

header {
  background: var(--ink);
  color: var(--paper);
  padding: 0;
  overflow: hidden;
  position: relative;
}

.header-inner {
  max-width: 1100px;
  margin: 0 auto;
  padding: 80px 40px 70px;
  position: relative;
  z-index: 2;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.header-eyebrow {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  letter-spacing: 0.25em;
  text-transform: uppercase;
  color: #a09880;
  margin-bottom: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
}
.header-eyebrow::before {
  content: '';
  display: inline-block;
  width: 32px;
  height: 1px;
  background: var(--accent);
}

header h1 {
  font-family: 'Playfair Display', serif;
  font-size: clamp(42px, 6vw, 76px);
  font-weight: 900;
  line-height: 1.05;
  letter-spacing: -0.02em;
  max-width: 780px;
  text-align: center;
}

header h1 em {
  font-style: italic;
  color: #c9a96e;
}

.header-sub {
  margin-top: 28px;
  color: #a09880;
  font-size: 18px;
  max-width: 600px;
  font-weight: 300;
  margin-left: auto;
  margin-right: auto;
  text-align: center;
}

.header-meta {
  margin-top: 48px;
  display: flex;
  gap: 32px;
  flex-wrap: wrap;
  justify-content: center;
}

.header-copyright {
  margin-top: 56px;
  padding-top: 36px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  font-size: 11px;
  line-height: 1.7;
  color: #8a8278;
  max-width: 640px;
  font-weight: 300;
}
.header-copyright a {
  color: #a09880;
  text-decoration: underline;
  text-underline-offset: 2px;
  text-decoration-color: rgba(160, 152, 128, 0.45);
  transition: color 0.2s, text-decoration-color 0.2s;
}
.header-copyright a:hover {
  color: #c9a96e;
  text-decoration-color: rgba(201, 169, 110, 0.8);
}

.meta-item {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: #6b6355;
}
.meta-item span { color: var(--paper); font-weight: 600; }

.header-grid {
  position: absolute;
  right: 0;
  top: 0;
  bottom: 0;
  width: 380px;
  opacity: 0.06;
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  grid-template-rows: repeat(8, 1fr);
}
.header-grid div {
  border: 1px solid #fff;
}

/* ── Left contents nav (aligned with agentic guide) ── */
.section-nav {
  position: sticky;
  top: 24px;
  align-self: start;
  padding: 20px 18px;
  background: var(--cream);
  border: 1px solid var(--border);
  border-radius: 2px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.section-nav-title {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0 0 12px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
}

.section-nav a {
  display: flex;
  align-items: baseline;
  gap: 8px;
  padding: 8px 10px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  text-decoration: none;
  color: var(--ink);
  background: var(--paper);
  border: 1px solid transparent;
  border-radius: 2px;
  line-height: 1.35;
  transition: background 0.2s, color 0.2s, border-color 0.2s;
}

.section-nav a:hover {
  background: var(--ink);
  color: var(--paper);
  border-color: var(--ink);
}

.section-nav a.is-active {
  background: var(--ink);
  color: var(--paper);
  border-color: var(--ink);
}

.section-nav-num {
  font-size: 9px;
  color: var(--muted);
  flex-shrink: 0;
  min-width: 1.25rem;
}

.section-nav a:hover .section-nav-num,
.section-nav a.is-active .section-nav-num {
  color: rgba(245, 240, 232, 0.75);
}

/* ── ModelSure platform bar (classic ↔ agentic) ── */
.modelsure-wordmark {
  color: #c9a96e;
  font-weight: 600;
  letter-spacing: 0.12em;
}

.modelsure-bar {
  background: var(--cream);
  border-bottom: 1px solid var(--border);
  position: relative;
  z-index: 5;
}

.modelsure-bar-inner {
  max-width: 1100px;
  margin: 0 auto;
  padding: 12px 40px 14px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px 20px;
}

.modelsure-brand {
  font-family: 'Playfair Display', serif;
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--ink);
  text-decoration: none;
  letter-spacing: -0.02em;
}

.modelsure-brand:hover {
  color: var(--accent);
}

.modelsure-switch {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.modelsure-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  padding: 8px 16px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  text-decoration: none;
  color: var(--ink);
  background: var(--paper);
  border: 1px solid var(--border);
  border-radius: 2px;
  transition: background 0.2s, color 0.2s, border-color 0.2s;
}

.modelsure-btn:hover {
  background: var(--ink);
  color: var(--paper);
  border-color: var(--ink);
}

.modelsure-btn.is-active {
  background: var(--ink);
  color: var(--paper);
  border-color: var(--ink);
}

.page {
  max-width: 1180px;
  margin: 0 auto;
  padding: 72px 40px;
  display: grid;
  grid-template-columns: minmax(0, 220px) minmax(0, 1fr) minmax(0, 280px);
  gap: 40px 48px;
  align-items: start;
}

.page > .section-nav,
.page > .content,
.page > .sidebar {
  min-width: 0;
}

.sidebar {
  position: sticky;
  top: 32px;
}
.sidebar-card {
  border: 1px solid var(--border);
  padding: 24px;
  margin-bottom: 24px;
  background: var(--cream);
}
.sidebar-card h4 {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 16px;
}
.sidebar-stat {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}
.sidebar-stat:last-child { border-bottom: none; }
.sidebar-stat .val {
  font-family: 'JetBrains Mono', monospace;
  font-size: 15px;
  font-weight: 600;
  color: var(--accent);
}
.cheatsheet-item {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 10px 14px;
  align-items: start;
  font-size: 13px;
  padding: 8px 0;
  border-bottom: 1px dotted var(--border);
}
.cheatsheet-item:last-child { border: none; }
.cheatsheet-item .ci-key {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  color: var(--accent2);
  white-space: nowrap;
  padding-top: 2px;
}
.cheatsheet-item > span:last-child {
  min-width: 0;
  line-height: 1.5;
  text-align: left;
  word-wrap: break-word;
  overflow-wrap: break-word;
}

.section-label {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  letter-spacing: 0.3em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.section-label::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

h2 {
  font-family: 'Playfair Display', serif;
  font-size: clamp(28px, 3.5vw, 40px);
  font-weight: 700;
  line-height: 1.15;
  letter-spacing: -0.02em;
  margin-bottom: 20px;
}

h3 {
  font-family: 'Playfair Display', serif;
  font-size: clamp(18px, 2.5vw, 22px);
  font-weight: 700;
  margin-top: 40px;
  margin-bottom: 12px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}
h3 .h3-num {
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  background: var(--ink);
  color: var(--paper);
  padding: 2px 7px;
  border-radius: 2px;
  font-weight: 400;
  letter-spacing: 0;
}

p { margin-bottom: 16px; color: #2a2520; }

.callout {
  border-left: 3px solid var(--accent);
  padding: 16px 20px;
  background: var(--cream);
  margin: 28px 0;
  font-size: 15px;
}
.callout.green { border-color: var(--accent2); }
.callout.blue  { border-color: var(--accent3); }
.callout strong { display: block; margin-bottom: 4px; font-size: 12px; letter-spacing: 0.1em; text-transform: uppercase; font-family: 'JetBrains Mono', monospace; color: var(--accent); }
.callout.green strong { color: var(--accent2); }
.callout.blue  strong { color: var(--accent3); }

.technique-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin: 28px 0;
}
.tcard {
  border: 1px solid var(--border);
  padding: 24px;
  background: var(--paper);
  position: relative;
  overflow: hidden;
  transition: box-shadow 0.2s;
}
.tcard:hover { box-shadow: 4px 4px 0 var(--ink); }
.tcard::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
}
.tcard.red::before  { background: var(--accent); }
.tcard.green::before { background: var(--accent2); }
.tcard.blue::before { background: var(--accent3); }
.tcard.gold::before { background: #c9a96e; }
.tcard h4 {
  font-family: 'Playfair Display', serif;
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 10px;
}
.tcard p { font-size: 14px; color: var(--muted); margin: 0; }
.tcard .tc-tag {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 8px;
}
.tcard .tc-pros, .tcard .tc-cons {
  margin-top: 12px;
  font-size: 13px;
}
.tcard .tc-pros span { color: var(--accent2); margin-right: 4px; }
.tcard .tc-cons span { color: var(--accent);  margin-right: 4px; }

.code-wrap {
  background: var(--code-bg);
  border-radius: 0;
  margin: 24px 0;
  overflow: hidden;
  border: 1px solid #2a2a3e;
}
.code-header {
  background: #181825;
  padding: 10px 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid #2a2a3e;
}
.code-lang {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: #6c7086;
}
.code-dots { display: flex; gap: 6px; }
.code-dots span {
  width: 10px; height: 10px;
  border-radius: 50%;
  display: inline-block;
}
.code-dots span:nth-child(1) { background: #f38ba8; }
.code-dots span:nth-child(2) { background: #f9e2af; }
.code-dots span:nth-child(3) { background: #a6e3a1; }
pre {
  padding: 24px 20px;
  overflow-x: auto;
  font-family: 'JetBrains Mono', monospace;
  font-size: 13.5px;
  line-height: 1.7;
  color: var(--code-text);
}
.k  { color: #cba6f7; }
.fn { color: #89b4fa; }
.s  { color: #a6e3a1; }
.n  { color: #fab387; }
.c  { color: #585b70; font-style: italic; }
.v  { color: #cdd6f4; }
.cls{ color: #f9e2af; }
.op { color: #89dceb; }

.table-scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin: 24px 0;
  overscroll-behavior-x: contain;
}

.table-scroll .metrics-table {
  margin: 0;
  min-width: 36rem;
}

.metrics-table {
  width: 100%;
  border-collapse: collapse;
  margin: 24px 0;
  font-size: 14px;
}
.metrics-table thead tr {
  background: var(--ink);
  color: var(--paper);
}
.metrics-table th {
  padding: 12px 16px;
  text-align: left;
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  font-weight: 600;
}
.metrics-table td {
  padding: 11px 16px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}
.metrics-table tbody tr:nth-child(even) { background: var(--cream); }
.metrics-table tbody tr:hover { background: #e8dfc8; }
.badge {
  display: inline-block;
  padding: 2px 8px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  border-radius: 2px;
}
.badge.reg  { background: #dbeafe; color: #1c4d8c; }
.badge.cls  { background: #dcfce7; color: #1a6b4a; }
.badge.clus { background: #fef3c7; color: #92400e; }

.diagram-wrap {
  background: var(--cream);
  border: 1px solid var(--border);
  padding: clamp(16px, 4vw, 32px);
  margin: 28px 0;
  text-align: center;
}

.diagram-wrap svg {
  max-width: 100%;
  height: auto;
}
.diagram-title {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 20px;
}

.bv-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin: 24px 0;
}
.bv-card {
  border: 1px solid var(--border);
  padding: 20px;
  text-align: center;
}
.bv-card .bv-title {
  font-family: 'Playfair Display', serif;
  font-size: 16px;
  font-weight: 700;
  margin-bottom: 8px;
}
.bv-card .bv-sub { font-size: 12px; color: var(--muted); margin-bottom: 16px; }

.checklist {
  list-style: none;
  margin: 20px 0;
}
.checklist li {
  padding: 10px 0;
  border-bottom: 1px dotted var(--border);
  display: flex;
  align-items: flex-start;
  gap: 12px;
  font-size: 15px;
}
.checklist li:last-child { border: none; }
.checklist li::before {
  content: '✓';
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  color: var(--accent2);
  flex-shrink: 0;
  margin-top: 3px;
  font-weight: 600;
}

.step-flow {
  display: flex;
  flex-direction: column;
  gap: 0;
  margin: 28px 0;
  border: 1px solid var(--border);
  overflow: hidden;
}
.step-item {
  display: grid;
  grid-template-columns: 60px 1fr;
  border-bottom: 1px solid var(--border);
}
.step-item:last-child { border-bottom: none; }
.step-num {
  background: var(--ink);
  color: var(--paper);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'JetBrains Mono', monospace;
  font-size: 13px;
  font-weight: 600;
}
.step-body {
  padding: 20px 24px;
  background: var(--paper);
}
.step-body strong {
  display: block;
  font-size: 15px;
  margin-bottom: 4px;
}
.step-body p {
  font-size: 13px;
  color: var(--muted);
  margin: 0;
}

.cluster-metrics {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin: 24px 0;
}
.cm-card {
  border: 1px solid var(--border);
  padding: 20px;
  text-align: center;
  background: var(--cream);
}
.cm-card .cm-val {
  font-family: 'JetBrains Mono', monospace;
  font-size: 28px;
  font-weight: 600;
  color: var(--accent);
  display: block;
  margin-bottom: 4px;
}
.cm-card .cm-name { font-size: 13px; color: var(--muted); }

footer {
  background: var(--ink);
  color: #6b6355;
  text-align: center;
  padding: 40px;
  font-size: 13px;
  font-family: 'JetBrains Mono', monospace;
  letter-spacing: 0.05em;
  margin-top: 40px;
  border-top: 3px solid var(--accent);
  display: flex;
  flex-direction: column;
  align-items: center;
}

footer span { color: var(--paper); }

.footer-tagline {
  margin: 0;
  max-width: 900px;
}

.footer-tagline .modelsure-brand-inline {
  color: var(--paper);
  font-weight: 600;
  text-decoration: none;
}

.footer-tagline .modelsure-brand-inline:hover {
  color: #c9a96e;
}

.footer-copyright {
  margin: 14px 0 0;
  padding: 0;
  border: none;
  max-width: 720px;
  margin-left: auto;
  margin-right: auto;
  text-align: center;
  font-family: 'DM Sans', sans-serif;
  font-size: 11px;
  line-height: 1.65;
  letter-spacing: 0.02em;
  color: #8a8278;
  font-weight: 300;
}

.footer-copyright a {
  color: #a09880;
  text-decoration: underline;
  text-underline-offset: 2px;
  text-decoration-color: rgba(160, 152, 128, 0.45);
  transition: color 0.2s, text-decoration-color 0.2s;
}

.footer-copyright a:hover {
  color: #c9a96e;
  text-decoration-color: rgba(201, 169, 110, 0.8);
}

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(24px); }
  to   { opacity: 1; transform: translateY(0); }
}
.content section {
  margin-bottom: 80px;
  animation: fadeUp 0.5s ease both;
}
.content section:nth-child(1) { animation-delay: 0.05s; }
.content section:nth-child(2) { animation-delay: 0.10s; }
.content section:nth-child(3) { animation-delay: 0.15s; }
.content section:nth-child(4) { animation-delay: 0.20s; }
.content section:nth-child(5) { animation-delay: 0.25s; }
.content section:nth-child(6) { animation-delay: 0.30s; }
.content section:nth-child(7) { animation-delay: 0.35s; }

@media (max-width: 1150px) {
  .page {
    grid-template-columns: minmax(0, 200px) minmax(0, 1fr) minmax(0, 260px);
    gap: 32px 36px;
    padding: 56px 28px;
  }
}

@media (max-width: 900px) {
  .modelsure-bar-inner {
    padding: 12px 24px 14px;
  }
  .page {
    grid-template-columns: 1fr;
    gap: 40px;
    padding: 48px 24px;
  }
  .section-nav {
    position: static;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    padding: 14px 16px;
    order: -1;
  }
  .section-nav-title {
    width: 100%;
    margin-bottom: 4px;
    padding-bottom: 8px;
  }
  .section-nav a {
    flex: 1 1 auto;
    justify-content: center;
    min-width: min(100%, 140px);
    text-align: center;
  }
  .sidebar { position: static; }
  .technique-grid { grid-template-columns: 1fr; }
  .cluster-metrics { grid-template-columns: 1fr 1fr; }
  .bv-grid { grid-template-columns: 1fr; }
  .header-inner { padding: 48px 24px; }
}

@media (max-width: 640px) {
  .modelsure-bar-inner {
    flex-direction: column;
    align-items: stretch;
    padding: 12px 16px 14px;
  }
  .modelsure-switch {
    justify-content: center;
  }
  body {
    font-size: 16px;
    line-height: 1.7;
  }
  .page {
    padding: 36px 16px;
  }
  .header-inner {
    padding: 40px 16px 44px;
  }
  .header-sub {
    font-size: 16px;
  }
  .header-meta {
    gap: 16px 24px;
    justify-content: center;
  }
  .cluster-metrics {
    grid-template-columns: 1fr;
  }
  .section-nav a {
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 8px 14px;
  }
  .metrics-table {
    font-size: 12px;
  }
  .metrics-table th,
  .metrics-table td {
    padding: 9px 10px;
  }
  .code-wrap pre {
    font-size: 12.5px;
    padding: 16px 14px;
  }
  .sidebar-card {
    padding: 18px 16px;
  }
  footer {
    padding: 28px 16px;
    font-size: 12px;
  }
}

@media (max-width: 420px) {
  .meta-item {
    letter-spacing: 0.08em;
  }
  .table-scroll .metrics-table {
    min-width: 32rem;
  }
}
