:root {
  --bg: #f7f7f7;
  --panel: #ffffff;
  --text: #121212;
  --muted: #4c4c4c;
  --line: #d8d8d8;
  --line-strong: #2a2a2a;
  --hover: rgba(0, 0, 0, 0.045);
  --title-size: clamp(2rem, 4.3vw, 3.2rem);
  --subtitle-size: 1.02rem;
  --corpus-size: 1.12rem;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Cabin", "Avenir Next", sans-serif;
  color: var(--text);
  background: #fff;
}

.shell {
  width: min(1260px, 95vw);
  margin: 0 auto;
  padding: 1.4rem 0 2.6rem;
}

.hero {
  text-align: center;
  background: transparent;
  border: 0;
  border-top: 1px solid var(--line);
  border-radius: 0;
  box-shadow: none;
  padding: 1.2rem 1rem 1rem;
}

.mini-search {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.45rem;
}

.information {
  display: flex;
  flex-direction: column;
  align-self: center;
    --title-size: clamp(1.2rem, 2.2vw, 1.6rem);
}

.home-link {
  margin-top: 0.35rem;
  color: #111;
  font-size: 0.84rem;
  text-decoration: none;
}

  text-decoration: underline;
}

#name {
  margin: 0.35rem 0 0;
}

.search-pane {
  display: flex;
  flex-direction: column;
  width: min(980px, 100%);
  align-items: center;
  gap: 0.5rem;
}

.is-hidden {
  display: none !important;
}

.corpus-select {
  width: min(860px, 100%);
  margin: 0;
  border: 1px solid var(--line);
  padding: 0.45rem 0.65rem;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 0.25rem 0.6rem;
}

.results-title {
  letter-spacing: 0.01em;
  font-weight: 600;
}

.corpus-select legend {
  float: left;
  width: 100%;
  text-align: center;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--muted);
  padding: 0 0.2rem;
  margin-bottom: 0.2rem;
}

.corpus-select label {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.85rem;
}

.kicker {
  margin: 0;
  text-transform: uppercase;
  letter-spacing: 0.07rem;
  color: var(--muted);
  font-size: 0.79rem;
  font-weight: 700;
}

h1 {
  margin: 0.35rem 0 0;
  font-family: "Cabin", sans-serif;
  font-size: var(--title-size);
  font-weight: 700;
  line-height: 1;
}

.subtitle {
  margin: 0.26rem 0 0.72rem;
  color: var(--muted);
  font-size: var(--subtitle-size);
  text-align: center;
}

.search-form {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0;
  width: min(860px, 100%);
}

.image-search-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  width: min(860px, 100%);
  border: 1px solid #000;
}

.image-drop-label {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

.image-search-form input[type="file"] {
  width: 100%;
  border: 0;
  border-right: 1px solid #000;
  border-radius: 0;
  padding: 0.58rem 0.72rem;
  font-size: 0.9rem;
  font-family: inherit;
  background: #fff;
}

.image-search-form button {
  border: 0;
  border-radius: 0;
  background: #000;
  color: #fff;
  padding: 0.58rem 0.95rem;
  min-width: 148px;
  font-size: 0.92rem;
  font-weight: 700;
  cursor: pointer;
  transition: background-color 160ms ease, color 160ms ease;
}

.image-search-form button:hover {
  background: #fff;
  color: #000;
}

.image-preview-wrap {
  margin-top: 0.45rem;
  border: 1px solid var(--line);
  padding: 0.4rem;
  width: min(860px, 100%);
  text-align: center;
}

.image-preview {
  width: min(280px, 100%);
  max-height: 180px;
  object-fit: contain;
  display: block;
  margin: 0 auto;
}

.image-preview-name {
  margin: 0.3rem 0 0;
  font-size: 0.75rem;
  color: var(--muted);
}

.search-form input {
  width: 100%;
  border: 1px solid #000;
  border-right: 0;
  border-radius: 0;
  padding: 0.58rem 0.72rem;
  font-size: 1rem;
  font-family: inherit;
}

.search-form button {
  border: 1px solid #000;
  border-radius: 0;
  background: #000;
  color: #fff;
  padding: 0.58rem 0.95rem;
  min-width: 148px;
  font-size: 0.92rem;
  font-weight: 700;
  cursor: pointer;
  transition: background-color 160ms ease, color 160ms ease;
}

.search-form button:hover {
  background: #fff;
  color: #000;
}

.query-echo {
  margin: 0.56rem 0 0;
  font-size: 0.9rem;
  color: var(--muted);
  text-align: center;
}

.model-echo {
  margin: 0.26rem 0 0;
  font-size: 0.8rem;
  color: #3f3f3f;
  text-align: center;
  letter-spacing: 0.01em;
}

.health-panel {
  width: min(980px, 100%);
  margin: 0.25rem auto 0;
  border-top: 1px solid var(--line);
  padding-top: 0.5rem;
}

.health-panel h3 {
  margin: 0 0 0.42rem;
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  text-align: center;
}

.health-status-list {
  display: grid;
  gap: 0.34rem;
}

.health-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.42rem;
  flex-wrap: wrap;
  font-size: 0.76rem;
  color: var(--muted);
}

.health-corpus {
  font-weight: 700;
  color: var(--text);
}

.health-chip {
  border: 1px solid #000;
  padding: 0.08rem 0.34rem;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  color: #000;
}

.health-chip--fresh {
  border-color: #1f7a3b;
  color: #1f7a3b;
}

.health-chip--stale,
.health-chip--missing,
.health-chip--invalid {
  border-color: #9a3f00;
  color: #9a3f00;
}

.health-chip--disabled {
  border-color: #666;
  color: #666;
}

.actions-row {
  margin-top: 0.52rem;
  display: flex;
  justify-content: center;
}

