body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  margin: 0;
  background-color: #f5f5f7;
  color: #1f1f1f;
}

a {
  color: #0057b8;
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

.container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 1.5rem;
}

.site-header,
.site-footer {
  background: #111;
  color: #fff;
}

.site-header a {
  color: #fff;
}

.tagline {
  margin: 0.3rem 0 0;
  color: #e0e0e0;
}

.search-panel {
  background: #fff;
  border-radius: 8px;
  padding: 1rem;
  margin-bottom: 1.5rem;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.08);
}

.summary-panel {
  background: #fff;
  border-radius: 12px;
  padding: 1.5rem;
  margin-bottom: 1.5rem;
  box-shadow: 0 15px 25px rgba(0, 0, 0, 0.05);
}

.summary-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 1rem;
  margin-bottom: 1rem;
}

.summary-meta {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.4rem;
}

.insights-panel {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.insights-panel.is-collapsed .insights-body {
  display: none;
}

.insights-toggle {
  padding: 0.4rem 0.8rem;
  border-radius: 999px;
  border: 1px solid #0057b8;
  background: transparent;
  color: #0057b8;
  font-weight: 600;
  cursor: pointer;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 1rem;
}

.flip-note {
  margin: 0.5rem 0 1rem;
  font-size: 0.9rem;
  color: #444;
}

.flip-card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  column-gap: 1.5rem;
  row-gap: 1.75rem;
  margin-top: 1rem;
}

.flip-card {
  perspective: 1200px;
  position: relative;
  min-height: var(--flip-card-height, 320px);
}

.flip-card-inner {
  position: relative;
  height: var(--flip-card-height, 320px);
  transition: transform 0.6s ease;
  transform-style: preserve-3d;
}

.flip-card.is-flipped .flip-card-inner {
  transform: rotateY(180deg);
}

