:root {
  --bg: #f6f5f2; --surface: #fff; --text: #1d1d1b; --muted: #6b6a66; --line: #e4e2dc;
  --accent: #2f6b5a; --accent-ink: #fff; --danger: #b3412e; --warn: #a86b12;
  --shadow: 0 1px 2px rgba(0,0,0,.06), 0 4px 16px rgba(0,0,0,.05); --radius: 12px;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #141413; --surface: #1e1e1c; --text: #ecebe7; --muted: #9c9a94; --line: #2e2d2a;
    --accent: #6fb39c; --accent-ink: #0f1f1a; --danger: #e07a66; --warn: #e0a64f; --shadow: none; }
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.55 "IBM Plex Sans Thai", system-ui, sans-serif; }
a { color: inherit; text-decoration: none; }
button, input, select { font: inherit; }
code { font: 13px ui-monospace, Consolas, monospace; background: color-mix(in srgb, var(--line) 60%, transparent); padding: 1px 6px; border-radius: 5px; }
.small { font-size: 13px; }
.err { color: var(--danger); }

/* top bar */
.topbar { position: sticky; top: 0; z-index: 10; display: flex; align-items: center; justify-content: space-between;
  gap: 12px; padding: 12px 24px; background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 8px; font-weight: 600; font-size: 17px; white-space: nowrap; }
.brand svg { color: var(--accent); flex: none; }
.ver { font-size: 12px; font-weight: 400; color: var(--muted); }
nav { display: flex; gap: 4px; flex-wrap: wrap; justify-content: flex-end; }
nav a { padding: 7px 14px; border-radius: 999px; color: var(--muted); }
nav a.active { color: var(--text); background: var(--surface); box-shadow: var(--shadow); }
nav a.cta { background: var(--accent); color: var(--accent-ink); }

main { max-width: 1200px; margin: 0 auto; padding: 28px 24px 100px; }
h1 { font-size: 26px; margin: 0; font-weight: 600; line-height: 1.3; }
h2.section { font-size: 17px; margin: 30px 0 12px; }
.sub { color: var(--muted); margin: 4px 0 0; }
.head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 22px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.foot { text-align: center; color: var(--muted); font-size: 12px; padding: 0 0 24px; }
.foot a { text-decoration: underline; }

.btn { display: inline-flex; align-items: center; gap: 6px; padding: 8px 16px; border-radius: 999px; border: 1px solid var(--line);
  background: var(--surface); color: var(--text); cursor: pointer; white-space: nowrap; }
