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

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 15px;
  line-height: 1.45;
  color: #1a1a1a;
  background: linear-gradient(160deg, #e8eaed 0%, #d7dce4 100%);
  min-height: 100vh;
}

.page {
  max-width: 920px;
  margin: 0 auto;
  padding: 1.25rem 1rem 3rem;
}

.site-header {
  margin-bottom: 1.25rem;
}

.site-header h1 {
  font-size: 1.65rem;
  font-weight: 800;
  margin: 0 0 0.35rem;
  letter-spacing: -0.02em;
  color: #0d1b2a;
}

.tagline {
  margin: 0;
  font-size: 0.95rem;
  color: #5f6368;
  max-width: 42rem;
}

.perf-badge {
  margin: 0.5rem 0 0;
  font-size: 0.8rem;
  font-weight: 650;
  color: #137333;
  background: #e6f4ea;
  display: inline-block;
  padding: 0.2rem 0.55rem;
  border-radius: 6px;
}

#ore-finder-title {
  font-size: 1.35rem;
  font-weight: 700;
  margin: 0 0 0.75rem;
  line-height: 1.25;
}

.dev-note {
  font-size: 0.88rem;
  color: #5f6368;
  margin: 0 0 1rem;
  padding: 0.65rem 0.85rem;
  background: rgba(26, 35, 126, 0.06);
  border-radius: 8px;
  border-left: 3px solid #1a237e;
}

.dev-note code {
  font-size: 0.85em;
}

.form-container {
  background: #fff;
  border-radius: 14px;
  padding: 1.35rem 1.35rem 1.6rem;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.07);
}

.connection-status {
  border: 1px solid #dadce0;
  border-radius: 10px;
  padding: 0.55rem 0.85rem;
  margin-bottom: 1.15rem;
  background: #fafafa;
}

.connection-status[data-state="connected"] {
  border-color: #0f9d58;
  background: #e6f4ea;
}

.connection-status[data-state="disconnected"] {
  border-color: #c5221f;
  background: #fce8e6;
}

.connection-status[data-state="checking"] {
  border-color: #f9ab00;
  background: #fef7e0;
}

.status-indicator {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #9aa0a6;
  flex-shrink: 0;
}

.connection-status[data-state="connected"] .status-dot {
  background: #0f9d58;
  box-shadow: 0 0 0 2px rgba(15, 157, 88, 0.35);
}

.connection-status[data-state="disconnected"] .status-dot {
  background: #c5221f;
}

.connection-status[data-state="checking"] .status-dot {
  background: #f9ab00;
  animation: pulse 1.2s ease-in-out infinite;
}

@keyframes pulse {
  50% {
    opacity: 0.5;
  }
}

.status-text {
  font-size: 0.88rem;
  font-weight: 600;
}

.connection-status[data-state="connected"] .status-text {
  color: #137333;
}

.connection-status[data-state="disconnected"] .status-text {
  color: #c5221f;
}

.ore-form .form-group {
  margin-bottom: 1rem;
}

.ore-form label {
  display: block;
  font-weight: 600;
  font-size: 0.82rem;
  color: #3c4043;
  margin-bottom: 0.35rem;
}

.y-label {
  margin-top: 0.65rem;
}

.hint,
.field-hint {
  font-weight: 400;
  color: #80868b;
  font-size: 0.8rem;
}

.field-hint {
  margin: 0.35rem 0 0;
}

.ore-form input[type="text"],
.ore-form input[type="number"],
.ore-form select {
  width: 100%;
  padding: 0.55rem 0.65rem;
  border: 1px solid #dadce0;
  border-radius: 8px;
  font-size: 1rem;
}

.form-grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

@media (max-width: 640px) {
  .form-grid-2 {
    grid-template-columns: 1fr;
  }
}

.coords-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.65rem;
}

.coords-3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.65rem;
}

.form-row {
  display: grid;
  gap: 0.65rem;
}

.ore-fieldset {
  border: 1px solid #e8eaed;
  border-radius: 10px;
  padding: 0.85rem 1rem 1rem;
  margin: 0 0 1rem;
}

.ore-fieldset legend {
  font-weight: 700;
  padding: 0 0.35rem;
  color: #1a1a1a;
}

.ore-category-section {
  margin-top: 0.85rem;
}

.ore-category-section:first-of-type {
  margin-top: 0.35rem;
}

.ore-category-title {
  font-size: 0.82rem;
  font-weight: 650;
  color: #5f6368;
  margin: 0 0 0.5rem;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

.structure-hint {
  margin: 0 0 0.5rem;
  font-size: 0.82rem;
}

.ore-btn-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(118px, 1fr));
  gap: 0.55rem;
}

.ore-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.25rem;
  padding: 0.55rem 0.4rem;
  border: 1px solid #dadce0;
  border-radius: 10px;
  cursor: pointer;
  font-size: 0.78rem;
  font-weight: 600;
  background: #fff;
  text-align: center;
  min-height: 4.1rem;
  transition: border-color 0.12s, box-shadow 0.12s, background 0.12s;
}

.ore-btn:hover {
  border-color: #3949ab;
  background: #f8f9ff;
}

.ore-btn:has(input:checked) {
  border-color: #1a237e;
  background: #e8eaf6;
  box-shadow: 0 0 0 2px rgba(26, 35, 126, 0.2);
}

.ore-btn input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.ore-btn .ic {
  font-size: 1.25rem;
  line-height: 1;
}

.ore-radio-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.radio-item {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.4rem 0.6rem;
  border: 1px solid #dadce0;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 500;
  background: #fff;
  transition: border-color 0.15s, background 0.15s;
}

.radio-item:hover {
  border-color: #1a237e;
  background: #f8f9ff;
}

