:root {
  --pd-bg: #f4f6f3;
  --pd-surface: #fff;
  --pd-subtle: #e8efeb;
  --pd-ink: #182823;
  --pd-muted: #41554d;
  --pd-line: #c2cfc8;
  --pd-control: #657e71;
  --pd-accent: #12594d;
  --pd-accent-hover: #083e35;
  --pd-accent-soft: #dfede6;
  --pd-alert: #942c36;
  --pd-warn: #744719;
  --pd-night: #142d29;
  --pd-on-night: #f2faf5;
  --pd-on-night-muted: #cce4d9;
  --pd-font: "Instrument Sans", "PingFang TC", "Noto Sans TC", "Microsoft JhengHei", system-ui, sans-serif;
  --pd-width: 89rem;
  --pd-gutter: clamp(1rem, 4vw, 3.5rem);
  --pd-radius: .6rem;
}

.pandoronia-sitebar {
  position: relative;
  z-index: 2;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .35rem 1.5rem;
  padding: .6rem max(var(--pd-gutter), calc((100% - var(--pd-width)) / 2));
  border: 0;
  border-bottom: 1px solid var(--pd-line);
  background: var(--pd-surface);
  color: var(--pd-ink);
  font: 600 1rem/1.5 var(--pd-font);
}

.pandoronia-sitebar nav { display: flex; flex-wrap: wrap; gap: .25rem 1rem; }
.pandoronia-sitebar a { display: inline-flex; align-items: center; min-height: 2.75rem; color: var(--pd-accent); text-underline-offset: .2em; }
.pandoronia-sitebar .pandoronia-brand { color: var(--pd-ink); font-size: 1.15rem; font-weight: 800; text-decoration: none; }
.pandoronia-sitebar .pandoronia-skip { position: absolute; left: var(--pd-gutter); top: .6rem; transform: translateY(-200%); padding-inline: .75rem; background: var(--pd-surface); }
.pandoronia-sitebar .pandoronia-skip:focus { transform: none; }
#pandoronia-content { block-size: 0; }
.pandoronia-related a { font-weight: 700; }

body[data-pandoronia-layout="reading"] {
  --bg: var(--pd-bg) !important;
  --bg-2: var(--pd-subtle) !important;
  --paper: var(--pd-surface) !important;
  --surface: var(--pd-surface) !important;
  --surface-2: var(--pd-subtle) !important;
  --panel: var(--pd-surface) !important;
  --panel-2: var(--pd-subtle) !important;
  --card: var(--pd-surface) !important;
  --ink: var(--pd-ink) !important;
  --text: var(--pd-ink) !important;
  --fg: var(--pd-ink) !important;
  --muted: var(--pd-muted) !important;
  --sub: var(--pd-muted) !important;
  --line: var(--pd-line) !important;
  --border: var(--pd-line) !important;
  --accent: var(--pd-accent) !important;
  --teal: var(--pd-accent) !important;
  --cyan: var(--pd-accent) !important;
  --gold: var(--pd-warn) !important;
  --ok: var(--pd-accent) !important;
  --bad: var(--pd-alert) !important;
  margin: 0 !important;
  background: var(--pd-bg) !important;
  color: var(--pd-ink) !important;
  color-scheme: light;
  font: 1rem/1.65 var(--pd-font) !important;
  min-height: 100vh;
}

body[data-pandoronia-layout="reading"] > :where(main, .wrap, .container, .page-shell, .page-wrap, .page:not(:has(.page-inner)), .shell) {
  width: min(100% - 2 * var(--pd-gutter), var(--pd-width)) !important;
  max-width: none !important;
  margin-inline: auto !important;
}

body[data-pandoronia-layout="reading"] :not(:where(.battle-stage, .battle-stage *)):where(h1, h2, h3, h4, h5, h6) {
  color: var(--pd-ink) !important;
  font-family: var(--pd-font) !important;
  line-height: 1.3 !important;
  letter-spacing: normal !important;
  text-wrap: pretty;
  overflow-wrap: anywhere;
}

body[data-pandoronia-layout="reading"] :not(:where(.battle-stage, .battle-stage *)):where(h1) { font-size: clamp(1.85rem, 3.8vw, 3rem) !important; }
body[data-pandoronia-layout="reading"] :not(:where(.battle-stage, .battle-stage *)):where(h2) { font-size: clamp(1.35rem, 2.5vw, 1.75rem) !important; }
body[data-pandoronia-layout="reading"] :not(:where(.battle-stage, .battle-stage *)):where(h3) { font-size: clamp(1.125rem, 1.7vw, 1.35rem) !important; }

