:root {
  color-scheme: light;
  --bg: #edf2f6;
  --panel: #ffffff;
  --ink: #171b22;
  --muted: #66717d;
  --line: #ccd5df;
  --accent: #e4572e;
  --accent-dark: #b33b1d;
  --teal: #0f7b8a;
  --shadow: 0 24px 70px rgba(20, 30, 40, 0.22);
  --page-aspect: 0.7727;
  --zoom: 1;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  min-height: 100%;
  margin: 0;
}

body {
  font-family: Arial, Helvetica, sans-serif;
  background:
    linear-gradient(180deg, #f7fafc 0%, var(--bg) 45%, #dfe8ee 100%);
  color: var(--ink);
}

button,
input {
  font: inherit;
}

.app {
  min-height: 100vh;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
}

.topbar,
.control-strip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 14px clamp(16px, 3vw, 34px);
  background: rgba(255, 255, 255, 0.88);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(16px);
}

.control-strip {
  border-top: 1px solid var(--line);
  border-bottom: 0;
}

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

h1 {
  margin: 0;
  font-size: clamp(22px, 3vw, 34px);
  line-height: 1.05;
}

.actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
}

.icon-button,
.tool-button {
  min-width: 38px;
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-weight: 700;
  text-decoration: none;
  transition: transform 0.15s ease, border-color 0.15s ease, background 0.15s ease;
}

.tool-button {
  padding: 0 13px;
}

.icon-button:hover,
.tool-button:hover {
  border-color: #9daab6;
  transform: translateY(-1px);
}

.icon-button.primary {
  color: #fff;
  border-color: var(--accent);
  background: var(--accent);
}

.icon-button.primary:hover {
  background: var(--accent-dark);
}

.icon-button:disabled,
.tool-button:disabled {
  cursor: not-allowed;
  opacity: 0.42;
  transform: none;
}

.stage {
  position: relative;
  overflow: auto;
  display: grid;
  place-items: center;
  padding: clamp(18px, 3vw, 34px);
}

.mobile-deck {
  display: none;
}

.app.is-mobile-remaster {
  min-height: 100svh;
  background:
    linear-gradient(155deg, rgba(15, 123, 138, 0.32), transparent 34%),
    linear-gradient(28deg, rgba(228, 87, 46, 0.22), transparent 38%),
    #111820;
}

.app.is-mobile-remaster .topbar,
.app.is-mobile-remaster .control-strip {
  background: rgba(14, 20, 27, 0.9);
  border-color: rgba(255, 255, 255, 0.12);
  color: #fff;
}

.app.is-mobile-remaster .stage {
  overflow: auto;
  place-items: start center;
  padding: 0;
  background: transparent;
}

.app.is-mobile-remaster .book-shell {
  display: none;
}

.app.is-mobile-remaster .mobile-deck {
  display: block;
  width: min(100%, 460px);
  min-height: calc(100svh - 112px);
  padding: 10px 12px 14px;
  margin: 0 auto;
}

.mobile-panel {
  display: none;
  width: 100%;
}

.mobile-panel.is-active {
  display: block;
}

.mobile-card {
  overflow: hidden;
  width: 100%;
  border: 1px solid rgba(0, 0, 0, 0.08);
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.28);
}

.mobile-copy {
  min-height: min(712px, calc(100svh - 132px));
  padding: clamp(20px, 5.8vw, 32px);
  color: #18212a;
}

.mobile-card-top {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 18px;
}

.brand-mark {
  display: grid;
  flex: 0 0 auto;
  width: 44px;
  height: 44px;
  place-items: center;
  border-radius: 8px;
  background: #111820;
  color: #fff;
  font-size: 14px;
  font-weight: 900;
}

.slide-kicker,
.slide-category {
  line-height: 1.12;
}

.slide-kicker {
  margin: 0 0 4px;
  color: var(--teal);
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.slide-category {
  color: #5b6875;
  font-size: 14px;
  font-weight: 800;
}

.mobile-visual {
  position: relative;
  overflow: hidden;
  margin: 0 0 22px;
  min-height: 190px;
  border-radius: 8px;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.18), transparent 48%),
    #163b40;
  color: #fff;
}

.mobile-visual img {
  display: block;
  width: 100%;
  height: 210px;
  object-fit: cover;
}

