:root {
  --bg: #faf7f1;
  --surface: #ffffff;
  --band: #f2ece0;
  --ink: #1f1a14;
  --muted: #6b6255;
  --line: #e4dccd;
  --gold: #a8741a;
  --gold-soft: #f6ead2;
  --maroon: #7a2323;
  --on-accent: #fff8e8;
  --green: #2f7a4b;
  --green-soft: #e3f1e7;
  --amber-soft: #fbefd9;
  --blue-soft: #e5eef8;
  --blue: #2c5d8f;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(31, 26, 20, .06), 0 6px 20px rgba(31, 26, 20, .06);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #15120e; --surface: #1e1a15; --band: #1a1712; --ink: #f1ebe0; --muted: #a89e8f;
    --line: #342e25; --gold: #d9a54a; --gold-soft: #3a2e18; --maroon: #e08a7a; --on-accent: #1f1410;
    --green: #6cc28d; --green-soft: #1d3326; --amber-soft: #3a2f1a; --blue-soft: #1c2938; --blue: #8fb7e0;
    --shadow: 0 1px 2px rgba(0,0,0,.4); color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #15120e; --surface: #1e1a15; --band: #1a1712; --ink: #f1ebe0; --muted: #a89e8f;
  --line: #342e25; --gold: #d9a54a; --gold-soft: #3a2e18; --maroon: #e08a7a; --on-accent: #1f1410;
  --green: #6cc28d; --green-soft: #1d3326; --amber-soft: #3a2f1a; --blue-soft: #1c2938; --blue: #8fb7e0;
  --shadow: 0 1px 2px rgba(0,0,0,.4); color-scheme: dark;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 16px/1.65 "IBM Plex Sans Thai", system-ui, sans-serif;
}
h1, h2, h3 { font-family: "Noto Serif Thai", serif; line-height: 1.3; margin: 0 0 .4em; }
a { color: var(--gold); }
.wrap { max-width: 1160px; margin: 0 auto; padding: 0 16px; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* header */
.site-header { position: sticky; top: 0; z-index: 10; background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); }
.header-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; height: 62px; }
.logo { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--ink); font-weight: 600; font-size: 1.2rem; }
.logo b { color: var(--gold); }
.logo-mark { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 50%; background: var(--maroon); color: var(--on-accent); font-family: "Noto Serif Thai", serif; font-size: 1.05rem; box-shadow: inset 0 0 0 2px var(--gold); }
.nav { display: flex; align-items: center; gap: 20px; }
.nav a { color: var(--ink); text-decoration: none; font-size: .95rem; white-space: nowrap; }
.nav a:not(.btn):hover { color: var(--gold); }
@media (max-width: 720px) { .nav a:not(.btn):not(.nav-keep) { display: none; } .nav { gap: 12px; } .hide-sm { display: none; } }

/* buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 10px 18px; border-radius: 999px; border: 1px solid var(--maroon); background: var(--maroon); color: var(--on-accent) !important; text-decoration: none; font: inherit; font-weight: 500; cursor: pointer; }
.btn:hover { filter: brightness(1.1); }
.btn-sm { padding: 6px 14px; font-size: .9rem; }
.btn-ghost { background: transparent; color: var(--maroon) !important; }

/* hero */
.hero { padding: 56px 0 36px; background: radial-gradient(1200px 300px at 80% -10%, var(--gold-soft), transparent 70%); }
.eyebrow { color: var(--gold); font-weight: 600; letter-spacing: .02em; margin: 0 0 8px; }
.hero h1 { font-size: clamp(1.9rem, 4.6vw, 3.1rem); max-width: 18ch; }
.accent { color: var(--maroon); }
.lead { color: var(--muted); max-width: 56ch; font-size: 1.08rem; }

.search { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 24px; padding: 10px; background: var(--surface); border: 1px solid var(--line); border-radius: 18px; box-shadow: var(--shadow); }
.field { display: flex; flex: 1 1 170px; }
.field.grow { flex: 1 1 280px; }
.field input, .field select { width: 100%; font: inherit; color: var(--ink); background: var(--bg); border: 1px solid var(--line); border-radius: 12px; padding: 11px 14px; }
.field input:focus, .field select:focus { outline: 2px solid var(--gold); outline-offset: 1px; }

.stats { display: flex; gap: 28px; margin-top: 22px; flex-wrap: wrap; }
.stats div, .stats a { display: flex; flex-direction: column; }
.stats b { font-family: "Noto Serif Thai", serif; font-size: 1.7rem; color: var(--maroon); line-height: 1.1; }
.stats span { color: var(--muted); font-size: .9rem; }