.btn:hover { border-color: var(--muted); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.danger { color: var(--danger); }
.btn.big { padding: 12px 24px; font-size: 16px; }
.btn:disabled { opacity: .5; cursor: default; }
.link { background: none; border: 0; color: var(--accent); cursor: pointer; padding: 0 4px; }

.hero { text-align: center; padding: 36px 16px 20px; }
.hero h1 { font-size: 32px; }
.hero .sub { max-width: 560px; margin: 8px auto 20px; }

/* album cards */
.albums { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 18px; }
.album-card { background: var(--surface); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); border: 1px solid var(--line); transition: transform .15s; }
.album-card:hover { transform: translateY(-2px); }
.album-card .cover { position: relative; aspect-ratio: 4/3; background: var(--line) center/cover no-repeat; display: grid; place-items: center; color: var(--muted); }
.album-card .meta { padding: 10px 14px 12px; }
.album-card .name { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.album-card .count { color: var(--muted); font-size: 13px; }
.pill { position: absolute; top: 8px; left: 8px; font-size: 11px; padding: 2px 8px; border-radius: 999px; background: var(--accent); color: var(--accent-ink); }
.pill.dark { background: rgba(0,0,0,.65); color: #fff; }

.empty { text-align: center; color: var(--muted); padding: 60px 20px; border: 2px dashed var(--line); border-radius: var(--radius); }

/* photo grid */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 6px; }
@media (max-width: 600px) { .grid { grid-template-columns: repeat(3, 1fr); gap: 3px; } }
.tile { position: relative; aspect-ratio: 1; border-radius: 6px; overflow: hidden; background: var(--line); cursor: zoom-in; user-select: none; }
.selecting .tile { cursor: pointer; }
.tile img { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform .15s; }
.tile.sel img { transform: scale(.88); border-radius: 6px; }
.tile.sel { background: color-mix(in srgb, var(--accent) 25%, var(--line)); }
.tile .check { position: absolute; top: 6px; left: 6px; width: 24px; height: 24px; border-radius: 50%; border: 2px solid #fff;
  background: rgba(0,0,0,.25); box-shadow: 0 0 3px rgba(0,0,0,.4); opacity: 0; transition: opacity .15s; cursor: pointer; }
.tile:hover .check, .selecting .tile .check, .tile.sel .check { opacity: 1; }
@media (hover: none) { .tile .check { opacity: .9; } }
.tile.sel .check { background: var(--accent); border-color: var(--accent); }
.tile.sel .check::after { content: ''; position: absolute; left: 6px; top: 2px; width: 6px; height: 11px; border: solid var(--accent-ink); border-width: 0 2px 2px 0; transform: rotate(45deg); }
.tile .badge { position: absolute; left: 6px; bottom: 6px; font-size: 11px; padding: 1px 7px; border-radius: 999px; background: rgba(0,0,0,.55); color: #fff; }
.tile .badge.err-bg { background: var(--danger); }
.tile .score { position: absolute; right: 6px; bottom: 6px; font-size: 11px; padding: 1px 7px; border-radius: 999px; background: var(--accent); color: var(--accent-ink); }
.tile .src { position: absolute; right: 6px; top: 6px; font-size: 10px; padding: 0 6px; border-radius: 4px; background: rgba(0,0,0,.55); color: #fff; }
.tile .pill { left: auto; right: 6px; top: auto; bottom: 6px; }
.tile .ph { width: 100%; height: 100%; display: flex; flex-direction: column; gap: 6px; align-items: center; justify-content: center; color: var(--muted); padding: 8px; text-align: center; }
.tile .ph small { font-size: 11px; word-break: break-all; }
.tile.error .ph { color: var(--danger); font-size: 22px; }
.more { min-height: 60px; display: grid; place-items: center; color: var(--muted); }

/* selection bar */
.selbar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; background: var(--surface); border: 1px solid var(--line);
  border-radius: 999px; padding: 6px 6px 6px 18px; box-shadow: var(--shadow); margin-bottom: 14px; }
.selbar span { font-weight: 600; margin-right: auto; }
.selbar.floating { position: fixed; z-index: 20; left: 50%; bottom: 18px; transform: translateX(-50%); margin: 0;
  box-shadow: 0 6px 30px rgba(0,0,0,.2); width: max-content; max-width: calc(100vw - 24px); }

/* uploads / progress */
.drop { display: block; border: 2px dashed var(--line); border-radius: var(--radius); padding: 22px; text-align: center; color: var(--muted);
  margin-bottom: 18px; cursor: pointer; transition: background .15s, border-color .15s; }
.drop b { color: var(--text); }
.drop.over, .drop:hover { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 6%, transparent); }
.progress { margin: 0 0 18px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 16px; }
.bar { height: 6px; background: var(--line); border-radius: 999px; overflow: hidden; margin-top: 8px; }
.bar > i { display: block; height: 100%; background: var(--accent); width: 0; transition: width .2s; }

/* panels */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); }
.panel h2 { font-size: 16px; margin: 0 0 8px; }
.panel p { margin: 4px 0; }
.cards3 { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 16px; margin-bottom: 26px; }
.cards2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 16px; margin-bottom: 16px; }
.kv { display: flex; align-items: center; gap: 8px; padding: 3px 0; }
.kv span { color: var(--muted); font-size: 13px; width: 70px; }
.panel input[type=text], .panel input[type=password], .panel input:not([type]), .auth input {
  width: 100%; padding: 9px 12px; border-radius: 8px; border: 1px solid var(--line); background: var(--bg); color: var(--text); margin: 6px 0 10px; }
