/* TalentTH Studio. Same tokens and fonts as the galleries (gallery.html). */
@font-face {
  font-family: "Space Grotesk"; font-weight: 300 700; font-display: swap;
  src: url("/e/fonts/SpaceGrotesk.woff2") format("woff2");
}
@font-face {
  font-family: "Noto Sans Thai"; font-weight: 400; font-display: swap;
  src: url("/e/fonts/NotoSansThai-Regular.ttf") format("truetype");
  unicode-range: U+0E01-0E5B, U+200C-200D, U+25CC;
}
@font-face {
  font-family: "Noto Sans Thai"; font-weight: 600; font-display: swap;
  src: url("/e/fonts/NotoSansThai-SemiBold.ttf") format("truetype");
  unicode-range: U+0E01-0E5B, U+200C-200D, U+25CC;
}
:root {
  color-scheme: light;
  --bg: #f5f0e8; --card: #fff; --line: #e1d9ce; --text: #181511; --muted: #6e655a;
  --brand: #156055; --on-brand: #fff; --accent: #e27442; --soft: #ece5da;
  --danger: #b42318; --on-danger: #fff; --ok: #156055; --focus: #156055;
  --shadow: 0 20px 60px -40px rgb(15 23 42 / .4);
}
@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --bg: #090e0d; --card: #101716; --line: #222c29; --text: #f0ece6; --muted: #a0968a;
    --brand: #4cb9aa; --on-brand: #062320; --accent: #ec9b56; --soft: #18211f;
    --danger: #f97066; --on-danger: #2a0a07; --ok: #4cb9aa; --focus: #4cb9aa;
    --shadow: 0 20px 60px -40px rgb(0 0 0 / .9);
  }
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 15px/1.6 "Space Grotesk", "Noto Sans Thai", ui-sans-serif, -apple-system, "Segoe UI", system-ui, sans-serif;
}
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
a { color: var(--brand); }
h1, h2, h3 { letter-spacing: -.01em; line-height: 1.25; }
h1 { font-size: 24px; margin: 0; font-weight: 650; }
h2 { font-size: 17px; margin: 0 0 12px; font-weight: 650; }
p { margin: 0 0 10px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.boot { padding: 48px; text-align: center; color: var(--muted); }
[hidden] { display: none !important; }

/* ── shell: sidebar on desktop, a bar on top on a phone ── */
.shell { display: grid; grid-template-columns: 240px minmax(0, 1fr); min-height: 100%; }
.side {
  background: var(--card); border-right: 1px solid var(--line);
  padding: 20px 14px; display: flex; flex-direction: column; gap: 18px;
  position: sticky; top: 0; height: 100vh;
}
.brand {
  display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--text);
  font-weight: 700; font-size: 16px; padding: 4px 10px;
}
.brand .dot { width: 12px; height: 12px; border-radius: 4px; background: var(--accent); flex: none; }
.side nav { display: flex; flex-direction: column; gap: 2px; }
.side nav a {
  display: flex; align-items: center; gap: 10px; min-height: 42px; padding: 8px 12px;
  border-radius: 12px; color: var(--muted); text-decoration: none; font-weight: 600;
}
.side nav a:hover { background: var(--soft); color: var(--text); }
.side nav a[aria-current="page"] { background: var(--brand); color: var(--on-brand); }
.side .navlabel { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); padding: 10px 12px 2px; }
.side .grow { flex: 1; }
.who { padding: 10px 12px; border-top: 1px solid var(--line); font-size: 13px; }
.who strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.main { padding: 28px clamp(16px, 4vw, 40px) 64px; min-width: 0; max-width: 1180px; width: 100%; }

@media (max-width: 800px) {
  .shell { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto 1fr; }
  .side {
    position: sticky; top: 0; z-index: 10; height: auto; flex-direction: row; align-items: center;
    padding: 8px 10px; gap: 8px; border-right: 0; border-bottom: 1px solid var(--line); overflow-x: auto;
  }
  .brand { padding: 4px; }
  .brand .label { display: none; }
  .side nav { flex-direction: row; }
  .side nav a { min-height: 40px; padding: 6px 12px; white-space: nowrap; }
  .side .navlabel, .side .grow, .who { display: none; }
  .main { padding: 18px 14px 56px; }
}

