:root {
  color-scheme: light;
  --ink: #172019;
  --paper: #fffdf4;
  --lime: #d8ff63;
  --purple: #7656d6;
  --purple-dark: #342260;
  --line: #172019;
  --muted: #59625b;
  font-family: Inter, ui-rounded, "Arial Rounded MT Bold", system-ui, sans-serif;
}

* { box-sizing: border-box; }
html { background: #e9e1ff; }
body {
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 15% 5%, #fff6a8 0 10rem, transparent 10.1rem),
    linear-gradient(145deg, #f5f0ff, #d9f7ed);
  min-height: 100vh;
}
button, summary, a { touch-action: manipulation; }
a { color: var(--purple-dark); }
.skip-link { position: fixed; left: 1rem; top: -5rem; z-index: 10; background: #fff; padding: .75rem; }
.skip-link:focus { top: 1rem; }
.shell { width: min(70rem, calc(100% - 2rem)); margin-inline: auto; padding: 1.25rem 0 3rem; }
.masthead { display: flex; justify-content: space-between; align-items: center; gap: 1rem; margin-bottom: 1.1rem; }
.brand { margin: 0; font-size: clamp(1rem, 4vw, 1.35rem); font-weight: 900; letter-spacing: -.03em; }
.brand-mark { display: inline-grid; place-items: center; width: 2.1rem; aspect-ratio: 1; border: 2px solid; border-radius: 50%; background: var(--lime); transform: rotate(-8deg); }
.tagline { margin: 0; color: var(--muted); font-size: .9rem; text-align: right; }
.comic-card { background: rgba(255, 253, 244, .92); border: 3px solid var(--line); border-radius: 1.35rem; box-shadow: 8px 8px 0 var(--line); padding: clamp(.75rem, 2.5vw, 1.5rem); }
.comic-intro { display: grid; grid-template-columns: 1fr auto; align-items: end; gap: .75rem 1.5rem; margin-bottom: 1rem; }
.eyebrow { margin: 0 0 .2rem; color: var(--purple-dark); font-size: .75rem; font-weight: 900; text-transform: uppercase; letter-spacing: .12em; }
h1 { margin: 0; font-size: clamp(1.65rem, 5vw, 3.2rem); line-height: .96; letter-spacing: -.055em; max-width: 18ch; }
.summary { margin: .55rem 0 0; color: var(--muted); max-width: 58ch; }
.topics { display: flex; flex-wrap: wrap; gap: .35rem; margin-top: .7rem; }
.topic { background: #e9e1ff; border: 1.5px solid; border-radius: 999px; padding: .2rem .55rem; font-size: .75rem; font-weight: 750; }
.next-button { min-height: 3.25rem; min-width: 10rem; border: 2px solid var(--line); border-radius: 999px; padding: .7rem 1.15rem; background: var(--lime); color: var(--ink); box-shadow: 3px 3px 0 var(--line); font: inherit; font-weight: 900; cursor: pointer; }
.next-button:hover { transform: translate(-1px, -1px); box-shadow: 5px 5px 0 var(--line); }
.next-button:active { transform: translate(2px, 2px); box-shadow: 1px 1px 0 var(--line); }
.next-button[aria-busy="true"] { cursor: wait; opacity: .75; }
:focus-visible { outline: 4px solid #e8418c; outline-offset: 3px; }
.status { min-height: 1.4em; margin: .25rem 0 .75rem; color: var(--purple-dark); font-weight: 800; }
.comic-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: clamp(.22rem, 1vw, .7rem); list-style: none; margin: 0; padding: 0; }
.panel { min-width: 0; aspect-ratio: 1; border: clamp(1.5px, .25vw, 3px) solid var(--line); background: #fff; overflow: hidden; }
.panel img { display: block; width: 100%; height: 100%; object-fit: cover; }
.meta { display: grid; grid-template-columns: 1fr auto; gap: 1rem; align-items: start; margin-top: 1rem; }
details { border-top: 2px dashed #a69caf; padding-top: .8rem; }
summary { min-height: 2.75rem; font-weight: 900; cursor: pointer; }
.transcript { margin: .5rem 0 0; padding-left: 1.5rem; }
.transcript li { margin-block: .35rem; }
.attribution { margin: .1rem 0; color: var(--muted); font-size: .85rem; text-align: right; }
.empty { padding: 3rem 1rem; text-align: center; border: 3px dashed var(--purple); border-radius: 1rem; }
.empty h2 { margin-top: 0; }
.footer { display: flex; justify-content: space-between; gap: 1rem; margin-top: 1.25rem; color: var(--muted); font-size: .8rem; }
.noscript { background: #fff3bd; border: 2px solid; padding: .65rem; margin-bottom: 1rem; }

@media (max-width: 38rem) {
  .shell { width: min(100% - 1rem, 34rem); padding-top: .75rem; }
  .masthead, .comic-intro, .meta { grid-template-columns: 1fr; }
  .masthead { align-items: start; }
  .tagline, .attribution { text-align: left; }
  .comic-intro { display: grid; }
  .next-button { width: 100%; }
  .comic-card { box-shadow: 4px 4px 0 var(--line); border-radius: .9rem; }
}

@media (prefers-reduced-motion: no-preference) {
  .next-button { transition: transform 100ms ease, box-shadow 100ms ease; }
  .comic-grid[data-changing="true"] { animation: settle 180ms ease-out; }
  @keyframes settle { from { opacity: .7; transform: translateY(.25rem); } }
}
