:root {
  --ink: #14181f;
  --muted: #5d6b7c;
  --line: #e4eaf1;
  --paper: #f4f6fa;
  --card: #ffffff;
  --blue: #1aa3ea;
  --blue-deep: #0878b8;
  --orange: #ff7a1a;
  --orange-deep: #e25f00;
  --black: #000000;
  --shadow: 0 10px 30px rgba(16, 24, 40, 0.08);
  --radius: 18px;
  --topbar: 72px;
  --font: "Outfit", "Segoe UI", sans-serif;
  --display: "Fraunces", Georgia, serif;
  color-scheme: light;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; overflow: hidden; }
html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: var(--font);
  color: var(--ink);
  background: var(--black);
}

button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
img { max-width: 100%; }
a { color: var(--blue-deep); }

:focus-visible {
  outline: 3px solid var(--orange);
  outline-offset: 2px;
}

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

.skip {
  position: absolute;
  left: 12px;
  top: -40px;
  z-index: 20;
  background: #fff;
  color: #000;
  padding: 8px 12px;
  border-radius: 8px;
}
.skip:focus { top: 8px; }

.app {
  height: 100dvh;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: var(--topbar);
  padding: 8px 14px;
  padding-top: calc(8px + env(safe-area-inset-top));
  background: var(--black);
  color: #fff;
  position: relative;
  z-index: 5;
}

.topbar::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--blue) 0 46%, var(--orange) 46% 100%);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  color: inherit;
  text-decoration: none;
}

.brand img {
  height: 48px;
  width: auto;
  display: block;
}

.tagline {
  margin: 0;
  max-width: 11rem;
  font-size: 13px;
  line-height: 1.25;
  color: rgba(255, 255, 255, 0.78);
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: none;
}

.count-pill {
  margin: 0;
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.01em;
  white-space: nowrap;
}

.lang {
  display: flex;
  padding: 3px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
}

.lang button {
  border: 0;
  background: transparent;
  color: rgba(255, 255, 255, 0.72);
  min-width: 36px;
  min-height: 32px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
}

.lang button[aria-pressed="true"] {
  background: #fff;
  color: #000;
}

.workspace {
  min-height: 0;
  min-width: 0;
  overflow: hidden;
  display: grid;
  grid-template-columns: 1fr;
  grid-template-rows: minmax(140px, 1fr) minmax(210px, 52dvh);
  grid-template-areas: "map" "panel";
}

