/* Global layout fix: lock body to viewport to enable independent panel scrolling */
html, body {
  height: 100%;
  max-height: 100vh;
  margin: 0;
  padding: 0;
  overflow: hidden;
}

header.app-header {
  height: 61px;
  flex-shrink: 0;
}

main.main-workspace {
  height: calc(100vh - 61px);
  max-height: calc(100vh - 61px);
  min-height: 0;
  flex: 1 1 0%;
  display: flex;
  overflow: hidden;
  position: relative;
}

/* Sidebar scroll independently */
#controlsPanel {
  height: 100% !important;
  max-height: 100% !important;
  min-height: 0 !important;
  overflow-y: auto !important;
  flex-shrink: 0;
}

/* Preview panel scroll independently both horizontally and vertically */
#previewPanel {
  flex: 1 1 0% !important;
  height: 100% !important;
  max-height: 100% !important;
  min-height: 0 !important;
  min-width: 0 !important;
  overflow-y: auto !important;
  overflow-x: auto !important;
  -webkit-overflow-scrolling: touch;
  scroll-behavior: smooth;
  position: relative !important;
}

/* Inner preview wrapper: centers canvas when small, allows natural scroll when zoomed */
.preview-inner-wrapper {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-height: 100%;
  width: 100%;
  max-width: 100%;
  margin: 0 auto;
  padding: 0.75rem 0.5rem 8rem 0.5rem;
  box-sizing: border-box;
}

@media (min-width: 640px) {
  .preview-inner-wrapper {
    width: max-content;
    min-width: 100%;
    padding: 1.25rem 1.5rem 8rem 1.5rem;
  }
}

/* Custom Scrollbar for controls sidebar */
.custom-scrollbar::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

.custom-scrollbar::-webkit-scrollbar-track {
  background: rgba(241, 245, 249, 0.8);
}

.custom-scrollbar::-webkit-scrollbar-thumb {
  background: rgba(148, 163, 184, 0.6);
  border-radius: 9999px;
}

.custom-scrollbar::-webkit-scrollbar-thumb:hover {
  background: rgba(100, 116, 139, 0.9);
}

/* Enhanced high-contrast scrollbar for Preview Panel */
#previewPanel::-webkit-scrollbar {
  width: 12px;
  height: 12px;
}

#previewPanel::-webkit-scrollbar-track {
  background: rgba(203, 213, 225, 0.6);
  border-radius: 8px;
}

#previewPanel::-webkit-scrollbar-thumb {
  background: #64748b;
  border: 2px solid rgba(241, 245, 249, 0.9);
  border-radius: 8px;
}

#previewPanel::-webkit-scrollbar-thumb:hover {
  background: #334155;
}

#previewPanel {
  scrollbar-width: thin;
  scrollbar-color: #64748b rgba(203, 213, 225, 0.6);
}

/* Custom range slider aesthetics */
input[type=range] {
  height: 5px;
  background: #e2e8f0;
  border-radius: 4px;
  outline: none;
}

input[type=range]::-webkit-slider-thumb {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #2563eb;
  cursor: pointer;
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
  transition: transform 0.1s ease;
}

input[type=range]::-webkit-slider-thumb:hover {
  transform: scale(1.2);
}

/* Preset button states */
.font-preset-btn.active,
.paper-preset-btn.active,
.camera-filter-btn.active {
  border-color: #2563eb;
  background-color: #eff6ff;
  color: #1d4ed8;
  box-shadow: 0 0 0 1px #2563eb;
}

/* Ink color selected ring */
.ink-btn.active {
  ring-width: 2px;
  ring-color: #2563eb;
  transform: scale(1.1);
}

/* Canvas viewport - allow full dimensions for natural scrolling during zoom */
#canvasViewport {
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.15), 0 8px 10px -6px rgba(0, 0, 0, 0.1);
}

/* Studio Character Selector Grid Buttons */
.studio-char-btn {
  aspect-ratio: 1 / 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  border: 1px solid #e2e8f0;
  background-color: #ffffff;
  font-family: monospace;
  font-size: 14px;
  font-weight: 600;
  color: #334155;
  cursor: pointer;
  position: relative;
  transition: all 0.15s ease;
}

.studio-char-btn:hover {
  border-color: #93c5fd;
  background-color: #f8fafc;
}

.studio-char-btn.active {
  border-color: #2563eb;
  background-color: #eff6ff;
  color: #1d4ed8;
  box-shadow: 0 0 0 2px #bfdbfe;
}

.studio-char-btn.has-glyph::after {
  content: '';
  position: absolute;
  top: 3px;
  right: 3px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background-color: #10b981;
}

.studio-cat-btn.active {
  background-color: #ffffff;
  color: #1d4ed8;
  font-weight: 600;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

/* Multi-page continuous document styling (Word/Docs style) */
.page-card {
  transition: transform 0.15s ease;
}

.page-viewport {
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.15), 0 8px 10px -6px rgba(0, 0, 0, 0.1);
  background-color: #ffffff;
  border-radius: 2px;
}

.page-jump-pill {
  padding: 0.25rem 0.625rem;
  border-radius: 0.375rem;
  font-size: 11px;
  font-weight: 600;
  border: 1px solid #e2e8f0;
  background-color: #ffffff;
  color: #475569;
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
}

.page-jump-pill:hover {
  background-color: #eff6ff;
  border-color: #93c5fd;
  color: #1d4ed8;
}

.page-jump-pill.active {
  background-color: #2563eb;
  border-color: #2563eb;
  color: #ffffff;
  box-shadow: 0 1px 2px rgba(37, 99, 235, 0.2);
}

/* Custom Interactive Tooltip Styling */
.custom-tooltip-wrap {
  position: relative;
  display: inline-flex;
  align-items: center;
}

.custom-tooltip-wrap .tooltip-trigger {
  background: none;
  border: none;
  padding: 1px 3px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #94a3b8;
  border-radius: 9999px;
  transition: color 0.15s ease;
}

.custom-tooltip-wrap .tooltip-trigger:hover,
.custom-tooltip-wrap .tooltip-trigger:focus,
.custom-tooltip-wrap.active .tooltip-trigger {
  color: #2563eb;
}

.custom-tooltip-wrap .custom-tooltip-popup {
  position: absolute;
  bottom: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%) translateY(4px);
  width: 220px;
  max-width: 80vw;
  padding: 8px 10px;
  background: rgba(15, 23, 42, 0.97);
  color: #f8fafc;
  font-size: 11px;
  font-weight: 400;
  line-height: 1.4;
  border-radius: 8px;
  box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.35), 0 8px 10px -6px rgba(0, 0, 0, 0.2);
  border: 1px solid rgba(255, 255, 255, 0.12);
  pointer-events: none;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.15s ease, transform 0.15s ease, visibility 0.15s ease;
  z-index: 100;
  text-align: left;
}

/* Tooltip Arrow */
.custom-tooltip-wrap .custom-tooltip-popup::after {
  content: '';
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  border-width: 5px;
  border-style: solid;
  border-color: rgba(15, 23, 42, 0.97) transparent transparent transparent;
}

/* Show on Hover, Focus-Within, or when Active */
.custom-tooltip-wrap:hover .custom-tooltip-popup,
.custom-tooltip-wrap:focus-within .custom-tooltip-popup,
.custom-tooltip-wrap.active .custom-tooltip-popup {
  opacity: 1;
  visibility: visible;
  transform: translateX(-50%) translateY(0);
}


