:root {
  --bg: #0f0f14;
  --surface: #191922;
  --surface-2: #22222e;
  --line: #2e2e3c;
  --text: #f3f3f7;
  --muted: #a3a3b5;
  --accent: #ff3d5a;
  --gold: #ffc94a;
  --silver: #d6dbe4;
  --bronze: #e39a5d;
  --kofi: #29abe0;
  --stripe: #635bff;
  --radius: 16px;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font-family: "Prompt", system-ui, -apple-system, "Segoe UI", sans-serif;
  line-height: 1.45;
}
a { color: inherit; text-decoration: none; }
img { display: block; max-width: 100%; }
.wrap { width: 100%; max-width: 1080px; margin: 0 auto; padding: 0 16px; }

/* header */
.top { position: sticky; top: 0; z-index: 10; background: rgba(15,15,20,.86); backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); }
.top-in { display: flex; align-items: center; justify-content: space-between; height: 56px; }
.logo { font-weight: 700; font-size: 20px; display: flex; align-items: center; gap: 8px; }
.logo > span:last-child { display: flex; flex-direction: column; line-height: 1.05; }
.logo sup { font-size: 10px; color: var(--gold); margin-left: 2px; vertical-align: super; }
.logo small { font-size: 11px; font-weight: 500; color: var(--muted); }
.logo-mark { width: 32px; height: 32px; flex: none; }
.updated { color: var(--muted); font-size: 12px; text-align: right; }