.map-wrap { grid-area: map; position: relative; min-width: 0; min-height: 0; overflow: hidden; background: #d5e4ef; }
.panel { grid-area: panel; min-width: 0; }

#map { height: 100%; width: 100%; background: #d5e4ef; }

.map-tools {
  position: absolute;
  z-index: 500;
  top: 12px;
  right: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.map-tools button,
.peek-list {
  border: 0;
  background: #fff;
  color: var(--ink);
  box-shadow: 0 8px 20px rgba(16, 24, 40, 0.16);
}

.map-tools button {
  width: 44px;
  height: 44px;
  border-radius: 14px;
  display: grid;
  place-items: center;
}

.map-tools button svg,
.icon-btn svg,
.contact-row svg,
.nav-btn svg,
.peek-list svg { width: 20px; height: 20px; display: block; }

.map-tools button[aria-pressed="true"] {
  background: var(--blue);
  color: #fff;
}

#btnToList { display: none !important; }
.app.is-map #btnToList { display: grid !important; }

.leaflet-control-zoom a {
  width: 34px;
  height: 34px;
  line-height: 34px;
  border-radius: 10px !important;
}

.leaflet-bar {
  border: 0 !important;
  box-shadow: 0 8px 20px rgba(16, 24, 40, 0.16) !important;
}

.leaflet-tooltip.pin-tip {
  background: #111;
  color: #fff;
  border: 0;
  border-radius: 999px;
  padding: 5px 9px;
  font-family: var(--font);
  font-weight: 600;
  font-size: 12px;
  box-shadow: none;
}
.leaflet-tooltip.pin-tip::before { display: none; }

.leaflet-marker-icon.castle-pin-wrap {
  background: transparent;
  border: 0;
}

.castle-pin {
  width: 34px;
  height: 34px;
  margin: 0 auto;
  border-radius: 50% 50% 50% 0;
  background: linear-gradient(160deg, #49c4ff, #0b86d4);
  border: 2px solid #fff;
  box-shadow: 0 10px 16px rgba(0, 0, 0, 0.28);
  display: grid;
  place-items: center;
  transform: rotate(-45deg);
}

.castle-pin svg {
  width: 16px;
  height: 16px;
  transform: rotate(45deg);
}

.castle-pin-wrap.is-active .castle-pin {
  width: 42px;
  height: 42px;
  background: linear-gradient(160deg, #ffb067, #ef5d0c);
}

.castle-pin-wrap.is-active .castle-pin svg { width: 18px; height: 18px; }

.selected-chip {
  position: absolute;
  z-index: 500;
  left: 12px;
  right: 12px;
  bottom: 12px;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 10px 10px 14px;
  background: #fff;
  border-radius: 18px;
  box-shadow: 0 14px 40px rgba(16, 24, 40, 0.2);
}

.selected-chip strong,
.selected-chip span { display: block; }
.selected-chip strong {
  font-size: 15px;
  line-height: 1.2;
}
.selected-chip span {
  color: var(--muted);
  font-size: 13px;
}
.chip-copy { min-width: 0; flex: 1; }
.chip-copy strong,
.chip-copy span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.selected-chip .btn { flex: none; }

.panel {
  min-height: 0;
  display: flex;
  flex-direction: column;
  background: var(--paper);
  border-top: 1px solid var(--line);
}

.panel-body {
  min-height: 0;
  overflow: auto;
  padding: 16px 16px calc(20px + env(safe-area-inset-bottom));
  -webkit-overflow-scrolling: touch;
}

.peek-list {
  display: none;
  width: calc(100% - 24px);
  margin: 10px 12px calc(10px + env(safe-area-inset-bottom));
  min-height: 52px;
  border-radius: 16px;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-weight: 700;
}

.intro { position: relative; margin-bottom: 8px; }
.intro::before {
  content: "";
  position: absolute;
  width: 180px;
  height: 180px;
  right: -50px;
  top: -60px;
  background: radial-gradient(circle, rgba(255, 122, 26, 0.16), transparent 68%);
  pointer-events: none;
}

.kicker {
  margin: 0 0 6px;
  color: var(--orange-deep);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

h1, h2, .viewer-bar h2 {
  font-family: var(--display);
  font-weight: 560;
  letter-spacing: -0.03em;
}

h1 {
  margin: 0 0 8px;
  font-size: clamp(1.7rem, 1.2rem + 2vw, 2.45rem);
  line-height: 1.05;
  max-width: 16ch;
}

.lead, .cta p, .fineprint, .partner-info, .detail-info, #viewerDesc {
  color: var(--muted);
  line-height: 1.45;
}

.lead { margin: 0 0 14px; max-width: 38rem; }

.invite {
  margin: -4px 0 14px;
  font-weight: 600;
}
.invite a { color: var(--ink); text-underline-offset: 3px; }

.search {
  position: relative;
  display: block;
  margin-bottom: 12px;
}

.search input {
  width: 100%;
  min-height: 48px;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 14px;
  padding: 0 44px 0 14px;
  box-shadow: var(--shadow);
}

.search input::-webkit-search-cancel-button { appearance: none; }

.clear-search {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: 10px;
  background: var(--paper);
  font-size: 20px;
  line-height: 1;
}

.chips {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 4px;
  margin: 0 -16px 8px;
  padding-left: 16px;
  padding-right: 16px;
  scrollbar-width: none;
}
.chips::-webkit-scrollbar { display: none; }

.chips button {
  flex: none;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 999px;
  min-height: 36px;
  padding: 0 12px;
  color: var(--ink);
  font-size: 14px;
  font-weight: 600;
}

.chips button[aria-pressed="true"] {
  background: #111;
  border-color: #111;
  color: #fff;
}

.result-count {
  margin: 4px 0 10px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
}

.cards {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 10px;
}

.partner-card {
  width: 100%;
  display: flex;
  gap: 12px;
  align-items: center;
  text-align: left;
  padding: 10px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--card);
  box-shadow: var(--shadow);
}

.partner-card:hover { border-color: #c9d7e6; }
.partner-card.is-selected {
  border-color: #8dcef3;
  box-shadow: 0 0 0 3px rgba(26, 163, 234, 0.18);
}

.logo-slot {
  width: 86px;
  height: 64px;
  flex: none;
  border-radius: 12px;
  background: #fff;
  border: 1px solid var(--line);
  display: grid;
  place-items: center;
  overflow: hidden;
}

.logo-slot img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.monogram {
  font-family: var(--display);
  font-weight: 680;
  font-size: 20px;
  color: var(--blue-deep);
}

.partner-copy { min-width: 0; display: grid; gap: 2px; }
.partner-city {
  color: var(--blue-deep);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.02em;
}
.partner-name {
  font-size: 16px;
  font-weight: 700;
  line-height: 1.2;
}
.partner-info {
  font-size: 13px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.status-box, .empty-box {
  padding: 18px;
  border-radius: var(--radius);
  background: #fff;
  border: 1px dashed #cfd8e3;
  text-align: center;
}

.status-box p, .empty-box p { margin: 0 0 12px; }

.cta {
  margin-top: 18px;
  padding: 18px;
  border-radius: 22px;
  background: #000;
  color: #fff;
}

.cta h2 {
  margin: 0 0 8px;
  font-size: 1.55rem;
  line-height: 1.1;
  max-width: 16ch;
}

.cta p { color: rgba(255, 255, 255, 0.76); margin: 0 0 14px; }

.cta-actions, .detail-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.cta-direct {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
  margin: 12px 0 0;
  font-size: 14px;
}
.cta-direct a { color: #fff; font-weight: 600; }

.btn, .btn-orange, .btn-ghost, .btn-dark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 14px;
  border-radius: 12px;
  border: 0;
  text-decoration: none;
  font-weight: 700;
  text-align: center;
}

.btn-orange { background: var(--orange); color: #fff; }
.btn-orange:hover { background: var(--orange-deep); }
.btn-dark { background: #111; color: #fff; }
.btn-ghost {
  background: transparent;
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.28);
}
.btn-line {
  background: #fff;
  color: var(--ink);
  border: 1px solid var(--line);
}

.fineprint {
  margin: 14px 0 0;
  font-size: 12px;
}

.detail-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  position: sticky;
  top: -16px;
  z-index: 2;
  margin: -16px -16px 12px;
  padding: 10px 12px;
  background: rgba(244, 246, 250, 0.94);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}

.icon-btn {
  width: 42px;
  height: 42px;
  border: 0;
  border-radius: 12px;
  background: #fff;
  display: grid;
  place-items: center;
  box-shadow: var(--shadow);
}

.detail-kicker {
  margin: 0;
  text-align: center;
  font-size: 13px;
  font-weight: 700;
  color: var(--muted);
}

.logo-banner-wrap {
  height: 128px;
  border-radius: 18px;
  background: #fff;
  border: 1px solid var(--line);
  display: grid;
  place-items: center;
  overflow: hidden;
  margin-bottom: 14px;
}

.logo-banner-wrap img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.logo-banner-wrap .monogram { font-size: 36px; }

.detail-head h2 {
  margin: 0;
  font-size: clamp(1.6rem, 1.2rem + 1.4vw, 2.1rem);
  line-height: 1.08;
}

.detail-city {
  margin: 6px 0 0;
  color: var(--blue-deep);
  font-weight: 700;
}

.detail-info { margin: 12px 0; white-space: pre-wrap; }

.section-label {
  margin: 18px 0 8px;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.contact-list, .catalog-grid { display: grid; gap: 8px; }

.contact-row {
  width: 100%;
  min-height: 58px;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 12px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: #fff;
  text-align: left;
  text-decoration: none;
  color: inherit;
}

.contact-row small, .contact-row strong { display: block; }
.contact-row small {
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}
.contact-row strong { font-size: 15px; }
.contact-row .mark {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  background: #eef7fd;
  color: var(--blue-deep);
  flex: none;
}
.contact-row.is-loading { opacity: 0.6; }
.contact-row.is-empty {
  opacity: 0.55;
  cursor: default;
}

.catalog-btn { width: 100%; }

.catalog-grid { grid-template-columns: 1fr 1fr; }

.model-card {
  display: flex;
  flex-direction: column;
  padding: 0;
  overflow: hidden;
  border-radius: 16px;
  border: 1px solid var(--line);
  background: #fff;
  text-align: left;
  color: inherit;
  min-height: 100%;
}

.model-card img, .model-fallback {
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  background: #e9eef4;
}

.model-fallback {
  display: grid;
  place-items: center;
  color: var(--blue-deep);
}

.model-card span {
  padding: 8px 10px 12px;
  font-weight: 700;
  font-size: 14px;
  line-height: 1.25;
}

.warn {
  margin: 8px 0;
  padding: 10px 12px;
  border-radius: 12px;
  background: #fff4ec;
  color: #8a3d00;
  font-size: 14px;
}

#toast {
  position: fixed;
  z-index: 80;
  left: 50%;
  top: calc(var(--topbar) + 10px);
  transform: translateX(-50%) translateY(-8px);
  max-width: min(92vw, 420px);
  padding: 10px 14px;
  border-radius: 999px;
  background: #111;
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
}
#toast.is-on {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

#viewer {
  width: min(640px, calc(100vw - 24px));
  max-height: min(92dvh, 920px);
  padding: 0;
  border: 0;
  border-radius: 22px;
  color: var(--ink);
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.35);
}

#viewer::backdrop { background: rgba(6, 8, 12, 0.66); }

.viewer-bar {
  display: grid;
  grid-template-columns: 42px 1fr 42px;
  gap: 8px;
  align-items: center;
  padding: 12px;
}

.viewer-bar h2 {
  margin: 0;
  font-size: 1.25rem;
  line-height: 1.15;
  text-align: center;
}

.stage {
  position: relative;
  background: #111;
  min-height: 220px;
  display: grid;
  place-items: center;
}

.stage img {
  width: 100%;
  max-height: 52dvh;
  object-fit: contain;
  background: #111;
}

.nav-btn {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 42px;
  height: 42px;
  border: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.92);
  display: grid;
  place-items: center;
}
#photoPrev { left: 10px; }
#photoNext { right: 10px; }

.stage-status {
  position: absolute;
  margin: 0;
  color: #fff;
  background: rgba(0, 0, 0, 0.45);
  padding: 8px 12px;
  border-radius: 999px;
}

.thumbs {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 10px 12px;
  background: #f7f8fb;
}

.thumbs button {
  flex: none;
  width: 64px;
  height: 48px;
  padding: 0;
  border-radius: 8px;
  border: 2px solid transparent;
  background: #fff;
  overflow: hidden;
}
.thumbs button[aria-current="true"] { border-color: var(--orange); }
.thumbs img { width: 100%; height: 100%; object-fit: cover; display: block; }

.viewer-copy { padding: 4px 16px 18px; }
#viewerDesc { margin: 0 0 8px; white-space: pre-wrap; }
.photo-count { margin: 0; color: var(--muted); font-size: 13px; font-weight: 600; }

@media (max-width: 719px) {
  .tagline, .count-pill { display: none; }
}

@media (max-width: 380px) {
  .brand img { height: 42px; }
  .catalog-grid { grid-template-columns: 1fr; }
}

@media (max-width: 979px) {
  .app.is-map .workspace { grid-template-rows: minmax(0, 1fr) auto; }
  .app.is-detail .workspace { grid-template-rows: minmax(0, 1fr); }
  .app.is-detail .map-wrap { display: none; }
  .app.is-map .peek-list { display: flex; }
  .app.is-map .panel-body,
  .app.is-detail #viewList { display: none; }
  #viewer {
    position: fixed;
    inset: 0;
    width: 100%;
    max-width: none;
    height: 100dvh;
    max-height: none;
    margin: 0;
    border-radius: 0;
  }
}

@media (min-width: 980px) {
  .workspace,
  .app.is-map .workspace,
  .app.is-detail .workspace {
    grid-template-columns: minmax(360px, 440px) minmax(0, 1fr);
    grid-template-rows: minmax(0, 1fr);
    grid-template-areas: "panel map";
  }

  .app.is-detail .map-wrap { display: block; }
  .only-mobile { display: none !important; }
  .panel { border-top: 0; border-right: 1px solid #1c1c1c; }
  .panel-body { padding: 22px 22px 28px; }
  .app.is-detail #viewList { display: none; }
  .detail-bar { top: -22px; margin: -22px -22px 14px; padding: 12px; }
  .selected-chip { left: auto; width: min(420px, calc(100% - 24px)); }
  .catalog-grid { grid-template-columns: 1fr 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  * { scroll-behavior: auto !important; transition: none !important; }
}
