/* ── 전역 리셋 & 기본 ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --accent:       #2563EB;
  --accent-hover: #1D4ED8;
  --accent-light: #EFF6FF;
  --found-bg:     #DCFCE7;
  --found-fg:     #166534;
  --found-border: #86EFAC;
  --missing-bg:   #FEE2E2;
  --missing-fg:   #991B1B;
  --missing-border:#FCA5A5;
  --surface:      #FFFFFF;
  --bg:           #F3F4F6;
  --border:       #E5E7EB;
  --text:         #111827;
  --muted:        #6B7280;
  --radius:       10px;
  --shadow:       0 1px 4px rgba(0,0,0,.08), 0 2px 12px rgba(0,0,0,.06);
}

body {
  font-family: "Malgun Gothic", "맑은 고딕", "Apple SD Gothic Neo", sans-serif;
  font-size: 14px;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  padding: 24px 16px 48px;
}

/* ── 레이아웃 ── */
.container {
  max-width: 780px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* ── 헤더 ── */
header {
  text-align: center;
  padding: 8px 0 4px;
}
header h1 {
  font-size: 22px;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: -0.3px;
}
.subtitle {
  font-size: 12px;
  color: var(--muted);
  margin-top: 2px;
  letter-spacing: 0.5px;
}

/* ── 카드 ── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px 24px;
}
.card-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--muted);
  margin-bottom: 16px;
}

/* ── 입력 행 ── */
.input-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.input-hint {
  font-size: 13px;
  color: var(--muted);
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.divider {
  height: 1px;
  background: var(--border);
  margin: 14px 0;
}

/* ── 드롭존 ── */
.drop-zone {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 22px 16px;
  border: 2px dashed var(--border);
  border-radius: 8px;
  cursor: pointer;
  transition: border-color .15s, background .15s;
  text-align: center;
}
.drop-zone:hover,
.drop-zone.dragover {
  border-color: var(--accent);
  background: var(--accent-light);
}
.drop-zone.has-file {
  border-style: solid;
  border-color: var(--accent);
  background: var(--accent-light);
}
.drop-icon { font-size: 22px; }
#drop-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}
.drop-hint {
  font-size: 11px;
  color: var(--muted);
}
.drop-hint-sm {
  font-size: 10px;
  color: var(--muted);
  opacity: .75;
}

/* ── 버튼 ── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border: none;
  border-radius: 6px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s, opacity .15s;
  white-space: nowrap;
  text-decoration: none;
}
.btn:disabled { opacity: .5; cursor: not-allowed; }

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

.btn-secondary {
  background: #F3F4F6;
  color: var(--text);
  border: 1px solid var(--border);
}
.btn-secondary:hover:not(:disabled) { background: #E5E7EB; }

.btn-large {
  padding: 12px 40px;
  font-size: 15px;
}
.btn-sm {
  padding: 5px 12px;
  font-size: 12px;
}

.btn-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px; height: 26px;
  border: 1px solid var(--border);
  border-radius: 50%;
  background: #F3F4F6;
  font-size: 12px;
  cursor: pointer;
  flex-shrink: 0;
}
.btn-icon:hover { background: #E5E7EB; }

.optional-badge {
  font-size: 10px;
  font-weight: 400;
  background: #E5E7EB;
  color: var(--muted);
  padding: 1px 6px;
  border-radius: 99px;
  margin-left: 4px;
}

/* ── 추출 버튼 행 ── */
.action-row {
  display: flex;
  justify-content: center;
}

/* ── 탭 ── */
.tab-bar {
  display: flex;
  gap: 4px;
  border-bottom: 2px solid var(--border);
  margin-bottom: 16px;
}
.tab {
  padding: 8px 18px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  cursor: pointer;
  color: var(--muted);
  transition: color .15s, border-color .15s;
}
.tab:hover { color: var(--text); }
.tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}
.tab-panel { }
.tab-panel.hidden { display: none; }

/* ── 추출 결과 패널 ── */
.result-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}
#result-count {
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
}
.result-list {
  width: 100%;
  height: 280px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-family: "Consolas", "D2Coding", monospace;
  font-size: 13px;
  line-height: 1.7;
  resize: vertical;
  background: #FAFAFA;
  color: var(--text);
}

/* ── Diff 패널 ── */
.diff-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}
#diff-summary {
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
}

