#palette-container {
  padding: 0; /* Remove padding from container */
  display: flex;
  flex-direction: column;
  overflow: hidden;
  height: 100%;
  position: relative; /* Add relative positioning for the collapse button */
}
#palette-filters-container {
    padding: 16px;
    border-bottom: 1px solid var(--border-color);
    flex-shrink: 0;
}
#palette-tiles {
    padding: 16px;
    overflow-y: auto;
    flex-grow: 1;
    /* The button is no longer a child, so no relative needed here */
}

.palette-section{ 
  margin-bottom:8px; 
  border:1px solid var(--border-color); 
  border-radius:8px; 
  overflow:hidden; 
}
.section-header{ 
  display:flex; 
  align-items:center; 
  justify-content:space-between; 
  padding:8px 12px; 
  cursor:pointer; 
  background: var(--bg); 
  border-bottom:1px solid var(--border-color); 
}
.palette-section.open .section-header{ 
  border-bottom-color: var(--border-color-strong); 
}
.section-header h3{ 
  margin:0; 
  font-size:13px; 
  font-weight:600; 
  color:var(--fg); 
  text-transform:none; 
  letter-spacing:.2px; 
}
.section-header .chevron{ 
  width:16px; 
  height:16px; 
  transition:transform .2s ease; 
  transform: rotate(-90deg);
}
.palette-section.open .section-header .chevron{ 
  transform:rotate(0deg); 
}

.tile-grid{ 
  display:none; 
  grid-template-columns:repeat(auto-fill, minmax(64px, 1fr)); 
  gap:6px; 
  padding:12px; 
  background:var(--bg-offset); 
}
.palette-section.open .tile-grid { 
  display: grid; 
}

.tile-btn{ 
  position: relative; 
  border:1px solid var(--border-color); 
  border-radius:6px; 
  padding:4px; 
  background:var(--bg-offset); 
  cursor:pointer; 
  display:flex; 
  align-items:center; 
  justify-content:center; 
  height:72px; 
  transition:all .12s ease; 
}
.tile-btn img{ 
  max-width:100%; 
  max-height:100%; 
  image-rendering:pixelated; 
}
.tile-btn:hover{ 
  background:var(--bg-inset); 
  border-color:var(--fg-subtle); 
}
.tile-btn.active{ 
  border-color:var(--fg); 
  background:var(--bg-inset); 
  box-shadow:0 0 0 2px var(--fg) inset; 
}

.tile-btn.tool-btn {
    flex-direction: column;
    gap: 4px;
    font-size: 11px;
    font-weight: 500;
}
.tile-btn.tool-btn .tool-icon {
    font-size: 16px;
}

.rotation-indicator {
  position: absolute;
  top: 2px;
  right: 4px;
  font-size: 14px;
  color: var(--fg);
  opacity: 0.6;
  text-shadow: 0 0 2px white;
}
.debug-info {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  font-size: 8px;
  color: var(--fg-muted);
  background: rgba(255, 255, 255, 0.8);
  padding: 1px 2px;
  text-align: center; 
}

.badge{ 
  display:block; 
  padding:6px 8px; 
  border:1px solid var(--border-color); 
  border-radius:6px; 
  font-size:11px; 
  color:var(--fg-muted); 
  margin:8px 0; 
  text-align:center; 
}

#collapse-all-btn {
  position: absolute; /* Changed from sticky to absolute */
  top: 16px;
  right: 16px;
  z-index: 10;
  padding: 6px;
  font-size: 11px;
  width: 38px;
  height: 30px;
  border-radius: 6px;
  background: var(--bg-inset);
  border: 1px solid var(--border-color);
  margin-bottom: 0;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  /* margin-left is not needed with absolute positioning */
}
#collapse-all-btn:hover {
  border-color: var(--border-color-strong);
}

.filter-section {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
#search-filter-panel {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 8px;
}
.filter-controls {
  display: flex;
  justify-content: space-between;
  gap: 8px;
}
.filter-controls button {
  padding: 4px 8px;
  font-size: 12px;
  background: var(--bg);
  border: 1px solid var(--border-color-strong);
  border-radius: 4px;
}
.expand-collapse-controls {
  display: flex;
  gap: 4px;
}

.search-input {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--border-color-strong);
  border-radius: 6px;
  font-size: 14px;
  background-color: var(--button-bg);
  color: var(--button-fg);
}
.advanced-filters {
  padding: 8px;
  background: var(--bg-inset);
  border-radius: 6px;
  border: 1px solid var(--border-color);
}
.tag-filters { 
  display: flex; 
  flex-wrap: wrap; 
  gap: 4px; 
}
.tag-btn {
  padding: 4px 8px;
  border: 1px solid var(--border-color-strong);
  border-radius: 4px;
  background: white;
  font-size: 12px;
  cursor: pointer;
  transition: all 0.12s ease;
}
.tag-btn:hover { 
  background: var(--bg-inset); 
}
.tag-btn.active { 
  background: var(--fg); 
  color: var(--bg-offset); 
  border-color: var(--fg); 
}