.rule-tool {
  max-width: 920px;
  margin-inline: auto;
}

.proportion-types {
  margin: 0;
  padding: 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

.proportion-types:focus-within {
  border-color: var(--brand-strong);
}

.proportion-types legend,
.rule-examples legend {
  padding-inline: 0.35rem;
  font-weight: 800;
}

.proportion-types__grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.65rem;
}

.proportion-types label {
  display: flex;
  align-items: flex-start;
  min-height: 82px;
  margin: 0;
  padding: 0.75rem;
  gap: 0.6rem;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--surface-2);
  cursor: pointer;
}

.proportion-types label:hover {
  border-color: var(--brand-strong);
}

.proportion-types input {
  width: auto;
  min-height: auto;
  margin: 0.25rem 0 0;
  accent-color: var(--brand-strong);
}

.proportion-types strong,
.proportion-types small {
  display: block;
}

.proportion-types small {
  margin-top: 0.25rem;
  color: var(--muted);
  font-weight: 400;
  line-height: 1.4;
}

.rule-fields {
  margin-top: 1.35rem;
}

.rule-fields h2 {
  margin: 0;
  font-size: clamp(1.25rem, 3vw, 1.6rem);
}

.rule-hint {
  margin: 0.3rem 0 1rem;
  color: var(--muted);
}

.proportion-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: end;
  gap: 0.7rem;
}

.relation-symbol {
  display: grid;
  place-items: center;
  min-height: 48px;
  margin-bottom: 1rem;
  color: var(--brand);
  font-size: 1.4rem;
  font-weight: 800;
}

.proportion-field--result > span {
  display: block;
  margin-bottom: 0.4rem;
  font-weight: 700;
}

.proportion-field--result output {
  display: flex;
  align-items: center;
  min-height: 46px;
  padding: 0.7rem 0.8rem;
  border: 1px dashed var(--brand-strong);
  border-radius: 10px;
  background: rgba(22, 133, 248, 0.1);
  font-size: 1.1rem;
  font-weight: 800;
  overflow-wrap: anywhere;
}

.rule-tool input[aria-invalid="true"] {
  border-color: var(--danger);
}

.rule-examples {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
  margin: 0.25rem 0 1rem;
  padding: 0;
  border: 0;
}

.rule-examples legend {
  width: 100%;
  margin-bottom: 0.4rem;
}

.example-button {
  min-height: 40px;
  padding-block: 0.55rem;
  font-size: 0.92rem;
}

.rule-results {
  margin-top: 2rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
}

.results-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.results-heading h2 {
  margin: 0;
}

.eyebrow {
  margin: 0 0 0.25rem;
  color: var(--brand);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.rule-result-card {
  margin-top: 1rem;
  padding: 1rem;
  border: 1px solid var(--brand-strong);
  border-radius: 11px;
  background: rgba(22, 133, 248, 0.1);
}

.rule-result-card span {
  display: block;
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 700;
}

.rule-result-card strong {
  display: block;
  margin-top: 0.3rem;
  font-size: clamp(1.6rem, 5vw, 2.4rem);
  line-height: 1.2;
  overflow-wrap: anywhere;
}

.result-explanation {
  margin: 1rem 0 0;
  font-size: 1.05rem;
}

.formula-box {
  margin-top: 0.8rem;
  padding: 0.85rem 1rem;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--surface-2);
  overflow-x: auto;
}

.formula-box span {
  display: block;
  margin-bottom: 0.25rem;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 700;
}

.formula-box code,
.rule-content code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.rule-content .formula {
  max-width: 100%;
  padding: 0.9rem;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--surface-2);
  overflow-x: auto;
}

@media (max-width: 700px) {
  .proportion-layout {
    grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  }

  .proportion-types__grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 560px) {
  .proportion-layout {
    grid-template-columns: 1fr;
  }

  .relation-symbol {
    min-height: auto;
    margin-bottom: 0;
    transform: rotate(90deg);
  }

  .results-heading {
    align-items: flex-start;
    flex-direction: column;
  }

  .results-heading button {
    width: 100%;
  }
}