.mobile-visual::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, transparent 25%, rgba(0, 0, 0, 0.62) 100%);
  pointer-events: none;
}

.visual-badge {
  position: absolute;
  z-index: 1;
  left: 14px;
  right: 14px;
  bottom: 14px;
  display: grid;
  gap: 5px;
}

.visual-badge span {
  font-size: clamp(30px, 11vw, 50px);
  font-weight: 900;
  line-height: 0.95;
}

.visual-badge strong {
  max-width: 17rem;
  color: rgba(255, 255, 255, 0.88);
  font-size: 16px;
  line-height: 1.2;
}

.mobile-copy h2 {
  margin: 0;
  color: #111820;
  font-size: clamp(30px, 8.4vw, 44px);
  line-height: 1;
}

.mobile-subtitle {
  margin: 12px 0 0;
  color: #34424f;
  font-size: clamp(21px, 6vw, 28px);
  font-weight: 800;
  line-height: 1.12;
}

.mobile-body {
  margin: 22px 0 0;
  color: #25313c;
  font-size: clamp(18px, 4.8vw, 23px);
  line-height: 1.32;
}

.mobile-copy ul {
  display: grid;
  gap: 12px;
  margin: 24px 0 0;
  padding: 0;
  list-style: none;
}

.mobile-copy li {
  position: relative;
  padding-left: 23px;
  color: #25313c;
  font-size: clamp(18px, 4.8vw, 23px);
  line-height: 1.28;
}

.mobile-copy li::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0.5em;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--accent);
}

.theme-brand {
  background: #ffffff;
}

.theme-brand .mobile-visual {
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.18), transparent 48%),
    #2f6f2f;
}

.theme-brand .brand-mark {
  background: #74a843;
}

.theme-green .mobile-visual,
.theme-green .brand-mark {
  background-color: #477b37;
}

.theme-teal .mobile-visual,
.theme-teal .brand-mark {
  background-color: #0f7b8a;
}

.theme-orange .mobile-visual,
.theme-orange .brand-mark {
  background-color: #b84f28;
}

.theme-blue .mobile-visual,
.theme-blue .brand-mark {
  background-color: #325d89;
}

.theme-charcoal .mobile-visual,
.theme-charcoal .brand-mark {
  background-color: #202832;
}

.book-shell {
  width: min(96vw, 1380px);
  min-width: 280px;
  display: grid;
  place-items: center;
  perspective: 2400px;
}

.book {
  position: relative;
  width: min(96vw, 1380px);
  max-height: calc(100vh - 168px);
  aspect-ratio: calc(var(--page-aspect) * 2) / 1;
  transform: scale(var(--zoom));
  transform-origin: center center;
  transition: transform 0.2s ease;
}

.book::before {
  content: "";
  position: absolute;
  z-index: 2;
  inset: 0 auto 0 50%;
  width: 2px;
  background: linear-gradient(90deg, rgba(0, 0, 0, 0.18), rgba(255, 255, 255, 0.4));
  pointer-events: none;
}

.book.is-single {
  aspect-ratio: var(--page-aspect) / 1;
}

.book.is-single::before {
  display: none;
}

.paper {
  position: absolute;
  top: 0;
  left: 50%;
  width: 50%;
  height: 100%;
  transform-origin: left center;
  transform-style: preserve-3d;
  transition: transform 0.68s cubic-bezier(0.2, 0.62, 0.2, 1);
}

.paper.is-flipped {
  transform: rotateY(-180deg);
}

.book.is-single .paper {
  left: 0;
  width: 100%;
}

.face {
  position: absolute;
  inset: 0;
  overflow: hidden;
  background: var(--panel);
  border: 1px solid rgba(0, 0, 0, 0.08);
  box-shadow: var(--shadow);
  backface-visibility: hidden;
}

.front {
  border-radius: 0 7px 7px 0;
}

.back {
  transform: rotateY(180deg);
  border-radius: 7px 0 0 7px;
}

.book.is-single .front {
  border-radius: 7px;
}

.page-content,
.blank-page {
  width: 100%;
  height: 100%;
}

.page-content {
  display: grid;
  place-items: center;
  background: #f8fafc;
}

