/* /tools/ and the data tool pages: the converter panels, then how-to, FAQ, and next steps.
   Colors come from theme.css, so everything follows the Forest/Light toggle. */
.tool-page { max-width: 1240px; margin: 0 auto; padding: 0 var(--pe-gutter) 96px; color: var(--theme-text); }
.tool-page h1, .tool-page h2, .tool-page h3, .tool-page p, .tool-page ul, .tool-page ol, .tool-page dl, .tool-page dd { margin: 0; }
.tool-page p { color: var(--theme-muted); }
.tool-page a { color: var(--theme-text); }
.tool-page [hidden] { display: none !important; }

.tool-hero { padding: 56px 0 32px; display: grid; gap: 16px; }
.tool-page .tool-hero h1 {
  max-width: 18em; font-size: clamp(36px, 4.6vw, 60px); line-height: 1.05; font-weight: 500; letter-spacing: -0.03em; text-wrap: balance;
}
.tool-hero h1 em { color: var(--emerald, var(--theme-text)); }
.tool-intro { max-width: 44em; font-size: 18px; line-height: 1.6; }
.tool-page .tool-private {
  display: inline-flex; align-items: center; gap: 8px; justify-self: start; padding: 6px 14px;
  border: 1px solid var(--theme-line); border-radius: 20px; background: var(--theme-surface);
  font-family: var(--pe-mono); font-size: 13px; color: var(--theme-text);
}

/* The tool: input and options side by side, the result underneath. */
.tool {
  display: grid; grid-template-columns: minmax(0, 1.7fr) minmax(260px, 1fr); grid-template-areas: "input options" "output options";
  gap: 16px; align-items: start;
}
.tool-input { grid-area: input; }
.tool-options { grid-area: options; }
.tool-panel {
  min-width: 0; padding: 20px; display: grid; gap: 14px; align-content: start;
  border: 1px solid var(--theme-line); border-radius: 16px; background: var(--theme-surface);
}
.tool-output { grid-area: output; }
.tool-panel-head, .tool-output-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 12px; }
.tool-page .tool-panel-title {
  font-family: var(--pe-mono); font-size: 12px; font-weight: 400; letter-spacing: 0.1em; text-transform: uppercase; color: var(--theme-muted);
}
.tool-input-actions, .tool-actions { display: flex; flex-wrap: wrap; gap: 8px; }

@media (min-width: 901px) {
  /* A shorter hero, so the tool starts high in the first screen. */
  .tool-hero { padding: 24px 0; gap: 12px; }
  .tool-page .tool-hero h1 { font-size: clamp(34px, 3.3vw, 46px); }
  .tool-intro { max-width: 56em; font-size: 17px; line-height: 1.55; }
  /* Data tools show tables, so the result spans both columns under the input and options. */
  .tool-wide-result { grid-template-areas: "input options" "output output"; }
  /* Makers that take no file: the input panel is one slim row, so the preview starts near the top. */
  .tool-inputless { grid-template-areas: "input input" "output options"; }
  .tool-inputless > .tool-input {
    grid-template-columns: auto minmax(0, 1fr) auto; grid-template-areas: "title entry actions" "title hint actions";
    align-items: center; gap: 0 24px; padding: 12px 20px;
  }
  .tool-inputless > .tool-input > .tool-panel-head { display: contents; }
  .tool-inputless > .tool-input .tool-panel-title { grid-area: title; }
  .tool-inputless > .tool-input .tool-input-actions { grid-area: actions; }
  .tool-inputless > .tool-input > p:not(.tool-drop-hint) { grid-area: entry; align-self: end; }
  .tool-inputless > .tool-input > .tool-drop-hint { grid-area: hint; align-self: start; }
}
/* Wide screens: the privacy note joins the breadcrumb row. */
@media (min-width: 1180px) {
  .tool-hero:not(.tool-directory-hero) {
    grid-template-columns: minmax(0, 1fr) auto auto; grid-template-areas: "crumb private switch" "title title title" "intro intro intro";
    align-items: center; column-gap: 16px;
  }
  .tool-hero > .tool-context { display: contents; }
  .tool-hero > .tool-context > .breadcrumb { grid-area: crumb; }
  .tool-hero > .tool-context > .tool-switch { grid-area: switch; }
  .tool-hero:not(.tool-directory-hero) > h1 { grid-area: title; }
  .tool-hero:not(.tool-directory-hero) > .tool-intro { grid-area: intro; }
  .tool-hero:not(.tool-directory-hero) > .tool-private { grid-area: private; }
  .tool-directory-hero { grid-template-columns: minmax(0, 1fr) auto; align-items: center; column-gap: 16px; }
  .tool-directory-hero > :not(.breadcrumb, .tool-private) { grid-column: 1 / -1; }
  .tool-directory-hero > .tool-private { grid-row: 1; grid-column: 2; }
  .tool-directory-hero > .tool-intro { max-width: 66em; }
}

