:root {
  --bg: #14110e;
  --bg2: #1c1814;
  --ink: #f3ebe1;
  --muted: #b3a89a;
  --line: #3a322a;
  --accent: #d4a15a;
  --accent-dim: #8a6a38;
  --wine: #8b3d48;
  --wine-dim: #6e3038;
  --wine-soft: #b45a66;
  --page-max: 72rem;
  --page-pad: 2rem;
  --prose: 42rem;
}

::selection {
  background: var(--wine);
  color: var(--ink);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html {
  scroll-behavior: smooth;
  overflow-x: clip;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  font-family: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.65;
  min-height: 100vh;
  overflow-x: clip;
  padding-bottom: calc(90px + env(safe-area-inset-bottom, 0px));
}

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--wine-soft); text-decoration: underline; }

.top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  max-width: var(--page-max);
  margin: 0 auto;
  padding: 1.25rem var(--page-pad);
  border-bottom: 1px solid var(--line);
}

.wordmark {
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--ink);
  text-decoration: none;
  border-left: 2px solid var(--wine);
  padding-left: 0.55rem;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
}

.wordmark:hover {
  color: var(--wine-soft);
  text-decoration: none;
}

nav { display: flex; flex-wrap: wrap; gap: 0.85rem 1.35rem; font-size: 0.95rem; }
nav a {
  color: var(--muted);
  display: inline-flex;
  align-items: center;
  min-height: 44px;
}
nav a:hover { color: var(--wine-soft); text-decoration: none; }
nav a[aria-current="page"] { color: var(--ink); }

main {
  width: 100%;
  max-width: var(--page-max);
  margin: 0 auto;
  padding: 0 var(--page-pad) 4rem;
}

.hero { padding: 2rem 0 1.35rem; }

.eyebrow {
  color: var(--accent);
  letter-spacing: 0.16em;
  text-transform: uppercase;
  font-size: 0.75rem;
  font-family: ui-sans-serif, system-ui, sans-serif;
  margin-bottom: 0.75rem;
}

.hero-title {
  display: flex;
  align-items: baseline;
  justify-content: flex-start;
  gap: 1.15rem;
  margin-bottom: 0.85rem;
}

.hero h1 {
  font-size: clamp(2.2rem, 6vw, 3.4rem);
  font-weight: 600;
  letter-spacing: 0.04em;
  line-height: 1;
  flex: 0 0 auto;
}

.expand {
  margin: 0;
  color: var(--muted);
  font-size: clamp(1.15rem, 2vw, 1.55rem);
  text-align: left;
  line-height: 1.2;
  flex: 0 1 auto;
  white-space: nowrap;
}

.expand span { color: var(--ink); font-weight: 600; }

.lead { font-size: 1.05rem; max-width: none; }
.lead strong { font-weight: 600; }

.cta { display: flex; flex-wrap: wrap; gap: 0.75rem; margin-top: 1.15rem; }

.btn {
  display: inline-block;
  padding: 0.65rem 1.1rem;
  border: 1px solid var(--line);
  font-family: ui-sans-serif, system-ui, sans-serif;
  font-size: 0.9rem;
  text-decoration: none;
}

