:root {
  --bg: #faf6ee;
  --bg2: #f3ecdf;
  --card: #fffdf9;
  --text: #3a3128;
  --muted: #8b7e6f;
  --line: #ebe2d2;
  --gold: #b48a52;
  --gold-d: #8e6a3a;
  --gold-l: #f1e5cf;
  --ok: #4f7a52;
  --bad: #b0473a;
  --radius: 18px;
  --serif: 'Cormorant Garamond', 'Noto Serif Thai', Georgia, serif;
  --sans: 'Noto Sans Thai', 'Prompt', system-ui, sans-serif;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font-family: var(--sans); font-size: 16px; line-height: 1.6; min-height: 100vh; display: flex; flex-direction: column; }
main { flex: 1; }
a { color: var(--gold-d); }
img { max-width: 100%; display: block; }
h1, h2, h3 { font-family: var(--serif); font-weight: 600; line-height: 1.2; margin: 0 0 .4em; letter-spacing: .01em; }
h1 { font-size: clamp(2rem, 6vw, 3.2rem); }
h2 { font-size: 1.6rem; }
.wrap { max-width: 1120px; margin: 0 auto; padding: 0 16px; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: .88rem; }
.center { text-align: center; }

/* header */
.top { padding: 14px 0; border-bottom: 1px solid var(--line); background: rgba(250, 246, 238, .9); backdrop-filter: blur(8px); position: sticky; top: 0; z-index: 20; }
.top .wrap { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.logo { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--text); font-family: var(--serif); font-size: 1.35rem; font-weight: 600; }
.logo i { color: var(--gold); font-style: italic; }
.logo .mark { width: 34px; height: 34px; border-radius: 50%; border: 1.5px solid var(--gold); color: var(--gold); display: grid; place-items: center; font-size: 1.1rem; }
.foot { padding: 28px 0; color: var(--muted); font-size: .85rem; text-align: center; border-top: 1px solid var(--line); margin-top: 48px; }

