:root {
  --records-control: #0b121c;
  --records-hover: #193047;
  --records-input-line: #5a7087;
  --records-on-accent: #081620;
  --records-success: #83e6bc;
  --records-error: #ffab9f;
}
[hidden] { display: none !important; }
.main-nav [aria-current="page"] { color: var(--brand); text-decoration: underline; text-underline-offset: .38em; }
.records-hero {
  padding-block: clamp(3rem, 7.3vw, 6rem);
  color: var(--ink);
  border-bottom: 1px solid var(--line);
  background: radial-gradient(ellipse at 90% 100%, #17334d 0%, transparent 58%), linear-gradient(115deg, #0a0f17 15%, var(--navy) 84%);
}
.records-hero h1, .records-detail h1 {
  font-size: clamp(2.5rem, 5.4vw, 5rem);
  line-height: 1.12;
  letter-spacing: -.068em;
  text-wrap: balance;
}
.records-hero p { margin-top: .85rem; font-size: clamp(1.02rem, 1.7vw, 1.2rem); color: var(--muted); }
.records-section { padding-block: clamp(2rem, 5vw, 4.25rem) clamp(3.4rem, 7vw, 6.2rem); }
.records-filters {
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(0, 1fr) minmax(0, .8fr);
  align-items: end;
  gap: 1.1rem;
  padding: clamp(1rem, 3vw, 1.6rem);
  border: 1px solid var(--line);
  background: var(--light);
}
.field { display: grid; gap: .38rem; min-width: 0; }
.field > label, .remove-image { font-weight: 700; color: var(--brand); }
.field-help, .field-required { color: var(--muted); font-size: .875rem; font-weight: 500; }
.field-required { margin-inline-start: .2rem; }
.field input, .field select, .field textarea {
  width: 100%;
  min-height: 2.9rem;
  margin: 0;
  padding: .58rem .76rem;
  border: 1px solid var(--records-input-line);
  border-radius: .18rem;
  color: var(--ink);
  background-color: var(--records-control);
  font: inherit;
}
.field input::placeholder, .field textarea::placeholder { color: var(--muted); opacity: 1; }
.field select {
  appearance: none;
  padding-right: 2.3rem;
  background-image: linear-gradient(45deg, transparent 49%, var(--muted) 50%, var(--muted) 66%, transparent 67%), linear-gradient(135deg, transparent 34%, var(--muted) 35%, var(--muted) 51%, transparent 52%);
  background-position: calc(100% - 1.12rem) 50%, calc(100% - .82rem) 50%;
  background-size: .3rem .38rem;
  background-repeat: no-repeat;
}
.field textarea { resize: vertical; }
.field input[type="file"] { padding: .42rem; font-size: .94rem; }
.field input[type="file"]::file-selector-button { margin-inline-end: .55rem; border: 0; padding: .45rem .7rem; color: var(--brand); background: var(--light); font: inherit; font-weight: 700; cursor: pointer; }
.field input:focus-visible, .field select:focus-visible, .field textarea:focus-visible,
button:focus-visible, .remove-image input:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

.results-toolbar { display: flex; justify-content: space-between; align-items: center; gap: .7rem; min-height: 3.65rem; padding-top: .5rem; }
.results-toolbar p { color: var(--muted); font-weight: 650; }
.action-quiet, .action-solid, .action-outline {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 2.75rem;
  color: var(--brand);
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}
.action-quiet { border: 0; background: transparent; padding: .3rem 0; text-decoration: underline; text-underline-offset: .24em; }
.action-quiet:hover { color: var(--ink); }
.action-outline, .action-solid { border-radius: .18rem; padding: .48rem .9rem; }
.action-outline { border: 1px solid var(--records-input-line); background: var(--records-control); }
.action-outline:hover { background: var(--light); }
.action-solid { border: 1px solid var(--brand); background: var(--brand); color: var(--records-on-accent); }
.action-solid:hover { background: #96efff; border-color: #96efff; }
button:disabled { cursor: wait; opacity: .6; }

.records-list { list-style: none; margin: 0; padding: 0; }
.records-list:not(:empty) { border-top: 2px solid var(--brand); }
.records-list li { border-bottom: 1px solid var(--line); }
.record-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 1.1rem;
  min-height: 6.4rem;
  padding: .85rem clamp(.25rem, 2vw, 1.3rem);
}
.record-row:hover { background: var(--light); }
.record-row:is(:hover, :focus-visible) .record-title { color: var(--accent); }
.record-row:focus-visible { outline-offset: -3px; }
.record-meta { color: var(--muted); font-weight: 700; font-size: .9rem; }
.record-title { margin-top: .18rem; font-size: clamp(1.06rem, 2vw, 1.28rem); font-weight: 750; line-height: 1.33; }
.record-link-label { color: var(--brand); font-size: .87rem; font-weight: 650; text-decoration: underline; text-underline-offset: .24em; }
.record-thumb { width: clamp(4.65rem, 12vw, 7rem); aspect-ratio: 1.55; object-fit: cover; }
.records-footer-links { display: flex; align-items: center; gap: 1.1rem; }
#records-retry, #detail-retry, #admin-retry, #admin-sign-in { margin-top: 1rem; }

.records-detail { padding-block: clamp(1.8rem, 5vw, 4rem) clamp(3.4rem, 7.6vw, 6.2rem); max-width: 63rem; min-height: 22rem; }
.detail-back { margin-bottom: 1.5rem; }
.records-detail h1 { margin-top: .65rem; font-size: clamp(2.05rem, 4.75vw, 4.4rem); }
.records-detail figure { margin: clamp(1.35rem, 4vw, 2.65rem) 0 0; background: var(--light); }
.records-detail figure img { width: 100%; max-height: 44rem; height: auto; object-fit: contain; }
.detail-facts { margin-top: 2rem; border-block: 1px solid var(--line); }
.detail-facts > div { display: grid; grid-template-columns: minmax(5.15rem, .28fr) 1fr; gap: .7rem; padding: .9rem 0; }
.detail-facts dt { color: var(--brand); font-weight: 700; }
.detail-summary { margin-top: 2.2rem; }
.detail-summary h2 { margin-bottom: .65rem; font-size: 1.25rem; }
.detail-summary p { color: var(--muted); font-size: 1.1rem; white-space: pre-wrap; }
.detail-photo-button { display: block; position: relative; width: 100%; padding: 0; border: 0; background: var(--light); cursor: zoom-in; }
.detail-photo-button:hover .detail-photo-action, .detail-photo-button:focus-visible .detail-photo-action { background: var(--records-hover); }
.detail-photo-action { position: absolute; inset-inline-end: .75rem; inset-block-end: .75rem; padding: .37rem .7rem; color: #fff; background: #101d32f2; font: inherit; font-size: .9rem; font-weight: 700; }
.detail-gallery { margin-top: clamp(2rem, 4.6vw, 3.4rem); }
.detail-gallery h2 { margin-bottom: .85rem; font-size: 1.25rem; }
.detail-gallery-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 11rem), 1fr)); gap: .75rem; margin: 0; padding: 0; list-style: none; }
.detail-gallery-button img { display: block; width: 100%; aspect-ratio: 4 / 3; object-fit: cover; }
.detail-gallery-button:is(:hover, :focus-visible) { outline: 2px solid var(--accent); outline-offset: 2px; }