.tool-page textarea {
  width: 100%; min-height: 260px; resize: vertical; padding: 14px; border: 1px solid var(--theme-line); border-radius: 10px;
  background: var(--theme-bg); color: var(--theme-text); font: 13px/1.5 var(--pe-mono);
}
.tool-page textarea::placeholder { color: var(--theme-muted); opacity: 0.8; }
.tool-input.is-dragging { border-style: dashed; border-color: var(--theme-text); background: var(--theme-bg); }
.tool-page .tool-drop-hint { font-size: 14px; }
.tool-file {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 12px; padding: 14px 16px;
  border: 1px dashed var(--theme-line); border-radius: 10px; background: var(--theme-bg);
  font-family: var(--pe-mono); font-size: 14px; overflow-wrap: anywhere;
}

.tool-btn {
  display: inline-flex; align-items: center; justify-content: center; min-height: 44px; padding: 0 18px;
  border: 1px solid var(--theme-line); border-radius: 22px; background: var(--theme-bg); color: var(--theme-text);
  font: 500 15px var(--pe-sans); text-decoration: none; cursor: pointer;
}
.tool-btn:hover { border-color: var(--theme-text); }
.tool-btn-quiet { background: transparent; }
.tool-btn-primary { background: var(--theme-control); border-color: var(--theme-control); color: var(--theme-on-control); }
.tool-btn-primary:hover { background: var(--theme-hover); border-color: var(--theme-hover); }
.tool-file-button { position: relative; }
.tool-file-button input { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); opacity: 0; }
.tool-file-button:focus-within { outline: 2px solid var(--theme-focus); outline-offset: 2px; }

/* Options */
.tool-field { display: grid; gap: 6px; }
.tool-field > label, .tool-field > .tool-label, .tool-group legend { font-size: 15px; font-weight: 600; color: var(--theme-text); }
.tool-page select {
  width: 100%; min-height: 44px; padding: 0 12px; border: 1px solid var(--theme-line); border-radius: 10px;
  background: var(--theme-bg); color: var(--theme-text); font: 15px var(--pe-sans);
}
.tool-page .tool-field input[type="text"], .tool-page .tool-field input[type="number"] {
  width: 100%; min-height: 44px; padding: 0 12px; border: 1px solid var(--theme-line); border-radius: 10px;
  background: var(--theme-bg); color: var(--theme-text); font: 15px var(--pe-sans);
}
.tool-page .tool-field input[type="color"] {
  width: 64px; height: 40px; padding: 2px; border: 1px solid var(--theme-line); border-radius: 10px; background: var(--theme-bg); cursor: pointer;
}
.tool-page .tool-field input[type="file"] { font: 14px var(--pe-sans); color: var(--theme-muted); max-width: 100%; }
.tool-range > label { display: flex; justify-content: space-between; gap: 8px; }
.tool-range output { font-family: var(--pe-mono); font-size: 13px; font-weight: 400; color: var(--theme-muted); }
.tool-page .tool-range input[type="range"] { width: 100%; accent-color: var(--theme-control); }
.tool-check { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 10px; align-items: start; font-size: 15px; line-height: 1.4; }
.tool-check input { width: 18px; height: 18px; margin: 1px 0 0; accent-color: var(--theme-control); }
.tool-hint { display: block; margin-top: 2px; font-size: 13px; color: var(--theme-muted); }
.tool-group { min-width: 0; margin: 0; padding: 10px 12px 12px; border: 1px solid var(--theme-line); border-radius: 10px; }
.tool-group legend { padding: 0 4px; }
.tool-group-body { display: grid; gap: 8px; max-height: 420px; overflow: auto; }
.tool-type { display: grid; grid-template-columns: minmax(0, 1fr) minmax(120px, 150px); align-items: center; gap: 8px; }
.tool-type label { font-family: var(--pe-mono); font-size: 13px; overflow-wrap: anywhere; }
.tool-type select { min-height: 38px; font-size: 14px; }

