:root {
  --green: #1d5f38;
  --green-dark: #123d25;
  --green-light: #73e58a;
  --bg: #f4f7f4;
  --text: #17301f;
  --muted: #6a776e;
  --white: #ffffff;
  --shadow: 0 12px 35px rgba(18, 61, 37, .12);
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Arial, Helvetica, sans-serif;
}

.site-header {
  background: linear-gradient(135deg, var(--green-dark), var(--green));
  color: var(--white);
  padding: 58px 20px 54px;
  text-align: center;
}

.header-inner {
  max-width: 1100px;
  margin: auto;
}

.brand-title {
  display: block;
  font-size: clamp(25px, 4vw, 42px);
  font-weight: 800;
  letter-spacing: .16em;
}

.brand-line {
  display: block;
  width: 115px;
  height: 5px;
  background: var(--green-light);
  margin: 20px auto 25px;
}

.site-header h1 {
  margin: 0;
  font-size: clamp(32px, 5vw, 52px);
  letter-spacing: .02em;
}

.site-header p {
  margin: 14px 0 0;
  font-size: 18px;
  opacity: .9;
}

.container {
  width: min(1180px, calc(100% - 32px));
  margin: 42px auto 70px;
}

.toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 20px;
  margin-bottom: 30px;
}

.search-wrap {
  position: relative;
  flex: 1;
  max-width: 430px;
}

.search-wrap input {
  width: 100%;
  border: 1px solid #d5ded7;
  border-radius: 12px;
  background: var(--white);
  padding: 15px 18px 15px 45px;
  font-size: 16px;
  outline: none;
  box-shadow: 0 4px 16px rgba(18,61,37,.05);
}

.search-wrap input:focus {
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(29,95,56,.12);
}

.search-icon {
  position: absolute;
  left: 17px;
  top: 50%;
  transform: translateY(-52%);
  font-size: 24px;
  color: var(--green);
  z-index: 1;
}

.count {
  color: var(--muted);
  font-size: 14px;
}

.gallery {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 42px 28px;
}

.friend-card {
  background: var(--white);
  border-radius: 16px;
  overflow: hidden;
  box-shadow: var(--shadow);
}

.friend-title {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 18px 20px;
  border-bottom: 1px solid #edf1ed;
}

.friend-title h2 {
  margin: 0;
  font-size: 23px;
}

.friend-title span {
  color: var(--green);
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
}

.wallpaper-pair {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 2px;
  background: #dfe7e1;
}

.wallpaper {
  position: relative;
  min-width: 0;
  background: #111;
  overflow: hidden;
  cursor: pointer;
}

.wallpaper img {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 1 / 2;
  object-fit: cover;
  transition: transform .35s ease;
}

.wallpaper:hover img {
  transform: scale(1.025);
}

.wallpaper-overlay {
  position: absolute;
  inset: auto 0 0;
  padding: 44px 14px 14px;
  background: linear-gradient(transparent, rgba(0,0,0,.78));
  opacity: 0;
  transition: opacity .25s ease;
}

.wallpaper:hover .wallpaper-overlay,
.wallpaper:focus-visible .wallpaper-overlay {
  opacity: 1;
}

.download-label {
  display: block;
  width: max-content;
  max-width: 100%;
  margin-left: auto;
  padding: 10px 14px;
  border-radius: 8px;
  background: var(--white);
  color: var(--green-dark);
  font-size: 13px;
  font-weight: 800;
}

.empty {
  text-align: center;
  padding: 70px 20px;
  color: var(--muted);
}

.modal {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 1000;
}

.modal.open {
  display: grid;
  place-items: center;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(4, 20, 10, .72);
  backdrop-filter: blur(5px);
}

.modal-dialog {
  position: relative;
  z-index: 1;
  width: min(960px, calc(100% - 28px));
  max-height: calc(100vh - 28px);
  overflow: auto;
  border-radius: 18px;
  background: var(--white);
  box-shadow: 0 30px 80px rgba(0,0,0,.3);
  display: grid;
  grid-template-columns: minmax(280px, 48%) 1fr;
}

.modal-preview {
  background: #101510;
  display: grid;
  place-items: center;
  min-height: 420px;
}

.modal-preview img {
  display: block;
  max-width: 100%;
  max-height: 75vh;
  width: auto;
  height: auto;
}

.modal-content {
  padding: 42px;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.eyebrow {
  color: var(--green);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .12em;
}

.modal-content h2 {
  margin: 8px 0 12px;
  font-size: 34px;
}

.modal-content p {
  color: var(--muted);
  line-height: 1.6;
}

.download-button {
  display: inline-block;
  margin-top: 22px;
  padding: 15px 20px;
  border-radius: 10px;
  background: var(--green);
  color: white;
  text-decoration: none;
  text-align: center;
  font-weight: 800;
  transition: background .2s, transform .2s;
}

.download-button:hover {
  background: var(--green-dark);
  transform: translateY(-1px);
}

.modal-close {
  position: absolute;
  z-index: 2;
  top: 12px;
  right: 12px;
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: 50%;
  background: rgba(255,255,255,.92);
  color: #17301f;
  font-size: 28px;
  cursor: pointer;
  line-height: 1;
}

@media (max-width: 760px) {
  .site-header { padding: 42px 16px; }
  .container { width: min(100% - 20px, 620px); margin-top: 25px; }
  .toolbar { align-items: stretch; flex-direction: column; gap: 10px; }
  .search-wrap { max-width: none; }
  .gallery { grid-template-columns: 1fr; gap: 28px; }
  .friend-title h2 { font-size: 20px; }
  .modal-dialog { grid-template-columns: 1fr; }
  .modal-preview { min-height: 0; }
  .modal-preview img { max-height: 55vh; }
  .modal-content { padding: 28px 24px 30px; }
}

@media (hover: none) {
  .wallpaper-overlay { opacity: 1; }
}
