body {
  display: flex;
  flex-direction: column;
  align-items: center; /* Center the whole container */
  font-family: sans-serif;
  margin: 20px;
  background-color: #f0f0f0; /* Lighter page background */
}

/* --- Original .main-container ---
.main-container {
  display: flex;
  gap: 20px;
  width: 100%;
  max-width: 900px;
  align-items: flex-start;
}
*/

h2 {
  margin: 5rem auto .5rem; 
}

.main-container {
  display: flex;
  flex-direction: column; /* Stack top-row and svg-drawer vertically */
  margin: 1rem auto 1.25rem; 
  gap: 20px; /* Space between top-row and svg-drawer */
  width: 100%;
  max-width: 1000px; /* Optional: Increase max width if desired */
  /* align-items: flex-start; */ /* Remove or change if needed */
  /* align-items: center; */ /* Center items horizontally if max-width is reached */
}

/* --- Style for the top row container --- */
.top-row {
  display: flex;
  gap: 20px; /* Space between left panel and canvas area */
  width: 100%; /* Take full width of main-container */
  align-items: flex-start; /* Align tops of left panel and canvas area */
}

.left-panel {
  display: flex;
  flex-direction: column;
  gap: 15px; /* Space between sections in left panel */
  width: 250px; /* Fixed width for the left panel */
  flex-shrink: 0; /* Prevent shrinking */
}

.center-panel {
  flex-grow: 1; /* Allow canvas area to take space */
  display: flex; /* To center canvas if needed */
  justify-content: center; /* Center canvas horizontally */
}

/* --- NEW Rule for the Layers Panel --- */
.right-panel {
  display: flex;
  flex-direction: column;
  gap: 15px; /* In case you add more sections later */
  width: 200px; /* Adjust width as desired for layers */
  flex-shrink: 0; /* Prevent shrinking */
}

.controls-section,
.layer-controls,
.svg-drawer {
  border: 1px solid #ccc;
  border-radius: 5px;
  padding: 10px;
  background-color: #fff;
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.controls-section h3,
.layer-controls h3,
.svg-drawer h3 {
  margin: 0 0 10px 0;
  font-size: 1rem;
  text-align: center;
  border-bottom: 1px solid #eee;
  padding-bottom: 5px;
}

.controls {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 12px; /* Row and column gap */
  align-items: center;
}
.controls label {
  font-size: 0.9rem;
  display: inline-flex; /* Align label and input nicely */
  align-items: center;
  gap: 4px;
}
.controls input[type="color"] {
    width: 30px;
    height: 20px;
    padding: 0;
    border: 1px solid #ccc;
    vertical-align: middle;
}
.controls input,
.controls select,
.controls button {
  /* margin-left: 4px; */ /* Replaced by gap */
  padding: 4px 6px;
  font-size: 0.9rem;
}
.controls input[type="file"] {
    font-size: 0.8rem;
}
.controls button {
    cursor: pointer;
}

.animation-controls {
  /* Add any specific styles for the animation section if needed */
}
#frameInfo {
    /* Styles for the frame counter text */
    white-space: nowrap; /* Prevent wrapping */
    flex-shrink: 0; /* Prevent shrinking if space is tight */
}
#layerList {
  /* width: 100%; */ /* Takes width from parent */
  max-height: 180px; /* Slightly smaller */
  overflow-y: auto;
  border: 1px solid #eee; /* Lighter border */
  padding: 5px;
  margin-top: 5px;
}
.layer-item {
  display: flex;
  align-items: center;
  gap: 3px; /* Smaller gap */
  margin: 2px 0;
  font-size: 0.85rem; /* Slightly smaller text */
}
.layer-item span {
  flex-grow: 1;
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  padding: 2px;
}
.layer-item span:hover {
    background-color: #f0f0f0;
}
.layer-item button {
    padding: 1px 4px; /* Smaller buttons */
    font-size: 0.75rem;
    line-height: 1;
    cursor: pointer;
    flex-shrink: 0; /* Prevent buttons shrinking */
}