.demo-banner { margin-top: 12px; padding: 8px 12px; border-radius: 10px; background: #3a2d10; color: var(--gold); font-size: 13px; }

.h { font-size: 20px; margin: 24px 0 12px; font-weight: 600; }
.page-title { font-size: 22px; font-weight: 700; margin: 20px 0 6px; line-height: 1.3; }
.intro { color: var(--muted); font-size: 14px; margin: 0; }
@media (min-width: 640px) { .page-title { font-size: 28px; } }

/* top 3 cards */
/* phone: #1 full width, #2 and #3 side by side */
.top3 { display: grid; gap: 10px; grid-template-columns: 1fr 1fr; }
.top3 .r1, .top3 .empty { grid-column: 1 / -1; }
.top3 .r2 .views, .top3 .r3 .views { font-size: 17px; }
.top3 .r2 .card-body, .top3 .r3 .card-body { padding: 10px; }
.top3 .r2 .title, .top3 .r3 .title { font-size: 12px; }
@media (min-width: 640px) {
  .top3 { grid-template-columns: repeat(3, 1fr); gap: 16px; }
  .top3 .r1 { grid-column: auto; }
  .top3 .r2 .views, .top3 .r3 .views { font-size: 22px; }
  .top3 .r2 .title, .top3 .r3 .title { font-size: 14px; }
}

.card {
  background: var(--surface); border-radius: var(--radius); overflow: hidden;
  border: 1px solid var(--line); transition: transform .15s ease, border-color .15s ease;
  display: flex; flex-direction: column;
}
.card:hover, .card:focus-visible { transform: translateY(-3px); border-color: var(--accent); outline: none; }
.card:active { transform: scale(.98); }
.thumb { position: relative; aspect-ratio: 16 / 9; background: var(--surface-2); }
.thumb img { width: 100%; height: 100%; object-fit: cover; }
.play { position: absolute; inset: 0; display: grid; place-items: center; opacity: 0; transition: opacity .15s; background: rgba(0,0,0,.25); font-size: 40px; }
.card:hover .play { opacity: 1; }
.badge {
  position: absolute; top: 10px; left: 10px; min-width: 36px; height: 36px; padding: 0 8px;
  border-radius: 10px; display: grid; place-items: center; font-weight: 700; color: #111;
  background: var(--silver); box-shadow: 0 2px 8px rgba(0,0,0,.4);
}
.r1 .badge { background: var(--gold); }
.r2 .badge { background: var(--silver); }
.r3 .badge { background: var(--bronze); }
.card-body { padding: 12px 14px 14px; display: flex; flex-direction: column; gap: 4px; }
.views { font-size: 22px; font-weight: 700; }
.views small { font-size: 13px; font-weight: 500; color: var(--muted); margin-left: 4px; }
.title { font-size: 14px; color: var(--muted); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

/* chips */
.cat-section { margin-top: 8px; }
/* chips wrap onto several lines so every category is visible (a single scrolling row hid the
   later categories off-screen once there were 14) */
.chips { display: flex; flex-wrap: wrap; gap: 8px; padding-bottom: 6px; }
@media (max-width: 599px) { .chips { gap: 6px; } .chips .chip { padding: 8px 12px; font-size: 13px; min-height: 40px; } }
.chip {
  flex: none; border: 1px solid var(--line); background: var(--surface);
  color: var(--text); padding: 10px 16px; border-radius: 999px; font: inherit; font-size: 14px; cursor: pointer; min-height: 44px;
}
.chip[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); font-weight: 600; }

/* ranking list */
.ranking { margin-top: 16px; display: flex; flex-direction: column; gap: 10px; }
.row {
  display: grid; grid-template-columns: 32px 120px 1fr; gap: 12px; align-items: center;
  background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 10px;
  transition: border-color .15s;
}
a.row:hover, a.row:focus-visible { border-color: var(--accent); outline: none; }
.row .n { font-size: 20px; font-weight: 700; text-align: center; color: var(--muted); }
.row.r1 .n { color: var(--gold); } .row.r2 .n { color: var(--silver); } .row.r3 .n { color: var(--bronze); }
.row .t { aspect-ratio: 16/9; border-radius: 8px; overflow: hidden; background: var(--surface-2); }
.row .t img { width: 100%; height: 100%; object-fit: cover; }
.row .meta { min-width: 0; }
.row .v { font-weight: 700; font-size: 17px; }
.row .v small { color: var(--muted); font-weight: 500; font-size: 12px; margin-left: 3px; }
.row .v .gain { color: #7ee2a8; }
.row .v small.total { font-weight: 400; }
.note { margin: 0 0 2px; font-size: 13px; color: var(--muted); }
.row .tt { font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
@media (min-width: 640px) { .row { grid-template-columns: 44px 168px 1fr; padding: 12px; } .row .tt { white-space: normal; } }

/* locked */
.locked { position: relative; display: flex; flex-direction: column; gap: 10px; }
.locked .row { filter: blur(5px); opacity: .55; pointer-events: none; user-select: none; }
.locked .row .t { background: linear-gradient(135deg, #2a2a38, #3a3a4c); }
.bar { height: 12px; border-radius: 6px; background: #3a3a4c; margin: 4px 0; }
.unlock {
  position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: flex-start;
  gap: 10px; text-align: center; padding: 48px 16px 16px;
  background: linear-gradient(180deg, rgba(15,15,20,0) 0%, rgba(15,15,20,.75) 35%, rgba(15,15,20,.9) 100%);
}
.unlock h3 { margin: 0; font-size: 18px; }
.unlock p { margin: 0; color: var(--muted); font-size: 14px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 48px; padding: 0 20px;
  border-radius: 12px; border: 0; font: inherit; font-weight: 600; font-size: 15px; cursor: pointer; color: #fff;
}
.btn.primary { background: var(--accent); }
.btn.kofi { background: var(--kofi); }
.btn.stripe { background: var(--stripe); }
.btn:active { transform: scale(.98); }
.btn[disabled] { opacity: .6; cursor: wait; }

.empty { color: var(--muted); padding: 24px; text-align: center; background: var(--surface); border-radius: 14px; }
.skel { background: linear-gradient(90deg, var(--surface) 0%, var(--surface-2) 50%, var(--surface) 100%); background-size: 200% 100%; animation: sh 1.2s infinite; border-radius: var(--radius); }
@keyframes sh { to { background-position: -200% 0; } }

/* donate sheet: bottom sheet on phones, centered modal on desktop */
.sheet {
  border: 1px solid var(--line); background: var(--surface); color: var(--text);
  width: 100%; max-width: 440px; border-radius: 20px; padding: 24px 20px calc(20px + env(safe-area-inset-bottom));
}
.sheet::backdrop { background: rgba(0,0,0,.6); }
@media (max-width: 639px) {
  .sheet { margin: auto 0 0; max-width: none; border-radius: 20px 20px 0 0; }
}
.sheet h3 { margin: 0 0 4px; font-size: 20px; }
.sheet-close { position: absolute; top: 10px; right: 10px; margin: 0; }
.sheet-close button { background: var(--surface-2); color: var(--text); border: 0; width: 36px; height: 36px; border-radius: 50%; cursor: pointer; font-size: 14px; }
.muted { color: var(--muted); margin: 0 0 16px; font-size: 14px; }
.field { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--muted); }
.field input {
  font: inherit; font-size: 16px; color: var(--text); background: var(--bg); border: 1px solid var(--line);
  border-radius: 12px; padding: 12px 14px; min-height: 48px;
}
.field input:focus { outline: 2px solid var(--accent); border-color: transparent; }
.pay { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 14px 0 10px; }
.pay .btn { padding: 0 10px; font-size: 14px; }
.hint { font-size: 12px; color: var(--muted); margin: 0 0 10px; }
.sheet .btn.primary { width: 100%; }
.msg { min-height: 20px; font-size: 14px; margin: 10px 0 0; text-align: center; }
.msg.err { color: #ff8a9b; } .msg.ok { color: #7ee2a8; }

.foot { color: var(--muted); font-size: 12px; text-align: center; padding: 32px 16px 40px; }
.foot a { color: var(--text); text-decoration: underline; text-underline-offset: 3px; }
.site-stats { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; max-width: 520px; margin: 18px auto 0; }
.site-stats[hidden] { display: none; }
.site-stats::before { content: "📊 สถิติการเข้าชม"; grid-column: 1 / -1; font-size: 13px; color: var(--text); }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; font-size: 12px; }
.stat b { display: block; font-size: 18px; color: var(--text); font-weight: 600; }
@media (min-width: 640px) { .site-stats { grid-template-columns: repeat(4, minmax(0, 1fr)); } }

/* header nav link + contact page */
.top-right { display: flex; flex-direction: column; align-items: flex-end; gap: 2px; }
.nav-link { font-size: 13px; color: var(--text); padding: 6px 10px; border: 1px solid var(--line); border-radius: 999px; white-space: nowrap; }
.nav-link:hover { border-color: var(--accent); }
.contact { max-width: 640px; }
.lead { color: var(--muted); margin: 0 0 16px; }
.contact-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; display: flex; flex-direction: column; gap: 6px; }
.contact-label { font-size: 13px; color: var(--muted); }
.contact-email { font-size: 20px; font-weight: 600; color: var(--gold); word-break: break-all; }
.contact-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 10px; }
.btn.ghost { background: transparent; border: 1px solid var(--line); color: var(--text); }
.topics { margin: 0; padding-left: 20px; display: flex; flex-direction: column; gap: 10px; color: var(--muted); font-size: 14px; }
.topics b { color: var(--text); font-weight: 600; }
.muted-note { color: var(--muted); font-size: 13px; margin-top: 16px; }
