:root {
  --canvas: #131313;
  --slate: #2d2d2d;
  --image-frame: #313131;
  --white: #ffffff;
  --muted: #949494;
  --soft: #e9e9e9;
  --black: #000000;
  --mint: #3cffd0;
  --mint-border: #309875;
  --purple: #5200ff;
  --purple-rule: #3d00bf;
  --blue: #3860be;
  --cyan: #1eaedb;
  --yellow: #f9f871;
  --pink: #ff4fd8;
  --orange: #ff8a00;
  --max: 1280px;
  --display: Impact, "Arial Black", "Helvetica Neue Condensed", sans-serif;
  --sans: "Helvetica Neue", Helvetica, Arial, sans-serif;
  --mono: "Courier New", Courier, monospace;
  --serif: Georgia, serif;
}

* {
  box-sizing: border-box;
}

html {
  background: var(--canvas);
  color: var(--white);
  font-family: var(--sans);
  scroll-behavior: smooth;
}

body {
  min-height: 100vh;
  margin: 0;
  background: var(--canvas);
  color: var(--white);
}

a {
  color: inherit;
  text-decoration: none;
  transition: color 150ms ease;
}

a:hover {
  color: var(--blue);
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

img {
  display: block;
  max-width: 100%;
}

.skip-link {
  position: absolute;
  left: 24px;
  top: 12px;
  z-index: 20;
  transform: translateY(-120%);
  border: 1px solid var(--mint);
  border-radius: 24px;
  padding: 10px 20px;
  background: var(--mint);
  color: var(--black);
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 1.5px;
}

.skip-link:focus {
  transform: translateY(0);
}

.site-header {
  border-bottom: 1px solid var(--image-frame);
  background: var(--canvas);
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  width: min(100%, var(--max));
  margin: 0 auto;
  padding: 16px 24px;
}

.brand-small {
  flex: 0 1 auto;
  min-width: 0;
  font-family: var(--display);
  font-size: clamp(28px, 5vw, 60px);
  font-weight: 900;
  line-height: 0.95;
  letter-spacing: 1.07px;
  overflow-wrap: anywhere;
}

.site-links {
  display: flex;
  min-width: 0;
  align-items: center;
  justify-content: flex-end;
  gap: 18px;
}

.site-links a,
.menu-toggle,
.kicker,
.tag,
.meta,
.timestamp,
.button,
.pager a,
.reader-link {
  font-family: var(--mono);
  text-transform: uppercase;
}

.site-links a {
  padding: 12px 0;
  color: var(--soft);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 1.5px;
}

.site-links a.active {
  box-shadow: 0 -1px 0 0 var(--mint) inset;
}

.menu-toggle {
  display: none;
  min-height: 44px;
  border: 1px solid var(--mint);
  border-radius: 24px;
  padding: 10px 20px;
  background: transparent;
  color: var(--mint);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 1.5px;
}

.app-shell {
  width: min(100%, var(--max));
  margin: 0 auto;
  padding: 32px 24px 64px;
}

.app-shell > section:not(.masthead) {
  content-visibility: auto;
  contain-intrinsic-size: 720px;
}

.masthead {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(320px, 0.85fr);
  gap: 24px;
  align-items: stretch;
  padding: 20px 0 36px;
}

.wordmark {
  margin: 0;
  color: var(--white);
  font-family: var(--display);
  font-size: clamp(60px, 6.5vw, 80px);
  font-weight: 900;
  line-height: 0.84;
  letter-spacing: 1.07px;
  overflow-wrap: normal;
  white-space: nowrap;
}

.hero-panel,
.feature-panel,
.empty-state,
.error-state {
  border: 1px solid var(--white);
  border-radius: 24px;
  padding: 28px;
  background: var(--canvas);
}

.hero-panel {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-height: 280px;
}

.hero-panel p {
  margin: 18px 0 26px;
  color: var(--soft);
  font-size: 18px;
  font-weight: 500;
  line-height: 1.5;
}

.hero-actions,
.button-row,
.pager,
.chapter-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.button,
.pager a,
.reader-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  border-radius: 24px;
  padding: 10px 22px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 1.5px;
  transition: background 180ms ease, color 180ms ease, box-shadow 180ms ease,
    border-color 180ms ease;
}

.button.primary {
  border: 0;
  background: var(--mint);
  color: var(--black);
}

.button.secondary,
.pager a,
.reader-link {
  border: 0;
  background: var(--slate);
  color: var(--soft);
}

.button.tertiary {
  border: 1px solid var(--mint);
  background: transparent;
  color: var(--mint);
  border-radius: 40px;
}

.button:hover,
.pager a:hover,
.reader-link:hover {
  background: rgba(255, 255, 255, 0.2);
  color: var(--black);
  box-shadow: 0 0 0 1px #c2c2c2;
}

.button:focus-visible,
.pager a:focus-visible,
.reader-link:focus-visible,
.menu-toggle:focus-visible,
.search-form input:focus-visible,
.search-form button:focus-visible {
  outline: 0;
  border-color: #0500ff;
  background: var(--cyan);
  color: var(--white);
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.4);
}