/* ── building blocks ── */
.pagehead { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 20px; }
.pagehead .grow { flex: 1; }
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: 18px;
  padding: 20px; box-shadow: var(--shadow);
}
.stack { display: grid; gap: 16px; }
/* One-column grids: a long URL or filename must shrink, not widen the page. */
.stack, .eventhead, .queue, label.field, dialog .sheet, a.event .body { grid-template-columns: minmax(0, 1fr); }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row .grow { flex: 1; }
.empty { text-align: center; color: var(--muted); padding: 56px 16px; border: 1px dashed var(--line); border-radius: 18px; }

.btn {
  font: inherit; font-size: 14px; font-weight: 600; border-radius: 999px; padding: 9px 18px;
  min-height: 42px; cursor: pointer; border: 1px solid var(--line); background: var(--card); color: var(--text);
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; text-decoration: none; white-space: nowrap;
}
.btn:hover { border-color: var(--muted); }
.btn.primary { background: var(--brand); border-color: var(--brand); color: var(--on-brand); }
.btn.danger { background: var(--danger); border-color: var(--danger); color: var(--on-danger); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--brand); }
.btn.small { min-height: 34px; padding: 5px 12px; font-size: 13px; }
.btn:disabled { opacity: .55; cursor: default; }
.linkbtn { font: inherit; background: none; border: 0; padding: 0; color: var(--brand); cursor: pointer; text-decoration: underline; }

label.field { display: grid; gap: 6px; font-size: 14px; font-weight: 600; }
label.field .hint { font-weight: 400; color: var(--muted); font-size: 13px; }
input, select, textarea {
  font: inherit; font-size: 15px; color: var(--text); background: var(--bg);
  border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; min-height: 44px; width: 100%;
}
input:focus, select:focus, textarea:focus { border-color: var(--brand); outline: none; box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 25%, transparent); }
input[readonly] { color: var(--muted); }
label.check { display: flex; gap: 10px; align-items: flex-start; font-size: 14px; }
label.check input { width: 20px; height: 20px; min-height: 0; margin-top: 2px; flex: none; accent-color: var(--brand); }
form.stack { gap: 14px; }
.error { color: var(--danger); font-size: 14px; margin: 0; }
.error:empty { display: none; }

.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600;
  padding: 3px 10px; border-radius: 999px; background: var(--soft); color: var(--muted); white-space: nowrap;
}
.chip.brand { background: color-mix(in srgb, var(--brand) 16%, transparent); color: var(--brand); }
.chip.danger { background: color-mix(in srgb, var(--danger) 14%, transparent); color: var(--danger); }
.chip.accent { background: color-mix(in srgb, var(--accent) 18%, transparent); color: var(--accent); }

.meter { height: 8px; border-radius: 999px; background: var(--soft); overflow: hidden; }
.meter > span { display: block; height: 100%; background: var(--brand); border-radius: inherit; }
.meter.full > span { background: var(--danger); }

/* ── sign-in ── */
.auth { min-height: 100%; display: grid; place-items: center; padding: 24px 16px; }
.auth .card { width: min(100%, 420px); padding: 28px; }
.auth .brand { padding: 0 0 18px; font-size: 18px; }
.auth h1 { font-size: 22px; margin-bottom: 6px; }
.auth .switch { margin-top: 16px; font-size: 14px; color: var(--muted); display: flex; gap: 12px; flex-wrap: wrap; }

