/* [2 พ.ย. 2569] เครื่องมือ /bmi · /protein-calculator · /exercise-calories (.tl) — ต่อจาก pages-v2.css (.pv tokens + .art-* + .pv-packs)
   views app/Views/pages/tools/* · JS public/assets/js/tools.js · หัวสีเขียวเข้มแบบ /tdee/ การ์ดฟอร์มลอยทับหัว
   มือถือ: ฟอร์มอยู่จอแรก · กดคำนวณแล้วเลื่อนให้ผลอยู่บนสุดของจอ · เดสก์ท็อป: ฟอร์มซ้าย ผลขวา */
.tl { background: var(--bg2); }
.tl-w { max-width: 1000px; }
.tl-hero { padding: 16px 0 66px; background: #133a20; color: #fff; }
.tl-hero .art-crumb { margin-bottom: 8px; color: #a9c2a3; }
.tl-hero .art-crumb a { color: #e3f0dc; }
.tl-nw { display: inline-block; }
.tl-hero h1 { margin: 0; font-size: clamp(25px, 6.8vw, 40px); font-weight: 800; line-height: 1.28; letter-spacing: -.005em; color: #fff; text-wrap: balance; }
.tl-hero p { margin: 8px 0 0; max-width: 36em; font-size: 15.5px; line-height: 1.6; color: #cfe1c8; text-wrap: pretty; }
.tl-main { position: relative; margin-top: -50px; padding-bottom: 56px; }
.tl-top { display: grid; gap: 14px; align-items: start; }
.tl-out { display: grid; gap: 14px; min-width: 0; }
.tl-card { padding: 18px 16px; border: 1px solid var(--line); border-radius: 20px; background: #fff; box-shadow: 0 14px 34px -22px rgba(19, 58, 32, .45); }

/* ฟอร์ม */
.tl-row { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 10px; }
.tl-f { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.tl-f > span:first-child { font-size: 14.5px; font-weight: 700; color: var(--ink); }
.tl-f > span:first-child small { font-weight: 500; color: var(--ink2); }
.tl-gap { margin-top: 14px; }
.tl-f[hidden], .tl-rope[hidden] { display: none; }
.tl-in { display: flex; align-items: center; gap: 6px; min-height: 56px; padding: 0 14px; border: 1.5px solid var(--g-b); border-radius: 14px; background: #fff; cursor: text; transition: border-color .15s ease-out, box-shadow .15s ease-out; }
.tl-in:focus-within { border-color: var(--g); box-shadow: 0 0 0 3px rgba(0, 167, 85, .14); }
.tl-in input { flex: 1; min-width: 0; width: 100%; height: 52px; padding: 0; border: 0; outline: 0; background: transparent; font: inherit; font-size: 21px; font-weight: 700; color: var(--ink); font-variant-numeric: tabular-nums; }
.tl-in input::placeholder { font-size: 16px; font-weight: 500; color: #9aa592; }
.tl-in em { flex: none; font-style: normal; font-size: 14.5px; font-weight: 600; color: var(--ink2); }
.tl-f.is-err .tl-in { border-color: var(--red); background: #fffafa; }
.tl-err { margin: 12px 0 0; padding: 10px 12px; border-radius: 12px; background: var(--red-l); color: #9b2c2c; font-size: 14.5px; line-height: 1.55; }
.tl-go { width: 100%; margin-top: 16px; }
.tl-note { display: flex; align-items: flex-start; gap: 6px; margin: 10px 0 0; font-size: 13px; line-height: 1.5; color: var(--ink2); }
.tl-note .pv-ic { margin-top: 1px; color: var(--g-d); }

/* ปุ่มเลือก (แทน radio · ไม่มี name ไม่หลุดเข้า URL) */
.tl-seg { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; padding: 4px; border-radius: 14px; background: var(--bg2); border: 1px solid var(--line); }
.tl-seg.is-2 { grid-template-columns: 1fr 1fr; }
.tl-opt { display: flex; flex-direction: column; align-items: center; justify-content: center; min-height: 44px; padding: 6px 4px; border: 0; border-radius: 10px; background: transparent; color: var(--ink2); font: inherit; font-size: 14.5px; font-weight: 700; line-height: 1.3; text-align: center; cursor: pointer; transition: background-color .15s ease-out, color .15s ease-out; }
.tl-opt small { font-size: 11.5px; font-weight: 500; opacity: .85; }
.tl-opt[aria-pressed="true"] { background: #fff; color: #133a20; box-shadow: 0 1px 3px rgba(19, 58, 32, .18), 0 0 0 1.5px var(--g); }
.tl-seg.is-sm { padding: 3px; }
.tl-seg.is-sm .tl-opt { min-height: 36px; font-size: 14px; }
.tl-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.tl-chip { min-height: 38px; padding: 0 13px; border: 1.5px solid var(--g-b); border-radius: 999px; background: #fff; color: var(--ink); font: inherit; font-size: 14.5px; font-weight: 600; cursor: pointer; transition: background-color .15s ease-out, border-color .15s ease-out; }
.tl-chip:hover { border-color: var(--g); }
.tl-chip[aria-pressed="true"] { background: #133a20; border-color: #133a20; color: #fff; }
.tl-chips.is-dur { margin-top: 8px; }
.tl-chips.is-dur:empty { display: none; }
.tl-chips.is-dur .tl-chip { min-height: 34px; padding: 0 12px; font-size: 13.5px; }
.tl-sel { position: relative; display: block; margin-top: 4px; }
.tl-sel select { width: 100%; min-height: 52px; padding: 0 42px 0 14px; border: 1.5px solid var(--g-b); border-radius: 14px; background: #fff; color: var(--ink); font: inherit; font-size: 16px; font-weight: 600; -webkit-appearance: none; appearance: none; cursor: pointer; text-overflow: ellipsis; }
.tl-sel select:focus { outline: 0; border-color: var(--g); box-shadow: 0 0 0 3px rgba(0, 167, 85, .14); }
.tl-sel .pv-ic { position: absolute; right: 12px; top: 50%; margin-top: -10px; color: var(--g-d); pointer-events: none; }

/* ก่อนคำนวณ (เดสก์ท็อป) */
.tl-empty { display: none; }
.tl-empty-h { margin: 0 0 10px; font-size: 17px; font-weight: 800; color: #133a20; }
.tl-empty-n { margin: 12px 0 0; font-size: 14px; line-height: 1.6; color: var(--ink2); }
.tl-legend { display: grid; gap: 6px; margin: 0; padding: 0; list-style: none; }
.tl-legend li { display: grid; grid-template-columns: 14px 110px minmax(0, 1fr); align-items: center; gap: 10px; padding: 8px 10px; border-radius: 10px; background: var(--bg2); font-size: 15px; }
.tl-legend.is-plain li { grid-template-columns: 110px minmax(0, 1fr); }
.tl-legend i { width: 14px; height: 14px; border-radius: 4px; }
.tl-legend b { font-variant-numeric: tabular-nums; }
.tl-legend span { color: var(--ink2); }

/* ผลลัพธ์ */
.tl-res { scroll-margin-top: 76px; border: 2px solid #133a20; box-shadow: 0 18px 40px -26px rgba(19, 58, 32, .55); animation: tl-in .28s ease-out; }
.tl-res:focus { outline: 0; }
@keyframes tl-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.tl-res-k { margin: 0; font-size: 14.5px; font-weight: 700; color: var(--ink2); }
.tl-big { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px; margin-top: 2px; }
.tl-big b { font-size: 58px; font-weight: 800; line-height: 1.05; letter-spacing: -.02em; color: #133a20; font-variant-numeric: tabular-nums; }
.tl-big small { align-self: flex-end; margin: 0 0 10px -4px; font-size: 18px; font-weight: 700; color: #133a20; }
.tl-tag { display: inline-flex; align-items: center; min-height: 32px; padding: 0 13px; border-radius: 999px; background: var(--g); color: #fff; font-size: 15px; font-weight: 700; }
.tl-basis { margin: 4px 0 0; font-size: 14.5px; line-height: 1.55; color: var(--ink2); }
.tl-gauge { position: relative; margin: 16px 0 4px; }
.tl-gauge-bar { display: flex; gap: 2px; height: 12px; border-radius: 999px; overflow: hidden; }
.tl-gauge-bar i { display: block; height: 100%; }
.tl-pin { position: absolute; top: -6px; left: 0; width: 6px; height: 24px; margin-left: -3px; border-radius: 3px; background: #1d2618; box-shadow: 0 0 0 2px #fff; transition: left .35s ease-out; }
.tl-ax { position: relative; height: 20px; margin-top: 4px; font-size: 12px; color: var(--ink2); font-variant-numeric: tabular-nums; }
.tl-ax span { position: absolute; top: 0; transform: translateX(-50%); }
.tl-kv { margin: 12px 0 0; border-top: 1px solid var(--line); }
.tl-kv div { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.tl-kv dt { font-size: 14.5px; color: var(--ink2); }
.tl-kv dd { margin: 0; font-size: 16px; font-weight: 800; color: var(--ink); text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.tl-msg { margin: 12px 0 0; font-size: 15px; line-height: 1.65; color: var(--ink); text-wrap: pretty; }
.tl-src-s { margin: 8px 0 0; font-size: 12.5px; line-height: 1.5; color: var(--ink2); }
.tl-next { display: grid; gap: 10px; margin-top: 16px; }
.tl-next .pv-btn { font-size: 16px; }
.tl-alt { justify-self: center; color: var(--g-d) !important; font-size: 14.5px; font-weight: 700; text-decoration: underline; text-underline-offset: 3px; }
.tl-stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin: 14px 0 0; padding: 0; list-style: none; }
.tl-stats li { display: flex; flex-direction: column; gap: 2px; padding: 9px 8px; border-radius: 12px; background: var(--g-l); text-align: center; }
.tl-stats span { font-size: 12.5px; color: var(--ink2); }
.tl-stats b { font-size: 17px; font-weight: 800; color: #133a20; font-variant-numeric: tabular-nums; }
/* โปรตีน: ต่อมื้อ + ตัวอย่างเมนู */
.tl-meal { margin-top: 14px; padding: 12px; border-radius: 14px; background: var(--g-l); }
.tl-meal-h { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.tl-meal-h > span { font-size: 14.5px; font-weight: 700; color: var(--ink); }
.tl-meal-h .tl-seg { flex: 0 1 230px; background: #fff; }
.tl-meal-v { margin: 10px 0 0; font-size: 16px; color: var(--ink); }
.tl-meal-v b { font-size: 26px; font-weight: 800; color: #133a20; font-variant-numeric: tabular-nums; }
.tl-ex { margin-top: 14px; }
.tl-ex-h { margin: 0 0 8px; font-size: 14.5px; font-weight: 700; color: var(--ink); }
.tl-ex ul { display: grid; gap: 8px; margin: 0; padding: 0; list-style: none; }
.tl-ex li { display: grid; grid-template-columns: 48px minmax(0, 1fr); gap: 10px; align-items: center; }
.tl-ex img { width: 48px; height: 48px; border-radius: 10px; object-fit: cover; background: var(--bg2); }
.tl-ex-t { display: flex; justify-content: space-between; gap: 8px; font-size: 14px; line-height: 1.4; }
.tl-ex-t b { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 700; color: var(--ink); }
.tl-ex-t span { flex: none; color: var(--ink2); font-variant-numeric: tabular-nums; }
.tl-ex-bar { position: relative; height: 7px; margin-top: 5px; border-radius: 999px; background: var(--line); overflow: hidden; }
.tl-ex-bar i { position: absolute; left: 0; top: 0; bottom: 0; border-radius: 999px; background: var(--g); }
.tl-ex-n { margin: 8px 0 0; font-size: 12.5px; color: var(--ink2); }

/* ส่งผลเข้าอีเมล */
.tl-lead { position: relative; border: 1.5px solid var(--g-b); background: #fbfdf8; box-shadow: none; }
.tl-lead-h { display: flex; align-items: center; gap: 12px; }
.tl-lead-i { display: inline-flex; align-items: center; justify-content: center; width: 42px; height: 42px; border-radius: 50%; background: var(--g-l); color: var(--g-d); flex: none; }
.tl-lead h2 { margin: 0; font-size: 17.5px; font-weight: 800; line-height: 1.35; color: #133a20; }
.tl-lead-h p { margin: 2px 0 0; font-size: 14px; color: var(--ink2); }
.tl-lead-f { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; margin-top: 12px; }
.tl-lead-f input[type="email"] { min-width: 0; min-height: 50px; padding: 0 14px; border: 1.5px solid var(--g-b); border-radius: 12px; background: #fff; color: var(--ink); font: inherit; font-size: 16px; }
.tl-lead-f input[type="email"]:focus { outline: 0; border-color: var(--g); box-shadow: 0 0 0 3px rgba(0, 167, 85, .14); }
.tl-lead-f .pv-btn { min-height: 50px; padding: 0 20px; font-size: 16px; border-radius: 12px; }
.tl-lead-f .pv-btn[disabled] { opacity: .6; cursor: default; }
.tl-ck { grid-column: 1 / -1; display: flex; align-items: flex-start; gap: 10px; margin-top: 4px; font-size: 14px; line-height: 1.55; color: var(--ink); cursor: pointer; }
.tl-ck input { flex: none; width: 20px; height: 20px; margin: 1px 0 0; accent-color: var(--g); }
.tl-ck a { color: var(--g-d); font-weight: 600; text-decoration: underline; text-underline-offset: 2px; }
.tl-lead-n { margin: 10px 0 0; font-size: 13px; line-height: 1.6; color: var(--ink2); }
.tl-lead-st { margin: 10px 0 0; padding: 10px 12px; border-radius: 12px; font-size: 14.5px; line-height: 1.55; }
.tl-lead-st.is-ok { background: var(--g-l); color: var(--g-d); font-weight: 600; }
.tl-lead-st.is-err { background: var(--red-l); color: #9b2c2c; }
.tl-lead.is-done .tl-lead-f, .tl-lead.is-done .tl-lead-n { display: none; }
.tl-lead.is-busy::before { content: ''; position: fixed; left: 0; right: 0; top: 0; z-index: 9999; height: 3px; background: linear-gradient(90deg, transparent, var(--g), transparent); background-size: 50% 100%; background-repeat: no-repeat; animation: tl-bar 1s linear infinite; }
@keyframes tl-bar { from { background-position: -50% 0; } to { background-position: 150% 0; } }

/* เนื้อหาใต้เครื่องมือ */
.tl-doc { max-width: 760px; margin: 8px auto 0; font-size: 16.5px; }
.tl-doc .tl-sec { margin-top: 36px; scroll-margin-top: 80px; }
.tl-doc h2 { font-size: 23px; color: #133a20; }
.tl-doc .art-table td small, .tl-tbl td small { display: block; font-size: 12.5px; line-height: 1.45; color: var(--ink2); }
.tl-doc .art-table table { min-width: 0; }
.tl-doc .art-table th { white-space: normal; vertical-align: bottom; }
.tl-doc .art-table td:first-child { min-width: 6.5em; }
.tl-doc .art-table td.w { white-space: normal; }
.tl-doc .art-table td small a { font-weight: 500; }
.tl-doc .art-table td + td { white-space: nowrap; font-variant-numeric: tabular-nums; }
.tl-doc .art-table table.tl-tbl { min-width: 520px; }
.tl-doc .art-table a { color: var(--g-d); font-weight: 600; }
.tl-tbl td:first-child { min-width: 170px; }
.tl-tbl .tl-you { background: #f2f9ea; color: #133a20; font-weight: 800; }
.tl-formula { margin: 14px 0 0 !important; padding: 14px 16px; border-radius: 14px; background: #133a20; color: #fff !important; font-size: 18px; font-weight: 700; text-align: center; line-height: 1.5; }
.tl-formula.is-sm { margin: 0 !important; font-size: 15.5px; padding: 12px 14px; }
.tl-doc .art-box { margin-top: 20px; }
.tl-shop-s { margin: 4px 0 0 !important; font-size: 15px; line-height: 1.6; color: var(--ink2) !important; }
.tl-shop-n { margin: 10px 0 0 !important; font-size: 13.5px; line-height: 1.6; color: var(--ink2) !important; }
.tl-shop .art-menu ul { margin-top: 12px; }
.tl-more { display: grid; gap: 8px; margin: 12px 0 0 !important; padding: 0 !important; list-style: none !important; }
.tl-more a { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; column-gap: 10px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 14px; background: #fff; color: var(--ink) !important; font-weight: 400 !important; text-decoration: none !important; transition: border-color .15s ease-out; }
.tl-more a:hover { border-color: var(--g); }
.tl-more b { font-size: 16px; line-height: 1.4; }
.tl-more span { grid-column: 1; font-size: 14px; line-height: 1.5; color: var(--ink2); }
.tl-more .pv-ic { grid-column: 2; grid-row: 1 / span 2; color: var(--g-d); }
.tl-src { margin-top: 36px; padding-top: 16px; border-top: 1px solid var(--line); }
.tl-src h2 { font-size: 16px !important; }
.tl-src ol { margin: 8px 0 0; padding-left: 20px; display: grid; gap: 4px; list-style: decimal; }
.tl-src li, .tl-src p { font-size: 13px; line-height: 1.6; color: var(--ink2) !important; overflow-wrap: anywhere; }
.tl-src p { margin: 10px 0 0 !important; }
.tl-src a { color: var(--g-d) !important; font-weight: 500 !important; }

@media (max-width: 420px) {
  .tl-doc .art-table th, .tl-doc .art-table td { padding: 9px 9px; font-size: 14.5px; }
}
@media (min-width: 640px) {
  .tl-card { padding: 22px 22px; }
  .tl-more { grid-template-columns: 1fr 1fr; }
}
@media (min-width: 900px) {
  .tl-hero { padding: 28px 0 84px; }
  .tl-hero p { max-width: 46em; font-size: 17px; }
  .tl-main { margin-top: -64px; }
  .tl-top { grid-template-columns: minmax(0, 420px) minmax(0, 1fr); gap: 20px; }
  .tl-empty { display: block; }
  .tl-empty[hidden] { display: none; }
  .tl-doc { margin-top: 20px; }
  .tl-doc h2 { font-size: 25px; }
}
@media (prefers-reduced-motion: reduce) {
  .tl-res { animation: none; }
  .tl-pin, .tl-in, .tl-opt, .tl-chip { transition: none; }
  .tl-lead.is-busy::before { animation: none; background: var(--g); }
}
