:root {
  color-scheme: light dark;
  --paper: #f6f5f1;
  --paper-alt: #eeece4;
  --tile: #dedbd0;
  --panel: #ffffff;
  --panel-soft: #faf9f5;
  --ink: #161510;
  --muted: #5d5a50;
  --accent: #5239c9;
  --accent-soft: rgba(82, 57, 201, 0.11);
  --accent-border: rgba(82, 57, 201, 0.28);
  --warm: #c94e1f;
  --focus: #5239c9;
  --checker-a: #e8e5dc;
  --checker-b: #d5d1c6;
  --checker-dark-a: #2c2d35;
  --checker-dark-b: #22232a;
  --sans: "Bricolage Grotesque", "Avenir Next", "Segoe UI", system-ui, sans-serif;
  --mono: "Space Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  --copy: 740px;
  --wide: 1160px;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #11110f;
    --paper-alt: #181814;
    --tile: #2c2b26;
    --panel: #1a1916;
    --panel-soft: #21201c;
    --ink: #f0eee7;
    --muted: #a6a397;
    --accent: #a698ff;
    --accent-soft: rgba(166, 152, 255, 0.14);
    --accent-border: rgba(166, 152, 255, 0.34);
    --warm: #ff8a5c;
    --focus: #a698ff;
    --checker-a: #2b2a25;
    --checker-b: #201f1b;
  }
}

:root[data-theme="dark"] {
  --paper: #11110f;
  --paper-alt: #181814;
  --tile: #2c2b26;
  --panel: #1a1916;
  --panel-soft: #21201c;
  --ink: #f0eee7;
  --muted: #a6a397;
  --accent: #a698ff;
  --accent-soft: rgba(166, 152, 255, 0.14);
  --accent-border: rgba(166, 152, 255, 0.34);
  --warm: #ff8a5c;
  --focus: #a698ff;
  --checker-a: #2b2a25;
  --checker-b: #201f1b;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 17px;
  line-height: 1.62;
  font-variation-settings: "opsz" 17;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

a {
  color: var(--accent);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}

a:hover {
  text-decoration-thickness: 2px;
}

a:focus-visible,
button:focus-visible,
summary:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

strong,
b {
  font-weight: 680;
}

code {
  font-family: var(--mono);
  font-size: 0.86em;
  background: var(--paper-alt);
  border: 1px solid var(--tile);
  padding: 1px 6px;
  border-radius: 6px;
}

/* Layout containers */
.wrap {
  width: min(var(--wide), calc(100% - 40px));
  margin: 0 auto;
}

.article {
  width: min(var(--copy), calc(100% - 40px));
  margin: 0 auto;
  padding: 8px 0 88px;
}

/* Hero */
.hero {
  padding: 44px 0 28px;
}

.hero-grid {
  display: grid;
  grid-template-columns: minmax(0, 0.94fr) minmax(0, 1.06fr);
  gap: 36px;
  align-items: center;
}

.eyebrow {
  margin: 0 0 14px;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--warm);
}

.hero h1 {
  margin: 0 0 18px;
  font-size: clamp(34px, 4.4vw, 54px);
  font-weight: 800;
  font-variation-settings: "opsz" 96, "wdth" 94;
  line-height: 1.02;
  letter-spacing: -0.028em;
  text-wrap: balance;
}

.standfirst {
  margin: 0 0 22px;
  font-size: 19px;
  line-height: 1.52;
  color: var(--ink);
  max-width: 48ch;
  text-wrap: pretty;
}

.hero-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 22px;
}

.meta-pill {
  display: inline-flex;
  align-items: center;
  padding: 5px 11px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  background: var(--panel);
  border: 1px solid var(--tile);
  color: var(--ink);
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
}

.btn-primary {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 12px 20px;
  border-radius: 10px;
  background: var(--accent);
  color: #ffffff;
  font-weight: 700;
  font-size: 15.5px;
  text-decoration: none;
  border: 1px solid transparent;
  transition: transform 0.14s ease, opacity 0.14s ease;
}

.btn-primary:hover {
  opacity: 0.92;
  transform: translateY(-1px);
  text-decoration: none;
}

.btn-secondary {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 11px 17px;
  border-radius: 10px;
  background: var(--panel);
  color: var(--ink);
  font-weight: 650;
  font-size: 15px;
  text-decoration: none;
  border: 1px solid var(--tile);
  transition: border-color 0.14s ease, background 0.14s ease;
}

