:root {
  color-scheme: light;
  --paper: #f3f2ed;
  --card: #fffefa;
  --ink: #1d302e;
  --muted: #66736f;
  --line: #d8ddd7;
  --teal: #195f58;
  --teal-dark: #124b45;
  --teal-soft: #e5f0eb;
  --amber: #9a5b09;
  --amber-soft: #fff0d4;
  --red: #a53d32;
  --red-soft: #fae8e4;
  --shadow: 0 5px 22px rgb(28 48 42 / 6%);
  font-family: "Segoe UI", Arial, sans-serif;
  background: var(--paper);
  color: var(--ink);
  font-synthesis: none;
  text-rendering: optimizeLegibility;
}

* { box-sizing: border-box; }
body { margin: 0; min-width: 320px; }
button, input, select { font: inherit; }
button, a, select { -webkit-tap-highlight-color: transparent; }
a { color: inherit; }

.shell { width: min(1160px, calc(100% - 40px)); margin: 0 auto; }
.topbar { padding: 24px 0 18px; border-bottom: 1px solid var(--line); }
.brand-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.brand { display: flex; align-items: center; gap: 13px; min-width: 0; }
.brand-mark { display: grid; width: 42px; height: 42px; place-items: center; border-radius: 13px; color: white; background: var(--teal); font-size: 21px; font-weight: 700; }
.brand h1 { margin: 0; font-size: 22px; line-height: 1.1; letter-spacing: -.025em; }
.brand p { margin: 5px 0 0; color: var(--muted); font-size: 13px; }
.top-count { padding: 8px 12px; color: var(--teal-dark); background: var(--teal-soft); border-radius: 999px; font-size: 13px; font-weight: 650; white-space: nowrap; }
main { padding: 25px 0 54px; }
.intro { display: flex; justify-content: space-between; align-items: end; gap: 20px; margin: 0 0 18px; }
.intro h2 { margin: 0; font-size: clamp(23px, 3vw, 31px); letter-spacing: -.035em; }
.intro p { max-width: 520px; margin: 7px 0 0; color: var(--muted); font-size: 14px; line-height: 1.45; }
.filters { display: grid; grid-template-columns: minmax(220px, 2fr) repeat(4, minmax(130px, 1fr)); gap: 10px; padding: 13px; border: 1px solid var(--line); border-radius: 16px; background: var(--card); box-shadow: var(--shadow); }
.field { display: grid; gap: 6px; min-width: 0; }
.field label { color: var(--muted); font-size: 11px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; }
.field input, .field select { width: 100%; height: 42px; padding: 0 11px; color: var(--ink); border: 1px solid var(--line); border-radius: 10px; outline: none; background: white; }
.field input:focus, .field select:focus { border-color: var(--teal); box-shadow: 0 0 0 3px rgb(25 95 88 / 12%); }
.list-toolbar { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin: 18px 2px 11px; color: var(--muted); font-size: 13px; }
.list-toolbar strong { color: var(--ink); }
.record-list { display: grid; gap: 9px; }
.record-card { display: block; width: 100%; padding: 15px 17px; color: inherit; text-decoration: none; border: 1px solid var(--line); border-radius: 14px; background: var(--card); box-shadow: 0 2px 9px rgb(28 48 42 / 3%); transition: border-color .15s ease, transform .15s ease, box-shadow .15s ease; }
.record-card:hover, .record-card:focus-visible { border-color: #91b8aa; box-shadow: var(--shadow); transform: translateY(-1px); outline: none; }
.record-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; }
.record-title { margin: 0; font-size: 16px; line-height: 1.35; font-weight: 700; }
.record-sub { margin-top: 5px; color: var(--muted); font-size: 12px; }
.record-grid { display: grid; grid-template-columns: 1.2fr 1fr 1.7fr .75fr .8fr; gap: 12px; margin-top: 13px; }
.record-field { min-width: 0; }
.record-field span { display: block; margin-bottom: 4px; color: var(--muted); font-size: 10px; font-weight: 700; letter-spacing: .055em; text-transform: uppercase; }
.record-field strong { display: block; overflow-wrap: anywhere; font-size: 12px; line-height: 1.4; font-weight: 550; }
.record-badges { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 6px; }
.badge { display: inline-flex; align-items: center; width: fit-content; min-height: 23px; padding: 4px 8px; border-radius: 999px; font-size: 10px; font-weight: 700; white-space: nowrap; }
.badge-found { color: var(--teal-dark); background: var(--teal-soft); }
.badge-missing { color: var(--red); background: var(--red-soft); }
.badge-ambiguous { color: var(--amber); background: var(--amber-soft); }
.badge-neutral { color: #56625e; background: #edf0ed; }
.pagination { display: flex; justify-content: center; align-items: center; gap: 10px; margin: 18px 0 0; }
.button { min-height: 40px; padding: 0 15px; border: 1px solid var(--line); border-radius: 10px; color: var(--ink); background: var(--card); font-weight: 650; cursor: pointer; }
.button:hover:not(:disabled) { border-color: #91b8aa; }
.button:disabled { opacity: .43; cursor: default; }
.page-label { min-width: 90px; color: var(--muted); text-align: center; font-size: 13px; }
.empty { padding: 36px 18px; text-align: center; color: var(--muted); border: 1px dashed #b9c4bd; border-radius: 14px; background: rgb(255 254 250 / 70%); }

.detail-top { margin-bottom: 18px; }
.back-button { display: inline-flex; align-items: center; gap: 8px; margin: 0 0 18px; padding: 8px 0; color: var(--teal-dark); border: 0; background: transparent; font-weight: 700; cursor: pointer; }
.back-button:hover { color: var(--teal); }
.detail-title-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; }
.detail-title { margin: 0; font-size: clamp(25px, 4vw, 36px); letter-spacing: -.04em; line-height: 1.15; }
.detail-meta { margin: 8px 0 0; color: var(--muted); font-size: 14px; }
.detail-layout { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(320px, .85fr); gap: 18px; align-items: start; }
.panel { padding: 18px; border: 1px solid var(--line); border-radius: 16px; background: var(--card); box-shadow: var(--shadow); }
.panel h3 { margin: 0 0 14px; font-size: 15px; }
.info-table { display: grid; grid-template-columns: minmax(125px, .8fr) minmax(0, 1.5fr); border-top: 1px solid var(--line); }
.info-table dt, .info-table dd { margin: 0; padding: 10px 0; border-bottom: 1px solid var(--line); font-size: 13px; line-height: 1.45; overflow-wrap: anywhere; }
.info-table dt { padding-right: 12px; color: var(--muted); }
.info-table dd { font-weight: 550; white-space: pre-wrap; }
.source-meta { margin-top: 15px; color: var(--muted); font-size: 12px; }
.photo-stack { display: grid; gap: 12px; }
.photo-frame { overflow: hidden; margin: 0; border: 1px solid var(--line); border-radius: 12px; background: #eef0ec; }
.photo-zoom { display: block; cursor: zoom-in; }
.photo-frame img { display: block; width: 100%; max-height: 640px; object-fit: contain; }
.photo-frame figcaption { padding: 9px 11px; color: var(--muted); border-top: 1px solid var(--line); background: var(--card); font-size: 11px; overflow-wrap: anywhere; }
.photo-empty { padding: 18px; color: var(--muted); border: 1px dashed #b9c4bd; border-radius: 12px; line-height: 1.5; background: #fafaf6; font-size: 13px; }
.note { margin: 12px 0 0; padding: 11px 12px; color: #704600; border-radius: 10px; background: var(--amber-soft); font-size: 12px; line-height: 1.5; }
.note.error { color: var(--red); background: var(--red-soft); }

.gate-wrap { display: grid; min-height: 100vh; place-items: center; padding: 20px; background: radial-gradient(ellipse at 15% 10%, #d9e9e0 0, transparent 38%), var(--paper); }
.gate-card { width: min(420px, 100%); padding: 27px; border: 1px solid var(--line); border-radius: 20px; background: var(--card); box-shadow: 0 18px 60px rgb(28 48 42 / 10%); }
.gate-card .brand { margin-bottom: 25px; }
.gate-card h2 { margin: 0; font-size: 25px; letter-spacing: -.03em; }
.gate-card p { margin: 8px 0 18px; color: var(--muted); font-size: 14px; line-height: 1.5; }
.gate-card form { display: grid; gap: 10px; }
.gate-card input { width: 100%; height: 47px; padding: 0 13px; border: 1px solid var(--line); border-radius: 11px; outline: none; }
.gate-card input:focus { border-color: var(--teal); box-shadow: 0 0 0 3px rgb(25 95 88 / 12%); }
.primary-button { height: 46px; color: white; border: 0; border-radius: 11px; background: var(--teal); font-weight: 700; cursor: pointer; }
.primary-button:hover { background: var(--teal-dark); }
.gate-error { min-height: 17px; margin: 0 !important; color: var(--red) !important; font-size: 12px !important; }
.footer { padding: 14px 0 0; color: #82908a; text-align: center; font-size: 11px; }
.loading { padding: 60px 10px; color: var(--muted); text-align: center; }

@media (max-width: 850px) {
  .filters { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .field-search { grid-column: 1 / -1; }
  .record-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .detail-layout { grid-template-columns: 1fr; }
}

@media (max-width: 560px) {
  .shell { width: min(100% - 24px, 1160px); }
  .topbar { padding: 17px 0 14px; }
  .brand-mark { width: 38px; height: 38px; }
  .brand h1 { font-size: 19px; }
  .brand p { font-size: 11px; }
  .top-count { padding: 7px 9px; font-size: 11px; }
  main { padding-top: 19px; }
  .intro { display: block; }
  .intro p { font-size: 13px; }
  .filters { gap: 8px; padding: 10px; border-radius: 13px; }
  .field input, .field select { height: 40px; padding: 0 8px; font-size: 13px; }
  .field label { font-size: 10px; }
  .record-card { padding: 13px; }
  .record-head { display: block; }
  .record-title { font-size: 15px; }
  .record-badges { justify-content: flex-start; margin-top: 9px; }
  .record-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 11px 9px; margin-top: 12px; }
  .record-field strong { font-size: 12px; }
  .record-field-wide { grid-column: 1 / -1; }
  .list-toolbar { align-items: flex-start; font-size: 12px; }
  .detail-title-row { display: block; }
  .detail-title-row .badge { margin-top: 10px; }
  .panel { padding: 14px; }
  .info-table { grid-template-columns: minmax(105px, .75fr) minmax(0, 1.3fr); }
  .info-table dt, .info-table dd { font-size: 12px; }
}
