/* Shared bilingual reading palette; loaded after the existing layout rules. */
body.quarto-light {
  --pw-bg: #fbfaf7;
  --pw-surface: #fffdfa;
  --pw-surface-soft: #f2efe8;
  --pw-surface-hover: #eae5dc;
  --pw-text: #30302c;
  --pw-text-soft: #666158;
  --pw-text-faint: #746e64;
  --pw-primary: #806039;
  --pw-primary-hover: #604522;
  --pw-primary-soft: #eee7dc;
  --pw-accent: #947044;
  --pw-accent-hover: #70502b;
  --pw-border: #ded9d0;
  --pw-border-strong: #b7aea0;
  --pw-code-bg: #efede6;
  --pw-code-text: #79502f;
  --pw-table-head: #eeeae2;
  --pw-table-stripe: #f7f5ef;
  --pw-table-hover: #eeeae1;
  --pw-heading-3: #30302c;
  --pw-heading: #292824;
  --pw-shell-surface: #f1eee7;
  --pw-shell-surface-raised: #f8f6f0;
  --pw-interactive-surface: #e9e3d8;
  --pw-shell-hover: #e6dfd3;
  --pw-shell-border: #ddd6cb;
  --pw-on-primary: #fffdfa;
  --pw-focus: #806039;
  --pw-syntax-keyword: #b94343;
  --pw-syntax-string: #287e63;
  --pw-syntax-function: #617c20;
  --pw-syntax-number: #a64c88;
  --pw-syntax-comment: #68715f;
  --pw-accent-soft: #e9dfcd;
  --pw-note-border: #687d74;
  --pw-tip-border: #6d8051;
  --pw-warning-border: #947044;
  --pw-important-border: #996b70;
  --pw-caution-border: #a56452;
}
body.quarto-dark {
  color-scheme: dark;
  --pw-bg: #242321;
  --pw-surface: #2b2926;
  --pw-surface-soft: #2e2c28;
  --pw-surface-hover: #35322d;
  --pw-text: #e6e3dc;
  --pw-text-soft: #b9b3a9;
  --pw-text-faint: #aaa397;
  --pw-primary: #d2b17b;
  --pw-primary-hover: #ead0a5;
  --pw-primary-soft: #353027;
  --pw-accent: #c5a16a;
  --pw-accent-hover: #e0bc86;
  --pw-accent-soft: #554733;
  --pw-border: #3b3833;
  --pw-border-strong: #71685b;
  --pw-code-bg: #302f29;
  --pw-code-text: #b6c79b;
  --pw-table-head: #33302b;
  --pw-table-stripe: #282724;
  --pw-table-hover: #302e29;
  --pw-note-bg: #2b2c29;
  --pw-note-border: #a7b3ac;
  --pw-tip-bg: #292d26;
  --pw-tip-border: #a7bc8d;
  --pw-warning-bg: #302b24;
  --pw-warning-border: #c5a16a;
  --pw-important-bg: #302729;
  --pw-important-border: #c39b9e;
  --pw-caution-bg: #302725;
  --pw-caution-border: #cc9a8b;
  --pw-heading: #eee9df;
  --pw-heading-3: #e6e3dc;
  --pw-shell-surface: #201f1d;
  --pw-shell-surface-raised: #272522;
  --pw-interactive-surface: #332f29;
  --pw-shell-hover: #36322c;
  --pw-shell-border: #3b3833;
  --pw-shadow-soft: 0 1px 2px rgb(0 0 0 / 0.12);
  --pw-shadow-float: 0 8px 28px rgb(0 0 0 / 0.24);
  --pw-on-primary: #242321;
  --pw-focus: #d2b17b;
  --pw-syntax-keyword: #e67e80;
  --pw-syntax-string: #83c092;
  --pw-syntax-function: #a7c080;
  --pw-syntax-number: #d699b6;
  --pw-syntax-comment: #a4ac9b;
}
html:has(body.quarto-light) { color-scheme: light; }
html:has(body.quarto-dark) { color-scheme: dark; }
#quarto-content { background: var(--pw-bg); }
main.content :is(h1, h2, h4), .quarto-title h1 { color: var(--pw-heading) !important; }

