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

:root {
  --bg: #1a1a1a;
  --surface: #242424;
  --border: #333;
  --text: #e8e8e8;
  --text-muted: #888;
  --accent: #4a9eff;
}

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 14px;
}

/* ── Index Panel ── */
#index-btn {
  position: fixed;
  top: 16px;
  left: 16px;
  z-index: 100;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 6px 10px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: background 0.15s;
}

#index-btn:hover {
  background: #2e2e2e;
}

#index-panel {
  position: fixed;
  top: 0;
  left: 0;
  width: 300px;
  height: 100%;
  background: var(--surface);
  border-right: 1px solid var(--border);
  z-index: 90;
  overflow-y: auto;
  transform: translateX(-100%);
  transition: transform 0.2s ease;
  padding: 60px 0 16px;
}

#index-panel.open {
  transform: translateX(0);
}

#index-panel h2 {
  padding: 0 16px 12px;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  margin-bottom: 8px;
}

.tree-dir {
  padding: 5px 0;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
}

.tree-leaf {
  display: block;
  padding: 7px 12px 7px 0;
  color: var(--text);
  text-decoration: none;
  font-size: 13px;
  line-height: 1.4;
  transition: background 0.1s;
  border-radius: 4px;
}

.tree-leaf:hover {
  background: rgba(255,255,255,0.05);
}

.tree-leaf .item-date {
  display: block;
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
}

#overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 80;
}

#overlay.open {
  display: block;
}

/* ── Home page ── */
#home {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  gap: 12px;
}

#home h1 {
  font-size: 22px;
  font-weight: 500;
  color: var(--text-muted);
}

#home-note {
  font-size: 13px;
  color: #c86;
  min-height: 1em;
}

#home-note:empty {
  display: none;
}

/* ── Viewer ── */
#viewer {
  display: none;
  flex-direction: column;
  height: 100vh;
}

#viewer.active {
  display: flex;
}

#canvas-container {
  flex: 1;
  min-height: 0;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: default;
  background: #111;
  position: relative;
}

#canvas-container.laser-on {
  cursor: none;
}

/* ── Nav arrows ── */
.nav-arrow {
  position: fixed;
  width: 80px;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.15s;
  pointer-events: none;
  z-index: 10;
}

#nav-prev {
  background: linear-gradient(to right, rgba(0,0,0,0.45) 0%, transparent 100%);
  justify-content: flex-start;
  padding-left: 14px;
}

#nav-next {
  background: linear-gradient(to left, rgba(0,0,0,0.45) 0%, transparent 100%);
  justify-content: flex-end;
  padding-right: 14px;
}

.nav-arrow.visible {
  opacity: 1;
}

#pdf-canvas {
  display: block;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  user-select: none;
}

/* ── Laser pointer ── */
#laser {
  position: fixed;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: rgba(255, 40, 40, 0.85);
  box-shadow: 0 0 8px 3px rgba(255, 60, 60, 0.5);
  pointer-events: none;
  z-index: 200;
  transform: translate(-50%, -50%);
  display: none;
}

#laser.active {
  display: block;
}

/* ── Controls bar ── */
#controls {
  flex-shrink: 0;
  height: 44px;
  background: rgba(20, 20, 20, 0.9);
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  z-index: 50;
  backdrop-filter: blur(8px);
}

.ctrl-btn {
  background: none;
  border: none;
  color: var(--text);
  padding: 6px 10px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 14px;
  transition: background 0.1s;
}

.ctrl-btn:hover {
  background: rgba(255,255,255,0.08);
}

.ctrl-btn:disabled {
  color: var(--text-muted);
  cursor: default;
}

#page-info {
  font-size: 12px;
  color: var(--text-muted);
  min-width: 64px;
  text-align: center;
}

#laser-btn.on {
  color: #ff4444;
}

#download-btn {
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 6px;
}

/* ── Loading ── */
#loading {
  position: fixed;
  inset: 0;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 300;
  font-size: 13px;
  color: var(--text-muted);
}

#loading.hidden {
  display: none;
}
