.tool {
  margin: 1.5rem 0 2rem;
}

.tool-field {
  margin-bottom: 1rem;
}

.tool-field label {
  display: block;
  margin-bottom: 0.35rem;
  font-weight: 600;
}

.tool-field textarea,
.tool-field input[type="file"],
.tool-field input[type="number"] {
  width: 100%;
  max-width: 40rem;
  box-sizing: border-box;
}

.tool-field textarea {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.9rem;
  line-height: 1.4;
  padding: 0.75rem;
  border: 1px solid #ccc;
  border-radius: 4px;
  resize: vertical;
}

.tool-field--inline {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 0.75rem;
}

.tool-field--inline label {
  margin-bottom: 0;
}

.tool-field--inline input[type="number"] {
  width: 5rem;
  max-width: none;
  padding: 0.35rem 0.5rem;
}

.tool-hint {
  color: #666;
  font-size: 0.9rem;
}

.tool-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin: 1rem 0;
}

.tool-actions button,
.tool button {
  cursor: pointer;
  padding: 0.45rem 0.9rem;
  border: 1px solid #333;
  border-radius: 4px;
  background: #222;
  color: #fff;
}

.tool-actions button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.tool-button--secondary {
  background: #f5f5f5 !important;
  color: #222 !important;
  border-color: #999 !important;
}

.tool-status {
  min-height: 1.4em;
  margin: 0.5rem 0 1rem;
  color: #444;
}

.tool-status.is-error {
  color: #a40000;
}

.tool-preview {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.25rem;
}

@media (min-width: 720px) {
  .tool-preview {
    grid-template-columns: 1fr 1fr;
  }
}

.tool-preview h4 {
  margin: 0 0 0.5rem;
}

.tool-preview-box {
  min-height: 10rem;
  padding: 1rem;
  border: 1px dashed #bbb;
  border-radius: 6px;
  background: repeating-conic-gradient(#f0f0f0 0% 25%, #fff 0% 50%) 50% / 16px 16px;
  overflow: auto;
}

.tool-preview-box img,
.tool-preview-box svg {
  max-width: 100%;
  height: auto;
  display: block;
}

.tool-field select {
  width: 100%;
  max-width: 40rem;
  box-sizing: border-box;
  padding: 0.35rem 0.5rem;
  border: 1px solid #ccc;
  border-radius: 4px;
  background: #fff;
}

.tool-field--inline select {
  width: auto;
  min-width: 9rem;
  max-width: none;
}

.tool-modes {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin: 0 0 1.25rem;
}

.tool button.tool-mode {
  cursor: pointer;
  padding: 0.4rem 0.75rem;
  border: 1px solid #999;
  border-radius: 4px;
  background: #f5f5f5;
  color: #222;
  font: inherit;
}

.tool button.tool-mode.is-active {
  background: #222;
  border-color: #222;
  color: #fff;
}

.tool button.tool-mode:focus-visible {
  outline: 2px solid #2660ab;
  outline-offset: 2px;
}

.tool-panel[hidden] {
  display: none !important;
}

.tool-summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(9rem, 1fr));
  gap: 0.75rem 1rem;
  margin: 0.25rem 0 1rem;
}

.tool-summary-item {
  min-width: 0;
}

.tool-summary-label {
  display: block;
  color: #666;
  font-size: 0.85rem;
  margin-bottom: 0.15rem;
}

.tool-summary-value {
  display: block;
  font-weight: 700;
  font-size: 1.05rem;
  color: #222;
  word-break: break-word;
}

.tool-chart-wrap {
  width: 100%;
  max-width: 48rem;
  margin: 0.5rem 0 0.75rem;
  border: 1px solid #ddd;
  border-radius: 6px;
  background: #fafafa;
  overflow: hidden;
}

.tool-chart-wrap canvas {
  display: block;
  width: 100%;
  height: auto;
  min-height: 16rem;
}

.tool-periods {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  margin: 0.75rem 0 0.25rem;
}

.tool-period-row .tool-field--inline {
  margin-bottom: 0;
}

.tool-period-row input[type="number"] {
  width: 4.5rem;
}

.tool-period-remove {
  margin-left: 0.25rem;
}

@media (max-width: 719px) {
  .tool-mode {
    flex: 1 1 calc(50% - 0.4rem);
    text-align: center;
  }

  .tool-period-row .tool-field--inline {
    align-items: flex-start;
  }
}
