* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  margin: 0;
  background-color: #e5e7eb;
  color: #1f2933;
  font-family: "Pretendard", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

body {
  display: flex;
  align-items: stretch;
  justify-content: center;
  padding: 0;
}

.viewer-shell {
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 100%;
  height: 100%;
  max-height: 100%;
  background: transparent;
  border-radius: 0;
  box-shadow: none;
  overflow: hidden;
}

.viewer-header {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding: 12px 20px;
  color: #1f2933;
  flex-shrink: 0;
}

.viewer-footer {
  display: none;
}

.brand {
  display: none;
}

.icon-button {
  border: none;
  background: transparent;
  color: #1f2933;
  font-size: 20px;
  border-radius: 8px;
  width: 36px;
  height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.2s ease;
  padding: 0;
}

.icon-button:hover,
.icon-button:focus-visible {
  background: rgba(0, 0, 0, 0.08);
}

.icon-button:active {
  background: rgba(0, 0, 0, 0.12);
}

.viewer-main {
  position: relative;
  display: flex;
  min-height: 0;
  flex: 1 1 auto;
  overflow: hidden;
  background: #e5e7eb;
}

.thumbnail-panel {
  width: 200px;
  border-right: 1px solid rgba(148, 163, 184, 0.25);
  background: rgba(255, 255, 255, 0.75);
  backdrop-filter: blur(6px);
  overflow-y: auto;
  padding: 20px 14px;
}

.thumbnail-list {
  display: grid;
  gap: 12px;
}

.thumbnail-item {
  position: relative;
  border-radius: 12px;
  overflow: hidden;
  background: #ffffff;
  box-shadow: 0 12px 24px rgba(15, 23, 42, 0.08);
  cursor: pointer;
  transition: transform 0.18s ease, box-shadow 0.18s ease;
}

.thumbnail-item:hover {
  transform: translateY(-3px);
  box-shadow: 0 18px 30px rgba(15, 23, 42, 0.12);
}

.thumbnail-item canvas {
  width: 100%;
  display: block;
}

.thumbnail-caption {
  position: absolute;
  inset: auto 8px 8px 8px;
  padding: 4px 8px;
  border-radius: 10px;
  background: rgba(15, 23, 42, 0.65);
  color: #ffffff;
  font-size: 12px;
  text-align: center;
}

.spread-area {
  position: relative;
  flex: 1 1 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 20px;
  padding: 0 60px;
  min-height: 0;
}

.nav-button {
  border: none;
  background: transparent;
  color: #000000;
  font-size: 70px;
  line-height: 1;
  width: 60px;
  height: 60px;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-shadow: none;
  cursor: pointer;
  transition: opacity 0.2s ease;
  z-index: 10;
}

.nav-button:hover,
.nav-button:focus-visible {
  background: transparent;
  color: #000000;
}

.nav-button:disabled {
  opacity: 0.3;
  cursor: default;
}

.spread-container {
  position: relative;
  flex: 1 1 auto;
  display: flex;
  justify-content: center;
  align-items: center;
  width: 100%;
  height: 100%;
}

.book-view {
  display: block !important;
  position: relative;
  transition: transform 0.3s ease;
  transform-origin: center center;
  visibility: visible !important;
  opacity: 1 !important;
}

.book-view .page {
  width: 100%;
  height: 100%;
  background: #ffffff !important;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25), 0 2px 8px rgba(0, 0, 0, 0.15) !important;
  border-radius: 0;
  overflow: hidden;
}

.book-view canvas {
  width: 100%;
  height: 100%;
  display: block;
}

.hidden {
  display: none !important;
}

.loading-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(8px);
  background: rgba(229, 231, 235, 0.95);
  z-index: 100;
  transition: opacity 0.3s ease, visibility 0.3s ease;
}

.loading-overlay.hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.loading-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
}

.loading-bar-container {
  width: 300px;
  height: 6px;
  background: rgba(0, 0, 0, 0.1);
  border-radius: 3px;
  overflow: hidden;
  position: relative;
}

.loading-bar {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #3069ff 0%, #5fb4ff 100%);
  border-radius: 3px;
  animation: loading-progress 2s ease-in-out infinite;
  transition: width 0.3s ease;
}

@keyframes loading-progress {
  0% {
    width: 0%;
    transform: translateX(0);
  }
  50% {
    width: 70%;
    transform: translateX(0);
  }
  100% {
    width: 100%;
    transform: translateX(0);
  }
}

.loading-text {
  font-size: 16px;
  font-weight: 500;
  color: #1f2933;
  letter-spacing: 0.05em;
}

.quick-controls {
  position: absolute;
  right: 20px;
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px 8px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  z-index: 10;
  align-items: center;
}

.quick-controls .icon-button {
  width: 32px;
  height: 32px;
  font-size: 18px;
  color: #1f2933;
}

.zoom-slider {
  width: 4px;
  height: 120px;
  writing-mode: vertical-lr;
  direction: rtl;
  background: #d1d5db;
  border-radius: 2px;
  outline: none;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
}

.zoom-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #4b5563;
  cursor: pointer;
}

.zoom-slider::-moz-range-thumb {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #4b5563;
  cursor: pointer;
  border: none;
}

.zoom-value {
  font-size: 11px;
  font-weight: 500;
  text-align: center;
  color: #4b5563;
  padding: 4px 0;
}

.page-status {
  font-weight: 600;
}

.footer-controls {
  display: flex;
  align-items: center;
  gap: 12px;
}

.slider-label {
  font-size: 14px;
  color: #475569;
  font-weight: 500;
}

#zoomSlider {
  width: 8px;
}

#fitButton {
  padding: 8px 16px;
  border-radius: 12px;
  border: none;
  background: #1d4ed8;
  color: #ffffff;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

#fitButton:hover,
#fitButton:focus-visible {
  transform: translateY(-1px);
  box-shadow: 0 10px 20px rgba(29, 78, 216, 0.25);
}

#fitButton:active {
  transform: none;
  box-shadow: none;
}

@media (max-width: 1024px) {
  .spread-container {
    max-width: 720px;
  }
}

@media (max-width: 900px) {
  body {
    padding: 10px;
  }

  .viewer-shell {
    border-radius: 0;
  }

  .thumbnail-panel {
    display: none !important;
  }

  .quick-controls {
    display: none;
  }
}

/* 모바일 타이틀 (기본 숨김) */
.mobile-title {
  display: none;
}

/* 모바일 전용 스타일 (768px 이하) */
@media (max-width: 768px) {
  body {
    padding: 0;
    margin: 0;
  }

  .viewer-shell {
    box-shadow: none;
    border-radius: 0;
  }

  .viewer-header {
    display: none !important;
  }

  /* 모바일 타이틀 표시 */
  .mobile-title {
    display: block;
    position: fixed;
    top: 20px;
    left: 20px;
    font-size: 16px;
    font-weight: 600;
    color: #1f2933;
    z-index: 100;
    padding: 8px 12px;
  }

  .spread-area {
    padding: 0;
    gap: 0;
    padding-top: 70px;
    align-items: flex-start !important;
  }

  /* 네비게이션 버튼 숨김 (스와이프 사용) */
  .nav-button {
    display: none !important;
  }

  .spread-container {
    width: 100vw;
    padding: 0;
    align-items: flex-start !important;
  }

  .book-view {
    width: 100vw !important;
    margin: 0 !important;
  }

  .book-view .page {
    width: 100% !important;
    box-shadow: none !important;
  }
}