.export-panel {
  border-top: 1px solid var(--line);
  margin-top: 0.8rem;
  padding: 0.9rem 0.65rem 0.25rem;
}

.export-btn {
  border: 1px solid #000;
  border-radius: 0;
  background: #fff;
  color: #000;
  padding: 0.42rem 0.78rem;
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
  transition: background-color 140ms ease, color 140ms ease, opacity 140ms ease;
}

.export-btn:hover {
  background: #000;
  color: #fff;
}

.export-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.export-status {
  margin: 0.42rem 0 0;
  font-size: 0.78rem;
  color: var(--muted);
  text-align: center;
  max-width: min(1000px, 100%);
  word-break: break-word;
}

.results-grid {
  margin-top: 1rem;
  display: grid;
  gap: 0.8rem;
}

.corpus-block {
  background: transparent;
  border: 0;
  border-top: 1px solid var(--line);
  border-radius: 0;
  padding: 0.6rem 0.65rem 0.7rem;
  box-shadow: none;
}

.corpus-block h2 {
  margin: 0 0 0.5rem;
  font-size: var(--corpus-size);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  text-align: center;
}

.thumb-row {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 0.5rem;
}

.thumb-card {
  min-height: 170px;
  border-radius: 0;
  border: 0;
  background: #fff;
  padding: 0.38rem;
  display: flex;
  flex-direction: column;
  transform: translateY(8px);
  opacity: 0;
  animation: card-rise 220ms ease forwards;
  transition: border-color 120ms ease, background-color 120ms ease;
}

.thumb-card p {
  margin: 0;
  font-size: 0.77rem;
  color: var(--muted);
}

.thumb-card:hover {
  background-color: #fcfcfc;
}

.thumb-link {
  display: block;
  text-decoration: none;
}

.thumb-img {
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  border-radius: 0;
  border: 0;
  background: #efefef;
  display: block;
  flex-shrink: 0;
}

.thumb-img--missing {
  background: repeating-linear-gradient(
    -45deg,
    rgba(0, 0, 0, 0.04),
    rgba(0, 0, 0, 0.04) 4px,
    transparent 4px,
    transparent 10px
  );
}

.thumb-meta {
  padding: 0.28rem 0.08rem 0;
  font-size: 0.71rem;
  color: var(--muted);
  line-height: 1.38;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 5;
  -webkit-box-orient: vertical;
}

.meta-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin: 0 0 0.16rem 0;
  font-weight: 700;
  font-size: 0.76rem;
  color: var(--text);
}

.meta-right {
  display: flex;
  gap: 0.3rem;
  align-items: center;
  justify-content: flex-end;
}

.meta-content {
  line-height: 1.38;
}

.score {
  font-weight: 400;
  color: #2f2f2f;
}

.meta-key {
  font-weight: 600;
  color: var(--text);
}

.meta-value {
  color: var(--muted);
}

.meta-link {
  color: #0f4a8a;
  text-decoration: none;
  border-bottom: 1px solid rgba(15, 74, 138, 0.4);
}

.meta-link:hover {
  text-decoration: none;
  border-bottom-color: #0f4a8a;
}

.detail-shell {
  width: min(1260px, 95vw);
  margin: 0 auto;
  padding: 1.2rem 0 2.2rem;
}

.detail-header {
  border-top: 1px solid var(--line);
  padding-top: 0.9rem;
  margin-bottom: 0.85rem;
  text-align: center;
}

.detail-title {
  margin: 0;
  font-size: 1.45rem;
  font-weight: 700;
}

.detail-subtitle {
  margin: 0.26rem 0 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.detail-top {
  border-top: 1px solid var(--line);
  padding-top: 0.8rem;
  display: grid;
  grid-template-columns: minmax(300px, 420px) 1fr;
  gap: 0.9rem;
}

.detail-hero {
  border: 1px solid var(--line);
  padding: 0.5rem;
  background: #fff;
}

.detail-hero img {
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  display: block;
}

.detail-actions {
  margin-top: 0.45rem;
  display: flex;
  gap: 0.45rem;
  flex-wrap: wrap;
}

.detail-action {
  border: 1px solid #000;
  padding: 0.28rem 0.5rem;
  font-size: 0.78rem;
  text-decoration: none;
  color: #000;
}

.detail-action:hover {
  background: #000;
  color: #fff;
}

.detail-metadata {
  border: 1px solid var(--line);
  padding: 0.6rem;
  background: #fff;
}

.detail-metadata h3 {
  margin: 0 0 0.4rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  font-size: 0.84rem;
}

.detail-metadata-list {
  margin: 0;
  display: grid;
  gap: 0.24rem;
}

.detail-metadata-row {
  font-size: 0.8rem;
  color: var(--muted);
}

.detail-metadata-row strong {
  color: var(--text);
}

.detail-sections {
  margin-top: 1rem;
  display: grid;
  gap: 0.8rem;
}

.detail-footer-nav {
  margin-top: 1rem;
  border-top: 1px solid var(--line);
  padding-top: 0.8rem;
  display: flex;
  justify-content: center;
}

.detail-footer-nav .detail-action {
  min-width: 220px;
  text-align: center;
}

.detail-action--primary {
  background: #000;
  color: #fff;
}

.detail-action--primary:hover {
  background: #fff;
  color: #000;
}

@keyframes card-rise {
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

@media (max-width: 900px) {
  .hero {
    text-align: center;
  }

  .search-form {
    width: 100%;
  }

  .thumb-row {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

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

@media (max-width: 560px) {
  .shell {
    width: 96vw;
    padding-top: 0.9rem;
  }

  h1 {
    font-size: clamp(1.7rem, 8vw, 2.2rem);
  }

  .thumb-row {
    grid-template-columns: 1fr;
  }
}
