/* Working tools (/tools/<slug>) and the /tools hub's picture cards. Loaded only on those pages. */

.doc__article--tool {
  max-width: 1032px;
}

.doc__article--tool > .prose,
.doc__article--tool > .toc,
.doc__article--tool > .doc__header,
.doc__article--tool > .breadcrumbs,
.doc__article--tool > .pager,
.doc__article--tool > .cta {
  max-width: var(--measure);
}

.doc__lead {
  color: var(--muted);
  font-size: 18px;
  margin: 4px 0 0;
}

.tool-app {
  margin: 24px 0 40px;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--surface);
  padding: 20px;
}

.tool-app__boot {
  min-height: 220px;
  display: grid;
  place-items: center;
  color: var(--muted);
}

.tool-app__facts {
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 13px;
  text-align: center;
}

.tool {
  display: grid;
  grid-template-columns: minmax(260px, 340px) minmax(0, 1fr);
  gap: 20px;
  align-items: start;
}

.tool__controls {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.tool__drop {
  border: 2px dashed color-mix(in srgb, var(--brand) 45%, var(--border));
  border-radius: 12px;
  background: var(--bg);
  padding: 22px 16px;
  text-align: center;
  transition: background 0.15s, border-color 0.15s;
}

.tool__drop.is-over {
  background: color-mix(in srgb, var(--brand) 10%, var(--bg));
  border-color: var(--brand);
}

.tool__drop-title {
  margin: 0;
  font-weight: 700;
  line-height: 1.35;
}

.tool__drop-or {
  margin: 4px 0 8px;
  color: var(--muted);
  font-size: 14px;
}

.tool .button {
  border: 0;
  cursor: pointer;
  font-family: inherit;
}

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

.button--secondary {
  background: var(--bg);
  color: var(--text);
  box-shadow: inset 0 0 0 1px var(--border);
}

.link-button {
  background: none;
  border: 0;
  padding: 0;
  font: inherit;
  color: var(--brand);
  text-decoration: underline;
  cursor: pointer;
}

.tool__example {
  display: block;
  margin: 12px auto 0;
  font-size: 14px;
}

.tool__files {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.tool__files:empty {
  display: none;
}

.tool__files li {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 4px 6px 4px 10px;
  font-size: 14px;
}

.tool__file-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 600;
}

.tool__file-size {
  color: var(--muted);
}

.tool__file-remove {
  border: 0;
  background: none;
  color: var(--muted);
  font-size: 20px;
  line-height: 1;
  width: 28px;
  height: 28px;
  border-radius: 6px;
  cursor: pointer;
}

.tool__file-remove:hover {
  background: var(--surface);
  color: var(--text);
}

.tool__options {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.tool__options:empty {
  display: none;
}

.tool__field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.tool__field[hidden] {
  display: none;
}

.tool__field label {
  font-size: 14px;
  font-weight: 600;
}

.tool__label-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
}

.tool__readout {
  font-size: 13px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.tool__field select,
.tool__field input[type='text'],
.tool__field input[type='number'],
.tool__field textarea {
  font: inherit;
  font-size: 15px;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 10px;
  width: 100%;
}

.tool__field input[type='range'] {
  width: 100%;
  accent-color: var(--brand);
}

.tool__field input[type='color'] {
  width: 56px;
  height: 34px;
  padding: 2px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
}

.tool__field--check {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  column-gap: 8px;
}

.tool__field--check input {
  width: 18px;
  height: 18px;
  accent-color: var(--brand);
}

.tool__field--check .tool__hint {
  grid-column: 1 / -1;
}

.tool__number {
  display: flex;
  align-items: center;
  gap: 8px;
}

.tool__number span {
  color: var(--muted);
  font-size: 14px;
  white-space: nowrap;
}

.tool__hint {
  margin: 0;
  font-size: 13px;
  line-height: 1.45;
  color: var(--muted);
}

.tool__run {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.tool__action {
  width: 100%;
}

.tool__progress {
  height: 6px;
  border-radius: 999px;
  background: var(--border);
  overflow: hidden;
}

.tool__progress[hidden] {
  display: none;
}

.tool__progress-bar {
  height: 100%;
  width: 0;
  background: var(--brand);
  transition: width 0.2s;
}

.tool__status {
  margin: 0;
  font-size: 14px;
  color: var(--muted);
  min-height: 1.4em;
}

.tool__status.is-error {
  color: #c4320a;
  font-weight: 600;
}

@media (prefers-color-scheme: dark) {
  .tool__status.is-error {
    color: #ff8a65;
  }
}

.tool__output {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.tool__empty {
  margin: 0;
  min-height: 260px;
  display: grid;
  place-items: center;
  border-radius: 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--muted);
  text-align: center;
  padding: 16px;
}

.tool__previews {
  display: grid;
  gap: 12px;
  grid-template-columns: 1fr;
}

.tool__previews--2 {
  grid-template-columns: 1fr 1fr;
}

.tool__previews--3 {
  grid-template-columns: repeat(3, 1fr);
}

.tool__preview {
  margin: 0;
  min-width: 0;
}

.tool__preview figcaption {
  font-size: 13px;
  color: var(--muted);
  margin-top: 6px;
  text-align: center;
}

.tool__preview-frame {
  position: relative;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--bg);
  overflow: hidden;
  display: grid;
  place-items: center;
  aspect-ratio: 4 / 3;
}

.tool__preview-frame img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

.tool__preview-frame img.is-pixelated {
  image-rendering: pixelated;
}

.tool__preview-frame.is-checker {
  background-color: #fff;
  background-image: linear-gradient(45deg, #e6e8ee 25%, transparent 25%), linear-gradient(-45deg, #e6e8ee 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #e6e8ee 75%), linear-gradient(-45deg, transparent 75%, #e6e8ee 75%);
  background-size: 20px 20px;
  background-position: 0 0, 0 10px, 10px -10px, -10px 0;
}

.tool__preview-frame.is-tiled {
  background-repeat: repeat;
  background-size: 33.33% auto;
}

.tool__preview-frame--3d {
  background: #eef0f4;
  cursor: grab;
}

.tool__canvas {
  width: 100% !important;
  height: 100% !important;
  display: block;
  touch-action: none;
}

.tool__preview-text {
  margin: 0;
  max-height: 320px;
  overflow: auto;
  font-size: 13px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px;
  white-space: pre-wrap;
  word-break: break-word;
}

.tool__stats {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 4px 16px;
  margin: 0;
  font-size: 15px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 16px;
}

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

.tool__stats dd {
  margin: 0;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  overflow-wrap: anywhere;
}

.tool__notes {
  margin: 0;
  padding: 10px 14px 10px 30px;
  font-size: 14px;
  line-height: 1.5;
  border-radius: 12px;
  background: color-mix(in srgb, #f5c84c 16%, var(--bg));
  border: 1px solid color-mix(in srgb, #f5c84c 45%, var(--border));
}

.tool__notes li + li {
  margin-top: 4px;
}

.tool__downloads {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.tool__download-size {
  font-weight: 400;
  opacity: 0.8;
  margin-left: 8px;
  font-size: 0.85em;
}

.tool-app.is-busy .tool__action {
  opacity: 0.7;
}

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

@media (max-width: 640px) {
  .tool-app {
    padding: 14px;
    margin-left: -4px;
    margin-right: -4px;
  }
  .tool__previews--2,
  .tool__previews--3 {
    grid-template-columns: 1fr;
  }
  .tool__stats {
    grid-template-columns: 1fr;
  }
  .tool__stats dd {
    margin-bottom: 6px;
  }
}

/* ── /tools hub: picture cards ─────────────────────────────────────────── */

.hub--tools .chips a.chip {
  text-decoration: none;
}

.hub--tools .chip span {
  color: var(--muted);
  font-weight: 500;
  margin-left: 2px;
}

.tcards {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 16px;
}

.tcard__link {
  display: flex;
  flex-direction: column;
  height: 100%;
  border: 1px solid var(--border);
  border-radius: 14px;
  overflow: hidden;
  text-decoration: none;
  color: var(--text);
  background: var(--bg);
  transition: transform 0.15s, box-shadow 0.15s, border-color 0.15s;
}

.tcard__link:hover {
  transform: translateY(-2px);
  border-color: color-mix(in srgb, var(--brand) 40%, var(--border));
  box-shadow: 0 10px 28px -14px rgba(20, 30, 60, 0.35);
}

.tcard__art {
  position: relative;
  display: block;
  aspect-ratio: 16 / 10;
  overflow: hidden;
  background: var(--surface);
}

.tcard__art img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.tcard__fallback {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-weight: 800;
  font-size: 22px;
  color: #fff;
  padding: 12px;
  text-align: center;
}

.tcard--model-to-image .tcard__fallback { background: linear-gradient(135deg, #5a3fd9, #1e5eff); }
.tcard--converters .tcard__fallback { background: linear-gradient(135deg, #1e5eff, #0aa5c2); }
.tcard--utilities .tcard__fallback { background: linear-gradient(135deg, #09694f, #2bb673); }
.tcard--print .tcard__fallback { background: linear-gradient(135deg, #c2410c, #f59e0b); }
.tcard--image .tcard__fallback { background: linear-gradient(135deg, #be185d, #f472b6); }
.tcard--texture .tcard__fallback { background: linear-gradient(135deg, #3f3f46, #71717a); }

.tcard__badge {
  position: absolute;
  left: 10px;
  bottom: 10px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.02em;
  background: rgba(15, 17, 21, 0.78);
  color: #fff;
  padding: 3px 9px;
  border-radius: 999px;
}

.tcard__title {
  display: block;
  font-weight: 700;
  font-size: 16px;
  line-height: 1.3;
  padding: 12px 14px 0;
}

.tcard__description {
  display: block;
  font-size: 14px;
  line-height: 1.45;
  color: var(--muted);
  padding: 4px 14px 14px;
}

/* What this visitor's plan produces, on tools that follow the plan. */
.tool__plan {
  margin: 0 0 14px;
  padding: 12px 14px;
  border: 1px solid var(--border, rgba(127, 127, 127, 0.3));
  border-radius: 10px;
  font-size: 0.9rem;
  line-height: 1.45;
}
.tool__plan p {
  margin: 0;
}
.tool__plan-links {
  margin-top: 6px !important;
}
