/* ============================================================
   RESET & BASE
   ============================================================ */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --red:       #E63946;
  --red-dark:  #c1222f;
  --black:     #111111;
  --gray-900:  #222222;
  --gray-600:  #555555;
  --gray-300:  #DDDDDD;
  --gray-100:  #F5F5F5;
  --white:     #FFFFFF;
  --radius:    10px;
  --shadow-sm: 0 1px 4px rgba(0,0,0,.08);
  --shadow-md: 0 4px 16px rgba(0,0,0,.12);
  --shadow-lg: 0 8px 32px rgba(0,0,0,.16);
  --font:      'Manrope', system-ui, sans-serif;
  --transition: 180ms ease;
}

html {
  font-size: 16px;
  scroll-behavior: smooth;
}

body {
  font-family: var(--font);
  color: var(--black);
  background: var(--white);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

a {
  color: var(--red);
  text-decoration: none;
}

a:hover { text-decoration: underline; }

ul { list-style: none; }

/* ============================================================
   LAYOUT UTILITIES
   ============================================================ */
.container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 24px;
}

/* ============================================================
   SITE HEADER
   ============================================================ */
.site-header {
  background: var(--white);
  border-bottom: 1px solid var(--gray-300);
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 60px;
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
}

.logo-text {
  font-weight: 800;
  font-size: 1rem;
  color: var(--black);
  letter-spacing: -.3px;
}

.logo-sub {
  color: var(--red);
}

.link-docs {
  font-size: .85rem;
  font-weight: 600;
  color: var(--gray-600);
  padding: 6px 14px;
  border: 1px solid var(--gray-300);
  border-radius: var(--radius);
  transition: border-color var(--transition), color var(--transition);
}

.link-docs:hover {
  border-color: var(--red);
  color: var(--red);
  text-decoration: none;
}

/* ============================================================
   TOOL SECTION
   ============================================================ */
.tool-section {
  padding: 56px 24px 80px;
  display: flex;
  flex-direction: column;
  gap: 28px;
}

/* ============================================================
   API CONFIG PANEL
   ============================================================ */
.api-config {
  border: 1px solid var(--gray-300);
  border-radius: var(--radius);
  background: var(--white);
  overflow: hidden;
}

.api-config-summary {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 18px;
  cursor: pointer;
  user-select: none;
  list-style: none;
  background: var(--gray-100);
  font-size: .825rem;
}

.api-config-summary::-webkit-details-marker { display: none; }

.api-config-summary::before {
  content: '▶';
  font-size: .65rem;
  color: var(--gray-600);
  transition: transform var(--transition);
}

details[open] .api-config-summary::before {
  transform: rotate(90deg);
}

.api-config-label {
  font-weight: 700;
  color: var(--gray-900);
}

.api-url-display {
  font-size: .775rem;
  color: var(--gray-600);
  font-family: 'Menlo', 'Consolas', monospace;
  background: var(--white);
  padding: 2px 8px;
  border-radius: 4px;
  border: 1px solid var(--gray-300);
  max-width: 300px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.api-config-body {
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.api-config-field-label {
  font-size: .825rem;
  font-weight: 700;
  color: var(--black);
}

.api-config-row {
  display: flex;
  gap: 8px;
}

.api-url-input {
  flex: 1;
  padding: 9px 14px;
  border: 1.5px solid var(--gray-300);
  border-radius: 8px;
  font-family: 'Menlo', 'Consolas', monospace;
  font-size: .85rem;
  color: var(--black);
  outline: none;
  transition: border-color var(--transition);
}

.api-url-input:focus {
  border-color: var(--red);
}

.btn-save-url {
  padding: 9px 18px;
  background: var(--red);
  color: var(--white);
  border: none;
  border-radius: 8px;
  font-family: var(--font);
  font-size: .825rem;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
  transition: background var(--transition);
}

.btn-save-url:hover { background: var(--red-dark); }

.api-config-hint {
  font-size: .75rem;
  color: var(--gray-600);
}

.api-config-hint code {
  background: var(--gray-100);
  padding: 1px 5px;
  border-radius: 4px;
  font-family: 'Menlo', 'Consolas', monospace;
}

/* ============================================================
   GEO BANNER
   ============================================================ */
.geo-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 18px;
  border-radius: var(--radius);
  font-size: .875rem;
  font-weight: 600;
  transition: background var(--transition), color var(--transition);
}

.geo-pending {
  background: #FFF8E1;
  color: #7B5C00;
}

.geo-granted {
  background: #E8F5E9;
  color: #1B5E20;
}

.geo-denied {
  background: #FFEBEE;
  color: #B71C1C;
}

/* manual coords panel */
.manual-coords {
  margin-top: 16px;
  background: #FFF8E1;
  border: 1px solid #FFE082;
  border-radius: var(--radius);
  padding: 16px 20px;
}

.manual-coords[hidden] { display: none; }

.manual-coords-label {
  font-size: .825rem;
  font-weight: 700;
  color: #7B5C00;
  margin-bottom: 10px;
}

.manual-coords-row {
  display: flex;
  gap: 10px;
  align-items: flex-end;
  flex-wrap: wrap;
}

.manual-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
  min-width: 120px;
}

