:root {
  --bg: #efe2c1;
  --paper: #fff9ef;
  --ink: #33251a;
  --ink-soft: #71573f;
  --yellow: #f0bf2f;
  --brand: #b88700;
  --brand-soft: #e0ac1a;
  --gold: #d8b15c;
  --red: #dc3545;
  --line: rgba(95, 67, 35, 0.16);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Be Vietnam Pro", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at top, rgba(255, 249, 239, 0.8), transparent 34%),
    linear-gradient(135deg, #f8edd4 0%, #e6d0a0 45%, #cda56b 100%);
}

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

.hidden {
  display: none !important;
}

.scene {
  width: min(1280px, calc(100% - 24px));
  margin: 0 auto;
  padding: 28px 0 48px;
}

.hero {
  text-align: center;
  margin-bottom: 24px;
}

.eyebrow {
  margin: 0;
  color: var(--brand);
  font-size: 0.9rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
}

.hero h1 {
  margin: 12px 0 10px;
  color: var(--yellow);
  font-family: "Playfair Display", serif;
  font-size: clamp(2.2rem, 5vw, 4.4rem);
  line-height: 1.05;
  letter-spacing: 0.02em;
  text-shadow: 0 2px 8px rgba(184, 135, 0, 0.35),
  0 4px 16px rgba(216, 177, 92, 0.25),
  0 0 40px rgba(240, 191, 47, 0.15);
}

.subtitle {
  width: min(760px, 100%);
  margin: 0 auto 20px;
  color: var(--red);
  font-weight: 600;
  line-height: 1.7;
}

.top-nav {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
}

.top-nav-btn {
  border: 1px solid rgba(108, 74, 38, 0.12);
  border-radius: 999px;
  padding: 10px 16px;
  background: rgba(255, 249, 239, 0.88);
  color: var(--ink);
  font: inherit;
  font-weight: 500;
  cursor: pointer;
  box-shadow: 0 8px 20px rgba(59, 40, 19, 0.08);
}

.top-nav-btn.is-active {
  background: linear-gradient(135deg, var(--brand), var(--brand-soft));
  border-color: transparent;
  color: #fff;
}

.content-shell {
  display: grid;
  gap: 20px;
}

.book-shell,
.panel,
.letter-view {
  padding: 22px;
  border: 1px solid rgba(108, 74, 38, 0.12);
  border-radius: 28px;
  background: rgba(255, 248, 233, 0.45);
  box-shadow: 0 28px 60px rgba(82, 58, 27, 0.12);
  backdrop-filter: blur(10px);
}

.letter-view {
  display: grid;
  place-items: center;
}

.letter-image {
  width: min(100%, 980px);
  border-radius: 12px;
  box-shadow: 0 20px 40px rgba(59, 40, 19, 0.18);
}

.panel-header h2 {
  margin: 0 0 6px;
  font-family: "Playfair Display", serif;
  font-size: 2rem;
}

.panel-header p {
  margin: 0 0 18px;
  color: var(--ink-soft);
}

.book-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.book-status {
  text-align: center;
  color: var(--ink-soft);
  font-weight: 500;
}

.mobile-swipe-hint {
  display: none;
  width: 100%;
  margin: 0;
  text-align: center;
  color: var(--ink-soft);
  font-size: 0.92rem;
}

.nav-btn,
.search-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 999px;
  padding: 12px 18px;
  background: linear-gradient(135deg, var(--brand), var(--brand-soft));
  color: #fff;
  font: inherit;
  cursor: pointer;
  box-shadow: 0 10px 24px rgba(184, 135, 0, 0.22);
}

.nav-btn:disabled {
  cursor: not-allowed;
  opacity: 0.55;
  box-shadow: none;
}

.book-root {
  position: relative;
  width: 100%;
  min-height: 72vh;
  display: grid;
  place-items: center;
  overflow: hidden;
  touch-action: pan-x pan-y;
}