.btn-secondary:hover {
  border-color: var(--accent);
  text-decoration: none;
}

.byline {
  margin: 18px 0 0;
  font-size: 14px;
  color: var(--muted);
}

/* Prose typography */
.article h2 {
  margin: 56px 0 14px;
  font-size: clamp(26px, 3.1vw, 35px);
  font-weight: 760;
  font-variation-settings: "opsz" 60, "wdth" 94;
  letter-spacing: -0.022em;
  line-height: 1.14;
  text-wrap: balance;
}

.article h3 {
  margin: 28px 0 10px;
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.012em;
}

.article p {
  margin: 0 0 16px;
  max-width: 68ch;
}

.article ul,
.article ol {
  margin: 0 0 18px;
  padding-left: 22px;
  max-width: 66ch;
}

.article li {
  margin-bottom: 8px;
}

.callout {
  margin: 24px 0;
  padding: 16px 20px;
  border-left: 4px solid var(--warm);
  border-radius: 0 12px 12px 0;
  background: var(--panel);
  border-top: 1px solid var(--tile);
  border-right: 1px solid var(--tile);
  border-bottom: 1px solid var(--tile);
}

.callout p:last-child {
  margin-bottom: 0;
}

/* Interactive Layer Inspector (Hero & Wide Breakouts) */
.inspector-breakout {
  width: min(var(--wide), calc(100vw - 40px));
  position: relative;
  left: 50%;
  transform: translateX(-50%);
  margin: 26px 0 32px;
}

.inspector {
  background: var(--panel);
  border: 1px solid var(--tile);
  border-radius: 18px;
  overflow: hidden;
  box-shadow: 0 14px 36px rgba(18, 16, 12, 0.07);
}

.inspector-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px 16px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--tile);
  background: var(--panel-soft);
}

.inspector-title {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 8px;
  font-size: 14px;
}

.inspector-title strong {
  font-size: 15px;
}

.inspector-title span {
  color: var(--muted);
  font-family: var(--mono);
  font-size: 12px;
}

.inspector-tools {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}

.chip-btn {
  appearance: none;
  border: 1px solid var(--tile);
  background: var(--panel);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 13px;
  font-weight: 600;
  padding: 5px 11px;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.12s ease, border-color 0.12s ease, color 0.12s ease;
}

.chip-btn:hover {
  border-color: var(--accent);
}

.chip-btn[aria-pressed="true"],
.chip-btn.is-active {
  background: var(--accent);
  border-color: var(--accent);
  color: #ffffff;
}

.inspector-body {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(260px, 0.75fr);
  align-items: stretch;
}

.inspector--hero .inspector-body {
  grid-template-columns: minmax(0, 1fr) 262px;
}

.stage-wrap {
  position: relative;
  padding: 18px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: var(--paper-alt);
  min-width: 0;
}

.stage {
  position: relative;
  width: 100%;
  max-width: 560px;
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid var(--tile);
  background-color: var(--checker-a);
  background-image:
    linear-gradient(45deg, var(--checker-b) 25%, transparent 25%),
    linear-gradient(-45deg, var(--checker-b) 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, var(--checker-b) 75%),
    linear-gradient(-45deg, transparent 75%, var(--checker-b) 75%);
  background-size: 20px 20px;
  background-position: 0 0, 0 10px, 10px -10px, -10px 0;
  box-shadow: 0 8px 24px rgba(18, 16, 12, 0.1);
}

.stage--dark-checker {
  background-color: var(--checker-dark-a);
  background-image:
    linear-gradient(45deg, var(--checker-dark-b) 25%, transparent 25%),
    linear-gradient(-45deg, var(--checker-dark-b) 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, var(--checker-dark-b) 75%),
    linear-gradient(-45deg, transparent 75%, var(--checker-dark-b) 75%);
}

.stage--wide {
  max-width: 680px;
}

.stage--portrait {
  max-width: 440px;
}

.stage-backdrop {
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  transition: background-color 0.2s ease;
}

.stage-layer {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
  transition: opacity 0.18s ease, transform 0.28s ease;
  pointer-events: none;
}

.stage-layer.is-hidden {
  opacity: 0;
}

