/* โทนสีทั้งหมดอยู่ในตัวแปรชุดเดียว — ธีมมืดเปลี่ยนเฉพาะค่าตัวแปร */
:root {
  --bg: #f6f7f5;
  --surface: #ffffff;
  --surface-2: #f0f2ef;
  --text: #17201d;
  --muted: #5d6b66;
  --border: #dfe4e0;
  --accent: #0f766e;
  --accent-strong: #0b5e57;
  --accent-soft: #e3f3f0;
  --on-accent: #ffffff;
  --gold: #a16207;
  --warn-bg: #fff7e6;
  --warn-border: #f2d49b;
  --warn-text: #7a4b00;
  --ok: #15803d;
  --err: #b42318;
  --shadow: 0 1px 2px rgba(16, 24, 20, .05), 0 4px 16px rgba(16, 24, 20, .05);
  --radius: 14px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0e1412;
    --surface: #161e1b;
    --surface-2: #1d2724;
    --text: #e7eeeb;
    --muted: #9aaaa4;
    --border: #2a3632;
    --accent: #2dd4bf;
    --accent-strong: #5eead4;
    --accent-soft: #123631;
    --on-accent: #062b27;
    --gold: #fbbf24;
    --warn-bg: #2a2110;
    --warn-border: #5c4516;
    --warn-text: #f5d38b;
    --ok: #4ade80;
    --err: #fca5a5;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 6px 20px rgba(0, 0, 0, .25);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0e1412;
  --surface: #161e1b;
  --surface-2: #1d2724;
  --text: #e7eeeb;
  --muted: #9aaaa4;
  --border: #2a3632;
  --accent: #2dd4bf;
  --accent-strong: #5eead4;
  --accent-soft: #123631;
  --on-accent: #062b27;
  --gold: #fbbf24;
  --warn-bg: #2a2110;
  --warn-border: #5c4516;
  --warn-text: #f5d38b;
  --ok: #4ade80;
  --err: #fca5a5;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 6px 20px rgba(0, 0, 0, .25);
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Noto Sans Thai", system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 16px;
  line-height: 1.65;
}
.wrap { width: 100%; max-width: 1080px; margin: 0 auto; padding: 0 16px; }
h1, h2, h3 { line-height: 1.35; margin: 0; }
small { color: var(--muted); }

/* แถบบน */
.topbar { background: var(--surface); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 5; }
.topbar-inner { display: flex; align-items: center; justify-content: space-between; height: 56px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 600; }
.brand-logo { display: block; width: 38px; height: auto; }
.theme-btn { display: grid; place-items: center; width: 38px; height: 38px; border-radius: 10px; border: 1px solid var(--border); background: var(--surface-2); color: var(--text); cursor: pointer; }
.theme-btn .i-moon { display: none; }
:root[data-theme="dark"] .theme-btn .i-sun { display: none; }
:root[data-theme="dark"] .theme-btn .i-moon { display: block; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme-btn .i-sun { display: none; }
  :root:not([data-theme="light"]) .theme-btn .i-moon { display: block; }
}

/* ส่วนหัว */
.hero { padding: 32px 0 8px; }
/* มาสคอตอยู่ขวามือ (มือถือ: ลอยขวา ให้ข้อความไหลรอบ ไม่ดันเนื้อหาลง) */
.hero-top { display: flex; flex-direction: row-reverse; align-items: center; justify-content: space-between; gap: 24px; }
.hero-text { flex: 1 1 auto; min-width: 0; }
.hero-art { flex: none; width: 176px; }
.hero-art img { display: block; width: 100%; height: auto; filter: drop-shadow(0 8px 14px rgba(15, 60, 55, .18)); }
.hero h1 { font-size: clamp(1.35rem, 3.2vw, 1.9rem); font-weight: 700; max-width: 820px; }
.lead { color: var(--muted); max-width: 760px; margin: 10px 0 16px; }
.notice { display: flex; gap: 10px; align-items: flex-start; background: var(--warn-bg); border: 1px solid var(--warn-border); color: var(--warn-text); border-radius: 12px; padding: 12px 14px; max-width: 820px; }
.notice svg { flex: none; margin-top: 3px; }
.notice p { margin: 0; font-size: .95rem; }

/* ตัวเลขสรุป */
.stats { display: grid; grid-template-columns: 1.4fr 1fr 1fr; gap: 12px; margin: 22px 0; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.stat-label { color: var(--muted); font-size: .9rem; }
.stat-value { font-size: 1.6rem; font-weight: 700; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.stat-value small { font-size: .9rem; font-weight: 500; }
.stat-main { background: var(--accent-soft); border-color: transparent; }
.stat-main .stat-value { color: var(--accent-strong); font-size: 2rem; }

/* โครงสองคอลัมน์ */
.grid { display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); gap: 16px; align-items: start; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); min-width: 0; }
.card h2 { font-size: 1.15rem; font-weight: 700; margin-bottom: 14px; }

