/* คิดง่าย: สไตล์กลางของทุกหน้า ฟอนต์เก็บในเว็บเอง ไม่โหลดจากเว็บอื่น */
@font-face { font-family: "Plex Looped"; font-weight: 400; font-display: swap; src: url("fonts/ibm-plex-sans-thai-looped-thai-400-normal.woff2") format("woff2"); unicode-range: U+0E01-0E5B, U+200C-200D, U+25CC; }
@font-face { font-family: "Plex Looped"; font-weight: 400; font-display: swap; src: url("fonts/ibm-plex-sans-thai-looped-latin-400-normal.woff2") format("woff2"); unicode-range: U+0000-00FF, U+2000-206F; }
@font-face { font-family: "Plex Looped"; font-weight: 600; font-display: swap; src: url("fonts/ibm-plex-sans-thai-looped-thai-600-normal.woff2") format("woff2"); unicode-range: U+0E01-0E5B, U+200C-200D, U+25CC; }
@font-face { font-family: "Plex Looped"; font-weight: 600; font-display: swap; src: url("fonts/ibm-plex-sans-thai-looped-latin-600-normal.woff2") format("woff2"); unicode-range: U+0000-00FF, U+2000-206F; }
@font-face { font-family: "Mitr"; font-weight: 500; font-display: swap; src: url("fonts/mitr-thai-500-normal.woff2") format("woff2"); unicode-range: U+0E01-0E5B, U+200C-200D, U+25CC; }
@font-face { font-family: "Mitr"; font-weight: 500; font-display: swap; src: url("fonts/mitr-latin-500-normal.woff2") format("woff2"); unicode-range: U+0000-00FF, U+2000-206F; }

:root {
  --bg: #f3efe4;
  --card: #fffdf8;
  --ink: #17261d;
  --muted: #56635a;
  --line: #ddd5c2;
  --green: #1d5a3c;
  --green-deep: #133f2a;
  --on-green: #f6f2e7;
  --on-green-muted: #b9cdbf;
  --ochre: #a86b12;
  --ochre-line: #d9a441;
  --ochre-soft: #fbf0d9;
  --warn: #a13c2a;
  --shadow: 0 1px 2px rgba(23, 38, 29, 0.06), 0 6px 20px rgba(23, 38, 29, 0.06);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #101612;
    --card: #18211b;
    --ink: #e8ece6;
    --muted: #a2afa5;
    --line: #2e3a32;
    --green: #6fbf93;
    --green-deep: #1d3a2a;
    --on-green: #eef3ee;
    --on-green-muted: #9fbcab;
    --ochre: #e0a54a;
    --ochre-line: #b9843a;
    --ochre-soft: #2a2316;
    --warn: #f0937f;
    --shadow: none;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "Plex Looped", "Sarabun", "Noto Sans Thai", "Thonburi", "Leelawadee UI", system-ui, sans-serif;
  font-size: 18px;
  line-height: 1.75;
}
a { color: var(--green); }

.top { border-bottom: 1px solid var(--line); background: var(--card); }
.top-in { max-width: 760px; margin: 0 auto; padding: 10px 16px; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.brand { display: inline-flex; align-items: center; gap: 10px; color: var(--ink); text-decoration: none; font-family: "Mitr", sans-serif; font-weight: 500; font-size: 1.3rem; line-height: 1; }
.brand svg { flex: none; }
.top-note { color: var(--muted); font-size: 0.85rem; }

main { max-width: 760px; margin: 0 auto; padding: 16px 16px 64px; }
.crumb { font-size: 0.9rem; color: var(--muted); margin: 4px 0 8px; }
.crumb a { color: var(--muted); }
h1, h2 { font-family: "Mitr", sans-serif; font-weight: 500; letter-spacing: 0; }
h1 { font-size: 1.75rem; line-height: 1.35; margin: 6px 0 6px; }
h2 { font-size: 1.3rem; line-height: 1.4; margin: 40px 0 8px; }
h3 { font-size: 1.05rem; margin: 24px 0 4px; }
p { margin: 8px 0 12px; }
.lead { color: var(--muted); margin-bottom: 4px; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 20px 16px;
  margin: 20px 0;
  box-shadow: var(--shadow);
}
.card > h2 { margin: 0 0 12px; }

.row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; align-items: end; }
.row.two { grid-template-columns: 1.6fr 1.4fr; }
label { display: block; font-size: 0.9rem; color: var(--muted); margin-bottom: 4px; }
.field { position: relative; }
.field input { padding-right: 3.2em; }
.field .unit {
  position: absolute; right: 12px; top: 50%; transform: translateY(-50%);
  color: var(--muted); font-size: 0.9rem; pointer-events: none;
}
input, select {
  width: 100%;
  font: inherit;
  font-size: 1.2rem;
  font-variant-numeric: tabular-nums;
  color: var(--ink);
  background: var(--bg);
  border: 2px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
  min-height: 54px;
}
select { font-size: 1.05rem; }
input:focus, select:focus { outline: none; border-color: var(--green); background: var(--card); }
button:focus-visible, a:focus-visible { outline: 3px solid var(--ochre-line); outline-offset: 2px; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 14px 0 4px; align-items: center; }
.chips span { color: var(--muted); font-size: 0.9rem; margin-right: 2px; }
.chip {
  font: inherit; font-size: 0.95rem;
  background: transparent; color: var(--green);
  border: 1px solid var(--line); border-radius: 999px;
  padding: 4px 14px; min-height: 40px; cursor: pointer;
}
.chip:hover { border-color: var(--green); }
.or { color: var(--muted); font-size: 0.9rem; margin: 18px 0 8px; }

