:root {
  color-scheme: light;
  --bg: #f6f7f9;
  --panel: #ffffff;
  --text: #16181d;
  --muted: #7a808a;
  --line: #e2e5ea;
  --line-strong: #cfd4dc;
  --success: #16a34a;
  --error: #dc2626;
  --shadow: 0 10px 28px rgba(22, 24, 29, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", sans-serif;
}

button,
input {
  font: inherit;
}

.page {
  width: min(1180px, calc(100% - 28px));
  margin: 0 auto;
  padding: 28px 0 44px;
}

.header {
  margin-bottom: 18px;
}

.title-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
}

h1 {
  margin: 0;
  font-size: 24px;
  line-height: 1.25;
  font-weight: 700;
  letter-spacing: 0;
}

.tag {
  display: inline-flex;
  align-items: center;
  height: 24px;
  padding: 0 9px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #f0f2f5;
  color: #676d77;
  font-size: 13px;
  line-height: 1;
}

.search-wrap {
  display: block;
}

#searchInput {
  width: 100%;
  height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--text);
  padding: 0 14px;
  outline: none;
  box-shadow: 0 1px 0 rgba(22, 24, 29, 0.02);
  transition: border-color 160ms ease, box-shadow 160ms ease;
}

#searchInput::placeholder {
  color: #9aa0aa;
}

#searchInput:focus {
  border-color: #9aa7b8;
  box-shadow: 0 0 0 4px rgba(104, 119, 141, 0.13);
}

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

.tile {
  position: relative;
  display: block;
  width: 100%;
  aspect-ratio: 3 / 4;
  padding: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel);
  cursor: pointer;
}

.tile:focus-visible {
  outline: 3px solid rgba(22, 163, 74, 0.28);
  outline-offset: 3px;
}

.tile img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 12px;
  transition: transform 180ms ease;
}

.tile:hover img,
.tile:focus-visible img {
  transform: scale(1.015);
}

.badge {
  position: absolute;
  top: 10px;
  left: 10px;
  z-index: 2;
  min-width: 30px;
  max-width: calc(100% - 20px);
  padding: 4px 9px;
  overflow: hidden;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.94);
  color: var(--text);
  font-size: 13px;
  line-height: 1.2;
  font-weight: 650;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 16px;
  border-radius: 12px;
  background: rgba(20, 24, 30, 0.46);
  color: #ffffff;
  font-size: 15px;
  font-weight: 650;
  line-height: 1.4;
  text-align: center;
  opacity: 0;
  transition: opacity 160ms ease;
}

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

.empty {
  margin: 34px 0 0;
  color: var(--muted);
  font-size: 15px;
  text-align: center;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  z-index: 10;
  max-width: calc(100% - 32px);
  padding: 11px 16px;
  border-radius: 8px;
  background: var(--success);
  color: #ffffff;
  font-size: 14px;
  line-height: 1.35;
  box-shadow: var(--shadow);
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 14px);
  transition: opacity 160ms ease, transform 160ms ease;
}

.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

.toast.error {
  background: var(--error);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@media (min-width: 768px) {
  .page {
    padding-top: 36px;
  }

  .gallery {
    grid-template-columns: repeat(4, 1fr);
  }
}
