@font-face { font-family: "Mali"; src: url("fonts/Mali-Bold.woff") format("woff"); font-weight: 700; font-display: swap; }
:root {
  --ink: #2B2F4A; --muted: #6B7090; --line: #E7E9F5;
  --yellow: #FFC93C; --pink: #FF6B8B; --mint: #22C3A6; --blue: #4D7CFE; --violet: #5B5FEF; --orange: #FF8A3D;
  --longan: #C9925A; --good: #12A386; --bad: #E2456A;
  --card-shadow: 0 1px 2px rgba(20,24,40,.08), 0 6px 14px -6px rgba(20,24,40,.22);
  --r: 18px;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { font-size: 17px; }
body {
  margin: 0; color: var(--ink); min-height: 100vh;
  font-family: "Sarabun", "Noto Sans Thai", "Leelawadee UI", "Thonburi", system-ui, sans-serif; line-height: 1.5;
  background: linear-gradient(180deg, #ECEEFF 0%, #F6F2FF 45%, #FFF5EF 100%) fixed;
}
h1, h2, h3, .brand, .big, .btn, .tabs button, .label { font-family: "Mali", "Sarabun", system-ui, sans-serif; font-weight: 700; }
h1 { font-size: 1.45rem; margin: 0; line-height: 1.3; }
h2 { font-size: 1.15rem; margin: 22px 0 10px; }
h3 { font-size: 1rem; margin: 0 0 6px; }
a { color: var(--violet); }
#app { max-width: 560px; margin: 0 auto; padding: 14px 14px 110px; }
.muted { color: var(--muted); font-size: .9rem; }
.small { font-size: .82rem; }
.row { display: flex; gap: 10px; align-items: center; }
.between { justify-content: space-between; }
.wrap { flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
.center { text-align: center; }
.mt { margin-top: 14px; }
.good { color: var(--good); } .bad { color: var(--bad); }

/* หัวหน้า */
.topbar { display: flex; align-items: center; gap: 10px; margin: 4px 2px 14px; }
.topbar .back { width: 42px; height: 42px; border-radius: 50%; border: 0; background: #fff; box-shadow: var(--card-shadow); font-size: 1.2rem; cursor: pointer; }
.brand { font-size: 1.05rem; color: #0E8F78; }

/* การ์ด */
.card { background: #fff; border-radius: var(--r); padding: 16px; box-shadow: var(--card-shadow); margin-bottom: 12px; position: relative; overflow: hidden; }
.card::after { content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 5px; background: var(--accent, #D9F5EE); }
.card.flat::after { display: none; }

/* การ์ดภาพประกอบ */
.art-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.art { position: relative; display: block; aspect-ratio: 200/95; border-radius: 12px; overflow: hidden; text-decoration: none;
  box-shadow: 0 1px 2px rgba(20,24,40,.08), 0 6px 14px -6px rgba(20,24,40,.22), inset 0 0 0 1px rgba(255,255,255,.6); transition: transform .12s; }
.art.wide { grid-column: 1 / -1; }
.art:active { transform: scale(.97); }
.art svg { width: 100%; height: 100%; display: block; }
.art .art-obj { transform-origin: 50% 100%; transition: transform .45s cubic-bezier(.34,1.56,.64,1); }
.art:hover .art-obj { transform: scale(1.05); }
.art .tag { position: absolute; left: 8px; top: 8px; background: rgba(255,255,255,.94); border-radius: 7px; padding: 3px 9px;
  font-family: "Mali", sans-serif; font-size: .86rem; box-shadow: 0 1px 3px rgba(20,24,40,.12); max-width: 80%; }
.hero { position: relative; aspect-ratio: 200/95; border-radius: 16px; overflow: hidden; box-shadow: var(--card-shadow); margin-bottom: 14px; }
.hero svg { width: 100%; height: 100%; display: block; }

/* ปุ่ม */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 0; border-radius: 14px; padding: 13px 18px;
  font-size: 1rem; cursor: pointer; background: var(--violet); color: #fff; text-decoration: none; min-height: 50px; }
.btn.block { width: 100%; }
.btn.soft { background: #EEF0FF; color: var(--violet); }
.btn.mint { background: #DDF6F0; color: #0E8F78; }
.btn.pink { background: #FFE6EC; color: #C0395A; }
.btn.small { padding: 8px 12px; min-height: 38px; font-size: .88rem; border-radius: 11px; }
.btn:disabled { opacity: .5; }
.fab { position: fixed; right: max(18px, calc(50% - 262px)); bottom: 92px; width: 62px; height: 62px; border-radius: 50%; border: 0; background: var(--violet);
  color: #fff; font-size: 2rem; box-shadow: 0 8px 20px -6px rgba(91,95,239,.6); cursor: pointer; z-index: 5; }
.linkbtn { background: none; border: 0; color: var(--muted); font: inherit; font-size: .85rem; cursor: pointer; padding: 4px; }

/* ฟอร์ม */
label.f { display: block; margin-bottom: 12px; }
label.f > span { display: block; font-size: .92rem; margin-bottom: 4px; color: var(--muted); }
input, select, textarea { width: 100%; font: inherit; font-size: 1.05rem; padding: 12px 14px; border-radius: 12px; border: 2px solid var(--line); background: #FBFBFF; color: var(--ink); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--violet); background: #fff; }
input.pin { letter-spacing: .6em; text-align: center; font-size: 1.6rem; font-family: "Mali", monospace; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.chips { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.chip { border: 0; border-radius: 999px; padding: 8px 14px; background: #fff; color: var(--ink); font: inherit; font-size: .92rem; cursor: pointer; box-shadow: 0 1px 3px rgba(20,24,40,.1); }
.chip.on { background: var(--violet); color: #fff; }
.tabs { display: flex; background: #EEF0FF; border-radius: 14px; padding: 4px; margin-bottom: 14px; }
.tabs button { flex: 1; border: 0; background: none; padding: 10px 4px; white-space: nowrap; border-radius: 11px; font-size: .95rem; color: var(--muted); cursor: pointer; }
.tabs button.on { background: #fff; color: var(--violet); box-shadow: 0 1px 3px rgba(20,24,40,.12); }

/* สถิติ */
.stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.stat { background: #fff; border-radius: 14px; padding: 12px; box-shadow: 0 1px 3px rgba(20,24,40,.08); }
.stat .big { font-size: 1.35rem; line-height: 1.2; }
.stat .muted { font-size: .8rem; }
.pill { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: .8rem; background: #EEF0FF; color: var(--violet); }
.pill.mint { background: #DDF6F0; color: #0E8F78; } .pill.pink { background: #FFE6EC; color: #C0395A; } .pill.yellow { background: #FFF3CF; color: #8A6400; }

/* รายการ */
.list { background: #fff; border-radius: var(--r); box-shadow: var(--card-shadow); overflow: hidden; margin-bottom: 12px; }
.item { display: flex; align-items: center; gap: 12px; padding: 13px 16px; border-bottom: 1px solid var(--line); text-decoration: none; color: inherit; }
.item:last-child { border-bottom: 0; }
.item .ic { width: 42px; height: 42px; border-radius: 12px; display: grid; place-items: center; font-size: 1.3rem; background: #F2F3FF; flex: none; }
.item .amt { font-family: "Mali", sans-serif; white-space: nowrap; }
.empty { text-align: center; padding: 26px 16px; color: var(--muted); }

/* ความคืบหน้ารอบ */
.progress { height: 14px; background: #EEF0FF; border-radius: 99px; overflow: hidden; }
.progress > i { display: block; height: 100%; background: linear-gradient(90deg, var(--mint), #7EE08F); border-radius: 99px; }
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { display: flex; gap: 12px; align-items: flex-start; padding: 8px 0; position: relative; }
.timeline li::before { content: ""; position: absolute; left: 17px; top: 40px; bottom: -8px; width: 3px; background: var(--line); }
.timeline li:last-child::before { display: none; }
.timeline .dot { width: 37px; height: 37px; flex: none; border-radius: 50%; display: grid; place-items: center; background: #F2F3FF; font-size: 1.05rem; position: relative; z-index: 1; }
.timeline li.done .dot { background: #DDF6F0; }
.timeline li.now .dot { background: var(--yellow); box-shadow: 0 0 0 5px rgba(255,201,60,.3); }
.timeline li.done .t { color: var(--muted); }

/* กราฟแท่ง */
.bars { display: flex; align-items: flex-end; gap: 5px; height: 170px; padding-top: 20px; }
.bars .b { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; min-width: 0; cursor: pointer; }
.bars .b i { display: block; width: 100%; border-radius: 7px 7px 3px 3px; background: var(--mint); min-height: 3px; position: relative; }
.bars .b i.hot { background: var(--pink); }
.bars .b i.sel { outline: 3px solid var(--violet); outline-offset: 1px; }
.bars .b em { font-style: normal; font-size: .72rem; margin-bottom: 2px; font-family: "Mali", sans-serif; }
.bars .b small { font-size: .7rem; color: var(--muted); margin-top: 4px; white-space: nowrap; }
.legend { display: flex; gap: 14px; font-size: .8rem; color: var(--muted); margin-top: 8px; }
.legend i { display: inline-block; width: 11px; height: 11px; border-radius: 3px; margin-right: 4px; vertical-align: -1px; }

/* ตารางราคา */
.ptable { width: 100%; border-collapse: collapse; }
.ptable td, .ptable th { padding: 7px 4px; text-align: center; border-bottom: 1px solid var(--line); font-size: .95rem; }
.ptable th { font-size: .8rem; color: var(--muted); font-weight: 400; }
.ptable td:first-child, .ptable th:first-child { text-align: left; }
.ptable .best { color: var(--good); font-weight: 700; }
.kind-row { display: grid; grid-template-columns: 70px 1fr; gap: 10px; align-items: center; margin-bottom: 8px; }
.kind-row .label { background: #FFF3CF; border-radius: 10px; padding: 10px 0; text-align: center; color: #8A6400; }

/* ผลคำนวณ */
.versus { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.versus .stat.win { box-shadow: 0 0 0 3px var(--mint), 0 6px 14px -6px rgba(20,24,40,.22); }
.verdict { background: #DDF6F0; color: #0B6E5C; border-radius: 14px; padding: 14px; margin-top: 12px; font-size: 1.05rem; }
.verdict.warn { background: #FFF3CF; color: #7A5800; }
.note { background: #FFF8E6; border-radius: 12px; padding: 10px 12px; font-size: .85rem; color: #7A5800; margin: 10px 0; }

/* แถบเมนูล่าง */
#tabbar { position: fixed; left: 0; right: 0; bottom: 0; display: flex; justify-content: center; background: rgba(255,255,255,.96);
  box-shadow: 0 -4px 18px -8px rgba(20,24,40,.25); padding: 6px 4px calc(6px + env(safe-area-inset-bottom)); z-index: 10; backdrop-filter: blur(8px); }
#tabbar[hidden] { display: none; }
#tabbar a { flex: 1; max-width: 112px; display: flex; flex-direction: column; align-items: center; gap: 1px; text-decoration: none; color: var(--muted);
  font-size: .7rem; padding: 4px 0; border-radius: 12px; font-family: "Mali", sans-serif; }
#tabbar a span { font-size: 1.35rem; line-height: 1.2; filter: grayscale(.6); }
#tabbar a.on { color: var(--violet); background: #EEF0FF; }
#tabbar a.on span { filter: none; }

/* แผ่นเลื่อนขึ้น */
#sheet { position: fixed; inset: 0; z-index: 20; display: flex; align-items: flex-end; justify-content: center; }
#sheet[hidden] { display: none; }
.sheet-bg { position: absolute; inset: 0; background: rgba(30,33,60,.42); }
.sheet-card { position: relative; width: 100%; max-width: 560px; max-height: 92vh; overflow: auto; background: #fff; border-radius: 22px 22px 0 0;
  padding: 18px 16px calc(20px + env(safe-area-inset-bottom)); animation: up .22s ease-out; }
.sheet-card::before { content: ""; display: block; width: 44px; height: 5px; border-radius: 9px; background: var(--line); margin: -6px auto 12px; }
@keyframes up { from { transform: translateY(30px); opacity: .5; } }
#toast { position: fixed; left: 50%; bottom: 96px; transform: translateX(-50%); background: var(--ink); color: #fff; padding: 11px 18px; border-radius: 14px;
  z-index: 30; font-size: .95rem; max-width: 90vw; box-shadow: 0 8px 20px -8px rgba(0,0,0,.4); }
#toast.err { background: var(--bad); }
.spin { text-align: center; padding: 40px; color: var(--muted); }

.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; text-align: center; margin-top: 6px; }
.grid3 .big { font-size: 1.35rem; }
.timeline li.mhead { padding: 12px 0 2px; color: var(--violet); }
.timeline li.mhead::before { display: none; }
.klist { margin: 6px 0 10px; padding-left: 20px; } .klist li { margin-bottom: 6px; }
.ktable { width: 100%; border-collapse: collapse; margin: 6px 0 10px; font-size: .9rem; }
.ktable th { background: #F2F3FF; color: var(--muted); font-weight: 400; font-size: .8rem; text-align: left; padding: 7px 8px; }
.ktable td { padding: 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
.ktable tr:nth-child(odd) td { background: #FCFCFF; }
.art-grid.one { grid-template-columns: 1fr; }
.art .sub { position: absolute; left: 8px; right: 8px; bottom: 8px; background: rgba(255,255,255,.9); border-radius: 7px; padding: 3px 9px; font-size: .78rem; color: var(--muted);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.photos { display: grid; gap: 12px; margin-bottom: 14px; }
.photo { margin: 0; background: #fff; border-radius: 14px; overflow: hidden; box-shadow: var(--card-shadow); }
.photo img { width: 100%; aspect-ratio: 4/3; object-fit: cover; display: block; background: #EEF0FF; cursor: zoom-in; }
.photo figcaption { padding: 8px 12px 10px; font-size: .9rem; }
.photo .credit { font-size: .72rem; color: var(--muted); } .photo .credit a { color: var(--muted); }
.art .cam { position: absolute; right: 8px; top: 8px; background: rgba(43,47,74,.78); color: #fff; border-radius: 7px; padding: 2px 8px; font-size: .74rem; }
.art .ph { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; transition: transform .45s cubic-bezier(.34,1.56,.64,1); }
.art:hover .ph { transform: scale(1.05); }
.hero .ph { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.hero-credit { font-size: .7rem; color: var(--muted); margin: -10px 4px 6px; text-align: right; } .hero-credit a { color: var(--muted); }
