/* ---------- base ---------- */
:root {
  --ink: #2b2118; --muted: #7a6a5c; --line: #eadfd2; --bg: #fff8f0; --card: #ffffff;
  --brand: #d2462f; --brand-dark: #a93421; --gold: #e6a817; --ok: #2e7d32; --bad: #c62828; --warn: #ef8f00;
  --radius: 16px;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font-family: 'Sarabun', system-ui, sans-serif; font-size: 17px; line-height: 1.6; color: var(--ink); background: var(--bg); }
h1, h2, h3 { font-family: 'Kanit', 'Sarabun', sans-serif; font-weight: 600; line-height: 1.3; margin: 0 0 .6em; }
h1 { font-size: 1.7rem; } h2 { font-size: 1.3rem; } h3 { font-size: 1.08rem; margin-top: 1.2em; }
a { color: var(--brand-dark); }
img { max-width: 100%; }
code { background: #f6efe6; padding: 1px 6px; border-radius: 6px; }
.muted { color: var(--muted); } .small { font-size: .88rem; } .center { text-align: center; } .err { color: var(--bad); }
[hidden] { display: none !important; }

.btn { display: inline-block; border: 0; border-radius: 999px; padding: .6em 1.4em; background: var(--brand); color: #fff; font: 600 1rem 'Kanit', sans-serif;
  text-decoration: none; cursor: pointer; transition: transform .1s, background .2s; text-align: center; }
.btn:hover { background: var(--brand-dark); } .btn:active { transform: scale(.97); }
.btn:disabled { opacity: .6; cursor: wait; }
.btn-big { font-size: 1.15rem; padding: .8em 1.8em; box-shadow: 0 6px 18px rgba(210, 70, 47, .3); }
.btn-ghost { background: transparent; color: var(--brand-dark); box-shadow: inset 0 0 0 2px var(--brand); }
.btn-ghost:hover { background: #fdeee9; }
.btn-danger { background: var(--bad); } .btn.small { font-size: .88rem; padding: .35em 1em; }
.linkbtn { background: none; border: 0; color: inherit; text-decoration: underline; cursor: pointer; font: inherit; padding: 0; }
form.inline { display: inline; }

.form label { display: block; margin: .7em 0; font-weight: 600; }
.form input:not([type=checkbox]):not([type=radio]):not([type=file]):not([type=range]), .form select, .form textarea, .filters input, .filters select {
  display: block; width: 100%; margin-top: .3em; padding: .6em .8em; border: 1.5px solid var(--line); border-radius: 10px;
  font: 400 1rem 'Sarabun', sans-serif; background: #fff; color: var(--ink); }
.form input:focus, .form select:focus, .form textarea:focus { outline: 0; border-color: var(--brand); box-shadow: 0 0 0 3px rgba(210, 70, 47, .15); }
.form input[type=file] { display: block; margin-top: .4em; font: inherit; max-width: 100%; }
.form label.check, label.check { display: flex; gap: .6em; align-items: flex-start; font-weight: 400; }
label.check input { margin-top: .35em; width: 1.15em; height: 1.15em; flex: none; accent-color: var(--brand); }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 1em; }
.hint { color: var(--muted); font-size: .9rem; margin: .2em 0 .8em; }
.req { color: var(--bad); }
.error { background: #fdecea; color: var(--bad); padding: .8em 1em; border-radius: 10px; font-weight: 600; }
.notice { background: #fff4d6; border-radius: 12px; padding: .9em 1.1em; }
.notice.ok { background: #e8f5e9; } .notice.bad { background: #fdecea; }
.preview { display: block; max-height: 220px; border-radius: 10px; margin: .3em 0 1em; box-shadow: 0 2px 8px rgba(0,0,0,.15); }
.preview.round { width: 160px; height: 160px; object-fit: cover; border-radius: 50%; }

/* ---------- public ---------- */
body.pub { background: radial-gradient(circle at 10% 0%, #ffe9cc 0, transparent 40%), radial-gradient(circle at 100% 20%, #ffe0e6 0, transparent 35%), var(--bg); }
.pub-head { padding: .8em 1em; }
.brand { display: inline-flex; align-items: center; gap: .7em; text-decoration: none; color: var(--ink); }
.brand b { display: block; font-family: 'Kanit', sans-serif; font-weight: 600; font-size: 1.05rem; line-height: 1.2; }
.brand small { color: var(--muted); }
.logo { width: 48px; height: 48px; border-radius: 50%; object-fit: cover; background: #fff; }
.logo-ph { font-size: 2rem; }
.pub-main { max-width: 860px; margin: 0 auto; padding: 0 16px 40px; }
.pub-main.narrow { max-width: 680px; } .pub-main.wide { max-width: 1180px; }
.box { background: var(--card); border-radius: var(--radius); padding: 1.3em 1.4em; margin: 1.2em 0; box-shadow: 0 4px 22px rgba(120, 70, 30, .08); }
.form.box h2 { margin-top: 1.4em; padding-top: 1em; border-top: 1px dashed var(--line); }
.form.box h2:first-child { margin-top: 0; padding-top: 0; border-top: 0; }
.hero { text-align: center; padding: 1.5em 0 .5em; }
.hero h1 { font-size: 2.3rem; font-weight: 800; color: var(--brand-dark); }
.hero .lead { font-size: 1.12rem; max-width: 640px; margin: 0 auto 1.2em; }
.cover { width: 100%; max-height: 360px; object-fit: cover; border-radius: var(--radius); margin-bottom: 1em; }
.progress-card { background: #fff; border-radius: var(--radius); padding: 1.1em 1.3em; max-width: 520px; margin: 0 auto 1.4em; box-shadow: 0 4px 22px rgba(120, 70, 30, .1); }
.progress-card .big { font: 800 2.4rem 'Kanit', sans-serif; color: var(--brand); line-height: 1.1; }
progress.bar { display: block; width: 100%; height: 14px; margin-top: .7em; border: 0; border-radius: 99px; background: #f3e6d8; overflow: hidden; appearance: none; -webkit-appearance: none; }
progress.bar::-webkit-progress-bar { background: #f3e6d8; border-radius: 99px; }
progress.bar::-webkit-progress-value { background: linear-gradient(90deg, var(--gold), var(--brand)); border-radius: 99px; }
progress.bar::-moz-progress-bar { background: linear-gradient(90deg, var(--gold), var(--brand)); border-radius: 99px; }
.bar-legend { display: flex; justify-content: space-between; font-size: .9rem; color: var(--muted); }
.steps { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(4, 1fr); gap: .8em; counter-reset: s; }
.steps li { background: #fff7ef; border-radius: 12px; padding: .9em .8em; text-align: center; counter-increment: s; }
.steps li::before { content: counter(s); display: grid; place-items: center; width: 2em; height: 2em; margin: 0 auto .3em; border-radius: 50%; background: var(--brand); color: #fff; font: 600 1rem 'Kanit'; }
.steps b { display: block; font-family: 'Kanit', sans-serif; font-weight: 600; } .steps span { font-size: .9rem; color: var(--muted); }
.pay { display: flex; flex-wrap: wrap; gap: 1.2em; align-items: center; justify-content: center; }
.payqr { width: 260px; border-radius: 12px; border: 1px solid var(--line); background: #fff; }
.bank { display: grid; grid-template-columns: auto 1fr; gap: .2em 1em; margin: 0; }
.bank dt { color: var(--muted); } .bank dd { margin: 0; font-weight: 600; } .bank .acct { font-size: 1.3rem; letter-spacing: .05em; }
.wall { list-style: none; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: .5em; justify-content: center; }
.wall li { background: linear-gradient(135deg, #fff3e0, #ffe8ee); border-radius: 999px; padding: .35em 1em; display: inline-flex; gap: .45em; align-items: baseline; }
.wall .heart { color: #e91e63; } .wall .amt { color: var(--brand-dark); font-size: .9rem; }
.hashtag { font: 600 1.2rem 'Kanit', sans-serif; color: var(--brand); }
.pub-foot { text-align: center; padding: 1.5em 16px 2.5em; color: var(--muted); font-size: .9rem; }
.pub-foot p { margin: .2em 0; }
.linkbox { display: flex; gap: .5em; margin-top: .6em; } .linkbox input { flex: 1; min-width: 0; padding: .45em .7em; border: 1px solid var(--line); border-radius: 8px; font: inherit; }

.my-head { display: flex; flex-wrap: wrap; gap: .6em; align-items: center; margin: 1em 0; } .my-head h1 { margin: 0; }
.badge { display: inline-block; padding: .2em .8em; border-radius: 99px; font-size: .9rem; font-weight: 600; }
.b-pending { background: #fff4d6; color: #8a5a00; } .b-ok { background: #e8f5e9; color: var(--ok); } .b-bad { background: #fdecea; color: var(--bad); }

/* ---------- card editor ---------- */
.editor { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(300px, 1fr); gap: 1.5em; align-items: start; }
.canvas-wrap { position: sticky; top: 12px; }
#card { display: block; width: 100%; height: auto; border-radius: 14px; box-shadow: 0 10px 40px rgba(60, 30, 10, .25); background: #fff; touch-action: none; cursor: grab; }
#card.story { width: auto; max-width: 100%; max-height: 82vh; margin: 0 auto; }
.controls { background: #fff; border-radius: var(--radius); padding: 1.1em 1.3em; box-shadow: 0 4px 22px rgba(120, 70, 30, .08); }
.controls h3:first-of-type { margin-top: .8em; }
.controls label { display: block; font-weight: 600; margin: .5em 0; }
.controls input:not([type=checkbox]):not([type=range]) { display: block; width: 100%; margin-top: .3em; padding: .5em .7em; border: 1.5px solid var(--line); border-radius: 10px; font: inherit; }
.seg { display: inline-flex; background: #f6efe6; border-radius: 99px; padding: 4px; }
.seg button { border: 0; background: none; padding: .4em 1em; border-radius: 99px; font: 600 .95rem 'Kanit', sans-serif; cursor: pointer; color: var(--muted); }
.seg button.on { background: #fff; color: var(--brand-dark); box-shadow: 0 1px 4px rgba(0,0,0,.12); }
.frames { display: grid; grid-template-columns: repeat(5, 1fr); gap: .5em; }
.frame-btn { border: 2px solid transparent; background: none; padding: 3px; border-radius: 12px; cursor: pointer; text-align: center; font: 400 .75rem 'Sarabun', sans-serif; color: var(--ink); }
.frame-btn canvas { display: block; width: 100%; aspect-ratio: 1; border-radius: 8px; box-shadow: 0 1px 5px rgba(0,0,0,.18); }
.frame-btn span { display: block; margin-top: 3px; line-height: 1.2; }
.frame-btn.on { border-color: var(--brand); background: #fdeee9; }
.chips { display: flex; flex-wrap: wrap; gap: .4em; }
.chip { border: 1.5px solid var(--line); background: #fff; border-radius: 99px; padding: .3em .9em; cursor: pointer; font: 400 .95rem 'Sarabun', sans-serif; color: var(--ink); }
.chip.on { border-color: var(--brand); background: var(--brand); color: #fff; }
.photo-ctl { display: flex; gap: .5em; flex-wrap: wrap; }
.photo-ctl label.btn { margin: 0; font-weight: 600; }
.range { display: flex !important; align-items: center; gap: .6em; } .range input { flex: 1; accent-color: var(--brand); }
.actions { display: flex; gap: .6em; flex-wrap: wrap; margin-top: 1em; }

/* ---------- back office ---------- */
body.adm { background: #f5f6f8; font-size: 16px; }
.adm-head { display: flex; flex-wrap: wrap; align-items: center; gap: .5em 1.5em; padding: .6em 1.2em; background: #2b2118; color: #fff; }
.adm-head a { color: #fff; text-decoration: none; }
.adm-brand { font: 600 1.05rem 'Kanit', sans-serif; }
.adm-head nav { display: flex; flex-wrap: wrap; gap: .2em; flex: 1; }
.adm-head nav a { padding: .35em .8em; border-radius: 8px; opacity: .8; } .adm-head nav a.on, .adm-head nav a:hover { background: rgba(255,255,255,.14); opacity: 1; }
.who { display: flex; gap: 1em; align-items: center; font-size: .92rem; }
.adm-main { max-width: 1240px; margin: 0 auto; padding: 1.2em 16px 3em; }
.adm .box { box-shadow: 0 1px 4px rgba(0,0,0,.06); border-radius: 12px; }
.narrow-box { max-width: 520px; }
.flash { background: #e8f5e9; border-radius: 10px; padding: .7em 1em; } .flash.err { background: #fdecea; color: var(--bad); }
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: .8em; margin-bottom: 1em; }
.tile { background: #fff; border-radius: 12px; padding: .9em 1em; text-decoration: none; color: var(--ink); box-shadow: 0 1px 4px rgba(0,0,0,.06); border-left: 5px solid var(--ok); }
.tile.warn { border-left-color: var(--warn); }
.tile span { display: block; color: var(--muted); font-size: .9rem; } .tile b { font: 600 1.5rem 'Kanit', sans-serif; } .tile small { font-size: .8rem; color: var(--muted); }
.table-wrap { overflow-x: auto; background: #fff; border-radius: 12px; box-shadow: 0 1px 4px rgba(0,0,0,.06); }
table.list { width: 100%; border-collapse: collapse; font-size: .94rem; }
table.list th, table.list td { padding: .55em .7em; border-bottom: 1px solid #eee; text-align: left; vertical-align: middle; white-space: nowrap; }
table.list th { background: #faf7f3; font-weight: 600; }
table.list .num { text-align: right; }
table.list tr:hover td { background: #fffaf3; }
.pill { display: inline-block; padding: .1em .65em; border-radius: 99px; font-size: .82rem; font-weight: 600; }
.p-pending { background: #fff4d6; color: #8a5a00; } .p-verified { background: #e8f5e9; color: var(--ok); } .p-rejected { background: #fdecea; color: var(--bad); }
.filters { display: flex; flex-wrap: wrap; gap: .5em; margin: .8em 0; align-items: center; }
.filters input { flex: 1 1 260px; width: auto; margin: 0; } .filters select { width: auto; margin: 0; }
.pager { text-align: center; margin: 1em 0; }
.detail { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); gap: 1.2em; align-items: start; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: .3em 1em; margin: 0; } .kv dt { color: var(--muted); } .kv dd { margin: 0; }
.slip { display: block; max-height: 640px; margin: 0 auto; border-radius: 8px; border: 1px solid #eee; }
.donor-photo { width: 220px; height: 220px; object-fit: cover; border-radius: 50%; }
.btnrow { display: flex; gap: .5em; flex-wrap: wrap; align-items: center; }
.howto { margin: 0 0 1em; padding-left: 1.3em; }
.upls { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 1em; }
.upl { border: 1px dashed #ddd; border-radius: 10px; padding: .8em; text-align: center; }
.upl b { display: block; margin-bottom: .4em; } .upl img { max-height: 140px; display: block; margin: 0 auto .5em; }
.qr-mini { width: 120px; vertical-align: middle; border: 1px solid #eee; border-radius: 6px; }
code.pw { font-size: 1.15rem; padding: .2em .6em; user-select: all; }
.cardgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 1em; }
.cardtile { background: #fff; border-radius: 12px; padding: .7em; box-shadow: 0 1px 4px rgba(0,0,0,.08); display: flex; flex-direction: column; gap: .5em; }
.cardtile img { display: block; width: 100%; aspect-ratio: 1; object-fit: contain; background: #f3f0ec; border-radius: 8px; }
.cardtile .nocard { display: grid; place-content: center; gap: .4em; aspect-ratio: 1; background: #f7f2ec; border-radius: 8px; text-align: center; text-decoration: none; color: var(--muted); padding: 1em; }
.cardtile .nocard b { color: var(--brand-dark); }
.cardtile .meta { line-height: 1.9; }
#cards-msg { white-space: pre-line; }
#editor-msg { white-space: pre-line; }
.login-box { max-width: 380px; margin: 10vh auto; background: #fff; padding: 2em; border-radius: 16px; box-shadow: 0 4px 24px rgba(0,0,0,.08); }

/* ---------- small screens ---------- */
@media (max-width: 820px) {
  .editor, .detail { grid-template-columns: 1fr; }
  .canvas-wrap { position: static; }
  .steps { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 560px) {
  body { font-size: 16px; }
  .row2 { grid-template-columns: 1fr; }
  .hero h1 { font-size: 1.8rem; }
  .frames { grid-template-columns: repeat(4, 1fr); }
  .box { padding: 1.1em 1em; }
  .payqr { width: 220px; }
}