/* sections */
.section { padding: 44px 16px; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 18px; }
.section-head h2 { font-size: clamp(1.4rem, 3vw, 1.9rem); margin: 0; }
.band { background: var(--band); border-block: 1px solid var(--line); }

/* cards */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr)); gap: 16px; }
.card { display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; cursor: pointer; transition: transform .15s, box-shadow .15s, border-color .15s; }
.card:hover, .card:focus-visible { transform: translateY(-2px); box-shadow: var(--shadow); border-color: var(--gold); outline: none; }
.card h3 { font-size: 1.15rem; margin: 8px 0 2px; }
.card-top { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.type { font-size: .78rem; font-weight: 600; padding: 3px 10px; border-radius: 999px; background: var(--gold-soft); color: var(--gold); }
.t-mall { background: var(--blue-soft); color: var(--blue); }
.t-online { background: var(--green-soft); color: var(--green); }
.open-now { font-size: .8rem; color: var(--green); font-weight: 600; }
.loc { color: var(--muted); margin: 0; font-size: .92rem; }
.hours { margin: 6px 0 8px; font-weight: 500; font-size: .95rem; }
.desc { color: var(--muted); font-size: .92rem; margin: 10px 0 12px; flex: 1; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.days { display: inline-flex; gap: 4px; }
.days i { font-style: normal; font-size: .74rem; width: 26px; height: 24px; display: grid; place-items: center; border-radius: 6px; background: var(--bg); color: var(--muted); border: 1px solid var(--line); }
.days i.on { background: var(--maroon); color: var(--on-accent); border-color: var(--maroon); }
.days i.today { box-shadow: 0 0 0 2px var(--gold); }
.card-foot { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.chip { font-size: .78rem; padding: 2px 9px; border-radius: 999px; border: 1px solid var(--line); color: var(--muted); }
.chip-muted { font-style: italic; }
.verified { margin-left: auto; font-size: .75rem; padding: 2px 8px; border-radius: 6px; }
.v-media { background: var(--blue-soft); color: var(--blue); }
.v-site { background: var(--green-soft); color: var(--green); }
.v-forum { background: var(--amber-soft); color: var(--gold); }
.empty { text-align: center; color: var(--muted); padding: 40px 0; }

/* ad slot */
.ad-slot { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; border: 1.5px dashed var(--gold); border-radius: var(--radius); padding: 14px 18px; margin-bottom: 18px; background: var(--gold-soft); }
.ad-slot p { margin: 0; flex: 1 1 260px; }
.ad-label { font-size: .75rem; font-weight: 600; color: var(--gold); text-transform: uppercase; letter-spacing: .04em; }

/* guide */
.guide { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 240px), 1fr)); gap: 16px; }
.guide article { padding: 18px; border-left: 3px solid var(--gold); background: var(--surface); border-radius: 0 var(--radius) var(--radius) 0; }
.guide h3 { font-size: 1.05rem; }
.guide p { margin: 0; color: var(--muted); font-size: .94rem; }

/* pricing */
.band-dark { background: var(--band); }
.pricing { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 260px), 1fr)); gap: 16px; }
.plan { position: relative; display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 24px; }
.plan-hl { border: 2px solid var(--maroon); }
.badge-top { position: absolute; top: -12px; left: 24px; background: var(--maroon); color: var(--on-accent); font-size: .78rem; padding: 2px 12px; border-radius: 999px; }
.price { font-family: "Noto Serif Thai", serif; font-size: 2rem; margin: 0 0 8px; color: var(--maroon); }
.price small { font-family: "IBM Plex Sans Thai", sans-serif; font-size: .9rem; color: var(--muted); }
.plan ul { padding-left: 18px; margin: 0 0 18px; flex: 1; color: var(--muted); font-size: .94rem; }
.plan li { margin-bottom: 4px; }

.claim { margin-top: 28px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 24px; }
.claim-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 240px), 1fr)); gap: 12px; }
.claim label { display: flex; flex-direction: column; gap: 4px; font-size: .9rem; color: var(--muted); }
.claim .full { grid-column: 1 / -1; }
.claim input, .claim textarea { font: inherit; color: var(--ink); background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; }
.claim-ok { color: var(--green); font-weight: 600; }