.radio-item:has(input:checked) {
  border-color: #1a237e;
  background: #e8eaf6;
  color: #1a237e;
}

.radio-item input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.radio-item:has(input:focus-visible) {
  outline: 2px solid #1a237e;
  outline-offset: 2px;
}

.ore-radio-icon {
  font-size: 1.15rem;
  line-height: 1;
  width: 1.4rem;
  text-align: center;
}

.hint-toggle {
  margin-top: 0.5rem;
}

.check-row {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  font-size: 0.88rem;
  color: #424242;
  cursor: pointer;
  font-weight: 500;
}

.check-row input {
  margin-top: 0.2rem;
  flex-shrink: 0;
}

.actions {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
  margin-top: 0.5rem;
}

.btn-primary {
  background: #1a237e;
  color: #fff;
  border: none;
  padding: 0.65rem 1.5rem;
  border-radius: 8px;
  font-weight: 600;
  font-size: 0.95rem;
  cursor: pointer;
}

.btn-primary:hover {
  background: #283593;
}

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

.search-status.muted,
.muted {
  color: #5f6368;
  font-size: 0.9rem;
}

.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;
}

/* Results */
.card {
  background: #fff;
  border-radius: 12px;
  padding: 1.25rem 1.25rem 1.5rem;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.results-wrap {
  margin-top: 1.25rem;
}

.results-header {
  font-size: 0.9rem;
  color: #3c4043;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid #e8eaed;
  margin-bottom: 0.85rem;
}

.results-summary-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 1rem;
  align-items: baseline;
  font-size: 0.92rem;
}

.result-section {
  margin-top: 1.25rem;
}

.result-section-title {
  font-size: 1.05rem;
  font-weight: 750;
  margin: 0 0 0.65rem;
  color: #0d1b2a;
}

.cluster-subtitle {
  font-size: 0.88rem;
  font-weight: 650;
  color: #5f6368;
  margin: 0.75rem 0 0.45rem;
}

.spot-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 0.75rem;
}

.spot-card {
  border: 1px solid #e8eaed;
  border-radius: 12px;
  padding: 0.85rem 1rem;
  background: #fafbfc;
}

.spot-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.5rem;
}

.copy-coords {
  flex-shrink: 0;
  font-size: 0.75rem;
  font-weight: 650;
  padding: 0.2rem 0.55rem;
  border: 1px solid #dadce0;
  border-radius: 6px;
  background: #fff;
  cursor: pointer;
  color: #1a237e;
}

.copy-coords:hover {
  background: #e8eaf6;
}

.spot-card.conf-high {
  border-color: #0f9d58;
  background: #e8f5e9;
}

.spot-card.conf-mid {
  border-color: #f9ab00;
  background: #fff8e1;
}

.spot-card.conf-low {
  border-color: #f57c00;
  background: #fff3e0;
}

.spot-card.conf-vlow {
  border-color: #b0bec5;
}

.spot-coords code {
  font-size: 0.95rem;
  font-weight: 700;
  color: #1a237e;
  background: transparent;
  padding: 0;
}

.spot-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 0.65rem;
  margin-top: 0.45rem;
  font-size: 0.82rem;
  align-items: center;
}

.conf-pill {
  background: #1a237e;
  color: #fff;
  padding: 0.12rem 0.45rem;
  border-radius: 999px;
  font-weight: 700;
  font-size: 0.78rem;
}

.conf-pill.soft {
  background: #5f6368;
  font-weight: 650;
}

.conf-pill-hint {
  background: #f57c00;
  margin-right: 0.25rem;
}

.fallback-banner {
  margin: 0 0 1rem;
  padding: 0.65rem 0.85rem;
  background: #fff8e1;
  border: 1px solid #f9ab00;
  border-radius: 8px;
  font-size: 0.88rem;
  color: #5f4100;
}

.conf-word {
  font-weight: 600;
  color: #3c4043;
}

.spot-dist {
  font-weight: 650;
  color: #1a237e;
}

.spot-prob {
  color: #5f6368;
}

.spot-tip {
  margin: 0.55rem 0 0;
  font-size: 0.82rem;
  color: #424242;
  line-height: 1.4;
}

.advice-line {
  margin-top: 1.25rem;
  font-size: 0.88rem;
  color: #37474f;
}

.results-header strong {
  color: #1a1a1a;
}

.results-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.results-list li {
  display: grid;
  grid-template-columns: 4.5rem 1fr auto;
  gap: 0.75rem;
  align-items: center;
  padding: 0.75rem 0;
  border-bottom: 1px solid #f1f3f4;
}

.results-list li:last-child {
  border-bottom: none;
}

.dist {
  font-weight: 700;
  color: #1a237e;
}

.meta {
  font-size: 0.88rem;
}

.coords {
  font-variant-numeric: tabular-nums;
  color: #5f6368;
}

.cluster-tag {
  font-size: 0.85rem;
  font-weight: 600;
  white-space: nowrap;
}

.err-box {
  background: #fce8e6;
  color: #c5221f;
  padding: 0.85rem 1rem;
  border-radius: 8px;
  font-size: 0.9rem;
}

.err-box.info-pending {
  background: #e8f0fe;
  color: #1967d2;
  border: 1px solid #aecbfa;
}

.raw-json {
  margin-top: 1rem;
  padding: 1rem;
  background: #f8f9fa;
  border-radius: 8px;
  overflow: auto;
  font-size: 0.75rem;
  max-height: 320px;
}

.link-btn {
  margin-top: 0.75rem;
  background: none;
  border: none;
  color: #1a237e;
  cursor: pointer;
  font-size: 0.85rem;
  text-decoration: underline;
  padding: 0;
}

code {
  font-size: 0.88em;
  background: #f1f3f4;
  padding: 0.1em 0.35em;
  border-radius: 4px;
}
