* {
  box-sizing: border-box;
}

:root {
  --bg: #0f0f10;
  --panel: #171719;
  --panel-2: #202024;
  --text: #f5f1e8;
  --muted: #aaa5a0;
  --accent: #c79a54;
  --accent-dark: #8d642f;
  --line: rgba(255, 255, 255, 0.12);
  --shadow: 0 24px 70px rgba(0, 0, 0, 0.45);
}

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

body {
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
    "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at top, rgba(199, 154, 84, 0.16), transparent 32rem),
    var(--bg);
  color: var(--text);
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-rows: auto 1fr auto;
}

.topbar,
.footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 1.4rem;
  border-color: var(--line);
  background: rgba(15, 15, 16, 0.86);
  backdrop-filter: blur(14px);
  z-index: 20;
}

.topbar {
  border-bottom: 1px solid var(--line);
}

.footer {
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.85rem;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.8rem;
}

.brand-mark {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 12px;
  background: linear-gradient(145deg, var(--accent), var(--accent-dark));
  color: #17120b;
  font-family: Georgia, serif;
  font-weight: 800;
  font-size: 1.4rem;
  box-shadow: 0 10px 25px rgba(199, 154, 84, 0.22);
}

.brand h1,
.brand p {
  margin: 0;
}

.brand h1 {
  font-size: 1.05rem;
}

.brand p {
  margin-top: 0.15rem;
  color: var(--muted);
  font-size: 0.78rem;
}

.top-actions {
  display: flex;
  gap: 0.6rem;
}

.button,
.icon-button,
.nav-button {
  border: 1px solid var(--line);
  color: var(--text);
  background: var(--panel-2);
  transition: 0.2s ease;
}

.button:hover,
.icon-button:hover,
.nav-button:hover {
  transform: translateY(-1px);
  border-color: rgba(199, 154, 84, 0.7);
}

.button {
  padding: 0.7rem 1rem;
  border-radius: 10px;
  font-weight: 700;
}

.button.primary {
  color: #17120b;
  background: var(--accent);
  border-color: transparent;
}

.main-area {
  position: relative;
  min-height: 0;
}

.welcome-panel,
.reader-panel {
  min-height: calc(100vh - 144px);
}

.welcome-panel {
  display: grid;
  place-items: center;
  padding: 2rem;
}

.welcome-card {
  width: min(680px, 100%);
  padding: 2.2rem;
  border: 1px solid var(--line);
  border-radius: 24px;
  background: linear-gradient(155deg, rgba(35, 35, 38, 0.95), rgba(19, 19, 21, 0.95));
  box-shadow: var(--shadow);
  text-align: center;
}

.eyebrow {
  display: inline-block;
  margin-bottom: 0.8rem;
  color: var(--accent);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.14em;
}

.welcome-card h2 {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(2rem, 5vw, 4rem);
  line-height: 1.05;
}

.welcome-card p {
  color: var(--muted);
  line-height: 1.7;
}

.drop-zone {
  margin-top: 1.4rem;
  padding: 2.6rem 1.2rem;
  border: 1px dashed rgba(199, 154, 84, 0.55);
  border-radius: 18px;
  background: rgba(199, 154, 84, 0.06);
  outline: none;
}

.drop-zone strong,
.drop-zone span {
  display: block;
}

.drop-zone span {
  margin-top: 0.35rem;
  color: var(--muted);
}

.drop-zone.dragging,
.drop-zone:focus {
  border-color: var(--accent);
  background: rgba(199, 154, 84, 0.12);
}

.small-note {
  margin-bottom: 0;
  font-size: 0.85rem;
}

.reader-panel {
  position: relative;
  display: grid;
  grid-template-rows: 1fr auto;
  overflow: hidden;
}

.hidden {
  display: none !important;
}

.book-stage {
  position: relative;
  min-height: 0;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 0.8rem;
  padding: 1rem;
}

.book-viewport {
  position: relative;
  min-width: 0;
  min-height: 65vh;
  display: grid;
  place-items: center;
  overflow: auto;
  border-radius: 16px;
  perspective: 1800px;
}

.flipbook {
  margin: auto;
  transform-origin: center center;
  transition: transform 0.2s ease;
}

.page {
  background: #f7f3e8;
  color: #111;
  overflow: hidden;
  box-shadow: inset 0 0 22px rgba(0, 0, 0, 0.08);
}

.page canvas {
  width: 100%;
  height: 100%;
  display: block;
}

