#app-header {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  background: #1a202c;
  z-index: 100;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
}

#app-header h1 {
  color: #4299e1;
  font-size: 1.5rem;
  margin: 0;
  padding: 10px 20px;
  float: left;
  font-weight: 600;
  letter-spacing: 0.5px;
}

#controls {
  display: flex;
  justify-content: center;
  gap: 10px;
  padding: 10px;
  margin-left: 250px;
}

#controls input {
  padding: 8px 12px;
  font-size: 1rem;
  border: 1px solid #2d3748;
  border-radius: 5px;
  outline: none;
  flex-grow: 1;
  max-width: 400px;
  background: #2d3748;
  color: #f7fafc;
  transition: border-color 0.3s, box-shadow 0.3s;
}

#controls input:focus {
  border-color: #4299e1;
  box-shadow: 0 0 0 2px rgba(66, 153, 225, 0.2);
}

#controls button {
  padding: 8px 20px;
  font-size: 1rem;
  border: none;
  border-radius: 5px;
  background: #3182ce;
  color: white;
  cursor: pointer;
  transition: all 0.3s ease;
}

#controls button:hover {
  background: #2b6cb0;
  transform: translateY(-1px);
}

#controls button:active {
  transform: translateY(0);
}

#controls #toggle-label {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 14px;
  color: #f7fafc;
  user-select: none;
}

#controls #toggle-label input {
  cursor: pointer;
  width: auto;
  margin: 0;
}

#stats-window {
  position: fixed;
  top: 90px;
  right: 20px;
  background: rgba(26, 32, 44, 0.95);
  color: #f7fafc;
  padding: 15px 25px;
  border-radius: 12px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  font-size: 14px;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
  z-index: 200;
  backdrop-filter: blur(5px);
  min-width: 200px;
}

#stats-window h3 {
  margin: 0 0 12px 0;
  font-size: 18px;
  color: #4299e1;
  font-weight: 600;
  letter-spacing: 0.5px;
}

#stats-window p {
  margin: 8px 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

#stats-window strong {
  color: #a0aec0;
}

html,
body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  background: black;
  display: flex;
  justify-content: center;
  align-items: center;
  overflow: hidden;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
}

canvas {
  display: block;
  margin-top: 80px;
  cursor: grab;
}

canvas.grabbing {
  cursor: grabbing;
}

#zoom-controls {
  position: fixed;
  top: 90px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(26, 32, 44, 0.95);
  padding: 12px 20px;
  border-radius: 8px;
  z-index: 100;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
  backdrop-filter: blur(5px);
  display: flex;
  align-items: center;
  gap: 15px;
  transition: opacity 0.3s ease, transform 0.3s ease;
  opacity: 0.85;
}

#zoom-controls:hover {
  opacity: 1;
}

#zoom-controls.inactive .zoom-slider-container {
  display: none;
}

#zoom-controls.inactive .zoom-status {
  color: #a0aec0;
}

.zoom-info {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.zoom-status {
  font-size: 14px;
  color: #f7fafc;
  transition: color 0.3s ease;
}

.zoom-slider-container {
  display: flex;
  align-items: center;
  gap: 12px;
}

.zoom-range {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 200px;
}

.zoom-track {
  flex: 1;
  height: 4px;
  background: #2d3748;
  border-radius: 2px;
  position: relative;
  cursor: pointer;
}

.zoom-fill {
  position: absolute;
  left: 0;
  top: 0;
  height: 100%;
  background: #4299e1;
  border-radius: 2px;
  pointer-events: none;
}

.zoom-handle {
  width: 16px;
  height: 16px;
  background: #f7fafc;
  border: 2px solid #4299e1;
  border-radius: 50%;
  position: absolute;
  top: 50%;
  transform: translate(-50%, -50%);
  cursor: grab;
  transition: box-shadow 0.2s ease;
}

.zoom-handle:hover {
  box-shadow: 0 0 0 4px rgba(66, 153, 225, 0.2);
}

.zoom-handle:active {
  cursor: grabbing;
  box-shadow: 0 0 0 6px rgba(66, 153, 225, 0.3);
}

.zoom-handle:focus {
  outline: none;
  box-shadow: 0 0 0 4px rgba(66, 153, 225, 0.4);
}

.min-zoom, .max-zoom {
  font-size: 12px;
  color: #a0aec0;
  min-width: 35px;
}

.zoom-value {
  font-size: 14px;
  color: #f7fafc;
  min-width: 45px;
  text-align: right;
}

.reset-zoom {
  background: none;
  border: none;
  padding: 6px;
  color: #a0aec0;
  cursor: pointer;
  border-radius: 4px;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

.reset-zoom:hover {
  color: #f7fafc;
  background: #2d3748;
}

.reset-zoom:active {
  transform: scale(0.95);
}

.reset-zoom:focus {
  outline: none;
  box-shadow: 0 0 0 2px rgba(66, 153, 225, 0.4);
}

#download-controls {
  position: fixed;
  top: 90px;
  left: 20px;
  background: #1a202c;
  padding: 12px;
  border-radius: 8px;
  z-index: 100;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
}

#download-button {
  padding: 8px 15px;
  font-size: 1rem;
  background: #3182ce;
  color: white;
  border: none;
  border-radius: 5px;
  cursor: pointer;
  transition: all 0.3s ease;
  min-width: 140px;
}

