/* Input form frame and legend styling */
.tool-form fieldset {
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 10px;
  padding: 1rem;
  margin: 0;
}

.tool-form legend {
  font-weight: 700;
  padding: 0 0.4rem;
}

/* Desktop layout: 2 columns and 3 rows for predictable field placement */
.tool-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  grid-template-rows: repeat(3, auto);
  align-items: start;
  gap: 0.9rem;
}

/* Explicit placement keeps both input columns aligned row-by-row. */
.tool-grid .tool-field:nth-of-type(1) {
  grid-column: 1;
  grid-row: 1;
}

.tool-grid .tool-field:nth-of-type(2) {
  grid-column: 2;
  grid-row: 1;
}

.tool-grid .tool-field:nth-of-type(3) {
  grid-column: 1;
  grid-row: 2;
}

.tool-grid .tool-field:nth-of-type(4) {
  grid-column: 2;
  grid-row: 2;
}

.tool-grid .tool-field:nth-of-type(5) {
  grid-column: 1 / -1;
  grid-row: 3;
}

/* Each field stacks label over input */
.tool-field {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

/* Input visual treatment */
.tool-field input {
  width: 100%;
  font: inherit;
  color: #fff;
  background: #0b0c0d;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 8px;
  padding: 0.65rem 0.7rem;
}

.tool-field input:focus {
  outline: 2px solid rgba(124, 58, 237, 0.4);
  outline-offset: 1px;
}

/* Action buttons row */
.tool-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  margin-top: 0.9rem;
}

/* Validation feedback */
.tool-error {
  margin-top: 0.8rem;
  color: #fca5a5;
  font-weight: 600;
}

/* Results section spacing */
.tool-results {
  margin-top: 1.2rem;
}

/* Desktop results: one row with equal-width cards */
.tool-results-grid {
  display: flex;
  flex-wrap: nowrap;
  gap: 0.9rem;
}

/* Card container for each metric */
.result-card {
  flex: 1 1 0;
  background: var(--surface);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 10px;
  padding: 0.9rem;
}

.result-card h3 {
  margin: 0 0 0.4rem 0;
  font-size: 1rem;
}

.result-value {
  margin: 0;
  font-size: 1.45rem;
  font-weight: 700;
}

.result-note {
  margin: 0.35rem 0 0 0;
  color: var(--muted);
}

.tool-notes {
  margin-top: 1.4rem;
}

/* Mobile layout: stack inputs and result cards into a single column */
@media (max-width: 880px) {
  .tool-grid {
    grid-template-columns: 1fr;
    grid-template-rows: auto;
  }

  .tool-grid .tool-field:nth-of-type(1),
  .tool-grid .tool-field:nth-of-type(2),
  .tool-grid .tool-field:nth-of-type(3),
  .tool-grid .tool-field:nth-of-type(4),
  .tool-grid .tool-field:nth-of-type(5) {
    grid-column: auto;
    grid-row: auto;
  }

  .tool-results-grid {
    flex-direction: column;
  }
}