body[data-pandoronia-layout="reading"] :not(:where(.battle-stage, .battle-stage *)):where(p, li, dt, dd, label, summary, blockquote) {
  color: var(--pd-ink) !important;
  line-height: 1.65 !important;
  overflow-wrap: anywhere;
}

body[data-pandoronia-layout="reading"] :not(:where(.battle-stage, .battle-stage *)):where(p, li, dt, dd, label, summary, blockquote) {
  font-size: max(1rem, 1em);
}

body[data-pandoronia-layout="reading"] :not(:where(.battle-stage, .battle-stage *)):where(.muted, .subtitle, .sub, .secondary, .secondary-text, .helper, .hint, .note, .description, .caption, .meta, .eyebrow, .kicker, .overline, .section-label, small, figcaption) {
  color: var(--pd-muted) !important;
  font-size: max(.875rem, .88em) !important;
  opacity: 1 !important;
  line-height: 1.5 !important;
}

body[data-pandoronia-layout="reading"] :not(:where(.battle-stage, .battle-stage *)):where(a) {
  color: var(--pd-accent) !important;
  text-underline-offset: .2em;
  overflow-wrap: anywhere;
}

body[data-pandoronia-layout="reading"] :not(:where(.battle-stage, .battle-stage *)):where(a:hover) { color: var(--pd-accent-hover) !important; text-decoration: underline; }

body[data-pandoronia-layout="reading"] :not(:where(.battle-stage, .battle-stage *)):where(.card, .panel, .metric, .data-card, .page-card, .section-card, .item-card, .codex-card, .character-card, .entity-card, .record-card, .toolbar, .controls, .sidebar, .side-panel, .topbar, .tabs, .filter-bar, .search-bar, .masthead, .hero, .site-header, .app-header, .intro, .section-head, details, dialog) {
  border-color: var(--pd-line) !important;
  background: var(--pd-surface) !important;
  color: var(--pd-ink) !important;
  box-shadow: none !important;
}

body[data-pandoronia-layout="reading"] :not(:where(.battle-stage, .battle-stage *)):where(.masthead, .hero, .intro) { border-radius: var(--pd-radius); }
body[data-pandoronia-layout="reading"] :not(:where(.battle-stage, .battle-stage *)):where(.badge, .tag, .pill, .chip) { background: var(--pd-subtle) !important; color: var(--pd-muted) !important; opacity: 1 !important; font-size: .875rem !important; }

body[data-pandoronia-layout="reading"] :not(:where(.battle-stage, .battle-stage *)):where(input:not([type="range"], [type="checkbox"], [type="radio"], [type="color"]), textarea, select, button, .button, .btn, [role="button"]) {
  min-height: 2.75rem;
  border: 1px solid var(--pd-control) !important;
  border-radius: .35rem;
  background: var(--pd-surface) !important;
  color: var(--pd-ink) !important;
  font: 600 max(.9375rem, 1em)/1.4 var(--pd-font) !important;
  padding: .5rem .75rem;
}

body[data-pandoronia-layout="reading"] :not(:where(.battle-stage, .battle-stage *)):where(input, textarea)::placeholder { color: var(--pd-muted) !important; opacity: 1; }
body[data-pandoronia-layout="reading"] :not(:where(.battle-stage, .battle-stage *)):where(button, [role="button"], input, select, textarea) { accent-color: var(--pd-accent); }
body[data-pandoronia-layout="reading"] :not(:where(.battle-stage, .battle-stage *)):where(button:hover, .button:hover, .btn:hover, [aria-current="page"], [aria-current="true"], [aria-selected="true"], [aria-pressed="true"], button.active) { background: var(--pd-accent-soft) !important; color: var(--pd-accent-hover) !important; }
body[data-pandoronia-layout="reading"] :not(:where(.battle-stage, .battle-stage *)):where([disabled]) { opacity: .72; cursor: default; }

[data-pandoronia-layout] :where(a, button, input, select, textarea, summary, [tabindex]):focus-visible {
  outline: 3px solid var(--pd-accent) !important;
  outline-offset: 3px !important;
  box-shadow: 0 0 0 3px var(--pd-surface) !important;
}