.manual-field label {
  font-size: .75rem;
  font-weight: 700;
  color: var(--gray-600);
}

.manual-field input {
  padding: 9px 12px;
  border: 1.5px solid var(--gray-300);
  border-radius: 8px;
  font-family: 'Menlo', 'Consolas', monospace;
  font-size: .85rem;
  color: var(--black);
  outline: none;
  transition: border-color var(--transition);
}

.manual-field input:focus { border-color: var(--red); }

.geo-icon { display: flex; flex-shrink: 0; }

/* ============================================================
   STEP CARDS
   ============================================================ */
.step-card {
  background: var(--white);
  border: 1px solid var(--gray-300);
  border-radius: var(--radius);
  padding: 32px;
  box-shadow: var(--shadow-sm);
}

.step-header {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 24px;
}

.step-number {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--red);
  color: var(--white);
  font-weight: 800;
  font-size: .875rem;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.step-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--black);
}

/* ============================================================
   DROP ZONE
   ============================================================ */
.drop-zone {
  border: 2px dashed var(--gray-300);
  border-radius: var(--radius);
  min-height: 180px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: border-color var(--transition), background var(--transition);
  position: relative;
  outline: none;
}

.drop-zone:hover,
.drop-zone:focus-visible,
.drop-zone.drag-over {
  border-color: var(--red);
  background: #FFF0F1;
}

.drop-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 32px 24px;
  text-align: center;
}

.drop-icon {
  color: var(--gray-300);
  margin-bottom: 4px;
}

.drop-text {
  font-weight: 700;
  color: var(--gray-600);
  font-size: 1rem;
}

.drop-hint {
  font-size: .8rem;
  color: var(--gray-600);
  margin-bottom: 12px;
}

.btn-secondary {
  padding: 9px 22px;
  border: 1.5px solid var(--gray-300);
  border-radius: 8px;
  background: var(--white);
  color: var(--gray-900);
  font-family: var(--font);
  font-size: .875rem;
  font-weight: 700;
  cursor: pointer;
  transition: border-color var(--transition), color var(--transition);
}

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

/* Preview */
.drop-preview {
  width: 100%;
  padding: 16px;
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}

.drop-preview[hidden] { display: none; }

#preview-img {
  width: 100px;
  height: 80px;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid var(--gray-300);
  flex-shrink: 0;
}

.preview-name {
  font-size: .875rem;
  color: var(--gray-600);
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.btn-remove {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 1.5px solid var(--gray-300);
  background: var(--white);
  color: var(--gray-600);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: border-color var(--transition), color var(--transition);
}

.btn-remove:hover {
  border-color: var(--red);
  color: var(--red);
}

/* ============================================================
   METHOD GRID
   ============================================================ */
.method-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 24px;
}

.method-card {
  border: 2px solid var(--gray-300);
  border-radius: var(--radius);
  padding: 20px;
  cursor: pointer;
  display: flex;
  gap: 16px;
  align-items: flex-start;
  position: relative;
  transition: border-color var(--transition), box-shadow var(--transition), opacity var(--transition);
  outline: none;
}

.method-card:hover:not([aria-disabled="true"]) {
  border-color: var(--red);
  box-shadow: var(--shadow-sm);
}

.method-card:focus-visible {
  outline: 3px solid var(--red);
  outline-offset: 2px;
}

.method-card[aria-checked="true"] {
  border-color: var(--red);
  background: #FFF0F1;
  box-shadow: var(--shadow-md);
}

.method-card[aria-disabled="true"] {
  opacity: .45;
  cursor: not-allowed;
  pointer-events: none;
}

.method-icon {
  color: var(--red);
  flex-shrink: 0;
  margin-top: 2px;
}

.method-info { flex: 1; }

.method-name {
  font-size: 1rem;
  font-weight: 700;
  color: var(--black);
  margin-bottom: 6px;
}

.method-desc {
  font-size: .825rem;
  color: var(--gray-600);
  line-height: 1.5;
  margin-bottom: 10px;
}

.method-needs {
  font-size: .775rem;
  color: var(--gray-600);
}

.method-needs li::before {
  content: "· ";
  color: var(--red);
  font-weight: 700;
}

.nearby-geo-status {
  font-size: .75rem;
  font-weight: 600;
  margin-top: 8px;
  color: var(--gray-600);
}

.method-check {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--red);
  color: var(--white);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transform: scale(.6);
  transition: opacity var(--transition), transform var(--transition);
}

.method-card[aria-checked="true"] .method-check {
  opacity: 1;
  transform: scale(1);
}

/* ============================================================
   RADIO SLIDER
   ============================================================ */
.radio-control {
  background: var(--gray-100);
  border-radius: var(--radius);
  padding: 20px 24px;
}

.radio-control[hidden] { display: none; }

.radio-label {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: .875rem;
  font-weight: 700;
  color: var(--black);
  margin-bottom: 12px;
}

.radio-value {
  color: var(--red);
  font-weight: 800;
}

