:root {
  --color-bg: #ffffff;
  --color-surface: #f5f7fa;
  --color-border: #dde1e7;
  --color-text: #1a1d23;
  --color-text-muted: #6b7280;
  --color-primary: #2563eb;
  --color-primary-hover: #1d4ed8;
  --color-primary-text: #ffffff;
  --color-error-bg: #fef2f2;
  --color-error-border: #fca5a5;
  --color-error-text: #b91c1c;
  --color-copy-bg: #f0f4ff;
  --color-copy-hover: #dbeafe;
  --color-copy-text: #2563eb;
  --color-spinner: #2563eb;
  --color-badge-bg: #eff6ff;
  --color-badge-text: #1d4ed8;
  --color-badge-border: #bfdbfe;
  --color-rate-bg: #f0fdf4;
  --color-rate-text: #166534;
  --color-rate-border: #bbf7d0;
  --color-rate-empty-bg: #fef9c3;
  --color-rate-empty-text: #854d0e;
  --color-rate-empty-border: #fde68a;
  --color-footer-bg: #f5f7fa;
  --color-footer-text: #6b7280;
  --color-footer-link: #2563eb;

  --font-sans: system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  --font-mono: "JetBrains Mono", "Fira Code", "Cascadia Code", "Courier New", ui-monospace, monospace;

  --radius: 8px;
  --radius-sm: 4px;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.08), 0 1px 2px rgba(0, 0, 0, 0.04);
}

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  background: var(--color-bg);
  color: var(--color-text);
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.6;
  padding: 2rem 1rem 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

main {
  max-width: 800px;
  width: 100%;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  flex: 1;
}

/* Header row */

.header-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

h1 {
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--color-text);
}

/* Badge */

.badge {
  display: inline-block;
  padding: 0.2rem 0.65rem;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  color: var(--color-badge-text);
  background: var(--color-badge-bg);
  border: 1px solid var(--color-badge-border);
  border-radius: 999px;
  white-space: nowrap;
}

/* Subtitle */

.subtitle {
  font-size: 0.9rem;
  color: var(--color-text-muted);
  margin-top: -0.25rem;
}

/* Search hint */

.search-hint {
  font-size: 0.82rem;
  color: var(--color-text-muted);
}

/* Rate banner */

.rate-banner {
  display: inline-flex;
  align-items: center;
  padding: 0.4rem 0.875rem;
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--color-rate-text);
  background: var(--color-rate-bg);
  border: 1px solid var(--color-rate-border);
  border-radius: var(--radius);
}

.rate-banner--empty {
  color: var(--color-rate-empty-text);
  background: var(--color-rate-empty-bg);
  border-color: var(--color-rate-empty-border);
}

/* Search form */

#search-form {
  display: flex;
  gap: 0.5rem;
}

#query-input {
  flex: 1;
  min-width: 0;
  padding: 0.75rem 0.875rem;
  font-family: var(--font-sans);
  font-size: 1rem;
  color: var(--color-text);
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  outline: none;
  -webkit-appearance: none;
  appearance: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

#query-input::placeholder {
  color: var(--color-text-muted);
}

#query-input:focus {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

#query-input:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

#submit-btn {
  padding: 0.75rem 1.25rem;
  font-family: var(--font-sans);
  font-size: 1rem;
  font-weight: 600;
  color: var(--color-primary-text);
  background: var(--color-primary);
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  white-space: nowrap;
  -webkit-appearance: none;
  appearance: none;
  transition: background 0.15s, opacity 0.15s;
  min-height: 44px;
  min-width: 44px;
}

#submit-btn:hover:not(:disabled) {
  background: var(--color-primary-hover);
}

#submit-btn:active:not(:disabled) {
  opacity: 0.9;
}

#submit-btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

#submit-btn.btn--limit {
  opacity: 0.55;
  cursor: not-allowed;
}

#submit-btn.btn--limit:hover {
  background: var(--color-primary);
}

/* Geolocation button */

