:root {
  color-scheme: light;
  --paper: #f2f0e9;
  --paper-bright: #fbfaf6;
  --ink: #1d2424;
  --muted: #65706c;
  --line: #d4d7cf;
  --teal: #176f69;
  --teal-dark: #0e4b48;
  --red: #c84235;
  --yellow: #e5b846;
  --blue: #426d99;
  --serif: Georgia, "Times New Roman", serif;
  --sans: "Avenir Next", Avenir, "Segoe UI", sans-serif;
  font-family: var(--sans);
  color: var(--ink);
  background: var(--paper);
  font-synthesis: none;
  text-rendering: optimizeLegibility;
}

* { box-sizing: border-box; }

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  background-color: var(--paper);
  background-image: repeating-linear-gradient(0deg, transparent 0 39px, rgba(29, 36, 36, .025) 40px);
}

button, input, select, textarea { font: inherit; }
button, select, label[for="import-progress"] { cursor: pointer; }
button { color: inherit; }
a { color: inherit; }

.app-shell { width: min(1540px, 100%); margin: 0 auto; padding: 0 42px; }
.skip-link { position: absolute; z-index: 20; top: 8px; left: 8px; padding: 10px 14px; transform: translateY(-150%); background: var(--ink); color: white; }
.skip-link:focus { transform: translateY(0); }

.topbar {
  min-height: 84px;
  display: grid;
  grid-template-columns: minmax(190px, 1fr) auto minmax(300px, 1fr);
  align-items: center;
  gap: 24px;
  border-bottom: 1px solid var(--line);
}

.brand { display: inline-flex; align-items: center; gap: 12px; width: fit-content; text-decoration: none; }
.brand-mark { width: 34px; height: 34px; display: grid; grid-template-columns: 1fr 1fr; gap: 3px; padding: 4px; background: var(--ink); transform: rotate(-5deg); }
.brand-mark i:nth-child(1) { background: var(--yellow); }
.brand-mark i:nth-child(2) { background: var(--red); }
.brand-mark i:nth-child(3) { background: var(--teal); }
.brand-mark i:nth-child(4) { background: var(--paper-bright); }
.brand-copy { display: grid; gap: 2px; }
.brand-copy strong { font-family: var(--serif); font-size: 19px; line-height: 1; letter-spacing: 0; }
.brand-copy small { color: var(--muted); font-size: 9px; font-weight: 700; letter-spacing: 1.2px; }

.publisher-nav { align-self: stretch; display: flex; align-items: stretch; gap: 8px; }
.publisher-link { position: relative; border: 0; padding: 0 14px; background: transparent; color: var(--muted); font-size: 13px; font-weight: 700; }
.publisher-link:hover, .publisher-link.is-selected { color: var(--ink); }
.publisher-link.is-selected::after { position: absolute; right: 12px; bottom: -1px; left: 12px; height: 3px; background: var(--teal); content: ""; }
.publisher-link[data-publisher="DC"].is-selected::after { background: var(--blue); }
.publisher-link[data-publisher="Marvel"].is-selected::after { background: var(--red); }

.top-actions { display: flex; justify-content: flex-end; align-items: center; gap: 16px; }
.local-label { display: flex; align-items: center; gap: 7px; color: var(--muted); font-size: 11px; white-space: nowrap; }
.local-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--teal); }
.text-action { border: 0; padding: 7px 0; background: transparent; color: var(--ink); font-size: 11px; font-weight: 700; text-decoration: underline; text-decoration-color: var(--line); text-underline-offset: 4px; white-space: nowrap; }
.text-action:hover { text-decoration-color: currentColor; }
.visually-hidden { position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; clip-path: inset(50%); }

.welcome {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
  gap: 28px;
  padding: 39px 0 25px;
}
.eyebrow { margin: 0 0 10px; color: var(--teal); font-size: 10px; font-weight: 800; letter-spacing: 1.6px; text-transform: uppercase; }
h1, h2, h3, p { margin-top: 0; }
.welcome h1, .detail-heading h1, .story-heading h1 { margin: 0; font-family: var(--serif); font-size: clamp(32px, 4vw, 52px); font-weight: 400; line-height: 1.02; letter-spacing: 0; }
.welcome-copy { max-width: 580px; margin: 12px 0 0; color: var(--muted); font-size: 13px; line-height: 1.6; }
.collection-stat { display: grid; grid-template-columns: auto auto; align-items: baseline; gap: 3px 8px; padding: 0 0 4px 20px; border-left: 1px solid var(--line); }
.collection-stat strong { font-family: var(--serif); font-size: 34px; font-weight: 400; }
.collection-stat span { color: var(--muted); font-size: 11px; }
.collection-stat small { grid-column: 1 / -1; color: var(--muted); font-size: 10px; }

