*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --bg: #0a0c10;
  --surface: #151820;
  --surface-elevated: #1c2030;
  --border: #262a3a;
  --border-hover: #3a3f54;
  --text: #e8e8ec;
  --text-muted: #8b8fa4;
  --text-dim: #5c6078;
  --accent: #6366f1;
  --accent-hover: #818cf8;
  --accent-glow: rgba(99, 102, 241, 0.12);
  --success: #22c55e;
  --success-bg: rgba(34, 197, 94, 0.08);
  --warning: #f59e0b;
  --warning-bg: rgba(245, 158, 11, 0.08);
  --error: #ef4444;
  --error-bg: rgba(239, 68, 68, 0.08);
  --radius: 12px;
  --radius-sm: 8px;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Inter", sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
  padding: 2rem 1.5rem;
  max-width: 760px;
  margin: 0 auto;
}

/* ---- Header ---- */

header {
  text-align: center;
  margin-bottom: 2.5rem;
}

.brand {
  margin-bottom: 0.75rem;
}

h1 {
  font-size: 2.2rem;
  font-weight: 300;
  letter-spacing: -0.03em;
}

h1 .accent {
  font-weight: 700;
  color: var(--accent);
}

.tagline {
  color: var(--text-muted);
  font-size: 1.05rem;
  margin-top: 0.25rem;
}

.description {
  color: var(--text-dim);
  font-size: 0.88rem;
  max-width: 540px;
  margin: 0 auto;
  line-height: 1.65;
}

/* ---- Cards ---- */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  margin-bottom: 1.5rem;
}

.card-header {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin-bottom: 0.75rem;
}

.card-header h2 {
  font-size: 1.05rem;
  font-weight: 600;
}

.step-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--accent);
  color: white;
  font-size: 0.75rem;
  font-weight: 700;
  flex-shrink: 0;
}

.match-badge { background: var(--success); }
.ambiguous-badge { background: var(--warning); color: #000; }
.nomatch-badge { background: var(--text-dim); }
.error-badge { background: var(--error); }
.demo-badge { background: var(--surface-elevated); color: var(--accent); border: 1px solid var(--border); }

/* ---- Drop zone ---- */

#drop-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 2rem;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
  min-height: 120px;
  display: flex;
  align-items: center;
  justify-content: center;
}

#drop-zone:hover,
#drop-zone.dragover {
  border-color: var(--accent);
  background: var(--accent-glow);
}

.upload-icon {
  width: 32px;
  height: 32px;
  color: var(--text-dim);
  margin-bottom: 0.5rem;
}

#drop-prompt p {
  color: var(--text-muted);
  font-size: 0.9rem;
  margin: 0;
}

#drop-prompt .hint {
  font-size: 0.78rem;
  color: var(--text-dim);
  margin-top: 0.35rem;
}

#browse-btn {
  background: none;
  border: none;
  color: var(--accent);
  cursor: pointer;
  text-decoration: underline;
  font-size: inherit;
  padding: 0;
}

/* ---- Drop preview ---- */

#drop-preview {
  display: flex;
  align-items: center;
  gap: 1rem;
  width: 100%;
}

#preview-img {
  width: 72px;
  height: 72px;
  object-fit: cover;
  border-radius: var(--radius-sm);
  background: var(--border);
}

.preview-info {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  text-align: left;
}

#preview-name {
  font-size: 0.85rem;
  color: var(--text);
  word-break: break-all;
}

#clear-btn {
  background: none;
  border: none;
  color: var(--accent);
  cursor: pointer;
  font-size: 0.8rem;
  padding: 0;
  text-decoration: underline;
  text-align: left;
}

/* ---- Verify button ---- */

#verify-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  width: 100%;
  margin-top: 1rem;
  padding: 0.8rem;
  background: var(--accent);
  color: white;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s, opacity 0.2s;
}

#verify-btn svg {
  width: 18px;
  height: 18px;
}

#verify-btn:hover:not(:disabled) {
  background: var(--accent-hover);
}

#verify-btn:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

/* ---- Result section ---- */

.hidden {
  display: none !important;
}

