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

:root {
  --bg: #000000;
  --text: #ffffff;
  --accent: #ff2828;
  --border: #222222;
  --radius: 4px;
  --space: 20px;
}

:root.light {
  --bg: #ffffff;
  --text: #000000;
  --accent: #ff2828;
  --border: #eeeeee;
}

@media (prefers-color-scheme: light) {
  :root:not(.dark) {
    --bg: #ffffff;
    --text: #000000;
    --accent: #ff2828;
    --border: #eeeeee;
  }
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  line-height: 1.5;
  overflow-x: hidden;
}

.container {
  width: 100%;
  max-width: 100%;
  margin: 0 auto;
  padding: 0 var(--space);
}

.thumb-label,
.gallery-header,
.loading,
.error,
.footer-text {
  text-align: center;
}

.thumb-label,
.gallery-header h1,
.loading,
.error,
.footer-text {
  font-weight: 800;
  text-transform: uppercase;
}

.search-form input,
.lang-select,
.theme-toggle,
.meta a {
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: var(--radius);
}

.search-btn,
.theme-toggle,
.lightbox,
.lightbox-close {
  display: flex;
  align-items: center;
  justify-content: center;
}

header {
  background: var(--bg);
  padding: var(--space) 0;
  position: sticky;
  top: 0;
  z-index: 100;
  border-bottom: 1px solid var(--border);
}

header .container {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.logo {
  font-size: 26px;
  font-weight: 800;
  color: var(--accent);
  text-decoration: none;
  text-transform: uppercase;
}

.header-right {
  display: flex;
  align-items: center;
  gap: var(--space);
}

.search-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

.search-form input {
  padding: 10px 45px 10px var(--space);
  outline: none;
  font-family: inherit;
  font-size: 0.95rem;
  width: 240px;
}

.search-form input:focus {
  border-color: var(--border-hover);
}

.search-btn {
  position: absolute;
  right: 1px;
  top: 1px;
  bottom: 1px;
  background: transparent;
  border: none;
  color: var(--text);
  padding: 0 14px;
  cursor: pointer;
  border-radius: 0 var(--radius) var(--radius) 0;
}

.lang-select {
  padding: 10px var(--space);
  outline: none;
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
}

.theme-toggle {
  cursor: pointer;
  width: 42px;
  height: 42px;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: var(--space);
  padding: var(--space) 0;
}

.thumb {
  background: var(--bg);
  border-radius: var(--radius);
  overflow: hidden;
  position: relative;
  aspect-ratio: 3/5;
  border: 1px solid var(--border);
  scroll-margin-top: 120px;
}

.thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.thumb-label {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--bg);
  color: var(--text);
  padding: var(--space);
  font-size: 0.95rem;
  z-index: 10;
  border-top: 1px solid var(--border);
}

.thumb:not(:has(img)) {
  aspect-ratio: auto;
  min-height: auto;
}

.thumb:not(:has(img)) .thumb-label {
  position: static;
  padding: var(--space);
  display: block;
}

.gallery-images {
  column-count: 4;
  column-gap: var(--space);
  padding: var(--space) 0;
}

.gallery-images img {
  width: 100%;
  display: block;
  margin-bottom: var(--space);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  cursor: pointer;
}

.gallery-header h1 {
  font-size: 2.5rem;
}

.meta {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: var(--space);
}

.meta a {
  padding: 10px var(--space);
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 600;
  text-transform: uppercase;
}

.loading,
.error {
  padding: 120px 0;
  color: var(--text);
  font-size: 1.2rem;
}

footer {
  background: var(--bg);
  padding: var(--space) 0;
  border-top: 1px solid var(--border);
}

.footer-text {
  display: block;
  font-size: 1.1rem;
  color: var(--text);
}

.lightbox {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: var(--bg);
  z-index: 2000;
  user-select: none;
}

.lightbox-img {
  max-width: 95%;
  max-height: 95%;
  object-fit: contain;
  border: 1px solid var(--border);
}

.lightbox-close {
  position: absolute;
  top: 25px;
  right: 25px;
  color: var(--text);
  font-size: 40px;
  font-weight: 800;
  cursor: pointer;
  z-index: 2020;
  width: 50px;
  height: 50px;
  border: 1px solid var(--border);
  background: var(--bg);
}

.lightbox-nav {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 12%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text);
  font-size: 45px;
  font-weight: 800;
  cursor: pointer;
  z-index: 2010;
  background: transparent;
}

.lightbox-prev {
  left: 0;
}

.lightbox-next {
  right: 0;
}

.lightbox-counter {
  position: absolute;
  bottom: 30px;
  color: var(--text);
  font-size: 1rem;
  font-weight: 800;
  z-index: 2010;
  background: var(--bg);
  border: 1px solid var(--border);
  padding: 10px var(--space);
  border-radius: var(--radius);
}

@media (max-width: 1024px) {
  .gallery-images {
    column-count: 3;
  }
}

@media (max-width: 768px) {
  .grid {
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: var(--space);
    padding: var(--space) 0;
  }

  .gallery-images {
    column-count: 2;
    column-gap: var(--space);
  }

  .gallery-header h1 {
    font-size: 2rem;
  }

  .search-form input {
    width: 160px;
  }
}
