* { box-sizing: border-box; }
body { font-family: 'Inter', system-ui, -apple-system, sans-serif; }

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-8px); }
  60% { transform: translateX(8px); }
  80% { transform: translateX(-4px); }
}
.shake { animation: shake 0.3s ease; }

.line-clamp-2 {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* ── Thumbnail cards ── */
.thumbnail-card {
  position: relative;
  cursor: pointer;
  border-radius: 0.75rem;
  overflow: hidden;
  border: 2.5px solid transparent;
  transition: all 0.15s;
  background: white;
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}
.thumbnail-card:hover {
  border-color: #bfdbfe;
  box-shadow: 0 4px 14px rgba(0,0,0,0.15);
  transform: translateY(-2px);
}
.thumbnail-card.selected {
  border-color: #3b82f6;
  box-shadow: 0 0 0 3px rgba(59,130,246,0.25);
}
.thumbnail-card .check-badge {
  position: absolute;
  top: 7px;
  right: 7px;
  width: 22px;
  height: 22px;
  background: #3b82f6;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.15s;
  box-shadow: 0 1px 4px rgba(0,0,0,0.25);
  z-index: 2;
}
.thumbnail-card:hover .check-badge,
.thumbnail-card.selected .check-badge { opacity: 1; }
.thumbnail-card.selected .check-badge { background: #3b82f6; }
.thumbnail-card:hover:not(.selected) .check-badge { background: #93c5fd; }

/* ── Page modal ── */
#page-modal { transition: opacity 0.2s ease; }
#page-modal.hidden { display: none; }
#modal-canvas-wrap {
  overflow: auto;
  display: flex;
  align-items: flex-start;
  justify-content: center;
}

/* ── History sidebar ── */
#history-sidebar {
  width: 280px;
  flex-shrink: 0;
}
.history-item {
  cursor: pointer;
  border-radius: 0.75rem;
  border: 1.5px solid #e2e8f0;
  transition: all 0.15s;
}
.history-item:hover { border-color: #bfdbfe; background: #f0f7ff; }
.history-item.active { border-color: #3b82f6; background: #eff6ff; }

/* ── Spinner ── */
@keyframes spin { to { transform: rotate(360deg); } }
.spin { animation: spin 0.8s linear infinite; }

/* ── Thumbnail zoom button ── */
.thumbnail-card .zoom-btn {
  position: absolute;
  top: 7px;
  left: 7px;
  width: 26px;
  height: 26px;
  background: rgba(0, 0, 0, 0.55);
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.15s;
  z-index: 2;
  cursor: pointer;
  border: none;
  padding: 0;
  backdrop-filter: blur(2px);
}
.thumbnail-card:hover .zoom-btn { opacity: 1; }
.thumbnail-card .zoom-btn:hover { background: rgba(0, 0, 0, 0.8); }

/* ── Pages collapsible transition ── */
#pages-collapsible {
  overflow: hidden;
  transition: opacity 0.2s ease;
}
#pages-collapsible.hidden { display: none; }