/* Preserve a distinct title band, including when a progressive hint is open. */
.callout .callout-header {
  background: color-mix(in srgb, var(--pw-callout-color) 9%, var(--pw-surface)) !important;
}
.callout .callout-title-container {
  color: var(--pw-heading) !important;
  font-size: 1rem;
  font-weight: 720;
}
main.content details > summary {
  color: var(--pw-heading);
  font-size: 1rem;
  font-weight: 700;
  background: var(--pw-primary-soft);
  border-bottom-color: var(--pw-border-strong);
}
main.content .pw-entry-grid h3 {
  font-size: 1.15rem;
  line-height: 1.45;
  padding-bottom: 0.65rem;
  border-bottom: 1px solid var(--pw-border);
}
main.content .pw-entry-grid h3 a:not(.anchorjs-link) { font-weight: 700; }

.callout-note { --pw-callout-color: var(--pw-note-border); }
.callout-tip { --pw-callout-color: var(--pw-tip-border); }
.callout-warning { --pw-callout-color: var(--pw-warning-border); }
.callout-important { --pw-callout-color: var(--pw-important-border); }
.callout-caution { --pw-callout-color: var(--pw-caution-border); }

/* Replace legacy white glass surfaces without changing their dimensions. */
.aa-DetachedContainer { background: var(--pw-surface) !important; }
body.quarto-dark :is(.aa-DetachedContainer, .pw-panel-toggle, .pw-edge-toggle, .gallery-locator) {
  box-shadow: var(--pw-shadow-soft) !important;
}
body.quarto-dark .sidebar-item .sidebar-link {
  background-image: none !important;
  border-color: transparent;
}
body .pw-home-shortcuts a:first-child { color: var(--pw-on-primary); }
body.quarto-dark .pw-panel-toggle { background: var(--pw-interactive-surface); }
body.quarto-dark .nav-tabs .nav-link.active {
  background: var(--pw-primary-soft);
  color: var(--pw-primary);
}
body.quarto-dark .nav-footer { background: var(--pw-shell-surface); }
.nav-footer p { color: var(--pw-text-soft); }

/* The footer shares the reading area and responds to either fixed panel. */
footer.footer { background: var(--pw-shell-surface); }
footer .nav-footer {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  padding: 1.4rem 1rem;
  background: transparent;
}
footer .nav-footer > div {
  width: 100%;
  min-width: 0;
  text-align: center;
}
footer .nav-footer-center:empty { display: none; }
footer .nav-footer p { margin: 0; overflow-wrap: anywhere; }
@media (min-width: 1100px) {
  body.pw-custom-layout-ready footer.footer {
    padding-left: calc(var(--pw-left-panel-width) + 1rem);
    padding-right: calc(var(--pw-right-panel-width) + 1rem);
    transition: padding var(--pw-layout-speed) ease;
  }
  body.pw-left-collapsed footer.footer { padding-left: 1rem; }
  body.pw-right-collapsed footer.footer { padding-right: 1rem; }
  footer .nav-footer { max-width: 960px; margin-inline: auto; }
  body.pw-left-collapsed footer .nav-footer,
  body.pw-right-collapsed footer .nav-footer { max-width: 1060px; }
  body.pw-left-collapsed.pw-right-collapsed footer .nav-footer { max-width: 1180px; }
}
@media (prefers-reduced-motion: reduce) {
  body.pw-custom-layout-ready footer.footer { transition: none; }
}

/* Native Bootstrap icons use embedded SVG fills, rather than currentColor. */
/* A CSS half-circle remains legible in both modes without embedded SVG fills. */
.quarto-color-scheme-toggle .bi::before {
  background-image: linear-gradient(90deg, currentColor 50%, transparent 50%) !important;
  border: 1.5px solid currentColor;
  border-radius: 50%;
  color: var(--pw-text-soft);
  filter: none !important;
}
body.quarto-dark .callout-icon::before { filter: brightness(1.8) saturate(0.6); }

/* Only the secondary sidebar button is used for navigation below desktop. */
#quarto-header .navbar-toggler[data-bs-target="#navbarCollapse"] {
  display: none !important;
  pointer-events: none !important;
}
@media (max-width: 991.98px) {
  #quarto-header #navbarCollapse { display: none !important; }
}