.book-root.book-spine-fill::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  z-index: 2;
  width: 18px;
  height: min(78vh, 760px);
  border-radius: 10px;
  background: var(--paper);
  box-shadow:
    0 0 0 1px rgba(95, 67, 35, 0.06),
    0 0 18px rgba(255, 249, 239, 0.6);
  transform: translate(-50%, -50%);
  pointer-events: none;
}

.book {
  width: min(100%, 1120px);
  height: min(78vh, 760px);
  margin: 0 auto;
}

.book-mobile {
  width: min(100%, 560px);
  height: auto;
}

.book.book-mobile.turnjs-mobile-book {
  position: relative !important;
  left: 0 !important;
  margin-inline: auto !important;
  height: min(78vh, 760px);
  filter: drop-shadow(0 18px 36px rgba(59, 40, 19, 0.16));
  touch-action: pan-x pan-y;
}

.book.turnjs-book {
  position: relative !important;
  left: 0 !important;
  margin-inline: auto !important;
  filter: drop-shadow(0 24px 35px rgba(59, 40, 19, 0.22));
  touch-action: pan-x pan-y;
}

.book.turnjs-book .page-wrapper {
  perspective: 2000px;
}

.book.turnjs-book .page {
  overflow: hidden;
}

.search-bar {
  position: relative;
  z-index: 2;
  width: min(100%, 720px);
  margin: 20px auto 0;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 14px;
}

.search-label {
  margin: 0;
  color: var(--ink-soft);
  font-size: 0.95rem;
  font-weight: 500;
  white-space: nowrap;
}

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

.search-input {
  width: 100%;
  min-width: 0;
  border: 1px solid rgba(108, 74, 38, 0.16);
  border-radius: 999px;
  padding: 12px 16px;
  background: rgba(255, 249, 239, 0.92);
  color: var(--ink);
  font: inherit;
}

.search-input:focus {
  outline: 2px solid rgba(184, 135, 0, 0.2);
  border-color: rgba(184, 135, 0, 0.42);
}

.search-btn-secondary {
  background: rgba(255, 249, 239, 0.92);
  color: var(--ink-soft);
  border: 1px solid rgba(108, 74, 38, 0.12);
  box-shadow: none;
}

.mobile-card {
  width: 100%;
  height: 100%;
  overflow: hidden;
  border-radius: 28px;
  background: var(--paper);
  box-shadow: 0 18px 36px rgba(59, 40, 19, 0.16);
}

.mobile-cover {
  width: 100%;
}

.mobile-cover .page {
  min-height: 72vh;
  overflow: hidden;
  border-radius: 28px;
  box-shadow: 0 18px 36px rgba(59, 40, 19, 0.16);
}

.mobile-card-image {
  width: 100%;
  aspect-ratio: 16 / 10;
  object-fit: contain;
  object-position: center;
  background: linear-gradient(180deg, rgba(184, 135, 0, 0.08), rgba(216, 177, 92, 0.18));
  cursor: zoom-in;
}

.mobile-card-body {
  display: flex;
  flex-direction: column;
  height: calc(100% - min(42%, 280px));
  padding: 22px 18px 24px;
}

.mobile-card-title {
  font-size: 1.5rem;
}

.mobile-card-content {
  overflow: auto;
  font-size: 0.98rem;
  line-height: 1.8;
}

.page-mobile-turn {
  overflow: hidden;
}

.page-mobile-turn::before {
  display: none;
}

.page {
  position: relative;
  width: 100%;
  height: 100%;
  background: var(--paper);
  color: var(--ink);
  background-image:
    linear-gradient(to bottom, rgba(255, 255, 255, 0.72), rgba(240, 228, 202, 0.24)),
    repeating-linear-gradient(to bottom, transparent, transparent 31px, rgba(117, 87, 63, 0.04) 31px, rgba(117, 87, 63, 0.04) 32px);
}