.result {
  background: var(--green-deep);
  color: var(--on-green);
  border-radius: 14px;
  padding: 18px 16px 16px;
  margin: 20px 0 8px;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 4px 16px;
  align-items: center;
}
.result .label { color: var(--on-green-muted); font-size: 0.9rem; }
.big { font-family: "Mitr", sans-serif; font-weight: 500; font-size: 2.4rem; line-height: 1.2; font-variant-numeric: tabular-nums; word-break: break-all; }
.big small { font-family: "Plex Looped", sans-serif; font-size: 1rem; font-weight: 400; margin-left: 6px; color: var(--on-green-muted); }
.deed {
  border: 2px solid var(--ochre-line);
  border-radius: 8px;
  padding: 6px 12px 4px;
  text-align: center;
  line-height: 1.3;
}
.deed b { display: block; font-family: "Mitr", sans-serif; font-weight: 500; font-size: 1.35rem; color: #f2c46d; font-variant-numeric: tabular-nums; white-space: nowrap; }
.deed span { font-size: 0.75rem; color: var(--on-green-muted); }
.result .answer { grid-column: 1 / -1; font-size: 0.95rem; color: var(--on-green-muted); margin-top: 6px; }

.result.price { background: var(--ochre-soft); color: var(--ink); border: 1px solid var(--ochre-line); }
.result.price .label, .result.price .answer, .result.price .big small { color: var(--muted); }
.result.price .big { color: var(--ochre); }

.area-sum {
  display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 12px;
  border: 2px dashed var(--line); border-radius: 10px;
  padding: 10px 14px; margin: 0 0 12px;
}
.area-sum .label { color: var(--muted); font-size: 0.88rem; flex-basis: 100%; }
.area-sum #price-area { font-family: "Mitr", sans-serif; font-weight: 500; font-size: 1.2rem; font-variant-numeric: tabular-nums; }
.area-sum a { font-size: 0.92rem; margin-left: auto; }

.results { width: 100%; border-collapse: collapse; margin-top: 6px; }
.results th, .results td { padding: 8px 0; border-bottom: 1px dashed var(--line); font-weight: 400; }
.results th { text-align: left; color: var(--muted); }
.results td { text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; white-space: nowrap; padding-left: 12px; }
.results tr:last-child th, .results tr:last-child td { border-bottom: 0; }

button.main, button.ghost {
  font: inherit; font-size: 1rem;
  border-radius: 10px; padding: 9px 18px; min-height: 48px; cursor: pointer;
}
button.main { background: var(--green); color: var(--card); border: 0; }
button.ghost { background: transparent; color: var(--green); border: 2px solid var(--line); }
.actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 14px; }
.msg { color: var(--warn); font-size: 0.95rem; min-height: 1.5em; margin: 6px 0 0; }
.hint { color: var(--muted); font-size: 0.88rem; line-height: 1.65; margin: 12px 0 0; }

table.ref { width: 100%; border-collapse: collapse; margin: 12px 0; font-size: 0.98rem; background: var(--card); }
table.ref th, table.ref td { border: 1px solid var(--line); padding: 8px 10px; text-align: right; font-variant-numeric: tabular-nums; }
table.ref th:first-child, table.ref td:first-child { text-align: left; }
table.ref thead th { background: var(--green-deep); color: var(--on-green); font-weight: 600; }
.scroll { overflow-x: auto; }

a.tool {
  display: grid; grid-template-columns: auto 1fr; gap: 14px; align-items: center;
  background: var(--card); border: 1px solid var(--line); border-radius: 16px;
  padding: 16px; margin: 16px 0; color: var(--ink); text-decoration: none; box-shadow: var(--shadow);
}
a.tool:hover { border-color: var(--green); }
a.tool strong { display: block; font-family: "Mitr", sans-serif; font-weight: 500; font-size: 1.15rem; color: var(--green); }
a.tool span { color: var(--muted); font-size: 0.95rem; }
.icon { width: 52px; height: 52px; border-radius: 12px; background: var(--green-deep); display: grid; place-items: center; }

footer { color: var(--muted); font-size: 0.88rem; margin-top: 48px; border-top: 1px solid var(--line); padding-top: 16px; }

@media (max-width: 520px) {
  .row { gap: 8px; }
  .row.price { grid-template-columns: 1fr; gap: 12px; }
  .field input { padding-right: 2.6em; padding-left: 10px; }
  .field .unit { right: 8px; font-size: 0.8rem; }
  .big { font-size: 2rem; }
  .result { grid-template-columns: 1fr; }
  .deed { justify-self: start; }
}