/* Exploded depth view */
.stage[data-view="exploded"] {
  overflow: visible;
  background: transparent;
  border-color: transparent;
  box-shadow: none;
}

.stage[data-view="exploded"] .stage-backdrop {
  opacity: 0;
}

.stage[data-view="exploded"] .stage-layer {
  border-radius: 10px;
  background-color: rgba(255, 255, 255, 0.08);
  box-shadow: 0 10px 24px rgba(12, 12, 16, 0.22);
  transform:
    perspective(900px)
    rotateX(22deg)
    rotateY(-18deg)
    translateX(calc((var(--depth, 0) - 2) * 14px))
    translateY(calc((var(--depth, 0) - 2) * -10px))
    scale(0.84);
}

/* Bounding box SVG overlay */
.bbox-overlay {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 20;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.18s ease;
}

.stage[data-boxes="on"] .bbox-overlay {
  opacity: 1;
}

.bbox-rect {
  fill: rgba(82, 57, 201, 0.12);
  stroke: #ff6b2b;
  stroke-width: 4;
  vector-effect: non-scaling-stroke;
}

.bbox-label-bg {
  fill: rgba(20, 19, 16, 0.86);
}

.bbox-label-text {
  fill: #ffffff;
  font-family: var(--sans);
  font-size: 24px;
  font-weight: 700;
}

/* Background swatch strip */
.stage-footer {
  width: 100%;
  max-width: 560px;
  margin-top: 12px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 12px;
  font-size: 13px;
  color: var(--muted);
}

.stage-footer--wide {
  max-width: 680px;
}

.stage-footer--portrait {
  max-width: 440px;
}

.swatches {
  display: flex;
  align-items: center;
  gap: 6px;
}

.swatch {
  width: 24px;
  height: 24px;
  border-radius: 999px;
  border: 2px solid var(--tile);
  cursor: pointer;
  padding: 0;
  transition: transform 0.12s ease, border-color 0.12s ease;
}

.swatch:hover {
  transform: scale(1.08);
}

.swatch[aria-pressed="true"] {
  border-color: var(--ink);
  box-shadow: 0 0 0 2px var(--panel), 0 0 0 4px var(--accent);
}

.swatch--checker {
  background-color: var(--checker-a);
  background-image:
    linear-gradient(45deg, var(--checker-b) 25%, transparent 25%),
    linear-gradient(-45deg, var(--checker-b) 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, var(--checker-b) 75%),
    linear-gradient(-45deg, transparent 75%, var(--checker-b) 75%);
  background-size: 8px 8px;
  background-position: 0 0, 0 4px, 4px -4px, -4px 0;
}

/* Layer Stack Sidebar */
.layer-panel {
  border-left: 1px solid var(--tile);
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: var(--panel);
  min-width: 0;
}

.layer-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}

.layer-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.layer-row {
  display: grid;
  grid-template-columns: 30px minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  padding: 7px 8px;
  border-radius: 10px;
  border: 1px solid var(--tile);
  background: var(--panel-soft);
  transition: border-color 0.12s ease, background 0.12s ease, opacity 0.12s ease;
}

