*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  overflow: hidden; /* body自体はスクロールさせない */
}

body {
  display: flex;
  flex-direction: column;
  background: #f0ede8;
  font-family: 'Hiragino Kaku Gothic ProN', 'Meiryo', sans-serif;
  color: #333;
}

/* ===== ヘッダー（固定） ===== */
#header {
  flex-shrink: 0;
  background: #1a1a1a;
  color: #fff;
  padding: 12px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  z-index: 100;
}

.back-link {
  color: #ccc;
  text-decoration: none;
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: color 0.2s;
  white-space: nowrap;
}
.back-link:hover { color: #fff; }

.header-title {
  font-size: 14px;
  font-weight: bold;
  letter-spacing: 0.1em;
}

.header-right { width: 100px; }

/* ===== ツールバー（固定） ===== */
#toolbar {
  flex-shrink: 0;
  background: #2a2a2a;
  padding: 10px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  z-index: 99;
}

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

#controls button {
  padding: 8px 18px;
  background: #555;
  color: #fff;
  border: none;
  border-radius: 4px;
  font-size: 13px;
  cursor: pointer;
  transition: background 0.2s;
  white-space: nowrap;
  -webkit-tap-highlight-color: transparent;
}
#controls button:hover:not(:disabled) { background: #777; }
#controls button:disabled { opacity: 0.3; cursor: default; }

#page-info {
  font-size: 13px;
  color: #aaa;
  min-width: 70px;
  text-align: center;
}

#zoom-controls {
  display: flex;
  align-items: center;
  gap: 6px;
}

#zoom-controls button {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  padding: 0;
  background: #555;
  color: #fff;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  transition: background 0.2s;
  -webkit-tap-highlight-color: transparent;
}
#zoom-controls button:hover:not(:disabled) { background: #777; }
#zoom-controls button:disabled { opacity: 0.3; cursor: default; }

#zoom-reset {
  width: auto !important;
  padding: 0 10px !important;
  font-size: 12px !important;
}

#zoom-label {
  font-size: 12px;
  color: #aaa;
  min-width: 40px;
  text-align: center;
}

/* ===== メイン（残りの高さを全部使う） ===== */
#main {
  flex: 1;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

/* ===== ローディング ===== */
#loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  color: #666;
  font-size: 14px;
}

.loading-spinner {
  width: 40px;
  height: 40px;
  border: 3px solid #ddd;
  border-top-color: #1a1a1a;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ===== PDFスクロールエリア（ここだけスクロール） ===== */
#pdf-scroll-area {
  width: 100%;
  height: 100%;
  overflow: auto; /* ← ここだけスクロール */
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding: 20px;
}

#pdf-inner {
  display: flex;
  justify-content: center;
  align-items: flex-start;
  min-width: fit-content;
}

/* ===== canvasアニメーション ===== */
#pdf-canvas {
  display: block;
  box-shadow: 0 4px 24px rgba(0,0,0,0.25);
  background: #fff;
  /* ページめくりアニメーション */
  transition: opacity 0.25s ease, transform 0.25s ease;
}

#pdf-canvas.page-leave {
  opacity: 0;
  transform: translateX(-30px);
}

#pdf-canvas.page-enter {
  opacity: 0;
  transform: translateX(30px);
}

/* ===== フッター（固定） ===== */
#footer {
  flex-shrink: 0;
  text-align: center;
  padding: 10px;
  font-size: 11px;
  color: #999;
  background: #1a1a1a;
}

/* ===== スマホ ===== */
@media (max-width: 767px) {
  #toolbar {
    padding: 8px 12px;
    justify-content: center;
  }

  #controls button {
    padding: 8px 12px;
    font-size: 12px;
  }

  .header-right { width: 40px; }
}