/* dialog */
dialog { width: min(560px, calc(100% - 32px)); border: 1px solid var(--line); border-radius: 18px; padding: 26px; background: var(--surface); color: var(--ink); box-shadow: 0 20px 60px rgba(0,0,0,.25); }
dialog::backdrop { background: rgba(20, 15, 10, .5); }
dialog h2 { margin-top: 10px; }
dialog dl { display: grid; grid-template-columns: 100px 1fr; gap: 10px 14px; margin: 16px 0 20px; font-size: .95rem; }
dialog dt { color: var(--muted); }
dialog dd { margin: 0; }
.close { position: absolute; top: 12px; right: 14px; border: 0; background: none; font-size: 1.6rem; color: var(--muted); cursor: pointer; }
.d-actions { display: flex; gap: 10px; flex-wrap: wrap; }
@media (max-width: 480px) { dialog dl { grid-template-columns: 1fr; gap: 2px; } dialog dd { margin-bottom: 10px; } }

.site-footer { padding: 32px 0 48px; border-top: 1px solid var(--line); }
.site-footer p { margin: 0 0 6px; }

/* keep anchored sections clear of the sticky header */
section[id], form[id], .place { scroll-margin-top: 72px; }

/* ───────── province pages ───────── */
.crumbs { display: flex; flex-wrap: wrap; gap: 8px; padding-top: 16px; font-size: .88rem; color: var(--muted); }
.crumbs a { color: var(--muted); text-decoration: none; }
.crumbs a:hover { color: var(--gold); }
.hero-sm { padding: 28px 0 28px; }
.hero-sm h1 { max-width: none; font-size: clamp(1.8rem, 4.2vw, 2.7rem); }
.notice { margin: 18px 0 0; padding: 10px 14px; border-radius: 10px; background: var(--amber-soft); font-size: .92rem; max-width: 70ch; }
.h-sm { font-size: 1.15rem; margin: 26px 0 12px; }

.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.schedule { width: 100%; border-collapse: collapse; font-size: .95rem; }
.schedule th { width: 110px; text-align: left; font-weight: 600; padding: 10px 16px; white-space: nowrap; color: var(--muted); }
.schedule td { padding: 10px 16px; }
.schedule tr + tr > * { border-top: 1px solid var(--line); }
.schedule tr.today { background: var(--gold-soft); }
.schedule tr.today th { color: var(--maroon); }
.schedule tr.today th::after { content: " · วันนี้"; font-weight: 500; font-size: .8rem; }
.schedule a { color: var(--ink); text-decoration-color: var(--gold); text-underline-offset: 3px; }
.schedule .sep { color: var(--muted); margin: 0 8px; }

.places { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 420px), 1fr)); gap: 16px; }
.place { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; }
.place:target { border-color: var(--gold); box-shadow: 0 0 0 3px var(--gold-soft); }
.place h3 { font-size: 1.2rem; margin: 10px 0 6px; }
.place dl { display: grid; grid-template-columns: 84px 1fr; gap: 8px 12px; margin: 10px 0 12px; font-size: .94rem; }
.place dt { color: var(--muted); }
.place dd { margin: 0; }
.place .verified { margin-left: 0; }
.place .tags { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 14px; }
@media (max-width: 480px) { .place dl { grid-template-columns: 1fr; gap: 2px; } .place dd { margin-bottom: 8px; } }

.faq { display: grid; gap: 10px; max-width: 820px; }
.faq details { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 4px 18px; }
.faq summary { cursor: pointer; font-weight: 600; padding: 10px 0; }
.faq p { margin: 0 0 14px; color: var(--muted); }

.province-links { display: flex; flex-wrap: wrap; gap: 8px; margin: 0; }
.province-links a { text-decoration: none; color: var(--ink); border: 1px solid var(--line); background: var(--surface); padding: 6px 14px; border-radius: 999px; font-size: .92rem; }
.province-links a:hover { border-color: var(--gold); color: var(--gold); }
.province-links span { color: var(--muted); font-size: .8rem; margin-left: 2px; }

.province-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 250px), 1fr)); gap: 12px; }
.province-card { display: flex; flex-direction: column; gap: 2px; padding: 16px 18px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); text-decoration: none; color: var(--ink); transition: border-color .15s, transform .15s; }
.province-card:hover { border-color: var(--gold); transform: translateY(-2px); }
.province-card b { font-family: "Noto Serif Thai", serif; font-size: 1.1rem; }
.province-card span { color: var(--maroon); font-size: .9rem; font-weight: 500; }
.province-card small { color: var(--muted); font-size: .84rem; }
.d-link { display: inline-block; margin-top: 14px; font-size: .92rem; }
@media (max-width: 480px) { .schedule th { width: 76px; padding: 10px 10px 10px 14px; } .schedule td { padding: 10px 14px 10px 4px; } }
.chip-month { border-color: var(--gold); color: var(--gold); font-weight: 500; }
.schedule tr.row-month { border-top: 2px solid var(--line); }
.schedule tr.row-month th { color: var(--gold); }
.v-ok { background: var(--green-soft); color: var(--green); font-weight: 600; }

