/* The family interface reads the same palette as the selected illustration. */
:root[data-child-theme="gothic"] {
  --paper: #f3eaee;
  --surface: #fff9fc;
  --text: #352032;
  --muted: #684959;
  --accent: #792c56;
  --on-accent: #fff8fc;
  --gold: #8f5b35;
  --border: #dcc2cf;
  --panel: #f1dce8;
  --panel-border: #c894ac;
  --shadow: 0 16px 42px #4d193a16;
  --world-ink: #f8e7ef;
  --world-muted: #d9b9cd;
  --world-accent: #ec9fc7;
  --world-edge: #86536d;
  --world-backdrop: radial-gradient(ellipse at 79% 24%, #5f2847 0, transparent 51%),
    linear-gradient(128deg, #231721, #331b2b 70%, #21141d);
}

:root[data-child-theme="gothic"][data-theme="dark"] {
  --paper: #1b131a;
  --surface: #2a1c27;
  --text: #f9e9f1;
  --muted: #d3b4c5;
  --accent: #efa7cc;
  --on-accent: #361427;
  --gold: #e9b581;
  --border: #5d3a50;
  --panel: #352032;
  --panel-border: #80536a;
  --shadow: 0 18px 48px #0c070a66;
}

:root[data-child-theme="kpop"] {
  --paper: #f7f1fd;
  --surface: #fffbff;
  --text: #35234f;
  --muted: #635277;
  --accent: #7043b0;
  --on-accent: #fffaff;
  --gold: #a63871;
  --border: #ded0ef;
  --panel: #eee2fa;
  --panel-border: #c1a4e4;
  --shadow: 0 16px 44px #6e449b19;
  --world-ink: #fff8ff;
  --world-muted: #eaddff;
  --world-accent: #f9bde5;
  --world-edge: #9c71dc;
  --world-backdrop: radial-gradient(ellipse at 85% 0%, #be64af 0, transparent 45%),
    radial-gradient(ellipse at 70% 90%, #6246ad 0, transparent 55%),
    linear-gradient(140deg, #2b1846, #452861);
}

:root[data-child-theme="kpop"][data-theme="dark"] {
  --paper: #20162d;
  --surface: #2c2040;
  --text: #faedff;
  --muted: #d0bce5;
  --accent: #d8adff;
  --on-accent: #30154b;
  --gold: #f6a6dc;
  --border: #594378;
  --panel: #36264d;
  --panel-border: #8063ad;
  --shadow: 0 18px 48px #0c061c55;
}

:root[data-child-theme="dungeon"] {
  --paper: #f2e7d5;
  --surface: #fff8eb;
  --text: #3e2923;
  --muted: #6e5143;
  --accent: #864235;
  --on-accent: #fff8e8;
  --gold: #805917;
  --border: #ddc5aa;
  --panel: #ecdbc1;
  --panel-border: #b99473;
  --shadow: 0 12px 28px #53352022;
  --world-ink: #fff0d6;
  --world-muted: #e1c8a5;
  --world-accent: #ffd18c;
  --world-edge: #b78b62;
  --world-backdrop: repeating-linear-gradient(0deg, transparent 0 31px, #f8cd9720 31px 32px),
    repeating-linear-gradient(90deg, transparent 0 31px, #f8cd9720 31px 32px),
    radial-gradient(ellipse at 77% 52%, #684535 0, #34241f 73%);
}

:root[data-child-theme="dungeon"][data-theme="dark"] {
  --paper: #241a16;
  --surface: #30231b;
  --text: #fcebd1;
  --muted: #d2b99b;
  --accent: #efaa84;
  --on-accent: #361d16;
  --gold: #f4bf70;
  --border: #604737;
  --panel: #403025;
  --panel-border: #8a6a4e;
  --shadow: 0 16px 36px #170d0877;
}

:root[data-child-theme="pets"] {
  --paper: #fff3f7;
  --surface: #fffafd;
  --text: #47344f;
  --muted: #6c526f;
  --accent: #934578;
  --on-accent: #fff9fd;
  --gold: #327260;
  --border: #efd2e1;
  --panel: #f8ddec;
  --panel-border: #d5a7c2;
  --shadow: 0 16px 43px #843c6c19;
  --world-ink: #4a3252;
  --world-muted: #63476b;
  --world-accent: #8c3c71;
  --world-edge: #d9a7c2;
  --world-backdrop: radial-gradient(circle at 90% 17%, #fcfbdb 0, transparent 34%),
    radial-gradient(circle at 76% 83%, #c6ebdd 0, transparent 41%),
    linear-gradient(132deg, #fae1ee, #eadcf8 81%);
}

:root[data-child-theme="pets"][data-theme="dark"] {
  --paper: #261c2b;
  --surface: #32253a;
  --text: #fff0f8;
  --muted: #dfc2d7;
  --accent: #f5b5df;
  --on-accent: #401c36;
  --gold: #9ce4cf;
  --border: #644965;
  --panel: #433047;
  --panel-border: #8a638c;
  --shadow: 0 16px 46px #140d1866;
  --world-ink: #fff0f8;
  --world-muted: #edc7e4;
  --world-accent: #fac0e4;
  --world-edge: #986e95;
  --world-backdrop: radial-gradient(circle at 87% 14%, #596765 0, transparent 39%),
    linear-gradient(132deg, #39243b, #513451 81%);
}

:root[data-child-theme="velvet"] {
  --paper: #f5eee4;
  --surface: #fffaf2;
  --text: #3c2b28;
  --muted: #6c5349;
  --accent: #75364d;
  --on-accent: #fff9ed;
  --gold: #826025;
  --border: #dfcdbb;
  --panel: #efe0cc;
  --panel-border: #bd9a77;
  --shadow: 0 16px 44px #6d402b1c;
  --world-ink: #fff1d8;
  --world-muted: #e8cdb7;
  --world-accent: #f4c579;
  --world-edge: #b28b5b;
  --world-backdrop: radial-gradient(ellipse at 82% 30%, #754356 0, transparent 42%),
    radial-gradient(ellipse at 90% 100%, #334c3c 0, transparent 53%),
    linear-gradient(132deg, #351d2b, #4c2637 55%, #252f28);
}

:root[data-child-theme="velvet"][data-theme="dark"] {
  --paper: #221b1d;
  --surface: #302326;
  --text: #fff0da;
  --muted: #dec4ad;
  --accent: #f0adb9;
  --on-accent: #421f31;
  --gold: #edc17a;
  --border: #634344;
  --panel: #432c32;
  --panel-border: #855d52;
  --shadow: 0 18px 46px #130b0c66;
}

:root[data-child-theme] :is(.hero-search button, .message-form .button-link) {
  background: var(--accent);
  color: var(--on-accent);
}

:root[data-child-theme] .editorial-card .editorial-banner {
  background: var(--panel);
  color: var(--accent);
}

.child-world {
  position: relative;
  isolation: isolate;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, .92fr);
  align-items: center;
  gap: clamp(1.2rem, 4.5vw, 4.5rem);
  min-height: 19rem;
  margin-block: clamp(1rem, 3.8vw, 2.75rem);
  padding: clamp(1.5rem, 4.8vw, 4rem);
  color: var(--world-ink, var(--text));
  background: var(--world-backdrop, var(--panel));
  border: 1px solid var(--world-edge, var(--border));
  border-radius: 1.25rem;
  box-shadow: var(--shadow);
  overflow: hidden;
}

.child-world-copy {
  position: relative;
  z-index: 1;
  min-width: 0;
}

.child-world-copy :is(h1, h2, h3) {
  margin: 0;
  color: var(--world-ink, var(--text));
  font: 700 clamp(2.45rem, 5.2vw, 4.75rem)/1.03 var(--serif);
  letter-spacing: -.045em;
  overflow-wrap: anywhere;
}

.child-world-copy p:not(.child-world-kicker) {
  max-width: 43ch;
  margin: .95rem 0 0;
  color: var(--world-muted, var(--muted));
  font-size: clamp(.95rem, 1.7vw, 1.08rem);
}

.child-world-kicker {
  display: flex;
  align-items: center;
  gap: .6rem;
  margin: 0 0 .8rem;
  color: var(--world-accent, var(--accent));
  font: 750 .72rem/1.5 var(--sans);
  letter-spacing: .17em;
  text-transform: uppercase;
}

.child-world-kicker::before {
  content: "";
  width: 1.65rem;
  height: 1px;
  background: currentColor;
}

.child-world-art {
  z-index: 1;
  display: grid;
  place-items: center;
  width: 100%;
  max-width: 27rem;
  height: auto;
  margin-inline: auto;
  color: var(--world-accent, var(--accent));
}

.child-world-art :is(svg, img) {
  display: block;
  width: 100%;
  height: auto;
}

.child-world-links {
  display: flex;
  flex-wrap: wrap;
  gap: .5rem;
  margin-top: 1.35rem;
}

.child-world-links :is(a, button) {
  display: inline-flex;
  align-items: center;
  gap: .45rem;
  min-height: 2.75rem;
  padding: .45rem .85rem;
  border: 1px solid var(--world-edge, var(--border));
  border-radius: .55rem;
  background: transparent;
  color: var(--world-ink, var(--text));
  font: 700 .85rem/1.3 var(--sans);
  text-decoration: none;
}

.child-world-links :is(a, button):first-child {
  background: var(--world-ink, var(--text));
  color: #302238;
}

:root[data-child-theme="pets"]:not([data-theme="dark"]) .child-world-links :is(a, button):first-child {
  color: #fff9fc;
}

.child-world-links :is(a, button):hover { text-decoration: underline; }
.child-world :focus-visible { outline-color: var(--world-accent, var(--gold)); }

.world-atlas {
  overflow: hidden;
  margin-block: 1.5rem;
  border: 1px solid var(--border);
  border-radius: 1rem;
  background: var(--surface);
  box-shadow: var(--shadow);
  scroll-margin-top: 5rem;
}

.atlas-peaks {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: .45rem;
  margin: 1rem 0;
  padding: 0;
  list-style: none;
}
.atlas-peaks li {
  display: grid;
  place-items: center;
  min-height: 5rem;
  padding: .5rem .2rem;
  border-block-start: 2px solid var(--atlas-accent);
  background: var(--atlas-panel);
  text-align: center;
}
.atlas-peaks small { color: var(--atlas-muted); }
.atlas-peaks strong { font: 750 clamp(1.35rem, 3vw, 2.15rem)/1 var(--atlas-display); }

:root[data-child-theme="gothic"] .child-world {
  border-radius: .35rem;
}

:root[data-child-theme="gothic"] .child-world::before {
  position: absolute;
  inset: .55rem;
  z-index: -1;
  content: "";
  border: 1px solid color-mix(in srgb, var(--world-edge) 65%, transparent);
  pointer-events: none;
}

:root[data-child-theme="gothic"] .child-world-copy :is(h1, h2, h3) {
  font-weight: 400;
  letter-spacing: -.025em;
}

:root[data-child-theme="kpop"] .child-world-copy :is(h1, h2, h3) {
  font-family: var(--sans);
  font-weight: 900;
  letter-spacing: -.055em;
}

:root[data-child-theme="kpop"] .child-world-links :is(a, button),
:root[data-child-theme="pets"] .child-world-links :is(a, button) { border-radius: 999px; }

:root[data-child-theme="dungeon"] .child-world {
  border-width: 3px;
  border-radius: .25rem;
  box-shadow: inset 0 0 0 4px #2b1d18, var(--shadow);
}

:root[data-child-theme="dungeon"] .child-world-copy :is(h1, h2, h3) {
  font-family: "Cascadia Mono", Consolas, monospace;
  font-size: clamp(2rem, 4.3vw, 4rem);
  text-shadow: 3px 3px 0 #281a16;
}

:root[data-child-theme="dungeon"] .child-world-links :is(a, button) {
  border-radius: .15rem;
  font-family: "Cascadia Mono", Consolas, monospace;
}

:root[data-child-theme="pets"] .child-world { border-radius: clamp(1.4rem, 4vw, 2.5rem); }

:root[data-child-theme="pets"] .child-world-copy :is(h1, h2, h3) {
  font-family: "Arial Rounded MT Bold", "Trebuchet MS", var(--sans);
  letter-spacing: -.04em;
}

.child-theme-picker {
  display: flex;
  flex-wrap: wrap;
  gap: .5rem;
  margin-block: 1rem 1.75rem;
}

.child-theme-choice {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .45rem;
  min-height: 2.75rem;
  padding: .5rem .8rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text);
  font: 700 .84rem/1.35 var(--sans);
  text-decoration: none;
}

.child-theme-choice::before {
  content: "";
  width: .66rem;
  height: .66rem;
  flex: 0 0 .66rem;
  border-radius: 50%;
  background: var(--choice-color, var(--accent));
}

.child-theme-choice:is([data-theme-choice="gothic"], [data-child-theme-choice="gothic"], [href*="gothic"]) { --choice-color: #953c68; }
.child-theme-choice:is([data-theme-choice="kpop"], [data-child-theme-choice="kpop"], [href*="kpop"]) { --choice-color: #8c62d1; }
.child-theme-choice:is([data-theme-choice="dungeon"], [data-child-theme-choice="dungeon"], [href*="dungeon"]) { --choice-color: #a06b40; }
.child-theme-choice:is([data-theme-choice="pets"], [data-child-theme-choice="pets"], [href*="pets"]) { --choice-color: #c971a7; }
.child-theme-choice:is([data-theme-choice="velvet"], [data-child-theme-choice="velvet"], [href*="velvet"]) { --choice-color: #873e55; }

.child-theme-choice:is(:hover, [aria-pressed="true"], [aria-current]) {
  border-color: var(--accent);
  background: var(--panel);
}

#child-theme-picker {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(9rem, 100%), 1fr));
  gap: .8rem;
  margin-bottom: 0;
}

#child-theme-picker .child-theme-choice {
  display: grid;
  justify-content: stretch;
  gap: .25rem;
  padding: .5rem;
  border-radius: .85rem;
}

#child-theme-picker .child-theme-choice::before { display: none; }
#child-theme-picker img {
  display: block;
  width: 100%;
  height: auto;
  margin-bottom: .3rem;
  border-radius: .5rem;
  background: color-mix(in srgb, var(--choice-color) 20%, var(--paper));
}
#child-theme-picker :is(strong, span) { padding-inline: .3rem; }
#child-theme-picker strong { font: 700 1.12rem var(--serif); }
#child-theme-picker span { color: var(--muted); font-size: .75rem; }

@media (max-width: 690px) {
  .child-world {
    grid-template-columns: minmax(0, 1fr);
    gap: 1rem;
    min-height: 0;
  }

  .child-world-art { max-width: 19rem; }
  .child-theme-picker { gap: .4rem; }
}