/* Result */
.tool-page .tool-status { font-size: 16px; line-height: 1.5; color: var(--theme-text); }
.tool-page .tool-status[data-state="error"] {
  padding: 12px 14px; border: 1px solid #934134; border-radius: 10px; background: #fbede7; color: #733a31;
}
[data-theme="forest"] .tool-page .tool-status[data-state="error"] { border-color: #f0aa90; background: #59362f; color: #ffdcce; }
.tool-notes { display: grid; gap: 4px; padding-left: 20px; font-size: 15px; line-height: 1.5; color: var(--theme-muted); }
.tool-views { display: flex; flex-wrap: wrap; gap: 8px; }
.tool-view {
  min-height: 38px; padding: 0 14px; border: 1px solid var(--theme-line); border-radius: 19px;
  background: transparent; color: var(--theme-text); font: 14px var(--pe-sans); cursor: pointer;
}
.tool-view[aria-pressed="true"] { background: var(--theme-control); border-color: var(--theme-control); color: var(--theme-on-control); }
.tool-preview { max-height: 520px; overflow: auto; border: 1px solid var(--theme-line); border-radius: 10px; }
.tool-preview:focus-visible { outline: 2px solid var(--theme-focus); outline-offset: 2px; }
/* A soft shadow shows at each edge of a scrolling box that has more to see. The covers move with the content
   (local) and hide the shadows (scroll) at each end, so no script is needed. --scroll-cover is the box's background. */
.tool-group-body, .tool-sectioned .tool-options, .tool-switch-panel nav {
  background:
    linear-gradient(var(--scroll-cover) 30%, transparent) center top / 100% 36px no-repeat local,
    linear-gradient(transparent, var(--scroll-cover) 70%) center bottom / 100% 36px no-repeat local,
    radial-gradient(farthest-side at 50% 0, var(--theme-shadow), transparent) center top / 100% 12px no-repeat scroll,
    radial-gradient(farthest-side at 50% 100%, var(--theme-shadow), transparent) center bottom / 100% 12px no-repeat scroll,
    var(--scroll-cover);
}
/* The preview can scroll both ways (wide tables, long text). */
.tool-preview {
  background:
    linear-gradient(var(--scroll-cover) 30%, transparent) center top / 100% 36px no-repeat local,
    linear-gradient(transparent, var(--scroll-cover) 70%) center bottom / 100% 36px no-repeat local,
    linear-gradient(to right, var(--scroll-cover) 30%, transparent) left center / 36px 100% no-repeat local,
    linear-gradient(to left, var(--scroll-cover) 30%, transparent) right center / 36px 100% no-repeat local,
    radial-gradient(farthest-side at 50% 0, var(--theme-shadow), transparent) center top / 100% 12px no-repeat scroll,
    radial-gradient(farthest-side at 50% 100%, var(--theme-shadow), transparent) center bottom / 100% 12px no-repeat scroll,
    radial-gradient(farthest-side at 0 50%, var(--theme-shadow), transparent) left center / 12px 100% no-repeat scroll,
    radial-gradient(farthest-side at 100% 50%, var(--theme-shadow), transparent) right center / 12px 100% no-repeat scroll,
    var(--scroll-cover);
}
.tool-preview, .tool-switch-panel nav { --scroll-cover: var(--theme-bg); }
.tool-group-body, .tool-sectioned .tool-options { --scroll-cover: var(--theme-surface); }
/* Says how many table columns are past the right edge of the preview. */
.tool-page .tool-scroll-hint { font-size: 14px; line-height: 1.4; }
/* Image tools: a drop area instead of a paste box, and before/after previews. */
.tool-dropzone {
  min-height: 220px; padding: 24px; display: grid; place-content: center; gap: 6px; text-align: center;
  border: 1.5px dashed var(--theme-line); border-radius: 12px; background: var(--theme-bg);
}
.tool-page .tool-dropzone p:first-child { font-size: 17px; color: var(--theme-text); }
.tool-input.is-dragging .tool-dropzone { border-color: var(--theme-text); }
.tool-images { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; padding: 12px; }
.tool-image { margin: 0; display: grid; gap: 6px; align-content: start; }
.tool-image img {
  display: block; width: 100%; height: auto; max-height: 460px; object-fit: contain; border-radius: 8px;
  background: var(--theme-surface);
}
.tool-image-checker img {
  background-color: #ffffff;
  background-image: conic-gradient(#d9ddd5 25%, #ffffff 0 50%, #d9ddd5 0 75%, #ffffff 0);
  background-size: 20px 20px;
}
.tool-image figcaption { font-family: var(--pe-mono); font-size: 12px; letter-spacing: 0.06em; text-transform: uppercase; color: var(--theme-muted); }
.tool-images-single { grid-template-columns: minmax(0, 1fr); }
.tool-images-single .tool-image img, .tool-images-single .tool-image video {
  display: block; width: 100%; height: auto; max-height: 560px; object-fit: contain; border-radius: 8px; background: var(--theme-surface);
}
.tool-images-single .tool-image figcaption { font-size: 11px; letter-spacing: 0; text-transform: none; overflow-wrap: anywhere; }
.tool-images-grid { grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); }
.tool-images-grid .tool-image img { aspect-ratio: 1; max-height: 180px; }
.tool-images-grid .tool-image:only-child img { aspect-ratio: auto; max-height: 420px; }
.tool-images-grid .tool-image figcaption, .tool-images-files .tool-image figcaption { font-size: 11px; letter-spacing: 0; text-transform: none; overflow-wrap: anywhere; }

.tool-table { min-width: 100%; border-collapse: collapse; font: 13px/1.4 var(--pe-mono); }
.tool-table th, .tool-table td {
  padding: 8px 12px; border-bottom: 1px solid var(--theme-line); text-align: left; vertical-align: top; white-space: nowrap;
}
.tool-table th { position: sticky; top: 0; background: var(--theme-surface); font-weight: 500; }
.tool-pre { margin: 0; padding: 14px; font: 13px/1.5 var(--pe-mono); color: var(--theme-text); white-space: pre; }
.tool-page .tool-more-rows { padding: 10px 12px; font-size: 14px; }

/* How it works, FAQ, next step */
.tool-how, .tool-faq, .tool-more { padding-top: 72px; display: grid; gap: 24px; }
.tool-page .tool-how h2, .tool-page .tool-faq h2, .tool-page .tool-cta h2, .tool-page .tool-more h2 {
  font-size: clamp(28px, 3vw, 40px); line-height: 1.1; font-weight: 500; letter-spacing: -0.025em;
}
.tool-steps { list-style: none; padding: 0; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 24px 40px; }
.tool-steps li { display: grid; gap: 8px; align-content: start; }
.tool-steps span {
  display: grid; place-items: center; width: 40px; height: 40px; border: 1.5px solid var(--theme-text); border-radius: 50%; font-weight: 600;
}
.tool-page .tool-steps h3 { font-size: 21px; font-weight: 500; letter-spacing: -0.01em; }
.tool-steps p, .tool-explain dd { font-size: 16px; line-height: 1.55; }
.tool-explain { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.tool-explain > div { padding: 18px 20px; display: grid; gap: 6px; align-content: start; border: 1px solid var(--theme-line); border-radius: 14px; }
.tool-explain dt { font-size: 17px; font-weight: 600; }
.tool-explain dd { color: var(--theme-muted); }

.tool-faq-list { border-top: 1px solid var(--theme-line); }
.tool-faq-item { border-bottom: 1px solid var(--theme-line); }
.tool-faq-item summary {
  display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 18px 0; cursor: pointer; list-style: none;
}
.tool-faq-item summary::-webkit-details-marker { display: none; }
.tool-faq-item summary::after { content: "+"; font-size: 24px; line-height: 1; color: var(--theme-muted); }
.tool-faq-item[open] summary::after { content: "−"; }
.tool-page .tool-faq-item summary h3 { font-size: 19px; font-weight: 500; letter-spacing: -0.01em; }
.tool-faq-item p { max-width: 46em; padding: 0 0 20px; font-size: 16px; line-height: 1.6; }

.tool-cta { margin-top: 72px; padding: 40px; display: grid; gap: 14px; justify-items: start; background: var(--theme-surface); border-radius: 22px; }
.tool-cta > p { max-width: 44em; font-size: 17px; line-height: 1.6; }
.tool-cta-links { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 24px; margin-top: 6px; }
.tool-page .tool-cta-btn {
  display: inline-flex; align-items: center; min-height: 50px; padding: 0 24px; border-radius: 25px;
  background: var(--theme-control); color: var(--theme-on-control); font-weight: 600; text-decoration: none;
}
.tool-page .tool-cta-btn:hover { background: var(--theme-hover); }
.tool-cta-links a:not(.tool-cta-btn) { text-underline-offset: 4px; }

.tool-page .tool-support { display: flex; flex-wrap: wrap; gap: 4px 24px; font-size: 15px; color: var(--theme-text); }
.tool-page .tool-support[hidden] { display: none; }
.tool-support a { font-weight: 600; text-underline-offset: 4px; }
.tool-support-block {
  margin-bottom: 4px; padding: 10px 10px 10px 20px; display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 24px;
  border: 1px solid var(--theme-line); border-radius: 16px; background: var(--theme-surface);
}
.tool-page .tool-support-block h2 { font-size: 17px; font-weight: 500; letter-spacing: -0.01em; }
.tool-support-block p { margin-top: 2px; max-width: 44em; font-size: 15px; line-height: 1.5; }
.tool-page .tool-support-block .tool-btn-primary { color: var(--theme-on-control); }
.tool-support-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.tool-page .visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

.tool-source { margin-top: 48px; display: grid; gap: 12px; }
.tool-page .tool-source h2 { font-size: 22px; font-weight: 500; letter-spacing: -0.01em; }
.tool-source > p { max-width: 46em; font-size: 16px; line-height: 1.6; }
.tool-source ul { display: grid; gap: 6px; padding-left: 20px; font-size: 15px; line-height: 1.5; color: var(--theme-muted); }
.tool-source a { font-family: var(--pe-mono); font-size: 14px; text-underline-offset: 4px; }

.tool-cards { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.tool-hub .tool-cards { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.tool-page .tool-card {
  display: grid; gap: 8px; align-content: start; padding: 22px; border: 1px solid var(--theme-line); border-radius: 16px;
  background: var(--theme-surface); color: var(--theme-text); text-decoration: none;
}
.tool-page .tool-card:hover { border-color: var(--theme-text); }
.tool-card strong { font-size: 20px; font-weight: 600; }
.tool-page .tool-card h2, .tool-page .tool-card h3 { font-size: clamp(24px, 2.4vw, 30px); line-height: 1.15; font-weight: 500; letter-spacing: -0.02em; }
.tool-hub { padding-top: 16px; display: grid; gap: 16px; }
.tool-hub + .tool-hub { padding-top: 48px; }
.tool-page .tool-hub > h2 { font-family: var(--pe-mono); font-size: 12px; font-weight: 400; letter-spacing: 0.1em; text-transform: uppercase; color: var(--theme-muted); }
.tool-card span { font-size: 16px; line-height: 1.5; color: var(--theme-muted); }
.tool-card .tool-card-go { margin-top: 6px; font-weight: 600; color: var(--theme-text); }

/* The tools hub: a row of group links, then compact cards. */
.tool-jump { display: flex; flex-wrap: wrap; gap: 8px; margin: 4px 0 8px; }
.tool-page .tool-jump a {
  display: inline-flex; align-items: center; gap: 8px; min-height: 38px; padding: 0 14px; border: 1px solid var(--theme-line); border-radius: 19px;
  color: var(--theme-text); font: 14px var(--pe-sans); text-decoration: none; background: transparent;
}
.tool-page .tool-jump a:hover { border-color: var(--theme-text); }
.tool-jump a span { font: 12px var(--pe-mono); color: var(--theme-muted); }
.tool-hub .tool-cards-compact { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.tool-page .tool-cards-compact .tool-card { padding: 14px 16px; gap: 4px; border-radius: 12px; }
.tool-page .tool-cards-compact .tool-card h3 { font-size: 17px; line-height: 1.25; letter-spacing: -0.01em; font-weight: 600; }
.tool-cards-compact .tool-card span {
  font-size: 14px; line-height: 1.4; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
}
.tool-hub { padding-top: 8px; gap: 10px; }
.tool-hub + .tool-hub { padding-top: 24px; }

@media (max-width: 1100px) { .tool-hub .tool-cards-compact { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 900px) {
  .tool { grid-template-areas: "input" "options" "output"; }
  .tool, .tool-steps, .tool-explain, .tool-cards, .tool-hub .tool-cards { grid-template-columns: minmax(0, 1fr); }
  .tool-hub .tool-cards-compact { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 560px) {
  .tool-hero { padding-top: 36px; }
  .tool-panel { padding: 16px; }
  .tool-page textarea { min-height: 200px; }
  .tool-cta { padding: 28px; }
  .tool-actions .tool-btn { flex: 1 1 auto; }
  .tool-hub .tool-cards-compact { grid-template-columns: minmax(0, 1fr); }
  .tool-images:not(.tool-images-grid) { grid-template-columns: minmax(0, 1fr); }
}

/* 3D model viewer, shared by the casting and maker tools. */
.tool-preview:has(.tool-model-stage) { max-height: none; }
.tool-model-summary { margin: 0; padding: 12px 14px 0; font-size: 14px; line-height: 1.5; color: var(--theme-text); }
.tool-model-stage {
  position: relative; height: clamp(260px, 56vw, 420px); margin: 12px; border-radius: 8px; overflow: hidden; background: var(--theme-bg);
}
.tool-model-stage canvas { display: block; width: 100%; height: 100%; touch-action: none; }
.tool-model-stage canvas:focus-visible { outline: 2px solid var(--theme-focus); outline-offset: -2px; }
.tool-model-dimensions {
  position: absolute; left: 8px; bottom: 8px; max-width: calc(100% - 16px); margin: 0; padding: 3px 8px; border-radius: 6px;
  background: var(--theme-surface); color: var(--theme-text); font: 12px var(--pe-mono); pointer-events: none; overflow-wrap: anywhere;
}
.tool-model-legend {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 6px 14px; margin: 0; padding: 0 14px 14px;
  list-style: none; font-size: 14px; line-height: 1.4; color: var(--theme-text);
}
.tool-model-legend span {
  display: inline-block; width: 14px; height: 14px; margin-right: 8px; border: 1px solid var(--theme-line); border-radius: 3px; vertical-align: -2px;
}

/* A row of option buttons, such as the turn buttons on the sprue builder. */
.tool-button-row { display: flex; flex-wrap: wrap; gap: 8px; }
.tool-button-row .tool-btn { flex: 1 1 auto; }

/* Makers with longer forms keep controls beside the preview in keyboard-accessible sections. */
.tool-sectioned { grid-template-rows: min-content 1fr; }
.tool-sectioned .tool-options { gap: 0; }
.tool-sectioned .tool-options > .tool-panel-title { padding-bottom: 12px; }
.tool-option-section { min-width: 0; border-top: 1px solid var(--theme-line); }
.tool-option-section > summary {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 50px;
  cursor: pointer; list-style: none; font: 600 15px var(--pe-sans); color: var(--theme-text);
}
.tool-option-section > summary::-webkit-details-marker { display: none; }
.tool-option-section > summary::after { content: '+'; font-size: 22px; font-weight: 400; color: var(--theme-muted); }
.tool-option-section[open] > summary::after { content: '−'; }
.tool-option-section > summary:focus-visible { outline: 2px solid var(--theme-focus); outline-offset: 2px; border-radius: 4px; }
.tool-option-fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: start; gap: 12px; padding: 2px 0 18px; }
.tool-option-fields > .tool-check, .tool-option-fields > .tool-range,
.tool-option-fields > .tool-group, .tool-option-fields > :has(select),
.tool-option-fields > :has(textarea), .tool-option-fields > :has(input[type='file']),
.tool-option-fields > :has(.tool-button-row), .tool-option-fields > :only-child,
.tool-option-fields > [data-field='price'], .tool-option-fields > [data-field='slurryDensity'] { grid-column: 1 / -1; }
.tool[data-tool='cast-sign-pattern-maker'] .tool-option-fields > [data-field='units'] { grid-column: auto; }
.tool-page .tool-option-fields textarea { min-height: 112px; padding: 12px; font: 15px/1.5 var(--pe-sans); }
.tool-option-fields .tool-field > label { font-size: 14px; }
@media (min-width: 901px) {
  /* Pinned under the top bar, ending above the contact button in the bottom corner. */
  .tool-sectioned .tool-options {
    position: sticky; top: calc(var(--pe-topbar-h) + 16px); max-height: calc(100dvh - var(--pe-topbar-h) - 104px); overflow-y: auto;
    overscroll-behavior: contain; scrollbar-gutter: stable; scroll-padding: 12px;
  }
}
@media (max-width: 900px) { .tool-sectioned { grid-template-rows: auto; } }

/* A searchable collection, with a small tool switcher on every tool page. */
.tool-directory-hero { padding-bottom: 28px; }
.tool-page .tool-directory-hero h1 { max-width: 20em; }
.tool-directory-toolbar {
  position: sticky; top: var(--pe-topbar-h); z-index: 5; padding: 16px 0 12px; background: var(--theme-bg);
  border-bottom: 1px solid var(--theme-line);
}
.tool-directory-search { display: flex; align-items: center; gap: 12px; padding: 6px 16px; border: 1px solid var(--theme-line); border-radius: 14px; background: var(--theme-surface); }
.tool-directory-search:focus-within { border-color: var(--theme-focus); box-shadow: 0 0 0 1px var(--theme-focus); }
.tool-directory-search > svg { flex-shrink: 0; color: var(--theme-muted); }
.tool-directory-search input, .tool-switch input {
  min-width: 0; width: 100%; min-height: 44px; color: var(--theme-text); font: 16px var(--pe-sans);
  border: 0; background: transparent; outline: none;
}
.tool-directory-search input::-webkit-search-cancel-button, .tool-switch input::-webkit-search-cancel-button { display: none; }
.tool-directory-search input::placeholder, .tool-switch input::placeholder { color: var(--theme-muted); opacity: 1; }
.tool-directory-search button { flex-shrink: 0; min-height: 44px; border: 0; padding: 0 8px; color: var(--theme-text); background: transparent; font: 14px var(--pe-sans); cursor: pointer; text-decoration: underline; text-underline-offset: 4px; }
.tool-directory .tool-jump { margin: 12px 0 0; }
.tool-directory .tool-jump a { min-height: 44px; }
.tool-directory .tool-jump a[aria-current] { background: var(--theme-control); color: var(--theme-on-control); border-color: var(--theme-control); }
.tool-directory .tool-jump a[aria-current] span { color: inherit; }
.tool-library { padding: 20px 0 32px; }
/* The category links target the group headings. They land below the pinned search and category bar, whose height
   directory.js measures (--tool-toolbar-h); without JavaScript the bar holds only the category links. */
.tool-directory { --tool-toolbar-h: 86px; }
.tool-library, .tool-hub h2[id] { scroll-margin-top: calc(var(--tool-toolbar-h) + 12px); }
.tool-directory-count { font: 13px var(--pe-mono); margin-bottom: 24px !important; }
.tool-directory .tool-hub { gap: 18px; }
.tool-directory .tool-hub + .tool-hub { padding-top: 36px; }
.tool-group-heading { display: flex; align-items: start; justify-content: space-between; gap: 16px; }
.tool-page .tool-group-heading h2 { font: 500 clamp(24px, 2.5vw, 30px)/1.2 var(--pe-sans); letter-spacing: -0.02em; }
.tool-group-heading p { margin-top: 6px !important; font-size: 15px; line-height: 1.5; }
.tool-group-heading > span { flex-shrink: 0; padding-top: 5px; font: 12px var(--pe-mono); color: var(--theme-muted); }
.tool-directory-cards .tool-card { padding: 20px; gap: 12px; border-radius: 14px; transition: border-color .15s; }
.tool-directory-cards .tool-card:hover { background: var(--theme-bg); }
.tool-page .tool-directory-cards .tool-card h3 { font: 600 19px/1.25 var(--pe-sans); letter-spacing: -0.01em; }
.tool-card-top { display: flex; align-items: center; justify-content: space-between; }
.tool-card .tool-card-icon { display: inline-flex; padding: 9px; border-radius: 10px; border: 1px solid var(--theme-line); color: var(--theme-text); }
.tool-card .tool-card-arrow { font-size: 22px; color: var(--theme-text); }
.tool-card .tool-card-description { font-size: 14px; line-height: 1.5; }
.tool-directory-empty { display: grid; justify-items: start; gap: 14px; padding: 36px; border: 1px dashed var(--theme-line); border-radius: 14px; }
.tool-context { display: flex; align-items: start; justify-content: space-between; gap: 16px; }
.tool-context .breadcrumb { min-width: 0; }
.tool-switch { position: relative; flex-shrink: 0; z-index: 35; font-family: var(--pe-sans); }
.tool-switch > summary { display: flex; align-items: center; gap: 16px; min-height: 44px; padding: 0 16px; border: 1px solid var(--theme-line); border-radius: 22px; font-size: 14px; cursor: pointer; list-style: none; }
.tool-switch > summary::-webkit-details-marker { display: none; }
.tool-switch[open] > summary { background: var(--theme-surface); }
.tool-switch-panel { position: absolute; right: 0; top: calc(100% + 8px); display: flex; flex-direction: column; width: 380px; max-height: min(640px, calc(100dvh - var(--pe-topbar-h) - 200px)); overflow: hidden; padding: 16px; border: 1px solid var(--theme-line); border-radius: 14px; background: var(--theme-bg); box-shadow: 0 12px 40px #0002; }
/* The panel opens below the hero's first row and ends above the contact button. */
@media (min-width: 901px) { .tool-switch-panel { max-height: min(640px, calc(100dvh - var(--pe-topbar-h) - 164px)); } }
.tool-switch-panel nav { min-height: 0; overflow-y: auto; overscroll-behavior: contain; }
.tool-switch-panel > input, .tool-switch-panel > a, .tool-switch-panel > p { flex-shrink: 0; }
.tool-switch input { border: 1px solid var(--theme-line); border-radius: 8px; background: var(--theme-surface); padding: 0 12px; margin-bottom: 8px; }
.tool-switch input:focus-visible { outline: 2px solid var(--theme-focus); outline-offset: 2px; }
.tool-switch-group > p { font: 11px var(--pe-mono); text-transform: uppercase; letter-spacing: .06em; margin: 12px 8px 6px !important; }
.tool-switch-group a { display: flex; justify-content: space-between; align-items: center; gap: 12px; min-height: 44px; padding: 8px; border-radius: 6px; text-decoration: none; font-size: 14px; line-height: 1.3; }
.tool-switch-group a:hover, .tool-switch-group a[aria-current='page'] { background: var(--theme-surface); }
.tool-switch-group a span { font: 10px var(--pe-mono); color: var(--theme-muted); }
.tool-page .tool-switch-more { margin: 8px 8px 0; font: 12px var(--pe-mono); color: var(--theme-muted); }
/* With a mouse on a wide screen, the groups flow into two columns, each group kept whole under its heading, so every
   tool fits without scrolling on windows about 800px tall or taller. */
@media (min-width: 1100px) and (pointer: fine) {
  .tool-switch-panel { width: 640px; }
  .tool-switch-groups { columns: 2; column-gap: 24px; }
  .tool-switch-group { break-inside: avoid; }
  .tool-switch-group > p { margin: 10px 8px 4px !important; }
  .tool-switch-group:first-child > p { margin-top: 0 !important; }
  .tool-switch-group a { min-height: 28px; padding: 4px 8px; }
}
.tool-switch-all, .tool-browse-all { display: block; padding-top: 16px; font: 600 14px var(--pe-sans); text-underline-offset: 4px; }
.tool-switch-all { border-top: 1px solid var(--theme-line); margin-top: 12px; }
.tool-directory :is(a, button):focus-visible, .tool-switch :is(a, summary):focus-visible { outline: 2px solid var(--theme-focus); outline-offset: 3px; }
@media (min-width: 1100px) {
  .tool-directory { --tool-toolbar-h: 70px; }
  .tool-directory-toolbar { display: flex; align-items: center; gap: 16px; padding: 12px 0; }
  .tool-directory-search { flex: 1 1 280px; min-width: 0; }
  .tool-directory .tool-jump { flex: 0 1 auto; flex-wrap: nowrap; margin: 0; }
  .tool-directory .tool-directory-cards { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
  .tool-page .tool-directory-cards .tool-card {
    grid-template-columns: auto minmax(0, 1fr) auto; grid-template-areas: "icon title arrow" "text text text";
    align-items: center; gap: 10px 12px; padding: 16px 18px;
  }
  .tool-directory-cards .tool-card-top { display: contents; }
  .tool-directory-cards .tool-card .tool-card-icon { grid-area: icon; padding: 7px; }
  .tool-directory-cards .tool-card .tool-card-arrow { grid-area: arrow; font-size: 18px; }
  .tool-page .tool-directory-cards .tool-card h3 { grid-area: title; font-size: 17px; }
  .tool-directory-cards .tool-card .tool-card-description { grid-area: text; align-self: start; }
}
@media (max-width: 900px) { .tool-directory .tool-directory-cards { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 560px) {
  .tool-directory-search { gap: 8px; padding: 4px 10px; }
  .tool-directory-search input { font-size: 16px; }
  .tool-directory-search button { font-size: 12px; }
  /* The pinned bar stays short under the phone's taller top bar: the category links scroll sideways in one row,
     with a shadow at the edge that has more. */
  .tool-directory-toolbar { padding-top: 10px; }
  .tool-directory .tool-jump {
    flex-wrap: nowrap; overflow-x: auto; overscroll-behavior-x: contain; scrollbar-width: none;
    margin: 8px calc(var(--pe-gutter) * -1) 0; padding: 0 var(--pe-gutter) 10px; scroll-padding-inline: var(--pe-gutter);
    background:
      linear-gradient(to right, var(--theme-bg) 30%, transparent) left center / 36px 100% no-repeat local,
      linear-gradient(to left, var(--theme-bg) 30%, transparent) right center / 36px 100% no-repeat local,
      radial-gradient(farthest-side at 0 50%, var(--theme-shadow), transparent) left center / 12px 100% no-repeat scroll,
      radial-gradient(farthest-side at 100% 50%, var(--theme-shadow), transparent) right center / 12px 100% no-repeat scroll,
      var(--theme-bg);
  }
  .tool-directory .tool-jump::-webkit-scrollbar { display: none; }
  .tool-directory .tool-jump a { flex-shrink: 0; }
  .tool-directory .tool-directory-cards { grid-template-columns: minmax(0, 1fr); }
  .tool-directory-cards .tool-card { padding: 16px; }
  .tool-group-heading > span { display: none; }
  .tool-context { flex-direction: column; gap: 12px; }
  .tool-switch { width: 100%; }
  .tool-switch > summary { justify-content: space-between; }
  .tool-switch-panel { width: 100%; }
  .tool-directory-empty { padding: 24px; }
}