/* ───────── market detail page ───────── */
.place h3 a { color: inherit; text-decoration: none; }
.place h3 a:hover { color: var(--gold); text-decoration: underline; text-underline-offset: 3px; }
.today-status { display: inline-block; margin: 4px 0 16px; padding: 6px 14px; border-radius: 999px; font-weight: 600; font-size: .95rem; }
.today-status.open { background: var(--green-soft); color: var(--green); }
.today-status.closed { background: var(--band); color: var(--muted); border: 1px solid var(--line); }
.market-grid { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 36px; align-items: start; }
@media (max-width: 900px) { .market-grid { grid-template-columns: 1fr; } }
.market-main h2 { font-size: 1.3rem; margin: 30px 0 12px; }
.market-main h2:first-child { margin-top: 0; }
.market-main > p { max-width: 68ch; }
.facts { display: grid; grid-template-columns: 110px 1fr; gap: 12px 16px; margin: 0; padding: 20px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; }
.facts .tags { display: flex; flex-wrap: wrap; gap: 6px; }
@media (max-width: 480px) { .facts { grid-template-columns: 1fr; gap: 2px; } .facts dd { margin-bottom: 10px; } }
.map-box { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; aspect-ratio: 16 / 9; max-height: 420px; width: 100%; border: 1px dashed var(--line); border-radius: var(--radius); background: var(--band); text-align: center; padding: 16px; color: var(--muted); }
.map-box p { margin: 0; }
.map-box.loaded { padding: 0; border-style: solid; overflow: hidden; }
.map-box iframe { width: 100%; height: 100%; border: 0; }
.source-line { margin: 0 0 10px; }
.sources { margin: 10px 0 0; padding-left: 20px; }
.market-side { display: grid; gap: 14px; position: sticky; top: 78px; }
@media (max-width: 900px) { .market-side { position: static; } }
.side-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; }
.side-card h3 { font-size: 1.02rem; margin-bottom: 10px; }
.side-card p { margin: 0 0 12px; }
.link-list { list-style: none; margin: 0 0 10px; padding: 0; display: grid; gap: 8px; }
.link-list li { display: flex; flex-direction: column; }
.link-list a { color: var(--ink); text-decoration-color: var(--gold); text-underline-offset: 3px; font-weight: 500; }
.ad-side { flex-direction: column; align-items: flex-start; margin: 0; }

/* ── ตลาดพระวันนี้ / รายวัน ── */
.stats a { text-decoration: none; color: inherit; }
.stats a:hover span { color: var(--gold); }
.day-tabs { display: flex; flex-wrap: wrap; gap: 6px; margin: 18px 0 6px; }
.day-tabs a { text-decoration: none; color: var(--ink); background: var(--surface); border: 1px solid var(--line); padding: 6px 14px; border-radius: 999px; font-size: .92rem; }
.day-tabs a:hover { border-color: var(--gold); color: var(--gold); }
.day-tabs a.today::after { content: " · วันนี้"; font-size: .78rem; color: var(--muted); }
.day-tabs a[aria-current="page"] { background: var(--maroon); border-color: var(--maroon); color: var(--on-accent); }
.day-tabs a[aria-current="page"]::after { color: inherit; opacity: .8; }
.jump { display: flex; flex-wrap: wrap; gap: 6px 14px; margin: 0 0 4px; font-size: .9rem; }
.h-region { font-size: 1.02rem; margin: 22px 0 10px; padding-bottom: 6px; border-bottom: 1px solid var(--line); scroll-margin-top: 72px; }
.mini-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 10px; }
.mini { display: flex; flex-direction: column; gap: 2px; padding: 12px 14px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; text-decoration: none; color: var(--ink); }
.mini:hover { border-color: var(--gold); box-shadow: var(--shadow); }
.mini b { font-weight: 600; line-height: 1.4; }
.mini-loc { font-size: .85rem; color: var(--muted); }
.mini-hours { font-size: .88rem; }
.mini .verified { margin: 6px 0 0; align-self: flex-start; }
.mini-big .mini { border-color: color-mix(in srgb, var(--gold) 55%, var(--line)); background: color-mix(in srgb, var(--gold-soft) 45%, var(--surface)); }
.big-tag { display: inline-block; font-size: .75rem; font-weight: 600; color: var(--maroon); background: var(--gold-soft); padding: 0 7px; border-radius: 6px; margin-right: 2px; }
.mini-hit { border-color: var(--green); background: var(--green-soft); }
.mini-hit .big-tag { color: var(--green); background: var(--surface); }
