:root {
  --paper: #eee9df;
  --paper-deep: #e2dbcf;
  --ink: #1d211f;
  --muted: #696a63;
  --line: rgba(29, 33, 31, .2);
  --accent: #b13c2e;
  --blue: #315f67;
  --focus: #155ed1;
  color-scheme: light;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
button, input { font: inherit; }
button { color: inherit; }

body.playground-child {
  min-height: 100vh;
  margin: 0;
  background:
    radial-gradient(circle at 18% 4%, rgba(255,255,255,.8), transparent 32rem),
    linear-gradient(135deg, rgba(177,60,46,.035) 25%, transparent 25%) 0 0 / 28px 28px,
    var(--paper);
  color: var(--ink);
  font-family: "DM Mono", ui-monospace, monospace;
}

.playground-chrome {
  position: sticky;
  top: 0;
  z-index: 20;
  height: 38px;
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 0 14px;
  background: rgba(238,233,223,.93);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(14px);
}
.playground-chrome span { width: 9px; height: 9px; border: 1px solid var(--ink); border-radius: 50%; }
.playground-chrome span:first-child { background: var(--accent); }
.playground-chrome p { margin: 0 auto; padding-right: 42px; font-size: 10px; text-transform: uppercase; letter-spacing: .14em; }

.atlas-shell { width: min(1180px, 100%); margin: 0 auto; padding: 20px 16px 44px; }
.atlas-header { display: flex; justify-content: space-between; align-items: end; gap: 24px; border-bottom: 1px solid var(--ink); padding-bottom: 14px; }
.eyebrow { margin: 0 0 6px; color: var(--accent); font-size: 12px; line-height: 1.45; text-transform: uppercase; letter-spacing: .12em; }
h1, h2, h3 { font-family: "Newsreader", Georgia, serif; font-weight: 500; }
h1 { margin: 0; font-size: clamp(36px, 8vw, 70px); line-height: .86; letter-spacing: -.045em; }
h2 { margin: 0; font-size: clamp(32px, 6vw, 58px); line-height: .96; letter-spacing: -.035em; }
h3 { margin: 0; font-size: 24px; }
.header-meta { display: grid; justify-items: end; gap: 6px; max-width: 300px; color: var(--muted); font-size: 12px; line-height: 1.4; text-align: right; }
.text-button { min-width: 44px; min-height: 44px; padding: 0 8px; border: 0; background: none; text-decoration: underline; text-underline-offset: 3px; cursor: pointer; }

.atlas-nav { min-height: 48px; display: flex; align-items: center; gap: 6px; border-bottom: 1px solid var(--line); }
.atlas-tabs { min-height: 48px; display: flex; align-items: center; gap: 6px; }
.nav-tab, .context-toggle { min-height: 44px; display: inline-flex; align-items: center; padding: 0 12px; border: 0; background: transparent; color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .08em; cursor: pointer; }
.nav-tab.is-active { color: var(--ink); box-shadow: inset 0 -2px var(--accent); }
.context-toggle { margin-left: auto; gap: 8px; text-transform: none; letter-spacing: 0; }
.context-toggle input { accent-color: var(--accent); }

.compare-view { padding-top: 14px; }
.session-line { display: flex; justify-content: space-between; gap: 16px; align-items: baseline; }
.session-line p { margin: 0; font-family: "Newsreader", Georgia, serif; font-size: 19px; }
.session-line .progress { font-family: "DM Mono", monospace; font-size: 12px; }
.progress-track { height: 2px; margin: 8px 0 14px; overflow: hidden; background: var(--line); }
.progress-track i { display: block; width: 0; height: 100%; background: var(--accent); transition: width .35s ease; }

.comparison-stage { position: relative; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 10px; align-items: stretch; }
.artwork-choice {
  position: relative;
  min-width: 0;
  min-height: 326px;
  display: grid;
  grid-template-rows: 24px minmax(250px, 1fr) auto;
  gap: 8px;
  padding: 9px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 0;
  background: rgba(255,255,255,.3);
  text-align: left;
  cursor: pointer;
  transition: border-color .18s ease, background-color .18s ease, transform .18s ease;
}
.artwork-choice:not(:disabled):hover { border-color: var(--ink); background: rgba(255,255,255,.65); transform: translateY(-2px); }
.artwork-choice:disabled { cursor: wait; }
.artwork-choice.is-selected { border-color: var(--accent); background: rgba(177,60,46,.08); }
.artwork-choice:focus-visible, button:focus-visible, input:focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; }
.choice-index { font-size: 12px; color: var(--muted); }
.image-well { min-width: 0; min-height: 250px; display: grid; place-items: center; overflow: hidden; background: #d8d2c7; }
.image-well img { display: block; width: 100%; height: 100%; min-width: 0; max-height: 390px; object-fit: contain; }
.artwork-context { min-height: 48px; display: grid; align-content: start; gap: 2px; }
.artwork-context strong { font-family: "Newsreader", Georgia, serif; font-size: 17px; line-height: 1.05; }
.artwork-context small { color: var(--muted); font-size: 12px; line-height: 1.4; }
.versus { position: absolute; z-index: 2; left: 50%; top: 48%; translate: -50% -50%; display: grid; place-items: center; width: 34px; height: 34px; border: 1px solid var(--ink); border-radius: 50%; background: var(--paper); font-family: "Newsreader", serif; font-style: italic; font-size: 14px; }

.outcome-controls { display: flex; justify-content: center; gap: 4px; min-height: 50px; padding-top: 6px; }
.outcome-controls button, .reveal-strip button, .summary-actions button, .primary-action, .error-banner button {
  min-height: 44px;
  padding: 0 14px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
  cursor: pointer;
}
.outcome-controls button:hover, .reveal-strip button:hover { color: var(--ink); border-color: var(--line); }
.outcome-controls button:disabled { opacity: .4; cursor: wait; }

.reveal-strip { min-height: 58px; display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 7px 10px; border-block: 1px solid var(--line); background: rgba(255,255,255,.35); }
.reveal-strip p { margin: 0; font-size: 12px; line-height: 1.45; }
.reveal-strip > div:first-child { display: grid; gap: 3px; }
.reveal-strip > div:last-child { display: flex; }
.reveal-sources a { color: var(--blue); text-underline-offset: 2px; }
.reveal-strip .next-button, .primary-action { border-color: var(--ink); color: var(--ink); }

.error-banner { margin-bottom: 10px; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 8px 12px; border: 1px solid var(--accent); color: var(--accent); font-size: 12px; }

.session-summary { padding: 34px 18px; border: 1px solid var(--ink); background: rgba(255,255,255,.45); text-align: center; }
.session-summary h2 { max-width: 520px; margin: 0 auto 14px; }
.session-summary > p:not(.eyebrow) { max-width: 520px; margin: 0 auto; color: var(--muted); font-size: 13px; line-height: 1.6; }
.summary-actions { display: flex; justify-content: center; gap: 8px; margin-top: 20px; }
.summary-actions .primary-action { background: var(--ink); color: var(--paper); }
.summary-actions button:last-child { border-color: var(--line); }

.session-history { margin-top: 12px; border-top: 1px solid var(--line); font-size: 12px; }
.session-history summary { min-height: 44px; display: flex; justify-content: space-between; align-items: center; cursor: pointer; }
.session-history ol { margin: 0; padding: 0; list-style: none; }
.session-history li { display: grid; grid-template-columns: 28px 1fr; gap: 8px; padding: 8px 0; border-top: 1px solid var(--line); }

.atlas-view { padding-top: 28px; }
.atlas-intro { max-width: 720px; }
.atlas-intro > p:last-child { color: var(--muted); font-family: "Newsreader", serif; font-size: 19px; line-height: 1.45; }
.atlas-grid { display: grid; grid-template-columns: 1.1fr .9fr; gap: 12px; margin-top: 28px; }
.atlas-panel { min-height: 280px; padding: 16px; border: 1px solid var(--ink); background: rgba(255,255,255,.32); }
.signal-panel:has(.signal-list > .empty-state) { min-height: 172px; }
.panel-heading { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; padding-bottom: 12px; border-bottom: 1px solid var(--line); }
.panel-heading span { color: var(--muted); font-size: 12px; }
.signal-list { display: grid; }
.signal { display: grid; grid-template-columns: 1fr auto; gap: 4px 16px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.signal strong { font-family: "Newsreader", serif; font-size: 21px; }
.signal span, .signal small, .empty-state { color: var(--muted); font-size: 12px; line-height: 1.45; }
.signal small { grid-column: 1 / -1; }
.favorite-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; padding-top: 12px; }
.favorite { margin: 0; }
.favorite img { width: 100%; aspect-ratio: 1; object-fit: contain; background: var(--paper-deep); }
.favorite figcaption { padding-top: 5px; font-family: "Newsreader", serif; font-size: 13px; line-height: 1.1; }
.favorite small { display: block; color: var(--muted); font-family: "DM Mono", monospace; font-size: 12px; }
.favorite.image-unavailable::before { content: "Image unavailable"; min-height: 90px; display: grid; place-items: center; background: var(--paper-deep); color: var(--muted); font-size: 12px; }
.return-action { margin-top: 14px; }

.atlas-footer { display: flex; justify-content: space-between; gap: 24px; margin-top: 40px; padding-top: 14px; border-top: 1px solid var(--ink); color: var(--muted); font-size: 12px; line-height: 1.45; }
.atlas-footer p { max-width: 480px; margin: 0; }

@media (max-width: 680px) {
  .atlas-shell { padding: 14px 10px 30px; }
  .atlas-header { align-items: start; }
  .header-meta { max-width: 135px; }
  .context-toggle { padding-right: 2px; font-size: 12px; }
  .comparison-stage { gap: 7px; }
  .artwork-choice { min-height: 326px; grid-template-rows: 20px minmax(250px, 1fr) auto; padding: 6px; }
  .image-well { min-height: 250px; }
  .image-well img { max-height: 276px; }
  .versus { width: 30px; height: 30px; }
  .outcome-controls { justify-content: space-between; }
  .outcome-controls button { padding-inline: 7px; font-size: 12px; }
  .reveal-strip { align-items: stretch; flex-direction: column; }
  .reveal-strip > div:last-child { align-self: end; margin-left: auto; }
  .reveal-strip button { padding-inline: 8px; }
  .atlas-grid { grid-template-columns: 1fr; }
  .atlas-footer { display: grid; }
}

@media (max-width: 350px) {
  .header-meta [data-dataset-status] { display: none; }
  .artwork-choice { min-height: 300px; grid-template-rows: 20px minmax(224px, 1fr) auto; }
  .image-well { min-height: 224px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .001ms !important; animation-duration: .001ms !important; }
}