body[data-pandoronia-layout="reading"] :not(:where(.battle-stage, .battle-stage *)):where(table, th, td) { border-color: var(--pd-line) !important; color: var(--pd-ink) !important; font-size: max(.9375rem, 1em) !important; }
body[data-pandoronia-layout="reading"] :not(:where(.battle-stage, .battle-stage *)):where(table, td) { background: var(--pd-surface) !important; }
body[data-pandoronia-layout="reading"] :not(:where(.battle-stage, .battle-stage *)):where(th) { background: var(--pd-subtle) !important; }
body[data-pandoronia-layout="reading"] :not(:where(.battle-stage, .battle-stage *)):where(.table-wrap, .table-scroll) { overflow: auto; max-width: 100%; }
body[data-pandoronia-layout="reading"] :not(:where(.battle-stage, .battle-stage *)):where(code, pre) { color: var(--pd-muted) !important; overflow-wrap: anywhere; }
body[data-pandoronia-layout="reading"] :not(:where(.battle-stage, .battle-stage *)):where(pre) { white-space: pre-wrap; }
body[data-pandoronia-layout="reading"] :not(:where(.battle-stage, .battle-stage *)):where(img, video) { max-width: 100%; }
body[data-pandoronia-layout="reading"] :not(:where(.battle-stage, .battle-stage *)):where([hidden]) { display: none !important; }
body[data-pandoronia-layout="reading"] :not(:where(.battle-stage, .battle-stage *)):where(footer) { color: var(--pd-muted) !important; }
[data-pandoronia-layout="interactive"] :where(.pandoronia-sitebar) { background: var(--pd-night); color: var(--pd-on-night); border-color: var(--pd-control); }
[data-pandoronia-layout="interactive"] .pandoronia-sitebar :where(a) { color: var(--pd-on-night); }
[data-pandoronia-layout="interactive"] .pandoronia-sitebar .pandoronia-skip { background: var(--pd-night); }

/* The reading layout also covers legacy section names and data summaries. */
body[data-pandoronia-layout="reading"] > :where(header:not(.pandoronia-sitebar), nav) {
  background: var(--pd-surface) !important;
  color: var(--pd-ink) !important;
  border-color: var(--pd-line) !important;
}

body[data-pandoronia-layout="reading"] :not(:where(.battle-stage, .battle-stage *)):where(
  .graph-panel, .detail, .detail-inner, .panel-head, .route-note, .stamp, .inventory-stat,
  .control-bar, .scope-note, .progress-head, .side-status, .mobile-bar, .boundary,
  .fact-sheet, .source-row, .reward-row, .urban-card, .symmetry-card, .notice,
  .intro-card, .section-block, .reading-intro, .chapter-card, .stat-card
) {
  background: var(--pd-surface) !important;
  color: var(--pd-ink) !important;
  border-color: var(--pd-line) !important;
}
body[data-pandoronia-layout="reading"] :is(.stamp, .legend, .inventory-stat, .progress-head, .side-status, .nav-label, .metric, .directory-grid a) :is(span, strong, small, b, em),
body[data-pandoronia-layout="reading"] :is(.nav-label, .stamp, .legend, .masthead h1 em, .sidebar nav a span, .brand-mark) {
  color: var(--pd-muted) !important;
}
body[data-pandoronia-layout="reading"] :where(.graph-wrap) {
  background: var(--pd-night) !important;
}
body[data-pandoronia-layout="reading"] > .sidebar:has(+ .mobile-bar) {
  padding-top: 5rem;
}
body[data-pandoronia-layout="reading"]:has(> .sidebar + .mobile-bar) {
  overflow-x: clip;
}
body[data-pandoronia-layout="reading"]:has(> .sidebar + .mobile-bar) > .pandoronia-sitebar {
  z-index: 41;
}
body[data-pandoronia-layout="reading"] .page:has(.page-inner) {
  max-width: calc(100% - var(--sidebar));
}
body[data-pandoronia-layout="reading"] .page-inner :is(.progress-grid, .fact-sheet, .section-head) > * { min-width: 0; }
@media (max-width: 58rem) {
  body[data-pandoronia-layout="reading"] .page:has(.page-inner) { max-width: 100%; }
}
@media (max-width: 42rem) {
  body[data-pandoronia-layout="reading"] .page-inner :is(.progress-grid, .fact-sheet) { grid-template-columns: minmax(0, 1fr) !important; }
}

body[data-pandoronia-layout="interactive"] :where(.app:has(.source-status), .app:has(.map-progress)) {
  --text: var(--pd-on-night);
  --ink: var(--pd-on-night);
  --muted: var(--pd-on-night-muted);
  --line: #55786a;
  color: var(--pd-on-night);
}
body[data-pandoronia-layout="interactive"] :where(.app:has(.source-status), .app:has(.map-progress)) :where(.topbar, .route-panel, .action-panel, .stage, .loading, .dialogue-choices) {
  background-color: var(--pd-night);
  color: var(--pd-on-night);
}

