html, body {
  margin: 0;
  height: 100%;
}

#map {
  position: absolute;
  inset: 0;
}

.lang-hint {
  display: block;
  margin-top: 2px;
  font-size: 0.85em;
  color: #5a6b78;
}

#toolbar {
  position: absolute;
  top: 12px;
  left: 12px;
  z-index: 1;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  background: rgba(255, 255, 255, 0.95);
  border-radius: 8px;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.25);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

#toolbar label {
  font-size: 13px;
  color: #333;
}

/* Keep a label and its field together so they never wrap separately. */
.field-group {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* The collapse toggle is only relevant on small screens. */
#toolbar-toggle {
  display: none;
  border: 1px solid #ccc;
  border-radius: 6px;
  background: #fff;
  color: #333;
  cursor: pointer;
  line-height: 1;
}

#word {
  font-size: 14px;
  padding: 6px 10px;
  border: 1px solid #ccc;
  border-radius: 6px;
  outline: none;
  min-width: 200px;
}

#word:focus {
  border-color: #4a90d9;
  box-shadow: 0 0 0 2px rgba(74, 144, 217, 0.2);
}

#threshold,
#user-country {
  font-size: 14px;
  padding: 6px 8px;
  border: 1px solid #ccc;
  border-radius: 6px;
  outline: none;
  background: #fff;
  color: #333;
  cursor: pointer;
}

#threshold:focus,
#user-country:focus {
  border-color: #4a90d9;
  box-shadow: 0 0 0 2px rgba(74, 144, 217, 0.2);
}

#translate-btn {
  font-size: 14px;
  padding: 6px 14px;
  border: 1px solid #4a90d9;
  border-radius: 6px;
  background: #4a90d9;
  color: #fff;
  cursor: pointer;
}

#translate-btn:hover {
  background: #3b7dc0;
  border-color: #3b7dc0;
}

#export-btn {
  font-size: 14px;
  padding: 6px 14px;
  border: 1px solid #4a90d9;
  border-radius: 6px;
  background: #fff;
  color: #2b5f92;
  cursor: pointer;
}

#export-btn:hover {
  background: #eef4fb;
}

#similarity-spinner {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: none;
  align-items: center;
  justify-content: center;
  /* Transparent overlay that also intercepts clicks while active. */
  background: rgba(255, 255, 255, 0.05);
  cursor: progress;
}

#similarity-spinner.open {
  display: flex;
}

#similarity-spinner .spinner {
  width: 54px;
  height: 54px;
  border: 5px solid rgba(74, 144, 217, 0.25);
  border-top-color: #4a90d9;
  border-radius: 50%;
  animation: similarity-spin 0.8s linear infinite;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
}

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

#export-modal {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.35);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

#export-modal.open {
  display: flex;
}

#export-card {
  background: #fff;
  border-radius: 10px;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.3);
  padding: 20px 22px;
  width: 320px;
  max-width: calc(100vw - 32px);
}

#export-card h2 {
  margin: 0 0 12px;
  font-size: 17px;
  color: #222;
}

#export-card label {
  display: block;
  font-size: 13px;
  color: #444;
  margin-bottom: 6px;
}

#export-scale {
  width: 100%;
  box-sizing: border-box;
  font-size: 14px;
  padding: 8px 10px;
  border: 1px solid #ccc;
  border-radius: 6px;
  outline: none;
}

#export-hint {
  font-size: 12px;
  color: #777;
  margin: 8px 0 16px;
}

#export-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

#export-actions button {
  font-size: 14px;
  padding: 7px 14px;
  border-radius: 6px;
  cursor: pointer;
  border: 1px solid #ccc;
  background: #f4f4f4;
  color: #333;
}

#export-confirm {
  border-color: #4a90d9 !important;
  background: #4a90d9 !important;
  color: #fff !important;
}

#export-confirm:hover {
  background: #3b7dc0 !important;
  border-color: #3b7dc0 !important;
}

#about-btn {
  position: fixed;
  left: 12px;
  bottom: 12px;
  z-index: 10;
  font-size: 14px;
  padding: 8px 14px;
  border: 1px solid #4a90d9;
  border-radius: 6px;
  background: #fff;
  color: #2b5f92;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

#about-btn:hover {
  background: #eef4fb;
}

#about-modal {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.35);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

#about-modal.open {
  display: flex;
}

#about-card {
  background: #fff;
  border-radius: 10px;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.3);
  padding: 20px 22px;
  width: 360px;
  max-width: calc(100vw - 32px);
}

#about-card h2 {
  margin: 0 0 12px;
  font-size: 17px;
  color: #222;
}

p.about-text {
  margin: 0 0 16px;
  font-size: 14px;
  line-height: 1.5;
  color: #444;
}

#about-actions {
  display: flex;
  justify-content: flex-end;
}

#about-actions button {
  font-size: 14px;
  padding: 7px 14px;
  border-radius: 6px;
  cursor: pointer;
  border: 1px solid #4a90d9;
  background: #4a90d9;
  color: #fff;
}

#about-actions button:hover {
  background: #3b7dc0;
  border-color: #3b7dc0;
}

@media (max-width: 640px) {
  #toolbar {
    left: 8px;
    right: 8px;
    top: 8px;
    flex-wrap: wrap;
    gap: 6px 8px;
    padding: 8px;
  }

  /* Show the hamburger and let it sit on its own row. */
  #toolbar-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
    font-size: 18px;
    padding: 6px 12px;
  }

  /* When collapsed, shrink the toolbar to just the toggle button. */
  #toolbar.collapsed {
    right: auto;
  }

  #toolbar.collapsed > *:not(#toolbar-toggle) {
    display: none;
  }

  /* Input takes a full row and shrinks freely. */
  #word {
    flex: 1 1 100%;
    min-width: 0;
    font-size: 16px; /* prevents auto-zoom on focus in iOS Safari */
  }

  /* Label+field groups share a row and stay intact. */
  .field-group {
    flex: 1 1 auto;
    min-width: 0;
    gap: 6px;
  }

  #user-country,
  #threshold {
    flex: 1 1 auto;
    min-width: 0;
    font-size: 16px;
  }

  /* Buttons stretch into comfortable touch targets. */
  #translate-btn,
  #export-btn {
    flex: 1 1 auto;
    font-size: 15px;
    padding: 8px 12px;
  }

  #about-btn {
    font-size: 13px;
    padding: 7px 12px;
  }
}