/* --- NEW Styles for Thumbnails --- */
#frameThumbnailsContainer {
  margin-top: 10px; /* Space above thumbnails */
  border: 1px solid #eee;
  border-radius: 3px;
  background-color: #f9f9f9;
  flex-grow: 1; /* Allow container to fill remaining space */
  min-height: 50px; /* Ensure it has some height even when empty */
  overflow: hidden; /* Hide direct overflow, use inner div for scroll */
  display: flex; /* Needed for flex-grow */
}

#frameThumbnails {
  padding: 5px; /* Padding inside the scroll area */
  display: flex;
  flex-wrap: wrap; /* Allow thumbnails to wrap */
  gap: 6px; /* Space between thumbnails */
  overflow-y: auto; /* Enable vertical scrolling */
  width: 100%; /* Take full width of container */
  align-content: flex-start; /* Align wrapped lines to the top */
}

.frame-thumbnail {
  width: 60px; /* Thumbnail width */
  height: 36px; /* Thumbnail height (maintain aspect ratio ~480x320) */
  object-fit: contain; /* Fit image within bounds, keep aspect ratio */
  border: 2px solid #ccc;
  border-radius: 2px;
  cursor: pointer;
  background-color: #fff; /* White background behind transparent parts */
  transition: border-color 0.2s ease; /* Smooth transition for highlight */
}

.frame-thumbnail:hover {
  border-color: #888;
}

.frame-thumbnail.active {
  border-color: #007bff; /* Highlight color for active frame */
  box-shadow: 0 0 3px rgba(0, 123, 255, 0.5);
}

#canvas {
  border: 1px solid #888; /* Darker canvas border */
  display: block; /* Remove potential extra space below */
  background-color: #fff; /* Ensure canvas bg is white */
  touch-action: none;
  box-shadow: 0 2px 5px rgba(0,0,0,0.2); /* Add shadow to canvas */
}

.controls button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* --- SVG Drawer Styling --- */
.svg-drawer {
  /* It inherits border, padding etc from the shared rule */
  width: 100%; /* Make it span the full width of main-container */
  box-sizing: border-box; /* Include padding/border in the 100% width */
}

/* You might want to adjust the height/scroll panel inside
#svgPanel {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  max-height: 250px;
  overflow-y: auto;
  padding: 5px;
  border: 1px solid #eee;
  border-radius: 3px;
}
*/

#svgPanel {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  max-height: 300px; /* Limit height and enable scroll */
  overflow-y: auto;
  padding: 5px; /* Padding inside the scroll area */
  border: 1px solid #eee;
  border-radius: 3px;
}

.svg-section {
  border: 1px solid #ddd; /* Lighter border for each section */
  border-radius: 4px;
  padding: 6px;
  /* width: 100px; */ /* Let flexbox decide width based on content/panel */
  background: #f9f9f9;
  text-align: center; /* Center title */
    /* --- NEW: Apply flexbox HERE to arrange children (h4 and images) --- */
  display: flex;
  flex-wrap: wrap; /* Allow images to wrap below the title */
  gap: 6px; /* Space between images AND between title row / image row */
  align-items: center; /* Align items vertically in the center of a 'line' */
}
.svg-section h4 {
  margin: 0 0 6px;
  font-size: 0.8rem; /* Smaller title */
  font-weight: normal;
  color: #555;
}

.svg-section img {
  display: block; /* Ensure block display */
  margin: 0 auto 4px; /* Center horizontally */
  width: 70px;   /* Set a fixed small width */
  height: 70px;  /* Set a fixed small height */
  object-fit: contain; /* Ensure aspect ratio is maintained within bounds */
  cursor: pointer;
  border: 1px solid transparent; /* Placeholder for hover effect */
  border-radius: 3px;
  padding: 2px; /* Add padding around image */
  background-color: #fff; /* White background for the image */

  object-fit: contain;
  cursor: pointer;
  border: 1px solid transparent;
  border-radius: 3px;
  padding: 2px;
  background-color: #fff;

  /* Removed display: block and margin: auto */
  /* Flexbox handles alignment and spacing via 'gap' */
}

.svg-section img:hover {
    border-color: #aaa; /* Highlight border on hover */
    background-color: #eef; /* Slight background tint on hover */
}