body[data-pandoronia-layout="reading"]:has(.hero-video-frame) {
  --bg2: var(--pd-bg);
  --bg3: var(--pd-subtle);
  --card2: var(--pd-subtle);
  --pdn: var(--pd-accent);
  --pdn-glow: var(--pd-accent);
  --magenta: var(--pd-accent-hover);
  --aether: var(--pd-accent);
  --aether-deep: var(--pd-accent-hover);
  --faint: var(--pd-muted);
  --line2: var(--pd-line);
}

body[data-pandoronia-layout="reading"] :is(.hero-video-frame, .qcard, .latest-card, .episode-card, .ep-card) {
  background: var(--pd-surface) !important;
  border-color: var(--pd-line) !important;
  box-shadow: none !important;
}
body[data-pandoronia-layout="reading"] .hero-video-frame {
  aspect-ratio: auto;
  min-height: 0;
  padding: .75rem 1rem;
  text-align: center;
}
body[data-pandoronia-layout="reading"] .hero-video-frame p { margin: 0; }
body[data-pandoronia-layout="reading"] :is(.hero-title, .hero-title .dim, .hero-sub, .hero .eyebrow) {
  text-shadow: none !important;
}
body[data-pandoronia-layout="reading"] .hero-title .dim { color: var(--pd-accent) !important; }
body[data-pandoronia-layout="reading"] .qcard :is(strong, b, small, span) {
  color: var(--pd-ink) !important;
  text-shadow: none !important;
}
body[data-pandoronia-layout="reading"] :is(.qcard, .latest, .hero-video-frame) {
  scroll-margin-top: 5rem;
}

body[data-pandoronia-layout="reading"] :is(
  .route-note, .map-card, .directory-card, .masthead__seal, .flowline, .policy-banner,
  .lead-card, .search-field, .select-field, .modal-body, .completion-card, .scope-card
) {
  background: var(--pd-surface) !important;
  border-color: var(--pd-line) !important;
  color: var(--pd-ink) !important;
}

body[data-pandoronia-layout="reading"] :is(
  .route-note, .map-card, .directory-card, .masthead__seal, .flowline, .policy-banner,
  .notice, .lead-card, .search-field, .select-field, .brand, .modal-body, .completion-card, .scope-card
) :is(b, strong, small, span, kbd) {
  color: var(--pd-ink) !important;
}

body[data-pandoronia-layout="reading"] :is(.battle-top, .standby) {
  background: var(--pd-surface) !important;
  color: var(--pd-ink) !important;
}
body[data-pandoronia-layout="reading"] .battle-top :is(strong, span) { color: var(--pd-ink) !important; }
body[data-pandoronia-layout="reading"] .art-brief { color: var(--pd-on-night) !important; }

body[data-pandoronia-layout="reading"] .page-inner :is(
  .section, .content-grid, .progress-board, .reader, .table-wrap, .table-scroll, pre
) {
  min-width: 0;
  max-width: 100%;
}
body[data-pandoronia-layout="reading"] .page-inner :is(.table-wrap, .table-scroll, .table-shell, .table-frame) {
  overflow-x: auto;
  max-width: 100%;
}
body[data-pandoronia-layout="reading"] .page-inner :is(a, code) { overflow-wrap: anywhere; }

body[data-pandoronia-layout="interactive"] :is(.audit-label, .audit-bar code, .pane-label) {
  color: var(--pd-on-night) !important;
}
body[data-pandoronia-layout="interactive"] :is(.take-badge, .viewer-hint, .viewer-status, .eyebrow, .loading-text) {
  color: var(--pd-on-night-muted);
}

body[data-pandoronia-layout="reading"] :is(.status-card, .segment, .principle, .boundary-note) {
  background: var(--pd-surface) !important;
  color: var(--pd-ink) !important;
  border-color: var(--pd-line);
}
body[data-pandoronia-layout="reading"] .page-inner :is(.domain-card, .domain-grid, .source, .tool, .conflict) {
  min-width: 0;
  max-width: 100%;
}
body[data-pandoronia-layout="reading"] .page-inner .badge {
  white-space: normal;
  overflow-wrap: anywhere;
  max-width: 100%;
}
@media (max-width: 52rem) {
  body[data-pandoronia-layout="reading"] .page-inner .domain-grid {
    grid-template-columns: minmax(0, 1fr);
  }
}
body[data-pandoronia-layout="interactive"] :is(.audit-label, .audit-label + code, .pane-label),
body[data-pandoronia-layout="interactive"] [class*="audit"] code {
  color: var(--pd-on-night) !important;
}