.page::before {
  content: "";
  position: absolute;
  inset: 18px;
  border: 1px solid var(--line);
  pointer-events: none;
}

.page-cover {
  background:
    radial-gradient(circle at 20% 20%, rgba(255, 255, 255, 0.14), transparent 24%),
    linear-gradient(135deg, #a87400 0%, #d19a00 48%, #f0bf2f 100%);
  color: #fff8ea;
}

.cover-inner,
.page-body {
  position: relative;
  z-index: 1;
  height: 100%;
  padding: 40px 15px 20px 20px;
  display: flex;
  flex-direction: column;
}

.page-text .page-body {
  padding: 38px 32px 24px 24px;
}

.page-image .page-body {
  padding: 18px 18px 18px 14px;
}

.cover-inner {
  align-items: center;
  justify-content: start;
  text-align: center;
}

.cover-logo {
  width: 120px;
  height: 120px;
  margin-bottom: 24px;
}

.cover-logo img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.cover-kicker,
.cover-school {
  margin: 2px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-size: 0.9rem;
  line-height: 1.5;
}

.cover-inner h2 {
  margin: 10px 0 12px;
  font-family: "Playfair Display", serif;
  font-size: clamp(2.2rem, 3vw, 3.4rem);
}

.page-label {
  color: var(--brand);
  text-transform: uppercase;
  letter-spacing: 0.18em;
  font-size: 0.78rem;
}

.person-name {
  margin: 14px 0 10px;
  font-family: "Playfair Display", serif;
  font-size: clamp(1.5rem, 2vw, 2.1rem);
  line-height: 1.2;
}

.page-divider {
  width: 92px;
  height: 3px;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--gold), rgba(216, 177, 92, 0));
  margin-bottom: 18px;
}

.tribute-content {
  margin: 0;
  padding-right: 6px;
  color: var(--ink-soft);
  font-size: 1rem;
  line-height: 1.9;
  white-space: pre-wrap;
}

.image-frame {
  flex: 1;
  height: 100%;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  border-radius: 24px;
  background: linear-gradient(180deg, rgba(184, 135, 0, 0.08), rgba(216, 177, 92, 0.18));
  border: 1px solid rgba(95, 67, 35, 0.08);
  box-shadow: inset 0 0 0 8px rgba(255, 255, 255, 0.45);
}

.tribute-image {
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: center;
  cursor: zoom-in;
}

.image-viewer {
  position: fixed;
  inset: 0;
  z-index: 1200;
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 16px;
  background: rgba(17, 11, 6, 0.94);
  touch-action: pan-x pan-y;
}

