:root {
  --header-h: clamp(80px, 12vh, 140px);
  --toolbar-h: 56px;
  --outline-w: 280px;

  --black: #000;
  --white: #fff;
  --stroke: #e3e7ee;
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
  font-family: 'Montserrat', sans-serif;
  color: var(--black);
  background: transparent;
}

a { text-decoration: none; color: inherit; }

/* ================= HEADER ================= */
.site-header {
  height: var(--header-h);
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  padding: 5%;
}

.header-inner {
  width: min(1200px, 90vw);
  display: flex;
  align-items: center;
  gap: 5vw;
  flex-wrap: nowrap;
}

.brand img.logo {
  width: clamp(30px, 7vw, 100px);
  height: auto;
  object-fit: cover;
  transition: transform .4s ease, filter .4s ease;
  display: block;
}

.brand img.logo:hover {
  transform: scale(1.05);
  filter: drop-shadow(0 0 2px rgba(0, 0, 0, .7));
}

.divider {
  width: .05vw;
  min-width: 1px;
  height: 7vh;
  background: var(--black);
  margin: 0 .15rem;
  animation: slide-line 1.2s forwards;
}

@keyframes slide-line {
  from { height: 0 }
  to { height: 15vh }
}

.nav-link { margin: 0; flex: 1 }

.nav-link h1 {
  margin: 0;
  padding: 0;
  letter-spacing: .3rem;
  font-size: clamp(.8rem, 1.2vw, 1.5rem);
  font-weight: 250;
  transition: all .5s ease;
}

.nav-link h1:hover {
  font-size: clamp(.9rem, 1.2vw, 1.25rem);
  font-weight: 500;
  text-shadow: 0 0 5vw rgba(255, 255, 255, 1);
}

.social-icons { display: flex; gap: 1vw; }

.social-icons i {
  color: var(--black);
  padding: 1vw;
  transition: all .5s ease;
  font-size: clamp(.8rem, 1.5vw, 1.2rem);
}

.social-icons i:hover {
  text-shadow: 0 0 5vw rgba(255, 255, 255, 1);
  font-size: clamp(1rem, 2vw, 1.5rem);
  filter: drop-shadow(0 0 1px rgba(0, 0, 0, .7));
}

.download-btn {
  display: inline-block;
  padding: clamp(.4rem, 1vw, .8rem) clamp(1rem, 2vw, 1.5rem);
  font-family: 'Oswald', sans-serif;
  font-size: .8rem;
  font-weight: 500;
  color: #fff;
  background: #000;
  border: none;
  border-radius: 5px;
  transition: .3s ease;
  white-space: nowrap;
}

.download-btn:hover {
  background: #444;
  transform: scale(1.05);
  box-shadow: 0 0 15px rgba(0, 0, 0, .4);
}

.fade-in {
  opacity: 0;
  animation: fadeIn 1.2s ease forwards;
  animation-delay: var(--delay, 0s);
}

@keyframes fadeIn {
  from { opacity: 0 }
  to { opacity: 1 }
}

/* ============== VIEWER SHELL ============== */
.viewer-shell {
  height: calc(100dvh - var(--header-h));
  background: linear-gradient(180deg, #f7f9fc, #eef1f6);
  display: grid;
  grid-template-rows: var(--toolbar-h) 1fr;
  position: relative;
  overflow: hidden;
}

/* ================= TOOLBAR ================= */
.toolbar {
  display: flex;
  align-items: center;
  gap: .6rem;
  padding: 0 .9rem;
  padding-left: calc(.9rem + 104px);
  background: rgba(255, 255, 255, .85);
  backdrop-filter: blur(6px);
  border-bottom: 1px solid var(--stroke);
  position: sticky;
  top: 0;
  z-index: 7;
  min-height: var(--toolbar-h);
  flex-wrap: nowrap;
  overflow-x: auto;
  white-space: nowrap;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
}

.toolbar .group {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex: 0 0 auto;
}

.toolbar .spacer { flex: 1 }

.toolbar::-webkit-scrollbar { height: 6px; }
.toolbar::-webkit-scrollbar-thumb { background: #cfd5df; border-radius: 4px; }
.toolbar::-webkit-scrollbar-track { background: transparent; }

.btn, .select {
  height: 38px;
  border: 1px solid var(--stroke);
  background: #fff;
  color: #000;
  border-radius: 12px;
  padding: 0 .75rem;
  font: 300 12px/1 'Montserrat', sans-serif;
  letter-spacing: .06em;
  cursor: pointer;
  transition: .2s ease;
  touch-action: manipulation;
  flex: 0 0 auto;
  white-space: nowrap;
}

.btn:hover {
  transform: scale(1.05);
  filter: drop-shadow(0 0 2px rgba(0, 0, 0, .35));
}

.btn.is-active {
  background: #000;
  color: #fff;
  border-color: #000;
}

.label {
  min-width: 68px;
  text-align: center;
  font: 500 12px/1 'Oswald', sans-serif;
  letter-spacing: .08rem;
}

/* LEFT DOCK */
.left-dock {
  position: absolute;
  left: 8px;
  top: 50%;
  transform: translateX(-70px) translateY(-50%);
  display: flex;
  gap: .4rem;
  z-index: 9;
  transition: transform .25s ease, opacity .25s ease;
  opacity: .75;
  pointer-events: auto;
}

.left-dock,
.left-dock:hover,
body.dock-open .left-dock {
  transform: translateX(0) translateY(-50%);
  opacity: 1;
}

/* ================= LEFT PANELS ================= */
.side-panel {
  position: absolute;
  left: 0;
  top: var(--toolbar-h);
  bottom: 0;
  width: var(--outline-w);
  background: rgba(255, 255, 255, .70);
  border-right: 1px solid var(--stroke);
  box-shadow: 0 10px 30px rgba(0, 0, 0, .08);
  transform: translateX(-105%);
  opacity: 0;
  pointer-events: none;
  max-width: 10vw;
  z-index: 6;
  overflow: auto;
}

.side-panel.open {
  transform: translateX(0);
  transition: transform .25s ease, opacity .25s ease;
  opacity: 1;
  width: 30vw;
  pointer-events: auto;
}

.panel-title {
  position: sticky;
  top: 0;
  background: #fff;
  padding: 10px 12px;
  border-bottom: 1px solid var(--stroke);
  font: 600 12px/1 'Oswald', sans-serif;
  letter-spacing: .06em;
  z-index: 1;
}

/* Thumbnails */
#thumbs {
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.thumb {
  position: relative;
  border: 1px solid var(--stroke);
  border-radius: 12px;
  background: #fff;
  padding: 8px;
  cursor: pointer;
  transition: transform .15s ease, box-shadow .15s ease;
}

.thumb:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 16px rgba(0, 0, 0, .12);
}

.thumb canvas {
  width: 100%;
  height: auto;
  display: block;
  border-radius: 10px;
}

.thumb .num {
  position: absolute;
  left: 10px;
  bottom: 10px;
  font: 600 10px/1 'Oswald', sans-serif;
  background: #000;
  color: #fff;
  padding: 3px 6px;
  border-radius: 6px;
  opacity: .9;
}

.thumb.active { outline: 2px solid #000; }

/* Outline */
#outlineList {
  list-style: none;
  margin: 0;
  padding: 8px 10px 20px;
}

#outlineList li { margin: 2px 0; }

#outlineList a {
  display: block;
  padding: 6px 8px;
  border-radius: 8px;
  text-decoration: none;
  color: #0e0f12;
  font-size: .55rem;
  line-height: 1.2;
}