.layer-row.is-solo {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.layer-row.is-hidden-row {
  opacity: 0.52;
}

.eye-btn {
  appearance: none;
  width: 28px;
  height: 28px;
  border-radius: 7px;
  border: 1px solid var(--tile);
  background: var(--panel);
  color: var(--ink);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
}

.eye-btn:hover {
  border-color: var(--accent);
}

.eye-btn svg {
  width: 16px;
  height: 16px;
}

.layer-meta {
  min-width: 0;
}

.layer-name {
  display: block;
  font-size: 13.5px;
  font-weight: 680;
  line-height: 1.25;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.layer-note {
  display: block;
  font-size: 12px;
  line-height: 1.3;
  color: var(--muted);
}

.solo-btn {
  appearance: none;
  border: 1px solid var(--tile);
  background: var(--panel);
  color: var(--muted);
  font-family: var(--sans);
  font-size: 11.5px;
  font-weight: 700;
  padding: 4px 8px;
  border-radius: 6px;
  cursor: pointer;
}

.solo-btn:hover {
  border-color: var(--accent);
  color: var(--ink);
}

.solo-btn[aria-pressed="true"] {
  background: var(--accent);
  border-color: var(--accent);
  color: #ffffff;
}

.layer-status {
  margin: auto 0 0;
  padding-top: 8px;
  border-top: 1px solid var(--tile);
  font-size: 12.5px;
  line-height: 1.4;
  color: var(--muted);
}

/* Preset buttons strip inside wide demos */
.preset-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 10px 16px;
  border-top: 1px solid var(--tile);
  background: var(--panel-soft);
}

/* Details / Prompts / FAQ */
details.spec-note,
details.faq {
  margin: 14px 0 8px;
  border: 1px solid var(--tile);
  border-radius: 12px;
  background: var(--panel);
}

details.spec-note summary,
details.faq summary {
  padding: 12px 16px;
  cursor: pointer;
  font-weight: 660;
  font-size: 15.5px;
}

details.spec-note .detail-body,
details.faq p {
  margin: 0;
  padding: 0 16px 15px;
  font-size: 15px;
  line-height: 1.56;
}

details.spec-note pre {
  margin: 8px 0 0;
  padding: 12px 14px;
  background: var(--paper-alt);
  border: 1px solid var(--tile);
  border-radius: 10px;
  font-family: var(--mono);
  font-size: 12.5px;
  line-height: 1.52;
  white-space: pre-wrap;
  overflow-x: auto;
}

/* Tables */
.table-wrap {
  width: 100%;
  overflow-x: auto;
  margin: 18px 0 12px;
  border: 1px solid var(--tile);
  border-radius: 14px;
  background: var(--panel);
}

table.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 15px;
}

table.data-table th,
table.data-table td {
  padding: 11px 14px;
  border-bottom: 1px solid var(--tile);
  text-align: left;
  vertical-align: top;
}

table.data-table th {
  font-weight: 700;
  background: var(--panel-soft);
  font-size: 13.5px;
  letter-spacing: 0.01em;
}

table.data-table tr:last-child td {
  border-bottom: 0;
}

table.data-table .num {
  text-align: right;
  font-family: var(--mono);
  font-size: 14px;
  white-space: nowrap;
}

table.data-table tr.is-default td {
  background: var(--accent-soft);
  font-weight: 650;
}

/* End CTA card */
.cta-band {
  margin: 44px 0 0;
  padding: 28px;
  border-radius: 18px;
  background: var(--panel);
  border: 1px solid var(--tile);
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.cta-band h2 {
  margin: 0;
  font-size: clamp(24px, 3vw, 30px);
}

.cta-band p {
  margin: 0;
}

/* More from Sogni (matching blogs/minimax-h3-upscaling/) */
.related {
  width: min(var(--wide), calc(100% - 40px));
  margin: 0 auto 76px;
  padding-top: 40px;
  border-top: 1px solid var(--tile);
}

.related h2 {
  margin: 0 0 20px;
  font-size: 24px;
  font-weight: 760;
  letter-spacing: -0.02em;
}

.related-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 20px;
}

.related-card {
  display: flex;
  flex-direction: column;
  background: var(--panel);
  border: 1px solid var(--tile);
  border-radius: 14px;
  overflow: hidden;
  text-decoration: none;
  color: var(--ink);
  transition: transform 0.16s ease, border-color 0.16s ease;
}

.related-card:hover {
  transform: translateY(-2px);
  border-color: var(--accent);
  text-decoration: none;
}

.related-card img {
  width: 100%;
  aspect-ratio: 16 / 10;
  object-fit: cover;
  display: block;
  background: var(--paper-alt);
}

.related-copy {
  padding: 14px 16px 16px;
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.related-copy small {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}

.related-copy strong {
  font-size: 16px;
  line-height: 1.32;
  color: var(--ink);
}

/* Responsive */
@media (max-width: 980px) {
  .hero-grid {
    grid-template-columns: 1fr;
    gap: 28px;
  }

  .inspector-body,
  .inspector--hero .inspector-body {
    grid-template-columns: 1fr;
  }

  .layer-panel {
    border-left: 0;
    border-top: 1px solid var(--tile);
  }

  .related-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 600px) {
  .wrap,
  .article,
  .related {
    width: calc(100% - 28px);
  }

  .inspector-breakout {
    width: calc(100vw - 28px);
  }

  .hero {
    padding: 28px 0 20px;
  }

  .stage-wrap {
    padding: 12px;
  }

  .cta-band {
    padding: 20px;
  }
}
