:root {
  --ivory: #f7f1e6;
  --paper: #fffaf2;
  --ink: #2e251b;
  --muted: #7a6a57;
  --line: #e4d6bf;
  --gold: #b08a3e;
  --gold-deep: #8a6826;
  --gold-soft: #dcc28c;
  --ok: #3f7d5a;
  --danger: #a4463b;
  --thai: "Prompt", "Leelawadee UI", "Segoe UI", Tahoma, sans-serif;
}

* { box-sizing: border-box; }
html, body { min-height: 100%; }
body {
  margin: 0;
  color: var(--ink);
  font-family: var(--thai);
  background:
    radial-gradient(900px 560px at 8% -10%, #fffdf7 0%, rgba(255, 253, 247, 0) 62%),
    radial-gradient(800px 520px at 100% 0%, #f1e2c9 0%, rgba(241, 226, 201, 0) 58%),
    var(--ivory);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--gold-deep); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select { font: inherit; }
button { cursor: pointer; }
.hidden { display: none !important; }

.site-head {
  max-width: 1080px;
  margin: 0 auto;
  padding: 22px 22px 6px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}
.brand { display: flex; align-items: center; gap: 12px; color: var(--ink); }
.brand:hover { text-decoration: none; }
.brand-mark {
  width: 42px; height: 42px; border: 1px solid var(--gold); border-radius: 50%;
  display: grid; place-items: center; font-size: 13px; letter-spacing: 1px;
  color: var(--gold-deep); background: rgba(255, 250, 242, 0.8);
}
.brand-name { display: block; font-size: 18px; letter-spacing: 4px; line-height: 1; }
.brand-sub { display: block; font-size: 9px; letter-spacing: 2.8px; color: var(--muted); text-transform: uppercase; }
.site-nav { display: flex; gap: 16px; font-size: 12px; }
.site-nav a { color: var(--muted); }
.site-nav a[aria-current="page"] { color: var(--gold-deep); }

.shell { max-width: 1080px; margin: 0 auto; padding: 10px 22px 60px; }
.page-top { margin: 10px 0 22px; }
.eyebrow { margin: 0 0 8px; font-size: 10px; letter-spacing: 3.6px; color: var(--gold-deep); text-transform: uppercase; }
h1 { margin: 0; font-size: clamp(26px, 5vw, 42px); font-weight: 500; line-height: 1.2; }
.lede { margin: 10px 0 0; color: var(--muted); font-size: 14px; line-height: 1.65; max-width: 60ch; }

.panel { background: var(--paper); border: 1px solid var(--line); border-radius: 20px; padding: 22px; box-shadow: 0 18px 50px rgba(70, 52, 28, 0.08); }
.panel + .panel { margin-top: 18px; }
.panel h2 { margin: 0 0 6px; font-size: 18px; font-weight: 500; }
.sub { margin: 0 0 16px; color: var(--muted); font-size: 13px; line-height: 1.6; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 10px 18px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--paper); color: var(--ink);
  font-size: 14px; text-decoration: none;
}
.btn:hover { text-decoration: none; border-color: var(--gold-soft); }
.btn-primary { background: var(--gold-deep); border-color: var(--gold-deep); color: #fff9ee; }
.btn-primary:hover { background: var(--gold); border-color: var(--gold); }
.btn-danger { color: var(--danger); border-color: rgba(164, 70, 59, 0.3); }
.btn:disabled { opacity: 0.55; cursor: default; }
.btn-lg { min-height: 56px; padding: 14px 24px; font-size: 16px; }

.field { display: grid; gap: 6px; font-size: 13px; color: var(--muted); }
.input {
  width: 100%; min-height: 44px; padding: 10px 12px; border: 1px solid var(--line);
  border-radius: 12px; background: #fffdf9; color: var(--ink);
}
.consent { display: flex; gap: 10px; align-items: flex-start; font-size: 13px; color: var(--muted); line-height: 1.55; }
.consent input { margin-top: 4px; width: 18px; height: 18px; }
details { margin-top: 8px; font-size: 12.5px; color: var(--muted); line-height: 1.6; }
summary { cursor: pointer; color: var(--gold-deep); }

.camera-box { position: relative; width: 100%; aspect-ratio: 4 / 3; border-radius: 18px; overflow: hidden; background: #16110b; margin-top: 14px; }
.camera-box video, .camera-box img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.camera-box video { transform: scaleX(-1); }
.camera-placeholder { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; color: rgba(255, 248, 234, 0.7); font-size: 13px; padding: 20px; }
.actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 14px; }
.file-input { display: none; }

.status { min-height: 22px; margin-top: 12px; font-size: 13px; color: var(--muted); }
.status.ok { color: var(--ok); }
.status.err { color: var(--danger); }

.guest-status { padding: 10px 14px; border-radius: 12px; background: rgba(176, 138, 62, 0.08); color: var(--muted); font-size: 13px; line-height: 1.5; }
.guest-status.ok { background: rgba(63, 125, 90, 0.08); color: var(--ok); }
.guest-status.err { background: rgba(164, 70, 59, 0.08); color: var(--danger); }

.results-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; margin-top: 14px; }
.result-card { margin: 0; border: 1px solid var(--line); border-radius: 14px; overflow: hidden; background: #fff; }
.result-card img { width: 100%; aspect-ratio: 16 / 9; object-fit: cover; display: block; }
.result-card .body { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 9px 10px; font-size: 12px; color: var(--muted); }
.result-card a { font-size: 12px; white-space: nowrap; }
.score { color: var(--gold-deep); }

.stats-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; margin-bottom: 18px; }
.stat { background: var(--paper); border: 1px solid var(--line); border-radius: 14px; padding: 14px 16px; }
.stat .k { font-size: 11px; letter-spacing: 0.6px; color: var(--muted); }
.stat .v { margin-top: 4px; font-size: 22px; color: var(--ink); }

.storage-bar { height: 10px; border-radius: 999px; border: 1px solid var(--line); background: rgba(176, 138, 62, 0.12); overflow: hidden; }
.storage-bar span { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--gold-soft), var(--gold)); }
.note { margin: 8px 0 0; color: var(--muted); font-size: 12px; line-height: 1.55; }