/* Override Bootstrap's fixed pale inline-code fill, including table cells. */
body main.content :not(pre) > code {
  background-color: var(--pw-code-bg) !important;
  color: var(--pw-code-text) !important;
}

/* Mixed prose/code must wrap inside its column rather than paint over the next. */
main.content :is(.affection-point-table, .affection-d19-summary-table) td {
  white-space: normal !important;
  overflow-wrap: anywhere;
}
main.content :is(.affection-point-table, .affection-d19-summary-table) td code {
  white-space: normal !important;
  overflow-wrap: anywhere;
}


/* Gold is reserved for content links; navigation and controls keep their palette. */
body.quarto-dark main.content a:not(.nav-link):not(.anchorjs-link):not(.btn):not(.pw-home-shortcuts a):not(.quarto-page-breadcrumbs a) {
  color: var(--pw-primary);
  text-decoration-color: var(--pw-accent);
  text-decoration-line: underline;
  text-underline-offset: 0.2em;
}
body.quarto-dark main.content a:not(.nav-link):not(.anchorjs-link):not(.btn):not(.pw-home-shortcuts a):not(.quarto-page-breadcrumbs a):is(:hover, :focus-visible) {
  color: var(--pw-primary-hover);
  text-decoration-color: currentColor;
}
.pw-reading-summary {
  border-left: 3px solid var(--pw-accent);
  padding: 0.2rem 0 0.2rem 1rem;
  margin: 1.6rem 0 2rem;
}
.pw-reading-summary > p { margin-bottom: 0.55rem; color: var(--pw-heading); }
.pw-reading-summary > ul { margin-bottom: 0; padding-left: 1.2rem; }
.pw-reading-summary li { margin-bottom: 0.4rem; font-size: 1rem; line-height: 1.8; }

/* Reading structure: group existing rules without hiding their conditions. */
.pw-rule-groups { margin-block: 1.25rem 1.75rem; }
.pw-rule-groups > p { color: var(--pw-heading); margin: 1.15rem 0 .4rem; }
.pw-rule-groups > ul { margin-bottom: 1rem; }
.pw-key-rule {
  border-inline-start: 3px solid var(--pw-accent);
  padding: .7rem 1rem;
  margin-block: 1.25rem;
  background: var(--pw-surface-soft);
  border-radius: 0 .4rem .4rem 0;
}
.pw-key-rule > p { margin-bottom: 0; color: var(--pw-heading); font-weight: 600; }
.pw-process-list > ol { padding-left: 1.6rem; margin-block: 1rem; }
.pw-process-list > ol > li { padding: .4rem 0 .7rem .35rem; }
.pw-process-list > ol > li + li { border-top: 1px solid var(--pw-border); }
.pw-process-list > ol > li::marker { color: var(--pw-heading); font-weight: 700; }