input[type="range"] {
  width: 100%;
  accent-color: var(--red);
  height: 4px;
  cursor: pointer;
}

.radio-ticks {
  display: flex;
  justify-content: space-between;
  font-size: .7rem;
  color: var(--gray-600);
  margin-top: 6px;
}

/* ============================================================
   BUTTONS
   ============================================================ */
.btn-primary {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 16px 32px;
  background: var(--red);
  color: var(--white);
  border: none;
  border-radius: var(--radius);
  font-family: var(--font);
  font-size: 1rem;
  font-weight: 800;
  letter-spacing: .3px;
  cursor: pointer;
  transition: background var(--transition), opacity var(--transition), transform var(--transition);
}

.btn-primary:hover:not(:disabled) {
  background: var(--red-dark);
  transform: translateY(-1px);
}

.btn-primary:active:not(:disabled) {
  transform: translateY(0);
}

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

.btn-full { width: 100%; }

/* ============================================================
   LOADING STATE
   ============================================================ */
.state-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 48px 24px;
}

.state-loading[hidden] { display: none; }

.spinner {
  width: 44px;
  height: 44px;
  border: 3px solid var(--gray-300);
  border-top-color: var(--red);
  border-radius: 50%;
  animation: spin .8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.loading-text {
  font-weight: 600;
  color: var(--gray-600);
}

.loading-timer {
  font-size: .875rem;
  color: var(--gray-300);
  font-variant-numeric: tabular-nums;
}

/* ============================================================
   ERROR STATE
   ============================================================ */
.state-error {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 16px 20px;
  background: #FFEBEE;
  color: #B71C1C;
  border-radius: var(--radius);
  font-weight: 600;
  font-size: .9rem;
}

.state-error[hidden] { display: none; }

/* ============================================================
   RESULTS
   ============================================================ */
.results-section {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.results-section[hidden] { display: none; }

.results-header {
  display: flex;
  align-items: center;
  gap: 12px;
}

.results-title {
  font-size: 1.2rem;
  font-weight: 800;
  color: var(--black);
}

.results-badge {
  padding: 3px 12px;
  border-radius: 100px;
  background: var(--red);
  color: var(--white);
  font-size: .75rem;
  font-weight: 700;
}

.results-list {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.result-card {
  border: 1px solid var(--gray-300);
  border-radius: var(--radius);
  padding: 24px;
  background: var(--white);
  box-shadow: var(--shadow-sm);
  transition: box-shadow var(--transition), transform var(--transition);
  display: flex;
  gap: 20px;
  align-items: flex-start;
}

.result-card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

.result-rank {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--gray-100);
  color: var(--red);
  font-size: .875rem;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-top: 2px;
}

.result-rank.rank-1 {
  background: var(--red);
  color: var(--white);
}

.result-body { flex: 1; min-width: 0; }

.result-name {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--black);
  margin-bottom: 4px;
}

.result-address {
  font-size: .875rem;
  color: var(--gray-600);
  margin-bottom: 12px;
  line-height: 1.5;
}

.result-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 16px;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border-radius: 100px;
  font-size: .75rem;
  font-weight: 700;
  background: var(--gray-100);
  color: var(--gray-600);
}

.chip-red {
  background: #FFF0F1;
  color: var(--red);
}

.result-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.btn-realtravel {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: 8px;
  background: var(--red);
  color: var(--white);
  font-family: var(--font);
  font-size: .8rem;
  font-weight: 700;
  text-decoration: none;
  transition: background var(--transition);
}

.btn-realtravel:hover {
  background: var(--red-dark);
  text-decoration: none;
  color: var(--white);
}

/* ============================================================
   JSON DEBUG
   ============================================================ */
.json-debug {
  border: 1px solid var(--gray-300);
  border-radius: var(--radius);
  overflow: hidden;
}

.json-summary {
  padding: 12px 20px;
  font-size: .825rem;
  font-weight: 700;
  color: var(--gray-600);
  cursor: pointer;
  background: var(--gray-100);
  user-select: none;
  list-style: none;
}

.json-summary::-webkit-details-marker { display: none; }

.json-output {
  background: var(--black);
  color: #A8FF78;
  padding: 20px;
  font-size: .8rem;
  line-height: 1.6;
  overflow-x: auto;
  font-family: 'Menlo', 'Consolas', monospace;
  max-height: 320px;
  overflow-y: auto;
  white-space: pre;
}

/* ============================================================
   FOOTER
   ============================================================ */
.site-footer {
  border-top: 1px solid var(--gray-300);
  background: var(--white);
  padding: 24px 0;
}

.footer-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: .8rem;
  color: var(--gray-600);
}

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 640px) {
  .hero { padding: 56px 0 48px; }

  .hero-title {
    font-size: clamp(2.5rem, 14vw, 4rem);
    letter-spacing: -1.5px;
  }

  .method-grid {
    grid-template-columns: 1fr;
  }

  .step-card { padding: 24px 20px; }

  .result-card { flex-direction: column; gap: 12px; }

  .footer-inner { flex-direction: column; gap: 8px; text-align: center; }
}
