:root {
  --brand: #0b3d91; --brand-2: #1557c0; --bg: #f3f5f9; --card: #fff; --text: #14192b; --muted: #6b7489;
  --line: #dde2ec; --ok: #0f8a4b; --ok-bg: #e5f6ec; --warn: #9a5b00; --warn-bg: #fff4dc; --bad: #b3261e; --bad-bg: #fde8e7;
  --info: #1557c0; --info-bg: #e7efff; --radius: 14px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #0f131c; --card: #1a202c; --text: #eef1f7; --muted: #9aa3b8; --line: #2d3546;
    --ok-bg: #12301f; --ok: #6fd99c; --warn-bg: #3a2c0f; --warn: #f3c46b; --bad-bg: #3d1614; --bad: #ff8a80;
    --info-bg: #17284a; --info: #8ab4ff; color-scheme: dark; }
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font: 16px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; background: var(--bg); color: var(--text);
  padding-bottom: calc(76px + env(safe-area-inset-bottom)); }
h1, h2 { margin: 8px 0 12px; } h2 { font-size: 20px; }
.muted { color: var(--muted); } .center { text-align: center; }
.topbar { position: sticky; top: 0; z-index: 5; display: flex; justify-content: space-between; align-items: center;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px; background: var(--brand); color: #fff; }
.brand { font-weight: 700; font-size: 17px; }
.sync { border: 0; border-radius: 999px; padding: 6px 12px; font: inherit; font-size: 13px; font-weight: 600; }
.sync.ok { background: rgba(255,255,255,.18); color: #fff; }
.sync.pending { background: #ffd166; color: #3b2a00; }
.screen { padding: 14px 16px; max-width: 560px; margin: 0 auto; }
.card { background: var(--card); border-radius: var(--radius); padding: 14px; margin-bottom: 12px; box-shadow: 0 1px 2px rgba(0,0,0,.06); }
label { display: block; font-size: 13px; font-weight: 600; color: var(--muted); margin-bottom: 10px; }
label small { display: block; font-weight: 400; margin-top: 4px; }
input:not([type=checkbox]):not([type=radio]), textarea {
  display: block; width: 100%; margin-top: 4px; padding: 11px 12px; font: inherit; font-size: 16px; color: var(--text);
  background: var(--bg); border: 1px solid var(--line); border-radius: 10px; }
input:focus, textarea:focus { outline: 2px solid var(--brand-2); outline-offset: -1px; }
input.filled { background: var(--info-bg); }
input.bad { border-color: var(--bad); background: var(--bad-bg); }
details summary { font-size: 13px; color: var(--info); margin: 2px 0 10px; cursor: pointer; }
.check { display: flex; gap: 10px; align-items: flex-start; font-weight: 500; color: var(--text); }
.check input { width: 20px; height: 20px; margin: 0; flex: none; }
.event label:last-child { margin-bottom: 0; }

.shots { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 12px; }
.shot { position: relative; background: var(--card); border-radius: var(--radius); overflow: hidden; aspect-ratio: 4/3.4;
  box-shadow: 0 1px 2px rgba(0,0,0,.06); border: 2px dashed var(--line); }
.shot.has { border-style: solid; border-color: var(--brand-2); }
.shot img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.shotBtn { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
  margin: 0; color: var(--brand-2); font-size: 15px; cursor: pointer; }
.shotBtn .icon { font-size: 36px; }
.shot.has .shotBtn { justify-content: flex-end; padding-bottom: 8px; background: linear-gradient(transparent 55%, rgba(0,0,0,.55)); color: #fff; }
.shot.has .icon { display: none; }
.shot .alt { position: absolute; left: 0; right: 0; bottom: 4px; text-align: center; font-size: 12px; font-weight: 500; margin: 0; color: var(--muted); cursor: pointer; }
.shot.has .alt { display: none; }
.shot:not(.has) .shotBtn { padding-bottom: 16px; }

.notice { border-radius: 10px; padding: 10px 12px; margin-bottom: 12px; font-size: 14px; background: var(--info-bg); color: var(--info); }
.notice.ok { background: var(--ok-bg); color: var(--ok); } .notice.warn { background: var(--warn-bg); color: var(--warn); }
.notice.bad { background: var(--bad-bg); color: var(--bad); }
.link { background: none; border: 0; color: inherit; text-decoration: underline; font: inherit; padding: 0 4px; }
.spin { display: inline-block; width: 14px; height: 14px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%;
  animation: spin .8s linear infinite; vertical-align: -2px; margin-right: 6px; }
@keyframes spin { to { transform: rotate(360deg); } }

.seg { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.seg label { margin: 0; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg span { display: block; text-align: center; padding: 10px 4px; border: 1px solid var(--line); border-radius: 10px; color: var(--text); font-size: 14px; line-height: 1.25; }
.seg small { color: var(--muted); font-weight: 400; }
.seg input:checked + span { border-color: var(--brand-2); background: var(--info-bg); box-shadow: inset 0 0 0 1px var(--brand-2); }

.btn { display: block; width: 100%; padding: 12px; border-radius: 12px; border: 1px solid var(--line); background: var(--card); color: var(--text);
  font: inherit; font-weight: 600; cursor: pointer; margin-bottom: 10px; }
.btn.primary { background: var(--brand-2); border-color: var(--brand-2); color: #fff; }
.btn.big { padding: 16px; font-size: 17px; }
.btn.ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn.small { width: auto; display: inline-block; padding: 8px 12px; font-size: 14px; margin: 0; }
.btn:disabled { opacity: .55; }
.row { display: flex; align-items: center; } .between { justify-content: space-between; } .gap { gap: 10px; } .gap .btn { flex: 1; }

.list { list-style: none; padding: 0; margin: 0 0 16px; }
.list li { display: flex; align-items: center; justify-content: space-between; gap: 10px; background: var(--card); border-radius: 12px;
  padding: 12px 14px; margin-bottom: 8px; cursor: pointer; box-shadow: 0 1px 2px rgba(0,0,0,.05); }
.who { min-width: 0; } .who b, .who span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.who span { font-size: 13px; }
.tag { display: inline-block !important; font-size: 11px; background: var(--warn-bg); color: var(--warn); border-radius: 6px; padding: 1px 6px; margin-top: 3px; }
.chip { flex: none; font-size: 12px; font-weight: 600; border-radius: 999px; padding: 4px 10px; background: var(--bg); color: var(--muted); }
.chip.ok { background: var(--ok-bg); color: var(--ok); } .chip.warn, .chip.pending { background: var(--warn-bg); color: var(--warn); }
.chip.bad { background: var(--bad-bg); color: var(--bad); } .chip.info, .chip.busy { background: var(--info-bg); color: var(--info); }
.settings { display: flex; justify-content: space-between; align-items: center; gap: 8px; font-size: 13px; }

.tabs { position: fixed; left: 0; right: 0; bottom: 0; z-index: 6; display: flex; background: var(--card); border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom); }
.tabs button { flex: 1; border: 0; background: none; padding: 8px 0 10px; font: inherit; font-size: 12px; font-weight: 600; color: var(--muted); }
.tabs button span { display: block; font-size: 20px; }
.tabs button.active { color: var(--brand-2); }

dialog { border: 0; padding: 0; width: 100%; max-width: 560px; max-height: 92vh; margin: auto auto 0; border-radius: 18px 18px 0 0;
  background: var(--card); color: var(--text); }
dialog::backdrop { background: rgba(0,0,0,.45); }
.sheet { padding: 16px 16px calc(16px + env(safe-area-inset-bottom)); }
.sheet h2 { margin: 0; }
#sheetInfo { font-size: 13px; margin: 2px 0 12px; }

.toast { position: fixed; left: 50%; bottom: calc(90px + env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 20;
  background: #14192b; color: #fff; padding: 12px 18px; border-radius: 12px; font-weight: 600; max-width: calc(100% - 32px);
  box-shadow: 0 6px 24px rgba(0,0,0,.25); }

.shotBtn { border: 0; background: none; font: inherit; font-weight: 600; width: 100%; }
.saveG { position: absolute; top: 6px; right: 6px; z-index: 2; border: 0; border-radius: 999px; padding: 5px 10px;
  font: inherit; font-size: 12px; font-weight: 700; background: #fff; color: var(--brand); box-shadow: 0 2px 6px rgba(0,0,0,.25); }
.check.small { font-size: 13px; color: var(--muted); margin: -2px 2px 12px; }
.check.small input { width: 18px; height: 18px; }

/* live camera */
.cam { position: fixed; inset: 0; z-index: 50; background: #000; color: #fff; }
.cam video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.cam video.mirror { transform: scaleX(-1); }
.guide { position: absolute; left: 6%; right: 6%; top: 50%; aspect-ratio: 1.75; transform: translateY(-55%);
  border: 3px solid rgba(255,255,255,.9); border-radius: 14px; box-shadow: 0 0 0 100vmax rgba(0,0,0,.35); pointer-events: none; }
.guide span { position: absolute; left: 0; right: 0; top: calc(100% + 12px); text-align: center; font-size: 14px; font-weight: 600; text-shadow: 0 1px 3px #000; }
.camTop, .camBar { position: absolute; left: 0; right: 0; display: flex; align-items: center; justify-content: space-between; padding: 0 20px; }
.camTop { top: 0; padding-top: calc(12px + env(safe-area-inset-top)); padding-bottom: 12px; background: linear-gradient(rgba(0,0,0,.55), transparent); font-weight: 600; }
.camBar { bottom: 0; padding-top: 18px; padding-bottom: calc(26px + env(safe-area-inset-bottom)); background: linear-gradient(transparent, rgba(0,0,0,.6)); }
.cam button { border: 0; background: rgba(255,255,255,.18); color: #fff; width: 48px; height: 48px; border-radius: 50%; font-size: 22px; }
.camTop span { flex: 1; text-align: center; }
#camTorch[hidden] { display: block !important; visibility: hidden; }
.cam .shutter { width: 76px; height: 76px; background: #fff; box-shadow: 0 0 0 5px rgba(255,255,255,.35); }
.cam .shutter:active { transform: scale(.92); }
.cam .shutter:disabled { opacity: .4; }
.camMsg { position: absolute; left: 24px; right: 24px; top: 35%; text-align: center; font-size: 16px; line-height: 1.5; }
.camMsg .btn { width: auto; height: auto; border-radius: 12px; font-size: 16px; padding: 12px 20px; margin-top: 16px; display: inline-block; }
.flash { position: absolute; inset: 0; background: #fff; opacity: 0; pointer-events: none; }
.flash.go { animation: flash .25s ease-out; }
@keyframes flash { from { opacity: .85; } to { opacity: 0; } }

/* admin */
.admin { max-width: 1200px; }
.admin table { width: 100%; border-collapse: collapse; background: var(--card); border-radius: var(--radius); overflow: hidden; font-size: 14px; }
.admin th, .admin td { text-align: left; padding: 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
.admin th { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; }
.admin td img { width: 64px; height: 48px; object-fit: cover; border-radius: 6px; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 10px; margin-bottom: 12px; }
.stat { background: var(--card); border-radius: 12px; padding: 12px; } .stat b { display: block; font-size: 24px; }
.tablewrap { overflow-x: auto; }

#cardShot img { object-fit: contain; background: #1b1f27; }

.previewDlg { max-width: 680px; height: 92vh; display: none; flex-direction: column; }
.previewDlg[open] { display: flex; }
.previewBar { padding: 12px 16px; gap: 8px; border-bottom: 1px solid var(--line); }
.previewBar b { font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.previewDlg iframe { flex: 1; width: 100%; border: 0; background: #f3f5f9; }
#saveBtn small { font-weight: 400; }
.tplGrid { display: grid; grid-template-columns: 1fr; gap: 12px; }
@media (min-width: 1000px) { .tplGrid { grid-template-columns: 1fr 1fr; } }
textarea.code { font: 13px/1.45 ui-monospace, SFMono-Regular, Consolas, monospace; white-space: pre; overflow: auto; }
.varList { font-size: 13px; margin-top: 8px; display: grid; gap: 4px; }
.varList code, .admin small code { background: var(--bg); border-radius: 4px; padding: 1px 5px; font-size: 12px; }
.previewCard iframe { width: 100%; height: 720px; border: 1px solid var(--line); border-radius: 10px; background: #f3f5f9; }
