html, body {
  height: 100%;
  margin: 0;
  font-family: sans-serif;
  background: #111;
  color: #eee;
}
body {
  display: flex;
  height: 100vh;
  overflow: hidden;
}
#controls {
  width: 300px;
  min-width: 300px;
  max-width: 300px;
  padding: 0 1rem 1rem 1rem;
  box-sizing: border-box;
  background: #222;
  display: flex;
  flex-direction: column;
  gap: 0.5rem; /* Reduced gap for compactness */
  overflow-y: auto; /* Enable vertical scroll if needed */
}
label {
  font-weight: bold;
  margin-bottom: 0.25rem;
  display: block;
}
input[type="text"], input[type="number"] {
  width: 100%;
  padding: 0.3rem 0.4rem; /* Reduced padding */
  border: none;
  border-radius: 3px;
  font-size: 0.95rem; /* Slightly smaller font */
  box-sizing: border-box;
  background: #333;
  color: #eee;
}
button {
  padding: 0.5rem;
  font-size: 1rem;
  border: none;
  border-radius: 3px;
  background: #444;
  color: #eee;
  cursor: pointer;
  transition: background 0.2s ease;
}
button:hover {
  background: #666;
}
#viewer {
  flex-grow: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #000;
  position: relative;
  height: 100vh; /* or 100% depending on your layout */
  overflow: hidden;
}

#viewer img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  user-select: none;
  pointer-events: none;
}
.nav-buttons {
  margin-top: 0.5rem; /* Reduced vertical margin */
  display: flex;
  gap: 0.5rem; /* Reduced gap */
  flex-wrap: wrap; /* Allow wrapping on narrow screens */
}

select {
	padding: 0.5rem;
	font-size: 1rem;
	border: none;
	border-radius: 3px;
	background: #444;
	color: #eee;
	cursor: pointer;
	transition: background 0.2s ease;
}


/* ========= IMAGE TAGS ========= */

.clickable-tag {
  display: inline-block;
  margin: 0 5px 5px 0;
  padding: 2px 6px;
  border-radius: 3px;
  color: #eee;
  cursor: pointer;
  user-select: none;
  background: #333; /* default neutral */
  transition: background-color 0.2s ease;
}
.clickable-tag.search-tag {
  background-color: #3b82f6; /* blue */
}
.clickable-tag.blacklist-tag {
  background-color: #ef4444; /* red */
}

/* ======= TOGGLE SOURCE BAR ======== */

.topToggleBtn {
  top: 0;
  left: 0;
  right: 0;
  height: 16px;
  font-size: 0.8rem;
  border: none;
  background: #333;
  color: #ccc;
  cursor: pointer;
  z-index: 10;
  padding: 0 0.5rem;
  text-align: center;
}

#sourceGroup {
  overflow: hidden;
  transition: max-height 0.3s ease;
}

#sourceGroup.collapsed {
  max-height: 0;
  padding-top: 0;
  padding-bottom: 0;
  margin-bottom: 0;
  border: none;
}

input:focus, button:focus {
  outline: none;
}

/* ====== PRE-LOAD PREVIEW ====== */
/* Wrapper for image layers */
.image-layer-wrapper {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  overflow: hidden;
}

/* Preview image (loads first, behind) */
.preview-layer {
  position: absolute;
  top: 0; left: 0; bottom: 0; right: 0;
  margin: auto;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  z-index: 0;
  /* optional fade */
  transition: opacity 0.3s ease;
}


/* Full image (fades in over preview) */
.full-layer {
  position: relative;
  top: 0; left: 0; bottom: 0; right: 0;
  margin: auto;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  z-index: 1;
  opacity: 0;
  transition: opacity 0.3s ease;
}

/* ===== AUTOCOMPLETE ====== */
.autocomplete {
  position: relative;
}
.autocomplete-items {
  position: absolute;
  top: 100%; left: 0; right: 0;
  background: #333;
  border: 1px solid #444;
  max-height: 200px;
  overflow-y: auto;
  z-index: 100;
}
.autocomplete-item {
  padding: 0.3rem 0.5rem;
  cursor: pointer;
  color: #eee;
}
.autocomplete-item:hover,
.autocomplete-item.active {
  background: #444;
}