:root {
  color-scheme: light;
  --bg: #f8fbff;
  --paper: #ffffff;
  --surface: #ffffff;
  --surface-soft: #f0f5fa;
  --ink: #28323d;
  --muted: #798aa3;
  --muted-strong: #5c6f86;
  --line: #dde7f0;
  --line-strong: #c5d2e0;
  --brand: #2686ea;
  --brand-dark: #1e6fd7;
  --brand-bright: #2dc6f0;
  --accent: #f6b940;
  --red: #d92d20;
  --shadow: 0 18px 48px rgba(38, 134, 234, 0.14);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.96), rgba(248, 251, 255, 0.98)),
    radial-gradient(circle at 16% 10%, rgba(45, 198, 240, 0.18), transparent 28%),
    radial-gradient(circle at 82% 4%, rgba(38, 134, 234, 0.18), transparent 30%),
    var(--bg);
  color: var(--ink);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

button,
input {
  font: inherit;
}

button {
  border: 0;
}

a {
  color: inherit;
}

.app-shell {
  min-height: 100vh;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  min-height: 72px;
  padding: 0 clamp(18px, 4vw, 56px);
  border-bottom: 1px solid rgba(221, 231, 240, 0.9);
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(16px);
}

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

.brand-logo {
  width: auto;
  height: 34px;
  display: block;
  object-fit: contain;
}

.brand-copy {
  display: grid;
  gap: 2px;
}

.brand-copy strong {
  font-size: 16px;
  font-weight: 900;
  line-height: 1;
}

.brand-copy small {
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
}

.top-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 18px;
  min-width: 0;
}

.top-actions a {
  color: var(--muted-strong);
  font-size: 13px;
  font-weight: 800;
  text-decoration: none;
  white-space: nowrap;
}

.api-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 34px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.72);
  color: var(--muted-strong);
  font-size: 12px;
  font-weight: 850;
  white-space: nowrap;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
}

.api-pill.ready {
  color: var(--brand);
}

.api-pill.ready .status-dot {
  background: var(--brand);
}

.api-pill.error {
  color: var(--red);
}

.api-pill.error .status-dot {
  background: var(--red);
}

main {
  width: min(1360px, 100%);
  margin: 0 auto;
  padding: clamp(22px, 4vw, 48px) clamp(18px, 4vw, 56px) 56px;
}

.hero {
  min-height: calc(100vh - 112px);
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(360px, 460px);
  align-items: center;
  gap: clamp(24px, 5vw, 64px);
  padding-bottom: 26px;
}

.hero-copy {
  max-width: 760px;
}

.eyebrow,
h1,
h2,
p {
  margin: 0;
}

.eyebrow {
  color: var(--brand);
  font-size: 12px;
  font-weight: 950;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1 {
  margin-top: 14px;
  max-width: 740px;
  font-size: clamp(48px, 7vw, 86px);
  line-height: 0.96;
  letter-spacing: 0;
}

.hero-lead {
  margin-top: 20px;
  max-width: 560px;
  color: var(--muted-strong);
  font-size: clamp(17px, 2vw, 21px);
  line-height: 1.45;
}

.search-panel {
  display: grid;
  gap: 16px;
  padding: 16px;
  border: 1px solid rgba(221, 231, 240, 0.95);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: var(--shadow);
}

.selected-event {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 48px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper);
}

.selected-event span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 850;
  text-transform: uppercase;
}

.selected-event strong {
  min-width: 0;
  overflow: hidden;
  color: var(--ink);
  font-size: 14px;
  font-weight: 900;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.upload-zone {
  position: relative;
  min-height: 254px;
  display: block;
  overflow: hidden;
  border: 1px dashed var(--line-strong);
  border-radius: 8px;
  background:
    linear-gradient(135deg, rgba(45, 198, 240, 0.1), rgba(38, 134, 234, 0.1)),
    var(--surface-soft);
  cursor: pointer;
}

.upload-zone.dragging {
  border-color: var(--brand);
  background: rgba(38, 134, 234, 0.08);
}

.upload-zone input {
  position: absolute;
  inset: 0;
  z-index: 5;
  opacity: 0;
  cursor: pointer;
}

.upload-empty {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 9px;
  padding: 24px;
  text-align: center;
}

.upload-empty.has-preview {
  opacity: 0;
}

.upload-empty svg,
.primary-button svg,
.ghost-button svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
}

.upload-empty svg {
  width: 34px;
  height: 34px;
  color: var(--brand);
}

.upload-empty strong {
  max-width: 100%;
  overflow: hidden;
  font-size: 16px;
  font-weight: 900;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.upload-empty small {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

#previewImage {
  position: relative;
  z-index: 1;
  display: block;
  width: 100%;
  height: 254px;
  object-fit: cover;
  background: var(--ink);
}

.threshold-row {
  display: grid;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper);
}

