:root {
  --bg: #f6f5f3;
  --surface: #ffffff;
  --text: #1c1917;
  --muted: #6b6560;
  --line: #e5e1dc;
  --accent: #c2410c;
  --accent-text: #ffffff;
  --ok: #15803d;
  --warn: #b45309;
  --err: #b91c1c;
  --radius: 14px;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #141210;
    --surface: #1f1c19;
    --text: #f2efec;
    --muted: #a39d97;
    --line: #34302c;
    --accent: #ea580c;
    --ok: #4ade80;
    --warn: #fbbf24;
    --err: #f87171;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
h1, h2 { line-height: 1.2; margin: 0; }
h1 { font-size: 1.6rem; }
h2 { font-size: 1.05rem; margin-bottom: .5rem; }
button, input, select { font: inherit; color: inherit; }
a { color: var(--accent); }
.sr-only { position: absolute; width: 1px; height: 1px; opacity: 0; overflow: hidden; pointer-events: none; }
[hidden] { display: none !important; }

.wrap {
  max-width: 560px;
  margin: 0 auto;
  padding: max(20px, env(safe-area-inset-top)) 16px max(32px, env(safe-area-inset-bottom));
}
.top { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.eyebrow { margin: 0 0 2px; color: var(--muted); font-size: .9rem; }
.lead { margin: 14px 0 20px; font-size: 1.05rem; }
.hint { margin: 6px 0 0; color: var(--muted); font-size: .88rem; }

.lang {
  border: 1px solid var(--line); background: var(--surface); border-radius: 999px;
  padding: 6px 12px; font-size: .85rem; cursor: pointer; white-space: nowrap;
}

.pick {
  display: flex; align-items: center; justify-content: center; gap: 12px;
  width: 100%; min-height: 72px; padding: 16px;
  background: var(--accent); color: var(--accent-text);
  border-radius: var(--radius); font-size: 1.2rem; font-weight: 650;
  cursor: pointer; user-select: none; -webkit-tap-highlight-color: transparent;
  box-shadow: 0 6px 18px rgb(194 65 12 / .25);
  transition: transform .08s;
}
.pick:active { transform: scale(.98); }
.pick svg { width: 30px; height: 30px; fill: none; stroke: currentColor; stroke-width: 1.8; }
.pick.secondary { min-height: 56px; font-size: 1.05rem; box-shadow: none; }
.consent { margin: 10px 2px 0; color: var(--muted); font-size: .85rem; text-align: center; }

.status { margin-top: 24px; }
.status p { margin: 0 0 8px; font-weight: 600; }
.status p.hint { font-weight: 400; }
.bar { height: 8px; background: var(--line); border-radius: 999px; overflow: hidden; }
.bar span { display: block; height: 100%; width: 0; background: var(--accent); transition: width .3s; }
.status.done .bar span { background: var(--ok); }

.card {
  margin-top: 20px; padding: 16px; background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--radius);
}
.field { display: block; margin-top: 12px; }
.field span { display: block; font-size: .9rem; margin-bottom: 4px; }
.field input, .input {
  width: 100%; padding: 12px; border: 1px solid var(--line); border-radius: 10px;
  background: var(--bg); font-size: 16px;
}
.saved { margin: 8px 0 0; color: var(--ok); font-size: .9rem; }

#list-wrap { margin-top: 24px; }
.grid { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.tile {
  position: relative; aspect-ratio: 1; border-radius: 10px; overflow: hidden;
  background: var(--surface); border: 1px solid var(--line);
}
.tile img { width: 100%; height: 100%; object-fit: cover; display: block; }
.tile .icon {
  width: 100%; height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 4px; padding: 6px; color: var(--muted); font-size: .7rem; text-align: center; word-break: break-all;
}
.tile .icon svg { width: 32px; height: 32px; fill: currentColor; }
.tile .prog { position: absolute; left: 0; right: 0; bottom: 0; height: 5px; background: rgb(0 0 0 / .35); }
.tile .prog span { display: block; height: 100%; width: 0; background: var(--accent); transition: width .2s; }
.tile .badge {
  position: absolute; left: 6px; bottom: 9px; padding: 2px 7px; border-radius: 999px;
  font-size: .72rem; font-weight: 600; background: rgb(0 0 0 / .6); color: #fff;
}
.tile.done .prog { display: none; }
.tile.done .badge { background: var(--ok); }
.tile.error .badge { background: var(--err); }
.tile.retrying .badge { background: var(--warn); }
.tile .rm {
  position: absolute; top: 4px; right: 4px; width: 32px; height: 32px; border-radius: 50%;
  border: 0; background: rgb(0 0 0 / .55); color: #fff; font-size: 18px; line-height: 1; cursor: pointer;
}

/* ---------- Admin ---------- */
.admin .wrap { max-width: 1100px; }
.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.btn {
  border: 1px solid var(--line); background: var(--surface); border-radius: 10px;
  padding: 10px 14px; cursor: pointer; text-decoration: none; color: var(--text); display: inline-block;
}
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.btn.small { padding: 6px 10px; font-size: .85rem; }
.admin select.input, .admin input.input { width: auto; min-width: 0; flex: 1 1 200px; }
.panel { margin-top: 16px; padding: 14px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.panel h2 { font-size: .95rem; color: var(--muted); font-weight: 600; }
.active-label { font-size: 1.15rem; font-weight: 650; margin: 0 0 10px; }
.list { list-style: none; margin: 16px 0 0; padding: 0; display: grid; gap: 8px; }
.list li a {
  display: flex; justify-content: space-between; gap: 12px; padding: 14px; text-decoration: none; color: var(--text);
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
}
.list .who { font-weight: 650; }
.list .sub { color: var(--muted); font-size: .85rem; }
.pill { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: .75rem; font-weight: 650; margin-left: 6px; }
.pill.new { background: var(--accent); color: #fff; }
.pill.hidden { background: var(--line); color: var(--muted); }
.pill.up { background: var(--warn); color: #000; }
.empty { color: var(--muted); text-align: center; padding: 40px 0; }
.files { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; margin-top: 16px; }
.file { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.file.is-hidden { opacity: .6; }
.file .media { aspect-ratio: 4 / 3; background: #000; display: block; }
.file .media img, .file .media video { width: 100%; height: 100%; object-fit: contain; display: block; }
.file .media .icon { color: #aaa; height: 100%; display: flex; align-items: center; justify-content: center; font-size: .8rem; }
.file .info { padding: 10px; font-size: .82rem; }
.file .info .name { font-weight: 600; word-break: break-all; }
.file .info .sub { color: var(--muted); }
.qr { text-align: center; }
.qr img { width: min(320px, 80vw); background: #fff; padding: 8px; border-radius: 8px; }
.qr .url { word-break: break-all; font-family: ui-monospace, monospace; font-size: .85rem; }
.login { max-width: 360px; margin: 15vh auto 0; }
.err { color: var(--err); }

@media print {
  body * { visibility: hidden; }
  .qr, .qr * { visibility: visible; }
  .qr { position: absolute; inset: 0; }
  .qr .btn { display: none; }
}
