:root {
  --bg: #f4f7fb;
  --surface: #ffffff;
  --line: #d8e2ef;
  --text: #1f2d3e;
  --muted: #5d6f88;
  --brand: #1d5ea8;
  --brand-2: #2f2e70;
  --accent: #b64059;
  --ok: #3f8c6f;
  --shadow: 0 20px 40px rgba(21, 56, 95, 0.12);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  font-family: "IBM Plex Sans", sans-serif;
  background: linear-gradient(180deg, #e8eff9 0%, var(--bg) 34%, #f8fafd 100%);
  color: var(--text);
}

.bg-shape {
  position: fixed;
  z-index: -1;
  pointer-events: none;
  filter: blur(40px);
  opacity: 0.28;
}

.bg-shape-a {
  top: -120px;
  right: -80px;
  width: 340px;
  height: 340px;
  border-radius: 999px;
  background: radial-gradient(circle, #4e90d9 0%, transparent 65%);
}

.bg-shape-b {
  bottom: -140px;
  left: -120px;
  width: 420px;
  height: 420px;
  border-radius: 999px;
  background: radial-gradient(circle, #b64059 0%, transparent 65%);
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.9rem 1.2rem;
  background: linear-gradient(90deg, #163d70, #1d5ea8 58%, #4e90d9);
  color: #fff;
  box-shadow: 0 6px 24px rgba(10, 33, 63, 0.25);
}

.brand {
  display: flex;
  gap: 0.55rem;
  align-items: center;
  font-family: "Titillium Web", sans-serif;
  font-size: 1.2rem;
  font-weight: 700;
  letter-spacing: 0.01em;
}

.brand-dot {
  width: 0.75rem;
  height: 0.75rem;
  border-radius: 999px;
  background: #fff;
  box-shadow: 0 0 0 5px rgba(255, 255, 255, 0.2);
}

.meta {
  opacity: 0.95;
  font-weight: 600;
}

.layout {
  width: min(1380px, 96vw);
  margin: 1.2rem auto 2rem;
}

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--shadow);
}

.hero {
  padding: 1rem 1rem 1.1rem;
  animation: reveal 360ms ease-out both;
}

.hero h1 {
  margin: 0;
  font-family: "Titillium Web", sans-serif;
  font-size: clamp(1.35rem, 2vw, 1.9rem);
  color: #1e4271;
}

.hero p {
  margin: 0.35rem 0 0.8rem;
  color: var(--muted);
}

.toolbar {
  display: flex;
  gap: 0.65rem;
  flex-wrap: wrap;
}

.toolbar input,
.toolbar select,
.btn,
#zoomRange {
  border-radius: 10px;
  border: 1px solid #b9cbe0;
  background: #fff;
  color: var(--text);
  font: inherit;
}

.toolbar input,
.toolbar select {
  padding: 0.6rem 0.75rem;
  min-height: 44px;
}

.toolbar input {
  min-width: min(560px, 100%);
  flex: 1;
}

.toolbar select {
  min-width: 240px;
}

.stats {
  margin-top: 0.85rem;
  display: grid;
  gap: 0.8rem;
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.stat {
  padding: 0.8rem 0.95rem;
}

.kicker {
  color: var(--muted);
  font-size: 0.85rem;
}

.stat strong {
  display: block;
  margin-top: 0.15rem;
  color: #1d5ea8;
  font-size: 1.55rem;
}

.caption {
  color: #7587a0;
  font-size: 0.85rem;
}

.gallery {
  margin-top: 0.95rem;
  display: grid;
  gap: 0.9rem;
  grid-template-columns: repeat(auto-fill, minmax(285px, 1fr));
}

.tile {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: transform 220ms ease, box-shadow 220ms ease;
  animation: reveal 360ms ease-out both;
}

.tile:hover {
  transform: translateY(-4px);
  box-shadow: 0 28px 38px rgba(24, 62, 102, 0.16);
}

.thumb-wrap {
  aspect-ratio: 16 / 10;
  background: #eef3fa;
  overflow: hidden;
}

.tile img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.tile-body {
  padding: 0.7rem 0.75rem 0.9rem;
}

.tile h3 {
  margin: 0;
  font-family: "Titillium Web", sans-serif;
  font-size: 1rem;
}

.tags {
  margin-top: 0.45rem;
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
}

.tag {
  padding: 0.2rem 0.5rem;
  border-radius: 999px;
  border: 1px solid #c4d6ea;
  color: #32547e;
  font-size: 0.78rem;
  background: #f7fbff;
}

.viewer {
  border: 0;
  padding: 0;
  width: min(96vw, 1520px);
  height: min(94vh, 980px);
  border-radius: 18px;
  overflow: hidden;
  background: #ecf2fb;
}

.viewer::backdrop {
  background: rgba(12, 28, 51, 0.8);
}

.viewer-shell {
  width: 100%;
  height: 100%;
  display: grid;
  grid-template-rows: auto 1fr auto;
}

.viewer-top,
.viewer-bottom {
  background: linear-gradient(90deg, #f6f9fd, #ebf2fb);
  border-bottom: 1px solid #c9d7ea;
  padding: 0.55rem 0.7rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
}

.viewer-bottom {
  border-bottom: 0;
  border-top: 1px solid #c9d7ea;
}

.viewer-top h2 {
  margin: 0;
  font-size: 1rem;
  font-family: "Titillium Web", sans-serif;
}

.viewer-top p {
  margin: 0;
  color: var(--muted);
  font-size: 0.84rem;
}

.viewer-actions {
  display: flex;
  gap: 0.45rem;
  align-items: center;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.btn {
  min-height: 38px;
  padding: 0.44rem 0.7rem;
  cursor: pointer;
  font-weight: 600;
}

.btn:hover {
  border-color: #88a8ca;
  background: #f7fbff;
}

.btn-danger {
  border-color: #d7a5b1;
  color: #8f2f48;
  background: #fff6f8;
}

#zoomRange {
  width: 140px;
  accent-color: #1d5ea8;
}

#zoomValue {
  min-width: 56px;
  color: #244f86;
  font-weight: 700;
}

.viewport {
  position: relative;
  overflow: hidden;
  background:
    linear-gradient(45deg, #e7edf8 25%, transparent 25%, transparent 75%, #e7edf8 75%),
    linear-gradient(45deg, #e7edf8 25%, transparent 25%, transparent 75%, #e7edf8 75%);
  background-size: 34px 34px;
  background-position: 0 0, 17px 17px;
  cursor: grab;
}

.viewport:focus {
  outline: 2px solid #1d5ea8;
  outline-offset: -2px;
}

.viewport.dragging {
  cursor: grabbing;
}

.viewport img {
  position: absolute;
  top: 50%;
  left: 50%;
  transform-origin: center center;
  max-width: none;
  user-select: none;
  -webkit-user-drag: none;
  will-change: transform;
}

.thumb-strip {
  flex: 1;
  min-width: 0;
  display: flex;
  gap: 0.4rem;
  overflow-x: auto;
  padding-bottom: 0.2rem;
}

.thumb-btn {
  flex: 0 0 84px;
  height: 52px;
  padding: 0;
  border: 2px solid transparent;
  border-radius: 9px;
  overflow: hidden;
  background: #fff;
  cursor: pointer;
}

.thumb-btn.active {
  border-color: #1d5ea8;
}

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

@media (max-width: 900px) {
  .stats {
    grid-template-columns: 1fr;
  }

  .viewer {
    width: 100vw;
    height: 100vh;
    max-width: 100vw;
    max-height: 100vh;
    border-radius: 0;
  }

  .viewer-top,
  .viewer-bottom {
    padding: 0.5rem;
  }

  .viewer-actions {
    gap: 0.35rem;
  }
}

@keyframes reveal {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}