.fade-in {
  animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ---- Loading ---- */

.spinner {
  width: 36px;
  height: 36px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 1.5rem auto 0.75rem;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.loading-text {
  text-align: center;
  color: var(--text-muted);
  font-size: 0.9rem;
}

/* ---- Passport card ---- */

.passport-body {
  display: flex;
  gap: 1.5rem;
  margin-top: 0.5rem;
}

.passport-preview {
  flex: 0 0 140px;
}

.passport-preview img {
  width: 140px;
  height: 140px;
  object-fit: cover;
  border-radius: var(--radius-sm);
  background: var(--border);
  border: 1px solid var(--border);
}

.passport-meta {
  flex: 1;
  min-width: 0;
}

.passport-title {
  font-size: 1.1rem;
  font-weight: 600;
  margin-bottom: 0.6rem;
  line-height: 1.3;
}

.meta-grid {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.2rem 0.75rem;
  font-size: 0.85rem;
  margin-bottom: 0.75rem;
}

.meta-grid dt {
  color: var(--text-dim);
  font-weight: 500;
}

.meta-grid dd {
  color: var(--text);
}

.meta-grid dd a {
  color: var(--accent);
  text-decoration: none;
}

.meta-grid dd a:hover {
  text-decoration: underline;
}

.confidence-pill {
  margin-left: auto;
  font-size: 0.72rem;
  font-weight: 600;
  padding: 0.2rem 0.6rem;
  border-radius: 20px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  cursor: help;
}

.verification-method {
  font-size: 0.78rem;
  color: var(--text-dim);
  margin-bottom: 0.25rem;
}

.confidence-pill.high {
  background: var(--success-bg);
  color: var(--success);
}

.confidence-pill.medium {
  background: var(--warning-bg);
  color: var(--warning);
}

.confidence-pill.low {
  background: var(--error-bg);
  color: var(--error);
}

/* ---- Source link ---- */

.source-link-box {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.6rem 0.75rem;
  margin-bottom: 0.6rem;
}

.source-link-box label {
  display: block;
  font-size: 0.68rem;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 0.15rem;
  font-weight: 500;
}

.source-link-box a {
  color: var(--accent);
  text-decoration: none;
  font-size: 0.82rem;
  word-break: break-all;
}

.source-link-box a:hover {
  text-decoration: underline;
}

/* ---- Attribution box ---- */

.attribution-box {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.6rem 0.75rem;
}

.attribution-box label {
  display: block;
  font-size: 0.68rem;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 0.2rem;
  font-weight: 500;
}

.copyable {
  font-size: 0.82rem;
  margin-bottom: 0.4rem;
  word-break: break-word;
  line-height: 1.5;
  color: var(--text-muted);
}

#copy-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  background: var(--surface-elevated);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.3rem 0.7rem;
  font-size: 0.75rem;
  cursor: pointer;
  transition: border-color 0.2s;
}

#copy-btn svg {
  width: 13px;
  height: 13px;
}

#copy-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

/* ---- Ambiguous match ---- */

.state-description {
  color: var(--text-muted);
  font-size: 0.88rem;
  margin-bottom: 1rem;
  line-height: 1.6;
}

.candidates-grid {
  display: grid;
  gap: 0.75rem;
}

.candidate-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 1rem;
  transition: border-color 0.2s;
}

.candidate-card:hover {
  border-color: var(--border-hover);
}

.candidate-card h4 {
  font-size: 0.95rem;
  font-weight: 600;
  margin-bottom: 0.5rem;
}

.candidate-card dl {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.15rem 0.6rem;
  font-size: 0.82rem;
  margin-bottom: 0.5rem;
}

.candidate-card dt {
  color: var(--text-dim);
}

.candidate-link {
  color: var(--accent);
  text-decoration: none;
  font-size: 0.82rem;
}

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

/* ---- No match ---- */

.suggestions {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.75rem 1rem;
}

.suggestion-label {
  font-size: 0.78rem;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 0.4rem;
  font-weight: 500;
}

.suggestions ul {
  list-style: none;
  padding: 0;
}

.suggestions li {
  font-size: 0.82rem;
  color: var(--text-muted);
  padding: 0.2rem 0;
  padding-left: 1rem;
  position: relative;
}

.suggestions li::before {
  content: "\2022";
  color: var(--text-dim);
  position: absolute;
  left: 0;
}

/* ---- Reset button ---- */

#reset-btn {
  display: block;
  width: 100%;
  margin-top: 1rem;
  padding: 0.6rem;
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  cursor: pointer;
  transition: border-color 0.2s, color 0.2s;
}

#reset-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

/* ---- Demo section ---- */

.demo-explanation {
  color: var(--text-dim);
  font-size: 0.82rem;
  margin-bottom: 0.75rem;
}

.demo-buttons {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 0.6rem;
}

.demo-btn {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.75rem 1rem;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
  text-align: left;
}

.demo-btn:hover {
  border-color: var(--accent);
  background: var(--accent-glow);
}

.demo-btn-title {
  font-size: 0.88rem;
  font-weight: 600;
}

.demo-btn-sub {
  font-size: 0.75rem;
  color: var(--text-dim);
  margin-top: 0.15rem;
}

/* ---- Footer ---- */

footer {
  text-align: center;
  padding: 2.5rem 0 1rem;
}

.footer-brand {
  font-size: 0.85rem;
  color: var(--text-dim);
  font-weight: 600;
  letter-spacing: -0.01em;
}

.footer-tagline {
  font-size: 0.75rem;
  color: var(--text-dim);
  margin-top: 0.25rem;
  line-height: 1.6;
}

/* ---- Responsive ---- */

@media (max-width: 600px) {
  body {
    padding: 1rem;
  }

  h1 {
    font-size: 1.8rem;
  }

  .passport-body {
    flex-direction: column;
  }

  .passport-preview {
    flex: none;
    text-align: center;
  }

  .passport-preview img {
    width: 120px;
    height: 120px;
  }

  .demo-buttons {
    grid-template-columns: 1fr;
  }
}