.badge {
  font-size: 11px;
  padding: 1px 8px;
  border-radius: 99px;
  font-weight: 700;
}
.badge-found   { background: var(--found-fg);   color: #fff; }
.badge-missing { background: var(--missing-fg); color: #fff; }

/* ── Diff 테이블 ── */
.diff-table-wrap {
  overflow-x: auto;
  overflow-y: auto;
  max-height: 300px;
  border: 1px solid var(--border);
  border-radius: 6px;
  margin-bottom: 14px;
}
.diff-table {
  width: 100%;
  border-collapse: collapse;
  font-family: "Consolas", "D2Coding", monospace;
  font-size: 13px;
}
.diff-table thead {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #F3F4F6;
}
.diff-table th {
  padding: 8px 12px;
  font-weight: 700;
  font-size: 12px;
  color: var(--muted);
  border-bottom: 2px solid var(--border);
  text-align: center;
  white-space: nowrap;
}
.diff-table th.col-case { text-align: left; }
.diff-table td {
  padding: 5px 12px;
  border-bottom: 1px solid var(--border);
}
.diff-table tr:last-child td { border-bottom: none; }
.col-case   { min-width: 160px; }
.col-status { text-align: center; width: 80px; font-weight: 700; font-size: 15px; }
.row-common     td { background: #F0FDF4; color: var(--found-fg); }
.row-input-only td { background: #FFF7ED; color: #92400E; }
.row-ref-only   td { background: var(--missing-bg); color: var(--missing-fg); }

/* ── 클릭-복사 영역 ── */
.copy-areas {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.copy-area-block { display: flex; flex-direction: column; gap: 6px; }
.copy-area-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
}
.copy-hint {
  font-size: 11px;
  color: var(--muted);
  font-weight: 400;
  margin-left: auto;
}
.diff-list {
  width: 100%;
  height: 160px;
  padding: 10px 12px;
  border: 1px solid;
  border-radius: 6px;
  font-family: "Consolas", "D2Coding", monospace;
  font-size: 13px;
  line-height: 1.7;
  resize: vertical;
}
.found-list   { background: var(--found-bg);   color: var(--found-fg);   border-color: var(--found-border); }
.missing-list { background: var(--missing-bg); color: var(--missing-fg); border-color: var(--missing-border); }
.copy-field {
  cursor: pointer;
  transition: border-color .15s, background .15s;
}
.copy-field:hover {
  border-color: var(--accent);
  background: var(--accent-light);
}

/* ── 토스트 알림 ── */
.toast {
  position: fixed;
  bottom: 32px;
  left: 50%;
  transform: translateX(-50%) translateY(8px);
  background: rgba(17, 24, 39, .88);
  color: #fff;
  padding: 10px 22px;
  border-radius: 99px;
  font-size: 13px;
  font-weight: 600;
  z-index: 200;
  pointer-events: none;
  opacity: 0;
  transition: opacity .2s, transform .2s;
  white-space: nowrap;
}
.toast.toast-show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ── 푸터 안내 ── */
.footer-notice {
  text-align: center;
  padding: 8px 8px 2px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.footer-notice p {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.6;
}
.footer-notice a {
  color: var(--accent);
  text-decoration: none;
}
.footer-notice a:hover { text-decoration: underline; }

/* ── 로딩 오버레이 ── */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.35);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}
.overlay.hidden { display: none; }
.spinner-box {
  background: #fff;
  border-radius: 12px;
  padding: 32px 48px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  box-shadow: 0 8px 32px rgba(0,0,0,.18);
}
.spinner {
  width: 40px; height: 40px;
  border: 4px solid #E5E7EB;
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .75s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
#loading-msg {
  font-size: 14px;
  font-weight: 600;
  color: var(--muted);
}

/* ── 모달 ── */
dialog.modal {
  border: none;
  border-radius: var(--radius);
  box-shadow: 0 8px 40px rgba(0,0,0,.2);
  padding: 0;
  width: min(560px, 95vw);
  max-height: 90vh;
}
dialog.modal::backdrop {
  background: rgba(0,0,0,.4);
}
.modal-inner {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 24px;
}
.modal-title { font-size: 16px; font-weight: 700; }
.modal-desc  { font-size: 13px; color: var(--muted); }
.modal-textarea {
  width: 100%;
  height: 220px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-family: inherit;
  font-size: 13px;
  line-height: 1.6;
  resize: vertical;
}
.modal-textarea:focus { outline: 2px solid var(--accent); border-color: transparent; }
.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

/* ── 반응형 ── */
@media (max-width: 520px) {
  .copy-areas { grid-template-columns: 1fr; }
  .btn-large { padding: 11px 28px; font-size: 14px; }
  .card { padding: 16px; }
}
