:root {
  --navy: #08243d;
  --navy-dark: #041220;
  --navy-light: #0f3d65;
  --gold: #d5a84c;
  --gold-hover: #e6be67;
  --gold-glow: rgba(213, 168, 76, 0.25);
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --surface-glass: rgba(8, 36, 61, 0.82);
  --surface-border: rgba(213, 168, 76, 0.25);
  --white: #ffffff;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: radial-gradient(circle at 50% 45%, #0e375d 0%, var(--navy) 48%, var(--navy-dark) 100%);
  color: var(--text-main);
  user-select: none;
  -webkit-user-select: none;
}

/* Top bar */
.top-bar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 58px;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  background: var(--surface-glass);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--surface-border);
}

.top-bar-left {
  display: flex;
  align-items: center;
  gap: 14px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text-main);
  text-decoration: none;
  font-weight: 700;
  font-size: 13px;
  letter-spacing: 1.2px;
  text-transform: uppercase;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  background: linear-gradient(135deg, var(--gold), #997327);
  color: var(--navy-dark);
  font-weight: 900;
  font-size: 12px;
  border-radius: 6px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.top-divider {
  color: rgba(255, 255, 255, 0.2);
  font-size: 14px;
}

.doc-title {
  color: var(--gold);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 1px;
  text-transform: uppercase;
}

.top-bar-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.btn-top {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 14px;
  border-radius: 6px;
  background: rgba(213, 168, 76, 0.12);
  border: 1px solid var(--gold);
  color: var(--gold);
  font-size: 12px;
  font-weight: 600;
  text-decoration: none;
  letter-spacing: 0.5px;
  transition: all 0.2s ease;
}

.btn-top:hover {
  background: var(--gold);
  color: var(--navy-dark);
  box-shadow: 0 0 12px var(--gold-glow);
}

/* Viewer stage */
.viewer-stage {
  position: absolute;
  top: 58px;
  bottom: 64px;
  left: 0;
  right: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px 64px;
}

.side-nav-btn {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 46px;
  height: 46px;
  border-radius: 50%;
  background: var(--surface-glass);
  border: 1px solid var(--surface-border);
  color: var(--gold);
  cursor: pointer;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  transition: all 0.2s ease;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.35);
}

.side-nav-btn:hover:not(:disabled) {
  background: var(--gold);
  color: var(--navy-dark);
  transform: translateY(-50%) scale(1.08);
}

.side-nav-btn:disabled {
  opacity: 0.25;
  cursor: not-allowed;
}

.prev-btn {
  left: 20px;
}

.next-btn {
  right: 20px;
}

.flipbook-shell {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
}

.flipbook {
  position: relative;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.65), 0 0 0 1px rgba(255, 255, 255, 0.05);
  transition: transform 0.25s ease-out;
  transform-origin: center center;
}

.stf__block {
  perspective: none !important;
}

.page {
  background: #ffffff;
  overflow: hidden;
}

.page-blank {
  background: #ffffff;
}

.page canvas,
.page img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  user-select: none;
  -webkit-user-drag: none;
}

.flipbook-status {
  position: absolute;
  inset: 0;
  z-index: 10;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  background: rgba(4, 18, 32, 0.85);
  backdrop-filter: blur(8px);
  color: var(--gold);
  font-size: 13px;
  letter-spacing: 0.5px;
}

.flipbook-status progress {
  width: 220px;
  height: 4px;
  accent-color: var(--gold);
}

.flipbook-error {
  position: absolute;
  inset: 0;
  z-index: 10;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 24px;
  background: rgba(4, 18, 32, 0.9);
  color: #fca5a5;
  font-size: 14px;
  text-align: center;
}

.flipbook-error[hidden] {
  display: none !important;
}

.flipbook-error a {
  color: var(--gold);
  text-decoration: underline;
}

/* Floating bottom controls */
.bottom-bar {
  position: fixed;
  bottom: 12px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 50;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px;
  background: var(--surface-glass);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1px solid var(--surface-border);
  border-radius: 9999px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.45);
}

.bar-group {
  display: flex;
  align-items: center;
  gap: 6px;
}

.nav-group {
  padding: 0 8px;
  border-left: 1px solid rgba(255, 255, 255, 0.12);
  border-right: 1px solid rgba(255, 255, 255, 0.12);
}

.control-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  padding: 0;
  border-radius: 50%;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.2s ease;
}

.control-btn:hover:not(:disabled) {
  color: var(--gold);
  background: rgba(213, 168, 76, 0.15);
  border-color: rgba(213, 168, 76, 0.35);
}

.control-btn:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

.control-btn.active {
  color: var(--gold);
  background: rgba(213, 168, 76, 0.2);
  border-color: var(--gold);
}

.text-btn {
  width: auto;
  border-radius: 6px;
  padding: 0 8px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.5px;
}

.page-counter {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-main);
  min-width: 90px;
  text-align: center;
  letter-spacing: 0.5px;
}

/* Thumbnail drawer */
.thumbnail-drawer {
  position: fixed;
  bottom: 64px;
  left: 50%;
  transform: translateX(-50%);
  width: min(92vw, 860px);
  max-height: 220px;
  z-index: 45;
  background: var(--surface-glass);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--surface-border);
  border-radius: 12px;
  padding: 12px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.55);
}

.thumbnail-drawer[hidden] {
  display: none;
}

.thumbnail-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--gold);
}

.thumbnail-header button {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 14px;
  padding: 2px 6px;
}

.thumbnail-header button:hover {
  color: var(--gold);
}

.thumbnail-grid {
  display: flex;
  gap: 14px;
  overflow-x: auto;
  padding-bottom: 6px;
  scrollbar-width: thin;
  scrollbar-color: var(--gold) transparent;
}

.thumb-item {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  border: 2px solid transparent;
  border-radius: 4px;
  padding: 4px;
  transition: all 0.2s ease;
}

.thumb-item:hover {
  border-color: rgba(213, 168, 76, 0.5);
  transform: translateY(-2px);
}

.thumb-item.active {
  border-color: var(--gold);
  box-shadow: 0 0 10px var(--gold-glow);
}

.thumb-item canvas,
.thumb-item img {
  width: 90px;
  height: auto;
  border-radius: 2px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.4);
  background: #ffffff;
  display: block;
}

.thumb-label {
  font-size: 10px;
  font-weight: 600;
  color: var(--text-muted);
}

.thumb-item.active .thumb-label {
  color: var(--gold);
}

/* Responsive */
@media (max-width: 768px) {
  .brand-name {
    display: none;
  }

  .top-divider {
    display: none;
  }

  .viewer-stage {
    padding: 8px 12px;
  }

  .side-nav-btn {
    width: 38px;
    height: 38px;
  }

  .prev-btn {
    left: 8px;
  }

  .next-btn {
    right: 8px;
  }

  .bottom-bar {
    bottom: 8px;
    padding: 4px 10px;
    gap: 4px;
  }

  .btn-top span {
    display: none;
  }
}