.flip-card-face {
  position: absolute;
  inset: 0;
  border-radius: 10px;
  border: 1px solid #e2e6ef;
  background: linear-gradient(180deg, #fefefe, #f5f7fb);
  padding: 1rem;
  box-shadow: 0 15px 25px rgba(0, 0, 0, 0.05);
  backface-visibility: hidden;
  display: flex;
  flex-direction: column;
  min-height: 100%;
  pointer-events: none;
  overflow-y: auto;
}

.flip-card-front {
  cursor: pointer;
}

.flip-card-front:focus-visible {
  outline: 3px solid #0057b8;
  outline-offset: 3px;
}

.flip-card-face.flip-card-back {
  background: linear-gradient(180deg, #0f172a, #1d2951);
  color: #f4f9ff;
  transform: rotateY(180deg);
}

.flip-card:not(.is-flipped) .flip-card-front,
.flip-card.is-flipped .flip-card-back {
  pointer-events: auto;
}

.flip-card-back-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
  font-weight: 600;
}

.filter-options {
  margin-top: 0.75rem;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  background: rgba(255, 255, 255, 0.04);
  padding: 0.5rem;
  max-height: 190px;
  overflow-y: auto;
}

.checkbox-option {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.35rem 0.25rem;
  font-size: 0.9rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.checkbox-option:last-child {
  border-bottom: none;
}

.checkbox-option span {
  flex: 1;
}

.flip-card-back input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: #2ec4ff;
}

.flip-card-front .flip-button {
  margin-top: auto;
}

.flip-card-back .flip-button {
  color: #a6d6ff;
  font-size: 0.85rem;
}

.flip-button {
  background: none;
  border: none;
  color: #0057b8;
  font-weight: 600;
  cursor: pointer;
  padding: 0.35rem 0;
  text-align: left;
}

.flip-card-back .muted {
  color: #c7d7ff;
}

.flip-hint {
  margin-top: auto;
  font-size: 0.85rem;
  color: #555;
}

.summary-card {
  background: linear-gradient(180deg, #fefefe, #f5f7fb);
  border-radius: 10px;
  padding: 1rem;
  border: 1px solid #e2e6ef;
  min-height: 180px;
}

.summary-card-header {
  display: flex;
  justify-content: space-between;
  margin-bottom: 0.75rem;
  font-size: 0.9rem;
  color: #555;
}

.summary-field {
  font-weight: 600;
  color: #111;
}

.summary-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.summary-list li {
  margin-bottom: 0.65rem;
}

.summary-item-label {
  font-size: 0.9rem;
  font-weight: 500;
}

.summary-bar {
  background: #e6ebf5;
  border-radius: 999px;
  height: 6px;
  margin: 0.35rem 0;
  overflow: hidden;
}

.summary-bar span {
  display: block;
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, #0057b8, #00a8ff);
}

.summary-item-count {
  font-size: 0.85rem;
  color: #666;
}

.filter-panel {
  background: #fff;
  border-radius: 12px;
  padding: 1.25rem 1.5rem;
  margin-bottom: 1.5rem;
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.05);
}

.filter-form {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.filter-form label {
  font-weight: 600;
  display: block;
  margin-bottom: 0.4rem;
}

.search-row {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.filter-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
  margin-top: 1rem;
}

.filter-grid select {
  width: 100%;
  min-height: 120px;
  border-radius: 8px;
  border: 1px solid #d0d5e4;
  padding: 0.5rem;
  font-size: 0.9rem;
  background: #fafbff;
}

.filter-actions {
  margin-top: 1rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.search-form label {
  display: block;
  font-weight: 600;
}

.search-input-group {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.5rem;
}

.search-input-group input {
  flex: 1;
  padding: 0.6rem;
  border-radius: 6px;
  border: 1px solid #ccc;
}

.search-input-group button,
button,
.button {
  padding: 0.6rem 1rem;
  border: none;
  border-radius: 6px;
  background: #0057b8;
  color: #fff;
  cursor: pointer;
}

button:disabled {
  opacity: 0.7;
  cursor: not-allowed;
}

.button {
  text-decoration: none;
  display: inline-block;
}

.button.secondary {
  background: #fff;
  color: #0057b8;
  border: 1px solid #0057b8;
}

.button.secondary:hover {
  background: #eef4ff;
}

.entity-table,
.detail-table {
  width: 100%;
  border-collapse: collapse;
  background: #fff;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.08);
}

.entity-table th,
.entity-table td,
.detail-table th,
.detail-table td {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid #eee;
  vertical-align: top;
}

.entity-table tr:last-child td,
.detail-table tr:last-child td {
  border-bottom: none;
}

.thumb-cell {
  width: 120px;
}

.entity-thumb {
  width: 96px;
  height: 96px;
  border-radius: 8px;
  overflow: hidden;
  background: #e6e6e6;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  text-align: center;
}

.entity-thumb a {
  display: block;
  width: 100%;
  height: 100%;
}

.thumb-placeholder {
  font-size: 0.8rem;
  padding: 0.5rem;
}

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

.artwork-thumb-wrapper {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.entity-table ul {
  padding-left: 1.2rem;
  margin: 0;
}

.muted {
  color: #666;
}

.pagination {
  display: flex;
  gap: 1rem;
  justify-content: center;
  align-items: center;
  margin: 1.5rem 0;
}

.entity-detail section {
  margin-bottom: 2rem;
}

.wikidata-output {
  background: #111;
  color: #0f0;
  padding: 1rem;
  border-radius: 8px;
  overflow-x: auto;
  min-height: 120px;
}

.wikidata-actions {
  display: flex;
  gap: 1rem;
  align-items: center;
  flex-wrap: wrap;
}

.wikidata-image-container {
  max-width: 320px;
  margin-top: 1rem;
}

.wikidata-image-container img {
  width: 100%;
  border-radius: 8px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.25);
}

.media-well {
  display: flex;
  gap: 1.5rem;
  flex-wrap: wrap;
  margin-top: 1rem;
}

.media-stack {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.signature-container {
  margin-top: 1rem;
  padding: 1rem;
  border-radius: 8px;
  background: #f7f7f9;
  border: 1px solid #e1e1e8;
}

.signature-container img {
  max-width: 220px;
  border-radius: 6px;
  border: 1px solid #ddd;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.15);
  margin-top: 0.5rem;
  display: block;
}

.image-source {
  display: inline-block;
  margin-top: 0.4rem;
  font-size: 0.8rem;
  color: #555;
}

.image-source a {
  color: inherit;
  text-decoration: underline;
}

.hidden {
  display: none;
}

/* Lightbox */
.lightbox {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.9);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 1000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.lightbox.active {
  opacity: 1;
  pointer-events: auto;
}

.lightbox img {
  max-width: 90vw;
  max-height: 90vh;
  border-radius: 4px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
}

.lightbox-close {
  position: absolute;
  top: 1rem;
  right: 1.5rem;
  color: #fff;
  font-size: 2rem;
  cursor: pointer;
  background: none;
  border: none;
  padding: 0.5rem;
}
