:root {
  --header-height: 80px;
  --page-padding: 20px;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  padding: 0;
  background-color: #f5f6f7;
  font-family: Arial, sans-serif;
  color: #222;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  overflow: hidden;
}

header {
  padding: 16px var(--page-padding);
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid rgba(0, 0, 0, 0.06);
  background: #ffffffcc;
  backdrop-filter: saturate(1.2) blur(2px);
  gap: 20px;
}

.title {
  text-align: left;
  flex: 1;
}

.title h1 {
  margin: 0;
  font-size: 20px;
  font-weight: 700;
  letter-spacing: 0.2px;
}

.title p {
  margin: 4px 0 0;
  font-size: 14px;
  color: #555;
}

.actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  flex-shrink: 0;
  align-items: center;
}

.btn {
  appearance: none;
  border: 1px solid #d0d1d4;
  background: #fff;
  color: #111;
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
  transition: transform 0.04s ease, box-shadow 0.2s ease, border-color 0.2s ease;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06);
  white-space: nowrap;
}

.btn:hover {
  border-color: #bbbcc0;
  transform: translateY(-1px);
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.08);
}

.zoom-controls {
  display: flex;
  gap: 8px;
  align-items: center;
  border-left: 1px solid rgba(0, 0, 0, 0.1);
  padding-left: 15px;
  margin-left: 5px;
}

.zoom-btn {
  font-size: 16px;
  min-width: 40px;
}

.zoom-info {
  font-size: 12px;
  color: #666;
  min-width: 35px;
  text-align: center;
}

main {
  flex: 1 1 auto;
  min-height: 0;
  display: grid;
  place-items: center;
  padding: 16px;
  overflow: hidden;
  position: relative;
}

#book-wrapper {
  width: 100%;
  height: 100%;
  display: grid;
  place-items: center;
  overflow: hidden;
  position: relative;
  /* Default cursor */
  cursor: default;
}

/* Cursor states for the wrapper when draggable */
#book-wrapper.draggable {
  cursor: grab;
}

#book-wrapper.dragging {
  cursor: grabbing;
}

#book {
  margin: 0;
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.16);
  border-radius: 10px;
  background: #fff;
  max-width: calc(100vw - 32px);
  max-height: calc(100vh - var(--header-height) - 32px);
  overflow: hidden;
  transform-origin: center center;
  transition: transform 0.3s ease;
  position: relative;
}

/* Disable transitions when dragging */
#book-wrapper.dragging #book {
  transition: none;
}

.page {
  background: white;
  display: flex;
  align-items: center;
  justify-content: center;
}

#loading {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 100%;
  text-align: center;
  padding: 20px;
  font-size: 16px;
  color: #666;
  pointer-events: none;
  z-index: 10;
}

canvas {
  max-width: 100%;
  height: auto;
  display: block;
}

/* Pan hint */
.pan-hint {
  position: absolute;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0, 0, 0, 0.7);
  color: white;
  padding: 8px 12px;
  border-radius: 4px;
  font-size: 12px;
  opacity: 0;
  transition: opacity 0.3s ease;
  pointer-events: none;
  z-index: 20;
}

.pan-hint.show {
  opacity: 1;
}

@media (max-width: 768px) {
  header {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
  }

  .actions {
    width: 100%;
    justify-content: flex-start;
  }

  .btn {
    padding: 8px 12px;
    font-size: 12px;
  }

  .zoom-controls {
    border-left: none;
    padding-left: 0;
    margin-left: 0;
    margin-top: 5px;
  }
}