form.inline { display: flex; gap: 8px; align-items: center; margin-top: 10px; }
form.inline input { margin: 0 !important; }
.switch { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; padding: 0 6px; }
.switch input { accent-color: var(--accent); width: 18px; height: 18px; }
.auth { max-width: 400px; margin: 60px auto; }
.auth h1 { font-size: 22px; }
.auth form { margin-top: 16px; }
.auth .btn { width: 100%; justify-content: center; }
.panel code { word-break: break-all; }
code.path { display: inline-block; word-break: break-all; padding: 4px 8px; }
.panel code.path { display: block; margin: 4px 0 8px; }
.infolder { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin: -8px 0 18px; color: var(--muted); font-size: 13px; }
.album-card .folder { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.changelog a { color: var(--accent); }
.changelog h3 { font-size: 16px; margin: 18px 0 4px; }
.changelog h4 { font-size: 14px; margin: 10px 0 2px; color: var(--muted); }
.changelog ul { margin: 4px 0; padding-left: 22px; }

/* face scan */
.find { display: grid; grid-template-columns: 340px 1fr; gap: 24px; align-items: start; }
@media (max-width: 820px) { .find { grid-template-columns: 1fr; } main { padding: 20px 16px 100px; } .topbar { padding: 10px 16px; } }
.cam { position: relative; aspect-ratio: 1; border-radius: 10px; overflow: hidden; background: #000; margin: 12px 0; }
.cam video { width: 100%; height: 100%; object-fit: cover; display: block; transform: scaleX(-1); }
.cam .hint { position: absolute; inset: 0; display: grid; place-items: center; color: #bbb; text-align: center; padding: 20px; }
.selfies { display: flex; gap: 6px; flex-wrap: wrap; margin: 10px 0; }
.selfies .s { position: relative; width: 56px; height: 56px; border-radius: 8px; overflow: hidden; }
.selfies .s img { width: 100%; height: 100%; object-fit: cover; }
.selfies .s button { position: absolute; top: 0; right: 0; border: 0; background: rgba(0,0,0,.6); color: #fff; width: 18px; height: 18px;
  font-size: 12px; line-height: 1; cursor: pointer; border-radius: 0 0 0 6px; }
.field { margin-top: 14px; }
.field label { display: flex; justify-content: space-between; font-size: 13px; color: var(--muted); }
.field input[type=range] { width: 100%; accent-color: var(--accent); }
.field select { width: 100%; padding: 7px 10px; border-radius: 8px; border: 1px solid var(--line); background: var(--surface); color: var(--text); }
.status { font-size: 13px; color: var(--muted); margin-top: 10px; min-height: 1.5em; }
.results-head { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 4px; }
.results-head b { margin-right: auto; }
.result-group h3 { font-size: 15px; margin: 18px 0 8px; display: flex; gap: 8px; align-items: baseline; }
.result-group h3 small { color: var(--muted); font-weight: 400; }

/* lightbox */
.lightbox { position: fixed; inset: 0; z-index: 50; background: rgba(10,10,10,.95); display: flex; align-items: center; justify-content: center; }
.lb-stage { margin: 0; max-width: calc(100vw - 120px); max-height: 100vh; display: flex; flex-direction: column; align-items: center; }
.lb-frame { position: relative; line-height: 0; }
.lb-frame img { max-width: calc(100vw - 120px); max-height: calc(100vh - 90px); display: block; }
.lb-box { position: absolute; border: 3px solid #7fe0bd; border-radius: 6px; box-shadow: 0 0 0 9999px rgba(0,0,0,.25); }
.lightbox figcaption { color: #ccc; font-size: 13px; padding: 10px; display: flex; gap: 14px; align-items: center; flex-wrap: wrap; justify-content: center; }
.lightbox figcaption a { color: #7fe0bd; }
.lightbox > button { position: absolute; background: none; border: 0; color: #fff; font-size: 44px; cursor: pointer; padding: 10px 18px; opacity: .8; }
.lightbox > button:hover { opacity: 1; }
.lb-pick { background: none; border: 1px solid #7fe0bd; color: #7fe0bd; border-radius: 999px; padding: 3px 12px; cursor: pointer; }
.lb-pick.on { background: #7fe0bd; color: #0f1f1a; }
.lb-close { top: 6px; right: 10px; } .lb-prev { left: 6px; } .lb-next { right: 6px; }
@media (max-width: 600px) { .lb-stage, .lb-frame img { max-width: 100vw; } .lb-prev, .lb-next { top: auto; bottom: 60px; } }

.toast { position: fixed; bottom: 80px; left: 50%; transform: translateX(-50%); background: var(--text); color: var(--bg);
  padding: 10px 18px; border-radius: 999px; z-index: 60; }
.spin { display: inline-block; width: 14px; height: 14px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%;
  animation: spin .7s linear infinite; vertical-align: -2px; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---- UCN.Studio additions ---- */
.brand .mark { font-weight: 700; letter-spacing: .04em; }
.brand .mark i { font-style: normal; color: var(--accent); }
.newbar { display: flex; justify-content: center; margin: -8px 0 14px; }
.zipbar { position: fixed; z-index: 30; left: 50%; bottom: 18px; transform: translateX(-50%); width: min(420px, calc(100vw - 24px));
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 16px; box-shadow: 0 6px 30px rgba(0,0,0,.2); }
.tile .fresh { position: absolute; right: 6px; top: 6px; font-size: 11px; padding: 1px 7px; border-radius: 999px; background: var(--accent); color: var(--accent-ink); }
.demo-note { text-align: center; font-size: 12px; color: var(--warn); margin: -10px 0 16px; }
.cam video { transform: scaleX(-1); }
.drop .small { display: block; margin-top: 4px; }
@media (max-width: 820px) { .cam { max-width: 360px; margin-inline: auto; } }

/* shoot & upload */
.shoot { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 14px; }
.live { margin-bottom: 18px; }
.live-cam { position: relative; background: #000; border-radius: 10px; overflow: hidden; max-height: 70vh; display: grid; place-items: center; }
.live-cam video { width: 100%; max-height: 70vh; object-fit: contain; display: block; }
.flash { position: absolute; inset: 0; background: #fff; opacity: 0; pointer-events: none; }
.flash.on { animation: flash .35s ease-out; }
@keyframes flash { from { opacity: .85; } to { opacity: 0; } }
.live-ctl { margin-top: 12px; }
.shutter { width: 64px; height: 64px; border-radius: 50%; border: 4px solid var(--accent); background: var(--surface); cursor: pointer; box-shadow: inset 0 0 0 4px var(--surface), inset 0 0 0 30px var(--accent); transition: transform .1s; }
.shutter:active { transform: scale(.92); }
#shots { margin-top: 12px; }
/* users */
.urow { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 8px 0; border-top: 1px solid var(--line); }
.urow b { margin-right: auto; }
.urow select, .panel select { padding: 7px 10px; border-radius: 8px; border: 1px solid var(--line); background: var(--surface); color: var(--text); font: inherit; }
#logout { white-space: nowrap; }
@media (max-width: 600px) { .shoot .btn.big { flex: 1 1 100%; justify-content: center; } }
/* watch folder */
.watch { margin-bottom: 18px; border-color: color-mix(in srgb, var(--accent) 45%, var(--line)); }
.watch h2 { display: flex; align-items: center; gap: 8px; }
.watch .switch { margin: 4px 12px 0 0; padding: 0; }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 10px; margin: 12px 0; }
.kpi { background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 10px 14px; }
.kpi span { display: block; font-size: 12px; color: var(--muted); }
.kpi b { font-size: 24px; font-variant-numeric: tabular-nums; }