.kicker {
  margin: 0 0 10px;
  color: var(--mint);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 1.8px;
}

.section-header {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 16px;
  margin: 40px 0 16px;
  border-top: 1px solid var(--purple-rule);
  padding-top: 18px;
}

.section-header h2,
.page-title {
  margin: 0;
  font-size: clamp(34px, 6vw, 82px);
  font-weight: 900;
  line-height: 0.9;
}

.page-title {
  font-family: var(--display);
  letter-spacing: 1.07px;
}

.section-header h2 {
  font-family: var(--display);
  letter-spacing: 0.32px;
}

.section-header p,
.page-deck {
  margin: 0;
  color: var(--muted);
  font-size: 15px;
  font-weight: 500;
  line-height: 1.5;
}

.grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
}

.grid.compact {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.story-card {
  position: relative;
  contain: layout paint style;
  display: flex;
  min-width: 0;
  min-height: 100%;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid var(--white);
  border-radius: 20px;
  background: var(--canvas);
}

.story-card.accent-mint,
.story-card.accent-yellow,
.story-card.accent-white {
  border-color: transparent;
  color: var(--black);
}

.story-card.accent-mint {
  background: var(--mint);
}

.story-card.accent-purple {
  border-color: transparent;
  background: var(--purple);
}

.story-card.accent-yellow {
  background: var(--yellow);
}

.story-card.accent-pink {
  border-color: transparent;
  background: var(--pink);
}

.story-card.accent-orange {
  border-color: transparent;
  background: var(--orange);
}

.story-card.accent-white {
  background: var(--white);
}

.story-card.slate {
  border-color: var(--image-frame);
  background: var(--slate);
}

.story-image {
  aspect-ratio: 16 / 9;
  width: 100%;
  border-bottom: 1px solid var(--image-frame);
  object-fit: cover;
  background: var(--image-frame);
}

.story-body {
  display: flex;
  min-width: 0;
  flex: 1;
  flex-direction: column;
  gap: 10px;
  padding: 20px;
}

.story-title {
  margin: 0;
  font-size: clamp(20px, 2.3vw, 30px);
  font-weight: 800;
  line-height: 1;
  overflow-wrap: anywhere;
}

.story-card:hover .story-title {
  color: var(--blue);
}

.story-deck,
.detail-description {
  margin: 0;
  color: var(--soft);
  font-size: 15px;
  font-weight: 500;
  line-height: 1.5;
}

.accent-mint .story-deck,
.accent-yellow .story-deck,
.accent-white .story-deck {
  color: var(--canvas);
}

.meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: auto;
  color: var(--muted);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 1.5px;
  line-height: 1.4;
}

.accent-mint .meta,
.accent-yellow .meta,
.accent-white .meta {
  color: var(--canvas);
}

.tag {
  width: fit-content;
  border-radius: 20px;
  padding: 5px 10px;
  background: var(--mint);
  color: var(--black);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 1.8px;
}

.tag.purple {
  background: var(--purple);
  color: var(--white);
}

.timeline {
  position: relative;
  display: grid;
  gap: 14px;
  margin: 0;
  padding: 0 0 0 92px;
  list-style: none;
}

.timeline::before {
  position: absolute;
  left: 68px;
  top: 0;
  bottom: 0;
  width: 1px;
  background: repeating-linear-gradient(
    to bottom,
    var(--purple-rule) 0,
    var(--purple-rule) 8px,
    transparent 8px,
    transparent 15px
  );
  content: "";
}

.timeline-item {
  position: relative;
}

.timestamp {
  position: absolute;
  left: -92px;
  top: 22px;
  width: 70px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 1.1px;
  line-height: 1.2;
}

.feature-panel {
  display: grid;
  grid-template-columns: minmax(260px, 0.7fr) minmax(0, 1.3fr);
  gap: 24px;
  margin: 0 0 24px;
}

.feature-panel img {
  width: 100%;
  aspect-ratio: 4 / 3;
  border: 1px solid var(--image-frame);
  border-radius: 20px;
  object-fit: cover;
}

.detail-title {
  margin: 0;
  font-family: var(--display);
  font-size: clamp(52px, 8vw, 112px);
  font-weight: 900;
  line-height: 0.9;
  letter-spacing: 1.07px;
}

.detail-meta {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin: 20px 0;
}

.info-chip {
  border: 1px solid var(--image-frame);
  border-radius: 20px;
  padding: 12px;
  background: var(--slate);
}

.info-chip b {
  display: block;
  margin-bottom: 5px;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 1.5px;
  text-transform: uppercase;
}

.chapter-list {
  display: grid;
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.chapter-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  border: 1px solid var(--white);
  border-radius: 20px;
  padding: 16px;
  background: var(--canvas);
}

.chapter-row:hover strong {
  color: var(--blue);
}

.chapter-row strong {
  display: block;
  font-size: 18px;
  line-height: 1;
  overflow-wrap: anywhere;
  transition: color 150ms ease;
}

