@import url('https://fonts.googleapis.com/css2?family=Baskervville&family=DM+Sans:wght@400;500;600;700&display=swap');

:root {
  color-scheme: light;
  --paper: #f0f2ed;
  --surface: #fbfcf9;
  --mount: #e2e6dd;
  --ink: #242820;
  --muted: #565b50;
  --rule: #c9cfc4;
  --accent: #3f5239;
  --cols: 4;
  font: 400 15px/1.5 "DM Sans", system-ui, sans-serif;
  color: var(--ink);
  background: var(--paper);
  accent-color: var(--accent);
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; }
button, input, select, summary { font: inherit; color: inherit; }
button, select, summary { cursor: pointer; }
button:disabled { cursor: default; opacity: .45; }
button, select, summary, .btn-action {
  min-height: 42px;
  padding: 8px 13px;
  border: 1px solid var(--rule);
  border-radius: 3px;
  background: var(--surface);
}
button:hover, select:hover, summary:hover, .btn-action:hover { border-color: var(--muted); }
a { color: inherit; text-underline-offset: .2em; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
::selection { background: #dbe3cf; color: var(--ink); }

.container { width: min(100% - 80px, 1520px); margin-inline: auto; }
.masthead {
  min-height: 55px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--rule);
  font-size: 13px;
  font-weight: 700;
}
.masthead button { padding-inline: 8px; border-color: transparent; background: transparent; }
h1, .auth-card h2, .year-header h2 {
  font-family: "Baskervville", Georgia, serif;
  font-weight: 400;
  line-height: .98;
  margin: 0;
}
h1 { font-size: clamp(2.85rem, 5.5vw, 5.3rem); letter-spacing: -.025em; margin-block: 31px 27px; }
.catalog-tools { display: flex; align-items: center; gap: 8px; }
.search-box {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1 1 320px;
  min-width: 160px;
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: 3px;
  padding-inline: 11px;
}
.search-box:focus-within { outline: 2px solid var(--accent); outline-offset: 2px; }
.search-box svg { width: 18px; height: 18px; flex: 0 0 auto; }
.search-box input { width: 100%; min-height: 40px; border: 0; background: transparent; outline: 0; }
.search-box input::placeholder { color: var(--muted); }
.filter-select { position: relative; min-width: 0; max-width: 230px; }
.filter-select select {
  appearance: none;
  display: block;
  width: 100%;
  padding-inline: 13px 36px;
  text-overflow: ellipsis;
}
.filter-select::after,
.view-options summary::after {
  content: "";
  width: 8px;
  height: 8px;
  border-inline-end: 1.5px solid currentColor;
  border-block-end: 1.5px solid currentColor;
}
.filter-select::after {
  position: absolute;
  inset-inline-end: 16px;
  inset-block-start: 50%;
  transform: translateY(-70%) rotate(45deg);
  pointer-events: none;
}
@media (forced-colors: active) {
  .filter-select select { appearance: auto; padding-inline-end: 13px; }
  .filter-select::after { content: none; }
}
#showHiddenEvents[aria-pressed="true"], .view-panel button[aria-pressed="true"] { border-color: var(--accent); background: #e6ebdf; }
.view-options { position: relative; }
.view-options summary {
  display: flex;
  align-items: center;
  gap: 10px;
  white-space: nowrap;
  list-style: none;
}
.view-options summary::-webkit-details-marker { display: none; }
.view-options summary::after {
  flex: 0 0 auto;
  margin-inline: 2px 3px;
  transform: translateY(-2px) rotate(45deg);
}
.view-options[open] summary::after { transform: translateY(2px) rotate(225deg); }
.view-panel {
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  z-index: 3;
  width: min(260px, calc(100vw - 32px));
  padding: 14px;
  border: 1px solid var(--rule);
  background: var(--surface);
  box-shadow: 0 10px 30px #2428201a;
}
.view-modes { display: grid; gap: 5px; }
.view-panel button { text-align: left; }
.slider-group { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; margin-block: 13px; }
.slider-group input { width: 100%; }

.app-tabs {
  display: flex;
  gap: 24px;
  overflow-x: auto;
  margin-top: 15px;
  border-bottom: 1px solid var(--rule);
  scrollbar-width: thin;
}
.app-pill {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 10px 0;
  flex: 0 0 auto;
  border: 0;
  border-bottom: 2px solid transparent;
  border-radius: 0;
  background: transparent;
  white-space: nowrap;
  color: var(--muted);
}
.app-pill:hover, .app-pill[aria-pressed="true"] { color: var(--ink); }
.app-pill[aria-pressed="true"] { border-color: var(--accent); font-weight: 700; }
.app-pill .count { font-size: .75em; font-variant-numeric: tabular-nums; }
#catalog { padding-block: 13px 50px; }
#statsText { color: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; margin-bottom: 20px; }
.year-section + .year-section { margin-top: 43px; }
.year-header { padding-block: 10px 13px; border-top: 1px solid var(--rule); }
.year-header-left { display: flex; align-items: baseline; gap: 13px; }
.year-header h2 { font-size: clamp(2.4rem, 3.3vw, 3.4rem); }
.year-header span { color: var(--muted); font-size: 13px; }
.wall-grid { display: grid; grid-template-columns: repeat(var(--cols), minmax(0, 1fr)); gap: 27px 17px; }
.wall-masonry { columns: var(--cols); column-gap: 17px; }
.wall-masonry .card { display: inline-block; width: 100%; break-inside: avoid; margin-bottom: 27px; }
.card { min-width: 0; cursor: pointer; }
.card-img-wrap { position: relative; background: var(--mount); display: grid; place-items: center; overflow: hidden; }
.wall-grid .card-img-wrap { aspect-ratio: 4 / 5; }
.wall-grid.pieces .card-img-wrap { aspect-ratio: 1; }
.wall-grid.pieces--cenario .card-img-wrap { aspect-ratio: 3 / 2; }
.wall-grid.pieces--led .card-img-wrap,
.wall-grid.pieces--tv .card-img-wrap,
.wall-grid.pieces--web .card-img-wrap { aspect-ratio: 16 / 9; }
.card-img-wrap img { display: block; width: 100%; height: 100%; object-fit: contain; }
.wall-masonry .card-img-wrap img { height: auto; }
.wall-masonry .card-img-wrap:has(.thumb-fallback:not([hidden])) { aspect-ratio: 4 / 5; }
.thumb-retry { background: transparent; border-color: transparent; text-decoration: underline; }
.card-info { padding-top: 9px; }
.card-title { font-weight: 700; line-height: 1.28; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.card-meta { color: var(--muted); font-size: 13px; margin-top: 3px; }
.event-visibility-button {
  position: absolute;
  inset: 7px 7px auto auto;
  display: grid;
  place-items: center;
  width: 34px;
  min-height: 34px;
  padding: 0;
  background: var(--surface);
}
.event-visibility-button svg { width: 17px; height: 17px; }
.event-visibility-button:focus-visible { outline-offset: -4px; }
@media (pointer: coarse) {
  .event-visibility-button { width: 44px; min-height: 44px; }
}
.thumb-fallback { padding: 20px 8px; text-align: center; color: var(--muted); display: grid; gap: 2px; }
#moreResults { display: block; margin: 29px auto 0; }
.empty-state { border-top: 1px solid var(--rule); color: var(--muted); padding-block: 27px; }

.auth-gate { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.auth-card { width: min(100%, 480px); padding: 30px 0; border-block: 1px solid var(--rule); }
.auth-card h2 { font-size: clamp(2.8rem, 8vw, 4.5rem); }
.auth-card p { color: var(--muted); }
.auth-card form { display: grid; gap: 9px; margin-top: 27px; }
.auth-card input { min-height: 44px; padding-inline: 9px; border: 1px solid var(--rule); background: var(--surface); }
.auth-card button, #lbOpenOrigBtn { border-color: var(--accent); background: var(--accent); color: white; }
#authError { color: #8d302b; }

.preview-open { overflow: hidden; }
.lightbox { display: none; position: fixed; inset: 0; z-index: 10; background: var(--paper); }
.lightbox.open { display: grid; grid-template-rows: auto minmax(135px, 1fr) auto; }
.lb-top { display: flex; justify-content: space-between; align-items: center; gap: 10px 20px; flex-wrap: wrap; padding: 12px 24px; border-bottom: 1px solid var(--rule); }
.lb-title-wrap { flex: 1 1 260px; min-width: 0; }
.lb-title-wrap h2, .lb-title-wrap p { margin: 0; overflow-wrap: anywhere; }
.lb-title-wrap h2 { font-size: 19px; }
.lb-title-wrap p { color: var(--muted); font-size: 13px; }
.lb-actions { display: flex; flex-wrap: wrap; gap: 5px; }
.btn-action { display: inline-flex; align-items: center; text-decoration: none; }
.lb-body { position: relative; min-height: 0; display: grid; place-items: center; background: var(--mount); padding: 12px 56px; overflow: hidden; }
.lb-body img { display: block; width: 100%; height: 100%; min-height: 0; object-fit: contain; }
.lb-nav { position: absolute; top: calc(50% - 21px); z-index: 1; font-size: 24px; line-height: 1; }
.lb-nav.prev { left: 8px; }
.lb-nav.next { right: 8px; }
.lb-candidates { min-width: 0; padding: 0 24px 10px; border-top: 1px solid var(--rule); }
.lb-tabs, .lb-cand-strip { display: flex; align-items: stretch; gap: 6px; overflow-x: auto; scrollbar-width: thin; }
.lb-tabs { padding-block: 7px; }
.lb-tab { flex-shrink: 0; }
.lb-tab.active { background: #e6ebdf; border-color: var(--accent); }
.lb-cand-header { display: flex; justify-content: space-between; gap: 10px; font-size: 12px; color: var(--muted); margin-bottom: 5px; }
.lb-cand-strip { padding: 4px; }
.cand-item { display: grid; position: relative; flex: 0 0 83px; width: 83px; min-width: 0; padding: 3px; gap: 2px; }
.cand-item.selected { border-color: var(--accent); outline: 1px solid var(--accent); }
.cand-thumb {
  display: grid;
  place-items: center;
  height: 53px;
  background: var(--mount);
}
.cand-item img { display: block; width: 100%; height: 53px; object-fit: contain; }
.cand-unavailable { color: var(--muted); }
.cand-item span { min-width: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; font-size: 10px; }
.cand-ext { position: absolute; right: 3px; top: 3px; padding-inline: 2px; background: var(--surface); text-transform: uppercase; }

@media (max-width: 920px) {
  .container { width: calc(100% - 36px); }
  .catalog-tools { flex-wrap: wrap; }
  .search-box { flex-basis: 100%; }
  .wall-grid { grid-template-columns: repeat(min(var(--cols), 3), minmax(0, 1fr)); }
  .wall-masonry { columns: min(var(--cols), 3); }
}
@media (max-width: 580px) {
  .container { width: calc(100% - 28px); }
  h1 { margin-block: 23px 20px; }
  .catalog-tools { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .search-box { grid-column: 1 / -1; min-width: 0; }
  .filter-select { max-width: none; }
  .catalog-tools > .btn-toggle, .catalog-tools > .view-options { justify-self: start; }
  .view-options summary { white-space: normal; }
  .app-tabs { gap: 18px; }
  .wall-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 19px 9px; }
  .wall-masonry { columns: 2; column-gap: 9px; }
  .view-options { position: static; }
  .catalog-tools { position: relative; }
  .view-panel { left: 0; right: auto; }
  .lb-top, .lb-candidates { padding-inline: 9px; }
  .lb-top .btn-action { padding-inline: 7px; font-size: 12px; }
  .lb-cand-header { display: none; }
  .lb-body { padding-inline: 40px; }
  .lb-nav { padding-inline: 8px; }
}

.lightbox.show-event-board { grid-template-rows: auto minmax(0, 1fr); }
.event-board {
  overflow: auto;
  padding: 12px;
  padding: clamp(12px, 2vw, 30px);
  background: #1d221c;
}
.event-mosaic {
  position: relative;
  column-gap: 8px;
  width: min(100%, 1380px);
  margin-inline: auto;
}
.event-tile {
  position: absolute;
  min-width: 0;
  padding: 0;
  overflow: hidden;
  border: 0;
  border-radius: 6px;
  background: #30372e;
  color: #fff;
}
.event-cover { background: #353d32; }
.event-tile-preview {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  width: 100%;
  min-height: 0;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
}
.event-dismiss {
  position: absolute;
  inset: 8px 8px auto auto;
  display: grid;
  place-items: center;
  width: 34px;
  min-height: 34px;
  padding: 0;
  border: 0;
  border-radius: 4px;
  background: #1d221c;
  color: #fff;
  font-size: 22px;
  line-height: 1;
}
.event-dismiss:hover { background: #3d4939; }
.event-tile button:focus-visible { outline-color: #fff; outline-offset: -3px; }
@media (pointer: coarse) {
  .event-dismiss { width: 44px; min-height: 44px; }
}
.event-tile img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.event-board-empty { color: #f3f5ee; }
.event-tile-edit {
  position: absolute;
  inset: auto 8px 8px auto;
  display: grid;
  place-items: center;
  width: 30px;
  min-height: 30px;
  padding: 0;
  border-color: transparent;
  border-radius: 4px;
  background: #1d221c;
  color: #fff;
}
.event-tile-edit:hover { background: #3d4939; border-color: #b9c3b4; }
@media (pointer: coarse) {
  .event-tile-edit { width: 44px; min-height: 44px; }
}
.event-piece-type {
  position: absolute;
  inset: auto auto 8px 8px;
  max-width: calc(100% - 64px);
  overflow: hidden;
  padding: 2px 6px;
  border-radius: 3px;
  background: rgb(29 34 28 / 92%);
  color: #f3f5ee;
  font-size: 11px;
  line-height: 16px;
  white-space: nowrap;
  text-overflow: ellipsis;
  pointer-events: none;
}
.event-tile-empty { align-self: start; justify-self: start; margin: 13px 8px; font-size: 12px; }

.catalog-setting { display: grid; gap: 4px; font-size: 13px; }
.event-tags { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 5px; }
.event-tags span { font-size: 12px; padding: 2px 6px; background: #e2e7dd; border-radius: 3px; }
.event-details {
  display: flex;
  align-items: end;
  flex-wrap: wrap;
  gap: 10px 16px;
  flex-basis: 100%;
  border-top: 1px solid var(--rule);
  padding-top: 10px;
}
.credit-field { display: grid; grid-template-columns: minmax(110px, 1fr) auto; gap: 4px 6px; }
.credit-field label { grid-column: 1 / -1; font-size: 13px; }
.credit-field input { min-width: 0; border: 1px solid var(--rule); border-radius: 3px; padding: 7px; }
.event-origin { display: inline-flex; align-items: center; gap: 5px; min-height: 42px; }
.board-instruction { color: #f3f5ee; margin: 0 auto 10px; max-width: 1380px; font-size: 14px; }
#lbGroupBtn[aria-pressed="true"] { background: #e2e7dd; border-color: var(--accent); }
.event-tile.group-source, .event-tile.group-target { box-shadow: inset 0 0 0 3px #f3f5ee; }
.event-tile.group-suggestion::after,
.event-tile.group-source::after, .event-tile.group-target::after {
  content: "";
  position: absolute;
  inset: 0;
  border: 3px solid #f3f5ee;
  border-radius: inherit;
  pointer-events: none;
}
.event-tile.group-suggestion::after { border: 2px dashed #bed4b4; inset: 3px; }
.stack-navigation {
  position: absolute;
  inset: 50% 6px auto;
  transform: translateY(-50%);
  display: flex;
  align-items: center;
  justify-content: space-between;
  pointer-events: none;
}
.stack-navigation button, .event-ungroup {
  border: 0;
  background: #1d221c;
  color: #fff;
  pointer-events: auto;
}
.stack-navigation button { width: 36px; min-height: 36px; padding: 0; font-size: 23px; }
.stack-navigation span { background: #1d221c; border-radius: 3px; padding: 2px 6px; font-size: 11px; }
.event-ungroup { position: absolute; inset: 8px auto auto 8px; min-height: 34px; padding: 4px 7px; font-size: 11px; }
.stack-navigation button:hover, .event-ungroup:hover { background: #3d4939; }
@media (pointer: coarse) {
  .stack-navigation button { width: 44px; min-height: 44px; }
}

.led-editor {
  max-width: 1050px;
  margin: 0 auto;
  padding: clamp(12px, 2vw, 24px);
  border-radius: 6px;
  background: var(--paper);
  color: var(--ink);
}
.led-editor-header { display: flex; justify-content: space-between; gap: 12px; align-items: end; flex-wrap: wrap; margin-bottom: 12px; }
.led-editor h3 { margin: 0; }
.led-editor label, .led-center-field { display: grid; gap: 4px; min-width: 0; font-size: 13px; }
.led-editor input { width: 100%; min-height: 40px; padding: 6px 9px; border: 1px solid var(--rule); border-radius: 3px; }
.led-editor select { width: 100%; min-width: 0; text-overflow: ellipsis; }
.led-composition {
  position: relative;
  display: grid;
  align-items: stretch;
  column-gap: clamp(2px, 0.65vw, 8px);
  width: 100%;
  min-height: 0;
  overflow: hidden;
  background: #111410;
}
.led-screen { position: relative; display: grid; place-items: center; min-width: 0; min-height: 0; color: #f3f5ee; }
.led-screen-center { width: 100%; aspect-ratio: var(--led-center-ratio); }
.led-screen img, .led-tile .led-screen img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; }
.led-screen span { padding: 4px; font-size: 12px; text-align: center; }
.led-fields { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.5fr) minmax(0, 1fr); gap: 12px; align-items: start; margin: 14px 0; }
.led-add-row { display: flex; gap: 5px; }
.led-editor ol { display: grid; gap: 3px; margin: 3px 0; padding-left: 21px; }
.led-editor li { padding-bottom: 3px; overflow-wrap: anywhere; }
.led-editor li button { min-height: 30px; margin-left: 3px; padding: 2px 7px; }
.led-proportions > div { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; margin: 8px 0; }
.led-editor-actions { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 12px; }
.led-editor-actions button[type="submit"] { color: white; background: var(--accent); }
#ledError { color: #8d302b; margin-bottom: 0; }
.led-tile-header { display: flex; flex-wrap: wrap; align-items: center; gap: 5px; padding: 7px 9px; }
.led-tile-header strong { flex: 1 1 150px; font-size: 14px; overflow-wrap: anywhere; }
.led-tile-header button { min-height: 34px; padding: 3px 8px; font-size: 12px; color: var(--ink); }
.led-navigation { inset-inline: 8px; }
@media (max-width: 640px) {
  .led-fields, .led-proportions > div { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .led-center-field { grid-row: 2; grid-column: 1 / -1; }
}

.led-side-fields { display: grid; gap: 10px; min-width: 0; }
.led-editor .led-auto-option { display: flex; align-items: center; gap: 8px; margin-block: 10px; }
.led-auto-option input { width: auto; min-height: 0; }
.led-proportions > div { grid-template-columns: repeat(auto-fit, minmax(128px, 1fr)); }

.identity-credit {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 5px 8px;
  margin-top: 6px;
  font-size: 13px;
}
.identity-credit input, .piece-editor input {
  width: 100%;
  min-width: 0;
  min-height: 42px;
  padding: 7px;
  border: 1px solid var(--rule);
  border-radius: 3px;
  background: var(--surface);
}
.identity-credit input { width: min(180px, 100%); }
.identity-credit input::placeholder, .piece-editor input::placeholder { color: var(--muted); }
.identity-credit button { padding-inline: 10px; }
.piece-editor {
  display: grid;
  flex-basis: 100%;
  min-width: 0;
  gap: 8px;
  padding-top: 10px;
  border-top: 1px solid var(--rule);
}
.piece-editor strong { overflow-wrap: anywhere; font-size: 13px; }
.piece-fields {
  display: grid;
  grid-template-columns: minmax(0, 240px) minmax(0, 280px) auto;
  align-items: end;
  justify-content: start;
  gap: 8px 12px;
}
.piece-type-field { display: grid; min-width: 0; gap: 4px; font-size: 13px; }
.piece-type-field select { width: 100%; }
.piece-actions { display: flex; gap: 6px; }
.piece-actions button[type="submit"] { background: var(--accent); border-color: var(--accent); color: #fff; }
.piece-actions button[type="submit"]:hover { background: #30402b; }
.edit-status { flex-basis: 100%; font-size: 13px; color: var(--muted); }
.edit-status:empty { position: absolute; }
@media (max-width: 650px) {
  .piece-fields { grid-template-columns: minmax(0, 1fr); }
  .piece-fields .credit-field { grid-template-columns: minmax(0, 1fr) auto; }
}