.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th, .table td { text-align: left; padding: 9px 8px; border-bottom: 1px solid var(--line); }
.table th { color: var(--muted); font-weight: 500; font-size: 11px; letter-spacing: 0.4px; }
.table td.num { text-align: right; font-variant-numeric: tabular-nums; }

.login-gate { position: fixed; inset: 0; z-index: 20; display: grid; place-items: center; padding: 20px; background: rgba(24, 19, 14, 0.5); backdrop-filter: blur(4px); }
.login-card { width: min(400px, 100%); background: var(--paper); border-radius: 20px; padding: 26px; box-shadow: 0 30px 80px rgba(70, 52, 28, 0.2); display: grid; gap: 12px; }
.login-card h1 { font-size: 24px; }

.toast-stack { position: fixed; right: 16px; bottom: 16px; z-index: 40; display: grid; gap: 8px; max-width: min(360px, 90vw); }
.toast { padding: 10px 14px; border-radius: 12px; background: #241b12; color: #fff8ea; font-size: 13px; box-shadow: 0 10px 30px rgba(20, 14, 8, 0.3); }
.toast.ok { background: #2f5f45; }
.toast.err { background: #7c352d; }

.footer { margin-top: 22px; color: var(--muted); font-size: 11px; line-height: 1.6; }

@media (max-width: 560px) {
  .site-head { padding: 16px 16px 4px; }
  .shell { padding: 6px 16px 40px; }
  .panel { padding: 18px; border-radius: 18px; }
  .site-nav { gap: 10px; font-size: 11px; }
  .actions .btn { flex: 1 1 100%; }
  .results-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