.reader-header {
  margin: 0 0 24px;
  border-bottom: 1px solid var(--image-frame);
  padding: 0 0 18px;
  background: var(--canvas);
}

.reader-title {
  margin: 8px 0 14px;
  font-family: var(--display);
  font-size: clamp(42px, 5.8vw, 72px);
  font-weight: 900;
  line-height: 0.9;
  overflow-wrap: anywhere;
}

.reader-pages {
  display: grid;
  gap: 0;
  max-width: 980px;
  margin: 0 auto;
  background: var(--black);
}

.reader-pages img {
  display: block;
  width: 100%;
  border: 0;
  border-radius: 0;
  background: transparent;
}

.search-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  margin: 24px 0;
}

.search-form input {
  min-height: 48px;
  border: 1px solid var(--white);
  border-radius: 2px;
  padding: 12px 14px;
  background: var(--canvas);
  color: var(--white);
}

.search-form input::placeholder {
  color: var(--muted);
}

.search-form button {
  min-height: 48px;
  border: 0;
  border-radius: 24px;
  padding: 10px 24px;
  background: var(--mint);
  color: var(--black);
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 1.5px;
  text-transform: uppercase;
}

.genre-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 10px;
}

.genre-pill {
  display: flex;
  min-height: 54px;
  align-items: center;
  border: 1px solid var(--mint-border);
  border-radius: 30px;
  padding: 12px 16px;
  background: transparent;
  color: var(--white);
  font-weight: 700;
}

.genre-pill:hover {
  border-color: var(--blue);
}

.loading,
.empty-state,
.error-state {
  min-height: 220px;
}

.loading {
  display: grid;
  place-items: center;
  border: 1px solid var(--purple-rule);
  border-radius: 24px;
  color: var(--mint);
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 1.8px;
  text-transform: uppercase;
}

.empty-state,
.error-state {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 12px;
}

.error-state {
  border-color: var(--purple);
}

.site-footer {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  border-top: 1px solid var(--image-frame);
  padding: 18px 24px;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 1.5px;
  text-transform: uppercase;
}

@media (max-width: 1023px) {
  .masthead,
  .feature-panel {
    grid-template-columns: 1fr;
  }

  .hero-panel {
    min-height: 220px;
  }

  .grid,
  .grid.compact {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .genre-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 767px) {
  .topbar {
    flex-wrap: wrap;
    gap: 12px;
    padding: 14px 16px;
  }

  .brand-small {
    max-width: calc(100% - 96px);
    font-size: clamp(28px, 9vw, 44px);
  }

  .menu-toggle {
    display: inline-flex;
    flex: 0 0 auto;
  }

  .site-links {
    display: none;
    width: 100%;
    flex-direction: column;
    align-items: stretch;
    gap: 4px;
    padding-top: 8px;
  }

  .site-links.open {
    display: flex;
  }

  .site-links a {
    min-height: 44px;
    border-top: 1px solid var(--image-frame);
  }

  .app-shell {
    padding: 20px 16px 48px;
  }

  .masthead {
    gap: 18px;
    padding: 12px 0 28px;
  }

  .wordmark {
    font-size: clamp(38px, 10vw, 50px);
    line-height: 0.9;
  }

  .hero-panel,
  .feature-panel,
  .empty-state,
  .error-state {
    border-radius: 20px;
    padding: 20px;
  }

  .hero-panel p {
    font-size: 16px;
  }

  .hero-actions,
  .button-row,
  .pager,
  .chapter-actions {
    align-items: stretch;
  }

  .button,
  .pager a,
  .reader-link {
    width: 100%;
  }

  .section-header {
    margin-top: 28px;
  }

  .reader-header {
    margin: 0 0 20px;
    padding: 0 0 14px;
  }

  .grid,
  .grid.compact,
  .detail-meta,
  .genre-grid {
    grid-template-columns: 1fr;
  }

  .timeline {
    padding-left: 0;
  }

  .timeline::before {
    display: none;
  }

  .timestamp {
    position: static;
    width: auto;
    margin: 0 0 8px;
  }

  .search-form,
  .chapter-row {
    grid-template-columns: 1fr;
  }

  .chapter-row {
    align-items: stretch;
  }

  .section-header,
  .site-footer {
    align-items: start;
    flex-direction: column;
  }
}

@media (max-width: 420px) {
  .topbar {
    padding-inline: 12px;
  }

  .app-shell {
    padding-inline: 12px;
  }

  .brand-small {
    font-size: clamp(25px, 8vw, 34px);
  }

  .menu-toggle {
    min-height: 40px;
    padding: 8px 14px;
  }

  .wordmark {
    font-size: clamp(32px, 9vw, 38px);
  }

  .section-header h2,
  .page-title {
    font-size: clamp(32px, 13vw, 52px);
  }

  .detail-title {
    font-size: clamp(42px, 13vw, 58px);
  }

  .reader-title {
    font-size: clamp(36px, 12vw, 52px);
  }

  .story-body {
    padding: 16px;
  }
}