#download-button:hover {
  background: #2b6cb0;
  transform: translateY(-1px);
}

#download-button:active {
  transform: translateY(0);
}

.hidden {
  display: none !important;
}

#download-dropdown {
  position: absolute;
  top: 50px;
  left: 0;
  background: #2d3748;
  border: 1px solid #4a5568;
  border-radius: 8px;
  padding: 5px 0;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
  z-index: 100;
  min-width: 140px;
}

.download-option {
  padding: 10px 15px;
  font-size: 14px;
  color: #f7fafc;
  background: none;
  border: none;
  text-align: left;
  width: 100%;
  cursor: pointer;
  transition: background-color 0.2s;
}

.download-option:hover {
  background: #4a5568;
}

#loading-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.8);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  z-index: 1000;
}

#loading-overlay p {
  color: #f7fafc;
  margin-top: 20px;
  font-size: 1.2rem;
}

.spinner {
  width: 50px;
  height: 50px;
  border: 5px solid #f7fafc;
  border-top: 5px solid #3182ce;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

#credits {
  position: fixed;
  bottom: 20px;
  right: 20px;
  color: rgba(247, 250, 252, 0.3);
  text-decoration: none;
  font-size: 14px;
  padding: 8px 12px;
  border-radius: 6px;
  transition: all 0.3s ease;
  z-index: 100;
}

#credits::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(26, 32, 44, 0.8);
  border-radius: 6px;
  opacity: 0;
  transition: opacity 0.3s ease;
  z-index: -1;
  backdrop-filter: blur(5px);
}

#credits:hover {
  color: rgba(247, 250, 252, 0.9);
}

#credits:hover::before {
  opacity: 1;
}

#credits:focus {
  outline: none;
  box-shadow: 0 0 0 2px rgba(66, 153, 225, 0.4);
  color: rgba(247, 250, 252, 0.9);
}

#credits:focus::before {
  opacity: 1;
}

/* GIF Browser Styles */
#gif-browser {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  justify-content: center;
  align-items: center;
}

.browser-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.8);
  backdrop-filter: blur(5px);
}

.browser-content {
  position: relative;
  width: 90%;
  max-width: 1200px;
  max-height: 80vh;
  background: #1a202c;
  border-radius: 12px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.browser-header {
  padding: 15px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid #2d3748;
}

#category-select {
  padding: 8px 12px;
  font-size: 1rem;
  background: #2d3748;
  color: #f7fafc;
  border: 1px solid #4a5568;
  border-radius: 6px;
  cursor: pointer;
}

#close-browser {
  background: none;
  border: none;
  color: #a0aec0;
  font-size: 24px;
  cursor: pointer;
  padding: 5px 10px;
  border-radius: 6px;
  transition: all 0.2s;
}

#close-browser:hover {
  color: #f7fafc;
  background: #2d3748;
}

#gif-grid {
  padding: 20px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 20px;
  overflow-y: auto;
  max-height: calc(80vh - 120px);
}

.gif-item {
  position: relative;
  aspect-ratio: 1;
  border-radius: 8px;
  overflow: hidden;
  cursor: pointer;
  background: #2d3748;
}

.gif-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.3s ease;
}

.gif-item:hover img {
  transform: scale(1.1);
}

.gif-preview {
  position: absolute;
  inset: 0;
  opacity: 0;
  transition: opacity 0.3s ease;
  background: #1a202c;
}

.gif-item:hover .gif-preview {
  opacity: 1;
}

.browser-footer {
  padding: 15px;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 20px;
  border-top: 1px solid #2d3748;
}

.browser-footer button {
  padding: 8px 16px;
  background: #2d3748;
  color: #f7fafc;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s;
}

.browser-footer button:hover:not(:disabled) {
  background: #4a5568;
}

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

#page-info {
  color: #a0aec0;
  font-size: 14px;
}

.gif-item.loading {
  background: #2d3748;
}

.skeleton-pulse {
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, #2d3748 25%, #4a5568 50%, #2d3748 75%);
  background-size: 200% 100%;
  animation: pulse 1.5s infinite;
}

@keyframes pulse {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

#browse-toggle {
  position: fixed;
  bottom: 20px;
  left: 20px;
  padding: 10px 20px;
  background: #3182ce;
  color: white;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-size: 1rem;
  transition: all 0.3s ease;
  z-index: 90;
}

#browse-toggle:hover {
  background: #2b6cb0;
  transform: translateY(-1px);
}