.threshold-row > div {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.threshold-row label {
  color: var(--muted-strong);
  font-size: 13px;
  font-weight: 850;
}

.threshold-row strong {
  color: var(--brand);
  font-size: 16px;
  font-variant-numeric: tabular-nums;
  font-weight: 950;
}

input[type="range"] {
  width: 100%;
  accent-color: var(--brand);
}

.primary-button,
.ghost-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  min-height: 48px;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 900;
  transition:
    background-color 140ms ease,
    border-color 140ms ease,
    color 140ms ease,
    transform 140ms ease;
}

.primary-button {
  background: var(--brand);
  color: var(--paper);
}

.primary-button:hover:not(:disabled) {
  background: var(--brand-dark);
  transform: translateY(-1px);
}

.primary-button:disabled {
  cursor: not-allowed;
  background: #b9b5ab;
}

.ghost-button {
  min-width: 128px;
  padding: 0 14px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--muted-strong);
}

.ghost-button:hover {
  border-color: var(--line-strong);
  background: var(--paper);
}

.metrics-strip {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--line);
}

.metrics-strip div {
  display: grid;
  gap: 4px;
  min-height: 82px;
  align-content: center;
  padding: 14px 18px;
  background: rgba(255, 255, 255, 0.78);
}

.metrics-strip span {
  font-size: 27px;
  font-variant-numeric: tabular-nums;
  font-weight: 950;
  line-height: 1;
}

.metrics-strip small {
  color: var(--muted);
  font-size: 12px;
  font-weight: 850;
  text-transform: uppercase;
}

.section-block {
  margin-top: 28px;
}

.section-head {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 16px;
}

h2 {
  margin-top: 6px;
  font-size: clamp(25px, 3vw, 36px);
  line-height: 1.08;
  letter-spacing: 0;
}

.section-head p:not(.eyebrow) {
  margin-top: 7px;
  color: var(--muted);
  font-size: 14px;
}

.collection-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 14px;
}

.collection-card {
  min-width: 0;
  display: grid;
  grid-template-columns: 62px minmax(0, 1fr);
  grid-template-areas:
    "art body"
    "art count";
  gap: 10px 13px;
  min-height: 126px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.82);
  color: var(--ink);
  text-align: left;
  cursor: pointer;
  box-shadow: 0 1px 0 rgba(21, 20, 20, 0.03);
  transition:
    border-color 140ms ease,
    box-shadow 140ms ease,
    transform 140ms ease;
}

.collection-card:hover,
.collection-card.selected {
  border-color: rgba(38, 134, 234, 0.5);
  box-shadow: 0 14px 34px rgba(38, 134, 234, 0.14);
  transform: translateY(-2px);
}

.collection-card.selected {
  background:
    linear-gradient(135deg, rgba(38, 134, 234, 0.1), rgba(255, 255, 255, 0.96)),
    var(--surface);
}

.collection-art {
  grid-area: art;
  width: 62px;
  height: 98px;
  display: grid;
  place-items: center;
  overflow: hidden;
  border-radius: 8px;
  background:
    linear-gradient(140deg, rgba(45, 198, 240, 0.92), rgba(30, 111, 215, 0.9)),
    var(--brand);
}

.collection-card:nth-child(3n + 2) .collection-art {
  background:
    linear-gradient(140deg, rgba(38, 134, 234, 0.92), rgba(45, 198, 240, 0.86)),
    var(--brand);
}

.collection-card:nth-child(3n) .collection-art {
  background:
    linear-gradient(140deg, rgba(30, 111, 215, 0.92), rgba(38, 134, 234, 0.86)),
    var(--brand-dark);
}

.collection-art span {
  color: var(--paper);
  font-size: 19px;
  font-weight: 950;
}

.collection-body {
  grid-area: body;
  min-width: 0;
  display: grid;
  align-content: start;
  gap: 6px;
}

.collection-body strong,
.collection-body small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.collection-body strong {
  font-size: 16px;
  font-weight: 950;
}