/* Empty footer slots must not reserve a row for the floating return control. */
footer .nav-footer-center { min-height: 0; display: contents; }
footer .nav-footer { padding-block: 1rem; }
footer #quarto-back-to-top {
  position: static; transform: none; margin: .25rem auto;
  inset: auto; align-self: center; box-shadow: none;
}
/* The first heading in the expanded index needs no section-sized top gap. */
#gallery-trigger-index .callout-body > .gallery-trigger-group:first-child { padding-top: 0; }
#gallery-trigger-index .gallery-trigger-group h3 { margin-top: 1.2rem; margin-bottom: .7rem; }
#gallery-trigger-index .callout-body > .gallery-trigger-group:first-child h3 { margin-top: .25rem; }
/* Keep ID/date compact and give the remaining width to the narrative clue. */
#gallery-trigger-index .gallery-trigger-group table,
#gallery-non-gallery-index.gallery-non-gallery-index table { min-width: 46rem; }
#gallery-trigger-index .gallery-trigger-group :is(col,th,td):nth-child(1),
#gallery-non-gallery-index.gallery-non-gallery-index :is(col,th,td):nth-child(1) { width: 15rem !important; }
#gallery-trigger-index .gallery-trigger-group :is(col,th,td):nth-child(3),
#gallery-non-gallery-index.gallery-non-gallery-index :is(col,th,td):nth-child(3) { width: 9rem !important; }
#gallery-trigger-index .gallery-trigger-group :is(col,th,td):nth-child(4),
#gallery-non-gallery-index.gallery-non-gallery-index :is(col,th,td):nth-child(4) { width: auto !important; }
#gallery-trigger-index .gallery-trigger-group td code,
#gallery-non-gallery-index.gallery-non-gallery-index td code {
  max-width: 100%; white-space: normal !important; overflow-wrap: anywhere;
}
/* Preserve readable cells at tablet widths as well as on phones. */
main.content :is(.password-check-stages-table,.d19-result-table,.gallery-registration-change-table,.easter-wrong-day-table) :is(th,td),
main.content :is(.d19-result-table,.gallery-registration-change-table,.easter-wrong-day-table) td code {
  white-space: normal !important; overflow-wrap: anywhere;
}
main.content .affection-point-table { overflow-x: auto !important; }
main.content .affection-point-table table { min-width: 46rem !important; max-width: none !important; }
main.content .affection-point-table :is(col,th,td):first-child { width: 4rem !important; }
main.content .affection-point-table :is(col,th,td):last-child { width: 4.5rem !important; }
main.content .gallery-coordinate-table :is(col,th,td):first-child { width: 3.5rem !important; }
main.content .gallery-coordinate-table :is(col,th,td):nth-child(n+2) { width: calc((100% - 3.5rem) / 4) !important; }

footer .nav-footer > div { margin: 0 !important; }
footer .nav-footer > div:empty { display: none; }
/* Content tables size to their contents; Gallery retains its coordinate layout. */
main.content :is(.table-responsive, .quarto-bootstrap-table) {
  width: fit-content !important;
  max-width: 100% !important;
  min-width: 0 !important;
  overflow-x: auto !important;
  margin-inline: 0 !important;
}
main.content table:not(.gallery-coordinate-table table, .gallery-trigger-group table, #gallery-non-gallery-index table) {
  width: auto !important;
  min-width: 0 !important;
  max-width: 100% !important;
  table-layout: auto !important;
}
main.content table:not(.gallery-coordinate-table table, .gallery-trigger-group table, #gallery-non-gallery-index table) :is(col,th,td) {
  width: auto !important;
  min-width: 0 !important;
  max-width: none !important;
}
main.content table.table :is(th,td) {
  text-align: left !important;
  vertical-align: top;
}
main.content table.table th {
  white-space: nowrap !important;
  padding: .65rem .8rem !important;
}
main.content table.table td {
  padding: .6rem .8rem !important;
}
main.content table:not(.gallery-coordinate-table table, .gallery-trigger-group table, #gallery-non-gallery-index table) td {
  white-space: normal !important;
  overflow-wrap: anywhere;
}
main.content table:not(.gallery-coordinate-table table, .gallery-trigger-group table, #gallery-non-gallery-index table) td code {
  white-space: normal !important;
  overflow-wrap: anywhere !important;
  max-width: 100%;
}

