:root {
  --bg: #0f172a;
  --panel: #f8fafc;
  --text: #0f172a;
  --muted: #64748b;
  --accent: #b91c1c;
  --accent-hover: #991b1b;
  --border: #cbd5e1;
  --shadow: 0 12px 32px rgba(15, 23, 42, 0.28);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100dvh;
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  color: var(--text);
  background: linear-gradient(145deg, #0f172a 0%, #1c1917 42%, #7f1d1d 100%);
}

.app-header {
  display: grid;
  grid-template-columns: minmax(8rem, 1fr) auto minmax(8rem, 1fr);
  align-items: start;
  gap: 1rem;
  padding: 1.25rem 1.5rem 0.75rem;
  color: #f1f5f9;
}

.app-header__center {
  text-align: center;
  justify-self: center;
  min-width: 0;
}

.app-header__center h1 {
  margin: 0;
  font-size: clamp(1.6rem, 4vw, 2.15rem);
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  line-height: 1.15;
}

.title-3d {
  color: #f8fafc;
  text-shadow:
    1px 1px 0 #cbd5e1,
    2px 2px 0 #94a3b8,
    3px 3px 0 #64748b,
    4px 4px 0 #475569,
    5px 5px 8px rgba(0, 0, 0, 0.55);
}

.title-wanted {
  color: #ef4444;
  text-shadow:
    1px 1px 0 #dc2626,
    2px 2px 0 #b91c1c,
    3px 3px 0 #7f1d1d,
    4px 4px 0 #450a0a,
    5px 5px 10px rgba(0, 0, 0, 0.6);
}

.app-header__sub {
  margin: 0.3rem 0 0;
  color: #fff;
  font-size: 0.9rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.portal-back-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  text-decoration: none;
  white-space: nowrap;
  font-size: 0.875rem;
  font-weight: 600;
  padding: 0.45rem 0.9rem;
  border-radius: 4px;
  border: 1px solid rgba(148, 163, 184, 0.65);
  background: rgba(248, 250, 252, 0.96);
  color: #0f172a;
  justify-self: start;
  align-self: center;
}

.portal-back-btn:hover {
  background: #ffffff;
  text-decoration: none;
  color: #0f172a;
}

.back-link {
  color: #fecaca;
  text-decoration: none;
  font-size: 0.9rem;
  justify-self: start;
  align-self: center;
}

.back-link:hover { text-decoration: underline; }

.app-header__actions {
  justify-self: end;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.35rem;
}

.app-help-btn {
  width: 2.5rem;
  height: 2.5rem;
  border: none;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.75);
  color: #e2e8f0;
  cursor: pointer;
  display: grid;
  place-items: center;
}
.app-help-btn:hover {
  background: rgba(15, 23, 42, 0.92);
  color: #fff;
}
.app-help-btn svg {
  width: 1.15rem;
  height: 1.15rem;
}

.app-root {
  max-width: 1680px;
  margin: 0 auto;
  padding: 0.5rem 1.25rem 2rem;
}

.toolbar {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0.75rem;
  background: rgba(248, 250, 252, 0.96);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 0.9rem;
  box-shadow: var(--shadow);
  margin-bottom: 1rem;
}

.toolbar__row {
  display: grid;
  grid-template-columns: minmax(12rem, 2fr) minmax(7rem, 0.8fr) minmax(9rem, 1fr) auto;
  gap: 0.65rem;
  align-items: end;
}

.toolbar__row--sort {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  gap: 0.65rem;
  padding-top: 0.35rem;
  border-top: 1px solid rgba(148, 163, 184, 0.35);
}

.field--sort {
  flex: 0 1 16rem;
  max-width: 18rem;
  min-width: 12rem;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  min-width: 0;
  width: 100%;
}