#outlineList a:hover { background: rgba(0, 0, 0, .08); }

#outlineList .lvl-1 { padding-left: 8px }
#outlineList .lvl-2 { padding-left: 24px }
#outlineList .lvl-3 { padding-left: 40px }
#outlineList .lvl-4 { padding-left: 56px }

/* ================= VIEWER ================= */
.viewer {
  position: relative;
  overflow: hidden;
}

#stage {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%) scale(1);
  transform-origin: 50% 50%;
  will-change: transform;
  touch-action: none;
}

.spread {
  position: relative;
  display: flex;
  gap: 0;
  width: fit-content;
  height: fit-content;
  box-shadow: 0 16px 40px rgba(0, 0, 0, .12), 0 2px 8px rgba(0, 0, 0, .06);
  background: #fff;
}

body.is-panning .spread { box-shadow: none; }

.subpage {
  position: relative;
  width: fit-content;
  height: fit-content;
}

canvas {
  display: block;
  background: #fff;
}

.annLayer {
  position: absolute;
  inset: 0;
  pointer-events: auto;
}

.pdf-link {
  position: absolute;
  border-radius: 4px;
  transition: .15s ease;
  display: block;
}

.pdf-link:hover {
  box-shadow: 0 0 0 1px rgba(3, 227, 252, .7);
  transform: scale(1.05);
  filter: drop-shadow(0 0 2px rgba(3, 227, 252, 1));
}

.hint {
  position: absolute;
  right: 12px;
  bottom: 12px;
  background: #000c;
  color: #fff;
  padding: 6px 10px;
  border-radius: 8px;
  font-size: 12px;
  user-select: none;
  z-index: 1;
}

/* Edge nav */
.edge-nav {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 5;
}

.edge-btn {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  pointer-events: auto;
  width: 44px;
  height: 72px;
  border: none;
  border-radius: 10px;
  background: rgba(255, 255, 255, .9);
  backdrop-filter: blur(6px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, .12);
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: transform .15s ease, box-shadow .15s ease, background .15s ease;
}

.edge-btn:hover {
  transform: translateY(-50%) scale(1.03);
  box-shadow: 0 10px 28px rgba(0, 0, 0, .16);
}

.edge-btn i { font-size: 18px; }
.edge-btn.left { left: 12px; }
.edge-btn.right { right: 12px; }

@media (max-width:1024px) {
  :root { --outline-w: 240px; }
  .btn, .select { height: 36px; }
  .edge-btn { width: 40px; height: 64px; }
  .toolbar .spacer { display: none; }
}

@media (max-width:768px) {
  :root {
    --toolbar-h: 56px;
    --outline-w: 78vw;
  }

  .toolbar {
    gap: .5rem;
    padding: .5rem;
    padding-left: calc(.5rem + 104px);
  }

  .label { min-width: auto; }
  #zoomLbl { display: none; }
  .edge-btn, .hint { display: none; }

  .btn, .select {
    height: 34px;
    border-radius: 10px;
    padding: 0 .6rem;
    font-size: 12px;
  }

  .left-dock {
    transform: translateX(0) translateY(-50%);
    opacity: 1;
  }
}

@media (max-width:480px) {
  .toolbar { justify-content: space-between; }
  .toolbar .group:nth-child(4) { display: none; }
  #preset { display: none; }
}
