.tool-shell {
  width: min(100% - 2rem, 1080px);
  margin: 0 auto 5rem;
}

.tool-intro,
.tool-panel,
.tool-result {
  padding: 1.5rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
}

.tool-intro {
  margin: 3rem 0 1rem;
  color: var(--text-secondary);
  line-height: 1.7;
}

.tool-intro strong,
.tool-result strong {
  color: var(--text-primary);
}

.tool-form {
  display: grid;
  gap: 1.25rem;
}

.tool-fieldset {
  min-width: 0;
  margin: 0;
  padding: 1.25rem;
  border: 1px solid var(--border);
  border-radius: 8px;
}

.tool-fieldset legend {
  max-width: 100%;
  padding: 0 0.35rem;
  color: var(--text-primary);
  font-weight: 700;
  line-height: 1.45;
}

.tool-options {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 0.6rem;
  margin-top: 0.75rem;
}

.tool-option {
  display: grid;
  min-height: 5rem;
  padding: 0.75rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  cursor: pointer;
}

.tool-option:has(input:checked) {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 10%, var(--surface));
}

.tool-option input {
  width: 1.15rem;
  height: 1.15rem;
  margin: 0 0 0.5rem;
  accent-color: var(--accent);
}

.tool-option span {
  color: var(--text-secondary);
  font-size: 0.82rem;
  line-height: 1.35;
}

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

.tool-field {
  display: grid;
  gap: 0.45rem;
}

.tool-field label {
  color: var(--text-primary);
  font-weight: 650;
}

.tool-field small,
.tool-help {
  color: var(--text-secondary);
  line-height: 1.5;
}

.tool-field input,
.tool-field select {
  width: 100%;
  min-height: 2.9rem;
  padding: 0.65rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text-primary);
  background: var(--bg);
  font: inherit;
}

.tool-field input:focus-visible,
.tool-field select:focus-visible,
.tool-option:has(input:focus-visible) {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}

.tool-error {
  margin: 0;
  padding: 0.9rem 1rem;
  border-left: 3px solid #c53b3b;
  color: var(--text-primary);
  background: color-mix(in srgb, #c53b3b 12%, var(--surface));
}

.tool-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.tool-result {
  margin-top: 1rem;
  scroll-margin-top: 7rem;
}

.tool-result[hidden] {
  display: none;
}

.tool-result h2,
.tool-result h3 {
  letter-spacing: 0;
}

.tool-result h2 {
  margin-top: 0;
}

.tool-level {
  display: inline-block;
  margin-bottom: 0.75rem;
  padding: 0.35rem 0.55rem;
  border: 1px solid var(--accent);
  border-radius: 4px;
  color: var(--accent);
  font-weight: 750;
}

.tool-metrics {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.75rem;
  margin: 1.25rem 0;
}

.tool-metric {
  padding: 1rem;
  border: 1px solid var(--border);
  border-radius: 6px;
}

.tool-metric span {
  display: block;
  color: var(--text-secondary);
  font-size: 0.82rem;
}

.tool-metric strong {
  display: block;
  margin-top: 0.35rem;
  font-size: 1.35rem;
  overflow-wrap: anywhere;
}

@media (max-width: 800px) {
  .tool-options,
  .tool-fields,
  .tool-metrics {
    grid-template-columns: 1fr;
  }

  .tool-option {
    grid-template-columns: auto 1fr;
    align-items: start;
    min-height: 0;
    gap: 0.65rem;
  }

  .tool-option input {
    margin: 0.1rem 0 0;
  }
}

@media print {
  .nav-wrap,
  .footer,
  .detail-actions,
  .tool-actions,
  .tool-intro,
  .tool-form,
  .detail-related {
    display: none !important;
  }

  .detail-main {
    padding-top: 0;
  }

  .tool-result {
    border: 0;
  }
}