:root {
  --blue-900: #102f4e;
  --blue-800: #16466d;
  --blue-700: #1f5f8f;
  --gold: #c7a34a;
  --gold-dark: #9a7830;
  --paper: #f6f4ee;
  --surface: #ffffff;
  --ink: #1d2730;
  --muted: #657482;
  --line: #d8dee5;
  --focus: #2f7fc1;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  color: var(--ink);
  background: var(--paper);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.5;
}

a {
  color: var(--blue-800);
}

img {
  max-width: 100%;
  display: block;
}

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

.site-header {
  background: linear-gradient(90deg, var(--blue-900), var(--blue-800));
  border-bottom: 6px solid var(--gold);
  color: #fff;
}

.brand {
  max-width: 1180px;
  margin: 0 auto;
  min-height: 92px;
  padding: 18px 22px;
  display: flex;
  align-items: center;
  gap: 18px;
}

.brand-logo {
  width: 56px;
  height: 56px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  border: 2px solid var(--gold);
  color: var(--blue-900);
  background: #fff;
  font-weight: 800;
  font-size: 1.2rem;
  letter-spacing: 0;
}

.brand h1 {
  margin: 0;
  font-size: clamp(1.35rem, 2vw, 2rem);
  font-weight: 750;
  letter-spacing: 0;
  display: flex;
}

.page-shell {
  max-width: 1180px;
  margin: 0 auto;
  padding: 28px 22px 48px;
}

.search-panel,
.results-head,
.result-card,
.detail-content {
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: 0 12px 28px rgba(16, 47, 78, 0.08);
}

.search-panel {
  padding: 22px;
  border-top: 4px solid var(--gold);
}

.search-panel h2,
.detail-info h2 {
  margin: 0 0 18px;
  color: var(--blue-900);
  font-size: 1.35rem;
  letter-spacing: 0;
}

.search-grid {
  display: grid;
  grid-template-columns: minmax(220px, 1.6fr) repeat(3, minmax(160px, 1fr)) auto;
  gap: 16px;
  align-items: end;
}

.field {
  display: grid;
  gap: 7px;
}

label {
  color: var(--blue-900);
  font-weight: 700;
  font-size: 0.92rem;
}

input,
select {
  width: 100%;
  min-height: 42px;
  border: 1px solid #b9c4cf;
  background: #fff;
  color: var(--ink);
  padding: 9px 10px;
  font: inherit;
}

.actions,
.detail-actions,
.pagination {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.button {
  min-height: 42px;
  border: 1px solid transparent;
  padding: 9px 14px;
  font: inherit;
  font-weight: 750;
  text-decoration: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.button.primary {
  background: var(--blue-800);
  color: #fff;
}

.button.secondary {
  background: #fff;
  color: var(--blue-900);
  border-color: var(--gold-dark);
}

.button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.results-head {
  margin-top: 22px;
  padding: 16px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.results-head p {
  margin: 0;
  color: var(--blue-900);
  font-weight: 750;
}

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

.result-card {
  overflow: hidden;
}

.thumb-link {
  display: block;
  background: #e8edf1;
  aspect-ratio: 4 / 3;
}

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

.card-body {
  padding: 14px;
}

.card-body h3 {
  margin: 0 0 8px;
  color: var(--blue-900);
  font-size: 1rem;
  overflow-wrap: anywhere;
}

.card-body p {
  margin: 0 0 10px;
  color: var(--muted);
  font-size: 0.92rem;
}

.caption-list {
  margin: 0 0 12px;
  display: grid;
  gap: 5px 10px;
  font-size: 0.88rem;
}

.caption-list dt {
  color: var(--blue-900);
  font-weight: 750;
}

.caption-list dd {
  margin: -5px 0 5px;
  color: var(--ink);
  overflow-wrap: anywhere;
}

.detail-link {
  font-weight: 750;
  text-underline-offset: 3px;
}

.pagination {
  margin-top: 24px;
  justify-content: center;
}

.detail-actions {
  margin-bottom: 18px;
}

.detail-content {
  display: grid;
  grid-template-columns: minmax(280px, 1fr) minmax(300px, 0.9fr);
  gap: 24px;
  align-items: start;
  padding: 22px;
  border-top: 4px solid var(--gold);
}

.detail-media {
  background: #eef2f5;
  min-height: 420px;
  display: grid;
  place-items: start center;
}

.detail-media img {
  width: 100%;
  max-height: 75vh;
  object-fit: contain;
}

.detail-tabs {
  min-width: 0;
}

.tab-list {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 16px;
  border-bottom: 1px solid var(--line);
}

.tab-button {
  min-height: 40px;
  border: 1px solid var(--line);
  border-bottom: 0;
  background: #eef2f5;
  color: var(--blue-900);
  padding: 8px 16px;
  font: inherit;
  font-weight: 750;
  cursor: pointer;
}

.tab-button[aria-selected="true"] {
  background: #fff;
  border-color: var(--gold-dark);
  color: var(--blue-900);
  box-shadow: inset 0 3px 0 var(--gold);
}

.tab-button:hover {
  border-color: var(--gold-dark);
}

.metadata-table {
  width: 100%;
  border-collapse: collapse;
  background: #fff;
}

.metadata-table th,
.metadata-table td {
  border-bottom: 1px solid var(--line);
  padding: 10px 8px;
  text-align: left;
  vertical-align: top;
}

.metadata-table th {
  width: 38%;
  color: var(--blue-900);
  font-weight: 750;
}

.metadata-table td {
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

.notice {
  margin: 0;
  color: var(--blue-900);
  font-weight: 750;
}

@media (max-width: 980px) {
  .search-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .actions {
    grid-column: 1 / -1;
  }

  .detail-content {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 620px) {
  .brand {
    min-height: 78px;
    padding: 14px 16px;
  }

  .brand-logo {
    width: 48px;
    height: 48px;
  }

  .page-shell {
    padding: 20px 14px 36px;
  }

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

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

  .button {
    width: 100%;
  }

  .detail-actions .button {
    width: auto;
    flex: 1 1 180px;
  }
}

@media print {
  body {
    background: #fff;
    color: #000;
  }

  .site-header,
  .no-print,
  .detail-actions {
    display: none !important;
  }

  .page-shell {
    max-width: none;
    padding: 0;
  }

  .detail-content {
    display: block;
    border: 0;
    box-shadow: none;
    padding: 0;
  }

  .detail-media {
    min-height: 0;
    background: #fff;
    margin-bottom: 16px;
  }

  .detail-media img {
    max-height: 120mm;
    margin: 0 auto;
  }

  .metadata-table th,
  .metadata-table td {
    border: 1px solid #999;
    padding: 6px;
  }
}
