/* =========================================================
   Calculators — water jet calculators (page-templates/toolbox.php)
   ========================================================= */

.page-hero--calc { padding-bottom: 28px; }
.page-hero--calc .page-hero__sub { color: var(--ink-2); }
.tbx-section { padding-top: clamp(20px, 3vw, 32px); }
.tbx { display: grid; gap: 16px; align-items: start; }
.tbx-nav, .tbx-panels, .tbx-tool { min-width: 0; }
@media (min-width: 900px) { .tbx { grid-template-columns: 220px minmax(0, 1fr); gap: 24px; } }

/* Calculator list */
.tbx-nav ul { list-style: none; }
.tbx-nav__link { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 8px; font-weight: 600; font-size: .92rem; color: var(--ink-2); border: 1px solid transparent; transition: background .15s ease, border-color .15s ease, color .15s ease; white-space: nowrap; }
.tbx-nav__icon { flex: none; width: 32px; height: 32px; border-radius: 8px; display: grid; place-items: center; background: #fff; border: 1px solid var(--line); color: var(--ink-2); }
.tbx-nav__link:hover { background: #fff; color: var(--ink); }
.tbx-nav__link.is-active { background: #fff; border-color: var(--line); color: var(--ink); box-shadow: var(--shadow); }
.tbx-nav__link.is-active .tbx-nav__icon { background: var(--brand); border-color: var(--brand); color: var(--ink); }
@media (min-width: 900px) {
	.tbx-nav { position: sticky; top: 96px; }
	.tbx-nav ul { display: grid; gap: 3px; }
}
@media (max-width: 899px) {
	.tbx-nav { margin: 0 calc(var(--gutter) * -1); position: relative; }
	.tbx-nav::after { content: ""; position: absolute; top: 0; right: 0; bottom: 6px; width: 40px; background: linear-gradient(90deg, rgba(244,245,247,0), var(--bg-muted)); pointer-events: none; }
	.tbx-nav ul { display: flex; gap: 8px; overflow-x: auto; max-width: 100vw; padding: 2px var(--gutter) 6px; scroll-snap-type: x proximity; scrollbar-width: none; }
	.tbx-nav ul::-webkit-scrollbar { display: none; }
	.tbx-nav li { flex: none; scroll-snap-align: start; }
	.tbx-nav__link { padding: 5px 12px 5px 5px; gap: 8px; background: #fff; border-color: var(--line); font-size: .88rem; }
	.tbx-nav__icon { width: 28px; height: 28px; border: 0; background: var(--bg-muted); }
	.tbx-nav__link.is-active { border-color: var(--brand-dark); box-shadow: none; }
}

/* Panel */
.tbx-tool { background: #fff; border: 1px solid var(--line); border-radius: var(--radius-lg); padding: clamp(18px, 3vw, 28px); box-shadow: var(--shadow); }
.tbx-tool[hidden], .tbx-products[hidden], .tbx-nozzles[hidden], .tbx-result__note[hidden], .tbx-result__empty[hidden], .tbx-result__out[hidden], .tbx-result__error[hidden], .tbx-conv__list[hidden] { display: none; }
.tbx-tool__head { display: flex; gap: 14px; align-items: flex-start; margin-bottom: 20px; }
.tbx-tool__icon { flex: none; width: 48px; height: 48px; border-radius: 12px; display: grid; place-items: center; background: var(--brand-soft); color: var(--ink); }
.tbx-tool__head h2 { font-size: clamp(1.3rem, 2.2vw, 1.6rem); margin: 2px 0 4px; }
.tbx-tool__head p { margin: 0; color: var(--muted); font-size: .95rem; }

.tbx-tool__body { display: grid; gap: 18px; }
/* Inputs on top, result card full width underneath. */

/* Fields */
.tbx-fields { display: grid; gap: 12px; }
@media (min-width: 560px) { .tbx-fields { grid-template-columns: 1fr 1fr; } }
@media (min-width: 900px) { .tbx-fields { grid-template-columns: repeat(3, 1fr); } }
.tbx-field { display: block; }
.tbx-field__label { display: block; font-size: .84rem; font-weight: 700; color: var(--ink); margin-bottom: 5px; }
.tbx-field__box { display: flex; align-items: stretch; border: 1px solid #CBD0D6; border-radius: 8px; background: #fff; overflow: hidden; transition: border-color .15s ease, box-shadow .15s ease; }
.tbx-field__box:focus-within { border-color: var(--brand-dark); box-shadow: 0 0 0 3px rgba(251, 199, 7, .3); }
.tbx-field__box input, .tbx-field__box select { flex: 1; min-width: 0; border: 0; padding: 11px 13px; font: inherit; font-size: 1.05rem; font-weight: 600; color: var(--ink); background: transparent; outline: none; font-variant-numeric: tabular-nums; }
.tbx-field__box input::placeholder { color: #A7ADB5; font-weight: 500; font-size: .95rem; }
.tbx-field__box input::-webkit-outer-spin-button, .tbx-field__box input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.tbx-field__box input[type="number"] { -moz-appearance: textfield; }
.tbx-field__unit { display: flex; align-items: center; padding: 0 12px; background: var(--bg-muted); border-left: 1px solid var(--line); color: var(--muted); font-size: .86rem; font-weight: 600; white-space: nowrap; }
.tbx-field__box--select select { cursor: pointer; }
.tbx-field__box .tbx-field__unit--select { flex: none; width: auto; border: 0; border-left: 1px solid var(--line); border-radius: 0; font: inherit; font-size: .86rem; font-weight: 600; color: var(--ink-2); padding: 0 12px; background: var(--bg-muted); }
.tbx-field__box .tbx-field__unit--select.is-mirrored { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
/* Styled unit dropdown (mirrors the hidden select) */
.tbx-field__box { position: relative; overflow: visible; }
.tbx-field__box input { border-radius: 8px 0 0 8px; }
.tbx-unit { position: relative; display: flex; align-self: stretch; }
.tbx-unit__btn { display: inline-flex; align-items: center; gap: 6px; height: 100%; padding: 0 12px 0 14px; border: 0; border-left: 1px solid var(--line); border-radius: 0 8px 8px 0; background: var(--bg-muted); color: var(--ink-2); font: inherit; font-size: .86rem; font-weight: 700; white-space: nowrap; cursor: pointer; transition: background .15s ease, color .15s ease; }
.tbx-unit__btn svg { color: var(--muted); transition: transform .15s ease; }
.tbx-unit__btn:hover, .tbx-unit.is-open .tbx-unit__btn { background: var(--brand-soft); color: var(--ink); }
.tbx-unit.is-open .tbx-unit__btn svg { transform: rotate(180deg); color: var(--ink); }
.tbx-unit__btn:focus-visible { outline: none; box-shadow: inset 0 0 0 2px var(--brand); }
.tbx-unit__menu { position: absolute; top: calc(100% + 6px); right: 0; min-width: 100%; margin: 0; padding: 6px; list-style: none; background: #fff; border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--shadow-lg); z-index: 30; opacity: 0; visibility: hidden; transform: translateY(-4px); transition: opacity .12s ease, transform .12s ease, visibility .12s; }
.tbx-unit.is-open .tbx-unit__menu { opacity: 1; visibility: visible; transform: none; }
.tbx-unit__menu li { padding: 7px 12px; border-radius: 6px; font-size: .88rem; font-weight: 600; color: var(--ink-2); white-space: nowrap; cursor: pointer; }
.tbx-unit__menu li:hover { background: var(--bg-muted); color: var(--ink); }
.tbx-unit__menu li[aria-selected="true"] { background: var(--brand-soft); color: var(--ink); }
.tbx-form__actions { display: flex; align-items: center; gap: 16px; margin-top: 14px; }
.tbx-example { background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: 7px 12px; font-weight: 700; font-size: .86rem; color: var(--ink); cursor: pointer; transition: border-color .15s ease, background .15s ease; }
.tbx-example:hover { border-color: var(--brand-dark); background: var(--brand-soft); }
.tbx-reset { background: none; border: 0; padding: 4px 0; color: var(--muted); font-weight: 600; font-size: .88rem; cursor: pointer; text-decoration: underline; text-underline-offset: 3px; }
.tbx-reset:hover { color: var(--ink); }

/* Result */
.tbx-result { position: relative; border-radius: 12px; background: var(--bg-muted); border: 1px solid var(--line); padding: 16px 20px 18px; display: flex; flex-direction: column; transition: background .2s ease, border-color .2s ease; }
.tbx-result__out { display: grid; gap: 4px 32px; }
@media (min-width: 900px) {
	/* Big number on the left, secondary values as tiles beside it; wide extras (nozzle table) underneath. */
	.tbx-result__out { grid-template-columns: auto minmax(0, 1fr); grid-template-areas: "main rows" "extra extra" "note note" "aside aside" "actions actions"; align-items: stretch; gap: 0 28px; }
	/* With the nozzle table shown, the engineer panel moves to the right of the table. */
	.tbx-result__out:has(.tbx-nozzles:not([hidden])) { grid-template-columns: auto minmax(0, 1fr) 280px; grid-template-areas: "main rows rows" "extra extra aside" "note note note" "actions actions actions"; }
	/* Same top edge and height as the nozzle table (title line = 1.8em + 8px), text centred vertically. */
	.tbx-result__out:has(.tbx-nozzles:not([hidden])) .tbx-result__aside { flex-direction: column; flex-wrap: nowrap; align-items: stretch; align-self: stretch; justify-content: center; gap: 10px; margin-top: calc(18px + .76rem * 1.8 + 4px); padding: 20px 22px; }
	.tbx-result__out:has(.tbx-nozzles:not([hidden])) .tbx-result__aside strong, .tbx-result__out:has(.tbx-nozzles:not([hidden])) .tbx-result__aside p { flex: 0 0 auto; }
	.tbx-result__out:has(.tbx-nozzles:not([hidden])) .tbx-result__aside p { flex: 0 0 auto; }
	.tbx-result__out:has(.tbx-nozzles:not([hidden])) .tbx-result__aside .btn { align-self: flex-start; margin: 8px 0 0; }
	.tbx-result__main { grid-area: main; justify-content: center; padding-right: 28px; border-right: 1px solid var(--line); }
	.tbx-result__out .tbx-result__rows { grid-area: rows; margin: 0; border-top: 0; display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); gap: 10px; align-self: stretch; }
	.tbx-result__out .tbx-result__rows > div { flex-direction: column; justify-content: center; gap: 4px; padding: 12px 14px; border: 0; border-radius: 10px; background: var(--bg-muted); }
	.tbx-result__out .tbx-result__rows dt { font-size: .8rem; line-height: 1.3; color: var(--muted); }
	.tbx-result__out .tbx-result__rows dd { text-align: left; font-size: 1.3rem; line-height: 1.15; }
	.tbx-nozzles { grid-area: extra; margin-top: 18px; }
	.tbx-result__note { grid-area: note; margin-top: 14px; }
	.tbx-result__actions { grid-area: actions; margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--line); }
	.tbx-result__empty { display: flex; align-items: baseline; justify-content: flex-start; gap: 18px; text-align: left; padding: 4px 0; }
	.tbx-result__ghost { margin: 0; }
	.tbx-result__out .tbx-result__aside { grid-area: aside; margin-top: 18px; align-self: stretch; flex-direction: row; flex-wrap: wrap; align-items: center; gap: 4px 20px; }
	.tbx-result__out .tbx-result__aside strong { flex: 1 1 100%; }
	.tbx-result__out .tbx-result__aside p { flex: 1 1 320px; }
	.tbx-result__out .tbx-result__aside .btn { margin-top: 0; align-self: center; margin-left: auto; }
	.tbx-result__actions { border-top: 0; padding-top: 0; align-self: end; }
}
.tbx-result.has-result { background: #fff; border-color: var(--brand); box-shadow: 0 0 0 3px rgba(251, 199, 7, .18); }
.tbx-result.is-flash { background: var(--brand-soft); }
.tbx-result__title { font-size: .76rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); margin: 0 0 8px; }
.tbx-result__empty { margin: auto 0; text-align: center; padding: 12px 0 8px; }
.tbx-result__ghost { display: block; font-size: 2.6rem; font-weight: 800; color: #D5D9DE; line-height: 1.1; letter-spacing: -.02em; margin-bottom: 8px; }
.tbx-result__empty p { margin: 0; color: var(--muted); font-size: .92rem; }
.tbx-result__error { margin: auto 0; color: #B42318; font-weight: 600; font-size: .92rem; }
.tbx-result__main { display: flex; flex-direction: column; gap: 2px; }
.tbx-result__label { font-weight: 600; color: var(--ink-2); font-size: .95rem; }
.tbx-result__value { font-size: clamp(2.3rem, 5vw, 3rem); font-weight: 800; color: var(--ink); line-height: 1.1; font-variant-numeric: tabular-nums; letter-spacing: -.02em; }
.tbx-result__value small { font-size: 1.05rem; font-weight: 700; color: var(--muted); letter-spacing: 0; }
.tbx-result__rows { margin: 14px 0 0; border-top: 1px solid var(--line); }
.tbx-result__rows > div:first-child { border-top: 0; }
.tbx-result__rows > div { display: flex; justify-content: space-between; gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.tbx-result__rows > div[hidden] { display: none; }
.tbx-result__rows dt { color: var(--muted); font-size: .9rem; }
.tbx-result__rows dd { margin: 0; font-weight: 700; color: var(--ink); text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.tbx-result__note { margin: 12px 0 0; font-size: .88rem; color: var(--muted); line-height: 1.5; }
.tbx-result__note.is-warn { color: #9A3412; background: #FFF4EC; border: 1px solid #FED7AA; border-radius: 8px; padding: 8px 10px; }
.tbx-result__actions { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 16px; margin-top: 16px; }
.tbx-copy { background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: 7px 12px; font-weight: 700; font-size: .86rem; color: var(--ink); cursor: pointer; transition: border-color .15s ease; }
.tbx-copy:hover { border-color: var(--ink-2); }
.tbx-copy.is-done { border-color: #1a7f37; color: #1a7f37; }
.tbx-products { display: inline-flex; align-items: center; gap: 6px; font-weight: 700; font-size: .88rem; color: var(--ink); text-decoration: underline; text-underline-offset: 3px; text-decoration-color: var(--brand); }
.tbx-products:hover { color: var(--brand-dark); }
.tbx-products .icon { color: var(--brand-dark); }

/* Nozzle neighbours */
.tbx-nozzles { margin-top: 14px; }
.tbx-nozzles__title { margin: 0 0 8px; font-size: .76rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
html[lang="zh-CN"] .tbx-nozzles__title { letter-spacing: 0; text-transform: none; }
.tbx-nozzles table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: .88rem; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.tbx-nozzles th { text-align: left; font-weight: 600; color: var(--muted); font-size: .8rem; padding: 7px 12px; background: var(--bg-muted); border-bottom: 1px solid var(--line); }
.tbx-nozzles td { padding: 8px 12px; border-bottom: 1px solid var(--line); font-variant-numeric: tabular-nums; }
.tbx-nozzles tr:last-child td { border-bottom: 0; }
.tbx-nozzles th:first-child, .tbx-nozzles td:first-child { width: 22%; font-weight: 600; }
.tbx-nozzles th:last-child, .tbx-nozzles td:last-child { text-align: right; }
.tbx-nozzles tr.is-best td { background: var(--brand-soft); font-weight: 700; }
.tbx-nozzles tr.is-best td:first-child { box-shadow: inset 3px 0 0 var(--brand); }

/* Formula */
.tbx-formula { margin-top: 18px; border-top: 1px solid var(--line); padding-top: 12px; }
.tbx-formula summary { cursor: pointer; font-weight: 600; font-size: .9rem; color: var(--ink-2); }
.tbx-formula p { margin: 10px 0 0; color: var(--muted); font-size: .9rem; line-height: 1.7; }

/* Unit converter */
.tbx-conv__tabs { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }
.tbx-chip { border: 1px solid var(--line); background: #fff; border-radius: 999px; padding: 6px 15px; font-weight: 600; font-size: .9rem; color: var(--ink-2); cursor: pointer; }
.tbx-chip:hover { border-color: var(--ink-2); }
.tbx-chip.is-active { background: var(--brand); border-color: var(--brand); color: var(--ink); }
.tbx-conv__row { display: grid; gap: 12px; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); margin-bottom: 16px; }
@media (min-width: 700px) { .tbx-conv__row { max-width: 520px; } }
.tbx-result--conv { min-height: 0; display: block; }
.tbx-result--conv .tbx-result__empty { text-align: left; padding: 0; }
.tbx-conv__list { list-style: none; display: grid; gap: 1px; background: var(--line); border-radius: 8px; overflow: hidden; }
@media (min-width: 560px) { .tbx-conv__list { grid-template-columns: 1fr 1fr; } }
.tbx-conv__list li { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; background: #fff; padding: 11px 16px; }
.tbx-conv__val { font-size: 1.2rem; font-weight: 800; color: var(--ink); font-variant-numeric: tabular-nums; word-break: break-all; }
.tbx-conv__unit { color: var(--muted); font-weight: 600; white-space: nowrap; }

/* Help band */
.tbx-result__aside { margin-top: 18px; display: flex; flex-direction: column; gap: 8px; padding: 18px; border-radius: 10px; background: var(--bg-muted); border: 1px solid var(--line); }
.tbx-result__aside strong { color: var(--ink); font-size: .95rem; line-height: 1.4; }
.tbx-result__aside p { margin: 0; color: var(--muted); font-size: .88rem; line-height: 1.55; flex: 1; }
.tbx-result__aside .btn { align-self: flex-start; margin-top: 6px; }
.tbx-wechat { margin: 14px 0 0; color: var(--muted); font-size: .85rem; }

/* Mobile */
@media (max-width: 899px) {
	.page-hero--calc h1 { font-size: 1.7rem; }
	.page-hero--calc .page-hero__sub { font-size: .95rem; }
	.tbx-tool__head { gap: 12px; margin-bottom: 16px; }
	.tbx-tool__icon { width: 40px; height: 40px; }
	.tbx-result { padding: 16px; }
	.tbx-result__empty { padding: 4px 0; }
	.tbx-result__ghost { font-size: 2rem; }
}
