#cg-app {
  display: grid;
  grid-template-columns: 280px 1fr;
  height: 100vh;
  min-height: 0;
  overflow: hidden;
  background: #efe8f7;
  color: #2e1064;
  font-family: 'Inter', system-ui, sans-serif;
}
#cg-sidebar {
  background: #f7f2fc;
  border-right: 1px solid #ddd0ee;
  overflow-y: auto;
  padding: 16px;
  min-height: 0;
}
#cg-sidebar .brand h1 { font-size: 1.25rem; font-weight: 800; }
#cg-sidebar .tagline { font-size: 0.78rem; color: #6b21a8; margin-bottom: 14px; }
#cg-sidebar label, #cg-sidebar h2 {
  font-size: 0.72rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; color: #6b21a8;
}
#cg-sidebar input, #cg-sidebar select {
  width: 100%; margin: 6px 0 12px; padding: 8px 10px; border: 1px solid #ddd0ee; border-radius: 7px;
}
#cg-sidebar .btn {
  padding: 10px 12px; border: none; border-radius: 8px; font-weight: 600; cursor: pointer; width: 100%; margin-bottom: 8px;
}
#cg-sidebar .btn.primary { background: #7c3aed; color: #fff; }
#cg-sidebar .btn.success { background: #0f766e; color: #fff; }
#cg-sidebar .btn.secondary { background: #ede9fe; color: #2e1064; border: 1px solid #ddd0ee; }
#cg-sidebar .hint { font-size: 0.75rem; color: #6b21a8; margin: 6px 0; }
#cg-sidebar .checkbox { display: flex; align-items: center; gap: 8px; margin: 4px 0 18px; }
#cg-sidebar .panel + .panel { margin-top: 8px; }

#cg-main { display: flex; flex-direction: column; min-height: 0; overflow: hidden; }
.cg-stage {
  flex: 1; min-height: 0; overflow: auto;
  display: flex; justify-content: center; align-items: flex-start;
  padding: 20px; background: #d8cce8;
}
.cg-sheet {
  background: #fff;
  box-shadow: 0 12px 40px rgba(46,16,100,0.18);
  display: flex; flex-direction: column;
  overflow: hidden;
}
.cg-sheet.portrait { width: min(560px, 92%); aspect-ratio: 210/297; }
.cg-sheet.landscape { width: min(780px, 96%); aspect-ratio: 297/210; }
.cg-inner { display: flex; flex-direction: column; height: 100%; padding: 14px; box-sizing: border-box; }
.cg-head { text-align: center; margin-bottom: 8px; }
.cg-head h1 { font-size: 1.15rem; letter-spacing: 0.04em; }
.cg-grid {
  flex: 1; min-height: 0;
  display: grid;
  gap: 8px;
}
.cg-cell {
  position: relative;
  overflow: hidden;
  background: #f3e8ff;
  border: 1px solid #ddd0ee;
  border-radius: 6px;
}
.cg-cell img {
  width: 100%; height: 100%;
  object-fit: cover;
  display: block;
  cursor: move;
  touch-action: none;
  transform-origin: center center;
  will-change: transform;
}
.cg-cell img.panning { cursor: grabbing; }

.cg-empty {
  flex: 1; display: flex; align-items: center; justify-content: center;
  color: #7c3aed; border: 2px dashed #c4b5fd; border-radius: 10px;
}
@media print {
  body * { visibility: hidden !important; }
  #cgSheet, #cgSheet * { visibility: visible !important; }
  #cgSheet {
    position: absolute; left: 0; top: 0; width: 210mm !important; height: 297mm !important;
    box-shadow: none !important; aspect-ratio: auto !important;
  }
  #cg-app .cg-sheet.landscape { width: 297mm !important; height: 210mm !important; }
}