.demo-notice { display: flex; align-items: flex-start; gap: 11px; margin: 0 0 21px; padding: 11px 14px; border-left: 3px solid var(--yellow); background: rgba(229, 184, 70, .12); color: #565044; font-size: 11px; line-height: 1.5; }
.demo-notice strong { color: var(--ink); white-space: nowrap; }

.timeline-block { border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); padding: 13px 0 15px; }
.timeline-heading { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; margin-bottom: 10px; }
.timeline-heading strong { font-family: var(--serif); font-size: 16px; font-weight: 400; }
.timeline-heading span { color: var(--muted); font-size: 10px; }
.year-strip { display: flex; gap: 5px; overflow-x: auto; overscroll-behavior-inline: contain; scrollbar-color: #9da8a0 transparent; scrollbar-width: thin; padding-bottom: 7px; }
.year-button { flex: 0 0 48px; min-height: 31px; border: 1px solid transparent; background: transparent; color: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.year-button:hover { border-color: var(--line); color: var(--ink); }
.year-button.is-selected { border-color: var(--ink); background: var(--ink); color: var(--paper-bright); }

.filter-bar { display: grid; grid-template-columns: minmax(200px, 1.6fr) repeat(3, minmax(135px, .75fr)); gap: 10px; padding: 18px 0 13px; }
.field { display: grid; gap: 6px; min-width: 0; }
.field label { color: var(--muted); font-size: 10px; font-weight: 700; }
.field input, .field select { width: 100%; min-height: 39px; border: 1px solid var(--line); border-radius: 0; padding: 0 11px; background: var(--paper-bright); color: var(--ink); font-size: 12px; }
.field input:focus, .field select:focus, textarea:focus { outline: 2px solid var(--teal); outline-offset: 2px; }
.field input::placeholder { color: #89918d; }

.results-heading { display: flex; justify-content: space-between; align-items: end; gap: 18px; padding: 18px 0 14px; }
.results-heading h2 { margin: 0; font-family: var(--serif); font-size: 25px; font-weight: 400; }
.results-heading p { margin: 4px 0 0; color: var(--muted); font-size: 11px; }
.result-count { color: var(--muted); font-size: 11px; white-space: nowrap; }
.issue-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 28px 18px; padding-bottom: 55px; }
.issue-card { min-width: 0; }
.cover-tile { position: relative; isolation: isolate; display: flex; aspect-ratio: 1 / 1; flex-direction: column; justify-content: space-between; overflow: hidden; padding: 16px; color: white; text-decoration: none; }
.cover-tile::before { position: absolute; z-index: -1; right: -9%; bottom: 13%; width: 77%; height: 66%; background: rgba(255,255,255,.16); clip-path: polygon(0 8%, 100% 0, 77% 100%, 12% 81%); content: ""; transform: rotate(-13deg); }
.cover-tile::after { position: absolute; z-index: -1; top: -38%; right: -13%; width: 59%; height: 83%; border: 1px solid rgba(255,255,255,.38); content: ""; transform: rotate(28deg); }
.cover-dc { background-color: #315d83; background-image: repeating-linear-gradient(135deg, transparent 0 19px, rgba(255,255,255,.07) 20px 21px); }
.cover-marvel { background-color: #bb4439; background-image: repeating-linear-gradient(45deg, transparent 0 22px, rgba(255,255,255,.08) 23px 24px); }
.cover-dc-alt { background-color: #176f69; background-image: repeating-linear-gradient(0deg, transparent 0 25px, rgba(255,255,255,.09) 26px 27px), repeating-linear-gradient(90deg, transparent 0 25px, rgba(255,255,255,.09) 26px 27px); }
.cover-marvel-alt { background-color: #a1632e; background-image: repeating-linear-gradient(120deg, transparent 0 17px, rgba(255,255,255,.09) 18px 19px); }
.cover-tag { align-self: flex-start; padding: 5px 7px; background: rgba(20, 28, 29, .72); font-size: 9px; font-weight: 800; letter-spacing: 1px; }
.cover-mark { position: absolute; top: 34%; right: 14px; color: rgba(255,255,255,.2); font-family: var(--serif); font-size: clamp(46px, 6vw, 84px); line-height: .8; }
.cover-copy { max-width: 90%; }
.cover-copy h3 { margin: 0; font-family: var(--serif); font-size: clamp(18px, 2vw, 25px); font-weight: 400; line-height: 1.08; }
.cover-copy p { margin: 7px 0 0; font-size: 10px; font-weight: 700; letter-spacing: .3px; }
.cover-number { position: absolute; right: 14px; bottom: 14px; font-size: 9px; font-variant-numeric: tabular-nums; }
.card-under { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 8px 0 0; }
.card-under p { margin: 0; color: var(--muted); font-size: 10px; line-height: 1.4; }
.progress-select { max-width: 108px; min-height: 29px; border: 1px solid var(--line); border-radius: 0; padding: 0 5px; background: transparent; color: var(--ink); font-size: 10px; }
.empty-state { padding: 36px 0 64px; border-top: 1px solid var(--line); }
.empty-state h3 { margin-bottom: 6px; font-family: var(--serif); font-size: 24px; font-weight: 400; }
.empty-state p { margin: 0; color: var(--muted); font-size: 12px; }

.detail-view, .story-view { max-width: 1100px; margin: 0 auto; padding: 35px 0 70px; }
.back-link { display: inline-flex; gap: 8px; align-items: center; margin-bottom: 26px; color: var(--muted); font-size: 11px; text-decoration: none; }
.back-link:hover { color: var(--ink); text-decoration: underline; text-underline-offset: 3px; }
.detail-layout { display: grid; grid-template-columns: minmax(240px, 380px) minmax(0, 1fr); gap: clamp(28px, 6vw, 76px); align-items: start; }
.detail-art { position: sticky; top: 20px; }
.detail-art .cover-tile { width: 100%; }
.detail-heading { padding: 7px 0 22px; border-bottom: 1px solid var(--line); }
.detail-heading h1 { font-size: clamp(32px, 4vw, 46px); }
.detail-heading .subheading { margin: 10px 0 0; color: var(--muted); font-size: 13px; }
.demo-year { display: inline-block; margin-top: 13px; padding: 5px 8px; border: 1px solid var(--yellow); color: #635528; font-size: 9px; font-weight: 800; letter-spacing: .7px; text-transform: uppercase; }
.metadata-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 22px; margin: 0; }
.metadata-item { padding: 15px 0 13px; border-bottom: 1px solid var(--line); }
.metadata-item dt { margin-bottom: 6px; color: var(--muted); font-size: 10px; font-weight: 700; }
.metadata-item dd { margin: 0; font-size: 12px; line-height: 1.5; }
.detail-section { padding-top: 24px; }
.detail-section h2 { margin: 0 0 13px; font-family: var(--serif); font-size: 22px; font-weight: 400; }
.progress-control { display: inline-flex; border: 1px solid var(--line); }
.progress-control button { border: 0; border-right: 1px solid var(--line); padding: 9px 11px; background: transparent; color: var(--muted); font-size: 10px; }
.progress-control button:last-child { border-right: 0; }
.progress-control button[aria-pressed="true"] { background: var(--ink); color: white; }
.story-rows { border-top: 1px solid var(--line); }
.story-row { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 13px; align-items: center; padding: 13px 2px; border-bottom: 1px solid var(--line); text-decoration: none; }
.story-row:hover .story-title { text-decoration: underline; text-underline-offset: 3px; }
.story-index { color: var(--teal); font-family: var(--serif); font-size: 17px; }
.story-title { font-size: 12px; font-weight: 700; }
.story-meta { display: block; margin-top: 4px; color: var(--muted); font-size: 10px; font-weight: 400; }
.row-arrow { color: var(--muted); font-size: 17px; }
.no-credits { color: var(--muted); font-size: 11px; }

.story-view { max-width: 860px; }
.story-heading { padding-bottom: 22px; border-bottom: 1px solid var(--line); }
.story-heading h1 { font-size: clamp(34px, 5vw, 54px); }
.story-heading .subheading { margin: 10px 0 0; color: var(--muted); font-size: 12px; }
.narrative-label { display: block; margin: 25px 0 8px; font-size: 11px; font-weight: 800; }
.narrative-help { max-width: 68ch; margin: 0 0 12px; color: var(--muted); font-size: 11px; line-height: 1.6; }
.narrative-editor { display: block; width: 100%; min-height: 360px; resize: vertical; border: 1px solid var(--line); border-radius: 0; padding: 17px; background: var(--paper-bright); color: var(--ink); font-family: var(--serif); font-size: 16px; line-height: 1.75; }
.narrative-actions { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding-top: 11px; }
.narrative-actions span { color: var(--muted); font-size: 10px; }
.solid-button { min-height: 38px; border: 0; padding: 0 16px; background: var(--teal-dark); color: white; font-size: 11px; font-weight: 700; }
.solid-button:hover { background: var(--ink); }

.app-footer { display: flex; justify-content: space-between; gap: 15px; padding: 15px 0 23px; border-top: 1px solid var(--line); color: var(--muted); font-size: 9px; letter-spacing: .3px; }
.notice { position: fixed; z-index: 30; right: 20px; bottom: 20px; max-width: min(400px, calc(100vw - 40px)); padding: 12px 16px; background: var(--ink); color: white; font-size: 12px; line-height: 1.5; opacity: 0; pointer-events: none; transform: translateY(8px); transition: opacity .18s ease, transform .18s ease; }
.notice.is-visible { opacity: 1; transform: translateY(0); }

@media (max-width: 1050px) {
  .app-shell { padding: 0 26px; }
  .topbar { grid-template-columns: auto 1fr; gap: 8px 18px; padding: 14px 0; }
  .publisher-nav { grid-column: 1; grid-row: 2; min-height: 38px; }
  .top-actions { grid-column: 2; grid-row: 2; }
  .local-label { display: none; }
  .issue-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (max-width: 700px) {
  .app-shell { padding: 0 17px; }
  .topbar { grid-template-columns: 1fr auto; gap: 8px; }
  .brand { grid-column: 1; grid-row: 1; }
  .top-actions { grid-column: 2; grid-row: 1; gap: 10px; }
  .top-actions .text-action { font-size: 10px; }
  .publisher-nav { grid-column: 1 / -1; grid-row: 2; min-height: 36px; }
  .publisher-link { padding: 0 12px; }
  .welcome { grid-template-columns: 1fr; gap: 17px; padding-top: 28px; }
  .welcome h1 { max-width: 12ch; font-size: 39px; }
  .welcome-copy { max-width: 44ch; }
  .collection-stat { width: fit-content; grid-template-columns: auto auto auto; align-items: baseline; padding: 0; border: 0; }
  .collection-stat small { grid-column: auto; }
  .demo-notice { flex-direction: column; gap: 4px; }
  .filter-bar { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .field-search { grid-column: 1 / -1; }
  .issue-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 22px 12px; }
  .cover-tile { padding: 11px; }
  .cover-tag { font-size: 8px; }
  .cover-copy h3 { font-size: clamp(17px, 5vw, 22px); }
  .cover-copy p { font-size: 9px; }
  .card-under { align-items: flex-start; flex-direction: column; }
  .progress-select { max-width: none; width: 100%; }
  .results-heading { align-items: baseline; }
  .results-heading h2 { font-size: 22px; }
  .detail-layout { grid-template-columns: minmax(0, 1fr); gap: 25px; }
  .detail-art { position: static; width: min(100%, 360px); margin: 0 auto; }
  .detail-heading { padding-top: 0; }
  .metadata-grid { gap: 0 14px; }
  .progress-control { display: grid; width: 100%; grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .progress-control button { padding: 10px 6px; }
}

@media (max-width: 390px) {
  .app-shell { padding: 0 12px; }
  .brand-copy small { font-size: 8px; }
  .top-actions { gap: 7px; }
  .top-actions .text-action { max-width: 74px; white-space: normal; text-align: center; }
  .issue-grid { gap: 20px 9px; }
  .cover-tag { max-width: 100%; padding: 4px 5px; font-size: 7px; }
  .cover-number { right: 9px; bottom: 9px; }
  .metadata-grid { grid-template-columns: 1fr; }
}

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