/* Long English headers stay intact; overflowing tables scroll locally. */
main.content table:not(.gallery-coordinate-table table, .gallery-trigger-group table, #gallery-non-gallery-index table) th { white-space: nowrap !important; }
main.content .pw-table-scroll { width: fit-content; max-width: 100%; overflow-x: auto; margin-block: 1.35rem 1.8rem; }
main.content .pw-table-scroll > table { margin-block: 0; }
html[lang^="en"] #gallery-trigger-index .gallery-trigger-group :is(col,th,td):nth-child(3),
html[lang^="en"] #gallery-non-gallery-index.gallery-non-gallery-index :is(col,th,td):nth-child(3) { width: 10.5rem !important; }

/* Threshold expressions are identifiers, not prose: keep each condition intact. */
main.content :is(.affection-difference-table, .affection-outcome-table, .affection-kiss-table) table:not(#gallery-non-gallery-index table) :is(th,td):first-child,
main.content :is(.affection-difference-table, .affection-outcome-table, .affection-kiss-table) table:not(#gallery-non-gallery-index table) td:first-child code {
  white-space: nowrap !important;
  overflow-wrap: normal !important;
  word-break: normal !important;
}

/* A compact definition list preserves name-variable pairs across screen sizes. */
.pw-variable-grid { display: grid; grid-template-columns: 1fr; width: fit-content; max-width: 100%; margin-block: 1.35rem 1.8rem; border: 1px solid var(--pw-border); border-radius: .65rem; overflow: hidden; }
.pw-variable-grid > div { display: grid; grid-template-columns: 6rem minmax(0,1fr); align-items: baseline; gap: .8rem; padding: .65rem .85rem; border-bottom: 1px solid var(--pw-border); }
.pw-variable-grid > div:last-child { border-bottom: 0; }
.pw-variable-grid dt { color: var(--pw-heading); font-weight: 650; }
.pw-variable-grid dd { margin: 0; }
@media (min-width: 760px) {
 .pw-variable-grid { grid-template-columns: repeat(2,minmax(0,1fr)); }
 .pw-variable-grid > div:nth-child(odd) { border-right: 1px solid var(--pw-border); }
 .pw-variable-grid > div:nth-last-child(-n+2) { border-bottom: 0; }
}
/* Real subsection headings stand apart from body text and inline code chips. */
main.content h3:not(.pw-entry-grid h3) { font-size: 1.22rem; font-weight: 750; line-height: 1.45; color: var(--pw-heading) !important; padding-bottom: .45rem; border-bottom: 1px solid var(--pw-border); }
body main.content h3:not(.pw-entry-grid h3) code { color: inherit !important; background: transparent !important; border: 0; padding: 0; font-size: 1em; box-shadow: none; }

/* Two ordered halves use wide reading space without stretching individual columns. */
.pw-lore-columns { container-type: inline-size; margin-block: 1.35rem 1.8rem; }
main.content .pw-lore-columns > .compendium-lore-table { margin-block: 0 1rem !important; }
@container (min-width: 48rem) {
  main.content .pw-lore-columns > .compendium-lore-table { display: inline-block; vertical-align: top; margin-right: 1rem !important; }
}

/* Editorial surfaces and interaction states. Geometry stays in pw-guide-theme.css. */
body :is(.navbar, .sidebar-link, .pw-panel-toolbar,
  .pw-panel-toggle, .pw-edge-toggle, .aa-DetachedContainer,
  #quarto-header .quarto-secondary-nav) {
  -webkit-backdrop-filter: none !important;
  backdrop-filter: none !important;
}
body .navbar { background: var(--pw-shell-surface-raised) !important; box-shadow: none; }
body :is(#quarto-sidebar, #quarto-margin-sidebar, .pw-panel-toolbar,
  #quarto-header .quarto-secondary-nav) { background: var(--pw-shell-surface) !important; }
body :is(.navbar .dropdown-menu, .pw-edge-toggle) { background: var(--pw-surface) !important; }
body :is(.sidebar-link, .pw-panel-toggle, .pw-edge-toggle) {
  background-image: none !important;
  box-shadow: none !important;
}
body .sidebar-item .sidebar-link { border-color: transparent; }
body .sidebar-item .sidebar-link.active::before { box-shadow: none; }
body :is(.navbar .nav-link.active, .sidebar-item .sidebar-link.active,
  #TOC .nav-link.active) { color: var(--pw-primary) !important; }
body #TOC .nav-link:hover { color: var(--pw-primary-hover) !important; }
body :is(a, button, summary, input, select):focus-visible {
  outline-color: var(--pw-focus);
}
body .pw-home-shortcuts a:first-child:is(:hover, :focus-visible) { color: var(--pw-on-primary); }
body :is(.callout, .pw-entry-grid > .g-col-12, main.content table, .gallery-locator) {
  box-shadow: none !important;
}
body main.content .pw-entry-grid h3 a:not(.anchorjs-link) {
  color: var(--pw-heading) !important;
  text-decoration: none !important;
}
body main.content .pw-entry-grid h3 a:is(:hover, :focus-visible) { color: var(--pw-primary) !important; }
body main.content .pw-entry-grid h3 { border-bottom-color: transparent; }
body :is(.gallery-locator input, .gallery-locator select, .aa-Input) {
  background: var(--pw-surface);
  color: var(--pw-text);
  border-color: var(--pw-border-strong);
}
/* Syntax accents are confined to fenced code; inline identifiers keep one color. */
body pre code span:is(.kw, .cf) { color: var(--pw-syntax-keyword); }
body pre code span:is(.st, .ch, .vs) { color: var(--pw-syntax-string); }
body pre code span:is(.fu, .bu) { color: var(--pw-syntax-function); }
body pre code span:is(.dv, .bn, .fl) { color: var(--pw-syntax-number); }
body pre code span:is(.co, .cv) { color: var(--pw-syntax-comment); }

/* Breadcrumb context should stay neutral, including Bootstrap's active item. */
body .quarto-page-breadcrumbs {
  --bs-breadcrumb-item-active-color: var(--pw-text-soft);
  --bs-breadcrumb-divider-color: var(--pw-text-faint);
}
body .quarto-page-breadcrumbs .breadcrumb-item.active,
body .quarto-page-breadcrumbs .breadcrumb-item:last-child a { color: var(--pw-text-soft) !important; }
body .quarto-page-breadcrumbs .breadcrumb-item::before { color: var(--pw-text-faint); }

/* Inset every menu row equally; Quarto otherwise removes the first/last gap. */
body .navbar .dropdown-menu {
  padding: .45rem !important;
  border-radius: var(--pw-radius-md);
}
body .navbar .dropdown-menu .dropdown-item {
  margin: 0;
  border-radius: var(--pw-radius-sm);
}
body pre code span.op { color: var(--pw-syntax-keyword); }
body pre code span:is(.cn, .sc, .va) { color: var(--pw-syntax-number); }

/* Highlighted blocks use the same reading surface as plain fenced blocks. */
body div.sourceCode { background: var(--pw-code-bg) !important; box-shadow: none; }
body div.sourceCode pre.sourceCode {
  background: var(--pw-code-bg) !important;
  border: 0;
  margin: 0;
  padding: 1rem 1.05rem;
  box-shadow: none;
}
body pre.sourceCode > code.sourceCode,
body pre.sourceCode > code.sourceCode > span[id] {
  color: var(--pw-text);
  background: transparent;
}

/* Equal hover/selected geometry in the desktop navigation. */
body .navbar .nav-link { border-radius: var(--pw-radius-md) !important; }
/* Extend only the narrow-layout TOC surface through its outer grid gutter. */
@media (min-width: 768px) and (max-width: 1099.98px) {
  body #quarto-margin-sidebar {
    grid-column: body-end / screen-end;
    width: auto;
    padding-right: 3vw;
  }
}
body #quarto-margin-sidebar {
  -webkit-backdrop-filter: none !important;
  backdrop-filter: none !important;
}
/* Glass is limited to transient layers; reading surfaces remain opaque. */
@supports (backdrop-filter: blur(6px)) {
  body .aa-DetachedOverlay {
    -webkit-backdrop-filter: blur(6px) !important;
    backdrop-filter: blur(6px) !important;
  }
  body .navbar .dropdown-menu {
    background: color-mix(in srgb, var(--pw-surface) 96%, transparent) !important;
    -webkit-backdrop-filter: blur(8px) !important;
    backdrop-filter: blur(8px) !important;
  }
}
@media (prefers-reduced-transparency: reduce), (forced-colors: active) {
  body :is(.aa-DetachedOverlay, .navbar .dropdown-menu) {
    -webkit-backdrop-filter: none !important;
    backdrop-filter: none !important;
  }
  body .navbar .dropdown-menu { background: var(--pw-surface) !important; }
}
/* Match the adjacent theme/language tools; color marks system following. */
.navbar .quarto-navbar-tools .pw-theme-auto { cursor: pointer; }
.pw-theme-auto svg { width: 1.12rem; height: 1.12rem; }
.navbar .quarto-navbar-tools .pw-theme-auto[aria-pressed="true"] {
  color: var(--pw-primary) !important;
}

/* Let the brand truncate before full navigation labels overlap the tools. */
@media (min-width: 992px) {
  #quarto-header #navbarCollapse { flex: 1 0 auto; }
  #quarto-header .navbar-nav { column-gap: .25rem; }
}
