:root {
  --navy: #061b34;
  --navy-soft: rgba(6, 27, 52, 0.26);
  --gold: #d7a842;
  --paper: #f7f4ec;
  --ink: #07172d;
  --teal: #0d6f73;
  --shadow: 0 18px 46px rgba(0, 0, 0, 0.24);
}

* {
  box-sizing: border-box;
}

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

body {
  overflow: hidden;
  background: var(--navy);
  color: var(--ink);
  font-family: Tahoma, Arial, sans-serif;
}

button,
a {
  font: inherit;
}

.site-viewer,
.page {
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  min-height: 100svh;
}

.site-viewer {
  position: relative;
  overflow: hidden;
}

.page {
  position: absolute;
  inset: 0;
  display: none;
}

.page.is-active {
  display: block;
}

.image-page {
  background: var(--navy);
}

.image-page img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  user-select: none;
  -webkit-user-drag: none;
}

.form-page {
  cursor: pointer;
}

.listings-page {
  overflow: auto;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.9), rgba(247, 244, 236, 0.98)),
    radial-gradient(circle at top right, rgba(215, 168, 66, 0.2), transparent 34%),
    var(--paper);
}

.listings-content {
  width: min(1120px, 100%);
  min-height: 100%;
  margin: 0 auto;
  padding: max(24px, env(safe-area-inset-top)) 14px calc(112px + env(safe-area-inset-bottom));
}

.listings-header {
  margin: 0 0 18px;
  padding: 10px 2px 0;
  color: var(--navy);
  text-align: center;
}

.listings-header p {
  margin: 0 0 6px;
  color: var(--teal);
  font-size: 0.92rem;
  font-weight: 800;
}

.listings-header h1 {
  margin: 0;
  font-size: clamp(1.7rem, 8vw, 3.2rem);
  line-height: 1.1;
}

.listing-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}

.listing-card {
  display: grid;
  grid-template-columns: 88px 1fr;
  min-height: 154px;
  overflow: hidden;
  border: 1px solid rgba(6, 27, 52, 0.14);
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 12px 30px rgba(6, 27, 52, 0.1);
}

.listing-photo {
  appearance: none;
  border: 0;
  display: grid;
  place-items: center;
  position: relative;
  min-width: 0;
  margin: 0;
  padding: 0;
  background:
    linear-gradient(145deg, rgba(6, 27, 52, 0.96), rgba(13, 111, 115, 0.86)),
    var(--navy);
  color: var(--gold);
  cursor: default;
  font-size: 1.35rem;
  font-weight: 900;
  overflow: hidden;
}

.listing-photo img {
  position: absolute;
  inset: 0;
  display: none;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.listing-photo.has-images {
  cursor: zoom-in;
}

.listing-photo.has-images img {
  display: block;
}

.listing-photo.has-images .listing-photo-number {
  display: none;
}

.listing-photo:focus-visible {
  outline: 3px solid var(--gold);
  outline-offset: -5px;
}

.listing-photo:disabled {
  opacity: 1;
}

.listing-body {
  min-width: 0;
  padding: 14px 14px 12px;
}

.listing-body h2 {
  margin: 0 0 10px;
  color: var(--navy);
  font-size: 1.1rem;
  line-height: 1.25;
}

.listing-body dl {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px 10px;
  margin: 0;
}

.listing-body div {
  min-width: 0;
}

.listing-body dt {
  margin: 0 0 2px;
  color: #657186;
  font-size: 0.75rem;
  font-weight: 700;
}

.listing-body dd {
  margin: 0;
  color: var(--ink);
  font-size: 0.95rem;
  font-weight: 800;
  overflow-wrap: anywhere;
}

.page-controls {
  position: fixed;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 8;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  grid-template-areas: "prev indicator next";
  gap: 10px;
  align-items: center;
  direction: ltr;
  padding: 14px 14px calc(14px + env(safe-area-inset-bottom));
  pointer-events: none;
}

.control-button,
.page-indicator {
  border: 1px solid rgba(255, 255, 255, 0.34);
  border-radius: 8px;
  background: var(--navy-soft);
  color: #fff;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.14);
  backdrop-filter: blur(8px);
  direction: rtl;
}

.control-button {
  width: min(38vw, 220px);
  min-height: 48px;
  padding: 10px 12px;
  cursor: pointer;
  font-size: 0.95rem;
  font-weight: 900;
  pointer-events: auto;
}

.control-button:active {
  transform: translateY(1px);
}

.control-button:focus-visible,
.gallery-close:focus-visible,
.gallery-numbers button:focus-visible {
  outline: 3px solid var(--gold);
  outline-offset: 3px;
}

.control-button:disabled {
  cursor: default;
  opacity: 0.5;
}

.prev-button {
  grid-area: prev;
  justify-self: start;
}

.next-button {
  grid-area: next;
  justify-self: end;
}

.page-indicator {
  grid-area: indicator;
  min-width: 68px;
  padding: 10px 12px;
  text-align: center;
  font-size: 0.86rem;
  font-weight: 900;
}

.gallery-modal {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  gap: 14px;
  align-items: center;
  justify-items: center;
  direction: ltr;
  padding: calc(18px + env(safe-area-inset-top)) 14px calc(18px + env(safe-area-inset-bottom));
  background: rgba(2, 8, 18, 0.9);
}

.gallery-modal[hidden] {
  display: none;
}

.gallery-close {
  justify-self: end;
  min-width: 78px;
  min-height: 42px;
  border: 1px solid rgba(255, 255, 255, 0.5);
  border-radius: 8px;
  background: rgba(6, 27, 52, 0.72);
  color: #fff;
  cursor: pointer;
  direction: rtl;
  font-weight: 900;
}

.gallery-view {
  display: grid;
  place-items: center;
  width: min(100%, 980px);
  height: min(74vh, 760px);
  min-height: 240px;
}

.gallery-view img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.gallery-numbers {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  max-width: min(100%, 760px);
}

.gallery-numbers button {
  min-width: 42px;
  min-height: 38px;
  border: 1px solid rgba(255, 255, 255, 0.46);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  cursor: pointer;
  font-weight: 900;
}

.gallery-numbers button.is-active {
  border-color: var(--gold);
  background: var(--gold);
  color: var(--navy);
}

@media (min-width: 700px) {
  .image-page img {
    object-fit: contain;
  }

  .listings-content {
    padding-right: 28px;
    padding-left: 28px;
  }

  .listing-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
  }

  .listing-card {
    grid-template-columns: 104px 1fr;
  }
}

@media (min-width: 1040px) {
  .listing-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 360px) {
  .page-controls {
    gap: 6px;
    padding-right: 10px;
    padding-left: 10px;
  }

  .control-button {
    width: 36vw;
    min-height: 44px;
    padding-right: 10px;
    padding-left: 10px;
    font-size: 0.78rem;
  }

  .page-indicator {
    min-width: 58px;
    padding-right: 8px;
    padding-left: 8px;
    font-size: 0.78rem;
  }

  .listing-card {
    grid-template-columns: 72px 1fr;
  }
}
