:root {
  color-scheme: dark;
  --bg: #100f0d;
  --bar: rgba(16, 15, 13, 0.9);
  --paper: #f4efe4;
  --paper-2: #fbf7ee;
  --ink: #f7f0e4;
  --muted: #b9afa2;
  --line: rgba(244, 239, 228, 0.16);
  --accent: #caaa62;
  --topbar-height: 58px;
}

* {
  box-sizing: border-box;
}

html {
  overflow-x: hidden;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  overflow-x: hidden;
  background:
    radial-gradient(circle at 50% -20%, rgba(202, 170, 98, 0.11), transparent 34rem),
    var(--bg);
  color: var(--ink);
  font-family: Georgia, "Times New Roman", serif;
}

button {
  font: inherit;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  height: var(--topbar-height);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 0 18px;
  background: var(--bar);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(16px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  font-size: 18px;
  font-weight: 700;
  white-space: nowrap;
}

.brand-mark {
  width: 18px;
  height: 18px;
  border: 2px solid var(--accent);
  border-radius: 50%;
  box-shadow: inset 0 0 0 4px rgba(202, 170, 98, 0.17);
}

.controls {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.segmented {
  display: inline-flex;
  min-width: 0;
  gap: 2px;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.04);
}

.segment,
.icon-button,
.text-button {
  min-height: 34px;
  border: 0;
  color: var(--muted);
  background: transparent;
  cursor: pointer;
}

.segment {
  min-width: 72px;
  padding: 0 12px;
  border-radius: 6px;
}

.segment.is-active {
  color: #17130f;
  background: var(--accent);
}

.icon-button {
  width: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.04);
  font-size: 18px;
}

.segment:focus-visible,
.icon-button:focus-visible,
.text-button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.progress {
  position: sticky;
  top: var(--topbar-height);
  z-index: 19;
  height: 3px;
}

.progress span {
  display: block;
  width: 0;
  height: 100%;
  background: var(--accent);
}

.arrival {
  max-width: 1280px;
  margin: 0 auto;
  padding: clamp(24px, 5vw, 56px) 24px clamp(38px, 6vw, 72px);
}

.arrival-art {
  width: 100%;
  box-shadow: 0 24px 50px rgba(0, 0, 0, 0.42);
}

.arrival-art img {
  display: block;
  width: 100%;
  height: auto;
}

.arrival-copy {
  max-width: 720px;
  padding: 30px 4px 0;
}

.eyebrow {
  margin: 0 0 12px;
  color: var(--accent);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.arrival h1 {
  max-width: 15ch;
  margin: 0;
  color: var(--ink);
  font-size: clamp(38px, 6vw, 74px);
  line-height: 0.98;
  font-weight: 700;
}

.arrival-text {
  max-width: 46ch;
  margin: 22px 0 0;
  color: var(--muted);
  font-size: clamp(17px, 2vw, 21px);
  line-height: 1.5;
}

.arrival-link {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  margin-top: 28px;
  padding-bottom: 5px;
  border-bottom: 1px solid var(--accent);
  color: var(--ink);
  font-weight: 700;
  text-decoration: none;
}

.arrival-link span {
  color: var(--accent);
  font-size: 18px;
}

.reader {
  width: 100%;
  padding: 24px clamp(10px, 2vw, 28px) 72px;
}

.page {
  width: 100%;
  margin: 0 auto 28px;
  scroll-margin-top: 78px;
}

.frame {
  width: min(100%, 1220px);
  margin: 0 auto;
  padding: clamp(8px, 1.3vw, 16px);
  background: var(--paper);
  box-shadow: 0 20px 70px rgba(0, 0, 0, 0.44);
}

.stage {
  width: 100%;
  overflow-x: auto;
  overflow-y: hidden;
  background: var(--paper-2);
  scrollbar-color: var(--accent) rgba(0, 0, 0, 0.16);
}

.page img {
  display: block;
  width: 100%;
  max-width: 100%;
  height: auto;
  margin: 0 auto;
  border: 0;
  cursor: zoom-in;
  user-select: none;
}

.portrait .frame {
  width: min(100%, 880px);
}

.landscape .frame {
  width: min(100%, 1280px);
}

body[data-scale="read"] .landscape img {
  width: auto;
  max-width: none;
  min-width: min(1180px, calc(100vw - 56px));
}

body[data-scale="read"] .portrait .frame {
  width: min(100%, 920px);
}

body[data-scale="native"] .stage {
  padding-bottom: 10px;
}

body[data-scale="native"] .page img {
  width: auto;
  max-width: none;
}

.meta {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 2px 0;
  color: #3c352d;
  font-size: 13px;
  line-height: 1.2;
}

.thumbs {
  position: fixed;
  left: 0;
  top: var(--topbar-height);
  bottom: 0;
  z-index: 15;
  width: 118px;
  padding: 14px 10px 18px;
  overflow-y: auto;
  background: rgba(16, 15, 13, 0.94);
  border-right: 1px solid var(--line);
  transform: translateX(-100%);
  transition: transform 160ms ease;
}

body.thumbs-open .thumbs {
  transform: translateX(0);
}

body.thumbs-open .reader {
  padding-left: 132px;
}

.thumb {
  display: block;
  width: 100%;
  margin: 0 0 10px;
  padding: 4px;
  border: 1px solid transparent;
  border-radius: 6px;
  background: transparent;
  cursor: pointer;
}

.thumb.is-active {
  border-color: var(--accent);
  background: rgba(202, 170, 98, 0.16);
}

.thumb img {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 3px;
}

.lightbox {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: none;
  grid-template-rows: var(--topbar-height) 1fr;
  background: rgba(0, 0, 0, 0.94);
}

.lightbox.is-open {
  display: grid;
}

.lightbox-bar {
  display: grid;
  grid-template-columns: auto 1fr auto auto;
  align-items: center;
  gap: 10px;
  padding: 0 14px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.14);
}

