/* ---- Reset & base ---- */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: #f0f4f8;
  color: #1a202c;
  min-height: 100vh;
  padding: 2rem 1rem;
}

/* ---- Layout ---- */
.container {
  max-width: 800px;
  margin: 0 auto;
}

/* ---- Header ---- */
header {
  text-align: center;
  margin-bottom: 2rem;
}

header h1 {
  font-size: 2.2rem;
  font-weight: 700;
  color: #2d6a4f;
  letter-spacing: -0.5px;
}

header .subtitle {
  margin-top: 0.5rem;
  color: #4a5568;
  font-size: 1rem;
}

/* ---- Cards ---- */
.card {
  background: #ffffff;
  border-radius: 12px;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
  padding: 1.75rem 2rem;
  margin-bottom: 1.5rem;
}

/* ---- Coordinates panel ---- */
.coord-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.4rem;
}

.coord-header h2 {
  font-size: 1.1rem;
  font-weight: 600;
  color: #1a202c;
}

.coord-hint {
  font-size: 0.85rem;
  color: #718096;
  margin-bottom: 1.2rem;
}

/* 2×2 grid that visually mirrors the image corners */
.coord-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-template-rows: auto auto;
  gap: 0.9rem 1.2rem;
}

.coord-field {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.coord-field label {
  font-size: 0.78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #4a5568;
}

.coord-field input {
  padding: 0.55rem 0.75rem;
  border: 1.5px solid #cbd5e0;
  border-radius: 7px;
  font-size: 0.88rem;
  font-family: "SFMono-Regular", Consolas, monospace;
  color: #1a202c;
  transition: border-color 0.15s;
  width: 100%;
}

.coord-field input:focus {
  outline: none;
  border-color: #2d6a4f;
  box-shadow: 0 0 0 3px rgba(45, 106, 79, 0.12);
}

/* Ghost/text button for reset */
.btn-ghost {
  background: none;
  border: none;
  color: #2d6a4f;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  padding: 0.25rem 0.5rem;
  border-radius: 5px;
  transition: background 0.15s;
}

.btn-ghost:hover {
  background: #f0fff4;
}

/* ---- File upload label ---- */
.upload-label {
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px dashed #a0aec0;
  border-radius: 8px;
  padding: 2rem;
  cursor: pointer;
  color: #4a5568;
  font-size: 1rem;
  transition: border-color 0.2s, background 0.2s;
  text-align: center;
}

.upload-label:hover {
  border-color: #2d6a4f;
  background: #f0fff4;
}

.upload-label input[type="file"] {
  display: none;
}

/* ---- Image preview ---- */
#previewWrapper {
  margin-top: 1.25rem;
}

#imagePreview {
  width: 100%;
  max-height: 360px;
  object-fit: contain;
  border-radius: 8px;
  border: 1px solid #e2e8f0;
}

/* ---- Buttons ---- */
.btn-primary {
  display: block;
  width: 100%;
  margin-top: 1.5rem;
  padding: 0.85rem;
  font-size: 1.1rem;
  font-weight: 600;
  color: #ffffff;
  background: #2d6a4f;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.2s, transform 0.1s;
}

.btn-primary:hover:not(:disabled) {
  background: #1b4332;
}

.btn-primary:active:not(:disabled) {
  transform: scale(0.98);
}

.btn-primary:disabled {
  background: #a0aec0;
  cursor: not-allowed;
}

.btn-secondary {
  display: inline-block;
  padding: 0.5rem 1.1rem;
  font-size: 0.9rem;
  font-weight: 600;
  color: #2d6a4f;
  border: 2px solid #2d6a4f;
  border-radius: 8px;
  text-decoration: none;
  transition: background 0.2s, color 0.2s;
}

.btn-secondary:hover {
  background: #2d6a4f;
  color: #ffffff;
}

/* ---- Status messages ---- */
.status {
  padding: 1rem 1.25rem;
  border-radius: 8px;
  font-size: 0.95rem;
  margin-bottom: 1.5rem;
}

.status.loading {
  background: #ebf8ff;
  color: #2b6cb0;
  border-left: 4px solid #3182ce;
}

.status.error {
  background: #fff5f5;
  color: #c53030;
  border-left: 4px solid #e53e3e;
}

.status.hidden {
  display: none;
}

/* ---- Results ---- */
.results-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
}

.results-header h2 {
  font-size: 1.3rem;
  font-weight: 600;
}

#jsonOutput {
  background: #1a202c;
  color: #a8ff78;
  border-radius: 8px;
  padding: 1.25rem;
  font-size: 0.82rem;
  line-height: 1.6;
  overflow-x: auto;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 520px;
  overflow-y: auto;
}

/* ---- Top navigation ---- */
.topnav {
  display: flex;
  gap: 0.5rem;
  background: #ffffff;
  padding: 0.4rem;
  border-radius: 10px;
  margin-bottom: 1.5rem;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.nav-link {
  flex: 1;
  text-align: center;
  padding: 0.65rem 1rem;
  font-size: 0.95rem;
  font-weight: 600;
  color: #4a5568;
  text-decoration: none;
  border-radius: 7px;
  transition: background 0.15s, color 0.15s;
}

.nav-link:hover {
  background: #f0fff4;
  color: #2d6a4f;
}

.nav-link.active {
  background: #2d6a4f;
  color: #ffffff;
}

/* ---- Converter page extras ---- */
.section-title {
  font-size: 1.05rem;
  font-weight: 600;
  margin-bottom: 0.5rem;
}

#pastedJson {
  width: 100%;
  margin-top: 1rem;
  padding: 0.85rem 1rem;
  border: 1.5px solid #cbd5e0;
  border-radius: 7px;
  font-family: "SFMono-Regular", Consolas, monospace;
  font-size: 0.82rem;
  resize: vertical;
  min-height: 140px;
}

#pastedJson:focus {
  outline: none;
  border-color: #2d6a4f;
  box-shadow: 0 0 0 3px rgba(45, 106, 79, 0.12);
}

.divider {
  position: relative;
  text-align: center;
  margin: 1.25rem 0 0.5rem;
}
.divider::before {
  content: "";
  position: absolute;
  top: 50%;
  left: 0;
  right: 0;
  height: 1px;
  background: #e2e8f0;
}
.divider span {
  position: relative;
  background: #ffffff;
  padding: 0 0.75rem;
  color: #a0aec0;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.status.success {
  background: #f0fff4;
  color: #22543d;
  border-left: 4px solid #38a169;
}

.badge {
  display: inline-block;
  margin-left: 0.5rem;
  padding: 0.2rem 0.6rem;
  font-size: 0.75rem;
  font-weight: 600;
  background: #e6fffa;
  color: #2c7a7b;
  border-radius: 99px;
  vertical-align: middle;
}

.info-heading {
  font-size: 0.95rem;
  font-weight: 600;
  margin: 0.75rem 0 0.4rem;
}
.info-heading.warn { color: #b7791f; }
.info-heading.err  { color: #c53030; }

.info-list {
  list-style: disc;
  padding-left: 1.25rem;
  font-size: 0.88rem;
  color: #2d3748;
  line-height: 1.5;
}
.info-list li {
  margin-bottom: 0.25rem;
}

code {
  background: #f7fafc;
  padding: 0.1rem 0.35rem;
  border-radius: 4px;
  font-size: 0.85rem;
  color: #2d3748;
}

/* ---- Utility ---- */
.hidden {
  display: none !important;
}