#geo-btn {
  padding: 0.75rem;
  font-size: 1.1rem;
  line-height: 1;
  color: var(--color-primary);
  background: transparent;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  cursor: pointer;
  white-space: nowrap;
  -webkit-appearance: none;
  appearance: none;
  transition: border-color 0.15s, background 0.15s;
  min-height: 44px;
  min-width: 44px;
}

#geo-btn:hover {
  border-color: var(--color-primary);
  background: rgba(37, 99, 235, 0.06);
}

/* Loading indicator */

#loading:not([hidden]) {
  display: -webkit-box;
  display: flex;
  -webkit-box-align: center;
  align-items: center;
  gap: 0.5rem;
  color: var(--color-text-muted);
  font-size: 0.9rem;
}

.spinner {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2px solid var(--color-border);
  border-top-color: var(--color-spinner);
  border-radius: 50%;
  -webkit-animation: spin 0.7s linear infinite;
  animation: spin 0.7s linear infinite;
  flex-shrink: 0;
}

@-webkit-keyframes spin {
  to { -webkit-transform: rotate(360deg); transform: rotate(360deg); }
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* Error message */

#error {
  padding: 0.75rem 1rem;
  background: var(--color-error-bg);
  border: 1px solid var(--color-error-border);
  border-radius: var(--radius);
  color: var(--color-error-text);
  font-size: 0.9rem;
}

/* Station cards */

#results {
  display: -webkit-box;
  display: flex;
  -webkit-box-orient: vertical;
  -webkit-box-direction: normal;
  flex-direction: column;
  gap: 1rem;
}

.station-card {
  position: relative;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.station-card pre {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  line-height: 1.55;
  color: var(--color-text);
  white-space: pre-wrap;
  word-break: break-word;
  overflow-wrap: break-word;
  padding: 2.75rem 1rem 1rem;
}

/* Scope header (freq+location search context) */

.scope-header {
  background: #fef3c7;
  border-bottom: 1px solid #fde68a;
  padding: 0.5rem 6rem 0.5rem 0.875rem;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  line-height: 1.4;
  color: #92400e;
  white-space: pre-wrap;
}

.scope-header + pre {
  padding-top: 0.875rem;
}

/* Copy button */

.copy-btn {
  position: absolute;
  top: 0.625rem;
  right: 0.625rem;
  padding: 0.4rem 0.875rem;
  font-family: var(--font-sans);
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--color-copy-text);
  background: var(--color-copy-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
  transition: background 0.15s;
  min-height: 44px;
  min-width: 44px;
}

.copy-btn:hover {
  background: var(--color-copy-hover);
}

/* Footer */

footer {
  max-width: 800px;
  width: 100%;
  margin: 2rem auto 0;
  padding: 1rem 0 1.5rem;
  border-top: 1px solid var(--color-border);
  display: -webkit-box;
  display: flex;
  -webkit-box-align: center;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.82rem;
  color: var(--color-footer-text);
  flex-wrap: wrap;
}

.footer-sep {
  color: var(--color-border);
}

.footer-disclaimer {
  width: 100%;
  margin-top: 0.25rem;
  font-size: 0.75rem;
  color: var(--color-text-muted);
  line-height: 1.5;
}

footer a {
  color: var(--color-footer-link);
  text-decoration: none;
}

footer a:hover {
  text-decoration: underline;
}

/* Mobile */

@media (max-width: 540px) {
  body {
    padding: 1.25rem 1rem 0;
  }

  h1 {
    font-size: 1.25rem;
  }

  .header-row {
    gap: 0.5rem;
  }

  #search-form {
    flex-direction: column;
  }

  #submit-btn {
    width: 100%;
    padding: 0.875rem 1.25rem;
  }

  #geo-btn {
    align-self: flex-end;
  }

  #query-input {
    padding: 0.875rem;
  }

  .station-card pre {
    font-size: 0.72rem;
    padding-top: 3.25rem;
  }

  .scope-header + pre {
    padding-top: 0.875rem;
  }

  .copy-btn {
    font-size: 0.75rem;
  }

  footer {
    font-size: 0.78rem;
    padding-bottom: 2rem;
  }
}
