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

:root {
  --bg: #f4f6f8;
  --surface: #ffffff;
  --text: #1a1a2e;
  --text-muted: #5c6370;
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --danger: #dc2626;
  --danger-hover: #b91c1c;
  --border: #e2e8f0;
  --success: #059669;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
  --radius: 12px;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
}

.container {
  max-width: 720px;
  margin: 0 auto;
  padding: 0 1rem;
}

.header {
  background: var(--text);
  color: #fff;
  padding: 2rem 0;
  margin-bottom: 1.5rem;
}

.header h1 {
  font-size: 1.75rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
}

.subtitle {
  opacity: 0.85;
  font-size: 1rem;
}

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

.card h2 {
  font-size: 1.125rem;
  margin-bottom: 1rem;
}

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}

.section-header h2 { margin-bottom: 0; }

.mode-badge {
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.35rem 0.65rem;
  border-radius: 999px;
}

.mode-badge-ai { background: #dcfce7; color: #166534; }
.mode-badge-local { background: #e0e7ff; color: #3730a3; }

.field-hint {
  margin-top: 0.375rem;
  font-size: 0.8125rem;
  color: var(--text-muted);
}

.section-divider {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin: 1.5rem 0;
  color: var(--text-muted);
  font-size: 0.875rem;
  font-weight: 600;
}

.section-divider::before,
.section-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

#parseTextListBtn { width: 100%; margin-top: 0.5rem; }

.setup-banner {
  background: #fef3c7;
  border: 1px solid #f59e0b;
  color: #92400e;
  padding: 0.875rem 1rem;
  border-radius: var(--radius);
  margin-bottom: 1rem;
  font-size: 0.9rem;
}

.form-row textarea {
  width: 100%;
  padding: 0.75rem 1rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 1rem;
  font-family: inherit;
  resize: vertical;
  min-height: 120px;
}

.form-row textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

.preview-file {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 80px;
  padding: 0.5rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  font-size: 0.75rem;
  color: var(--text-muted);
  text-align: center;
}

.review-item {
  display: flex;
  gap: 0.5rem;
  align-items: flex-start;
}

.review-fields { flex: 1; min-width: 0; }
.review-fields input { width: 100%; }

.review-hospital {
  display: block;
  margin-top: 0.25rem;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.form-row {
  margin-bottom: 1rem;
}

.form-row label {
  display: block;
  font-size: 0.875rem;
  font-weight: 600;
  margin-bottom: 0.375rem;
}

.form-row input,
.search-box input,
.review-item input {
  width: 100%;
  padding: 0.75rem 1rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 1rem;
  transition: border-color 0.15s;
}

.form-row input:focus,
.search-box input:focus,
.review-item input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

.dropzone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 2.5rem 1.5rem;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}

.dropzone:hover,
.dropzone.dragover {
  border-color: var(--primary);
  background: rgba(37, 99, 235, 0.04);
}

.dropzone-icon {
  font-size: 2.5rem;
  display: block;
  margin-bottom: 0.5rem;
}

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

.preview-area {
  margin-top: 1rem;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
  gap: 0.5rem;
}

.preview-area img {
  width: 100%;
  height: 80px;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid var(--border);
}

.progress-area {
  margin-top: 1rem;
}

.progress-bar {
  height: 8px;
  background: var(--border);
  border-radius: 4px;
  overflow: hidden;
  margin-bottom: 0.5rem;
}

.progress-fill {
  height: 100%;
  background: var(--primary);
  width: 0%;
  transition: width 0.2s;
}

.review-area {
  margin-top: 1.5rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
}

.review-area h3 {
  font-size: 1rem;
  margin-bottom: 0.25rem;
}

.review-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin: 1rem 0;
  max-height: 320px;
  overflow-y: auto;
}

.review-actions {
  display: flex;
  gap: 0.75rem;
  justify-content: flex-end;
  flex-wrap: wrap;
}

.search-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
}

.search-header h2 {
  margin-bottom: 0;
}

.count-badge {
  background: var(--bg);
  color: var(--text-muted);
  font-size: 0.8125rem;
  font-weight: 600;
  padding: 0.25rem 0.75rem;
  border-radius: 999px;
}

.search-box {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.search-box input {
  flex: 1;
}

.toolbar {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.75rem 1.25rem;
  border: none;
  border-radius: 8px;
  font-size: 0.9375rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s;
}

.btn:active {
  transform: scale(0.98);
}

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

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

.btn-secondary {
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
}

.btn-secondary:hover {
  background: var(--border);
}

.btn-danger {
  background: #fef2f2;
  color: var(--danger);
  border: 1px solid #fecaca;
}

.btn-danger:hover {
  background: #fee2e2;
}

.btn-sm {
  padding: 0.5rem 1rem;
  font-size: 0.8125rem;
}

.btn-icon {
  padding: 0.75rem;
  min-width: 44px;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text-muted);
}

.btn-icon:hover {
  background: var(--border);
}

.btn-remove {
  background: none;
  border: none;
  color: var(--danger);
  font-size: 1.25rem;
  cursor: pointer;
  padding: 0.25rem 0.5rem;
  line-height: 1;
}

.results-list {
  min-height: 120px;
}

.person-card {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem;
  border-bottom: 1px solid var(--border);
}

.person-card:last-child {
  border-bottom: none;
}

.person-info {
  flex: 1;
}

.person-name {
  font-size: 1.0625rem;
  font-weight: 600;
  margin-bottom: 0.25rem;
}

.person-meta {
  font-size: 0.8125rem;
  color: var(--text-muted);
}

.person-meta span + span::before {
  content: " · ";
}

.empty-state {
  color: var(--text-muted);
  text-align: center;
  padding: 2rem 1rem;
}

.no-results {
  color: var(--text-muted);
  text-align: center;
  padding: 1.5rem;
}

.hidden {
  display: none !important;
}

.footer {
  padding: 2rem 0;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.8125rem;
}

mark {
  background: #fef08a;
  padding: 0 2px;
  border-radius: 2px;
}

@media (max-width: 480px) {
  .header h1 {
    font-size: 1.375rem;
  }

  .review-actions {
    flex-direction: column;
  }

  .review-actions .btn {
    width: 100%;
  }
}
