/* ===== ศูนย์เครื่องมือคำนวณสุขภาพ: CSS แยกไฟล์ · build คัดลอกเข้า assets/ เฉพาะเมื่อเปิดเครื่องมือ (--tools) ===== */
.ht-page .ht-head h1, .ht-tool-head h1 { font-size: clamp(22px, 3vw, 30px); line-height: 1.35; margin: 0 0 10px; color: var(--primary); }
.ht-lead { font-size: 17px; color: var(--ink-2); margin: 0 0 12px; }
.ht-disclaimer { margin: 10px 0 0; padding: 10px 14px; border-left: 4px solid var(--honey); background: var(--honey-bg); border-radius: 6px; font-size: 14px; line-height: 1.6; color: var(--honey-ink); }
.ht-privacy { font-size: 13px; color: var(--ink-2); margin: 14px 0 0; }
.ht-h2 { font-size: 20px; margin: 28px 0 12px; color: var(--primary); }
/* การ์ดเครื่องมือ: ภาพ + ข้อความ HTML ซ้อน (ไม่ฝังข้อความในภาพ) */
.ht-grid { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.ht-card-link { display: block; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; text-decoration: none; color: var(--ink); height: 100%; transition: transform .15s ease, box-shadow .15s ease; }
.ht-card-link:hover { transform: translateY(-2px); box-shadow: 0 10px 24px rgba(19, 48, 42, .12); }
.ht-card-link:focus-visible { outline: 3px solid #7CC24F; outline-offset: 2px; }
.ht-card-img { display: block; aspect-ratio: 4 / 3; background: var(--mist); }
.ht-card-img img { width: 100%; height: 100%; object-fit: cover; }
.ht-card-body { display: block; padding: 12px 14px 14px; }
.ht-card-h { display: block; font-size: 18px; font-weight: 800; color: var(--primary); line-height: 1.35; }
.ht-card-sub { display: block; font-size: 14px; color: var(--ink-2); margin-top: 2px; }
.ht-card-btn { display: inline-block; margin-top: 10px; font-size: 14px; font-weight: 700; color: var(--green-dark); }
.ht-soon { margin-top: 28px; padding: 14px 16px; background: var(--surface); border: 1px dashed var(--line); border-radius: 10px; }
.ht-soon .ht-h2 { margin-top: 0; font-size: 17px; }
.ht-soon-p { margin: 0 0 8px; font-size: 14px; color: var(--ink-2); }
.ht-soon-list { margin: 0; padding: 0; list-style: none; display: flex; flex-wrap: wrap; gap: 6px 8px; }
.ht-soon-list li { font-size: 13px; color: var(--ink-2); background: var(--paper); border: 1px solid var(--line); border-radius: 999px; padding: 3px 10px; }
.ht-line { margin: 24px 0 8px; padding: 16px; background: #F0FDF4; border: 1px solid #BBE5C8; border-radius: 12px; text-align: center; }
.ht-line p { margin: 0 0 6px; font-size: 15px; }
.ht-line .ht-line-h { font-weight: 800; color: var(--primary); font-size: 17px; }
.ht-line .btn-line { margin-top: 6px; }
/* หน้าเครื่องคำนวณ */
.ht-hero { margin: 0 0 12px; }
.ht-hero img { width: 100%; max-width: 520px; height: auto; border-radius: 12px; border: 1px solid var(--line); }
.ht-form { margin: 16px 0 0; padding: 16px 18px 18px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; }
.ht-grid-form { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 22px; }
.ht-field { display: flex; flex-direction: column; gap: 6px; min-width: 0; margin: 0; padding: 0; border: 0; }
.ht-field.ht-wide, .ht-units, .ht-scheme { grid-column: 1 / -1; }
.ht-field label, .ht-field legend { font-weight: 700; font-size: 15px; color: var(--ink); padding: 0; }
.ht-field b { color: #c2410c; font-weight: 700; }
.ht-field input[type=text], .ht-field select { width: 100%; min-height: 46px; padding: 8px 12px; font: inherit; font-size: 17px; color: var(--ink); background: #fff; border: 1px solid #C9D6CF; border-radius: 8px; }
.ht-field input[type=text]:focus-visible, .ht-field select:focus-visible, .ht-field input[type=radio]:focus-visible { outline: 3px solid #7CC24F; outline-offset: 1px; }
.ht-field [aria-invalid="true"] { border-color: #DC2626; }
.ht-input { position: relative; }
.ht-input input { padding-right: 64px; }
.ht-unit { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); font-size: 14px; color: var(--ink-2); pointer-events: none; }
.ht-units label, .ht-sex label, .ht-scheme label { display: inline-flex; align-items: center; gap: 8px; min-height: 44px; padding: 4px 14px 4px 10px; margin: 0 8px 0 0; border: 1px solid #C9D6CF; border-radius: 999px; font-weight: 500; font-size: 15px; cursor: pointer; background: #fff; }
.ht-units label:has(input:checked), .ht-sex label:has(input:checked), .ht-scheme label:has(input:checked) { border-color: var(--primary); background: var(--mist); font-weight: 700; }
.ht-units input, .ht-sex input, .ht-scheme input { margin: 0; accent-color: var(--primary); width: 18px; height: 18px; }
.ht-scheme label { display: flex; margin: 0 0 6px; border-radius: 10px; }
.ht-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 16px; }
.ht-submit { min-width: 180px; justify-content: center; }
.ht-errsum { margin: 12px 0 0; padding: 10px 14px; border: 1px solid #FCA5A5; background: #FEF2F2; color: #991B1B; border-radius: 10px; font-weight: 700; font-size: 15px; }
.ht-errsum[hidden] { display: none; }
.ht-result { margin: 18px 0 8px; padding: 18px 20px; background: #F0FDF4; border: 2px solid #86EFAC; border-radius: 14px; scroll-margin-top: 90px; }
.ht-result:focus { outline: none; }
.ht-result.is-stop { background: var(--honey-bg); border-color: var(--honey); }
.ht-r-h { margin: 0 0 10px; font-size: 18px; color: var(--primary); }
.ht-r { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 4px 16px; padding: 8px 0; border-top: 1px solid rgba(29, 92, 77, .15); }
.ht-r-l { font-size: 15px; color: var(--ink-2); flex: 1 1 220px; }
.ht-r-v { font-size: 17px; font-weight: 700; color: var(--ink); text-align: right; }
.ht-r-v small { font-weight: 500; color: var(--ink-2); }
.ht-r-big { border-top: 0; padding-top: 0; flex-direction: column; align-items: flex-start; gap: 2px; }
.ht-r-big .ht-r-l { flex: 0 0 auto; }
.ht-r-big .ht-r-v { text-align: left; }
.ht-r-big strong { font-size: clamp(36px, 7vw, 52px); line-height: 1.1; color: var(--primary); }
.ht-r-note { margin: 8px 0 0; font-size: 14px; line-height: 1.6; color: var(--ink-2); }
.ht-r-sub { margin: 12px 0 4px; font-size: 15px; font-weight: 700; }
.ht-r-list { margin: 0; padding-left: 20px; font-size: 14px; color: var(--ink-2); line-height: 1.6; }
.ht-r-next { margin: 12px 0 0; font-weight: 700; }
.ht-again { margin-top: 14px; }
.ht-how summary .acc-h { font-size: 18px; }
.ht-rel { margin: 0 0 8px; padding-left: 20px; }
.ht-rel li { margin: 0 0 6px; }
.ht-rel-tools { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 10px; }
.ht-rel-tools a { display: flex; align-items: center; gap: 10px; padding: 8px; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; text-decoration: none; color: var(--ink); min-height: 64px; }
.ht-rel-tools a:hover { border-color: var(--green); }
.ht-rel-tools img { width: 72px; height: 54px; object-fit: cover; border-radius: 6px; flex: 0 0 auto; }
.ht-rel-tools span { display: flex; flex-direction: column; line-height: 1.3; }
.ht-rel-tools b { font-size: 14px; color: var(--primary); }
.ht-rel-tools small { font-size: 12px; color: var(--ink-2); }
.ht-rel-all a { justify-content: center; font-weight: 700; color: var(--green-dark); }
/* กล่องปุ่มภาพในคอลัมน์ซ้าย (หน้าแรก) · แบนเนอร์ 2:1 + ชื่อไทยใหญ่ซ้อนบนภาพ */
.side-tools { padding: 0; overflow: hidden; }
.side-tools .st-head { margin: 0; padding: 10px 12px 2px; }
.side-tools .st-head .sb-h { margin: 0; }
.side-tools .st-head .sb-p { margin: 0 0 6px; }
.st-list { list-style: none; margin: 0; padding: 0 10px 10px; display: grid; gap: 8px; }
.st-btn { position: relative; display: block; aspect-ratio: 2 / 1; border-radius: 10px; overflow: hidden; text-decoration: none; color: #fff; background: var(--mist); outline-offset: 2px; }
.st-btn img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.st-btn::after { content: ""; position: absolute; inset: 0; background: linear-gradient(90deg, rgba(19, 48, 42, .82) 0%, rgba(19, 48, 42, .5) 48%, rgba(19, 48, 42, 0) 78%); }
.st-btn span { position: absolute; left: 12px; right: 34%; top: 50%; transform: translateY(-50%); z-index: 1; font-size: 15px; font-weight: 800; line-height: 1.3; text-shadow: 0 1px 2px rgba(0, 0, 0, .35); }
.st-btn:hover img { transform: scale(1.04); transition: transform .2s ease; }
.st-btn:focus-visible { outline: 3px solid #7CC24F; }
.st-all { display: block; padding: 10px 12px; text-align: center; font-weight: 700; font-size: 14px; color: var(--green-dark); background: var(--mist); text-decoration: none; }
.cat-jump .cat-jump-tools { background: var(--primary); color: #fff; }
/* มือถือ: การ์ดเครื่องมือเต็มความกว้างใต้เนื้อหา (ไม่ยัดในคอลัมน์ซ้ายแคบ · ไม่ใช้ปุ่มลอย) */
.ht-mob-wrap { display: none; }
/* กล่องชวนลองเครื่องมือในบทความ */
.ht-art-cta { margin: 18px 0; padding: 14px 16px; background: var(--mist); border-radius: 12px; }
.ht-art-cta p { margin: 0 0 8px; }
.ht-art-cta .ht-art-cta-h { font-weight: 800; color: var(--primary); }
.ht-art-cta-list { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 8px; }
.ht-art-cta-list a { display: inline-flex; align-items: center; gap: 8px; min-height: 44px; padding: 6px 14px 6px 6px; background: #fff; border: 1px solid var(--line); border-radius: 999px; text-decoration: none; color: var(--primary); font-weight: 700; font-size: 15px; }
.ht-art-cta-list img { width: 44px; height: 33px; object-fit: cover; border-radius: 999px; }
@media (max-width: 767px) {
  .sidebar .side-tools { display: none !important; }
  .ht-mob-wrap { display: block; padding: 0 8px 20px; }
  .ht-mob { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
  .ht-mob .sa-head { margin: 0; padding: 12px 16px; font-size: 17px; background: linear-gradient(180deg, #3FA34D, #23803A); color: #fff; text-align: center; }
  .ht-mob .sb-p { display: block; padding: 8px 16px 0; font-size: 14px; color: var(--ink-2); }
  .ht-mob .st-list { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; padding: 10px 12px; }
  .ht-mob .st-btn { aspect-ratio: 4 / 3; }
  .ht-mob .st-btn span { font-size: 16px; }
  .ht-mob .st-all { min-height: 48px; display: flex; align-items: center; justify-content: center; font-size: 15px; }
}
@media (max-width: 700px) {
  .ht-grid { grid-template-columns: 1fr; }
  .ht-grid-form { grid-template-columns: 1fr; gap: 12px; }
  .ht-form { padding: 14px; }
  .ht-actions .btn-primary { flex: 1 1 100%; justify-content: center; }
  .ht-r-v { text-align: left; }
  .ht-hero img { max-width: 100%; }
}

/* ภาพ hybrid editorial: ป้ายไอคอนเส้นสีแบรนด์ซ้อนมุมภาพ (HTML ไม่ฝังในภาพ) · เครดิตภาพถ่าย */
.ht-card-img, .ht-hero-img, .st-btn { position: relative; }
.ht-hero-img { display: block; position: relative; max-width: 520px; }
.ht-badge { position: absolute; left: 12px; top: 12px; z-index: 1; display: grid; place-items: center; width: 44px; height: 44px; border-radius: 50%; background: rgba(255, 255, 255, .92); color: var(--primary); box-shadow: 0 2px 8px rgba(19, 48, 42, .18); }
.st-btn .ht-badge { left: auto; right: 10px; top: 10px; width: 36px; height: 36px; }
.st-btn .ht-badge svg { width: 18px; height: 18px; }
.ht-hero figcaption, .ht-credits { font-size: 12px; color: var(--ink-2); margin: 6px 0 0; }
.ht-credits { margin-top: 10px; }

/* ===== Phase 2 (เป้าหมายแคลอรี · สัดส่วนสารอาหาร · รอบเอวต่อส่วนสูง · น้ำ) ===== */
.ht-goal, .ht-custom { grid-column: 1 / -1; }
.ht-goal label, .ht-env label { display: flex; align-items: center; gap: 8px; min-height: 44px; padding: 4px 14px 4px 10px; margin: 0 0 6px; border: 1px solid #C9D6CF; border-radius: 10px; background: #fff; font-weight: 400; cursor: pointer; }
.ht-goal label:has(input:checked), .ht-env label:has(input:checked) { border-color: var(--primary); background: var(--mist); font-weight: 700; }
.ht-goal input, .ht-env input { margin: 0; accent-color: var(--primary); width: 18px; height: 18px; flex: none; }
.ht-goal input:focus-visible, .ht-env input:focus-visible { outline: 3px solid #7CC24F; outline-offset: 1px; }
.ht-custom[hidden] { display: none; }
.ht-grid-pct { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.ht-sum { margin: 4px 0 0; font-size: 15px; color: var(--ink-2); }
.ht-r-note.is-warn { padding: 8px 12px; border-left: 4px solid var(--honey); background: var(--honey-bg); border-radius: 6px; color: var(--honey-ink); }
.ht-donut { display: flex; align-items: center; gap: 18px; margin: 12px 0 4px; flex-wrap: wrap; }
.ht-donut svg { flex: none; transform: rotate(0deg); }
.ht-seg-protein { stroke: var(--primary); } .ht-seg-carb { stroke: var(--honey); } .ht-seg-fat { stroke: var(--green-light); }
.ht-legend { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; font-size: 15px; }
.ht-legend li { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.ht-sw { width: 14px; height: 14px; border-radius: 3px; flex: none; }
.ht-leg-protein .ht-sw { background: var(--primary); } .ht-leg-carb .ht-sw { background: var(--honey); } .ht-leg-fat .ht-sw { background: var(--green-light); }
.ht-measure { margin: 8px 0 18px; }
.ht-measure-body { display: flex; gap: 20px; align-items: flex-start; padding: 14px; border: 1px solid var(--line); border-radius: var(--radius); background: #fff; }
.ht-measure-body img { flex: none; width: 220px; height: auto; }
.ht-measure-steps { margin: 0; padding-left: 22px; display: grid; gap: 8px; line-height: 1.6; }
@media (max-width: 700px) {
  .ht-grid-pct { grid-template-columns: 1fr 1fr 1fr; gap: 8px; }
  .ht-measure-body { flex-direction: column; align-items: center; }
  .ht-measure-body img { width: 200px; }
}
.ht-sweat .lf-hint { margin: 0 0 6px; }
.ht-grid-sweat { grid-template-columns: repeat(2, minmax(0, 1fr)); }

/* Safari/iOS audit 16 ต.ค. 2569: เลื่อนไปผล/ฟอร์มแล้วไม่ถูกเมนูที่ลอยอยู่บัง (เมนูสูง 57 px บนมือถือ · 77 px ตั้งแต่ 768 px) */
.ht-form, .ht-result { scroll-margin-top: 72px; }
@media (min-width: 768px) { .ht-form, .ht-result { scroll-margin-top: 92px; } }
/* Safari/iOS audit: ช่อง % ของมาโคร 3 คอลัมน์ต้องพอดีจอ 320 px · ป้ายไม่ทับคอลัมน์ข้าง ช่องกรอกเรียงระดับเดียวกัน ตัวเลขไม่ชนหน่วย */
.ht-grid-pct { align-items: end; }
.ht-grid-pct .ht-field { min-width: 0; }
.ht-grid-pct .ht-field label { font-size: 14px; line-height: 1.35; }
.ht-grid-pct .ht-input input[type=text] { padding-right: 26px; }
@media (max-width: 400px) {
  .ht-grid-pct:not(.ht-grid-sweat) { gap: 6px; }
  .ht-grid-pct:not(.ht-grid-sweat) .ht-field label { font-size: 13px; }
  .ht-grid-pct:not(.ht-grid-sweat) .ht-input input[type=text] { padding-left: 8px; padding-right: 22px; font-size: 16px; }
}
.ht-grid-pct .ht-unit { right: 8px; }
@media (max-width: 360px) { .ht-grid-pct:not(.ht-grid-sweat) .ht-field label { font-size: 12px; } }
.st-all > span[aria-hidden] { margin-left: 6px; }