.btn.primary { background: var(--accent); color: #1a140c; border-color: var(--accent); }
.btn.ghost { color: var(--ink); }
.btn:hover { text-decoration: none; filter: brightness(1.08); }

.reading .domain,
.readings .layer-documentary,
.readings .layer-operatory,
.readings .layer-reflexive {
  font-family: ui-sans-serif, system-ui, sans-serif;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.reading .domain { color: var(--accent); }

.reading code {
  font-size: 0.92em;
}

.readings { margin: 0 0 2.25rem; }
.readings p {
  color: var(--muted);
  font-size: 0.98rem;
}
.readings p + p { margin-top: 0.8rem; }

.readings .layer-documentary { color: var(--ink); }
.readings .layer-operatory { color: var(--accent); }
.readings .layer-reflexive { color: var(--wine-soft); }

.reading {
  width: 100%;
  max-width: none;
  margin: 0 0 2.25rem;
}

.reading h2,
.readings > h2,
.model h2,
.credits h2,
main > section.reading > h2,
main > section.readings > h2,
main > section.model > h2,
main > section.credits > h2 {
  font-size: 1.35rem;
  margin-bottom: 0.7rem;
}

.reading p {
  color: var(--muted);
  font-size: 0.98rem;
  max-width: none;
}

.reading strong { color: var(--ink); }
.reading strong.domain { color: var(--accent); }

.model p {
  color: var(--muted);
  font-size: 0.98rem;
  max-width: none;
}

.reading p + p { margin-top: 1rem; }

.model { margin: 0 0 2.5rem; }

#purpose,
#situated,
#graphs,
#readings,
#replay,
#core,
#credits {
  scroll-margin-top: 1.25rem;
}

.replay { margin: 0 0 2.5rem; }

.replay > h2 {
  font-size: 1.35rem;
  font-weight: 600;
  margin: 0 0 0.7rem;
}

.replay-intro {
  margin: 0 0 1rem;
}

.replay-intro p {
  color: var(--muted);
  font-size: 0.98rem;
  max-width: none;
}

.replay-intro p + p { margin-top: 0.7rem; }

.replay-intro strong { font-weight: 600; color: var(--ink); }

.replay-more {
  margin: 0.7rem 0 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.replay-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: flex-end;
  gap: 0.45rem 1.1rem;
  margin: 0.35rem 0 0;
  font-family: ui-sans-serif, system-ui, sans-serif;
  font-size: 0.78rem;
}

.replay-meta span { color: var(--accent); letter-spacing: 0.04em; }

.replay-stage {
  position: relative;
  width: 100%;
  height: min(64vh, 640px);
  min-height: 520px;
  overflow: hidden;
  background: #0b0a09;
  border: 1px solid var(--line);
}

.replay-stage iframe {
  display: block;
  width: 100%;
  height: 100%;
  border: 0;
  overflow: hidden;
  background: #0b0a09;
}

/*
 * Même bascule que le viewer dür.air (isPortraitPhoneViewport) :
 * largeur courte + portrait → pile verticale. Le cadre doit alors
 * être plus haut que large, sinon l’iframe reste en split 50/50.
 */
html.replay-stack .replay-stage,
.replay-stage.replay-stage-stack {
  width: calc(100% + (2 * var(--page-pad)));
  margin-left: calc(-1 * var(--page-pad));
  height: min(88dvh, 860px);
  min-height: max(70dvh, 640px);
  border-left: none;
  border-right: none;
}

@media (max-width: 768px) and (orientation: portrait) {
  .replay-stage {
    width: calc(100% + (2 * var(--page-pad)));
    margin-left: calc(-1 * var(--page-pad));
    height: min(88dvh, 860px);
    min-height: max(70dvh, 640px);
    border-left: none;
    border-right: none;
  }
}

@media (max-width: 932px) and (orientation: portrait) and (pointer: coarse) and (hover: none) {
  .replay-stage {
    width: calc(100% + (2 * var(--page-pad)));
    margin-left: calc(-1 * var(--page-pad));
    height: min(88dvh, 860px);
    min-height: max(70dvh, 640px);
    border-left: none;
    border-right: none;
  }
}

.example-group {
  margin: 0 0 1.25rem;
}

.example-group > h2 {
  font-size: 1.15rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: none;
  color: var(--ink);
  margin: 2.4rem 0 0.75rem;
  padding-bottom: 0.45rem;
  border-bottom: 1px solid var(--line);
}

.example-group .group-lead {
  color: var(--muted);
  font-size: 0.98rem;
  margin: 0 0 1.6rem;
  max-width: var(--prose);
}

.example-case {
  margin: 0 0 3.2rem;
}

.example-case h2,
.example-case h3 {
  font-size: 1.35rem;
  font-weight: 600;
  margin: 0 0 0.55rem;
}

.example-case > p {
  color: var(--muted);
  font-size: 0.98rem;
  margin: 0 0 1rem;
  max-width: none;
}

.example-case cite { font-style: italic; }

.page-head { padding: 3.2rem 0 1.75rem; }
.page-head h1 {
  font-size: clamp(2.2rem, 6vw, 3.4rem);
  font-weight: 600;
  letter-spacing: 0.03em;
  line-height: 1.05;
  margin-bottom: 1rem;
}

main > section > h2 {
  font-size: 1.45rem;
  margin-bottom: 0.85rem;
}

.artefacts {
  width: 100%;
  border-collapse: collapse;
  margin: 0 0 2.75rem;
  font-size: 0.95rem;
}

.artefacts th,
.artefacts td {
  text-align: left;
  padding: 0.7rem 0.6rem 0.7rem 0;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}

.artefacts th {
  color: var(--accent);
  font-family: ui-sans-serif, system-ui, sans-serif;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.artefacts td { color: var(--muted); }
.artefacts td:first-child { color: var(--ink); white-space: nowrap; }
.artefacts td:last-child { text-align: right; padding-right: 0; }

.glossary-wrap {
  overflow-x: auto;
  margin: 1.25rem 0 1.5rem;
}

.glossary {
  width: 100%;
  min-width: 40rem;
  border-collapse: collapse;
  font-size: 0.92rem;
}

.glossary th,
.glossary td {
  text-align: left;
  padding: 0.55rem 0.85rem 0.55rem 0;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}

.glossary th {
  color: var(--accent);
  font-family: ui-sans-serif, system-ui, sans-serif;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.glossary td { color: var(--muted); }
.glossary td:first-child { color: var(--ink); font-weight: 600; }

.row-actions {
  display: flex;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 0.45rem;
}

.btn.small {
  padding: 0.35rem 0.7rem;
  font-size: 0.78rem;
}

code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.88em;
  color: var(--accent);
}

.soon { margin-bottom: 0.6rem; }
.tools ul { padding-left: 1.2rem; }

.credits {
  margin: 0 0 2.5rem;
}

.credits p {
  color: var(--muted);
  font-size: 0.98rem;
  max-width: none;
}

.credits strong { color: var(--ink); }

.fixed-footer {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 20;
  background: #fff;
  border-top: 1px solid #e1e4e8;
  padding: 12px 0 calc(12px + env(safe-area-inset-bottom, 0px));
}

.footer-content {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.5rem;
  max-width: var(--page-max);
  margin: 0 auto;
  padding: 0 var(--page-pad);
}

.footer-text {
  flex: 1;
  margin: 0;
  color: #24292f;
  font-size: 12px;
  font-family: ui-sans-serif, system-ui, sans-serif;
  white-space: nowrap;
}

.footer-partners {
  display: block;
  height: 44px;
  width: auto;
  max-width: min(340px, 48vw);
  object-fit: contain;
}

.footer-link {
  flex: 1;
  text-align: right;
  color: #8b3d48;
  font-size: 12px;
  font-family: ui-sans-serif, system-ui, sans-serif;
  font-weight: 500;
  text-decoration: none;
  white-space: nowrap;
}

.footer-link:hover { color: #6e3038; text-decoration: none; }

@media (max-width: 960px) {
  .hero-title {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.4rem;
  }
  .expand { text-align: left; white-space: normal; margin-left: 0; }
}

@media (max-width: 720px) {
  :root { --page-pad: 1.15rem; }

  .top {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.15rem 0;
    padding-top: 0.85rem;
    padding-bottom: 0.65rem;
  }

  nav {
    width: 100%;
    gap: 0 0.35rem;
  }

  nav a { padding-right: 0.35rem; }

  .hero { padding-top: 1.35rem; }
  .page-head { padding-top: 1.75rem; }

  .replay-meta { justify-content: flex-start; }

  .artefacts thead { display: none; }
  .artefacts,
  .artefacts tbody,
  .artefacts tr,
  .artefacts td {
    display: block;
    width: 100%;
  }
  .artefacts tr {
    padding: 0.9rem 0;
    border-bottom: 1px solid var(--line);
  }
  .artefacts th,
  .artefacts td {
    padding: 0.12rem 0;
    border-bottom: 0;
  }
  .artefacts td:first-child {
    color: var(--ink);
    white-space: normal;
    font-weight: 600;
  }
  .artefacts td:last-child {
    text-align: left;
    padding-top: 0.5rem;
  }
  .row-actions { justify-content: flex-start; }
  .btn.small {
    min-height: 44px;
    padding: 0.55rem 0.85rem;
    display: inline-flex;
    align-items: center;
  }

  body {
    padding-bottom: calc(118px + env(safe-area-inset-bottom, 0px));
  }

  html.docs-page body.docs {
    padding-bottom: 0;
  }

  .docs .sidebar,
  .docs .content {
    padding-bottom: calc(118px + env(safe-area-inset-bottom, 0px));
  }

  .footer-content {
    flex-direction: column;
    gap: 0.45rem;
  }
  .footer-text,
  .footer-link {
    text-align: center;
    flex: none;
    white-space: normal;
  }
  .footer-partners { height: 32px; max-width: 220px; }
}

/* Model / docsify — chrome stays put; only the text pane scrolls */
html.docs-page {
  height: 100%;
  overflow: hidden;
}

html.docs-page body.docs {
  display: flex;
  flex-direction: column;
  height: 100%;
  height: 100dvh;
  max-height: 100dvh;
  overflow: hidden;
  padding-bottom: 0;
}

html.docs-page body.docs > header.top {
  flex: 0 0 auto;
}

html.docs-page body.docs > #app {
  flex: 1 1 auto;
  min-height: 0;
  width: 100%;
  overflow: hidden;
}

body.docs #app > main,
body.docs > main {
  width: 100%;
  max-width: var(--page-max);
  margin: 0 auto;
  padding: 1.25rem var(--page-pad) 0;
  display: grid !important;
  grid-template-columns: 16.5rem minmax(0, 1fr);
  gap: 2.5rem;
  align-items: stretch;
  height: 100%;
  min-height: 0 !important;
  min-width: 0;
  overflow: hidden;
}

.docs .sidebar-toggle {
  display: none;
}

.docs .sidebar {
  position: relative !important;
  top: auto;
  left: auto !important;
  background: transparent;
  border: 0;
  padding: 0.2rem 0 calc(90px + env(safe-area-inset-bottom, 0px));
  width: auto !important;
  height: 100%;
  overflow-x: hidden;
  overflow-y: auto;
  transform: none !important;
}

.docs .sidebar .app-name {
  margin: 0 0 0.85rem;
}

.docs .sidebar .app-name-link {
  color: var(--ink);
  font-family: inherit;
  font-size: 1.15rem;
  font-weight: 600;
  text-decoration: none;
}

.docs .sidebar ul {
  margin: 0;
  padding: 0;
  list-style: none;
}

.docs .sidebar li {
  margin: 0;
}

.docs .sidebar a {
  display: block;
  padding: 0.28rem 0;
  color: var(--muted);
  font-size: 0.92rem;
  text-decoration: none;
}

.docs .sidebar-nav > ul > li > a,
.docs .sidebar-nav > ul > li > p,
.docs .sidebar-nav > ul > li > p > a {
  color: var(--ink);
  font-weight: 600;
  font-size: 0.92rem;
  padding: 0.55rem 0 0.2rem;
}

.docs .sidebar-nav > ul > li > p {
  margin: 0;
}

.docs .sidebar-nav > ul > li.is-open > a,
.docs .sidebar-nav > ul > li.is-open > p > a {
  color: var(--accent);
}

.docs .sidebar-nav > ul > li.is-open > a::after,
.docs .sidebar-nav > ul > li.is-open > p > a::after {
  content: "▾";
  float: right;
  font-weight: 400;
  font-size: 0.72rem;
  color: var(--accent);
  margin-left: 0.4rem;
}

.docs .sidebar-nav > ul > ul,
.docs .sidebar-nav ul.app-sub-sidebar,
.docs .sidebar-nav > ul > li > ul {
  margin: 0.15rem 0 0.65rem;
  padding: 0.15rem 0 0.15rem 0.75rem;
  border-left: 1px solid var(--line);
}

.docs .sidebar-nav ul ul a,
.docs .sidebar-nav .app-sub-sidebar a {
  color: var(--muted);
  font-weight: 400;
  font-size: 0.8rem;
  line-height: 1.35;
  padding: 0.16rem 0;
}

.docs .sidebar a:hover,
.docs .sidebar .active {
  color: var(--wine-soft);
  text-decoration: none;
}

.docs .sidebar .active { color: var(--ink); }

.docs .content {
  left: auto !important;
  right: auto !important;
  position: relative !important;
  padding: 0 0 calc(90px + env(safe-area-inset-bottom, 0px)) !important;
  overflow-x: hidden;
  overflow-y: auto !important;
  height: 100%;
  min-width: 0;
  min-height: 0;
  max-width: 100%;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}

.docs .markdown-section {
  max-width: 100%;
  min-width: 0;
  margin: 0;
  padding: 0 0 2rem;
  color: var(--muted);
  font-size: 0.98rem;
  line-height: 1.65;
}

.docs .markdown-section h1,
.docs .markdown-section h2,
.docs .markdown-section h3,
.docs .markdown-section h4 {
  color: var(--ink);
  font-weight: 600;
  border: 0;
  scroll-margin-top: 0.4rem;
}

.docs .markdown-section h1 {
  font-size: clamp(2.2rem, 6vw, 3.4rem);
  letter-spacing: 0.03em;
  margin: 0 0 1rem;
}

.docs .markdown-section h2 {
  font-size: 1.35rem;
  margin: 2rem 0 0.7rem;
}

.docs .markdown-section h3 {
  font-size: 1.1rem;
  margin: 1.4rem 0 0.5rem;
}

.docs .markdown-section p {
  margin: 0 0 0.9rem;
}

.docs .markdown-section iframe.folio-reader {
  display: block;
  width: 100%;
  height: min(78vh, 760px);
  min-height: 560px;
  margin: 0.35rem 0 0.55rem;
  border: 1px solid var(--line);
  background: #0e0c0a;
}

.docs .markdown-section ul,
.docs .markdown-section ol {
  margin: 0 0 0.9rem;
  padding-left: 1.35rem;
}

.docs .markdown-section ul { list-style: disc; }
.docs .markdown-section ol { list-style: decimal; }

.docs .markdown-section li + li {
  margin-top: 0.25rem;
}

.docs .markdown-section a { color: var(--accent); }
.docs .markdown-section a:hover { color: var(--wine-soft); }

.docs .markdown-section strong { color: var(--ink); font-weight: 600; }

.docs .markdown-section code {
  background: transparent;
  color: var(--accent);
  font-size: 0.88em;
}

.docs .markdown-section img {
  display: block;
  width: 100%;
  height: auto;
  margin: 0.35rem 0 0.85rem;
}

.docs .markdown-section a.fig-graph {
  display: block;
  margin: 0.35rem 0 0.85rem;
}

.docs .markdown-section a.fig-graph:hover {
  text-decoration: none;
}

.docs .markdown-section a.fig-graph img {
  margin: 0;
}

.docs .markdown-section pre {
  background: var(--bg2);
  border: 1px solid var(--line);
  padding: 0.85rem 1rem;
  overflow: auto;
}

.docs .markdown-section pre code { color: var(--ink); }

.docs .markdown-section blockquote {
  margin: 0 0 1rem;
  padding: 0 0 0 0.9rem;
  border-left: 2px solid var(--wine);
  color: var(--muted);
  background: transparent;
}

.docs .markdown-section table {
  width: 100%;
  border-collapse: collapse;
  margin: 0 0 1.4rem;
  font-size: 0.92rem;
}

.docs .markdown-section th,
.docs .markdown-section td {
  text-align: left;
  padding: 0.55rem 0.6rem 0.55rem 0;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}

.docs .markdown-section th {
  color: var(--accent);
  font-family: ui-sans-serif, system-ui, sans-serif;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.docs .markdown-section td { color: var(--muted); }

.docs .progress {
  background: var(--wine);
}

@media (max-width: 800px) {
  body.docs #app > main,
  body.docs > main {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto minmax(0, 1fr);
    padding-top: 1rem;
  }
  .docs .sidebar {
    position: relative !important;
    border-bottom: 1px solid var(--line);
    padding-bottom: 0.65rem;
    margin-bottom: 0.35rem;
    width: 100% !important;
    height: auto;
    max-height: min(36vh, 18rem);
  }
  .docs .sidebar ul {
    display: block;
  }
  .docs .sidebar-nav > ul > li > ul,
  .docs .sidebar-nav ul.app-sub-sidebar {
    display: block;
  }
  .docs .sidebar a {
    display: block;
    min-height: 36px;
    padding: 0.2rem 0;
  }
  .docs .markdown-section {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  .docs .markdown-section table {
    display: block;
    width: max-content;
    max-width: 100%;
    overflow-x: auto;
  }
  .docs .markdown-section pre {
    max-width: 100%;
  }
}