/* buttons & inputs */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 0; border-radius: 999px; padding: 12px 22px; background: var(--gold); color: #fff; font: 600 1rem var(--sans); cursor: pointer; text-decoration: none; transition: background .15s, transform .1s; }
.btn:hover { background: var(--gold-d); }
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .5; cursor: default; }
.btn.ghost { background: transparent; color: var(--gold-d); border: 1.5px solid var(--gold); }
.btn.ghost:hover { background: var(--gold-l); }
.btn.light { background: var(--card); color: var(--text); border: 1px solid var(--line); }
.btn.danger { background: transparent; color: var(--bad); border: 1.5px solid var(--bad); }
.btn.sm { padding: 7px 14px; font-size: .88rem; }
.btn.big { padding: 16px 28px; font-size: 1.1rem; width: 100%; }
input, select, textarea { width: 100%; padding: 11px 14px; border: 1px solid var(--line); border-radius: 12px; background: #fff; font: inherit; color: var(--text); }
input:focus, select:focus { outline: 2px solid var(--gold-l); border-color: var(--gold); }
label { display: block; font-size: .9rem; color: var(--muted); margin: 10px 0 4px; }
.row { display: flex; gap: 12px; flex-wrap: wrap; }
.row > * { flex: 1 1 200px; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; }
.notice { background: var(--gold-l); border-radius: 12px; padding: 10px 14px; font-size: .92rem; }
.status { font-size: .92rem; color: var(--muted); margin-top: 8px; }
.pill { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: .8rem; background: var(--bg2); color: var(--muted); }
.pill.ok { background: #e3eee1; color: var(--ok); }
.pill.off { background: #f3e1de; color: var(--bad); }

/* home */
.intro { text-align: center; padding: 48px 0 28px; }
.intro .eyebrow { letter-spacing: .25em; text-transform: uppercase; font-size: .78rem; color: var(--gold); }
.intro p { max-width: 560px; margin: 8px auto 0; color: var(--muted); }
.steps { display: flex; justify-content: center; gap: 22px; flex-wrap: wrap; margin: 22px 0 6px; font-size: .92rem; }
.steps span b { display: inline-grid; place-items: center; width: 26px; height: 26px; border-radius: 50%; background: var(--gold-l); color: var(--gold-d); margin-right: 6px; font-size: .85rem; }
.search-ev { max-width: 420px; margin: 18px auto 26px; }
.events { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 20px; }
.ev-card { display: block; text-decoration: none; color: inherit; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; transition: transform .2s, box-shadow .2s; }
.ev-card:hover { transform: translateY(-3px); box-shadow: 0 12px 30px rgba(90, 64, 30, .1); }
.ev-card .cv { aspect-ratio: 4/3; background: linear-gradient(135deg, var(--gold-l), var(--bg2)); background-size: cover; background-position: center; display: grid; place-items: center; font-family: var(--serif); font-size: 2.6rem; color: var(--gold); }
.ev-card .bd { padding: 14px 16px 16px; }
.ev-card h3 { font-size: 1.35rem; margin: 0 0 2px; }
.ev-card .meta { color: var(--muted); font-size: .88rem; }

/* event page */
.ev-hero { position: relative; min-height: 46vh; display: flex; align-items: flex-end; background: linear-gradient(135deg, #e9dcc3, #f6efe2); background-size: cover; background-position: center; }
.ev-hero::after { content: ''; position: absolute; inset: 0; background: linear-gradient(180deg, rgba(40, 30, 18, 0) 30%, rgba(40, 30, 18, .7) 100%); }
.ev-hero.nocover::after { background: none; }
.ev-hero .wrap { position: relative; z-index: 1; width: 100%; padding-bottom: 26px; color: #fff; }
.ev-hero.nocover .wrap { color: var(--text); }
.ev-hero h1 { margin: 0; text-shadow: 0 2px 16px rgba(0, 0, 0, .25); }
.ev-hero.nocover h1 { text-shadow: none; }
.ev-hero .meta { opacity: .92; }
.scan-card { max-width: 520px; margin: -28px auto 0; position: relative; z-index: 2; text-align: center; box-shadow: 0 14px 40px rgba(90, 64, 30, .12); }
.scan-card .selfie { width: 96px; height: 96px; border-radius: 50%; object-fit: cover; margin: 0 auto 10px; border: 3px solid var(--gold-l); }
.scan-card .btns { display: grid; gap: 10px; margin-top: 14px; }
.privacy { font-size: .8rem; color: var(--muted); margin-top: 12px; }
.spinner { width: 34px; height: 34px; border-radius: 50%; border: 3px solid var(--gold-l); border-top-color: var(--gold); animation: spin 1s linear infinite; margin: 10px auto; }
@keyframes spin { to { transform: rotate(360deg); } }

.res-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin: 30px 0 12px; }
.res-head h2 { margin: 0; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
@media (max-width: 520px) { .grid { grid-template-columns: repeat(3, 1fr); gap: 4px; } }
.ph { position: relative; aspect-ratio: 1; overflow: hidden; border-radius: 10px; background: var(--bg2); cursor: pointer; }
.ph img { width: 100%; height: 100%; object-fit: cover; transition: transform .25s; }
.ph:hover img { transform: scale(1.04); }
.ph .badge { position: absolute; left: 6px; top: 6px; background: rgba(176, 120, 40, .92); color: #fff; font-size: .72rem; padding: 1px 8px; border-radius: 999px; }
.ph .badge.new { background: var(--ok); }
.ph .tick { position: absolute; right: 6px; top: 6px; width: 26px; height: 26px; border-radius: 50%; border: 2px solid #fff; background: rgba(0, 0, 0, .25); color: transparent; display: none; place-items: center; font-size: .9rem; }
.selecting .ph .tick { display: grid; }
.ph.sel .tick { background: var(--gold); color: #fff; }
.ph.sel img { opacity: .8; }
.sub-h { margin: 26px 0 8px; font-size: 1.15rem; }

.newbar { position: fixed; top: 70px; left: 50%; transform: translateX(-50%); z-index: 40; background: var(--ok); color: #fff; border-radius: 999px; padding: 10px 20px; box-shadow: 0 8px 24px rgba(0, 0, 0, .18); cursor: pointer; font-weight: 600; white-space: nowrap; }

.selbar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; background: var(--card); border-top: 1px solid var(--line); padding: 12px 0 calc(12px + env(safe-area-inset-bottom)); box-shadow: 0 -8px 24px rgba(90, 64, 30, .08); }
.selbar .wrap { display: flex; align-items: center; justify-content: space-between; gap: 10px; }

/* lightbox */
.lb { position: fixed; inset: 0; z-index: 60; background: #16120d; display: flex; flex-direction: column; }
.lb .lb-img { flex: 1; display: grid; place-items: center; min-height: 0; padding: 10px; }
.lb .lb-img img { max-width: 100%; max-height: 100%; object-fit: contain; border-radius: 6px; }
.lb .lb-bar { display: flex; justify-content: center; align-items: center; gap: 10px; padding: 12px 16px calc(14px + env(safe-area-inset-bottom)); flex-wrap: wrap; }
.lb .nav { position: absolute; top: 50%; transform: translateY(-50%); background: rgba(255, 255, 255, .12); color: #fff; border: 0; width: 46px; height: 46px; border-radius: 50%; font-size: 1.4rem; cursor: pointer; }
.lb .nav.l { left: 10px; } .lb .nav.r { right: 10px; }
.lb .x { position: absolute; top: 12px; right: 14px; background: rgba(255, 255, 255, .12); color: #fff; border: 0; width: 40px; height: 40px; border-radius: 50%; font-size: 1.1rem; cursor: pointer; z-index: 2; }
.lb .count { color: #d8cbb6; font-size: .85rem; }

/* modal */
.modal-bg { position: fixed; inset: 0; z-index: 70; background: rgba(40, 30, 18, .45); display: grid; place-items: center; padding: 16px; overflow-y: auto; }
.modal { background: var(--card); border-radius: var(--radius); padding: 24px; width: 100%; max-width: 460px; position: relative; max-height: calc(100vh - 32px); overflow-y: auto; }
.modal.wide { max-width: 760px; }
.modal-x { position: absolute; top: 10px; right: 12px; border: 0; background: none; font-size: 1.2rem; cursor: pointer; color: var(--muted); }
.modal .actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 18px; flex-wrap: wrap; }

/* admin */
.admin-h { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin: 26px 0 16px; }
.admin-ev { display: grid; grid-template-columns: 120px 1fr auto; gap: 16px; align-items: center; padding: 14px; }
.admin-ev + .admin-ev { margin-top: 12px; }
.admin-ev .cv { width: 120px; aspect-ratio: 4/3; border-radius: 10px; background: var(--bg2) center/cover; }
.admin-ev .acts { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
@media (max-width: 640px) { .admin-ev { grid-template-columns: 90px 1fr; } .admin-ev .cv { width: 90px; } .admin-ev .acts { grid-column: 1 / -1; justify-content: flex-start; } }
.drop { border: 2px dashed var(--gold); border-radius: var(--radius); padding: 28px 16px; text-align: center; cursor: pointer; background: #fffcf6; transition: background .15s; }
.drop.over, .drop:hover { background: var(--gold-l); }
.progress { height: 10px; background: var(--bg2); border-radius: 999px; overflow: hidden; }
.progress > div { height: 100%; width: 0; background: var(--gold); transition: width .2s; }
.stats { display: flex; gap: 18px; flex-wrap: wrap; color: var(--muted); font-size: .9rem; }
.stats b { color: var(--text); font-size: 1.05rem; }
.folder-live { display: flex; align-items: center; gap: 10px; }
.dot { width: 10px; height: 10px; border-radius: 50%; background: var(--ok); box-shadow: 0 0 0 0 rgba(79, 122, 82, .6); animation: pulse 1.6s infinite; flex: 0 0 auto; }
@keyframes pulse { 70% { box-shadow: 0 0 0 10px rgba(79, 122, 82, 0); } 100% { box-shadow: 0 0 0 0 rgba(79, 122, 82, 0); } }
.admin-grid { grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); }
.admin-grid .ph .fc { position: absolute; left: 4px; bottom: 4px; background: rgba(0, 0, 0, .55); color: #fff; font-size: .7rem; padding: 0 6px; border-radius: 6px; }
.qr-box { text-align: center; }
.qr-box canvas { max-width: 100%; height: auto; border-radius: 12px; border: 1px solid var(--line); }
.cover-pick { display: flex; gap: 12px; align-items: center; }
.cover-pick .cv { width: 110px; aspect-ratio: 4/3; border-radius: 10px; background: var(--bg2) center/cover; flex: 0 0 auto; display: grid; place-items: center; color: var(--muted); font-size: .8rem; }
.res-head .row > *, .admin-h .row > * { flex: 0 0 auto; }