/* ── events ── */
.cards { display: grid; gap: 16px; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }
a.event { display: flex; flex-direction: column; padding: 0; overflow: hidden; text-decoration: none; color: inherit; }
a.event:hover { border-color: var(--brand); }
.cover { aspect-ratio: 3 / 2; background: var(--soft); display: grid; place-items: center; overflow: hidden; }
.cover img { width: 100%; height: 100%; object-fit: cover; display: block; }
.cover .initial { font-size: 40px; font-weight: 700; color: var(--muted); }
a.event .body { padding: 14px 16px 16px; display: grid; gap: 4px; }
a.event strong { font-size: 16px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.eventhead { display: grid; gap: 10px; margin-bottom: 18px; }
.eventhead .back { font-size: 14px; text-decoration: none; }
.linkbox { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.linkbox code {
  font: 13px/1.4 ui-monospace, SFMono-Regular, Menlo, monospace; background: var(--card); border: 1px solid var(--line);
  border-radius: 10px; padding: 8px 10px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%; min-width: 0;
}
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 18px; overflow: auto hidden; }
.tabs a {
  padding: 10px 14px; text-decoration: none; color: var(--muted); font-weight: 600; white-space: nowrap;
  border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.tabs a[aria-current="page"] { color: var(--text); border-color: var(--accent); }

/* ── photos ── */
.drop {
  display: grid; place-items: center; text-align: center; gap: 6px; padding: 26px 16px; cursor: pointer;
  border: 2px dashed var(--line); border-radius: 18px; background: var(--card); color: var(--muted);
}
.drop strong { color: var(--text); }
.drop.over { border-color: var(--brand); background: color-mix(in srgb, var(--brand) 8%, var(--card)); }
.drop input { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.queue { display: grid; gap: 8px; margin-top: 12px; }
.queue:empty { display: none; }
.qitem { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px 12px; align-items: center; font-size: 13px; }
.qitem .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.qitem .meter { grid-column: 1 / -1; height: 6px; }
.qitem.done .meter > span { background: var(--ok); }
.qitem.failed .meter > span { background: var(--danger); }
.qitem.failed .state { color: var(--danger); }

.toolbar {
  position: sticky; top: 0; z-index: 4; display: flex; gap: 10px; align-items: center; flex-wrap: wrap;
  padding: 10px 0; margin: 14px 0 6px; background: var(--bg);
}
.grid { display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
.grid > .empty { grid-column: 1 / -1; }
.tile { position: relative; border-radius: 14px; overflow: hidden; background: var(--soft); aspect-ratio: 1; border: 2px solid transparent; }
.tile.selected { border-color: var(--brand); }
.tile button.open { all: unset; display: block; width: 100%; height: 100%; cursor: zoom-in; }
.tile img { width: 100%; height: 100%; object-fit: cover; display: block; }
.tile .pick {
  position: absolute; top: 8px; left: 8px; width: 26px; height: 26px; min-height: 0; padding: 0; margin: 0;
  accent-color: var(--brand); cursor: pointer;
}
.tile .badge { position: absolute; bottom: 8px; left: 8px; }
.tile .badge .chip { background: rgb(0 0 0 / .62); color: #fff; }

dialog {
  border: 1px solid var(--line); border-radius: 20px; padding: 0; background: var(--card); color: var(--text);
  width: min(94vw, 480px); box-shadow: 0 30px 80px -30px rgb(0 0 0 / .5);
}
dialog::backdrop { background: rgb(9 14 13 / .6); }
dialog .sheet { padding: 22px; display: grid; gap: 14px; }
dialog.wide { width: min(94vw, 960px); }
a.tile { display: block; }
dialog .bar { display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap; }
dialog.viewer { width: 100vw; height: 100dvh; max-width: 100vw; max-height: 100dvh; border: 0; border-radius: 0; background: #000; color: #fff; }
dialog.viewer::backdrop { background: #000; }
.viewer .frame { position: absolute; inset: 56px 0 72px; display: grid; place-items: center; }
.viewer .frame img { max-width: 100%; max-height: 100%; object-fit: contain; }
.viewer .top, .viewer .bottom { position: absolute; left: 0; right: 0; display: flex; gap: 10px; align-items: center; padding: 10px 14px; }
.viewer .top { top: 0; }
.viewer .bottom { bottom: 0; justify-content: center; flex-wrap: wrap; }
.viewer .top .grow { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; }
.viewer .btn { background: rgb(255 255 255 / .12); border-color: transparent; color: #fff; }
.viewer .btn.danger { background: #b42318; }

/* ── tables (admin) ── */
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th { text-align: left; font-size: 12px; color: var(--muted); font-weight: 600; padding: 8px 10px; border-bottom: 1px solid var(--line); }
.table td { padding: 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tr.link { cursor: pointer; }
.table tr.link:hover td { background: var(--soft); }
.tablewrap { overflow-x: auto; }
.table th, .table td.small { white-space: nowrap; } /* narrow screens scroll the table sideways instead of one word per line */
.stats { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); }
@media (max-width: 800px) { .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.stat { display: grid; gap: 2px; }
.stat b { font-size: 24px; font-variant-numeric: tabular-nums; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; font-size: 14px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; overflow-wrap: anywhere; }

#toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 100;
  background: var(--text); color: var(--bg); padding: 10px 18px; border-radius: 999px; font-size: 14px;
  box-shadow: var(--shadow); max-width: calc(100vw - 32px);
}
#toast:empty { display: none; }
#toast.bad { background: var(--danger); color: var(--on-danger); }