.field label {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.field input,
.field select {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.5rem 0.65rem;
  font: inherit;
  background: #fff;
  width: 100%;
  min-width: 0;
}

.btn-row {
  display: flex;
  gap: 0.45rem;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-start;
  padding-bottom: 0.05rem;
}

@media (max-width: 900px) {
  .toolbar__row {
    grid-template-columns: 1fr 1fr;
  }
  .toolbar__row .btn-row {
    grid-column: 1 / -1;
  }
}

@media (max-width: 560px) {
  .toolbar__row {
    grid-template-columns: 1fr;
  }
}

.btn {
  border: 0;
  border-radius: 8px;
  padding: 0.55rem 0.9rem;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
}

.btn-primary:hover { background: var(--accent-hover); }

.btn-ghost {
  background: #e2e8f0;
  color: #0f172a;
}

.btn-ghost:hover { background: #cbd5e1; }

.btn-back-top {
  background: #2563eb;
  color: #fff;
}

.btn-back-top:hover { background: #1d4ed8; }

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

.status-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: center;
  justify-content: space-between;
  color: #fecaca;
  margin: 0.25rem 0 0.85rem;
  font-size: 0.92rem;
}

.status-bar__load {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.45rem;
  color: #0f172a;
}

.status-bar__load label {
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #fecaca;
}

.status-bar__load select {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.4rem 0.55rem;
  font: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  background: #fff;
  color: #0f172a;
  min-width: 14.5rem;
}

.status-bar__load .btn {
  padding: 0.4rem 0.75rem;
  font-size: 0.85rem;
}

.tip-wrap {
  position: relative;
  display: inline-flex;
  align-items: center;
}

.tip-wrap::after {
  content: attr(data-tip);
  position: absolute;
  right: 0;
  bottom: calc(100% + 0.45rem);
  z-index: 30;
  width: max-content;
  max-width: min(16.5rem, 70vw);
  padding: 0.45rem 0.6rem;
  border-radius: 8px;
  background: #0f172a;
  color: #f8fafc;
  font-size: 0.75rem;
  font-weight: 600;
  line-height: 1.35;
  box-shadow: 0 8px 20px rgba(15, 23, 42, 0.35);
  opacity: 0;
  visibility: hidden;
  transform: translateY(0.2rem);
  transition: opacity 0.12s ease, transform 0.12s ease, visibility 0.12s ease;
  pointer-events: none;
  text-align: left;
}

.tip-wrap::before {
  content: '';
  position: absolute;
  right: 0.85rem;
  bottom: calc(100% + 0.15rem);
  z-index: 31;
  border: 6px solid transparent;
  border-top-color: #0f172a;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.12s ease, visibility 0.12s ease;
  pointer-events: none;
}

.tip-wrap:hover::after,
.tip-wrap:focus-within::after,
.tip-wrap:hover::before,
.tip-wrap:focus-within::before {
  opacity: 1;
  visibility: visible;
  transform: none;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.status-bar strong { color: #fff; }

.grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 0.9rem;
}

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

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

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

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

.card {
  background: var(--panel);
  border-radius: 14px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.15);
  box-shadow: var(--shadow);
  cursor: pointer;
  text-align: left;
  padding: 0;
  font: inherit;
  color: inherit;
  display: flex;
  flex-direction: column;
  min-height: 100%;
}

.card:hover { transform: translateY(-2px); }

.card__media {
  aspect-ratio: 4 / 5;
  background: #1e293b;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

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

.card__placeholder {
  color: #94a3b8;
  font-size: 0.85rem;
  padding: 1rem;
  text-align: center;
}

.card__body {
  padding: 0.75rem 0.85rem 0.95rem;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  flex: 1;
}

.card__badges {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.badge {
  display: inline-block;
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  border-radius: 999px;
  padding: 0.18rem 0.5rem;
}

.badge-fbi {
  background: #1e3a8a;
  color: #dbeafe;
}

.card__title {
  margin: 0;
  font-size: 1rem;
  line-height: 1.25;
}

.card__meta {
  margin: 0;
  color: var(--muted);
  font-size: 0.82rem;
}

.card__kind {
  margin-top: auto;
  padding: 0.45rem 0.65rem;
  text-align: center;
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #fff;
  border-top: 1px solid rgba(255, 255, 255, 0.12);
}

.card__kind--wanted {
  background: #991b1b;
}

.card__kind--missing {
  background: #1d4ed8;
}

.card__kind--seeking_info {
  background: #b45309;
}

.load-more {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 0.75rem 1rem;
  margin: 1.25rem 0 0.5rem;
  padding: 1rem;
  background: rgba(248, 250, 252, 0.96);
  border: 1px solid var(--border);
  border-radius: 0.75rem;
  text-align: center;
}

.load-more__meta {
  flex: 1 1 100%;
  margin: 0;
  font-size: 0.88rem;
  color: #475569;
}

.load-more__actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 0.65rem;
}

.empty,
.error,
.loading {
  background: rgba(248, 250, 252, 0.95);
  border-radius: 12px;
  padding: 1.25rem;
  text-align: center;
  color: #334155;
}

.error { color: #991b1b; background: #fee2e2; }

.disclaimer {
  max-width: 1680px;
  margin: 0 auto 1.5rem;
  padding: 0 1.25rem;
  color: #fecaca;
  font-size: 0.8rem;
  line-height: 1.45;
}

.record-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.72);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  z-index: 40;
}

.record-modal-overlay.is-open { display: flex; }

.record-modal {
  width: min(900px, 100%);
  max-height: min(94dvh, 1100px);
  overflow: auto;
  background: #fff;
  border-radius: 14px;
  box-shadow: var(--shadow);
}

.record-modal__head {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  align-items: center;
  padding: 0.9rem 1rem;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: #fff;
  z-index: 1;
}

.record-modal__head h2 {
  margin: 0;
  font-size: 1.1rem;
}

.record-modal__actions {
  display: flex;
  gap: 0.45rem;
  flex-wrap: wrap;
}

.record-modal__body { padding: 0.75rem 1rem 1rem; }

.poster-viewer {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.poster-progress {
  padding: 1.25rem 1rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #f8fafc;
  text-align: center;
}

.poster-progress__label {
  margin: 0 0 0.75rem;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text);
}

.poster-progress__track {
  height: 10px;
  border-radius: 999px;
  background: #e2e8f0;
  overflow: hidden;
}

.poster-progress__bar {
  height: 100%;
  width: 0%;
  border-radius: 999px;
  background: linear-gradient(90deg, #b91c1c, #ef4444);
  transition: width 0.18s ease;
}

.poster-progress.is-indeterminate .poster-progress__bar {
  width: 40% !important;
  animation: poster-indeterminate 1.1s ease-in-out infinite;
}

@keyframes poster-indeterminate {
  0% { transform: translateX(-120%); }
  100% { transform: translateX(280%); }
}

.poster-progress__pct {
  margin: 0.55rem 0 0;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--muted);
}

.poster-error {
  padding: 0.85rem 1rem;
  border-radius: 8px;
  border: 1px solid #fecaca;
  background: #fef2f2;
  color: #991b1b;
  font-size: 0.9rem;
}

.poster-pages {
  max-height: min(78dvh, 980px);
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #334155;
  padding: 0.75rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
}

.poster-page {
  display: block;
  width: 100%;
  height: auto;
  background: #fff;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.35);
}

.poster-langs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  align-items: center;
}

.poster-langs span {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.poster-langs button {
  border: 1px solid var(--border);
  background: #fff;
  color: var(--text);
  border-radius: 999px;
  padding: 0.28rem 0.7rem;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
}

.poster-langs button.is-active {
  background: #fee2e2;
  border-color: #fca5a5;
  color: #991b1b;
}

.poster-missing {
  padding: 1.25rem;
  border: 1px dashed var(--border);
  border-radius: 10px;
  color: var(--muted);
  text-align: center;
}

.poster-fallback-note {
  margin: 0 0 0.85rem;
  padding: 0.7rem 0.85rem;
  border-radius: 8px;
  border: 1px solid #fca5a5;
  background: #fef2f2;
  color: #991b1b;
  font-size: 0.86rem;
  line-height: 1.4;
}

.detail {
  display: grid;
  grid-template-columns: minmax(140px, 220px) 1fr;
  gap: 1rem;
}

.detail__photo {
  width: 100%;
  border-radius: 10px;
  background: #0f172a;
  aspect-ratio: 4 / 5;
  object-fit: cover;
}

.detail dl {
  margin: 0;
  display: grid;
  grid-template-columns: 7.5rem 1fr;
  gap: 0.35rem 0.75rem;
}

.detail dt {
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
}

.detail dd {
  margin: 0;
  font-size: 0.95rem;
}

.detail__block {
  margin-top: 0.85rem;
}

.detail__block h3 {
  margin: 0 0 0.35rem;
  font-size: 0.85rem;
  text-transform: uppercase;
  color: var(--muted);
}

.detail__block p {
  margin: 0;
  white-space: pre-wrap;
  line-height: 1.45;
}

@media (max-width: 700px) {
  .app-header {
    grid-template-columns: 1fr;
    text-align: center;
  }
  .back-link { justify-self: center; }
  .detail { grid-template-columns: 1fr; }
  .detail__photo { max-width: 260px; margin: 0 auto; }
  .poster-pages { max-height: min(70dvh, 720px); }
}

@media print {
  .no-print { display: none !important; }
  body { background: #fff; color: #0f172a; }
  .record-modal-overlay {
    display: block !important;
    position: static;
    background: transparent;
    padding: 0;
  }
  .record-modal {
    width: 100%;
    max-height: none;
    overflow: visible;
    box-shadow: none;
    border-radius: 0;
  }
  .record-modal__body { padding: 0; }
  .poster-progress,
  .poster-langs,
  .poster-error { display: none !important; }
  .poster-pages {
    max-height: none;
    overflow: visible;
    border: 0;
    border-radius: 0;
    background: #fff;
    padding: 0;
  }
  .poster-page {
    box-shadow: none;
    page-break-after: always;
    break-after: page;
  }
  .detail {
    display: grid;
    grid-template-columns: minmax(140px, 220px) 1fr;
    gap: 1rem;
    page-break-inside: avoid;
  }
  .detail__photo {
    max-width: 220px;
    box-shadow: none;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }
  .detail dt,
  .detail dd,
  .detail__block p {
    color: #0f172a;
  }
}
