* { box-sizing: border-box; }

:root {
  --fg: #fff;
  --bg: #000;
  --dim: #a6a6a6;
  --line: 1px solid var(--fg);
  font-family: Courier, serif;
  color: var(--fg);
  background: var(--bg);
  line-height: 1.4;
  color-scheme: dark;
}

html, body { height: 100%; }
body { margin: 0; overflow: hidden; overscroll-behavior: none; }
button, input { font: inherit; color: inherit; border-radius: 0; }
button { cursor: pointer; background: var(--bg); border: var(--line); min-height: 44px; padding: 8px 12px; letter-spacing: .06em; }
button[aria-pressed="true"] { color: var(--bg); background: var(--fg); }
button:focus-visible, input:focus-visible, a:focus-visible, .viewport:focus-visible, .panel:focus-visible { outline: 2px solid var(--fg); outline-offset: 2px; }
a { color: inherit; text-underline-offset: 4px; }
p, h1, h2 { margin: 0; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.skip-link { position: absolute; left: 8px; top: -80px; z-index: 50; padding: 12px; background: var(--fg); color: var(--bg); }
.skip-link:focus { top: 8px; }

/* Estrutura: no celular, coluna única; a lista ocupa a célula do mapa quando aberta. */
.app { display: grid; grid-template-columns: minmax(0, 1fr); grid-template-rows: auto auto minmax(0, 1fr) auto; height: 100vh; height: 100dvh; }
.top { grid-row: 1; display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 10px 16px; border-bottom: var(--line); }
.brand { line-height: 0; }
.brand img { display: block; height: 40px; width: auto; }
.floors { display: flex; align-items: center; gap: 10px; font-size: 12px; letter-spacing: .08em; }
.floor-buttons { display: flex; }
.floor-buttons button { min-width: 44px; }
.floor-buttons button + button { border-left: 0; }

.searchbar { grid-row: 2; display: flex; border-bottom: var(--line); }
.searchbar input { flex: 1; min-width: 0; height: 48px; padding: 0 16px; border: 0; background: var(--bg); font-size: 16px; letter-spacing: .04em; }
.searchbar input::placeholder { color: var(--dim); font-size: 12px; letter-spacing: .08em; }
.searchbar input::-webkit-search-cancel-button { filter: grayscale(1) invert(1); }
.toggle-panel { border: 0; border-left: var(--line); min-width: 84px; font-size: 12px; }

.map-area { grid-row: 3; grid-column: 1; position: relative; min-height: 0; overflow: hidden; }
.foot { grid-row: 4; grid-column: 1; display: flex; align-items: center; gap: 12px; padding: 0 0 env(safe-area-inset-bottom, 0px); border-top: var(--line); }
.sponsors { --logo-height: 48px; flex: 1; min-width: 0; display: grid; grid-template-columns: 96px minmax(0, 1fr) auto; align-items: center; }
.sponsor-role { padding-left: 16px; font-size: 10px; letter-spacing: .1em; color: var(--dim); }
.sponsor-stage { position: relative; height: calc(var(--logo-height) + 20px); cursor: pointer; }
.sponsor-logo { position: absolute; left: 50%; top: 50%; height: calc(var(--logo-height) * var(--fill)); width: calc(var(--logo-height) * var(--fill) * var(--ratio)); max-width: calc(100% - 32px); transform: translate(-50%, -50%); opacity: 0; transition: opacity 320ms; }
.sponsor-logo.on { opacity: 1; }
.sponsor-toggle { align-self: stretch; min-width: 48px; border: 0; border-left: var(--line); font-size: 11px; }
.credits { display: none; flex-shrink: 0; font-size: 10px; letter-spacing: .06em; color: var(--dim); }

.panel { grid-row: 3 / 5; grid-column: 1; z-index: 20; display: none; flex-direction: column; min-height: 0; background: var(--bg); }
body[data-panel="open"] .panel { display: flex; }
.panel-tools { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 8px 16px; border-bottom: var(--line); }
.panel-tools button { min-height: 36px; padding: 4px 10px; font-size: 12px; }
.count { font-size: 12px; letter-spacing: .08em; text-transform: uppercase; }
.work-list { flex: 1; min-height: 0; margin: 0; padding: 0; list-style: none; overflow-y: auto; overscroll-behavior: contain; }
.row { display: grid; grid-template-columns: 40px minmax(0, 1fr); align-items: baseline; gap: 8px; width: 100%; min-height: 56px; padding: 10px 16px; border: 0; border-bottom: 1px solid #333; text-align: left; letter-spacing: 0; }
.row:hover { background: #161616; }
.row[aria-current="true"] { background: var(--fg); color: var(--bg); }
.row-number { font-size: 14px; font-weight: 700; }
.row-title { display: block; font-size: 15px; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-artist { display: block; font-size: 13px; color: var(--dim); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row[aria-current="true"] .row-artist { color: #333; }
.empty { padding: 24px 16px; font-size: 14px; color: var(--dim); }

/* Mapa */
.viewport { position: absolute; inset: 0; overflow: hidden; touch-action: none; cursor: grab; user-select: none; -webkit-user-select: none; }
.viewport[data-dragging="true"] { cursor: grabbing; }
.viewport[data-hover="true"] { cursor: pointer; }
.stage {
  position: absolute; left: 0; top: 0; transform-origin: 0 0; will-change: transform;
  background-image:
    linear-gradient(to right, rgba(255, 255, 255, .2) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(255, 255, 255, .2) 1px, transparent 1px),
    linear-gradient(to right, rgba(255, 255, 255, .08) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(255, 255, 255, .08) 1px, transparent 1px);
  background-size:
    calc(100px * var(--s, 1)) calc(100px * var(--s, 1)), calc(100px * var(--s, 1)) calc(100px * var(--s, 1)),
    calc(20px * var(--s, 1)) calc(20px * var(--s, 1)), calc(20px * var(--s, 1)) calc(20px * var(--s, 1));
}
.viewport[data-density="dots"] .stage { background-size: calc(100px * var(--s, 1)) calc(100px * var(--s, 1)), calc(100px * var(--s, 1)) calc(100px * var(--s, 1)), 0 0, 0 0; }
.plan, .labels, .markers { position: absolute; inset: 0; }
.plan svg { display: block; width: 100%; height: 100%; overflow: visible; }
.plan svg :is(path, rect, line, polyline) { vector-effect: non-scaling-stroke; }
.labels, .plan { pointer-events: none; }

.map-label { position: absolute; transform: translate(-50%, -50%); padding: 0 4px; background: var(--bg); color: var(--dim); font-size: 10px; letter-spacing: .1em; white-space: nowrap; }
.map-label.major { background: transparent; color: #6f6f6f; font-size: 13px; letter-spacing: .3em; }
.viewport[data-density="dots"] .map-label:not(.major) { display: none; }
.viewport[data-density="dots"] .map-label.major { font-size: 9px; letter-spacing: .12em; }
.viewport[data-density="large"] .map-label { font-size: 12px; }
.viewport[data-density="large"] .map-label.major { font-size: 18px; }

.marker {
  position: absolute; transform: translate(-50%, -50%); display: grid; place-items: center;
  min-width: 22px; min-height: 0; height: 15px; padding: 0 2px; border: 1px solid var(--fg);
  background: var(--bg); color: var(--fg); font-size: 10px; font-weight: 700; line-height: 1; letter-spacing: 0;
  pointer-events: none; transition: opacity 160ms;
}
.marker[data-level="mezzanine"] { border-style: dashed; }
.marker.dim { opacity: .2; }
.viewport[data-density="dots"] .marker { min-width: 0; width: 7px; height: 7px; padding: 0; font-size: 0; background: var(--fg); }
.viewport[data-density="dots"] .marker[data-level="mezzanine"] { background: var(--bg); border-style: solid; }
.viewport[data-density="large"] .marker { min-width: 30px; height: 20px; font-size: 13px; }
.marker[aria-pressed="true"], .viewport[data-density="dots"] .marker[aria-pressed="true"] {
  z-index: 2; width: auto; min-width: 30px; height: 20px; padding: 0 3px; font-size: 13px;
  background: var(--fg); color: var(--bg); border-style: solid; opacity: 1;
  outline: 2px solid var(--fg); outline-offset: 3px;
}
.marker:focus-visible { z-index: 3; outline: 2px solid var(--fg); outline-offset: 3px; }

.places { position: absolute; z-index: 5; top: 0; left: 0; right: 0; display: flex; gap: 6px; padding: 8px 16px; overflow-x: auto; scrollbar-width: none; background: linear-gradient(to bottom, var(--bg) 60%, transparent); }
.places::-webkit-scrollbar { display: none; }
.places button { flex-shrink: 0; min-height: 36px; padding: 4px 10px; font-size: 11px; }
.places:empty { display: none; }

.minimap { position: absolute; z-index: 4; right: 10px; top: 60px; height: min(240px, 42%); aspect-ratio: var(--ratio, 360 / 1780); border: var(--line); background: var(--bg); touch-action: none; cursor: crosshair; }
.minimap img { display: block; width: 100%; height: 100%; opacity: .7; pointer-events: none; }
.minimap-dots { position: absolute; inset: 0; pointer-events: none; }
.minimap-dots i { position: absolute; width: 2px; height: 2px; margin: -1px 0 0 -1px; background: var(--fg); }
.minimap-dots i.on { z-index: 1; width: 8px; height: 8px; margin: -4px 0 0 -4px; outline: 1px solid var(--bg); }
.minimap-window { position: absolute; border: 1px solid var(--fg); background: rgba(255, 255, 255, .22); pointer-events: none; }

.zoom { position: absolute; z-index: 4; right: 10px; bottom: 12px; display: flex; flex-direction: column; }
.zoom button { width: 48px; padding: 0; font-size: 18px; }
.zoom button + button { border-top: 0; }
.zoom #zoom-all { font-size: 10px; }
.legend { position: absolute; z-index: 3; left: 16px; bottom: 12px; display: flex; align-items: center; gap: 6px; padding: 2px 6px; background: var(--bg); color: var(--dim); font-size: 10px; letter-spacing: .08em; }
.legend span { display: inline-block; width: 12px; height: 9px; border: 1px solid var(--fg); }
.legend .legend-mezzanine { margin-left: 8px; border-style: dashed; }
.map-status { position: absolute; z-index: 3; left: 16px; right: 16px; top: 45%; text-align: center; font-size: 14px; color: var(--dim); pointer-events: none; }
.tooltip { position: fixed; z-index: 30; max-width: 280px; padding: 4px 8px; border: var(--line); background: var(--bg); font-size: 12px; pointer-events: none; transform: translate(-50%, calc(-100% - 16px)); }

/* Cartão da obra: faixa inferior no celular, painel lateral em telas largas. */
.card { position: fixed; z-index: 25; left: 0; right: 0; bottom: 0; display: flex; flex-direction: column; max-height: 82vh; max-height: 82dvh; background: var(--bg); border-top: var(--line); padding-bottom: env(safe-area-inset-bottom, 0px); }
.card-nav { display: flex; align-items: center; border-bottom: var(--line); }
.card-nav button { border: 0; min-width: 52px; font-size: 18px; }
.card-nav #prev { border-right: var(--line); }
.card-nav #next { border-left: var(--line); border-right: var(--line); }
.card-position { flex: 0 0 auto; min-width: 92px; padding: 0 8px; text-align: center; font-size: 13px; letter-spacing: .08em; }
.card-close { margin-left: auto; font-size: 24px !important; line-height: 1; }
.card-body { flex: 1; min-height: 0; padding: 12px 16px; overflow-y: auto; overscroll-behavior: contain; touch-action: pan-y; overflow-wrap: anywhere; }
.card-thumb { float: left; width: 72px; height: 72px; margin: 0 12px 4px 0; object-fit: cover; border: var(--line); background: #111; }
.card[data-expanded="true"] .card-thumb { display: none; }
.card-more { clear: both; }
.card-meta { font-size: 11px; letter-spacing: .1em; color: var(--dim); }
.card h2 { margin-top: 4px; font-size: 19px; line-height: 1.2; }
.card-artist { margin-top: 2px; font-size: 14px; }
.card-sale { margin-top: 8px; font-size: 12px; letter-spacing: .06em; }
.card-sale:empty { display: none; }
.card-more { display: none; margin-top: 16px; padding-top: 16px; border-top: 1px solid #333; }
.card[data-expanded="true"] .card-more { display: block; }
.card[data-expanded="false"] h2 { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.card-image { display: block; width: 100%; height: auto; max-height: 52vh; object-fit: contain; margin-bottom: 16px; border: var(--line); background: #111; }
.card-audio { margin-top: 16px; }
.card-audio h3 { margin: 0 0 8px; font-size: 11px; font-weight: 400; letter-spacing: .1em; color: var(--dim); }
.card-audio audio { display: block; width: 100%; }
.card-description { font-size: 14px; line-height: 1.55; white-space: pre-line; }
.card-description:empty { display: none; }
.card-actions { display: flex; gap: 8px; margin-top: 16px; }
.card-actions button { flex: 1; font-size: 12px; }
.card-3d, .top-link { display: flex; align-items: center; justify-content: center; min-height: 44px; padding: 8px 12px; border: var(--line); font-size: 12px; letter-spacing: .06em; text-decoration: none; }
.card-3d { margin-top: 8px; }
.card-expand { border: 0; border-top: var(--line); font-size: 12px; }
.noscript { position: fixed; inset: auto 0 0; z-index: 40; padding: 16px; background: var(--fg); color: var(--bg); }

@media (min-width: 900px) {
  .app { grid-template-columns: 380px minmax(0, 1fr); }
  .top, .searchbar, .panel, .foot { grid-column: 1; border-right: var(--line); }
  .brand img { height: 56px; }
  .toggle-panel { display: none; }
  .panel { grid-row: 3; display: flex; z-index: auto; }
  .foot { flex-direction: column; align-items: stretch; gap: 0; }
  .sponsors { --logo-height: 72px; grid-template-columns: minmax(0, 1fr) auto; grid-template-rows: auto auto; }
  .sponsor-role { grid-column: 1 / 3; padding: 12px 16px 0; font-size: 11px; }
  .sponsor-stage { height: calc(var(--logo-height) + 28px); }
  .sponsor-toggle { align-self: end; min-height: 40px; border-top: var(--line); }
  .credits { display: block; padding: 8px 16px; border-top: 1px solid #333; }
  .map-area { grid-column: 2; grid-row: 1 / 5; }
  .places { padding: 12px 16px; }
  .minimap { left: 16px; right: auto; top: 68px; height: min(420px, 60%); }
  .zoom { left: 16px; right: auto; bottom: 44px; flex-direction: row; }
  .zoom button + button { border-top: var(--line); border-left: 0; }
  .card { left: auto; top: 16px; right: 16px; bottom: auto; width: 400px; max-height: calc(100vh - 32px); max-height: calc(100dvh - 32px); border: var(--line); }
  .card .card-more { display: block; }
  .card .card-thumb { display: none; }
  .card[data-expanded="false"] h2 { display: block; }
  .card-expand { display: none; }
}

@media (prefers-reduced-motion: reduce) { .marker, .sponsor-logo { transition: none; } }