.image-viewer-toolbar {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.image-viewer-btn {
  min-width: 48px;
  height: 48px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 999px;
  padding: 0 16px;
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

.image-viewer-btn-close {
  min-width: 56px;
  font-size: 1.6rem;
  line-height: 1;
}

.image-viewer-viewport {
  flex: 1;
  min-height: 0;
  overflow: auto;
  display: grid;
  place-items: center;
  border-radius: 18px;
}

.image-viewer-image {
  width: auto;
  height: auto;
  max-width: none;
  max-height: none;
  user-select: none;
  -webkit-user-drag: none;
  pointer-events: none;
}

body.image-viewer-open {
  overflow: hidden;
}

.table-wrap {
  overflow-x: auto;
}

.support-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 760px;
  background: rgba(255, 249, 239, 0.72);
}

.support-table th,
.support-table td {
  padding: 14px 16px;
  border-bottom: 1px solid rgba(95, 67, 35, 0.08);
  text-align: left;
  vertical-align: top;
}

.support-table th:nth-child(5),
.support-table td.cell-money {
  text-align: right;
}

.support-table th {
  color: var(--brand);
  font-size: 0.88rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  background: rgba(255, 248, 233, 0.9);
}

.support-table tbody tr:hover {
  background: rgba(255, 255, 255, 0.45);
}

.donate-grid {
  display: grid;
  grid-template-columns: 1.1fr 0.9fr;
  gap: 18px;
}

.donate-card {
  padding: 18px;
  border-radius: 18px;
  background: rgba(255, 249, 239, 0.78);
  border: 1px solid rgba(108, 74, 38, 0.1);
}

.donate-card h3 {
  margin: 0 0 14px;
  font-family: "Playfair Display", serif;
  font-size: 1.6rem;
}

.bank-list {
  display: grid;
  gap: 14px;
  margin: 0;
}

.bank-list div {
  display: grid;
  gap: 4px;
}

.bank-list dt {
  color: var(--ink-soft);
  font-size: 0.9rem;
}

.bank-list dd {
  margin: 0;
  font-weight: 600;
}

.donate-qr {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
}

.donate-qr img {
  width: min(100%, 320px);
  border-radius: 18px;
  background: #fff;
  padding: 12px;
}

.empty-state {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 30;
  width: min(calc(100% - 24px), 420px);
  padding: 0;
  border-radius: 18px;
  background: rgba(255, 248, 233, 0.96);
  color: var(--ink-soft);
  box-shadow: 0 18px 36px rgba(59, 40, 19, 0.18);
  backdrop-filter: blur(10px);
}

.empty-state.error {
  background: rgba(184, 135, 0, 0.12);
  color: var(--brand);
}

.empty-state-body {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 16px;
}

.empty-state p {
  margin: 0;
  flex: 1;
  line-height: 1.5;
}

.empty-state-close {
  width: 28px;
  height: 28px;
  flex: 0 0 28px;
  border: 0;
  border-radius: 999px;
  background: rgba(95, 67, 35, 0.08);
  color: inherit;
  font: inherit;
  font-size: 1rem;
  line-height: 1;
  cursor: pointer;
}

@media (max-width: 900px) {
  .scene {
    width: min(100% - 14px, 100%);
    padding-top: 20px;
  }

  .book-shell,
  .panel,
  .letter-view {
    padding: 14px;
    border-radius: 22px;
  }

  .book-toolbar {
    flex-wrap: wrap;
    gap: 10px;
  }

  .book-status {
    flex: 1;
    min-width: 0;
    font-size: 0.95rem;
  }

  .mobile-swipe-hint {
    display: block;
    order: 4;
  }

  .book-root {
    min-height: 64vh;
  }

  .book-root.book-spine-fill::after {
    height: min(64vh, 620px);
  }

  .search-bar {
    margin-top: 16px;
    display: block;
  }

  .search-controls {
    grid-template-columns: minmax(0, 1fr) auto;
  }

  .search-btn-secondary {
    grid-column: 1 / -1;
  }

  .donate-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 900px) and (orientation: landscape) {
  .book-root {
    min-height: 0;
    overflow: visible;
  }

  .book-root.book-spine-fill::after {
    height: 100%;
  }

  .book.turnjs-book {
    max-width: 100%;
  }
}

@media (max-width: 640px) {
  .hero h1 {
    font-size: 2.5rem;
  }

  .subtitle {
    font-size: 0.96rem;
  }

  .top-nav {
    gap: 8px;
  }

  .top-nav-btn {
    width: calc(50% - 6px);
    padding: 10px 12px;
  }

  .book {
    height: 74vh;
  }

  .book-root.book-spine-fill::after {
    display: none;
  }

  .mobile-cover .page {
    min-height: 68vh;
    border-radius: 22px;
  }

  .mobile-card-body {
    padding: 18px 16px 20px;
  }

  .image-viewer {
    padding: 12px;
  }

  .image-viewer-toolbar {
    justify-content: space-between;
  }

  .image-viewer-btn {
    min-width: 44px;
    height: 44px;
    padding: 0 14px;
  }

  .search-controls {
    grid-template-columns: 1fr;
  }

  .search-btn,
  .search-btn-secondary {
    width: 100%;
  }

  .support-table {
    min-width: 620px;
  }
}