.step + .step { margin-top: 22px; padding-top: 20px; border-top: 1px dashed var(--border); }
.step-head { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.step-head h3 { font-size: 1rem; font-weight: 600; }
.step-no { display: grid; place-items: center; width: 26px; height: 26px; border-radius: 50%; background: var(--accent); color: var(--on-accent); font-weight: 700; font-size: .9rem; flex: none; }

.pay { display: flex; gap: 18px; align-items: center; flex-wrap: wrap; }
.qr-col { display: grid; justify-items: center; gap: 8px; width: 260px; max-width: 100%; }
.qr { margin: 0; width: 100%; aspect-ratio: 640 / 593; background: #fff; border: 1px solid var(--border); border-radius: 12px; display: grid; place-items: center; overflow: hidden; }
.qr img { width: 100%; height: 100%; object-fit: contain; display: block; }
.qr figcaption { color: #5d6b66; text-align: center; padding: 16px; font-size: .9rem; }
.qr-save { text-decoration: none; padding: 5px 14px; }
.qr-hint { text-align: center; font-size: .8rem; line-height: 1.45; }
.account { margin: 0; display: grid; gap: 8px; flex: 1 1 200px; min-width: 0; }
.account div { display: grid; gap: 0; }
.account dt { color: var(--muted); font-size: .85rem; }
.account dd { margin: 0; font-weight: 600; overflow-wrap: anywhere; }
.acc-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.acc-no { font-size: 1.25rem; letter-spacing: .03em; font-variant-numeric: tabular-nums; }

/* ฟอร์ม */
form { display: grid; gap: 12px; }
.drop { position: relative; display: grid; place-items: center; min-height: 120px; border: 1.5px dashed var(--border); border-radius: 12px; background: var(--surface-2); text-align: center; padding: 14px; cursor: pointer; transition: border-color .15s; }
.drop:hover, .drop:focus-within { border-color: var(--accent); }
.drop input { position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; }
.drop img { max-height: 180px; max-width: 100%; border-radius: 8px; }
.drop.has-file { min-height: 0; }
.field { display: grid; gap: 4px; }
.field label { font-weight: 500; font-size: .95rem; }
input[type="text"], input:not([type]), textarea {
  width: 100%; font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 9px 12px;
}
textarea { resize: vertical; min-height: 64px; }
input:focus-visible, textarea:focus-visible, button:focus-visible, .drop:focus-within { outline: 2px solid var(--accent); outline-offset: 2px; }
.check { display: flex; gap: 8px; align-items: flex-start; font-size: .95rem; cursor: pointer; }
.check input { margin-top: 5px; accent-color: var(--accent); width: 16px; height: 16px; flex: none; }
.consent { color: var(--muted); font-size: .88rem; }
.consent strong { color: var(--text); }
.turnstile:empty { display: none; }
.btn-primary { font: inherit; font-weight: 600; border: 0; border-radius: 10px; padding: 11px 18px; background: var(--accent); color: var(--on-accent); cursor: pointer; transition: background .15s; }
.btn-primary:hover { background: var(--accent-strong); }
.btn-primary:disabled { opacity: .6; cursor: progress; }
.btn-ghost { font: inherit; font-size: .85rem; border: 1px solid var(--border); background: var(--surface-2); color: var(--text); border-radius: 8px; padding: 2px 10px; cursor: pointer; }
.status { margin: 0; min-height: 1.4em; font-size: .95rem; }
.status.ok { color: var(--ok); font-weight: 600; }
.status.err { color: var(--err); }

/* กระดานรายชื่อ */
.wall-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 6px; }
.wall-head h2 { margin-bottom: 0; }
.live { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-size: .85rem; }
.live i { width: 8px; height: 8px; border-radius: 50%; background: var(--ok); box-shadow: 0 0 0 0 var(--ok); animation: pulse 2s infinite; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(21, 128, 61, .45); } 70% { box-shadow: 0 0 0 7px rgba(21, 128, 61, 0); } 100% { box-shadow: 0 0 0 0 rgba(21, 128, 61, 0); } }
.wall { list-style: none; margin: 8px 0 0; padding: 0; display: grid; gap: 2px; max-height: 640px; overflow-y: auto; }
.wall li { display: grid; grid-template-columns: 40px minmax(0, 1fr) auto; gap: 12px; align-items: center; padding: 10px 6px; border-bottom: 1px solid var(--border); }
.wall li:last-child { border-bottom: 0; }
.wall li.new { animation: flash 2.4s ease-out; border-radius: 10px; }
@keyframes flash { 0% { background: var(--accent-soft); } 100% { background: transparent; } }
.avatar { width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent-strong); font-weight: 700; }
.who { min-width: 0; }
.who .name { font-weight: 600; overflow-wrap: anywhere; }
.who .msg { color: var(--muted); font-size: .9rem; overflow-wrap: anywhere; }
.who .time { color: var(--muted); font-size: .8rem; }
.amt { font-weight: 700; font-variant-numeric: tabular-nums; color: var(--accent-strong); white-space: nowrap; }
.empty, .updated { color: var(--muted); font-size: .9rem; margin: 10px 0 0; }
.updated { font-size: .8rem; }

.foot { color: var(--muted); font-size: .85rem; padding-top: 18px; padding-bottom: 32px; }

@media (max-width: 860px) {
  .grid { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 560px) {
  .stats { grid-template-columns: 1fr 1fr; }
  .stat-main { grid-column: 1 / -1; }
  .card { padding: 16px; }
  .pay { justify-content: center; }
  .qr-col { width: min(100%, 320px); }
  .hero-top { display: block; }
  .hero-top::after { content: ""; display: block; clear: both; }
  .hero-art { float: right; width: 104px; margin: 2px 0 4px 10px; }
}
@media (prefers-reduced-motion: reduce) {
  .live i, .wall li.new { animation: none; }
}