.collection-body small {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.collection-count {
  grid-area: count;
  width: max-content;
  max-width: 100%;
  align-self: end;
  overflow: hidden;
  padding: 6px 9px;
  border-radius: 8px;
  background: var(--surface-soft);
  color: var(--muted-strong);
  font-size: 12px;
  font-weight: 900;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.results-section {
  padding-bottom: 12px;
}

.result-count {
  min-width: 54px;
  height: 46px;
  display: inline-grid;
  place-items: center;
  border: 1px solid rgba(38, 134, 234, 0.18);
  border-radius: 8px;
  background: rgba(38, 134, 234, 0.08);
  color: var(--brand);
  font-size: 20px;
  font-variant-numeric: tabular-nums;
  font-weight: 950;
}

.notice {
  margin: 12px 0 0;
  padding: 12px 14px;
  border: 1px solid rgba(201, 53, 53, 0.2);
  border-radius: 8px;
  background: #fff4f2;
  color: var(--red);
  font-size: 13px;
  font-weight: 750;
  line-height: 1.4;
}

.results-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 14px;
  margin-top: 16px;
}

.result-card {
  min-width: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  transition:
    border-color 140ms ease,
    box-shadow 140ms ease,
    transform 140ms ease;
}

.result-card:hover {
  border-color: var(--line-strong);
  box-shadow: 0 14px 34px rgba(21, 20, 20, 0.11);
  transform: translateY(-2px);
}

.thumb-link {
  position: relative;
  display: block;
  aspect-ratio: 4 / 3;
  overflow: hidden;
  background: var(--ink);
  text-decoration: none;
}

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

.thumb-fallback {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: rgba(255, 253, 248, 0.74);
  font-size: 11px;
  font-weight: 900;
  text-transform: uppercase;
}

.thumb-fallback[hidden] {
  display: none;
}

.result-body {
  display: grid;
  gap: 10px;
  padding: 12px;
}

.result-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.match-rank {
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
}

.similarity {
  color: var(--brand);
  font-size: 13px;
  font-variant-numeric: tabular-nums;
  font-weight: 950;
}

.image-link {
  min-height: 38px;
  color: var(--ink);
  font-size: 13px;
  line-height: 1.35;
  overflow-wrap: anywhere;
  text-decoration-color: rgba(21, 20, 20, 0.28);
}

.empty-state {
  grid-column: 1 / -1;
  min-height: 190px;
  display: grid;
  place-items: center;
  padding: 24px;
  border: 1px dashed var(--line-strong);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.56);
  color: var(--muted);
  font-size: 14px;
  font-weight: 850;
  text-align: center;
}

.empty-state--hint {
  display: block;
  place-items: unset;
  padding: 28px 32px;
  text-align: left;
  font-weight: 500;
  line-height: 1.5;
}

.empty-state__title {
  display: block;
  margin-bottom: 8px;
  font-size: 16px;
  font-weight: 850;
  color: var(--ink, #28323d);
}

.empty-state__lead {
  margin: 0 0 12px;
  color: var(--muted);
}

.empty-state__tips {
  margin: 0;
  padding-left: 20px;
  display: grid;
  gap: 6px;
  color: var(--muted);
}

@media (max-width: 980px) {
  .hero {
    min-height: auto;
    grid-template-columns: 1fr;
  }

  .search-panel {
    max-width: 560px;
  }
}

@media (max-width: 720px) {
  .topbar {
    align-items: flex-start;
    flex-direction: column;
    gap: 12px;
    padding-top: 14px;
    padding-bottom: 14px;
  }

  .top-actions {
    width: 100%;
    justify-content: space-between;
    gap: 12px;
  }

  .top-actions a {
    display: none;
  }

  main {
    padding-inline: 16px;
  }

  h1 {
    font-size: 42px;
  }

  .metrics-strip {
    grid-template-columns: 1fr;
  }

  .section-head {
    align-items: stretch;
    flex-direction: column;
  }

  .ghost-button,
  .primary-button {
    width: 100%;
  }

  .collection-grid,
  .results-grid {
    grid-template-columns: 1fr;
  }
}

/* --- Botão "Ver landmarks" sobre o preview ------------------------------ */
.preview-frame {
  position: relative;
}

.preview-close {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 2;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border: none;
  border-radius: 50%;
  background: rgba(20, 27, 35, 0.6);
  color: #fff;
  font-size: 15px;
  font-weight: 900;
  line-height: 1;
  cursor: pointer;
  backdrop-filter: blur(4px);
  transition: background 0.15s ease, transform 0.15s ease;
}

.preview-close:hover {
  background: var(--brand);
  transform: scale(1.08);
}

.landmark-button {
  width: 100%;
  margin-top: 4px;
}

.landmark-button svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* --- Modal de landmarks (imagem + X, nada mais) ------------------------- */
.lm-modal {
  position: fixed;
  inset: 0;
  z-index: 60;
}

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

.lm-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(20, 27, 35, 0.82);
}

.lm-dialog {
  position: absolute;
  inset: 0;
}

.lm-close {
  position: absolute;
  top: 16px;
  right: 16px;
  z-index: 3;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border: 1px solid rgba(255, 255, 255, 0.55);
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.14);
  color: #fff;
  font-size: 20px;
  font-weight: 900;
  line-height: 1;
  cursor: pointer;
  backdrop-filter: blur(4px);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.4);
  transition: background 0.15s ease, transform 0.15s ease;
}

.lm-close:hover {
  background: var(--brand);
  border-color: var(--brand);
  transform: scale(1.05);
}

.lm-stage {
  position: absolute;
  inset: 0;
  overflow: hidden;
  cursor: grab;
  touch-action: none;
}

.lm-stage.dragging {
  cursor: grabbing;
}

.lm-frame {
  position: absolute;
  top: 0;
  left: 0;
  transform-origin: 0 0;
  will-change: transform;
}

.lm-frame canvas {
  display: block;
  width: 100%;
  height: 100%;
}

.lm-loading {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 2;
  padding: 8px 14px;
  border-radius: 999px;
  background: rgba(20, 27, 35, 0.7);
  color: #fff;
  font-size: 13px;
  font-weight: 800;
  pointer-events: none;
}