.page-content img,
.page-content canvas {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

.page-content.is-loading::after {
  content: "";
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 3px solid #d7dee6;
  border-top-color: var(--accent);
  animation: spin 0.9s linear infinite;
}

.blank-page {
  background:
    linear-gradient(90deg, rgba(0, 0, 0, 0.04), transparent 18%),
    #fff;
}

.loader {
  position: absolute;
  left: 50%;
  top: 50%;
  width: min(420px, calc(100vw - 40px));
  transform: translate(-50%, -50%);
  padding: 18px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.94);
  border: 1px solid var(--line);
  box-shadow: 0 16px 50px rgba(21, 29, 38, 0.18);
}

.loader.is-hidden {
  display: none;
}

.loader-bar {
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: #dfe6ed;
}

.loader-bar span {
  display: block;
  width: 10%;
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--teal));
  transition: width 0.2s ease;
}

.loader p {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 14px;
}

.page-label {
  flex: 0 0 auto;
  min-width: 130px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
}

.page-slider {
  width: min(720px, 100%);
  accent-color: var(--accent);
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@media (max-width: 720px) {
  body {
    background: #111820;
  }

  .app {
    min-height: 100svh;
    background:
      linear-gradient(155deg, rgba(15, 123, 138, 0.32), transparent 34%),
      linear-gradient(28deg, rgba(228, 87, 46, 0.22), transparent 38%),
      #111820;
  }

  .topbar,
  .control-strip {
    position: sticky;
    z-index: 20;
    gap: 10px;
    padding: 10px 12px;
    background: rgba(14, 20, 27, 0.9);
    border-color: rgba(255, 255, 255, 0.12);
    color: #fff;
  }

  .topbar {
    top: 0;
    align-items: center;
  }

  .control-strip {
    bottom: 0;
  }

  .eyebrow {
    display: none;
  }

  h1 {
    font-size: 18px;
    line-height: 1.1;
  }

  .actions {
    flex: 0 0 auto;
    justify-content: flex-end;
    gap: 6px;
  }

  #firstBtn,
  #lastBtn,
  #zoomOutBtn,
  #zoomInBtn,
  #fullBtn {
    display: none;
  }

  .icon-button,
  .tool-button {
    min-width: 42px;
    height: 42px;
    border-color: rgba(255, 255, 255, 0.24);
    background: rgba(255, 255, 255, 0.08);
    color: #fff;
  }

  .tool-button {
    padding-inline: 10px;
  }

  .stage {
    display: block;
    place-items: start;
    align-items: start;
    justify-items: start;
    overflow: auto;
    padding: 10px 0 14px;
    -webkit-overflow-scrolling: touch;
  }

  .app.is-mobile-remaster .mobile-deck {
    width: 100%;
    margin: 0;
  }

  .mobile-copy {
    min-height: min(640px, calc(100svh - 132px));
  }

  .mobile-card.is-loading {
    display: grid;
    min-height: min(560px, calc(100svh - 156px));
    place-items: center;
  }

  .mobile-card.is-loading::after {
    content: "";
    width: 34px;
    height: 34px;
    border-radius: 50%;
    border: 3px solid #d7dee6;
    border-top-color: var(--accent);
    animation: spin 0.9s linear infinite;
  }

  .book-shell {
    display: block;
    width: max-content;
    min-width: 0;
    place-items: start;
    padding: 0 12px 8px;
  }

  .book {
    max-height: none;
  }

  .book.is-single {
    width: min(760px, calc((100svh - 190px) * var(--page-aspect)));
    min-width: calc(100vw - 24px);
  }

  .book.is-single .paper {
    transition: opacity 0.18s ease;
  }

  .book.is-single .paper.is-flipped {
    opacity: 0;
    pointer-events: none;
    transform: none;
  }

  .face {
    box-shadow: 0 12px 30px rgba(20, 30, 40, 0.18);
  }

  .page-label {
    flex: 0 0 auto;
    min-width: 0;
    color: rgba(255, 255, 255, 0.78);
    font-size: 13px;
  }

  .page-slider {
    flex: 1 1 auto;
    width: auto;
    min-width: 120px;
  }
}

@media (max-width: 900px) and (orientation: landscape) {
  .topbar,
  .control-strip {
    padding-block: 8px;
  }

  .book.is-single {
    width: min(calc(100vw - 24px), calc((100svh - 132px) * var(--page-aspect)));
    min-width: 0;
  }
}