.page-cover {
  display: grid;
  place-items: center;
  padding: 2rem;
  text-align: center;
  background:
    linear-gradient(rgba(20, 15, 10, 0.12), rgba(20, 15, 10, 0.12)),
    #efe6d5;
}

.page-cover-inner {
  width: 80%;
  padding: 2rem 1rem;
  border: 2px solid #6e4d25;
}

.page-cover h2 {
  margin: 0;
  font-family: Georgia, serif;
  font-size: 2rem;
}

.page-cover p {
  color: #5d4934;
}

.nav-button {
  width: 48px;
  height: 64px;
  border-radius: 15px;
  font-size: 2.2rem;
  z-index: 10;
}

.controlbar {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 0.9rem;
  padding: 0.8rem 1rem 1rem;
}

.control-group,
.zoom-control,
.page-status {
  display: flex;
  align-items: center;
  gap: 0.45rem;
}

.icon-button {
  min-width: 42px;
  height: 38px;
  border-radius: 9px;
}

.icon-button.wide {
  padding-inline: 0.8rem;
}

.page-status {
  padding: 0.45rem 0.65rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel);
}

.page-status input {
  width: 64px;
  padding: 0.35rem 0.4rem;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #111;
  color: var(--text);
  text-align: center;
}

.zoom-control {
  padding-left: 0.5rem;
}

#zoomLabel {
  min-width: 50px;
  text-align: center;
  color: var(--muted);
}

.loading-overlay {
  position: absolute;
  inset: 0;
  z-index: 50;
  display: grid;
  place-content: center;
  justify-items: center;
  background: rgba(15, 15, 16, 0.91);
}

.spinner {
  width: 46px;
  height: 46px;
  border: 4px solid rgba(255, 255, 255, 0.12);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
}

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

@media (max-width: 760px) {
  .topbar {
    align-items: flex-start;
  }

  .brand p,
  .footer span:first-child {
    display: none;
  }

  .button {
    padding: 0.65rem 0.75rem;
  }

  .book-stage {
    grid-template-columns: 1fr;
    padding-inline: 0.4rem;
  }

  .nav-button {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 42px;
    height: 56px;
    background: rgba(32, 32, 36, 0.86);
  }

  .nav-button:hover {
    transform: translateY(-50%);
  }

  .nav-button.left {
    left: 0.4rem;
  }

  .nav-button.right {
    right: 0.4rem;
  }

  .book-viewport {
    min-height: 68vh;
  }

  .controlbar {
    gap: 0.55rem;
  }

  .zoom-control {
    width: 100%;
    justify-content: center;
  }
}


/* ===== Mobile Responsive Banner Fix ===== */

@media (max-width: 760px) {

  .topbar {
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 18px 14px;
    gap: 1rem;
    min-height: auto;
    text-align: center;
  }

  .topbar .brand {
    width: 100%;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
  }

  .brand-logo {
    width: 82px;
    height: 82px;
    flex-basis: 82px;
  }

  .brand-copy {
    width: 100%;
    max-width: 100%;
    text-align: center;
  }

  .brand-kicker {
    font-size: 0.65rem;
    letter-spacing: 0.12em;
    white-space: normal;
  }

  .topbar #bookTitle {
    font-size: clamp(1.6rem, 8vw, 2.2rem);
    line-height: 1.15;
    letter-spacing: 0.03em;
    word-break: normal;
    overflow-wrap: normal;
    white-space: normal;
  }

  .topbar .brand-copy p {
    font-size: 0.9rem;
  }

  .top-actions {
    width: 100%;
    justify-content: center;
    flex-wrap: wrap;
  }

  .top-actions .button {
    padding: 0.65rem 1rem;
  }

}


@media (max-width: 480px) {

  .topbar {
    padding: 15px 10px;
  }

  .brand-logo {
    width: 72px;
    height: 72px;
    flex-basis: 72px;
  }

  .topbar #bookTitle {
    font-size: 1.55rem;
  }

  .brand-kicker {
    font-size: 0.58rem;
  }

  .top-actions {
    gap: 8px;
  }

  .button {
    font-size: 0.85rem;
  }

}

/* ------------------------------------------------------------
   Compact professional literature header
   ------------------------------------------------------------ */
.topbar {
  position: relative;
  min-height: 112px;
  padding: 14px clamp(18px, 3vw, 42px);
  overflow: hidden;
  border-bottom: 1px solid rgba(212, 175, 55, 0.72);
  background:
    linear-gradient(90deg, rgba(4, 17, 30, 0.98) 0%, rgba(7, 28, 47, 0.94) 52%, rgba(4, 17, 30, 0.90) 100%),
    url("assets/liakat-banner-photo.jpg") center 37% / cover no-repeat;
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.3);
  isolation: isolate;
}