.photo-viewer { width: min(calc(100% - 2rem), 74rem); max-width: none; max-height: calc(100dvh - 1.5rem); margin: auto; border: 1px solid var(--line); border-radius: .5rem; padding: 0; color: #fff; background: var(--navy); }
.photo-viewer::backdrop { background: #03060bef; }
.photo-viewer-content { display: grid; min-height: 13rem; }
.photo-viewer-toolbar, .photo-viewer-footer { display: grid; gap: .55rem .9rem; align-items: center; padding: .7rem clamp(.75rem, 2.2vw, 1.35rem); }
.photo-viewer-toolbar { grid-template-columns: minmax(0, 1fr) auto; }
.photo-viewer-toolbar h2 { font-size: 1rem; }
.photo-viewer-control { min-height: 2.75rem; padding: .35rem .75rem; border: 1px solid var(--records-input-line); border-radius: .25rem; background: var(--records-control); color: #fff; font: inherit; font-size: .92rem; font-weight: 700; cursor: pointer; }
.photo-viewer-control:hover { border-color: var(--accent); background: var(--records-hover); }
.photo-viewer-control:focus-visible { outline-color: var(--accent); }
.photo-viewer-stage { display: grid; min-height: 9rem; place-items: center; background: #05070a; touch-action: pan-y; }
.photo-viewer-stage img { display: block; max-width: 100%; max-height: calc(100dvh - 11.5rem); width: 100%; height: auto; object-fit: contain; user-select: none; -webkit-user-drag: none; }
.photo-viewer-stage p { margin: 1.35rem; text-align: center; }
.photo-viewer-footer { grid-template-columns: auto minmax(0, 1fr) auto; grid-template-areas: 'previous caption next'; }
#photo-viewer-prev { grid-area: previous; }
#photo-viewer-next { grid-area: next; }
.photo-viewer-caption { grid-area: caption; max-height: 4rem; overflow: auto; text-align: center; color: var(--muted); font-size: .92rem; overflow-wrap: anywhere; }

.editor-grid { display: grid; grid-template-columns: minmax(0, .9fr) minmax(0, 1.1fr); align-items: start; gap: clamp(1rem, 2.8vw, 2rem); }
.editor-panel { min-width: 0; border: 1px solid var(--line); background: var(--light); }
.editor-panel-heading { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: .65rem; }
.editor-panel-heading h2 { font-size: clamp(1.25rem, 2.2vw, 1.6rem); line-height: 1.3; letter-spacing: -.04em; }
.editor-entries .editor-panel-heading, .editor-search, .editor-list-status { margin-inline: clamp(1rem, 2.5vw, 1.4rem); }
.editor-entries .editor-panel-heading { margin-top: 1rem; }
.editor-search { margin-top: 1rem; }
.editor-list-status { margin-block: .7rem; color: var(--muted); font-weight: 650; }
.editor-records { margin: 0; padding: 0; list-style: none; max-height: 34rem; overflow-y: auto; }
.editor-records li { border-top: 1px solid var(--line); }
.editor-record-button { width: 100%; min-height: 3.8rem; padding: .65rem clamp(1rem, 2.5vw, 1.4rem); border: 0; color: var(--ink); background: var(--records-control); text-align: start; font: inherit; font-weight: 700; cursor: pointer; }
.editor-record-button:hover, .editor-record-button[aria-pressed="true"] { background: var(--light); }
.editor-record-button[aria-pressed="true"] { box-shadow: inset .23rem 0 var(--brand); }
.editor-record-button:focus-visible { outline-offset: -3px; }
.editor-record-button .record-meta { display: block; margin-top: .15rem; font-size: .875rem; font-weight: 500; }
.editor-form-panel { padding: clamp(1rem, 2.8vw, 1.6rem); }
.editor-form-panel fieldset { display: grid; gap: 1rem; min-inline-size: 0; padding: 0; margin: 1.2rem 0 0; border: 0; }
.editor-fields-inline { display: grid; grid-template-columns: 1.2fr 1fr; gap: .8rem; }
.editor-media { display: grid; gap: .75rem; padding-top: 1rem; border-top: 1px solid var(--line); }
.editor-preview { display: grid; gap: .35rem; margin: 0; color: var(--muted); font-size: .875rem; }
.editor-preview img { width: min(100%, 18rem); height: auto; max-height: 12rem; object-fit: contain; object-position: left; }
.remove-image { display: flex; align-items: center; gap: .55rem; cursor: pointer; }
.remove-image input { width: 1.12rem; height: 1.12rem; margin: 0; accent-color: var(--brand); }
.editor-media h3 { color: var(--brand); font-size: 1.13rem; }
.editor-gallery-list { display: grid; gap: .6rem; margin: 0; padding: 0; list-style: none; }
.editor-gallery-list li { display: grid; grid-template-columns: minmax(3rem, 5.5rem) minmax(0, 1fr); gap: .75rem; align-items: start; padding: .65rem; border: 1px solid var(--line); }
.editor-gallery-list img { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; }
.editor-gallery-name { color: var(--brand); font-size: .93rem; font-weight: 700; overflow-wrap: anywhere; }
.editor-gallery-list .gallery-alt { margin-top: .35rem; color: var(--muted); font-size: .875rem; }
.editor-gallery-list .gallery-alt input { min-height: 2.5rem; }
.editor-gallery-list .gallery-removal-pending { background: var(--light); }
.gallery-removal-pending img { opacity: .5; }
.editor-actions { display: flex; align-items: center; flex-wrap: wrap; gap: .8rem 1rem; }
.editor-feedback { min-height: 1.65em; margin-top: .48rem; color: var(--records-success); font-weight: 670; }
.editor-feedback[data-state="error"] { color: var(--records-error); }
.editor-feedback[data-state="pending"] { color: var(--muted); }

@media (max-width: 47rem) {
  .editor-grid { grid-template-columns: 1fr; }
  .editor-records { max-height: 16rem; }
}
@media (max-width: 38rem) {
  .records-filters { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .8rem; }
  .field-search { grid-column: 1 / -1; }
  .record-row { gap: .7rem; }
  .record-link-label { font-size: .82rem; }
  .detail-gallery-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .photo-viewer { width: calc(100% - 1rem); }
  .photo-viewer-footer { grid-template-columns: repeat(2, minmax(0, 1fr)); grid-template-areas: 'caption caption' 'previous next'; }
  .photo-viewer-stage img { max-height: calc(100dvh - 13rem); }
}
@media (max-width: 34rem) {
  .admin-nav { justify-content: start; gap: 1rem; }
  .records-footer-links { gap: .75rem; }
}
