.tool-main {
  width: min(1040px, calc(100% - 32px));
}

.tool-main > p,
.tool-main > h2,
.tool-main > h3,
.tool-main > ul,
.tool-main > ol,
.tool-main > .table-scroll {
  max-width: 760px;
}

.tool {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(0, 0.9fr);
  gap: 22px;
  align-items: start;
  margin: 26px 0 34px;
}

.tool-form {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px 16px;
  padding: 22px;
  border-radius: var(--radius-card);
}

.tool-form fieldset {
  display: contents;
}

.tool-form legend {
  grid-column: 1 / -1;
  margin-top: 6px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.tool-form label {
  display: grid;
  align-content: start;
  gap: 6px;
  color: var(--text);
  font-size: 0.92rem;
  font-weight: 600;
}

.tool-form label.wide {
  grid-column: 1 / -1;
}

.tool-form small {
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 500;
}

.tool-form input,
.tool-form select {
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-weight: 600;
}

.tool-form input:focus-visible,
.tool-form select:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 1px;
}

.tool-result {
  position: sticky;
  top: 96px;
  display: grid;
  gap: 14px;
  padding: 22px;
  border-radius: var(--radius-card);
}

.tool-result .savings strong {
  font-size: 2.4rem;
}

.tool-lines {
  display: grid;
  gap: 8px;
  margin: 0;
}

.tool-lines div {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
  font-size: 0.94rem;
}

.tool-lines div:last-child {
  border-bottom: 0;
}

.tool-lines dt {
  color: var(--muted);
}

.tool-lines dd {
  margin: 0;
  color: var(--text);
  font-weight: 700;
  text-align: right;
}

.tool-warn {
  margin: 0;
  padding: 12px 14px;
  border-radius: 14px;
  background: var(--warning-soft);
  color: var(--text);
  font-size: 0.9rem;
  font-weight: 600;
}

.tool-note {
  margin: 0;
  color: var(--muted);
  font-size: 0.82rem;
}

.tool-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 16px;
  margin: 24px 0;
}

.tool-cards a {
  display: grid;
  gap: 8px;
  padding: 20px;
  border-radius: var(--radius-card);
  color: var(--text);
  text-decoration: none;
}

.tool-cards a strong {
  font-size: 1.08rem;
}

.tool-cards a span {
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.5;
}

.tool-formula {
  padding: 14px 16px;
  border-radius: 14px;
  background: var(--surface-secondary);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.88rem;
  line-height: 1.7;
  overflow-x: auto;
}

@media (max-width: 860px) {
  .tool {
    grid-template-columns: 1fr;
  }

  .tool-result {
    position: static;
  }
}

@media (max-width: 520px) {
  .tool-form {
    grid-template-columns: 1fr;
  }
}

.tool-result .savings span span {
  display: inline;
}