.topbar::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  background:
    radial-gradient(circle at 10% 45%, rgba(212, 175, 55, 0.16), transparent 28%),
    linear-gradient(90deg, transparent 0%, rgba(255, 255, 255, 0.035) 58%, transparent 100%);
  pointer-events: none;
}

.topbar .brand {
  min-width: 0;
  max-width: min(1050px, calc(100% - 245px));
  gap: 16px;
}

.brand-logo {
  width: 72px;
  height: 72px;
  flex: 0 0 72px;
  border-radius: 50%;
  object-fit: cover;
  object-position: center 24%;
  border: 2px solid #d9b54a;
  background: #fff;
  box-shadow:
    0 0 0 4px rgba(255, 255, 255, 0.08),
    0 8px 22px rgba(0, 0, 0, 0.35);
}

.brand-copy {
  min-width: 0;
}

.brand-kicker {
  display: block;
  margin-bottom: 4px;
  color: #e2bd4e;
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

.topbar #bookTitle {
  display: -webkit-box;
  max-width: 100%;
  margin: 0;
  overflow: hidden;
  color: #fff;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(1.35rem, 2.25vw, 2.25rem);
  font-weight: 700;
  line-height: 1.08;
  letter-spacing: 0.015em;
  text-wrap: balance;
  overflow-wrap: anywhere;
  text-shadow: 0 2px 12px rgba(0, 0, 0, 0.38);
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.topbar .brand-copy p {
  margin: 5px 0 0;
  color: rgba(237, 203, 103, 0.94);
  font-size: 0.82rem;
  letter-spacing: 0.035em;
}

.topbar .top-actions {
  position: relative;
  z-index: 1;
  flex: 0 0 auto;
  gap: 10px;
}

.topbar .button {
  min-height: 44px;
  padding: 0.66rem 0.95rem;
  border-radius: 11px;
  border-color: rgba(255, 255, 255, 0.20);
  background: rgba(20, 25, 33, 0.72);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.16);
  backdrop-filter: blur(9px);
}

.topbar .button.primary {
  color: #17120b;
  border-color: rgba(255, 255, 255, 0.12);
  background: linear-gradient(180deg, #e1bd67, #c99a47);
}

/* More room for the book after reducing the header height. */
.welcome-panel,
.reader-panel {
  min-height: calc(100vh - 166px);
}

.book-stage {
  padding-top: 0.7rem;
}

.book-viewport {
  min-height: calc(100vh - 248px);
  overflow: hidden;
}

/* Preserve high-resolution PDF raster detail inside PageFlip. */
.flipbook,
.stf__parent,
.stf__wrapper,
.stf__block {
  transform-origin: center center;
}

.stf__item img,
.flipbook img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: fill;
  image-rendering: auto;
  -webkit-font-smoothing: antialiased;
  backface-visibility: hidden;
}

@media (max-width: 900px) {
  .topbar {
    min-height: 102px;
    padding: 12px 16px;
  }

  .topbar .brand {
    max-width: calc(100% - 205px);
    gap: 12px;
  }

  .brand-logo {
    width: 62px;
    height: 62px;
    flex-basis: 62px;
  }

  .topbar #bookTitle {
    font-size: clamp(1.1rem, 3.5vw, 1.7rem);
  }

  .topbar .button {
    min-height: 40px;
    padding: 0.58rem 0.72rem;
    font-size: 0.86rem;
  }
}

@media (max-width: 620px) {
  .topbar {
    min-height: 88px;
    align-items: center;
    gap: 8px;
  }

  .topbar .brand {
    max-width: calc(100% - 96px);
  }

  .brand-logo {
    width: 52px;
    height: 52px;
    flex-basis: 52px;
  }

  .brand-kicker,
  .topbar .brand-copy p {
    display: none;
  }

  .topbar #bookTitle {
    font-size: clamp(1rem, 4.5vw, 1.35rem);
    -webkit-line-clamp: 2;
  }

  .topbar .top-actions {
    gap: 6px;
  }

  .topbar .button {
    min-height: 38px;
    padding: 0.52rem 0.64rem;
    font-size: 0.78rem;
  }

  .topbar .button:not(.primary) {
    width: 42px;
    overflow: hidden;
    color: transparent;
    white-space: nowrap;
  }

  .topbar .button:not(.primary)::after {
    content: "⛶";
    display: block;
    color: var(--text);
    font-size: 1rem;
  }

  .book-viewport {
    min-height: calc(100vh - 220px);
  }
}
