:root {
  --bg: #fff; --ink: #000; --sub: #555; --mute: #8f8f8f; --line: #e5e5e5; --card: #f7f7f7;
  --blue: #2189ff; --navy: #1428a0; --ok: #1428a0; --maybe: #8f8f8f; --err: #d0021b;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: var(--bg); color: var(--ink); font-family: "Sukhumvit Set", Kanit, -apple-system, "Helvetica Neue", Arial, sans-serif; font-size: 16px; -webkit-font-smoothing: antialiased; }
a { color: inherit; }

/* แถบบน */
.top { position: sticky; top: 0; z-index: 5; background: rgba(255,255,255,.94); backdrop-filter: blur(12px); border-bottom: 1px solid var(--line); }
.top .in { max-width: 1440px; margin: 0 auto; padding: 0 24px; height: 60px; display: flex; align-items: center; justify-content: space-between; }
.brand { font-weight: 800; font-size: 19px; letter-spacing: .12em; text-decoration: none; }
.top nav { display: flex; gap: 24px; font-size: 14px; font-weight: 600; }
.top nav { align-items: center; }
.top nav form { margin: 0; }
.navbtn { border: 0; background: none; font: inherit; font-weight: 600; color: var(--sub); cursor: pointer; padding: 6px 0; }
.pill { display: inline-block; font-size: 11px; font-weight: 700; color: #fff; background: var(--mute); border-radius: 999px; padding: 2px 10px; vertical-align: middle; }
.tile.hid img { opacity: .25; }
.tile.hid::after { content: 'ซ่อนอยู่'; position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 700; color: var(--sub); }
.acts { display: flex; gap: 6px; justify-content: flex-end; flex-wrap: wrap; }
.tablewrap { overflow-x: auto; }
.tablewrap table { min-width: 860px; }
.note { color: var(--sub); font-size: 14px; margin: -6px 0 14px; }
.top nav a { text-decoration: none; padding: 6px 0; border-bottom: 2px solid transparent; }
.top nav a:hover, .top nav a.on { border-color: var(--ink); }

main { max-width: 1440px; margin: 0 auto; padding: 0 24px 64px; }
.hero { padding: 40px 0 28px; text-align: center; }
.hero h1 { margin: 0; font-size: clamp(30px, 5vw, 48px); font-weight: 800; line-height: 1.15; }
.hero p { margin: 12px 0 0; color: var(--sub); font-size: 17px; }
.hero .crumb { display: inline-block; margin-bottom: 14px; font-size: 14px; font-weight: 600; text-decoration: none; color: var(--sub); }
.hero .crumb:hover { color: var(--ink); }

/* ปุ่มทรงแคปซูล */
.btn { display: inline-flex; align-items: center; justify-content: center; border: 1px solid var(--ink); border-radius: 999px; background: var(--ink); color: #fff; font: inherit; font-weight: 700; font-size: 15px; padding: 12px 28px; cursor: pointer; text-decoration: none; transition: opacity .15s; }
.btn:hover { opacity: .8; }
.btn.blue { background: var(--blue); border-color: var(--blue); }
.btn.line { background: transparent; color: var(--ink); }
.btn.small { font-size: 13px; padding: 7px 18px; }
.btn.off, .btn[disabled] { opacity: .3; cursor: not-allowed; }

/* กล่องหารูป */
.finder { background: var(--card); border-radius: 20px; padding: 24px; margin: 0 auto 36px; max-width: 760px; text-align: center; }
.finder h2 { margin: 0; font-size: 22px; font-weight: 800; }
.finder > p { margin: 6px 0 16px; color: var(--sub); font-size: 15px; }
.consent { display: flex; gap: 10px; align-items: flex-start; text-align: left; max-width: 520px; margin: 0 auto 18px; font-size: 13px; color: var(--sub); }
.consent input { margin-top: 2px; width: 18px; height: 18px; flex: none; accent-color: var(--blue); }
.status { min-height: 22px; margin-top: 14px; font-size: 14px; color: var(--sub); }
.status.err { color: var(--err); }
.status:empty { display: none; }

.bar { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin: 0 0 18px; }
.bar h2 { margin: 0; font-size: 24px; font-weight: 800; }
.bar span { color: var(--sub); font-size: 14px; }

/* อัลบั้ม */
.albums { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 32px 20px; }
.album { text-decoration: none; display: block; }
.album .cover { aspect-ratio: 1; border-radius: 20px; overflow: hidden; background: var(--card); display: flex; align-items: center; justify-content: center; color: var(--mute); font-size: 14px; }
.album .cover img { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform .35s; }
.album:hover .cover img { transform: scale(1.04); }
.album h3 { margin: 12px 0 2px; font-size: 17px; font-weight: 700; line-height: 1.3; }
.album p { margin: 0; color: var(--sub); font-size: 14px; }

/* รูป */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 6px; }
.tile { position: relative; aspect-ratio: 1; overflow: hidden; background: var(--card); cursor: zoom-in; border-radius: 8px; }
.tile img { width: 100%; height: 100%; object-fit: cover; display: block; }
.tag { position: absolute; left: 8px; bottom: 8px; font-size: 11px; font-weight: 700; color: #fff; border-radius: 999px; padding: 3px 10px; background: var(--ok); }
.tag.maybe { background: var(--maybe); }
.cap { position: absolute; left: 0; right: 0; top: 0; padding: 8px 10px 18px; font-size: 11px; font-weight: 600; color: #fff; background: linear-gradient(rgba(0,0,0,.55), transparent); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.empty { color: var(--sub); text-align: center; padding: 48px 0; font-size: 15px; }
.results { margin-bottom: 56px; }

/* หน้าช่างภาพ */
.cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 20px; margin-bottom: 48px; }
.box { background: var(--card); border-radius: 20px; padding: 28px 24px; }
.box h2 { margin: 0 0 4px; font-size: 20px; font-weight: 800; }
.box > p { margin: 0 0 16px; color: var(--sub); font-size: 14px; }
.field { display: block; margin-bottom: 12px; font-size: 13px; font-weight: 700; }
.field input, .field select { display: block; width: 100%; margin-top: 6px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 12px; background: #fff; font: inherit; font-weight: 400; font-size: 15px; }
.drop { border: 2px dashed #cfcfcf; border-radius: 16px; padding: 32px 16px; margin-bottom: 14px; color: var(--sub); text-align: center; font-size: 14px; background: #fff; }
.drop.over { border-color: var(--blue); color: var(--blue); }
.qr { text-align: center; }
.qr img { background: #fff; border-radius: 12px; padding: 8px; }
code { font-size: 13px; background: #fff; border-radius: 6px; padding: 2px 6px; }
table { width: 100%; border-collapse: collapse; font-size: 15px; }
th, td { text-align: left; padding: 14px 8px; border-bottom: 1px solid var(--line); }
th { font-size: 13px; color: var(--sub); font-weight: 700; }
td.r, th.r { text-align: right; }
td a { font-weight: 700; text-decoration: none; }
td a:hover { text-decoration: underline; }

/* ดูรูปใหญ่ */
#viewer { position: fixed; inset: 0; background: rgba(0,0,0,.94); display: none; align-items: center; justify-content: center; flex-direction: column; gap: 16px; z-index: 10; padding: 16px; }
#viewer.on { display: flex; }
#viewer img { max-width: 100%; max-height: 82vh; border-radius: 8px; }
#viewer .row { display: flex; gap: 10px; }
#viewer .btn { background: #fff; color: #000; border-color: #fff; }
#viewer .btn.line { background: transparent; color: #fff; border-color: rgba(255,255,255,.5); }

footer { border-top: 1px solid var(--line); color: var(--mute); font-size: 12px; padding: 24px; text-align: center; }
@media (max-width: 600px) {
  .top .in, main { padding-left: 16px; padding-right: 16px; }
  .albums { grid-template-columns: repeat(2, 1fr); gap: 24px 12px; }
  .grid { grid-template-columns: repeat(3, 1fr); gap: 3px; }
  .tile { border-radius: 4px; }
}

/* ปุ่มหารูป 2 แบบ และโหมดเลือกหลายรูป */
.picks { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
.tile img { transition: transform .12s; }
.tile .chk { position: absolute; top: 8px; right: 8px; width: 26px; height: 26px; border-radius: 50%; border: 2px solid #fff; background: rgba(0,0,0,.28); display: none; align-items: center; justify-content: center; color: #fff; font-size: 15px; font-weight: 700; line-height: 1; }
body.selecting .tile { cursor: pointer; }
body.selecting .tile .chk { display: flex; }
.tile.sel .chk { background: var(--blue); border-color: var(--blue); }
.tile.sel .chk::after { content: "\2713"; }
.tile.sel img { transform: scale(.88); border-radius: 8px; }
body.selecting main { padding-bottom: 140px; }
#selbar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 8; background: #000; color: #fff; padding: 12px 16px calc(12px + env(safe-area-inset-bottom)); display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
#selbar .selnote { font-size: 12px; color: #bbb; min-height: 16px; }
#selbar .btn.ghost { background: transparent; color: #fff; border-color: rgba(255,255,255,.45); }
#selbar .btn[disabled] { opacity: .35; }
