:root {
  --page: #f6f6f6;
  --panel: #fff;
  --line: #d7d7d7;
  --text: #222;
  --muted: #777;
  --link: #2b5f96;
  --accent: #a21f2d;
}

* {
  box-sizing: border-box;
}

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

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

a:hover {
  text-decoration: underline;
}

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

.navbar {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 18px;
  min-height: 78px;
  border-bottom: 1px solid var(--line);
}

.logo {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  color: #222;
  font-weight: 700;
}

.logo:hover {
  text-decoration: none;
}

.logo-mark {
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  border-radius: 3px;
  background: #262626;
  color: #fff;
  font-size: 28px;
  font-family: Georgia, serif;
  line-height: 1;
}

.logo-text {
  font-size: 28px;
  letter-spacing: 0;
}

.nav-links {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 16px;
}

.nav-links a,
.lang-button {
  color: #333;
  font-size: 15px;
  text-transform: lowercase;
}

.lang-button {
  padding: 0;
  border: 0;
  background: transparent;
  cursor: pointer;
  font: inherit;
}

.language-menu {
  position: relative;
}

.language-dropdown {
  position: absolute;
  z-index: 20;
  top: 24px;
  left: 0;
  width: 150px;
  border: 1px solid #bbb;
  background: #fff;
  box-shadow: 0 3px 8px rgba(0, 0, 0, .15);
}

.language-dropdown button {
  display: block;
  width: 100%;
  padding: 8px 10px;
  border: 0;
  border-bottom: 1px solid #e5e5e5;
  background: #fff;
  color: #333;
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.language-dropdown button:hover {
  background: #f2f2f2;
}

.directory-panel {
  margin: 14px 0 0;
  padding: 14px 16px;
  border: 1px solid var(--line);
  background: #fff;
  max-height: 520px;
  overflow: auto;
}

.directory-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.directory-header h2 {
  margin: 0;
  font-size: 16px;
  text-transform: lowercase;
}

.directory-close {
  padding: 3px 8px;
  border: 1px solid #c8c8c8;
  background: #f7f7f7;
  color: #444;
  cursor: pointer;
}

.directory-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.directory-letters {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin: 0 0 14px;
  padding: 0;
  list-style: none;
}

.directory-letters button {
  min-width: 30px;
  padding: 4px 7px;
  border: 1px solid #d0d0d0;
  background: #fafafa;
  color: var(--link);
  cursor: pointer;
  font: inherit;
}

.directory-letters button:hover,
.directory-letters button.active {
  border-color: #777;
  background: #ececec;
  text-decoration: underline;
}

.directory-list button {
  padding: 5px 8px;
  border: 1px solid #d0d0d0;
  background: #fafafa;
  color: var(--link);
  cursor: pointer;
  font: inherit;
}

.directory-list button:hover,
.directory-list button.active {
  border-color: #777;
  background: #ececec;
  text-decoration: underline;
}

.directory-list button span {
  color: #777;
  font-size: 12px;
}

.search-box {
  display: flex;
  min-width: min(370px, 42vw);
}

.search-box input,
.search-box button,
.sort-select select {
  height: 34px;
  border: 1px solid #bfbfbf;
  background: #fff;
  font: inherit;
}

.search-box input {
  min-width: 0;
  flex: 1;
  padding: 0 10px;
}

.search-box button {
  padding: 0 14px;
  border-left: 0;
  cursor: pointer;
}

.ad-slot,
.side-ad {
  display: grid;
  place-items: center;
  border: 1px dashed #c9c9c9;
  color: #999;
  background: #fafafa;
  font-size: 11px;
}

.top-ad {
  min-height: 120px;
  margin: 22px 0 18px;
}

.list-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin: 0 0 10px;
}

.list-title h1 {
  margin: 0;
  font-size: 20px;
  font-weight: 700;
}

.list-controls {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
}

.sort-select {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
}

.sort-select select {
  min-width: 170px;
  padding: 0 8px;
}

.pager {
  margin: 18px 0;
}

.pager ul {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.pager a,
.pager span {
  display: grid;
  min-width: 32px;
  height: 30px;
  place-items: center;
  border: 1px solid #cfcfcf;
  background: #fff;
  color: #444;
}

.pager .active {
  background: #444;
  color: #fff;
  border-color: #444;
}

.layout {
  display: grid;
  grid-template-columns: 1fr 188px;
  align-items: start;
  gap: 18px;
}

.side-ad {
  position: sticky;
  top: 16px;
  grid-column: 2;
  grid-row: 1;
  width: 188px;
  min-height: 320px;
}

.gallery-content {
  grid-column: 1;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(152px, 1fr));
  gap: 26px 18px;
  min-height: 600px;
}

.gallery-card {
  min-width: 0;
}

.result-count {
  grid-column: 1 / -1;
  color: var(--muted);
  font-size: 12px;
}

.cover-link {
  display: block;
  background: #e9e9e9;
  border: 1px solid #cfcfcf;
  box-shadow: 0 1px 1px rgba(0, 0, 0, .12);
}

.cover-link img {
  display: block;
  width: 100%;
  aspect-ratio: 3 / 4.25;
  object-fit: cover;
}

.gallery-title {
  display: block;
  margin-top: 8px;
  color: #254f80;
  font-size: 13px;
  font-weight: 700;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.gallery-meta {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.tag-row {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 5px;
}

.tag-row button {
  padding: 2px 5px;
  border: 1px solid #ddd;
  background: #fff;
  color: #666;
  font-size: 11px;
  font: inherit;
  cursor: pointer;
}

.tag-row button:hover {
  border-color: #999;
  color: var(--link);
  text-decoration: underline;
}

.empty-state {
  grid-column: 1 / -1;
  padding: 48px 16px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--muted);
  text-align: center;
}

.nozomi-link {
  margin: 24px 0;
  text-align: center;
}

@media (max-width: 860px) {
  .navbar {
    grid-template-columns: 1fr;
    gap: 12px;
    padding: 15px 0;
  }

  .search-box {
    min-width: 0;
    width: 100%;
  }

  .layout {
    display: block;
  }

  .side-ad {
    position: static;
    width: 100%;
    min-height: 80px;
    margin-bottom: 18px;
  }
}

@media (max-width: 560px) {
  .container {
    width: min(100% - 18px, 1180px);
  }

  .logo-text {
    font-size: 24px;
  }

  .list-title {
    align-items: stretch;
    flex-direction: column;
  }

  .list-controls {
    justify-content: stretch;
  }

  .sort-select {
    justify-content: space-between;
  }

  .sort-select select {
    flex: 1;
    min-width: 0;
  }

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