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

:root {
  --bg: #f1f5f9;
  --panel: #ffffff;
  --text: #0f172a;
  --muted: #64748b;
  --accent: #1d4ed8;
  --accent-hover: #1e40af;
  --border: #e2e8f0;
  --error-bg: #fef2f2;
  --error-text: #b91c1c;
}

html,
body {
  margin: 0;
  height: 100%;
  font-family: 'Pretendard', 'Apple SD Gothic Neo', 'Malgun Gothic', sans-serif;
  color: var(--text);
  background: var(--bg);
}

.layout {
  display: grid;
  grid-template-columns: minmax(280px, 340px) 1fr;
  height: 100vh;
}

.panel {
  display: flex;
  flex-direction: column;
  padding: 1.25rem;
  background: var(--panel);
  border-right: 1px solid var(--border);
  overflow-y: auto;
}

.panel h1 {
  margin: 0 0 1rem;
  font-size: 1.25rem;
  font-weight: 700;
}

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

.search-form {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.search-form input[type='text'] {
  width: 100%;
  padding: 0.65rem 0.75rem;
  font-size: 1rem;
  border: 1px solid var(--border);
  border-radius: 8px;
}

.search-form input:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.btn-primary {
  width: 100%;
  padding: 0.65rem 1rem;
  font-size: 1rem;
  font-weight: 600;
  color: #fff;
  background: var(--accent);
  border: none;
  border-radius: 8px;
  cursor: pointer;
}

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

.error {
  margin-top: 0.75rem;
  padding: 0.55rem 0.75rem;
  font-size: 0.85rem;
  background: var(--error-bg);
  color: var(--error-text);
  border-radius: 8px;
}

.result {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  margin-top: 0.75rem;
  padding: 0.75rem;
  font-size: 0.9rem;
  background: var(--bg);
  border-radius: 8px;
}

.result strong {
  font-family: ui-monospace, 'SF Mono', monospace;
  font-size: 1.05rem;
}

.result-block {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  margin-top: 0.35rem;
}

.result-label {
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  color: var(--text);
}

.result-sub {
  font-size: 0.78rem !important;
}

.result-wgs .result-label,
.result-wgs span:last-child {
  color: var(--muted);
}

.result span {
  color: var(--muted);
  font-family: ui-monospace, 'SF Mono', monospace;
  font-size: 0.85rem;
  line-height: 1.4;
}

.result-note {
  font-size: 0.8rem;
}

.origin-score-list {
  margin: 0.25rem 0 0;
  padding-left: 1.1rem;
  font-size: 0.78rem;
  color: var(--muted);
}

.origin-score-list li.picked {
  color: var(--text);
  font-weight: 600;
}

.grid-legend {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  margin: 0.5rem 0;
  padding: 0.55rem 0.65rem;
  font-size: 0.78rem;
  line-height: 1.35;
  color: var(--muted);
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 6px;
}

.grid-legend-title {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 0.15rem;
}

.grid-legend span {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-family: inherit;
  font-size: 0.78rem;
}

.swatch {
  display: inline-block;
  width: 0.65rem;
  height: 0.65rem;
  border-radius: 2px;
  flex-shrink: 0;
}

.swatch-axis {
  background: #64748b;
}

.swatch-km2 {
  background: #3b82f6;
  border: 1px solid #2563eb;
}

.swatch-500 {
  background: #22c55e;
  border: 1px solid #16a34a;
}

.swatch-50 {
  background: #eab308;
  border: 1px solid #ca8a04;
}

.swatch-radius {
  background: transparent;
  border: 2px dashed #dc2626;
  border-radius: 50%;
}

.sources-note {
  margin: 1rem 0 0;
  font-size: 0.75rem;
  line-height: 1.45;
  color: var(--muted);
}

.map-wrap {
  min-width: 0;
  min-height: 0;
}

.map {
  width: 100%;
  height: 100%;
}

@media (max-width: 768px) {
  .layout {
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr;
  }

  .panel {
    max-height: 40vh;
    border-right: none;
    border-bottom: 1px solid var(--border);
  }
}
