* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

/* Dark mode (default) */
:root {
  --bg-primary: #0a0a0a;
  --bg-secondary: #1a1a1a;
  --text-primary: #fff;
  --text-secondary: rgba(255, 255, 255, 0.6);
  --text-muted: rgba(255, 255, 255, 0.4);
  --border-color: rgba(255, 255, 255, 0.1);
  --input-bg: rgba(255, 255, 255, 0.05);
  --input-bg-focus: rgba(255, 255, 255, 0.08);
  --accent-color: #fff;
  --button-bg: #fff;
  --button-text: #0a0a0a;
  --button-hover-bg: #e5e5e5;
  --toggle-bg: rgba(255, 255, 255, 0.1);
  --toggle-icon: #fff;
}

/* Light mode */
[data-theme="light"] {
  --bg-primary: #f5f5f7;
  --bg-secondary: #e5e5e7;
  --text-primary: #1a1a1a;
  --text-secondary: rgba(0, 0, 0, 0.6);
  --text-muted: rgba(0, 0, 0, 0.4);
  --border-color: rgba(0, 0, 0, 0.1);
  --input-bg: rgba(0, 0, 0, 0.05);
  --input-bg-focus: rgba(0, 0, 0, 0.08);
  --accent-color: #1a1a1a;
  --button-bg: #1a1a1a;
  --button-text: #fff;
  --button-hover-bg: #333;
  --toggle-bg: rgba(0, 0, 0, 0.1);
  --toggle-icon: #1a1a1a;
}

/* System preference detection (when no explicit theme is set) */
@media (prefers-color-scheme: light) {
  :root:not([data-theme]) {
    --bg-primary: #f5f5f7;
    --bg-secondary: #e5e5e7;
    --text-primary: #1a1a1a;
    --text-secondary: rgba(0, 0, 0, 0.6);
    --text-muted: rgba(0, 0, 0, 0.4);
    --border-color: rgba(0, 0, 0, 0.1);
    --input-bg: rgba(0, 0, 0, 0.05);
    --input-bg-focus: rgba(0, 0, 0, 0.08);
    --accent-color: #1a1a1a;
    --button-bg: #1a1a1a;
    --button-text: #fff;
    --button-hover-bg: #333;
    --toggle-bg: rgba(0, 0, 0, 0.1);
    --toggle-icon: #1a1a1a;
  }
}

body {
  font-family:
    -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu,
    sans-serif;
  background-color: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  transition:
    background-color 0.2s ease,
    color 0.2s ease;
}

.header {
  position: relative;
  z-index: 100;
  background: var(--bg-primary);
  padding: 20px;
  border-bottom: 1px solid var(--border-color);
  transition:
    background-color 0.2s ease,
    border-color 0.2s ease;
}

.header-content {
  max-width: 800px;
  margin: 0 auto;
}

h1 {
  text-align: center;
  font-size: 1.8rem;
  font-weight: 600;
  margin-bottom: 20px;
}

h1 a {
  color: var(--accent-color);
  text-decoration: none;
}

/* Theme toggle button */
.theme-toggle {
  position: absolute;
  top: 20px;
  right: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border: none;
  border-radius: 8px;
  background: var(--toggle-bg);
  color: var(--toggle-icon);
  cursor: pointer;
  transition:
    background 0.2s ease,
    transform 0.2s ease;
  -webkit-tap-highlight-color: transparent;
}

.theme-toggle:hover {
  background: var(--border-color);
}

.theme-toggle:active {
  transform: scale(0.95);
}

.theme-toggle svg {
  width: 20px;
  height: 20px;
}

.theme-toggle .icon-sun,
.theme-toggle .icon-moon {
  display: none;
}

/* Show sun icon in dark mode (to switch to light) */
:root:not([data-theme]) .theme-toggle .icon-sun,
[data-theme="dark"] .theme-toggle .icon-sun {
  display: block;
}

/* Show moon icon in light mode (to switch to dark) */
[data-theme="light"] .theme-toggle .icon-moon {
  display: block;
}

/* Handle system preference for icon display */
@media (prefers-color-scheme: light) {
  :root:not([data-theme]) .theme-toggle .icon-sun {
    display: none;
  }
  :root:not([data-theme]) .theme-toggle .icon-moon {
    display: block;
  }
}

.search-form {
  display: flex;
  gap: 10px;
  max-width: 600px;
  margin: 0 auto;
}

.search-input {
  flex: 1;
  padding: 14px 20px;
  font-size: 16px;
  border: 2px solid var(--border-color);
  border-radius: 4px;
  background: var(--input-bg);
  color: var(--text-primary);
  outline: none;
  transition:
    border-color 0.2s ease,
    background 0.2s ease,
    box-shadow 0.2s ease;
}

.search-input:focus {
  border-color: var(--accent-color);
  background: var(--input-bg-focus);
}

.search-input::placeholder {
  color: var(--text-muted);
}

.search-button {
  padding: 14px 28px;
  font-size: 1rem;
  font-weight: 600;
  border: none;
  border-radius: 4px;
  background: var(--button-bg);
  color: var(--button-text);
  cursor: pointer;
  transition: background 0.2s ease;
  -webkit-tap-highlight-color: transparent;
}

.search-button:hover {
  background: var(--button-hover-bg);
}

.results-info {
  text-align: center;
  padding: 15px 20px;
  color: var(--text-secondary);
  font-size: 0.9rem;
}

.gallery {
  padding: 8px;
}

.gallery-row {
  display: flex;
  gap: 4px;
  margin-bottom: 4px;
  content-visibility: auto;
  contain-intrinsic-size: 0 280px;
}

.photo-container {
  position: relative;
  overflow: hidden;
  border-radius: 4px;
  background: var(--bg-secondary);
  cursor: pointer;
  transition: background-color 0.2s ease;
}

.photo-placeholder {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  filter: blur(20px);
  transform: scale(1.1);
  z-index: 1;
}

.photo-actual {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0;
  transition: opacity 250ms ease-in-out;
  z-index: 2;
}

.photo-actual.loaded {
  opacity: 1;
}

.photo-actual.no-transition {
  transition: none;
}

.photo-overlay {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 40px 12px 12px;
  background: linear-gradient(to top, rgba(0, 0, 0, 0.8) 0%, transparent 100%);
  opacity: 0;
  transition: opacity 0.3s ease;
  z-index: 3;
  pointer-events: none;
}

.photo-container:hover .photo-overlay {
  opacity: 1;
}

.photo-title {
  font-size: 0.85rem;
  font-weight: 500;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.photo-author {
  font-size: 0.75rem;
  color: rgba(255, 255, 255, 0.7);
  margin-top: 2px;
}

.no-photos {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-secondary);
}

.no-photos h2 {
  font-size: 1.5rem;
  margin-bottom: 10px;
}
