/* --- Reset & Globals --- */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}
body {
  font-family: 'Segoe UI', Roboto, sans-serif;
  background: #1e1e3f;
  color: #eee;
  overflow-x: hidden;
}

/* --- Background Canvas --- */
#bgCanvas {
  position: fixed;
  inset: 0;
  z-index: -1;
  background: linear-gradient(135deg, #1e1e3f 0%, #2b2d5c 100%);
}

/* --- Container --- */
.container {
  width: 100%;
  max-width: 900px;
  margin: 2rem auto;
  padding: 0 1rem;
  text-align: center;
}

/* --- Header & Logo --- */
.header {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-bottom: 2rem;
}
.header .logo {
  width: 50px;
  height: auto;
}

/* --- Controls --- */
.controls {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  margin-bottom: 2rem;
}
.object-inputs {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.object-inputs input {
  padding: 0.6rem;
  font-size: 1rem;
  border: none;
  border-radius: 8px;
  background-color: #2b2d5c;
  color: #fff;
}

/* --- Mode and Units Row --- */
.controls-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 1rem;
  justify-content: center;
}

/* --- Mode Select --- */
.mode-group {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}
.mode-group select {
  padding: 0.5rem;
  font-size: 1rem;
  border-radius: 8px;
  background-color: #2b2d5c;
  color: #fff;
  border: none;
}

/* --- Unit Toggle --- */
.unit-toggle {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}
.radio-group {
  display: flex;
  gap: 1rem;
}
.radio-group label {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  font-size: 0.9rem;
}

/* --- Calculate Button --- */
#calculateButton {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0.7rem 1.25rem;
  font-size: 1rem;
  background-color: #4e63f4;
  color: white;
  border: none;
  border-radius: 12px;
  cursor: pointer;
  transition: background-color 0.3s ease;
}
#calculateButton:hover {
  background-color: #3d4cd9;
}
#calculateButton.loading {
  opacity: 0.6;
  pointer-events: none;
}
#calculateButton .spinner {
  display: none;
  margin-left: 0.5rem;
}
#calculateButton.loading .spinner {
  display: inline-block;
  width: 1em;
  height: 1em;
  border: 2px solid white;
  border-top: 2px solid transparent;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}
@keyframes spin {
  100% {
    transform: rotate(360deg);
  }
}

/* --- Output Section --- */
#output {
  margin-top: 2rem;
  opacity: 0;
  transition: opacity 0.5s ease;
}
#output.visible {
  opacity: 1;
}
#explanation {
  margin-bottom: 1rem;
  font-size: 1.1rem;
}

/* --- Share Controls --- */
.share-controls {
  display: flex;
  justify-content: center;
  gap: 1rem;
  margin-bottom: 1rem;
}
.share-controls button,
.share-controls a {
  padding: 0.5rem 1rem;
  border-radius: 8px;
  background: #444b9c;
  color: white;
  text-decoration: none;
  font-size: 0.95rem;
  border: none;
  cursor: pointer;
}
.share-controls button:hover,
.share-controls a:hover {
  background: #5d63c4;
}

/* --- Images --- */
.image-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 1rem;
  margin-top: 1rem;
}
.image-grid img {
  width: 100%;
  border-radius: 16px;
  opacity: 0;
  transition: opacity 0.4s ease;
}
.image-grid img.visible {
  opacity: 1;
}

/* --- Responsive Adjustments --- */
@media (max-width: 600px) {
  .controls-row {
    flex-direction: column;
    align-items: stretch;
  }
  .object-inputs input {
    font-size: 0.95rem;
  }
}