.text-button {
  padding: 0 12px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.06);
}

#lightboxLabel {
  min-width: 0;
  overflow: hidden;
  color: var(--muted);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.lightbox-stage {
  overflow: auto;
  padding: 18px;
}

.lightbox-stage img {
  display: block;
  width: auto;
  max-width: min(100%, 1600px);
  height: auto;
  margin: 0 auto;
}

@media (max-width: 760px) {
  :root {
    --topbar-height: 104px;
  }

  .topbar {
    height: var(--topbar-height);
    align-items: stretch;
    flex-direction: column;
    justify-content: center;
    padding: 10px 12px;
  }

  .brand {
    justify-content: center;
  }

  .controls {
    width: 100%;
    display: grid;
    grid-template-columns: minmax(0, 1fr) 38px;
    gap: 8px;
  }

  .segmented {
    width: 100%;
  }

  .segment {
    flex: 1 1 0;
    min-width: 0;
    padding: 0 4px;
  }

  .reader {
    padding: 16px 10px 48px;
  }

  .arrival {
    padding: 24px 12px 42px;
  }

  .arrival h1 {
    font-size: clamp(34px, 9vw, 48px);
  }

  .arrival-text {
    margin-top: 14px;
    font-size: 16px;
  }

  .arrival-link {
    margin-top: 20px;
  }

  body.thumbs-open .reader {
    padding-left: 10px;
  }

  .frame {
    padding: 7px;
  }

  body[data-scale="read"] .landscape img {
    min-width: 1080px;
  }

  body[data-scale="native"] .page img {
    min-width: 0;
  }

  .thumbs {
    top: var(--topbar-height);
    right: 0;
    bottom: auto;
    width: 100%;
    max-height: 160px;
    display: flex;
    gap: 8px;
    overflow-x: auto;
    overflow-y: hidden;
    padding: 10px;
    border-right: 0;
    border-bottom: 1px solid var(--line);
    transform: translateY(-120%);
  }

  body.thumbs-open .thumbs {
    transform: translateY(0);
  }

  .thumb {
    flex: 0 0 64px;
    margin: 0;
  }

  .lightbox-stage {
    padding: 10px;
  }

  .lightbox-stage img {
    max-width: none;
  }
}

@media (max-width: 430px) {
  .arrival {
    padding-inline: 14px;
  }

  .arrival h1 {
    font-size: 34px;
  }

  .arrival-text {
    font-size: 15px;
    line-height: 1.4;
  }

  .arrival-link {
    font-size: 14px;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  .thumbs {
    transition: none;
  }
}
