:root {
  color-scheme: dark;
  --bg: #000;
  --fg: #f5f5f5;
  --muted: rgba(255, 255, 255, 0.72);
  --glass: rgba(0, 0, 0, 0.55);
  --accent: #ffd60a;
  --ok: #30d158;
  --warn: #ff9f0a;
  --bad: #ff453a;
  font: 16px/1.35 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--fg); }
button { font: inherit; color: inherit; cursor: pointer; }
button:disabled { opacity: 0.4; cursor: default; }
[hidden] { display: none !important; }

/* --- login ----------------------------------------------------------------- */
body.login { display: grid; place-items: center; padding: 24px; }
.card { width: min(360px, 100%); display: grid; gap: 12px; }
.card h1 { margin: 0 0 8px; font-size: 28px; }
.card input {
  font: inherit; padding: 14px; border-radius: 12px; border: 1px solid #444;
  background: #111; color: var(--fg);
}
.card button[type="submit"] {
  padding: 14px; border: 0; border-radius: 12px; background: var(--accent); color: #000; font-weight: 600;
}
.error { color: var(--bad); margin: 0; }

/* --- capture --------------------------------------------------------------- */
body.capture { overflow: hidden; touch-action: manipulation; user-select: none; -webkit-user-select: none; }
/* contain, not cover: the preview must show exactly what is captured (no cropped edges). */
#preview { position: fixed; inset: 0; width: 100%; height: 100%; object-fit: contain; background: #000; }
#flash { position: fixed; inset: 0; background: #fff; opacity: 0; pointer-events: none; }
#flash.on { animation: flash 180ms ease-out; }
@keyframes flash { from { opacity: 0.7; } to { opacity: 0; } }

.bar { position: fixed; left: 0; right: 0; display: flex; align-items: center; gap: 8px; padding: 12px; }
.bar.top { top: 0; padding-top: max(12px, env(safe-area-inset-top)); justify-content: center; flex-wrap: wrap; }
.bar.bottom {
  bottom: 0; padding-bottom: max(20px, env(safe-area-inset-bottom));
  justify-content: space-between; background: linear-gradient(transparent, rgba(0, 0, 0, 0.6));
}
.pill { background: var(--glass); padding: 6px 12px; border-radius: 999px; font-size: 15px; font-variant-numeric: tabular-nums; }
.pill:empty { display: none; }
#offline { background: var(--warn); color: #000; font-weight: 600; }

.shutter {
  width: 78px; height: 78px; border-radius: 50%; border: 5px solid #fff; background: #fff;
  box-shadow: inset 0 0 0 3px #000; flex: none;
}
.shutter:active:not(:disabled) { transform: scale(0.94); }
.secondary { min-width: 92px; padding: 10px 14px; border: 0; border-radius: 999px; background: var(--glass); }

.uploads {
  position: fixed; left: 12px; right: 12px; bottom: calc(130px + env(safe-area-inset-bottom));
  margin: 0; padding: 0; list-style: none; display: grid; gap: 6px; max-height: 40vh; overflow-y: auto;
}
.uploads li {
  display: flex; align-items: center; gap: 8px; padding: 8px 12px; border-radius: 12px;
  background: var(--glass); font-size: 14px;
}
.uploads li span { flex: 1; }
.uploads li[data-kind="ok"] {
  justify-self: center; padding: 4px 10px; background: rgba(0, 0, 0, 0.25); font-size: 12px; opacity: 0.55;
}
.uploads li[data-kind="ok"] span { color: var(--ok); }
.uploads li[data-kind="retry"] span { color: var(--warn); }
.uploads li[data-kind="failed"] span { color: var(--bad); }
.uploads li button { border: 0; border-radius: 8px; padding: 6px 10px; background: #333; }
.uploads li button.danger { background: var(--bad); }

.panel, .toast {
  position: fixed; left: 12px; right: 12px; top: calc(64px + env(safe-area-inset-top));
  padding: 14px; border-radius: 14px; background: rgba(28, 28, 30, 0.95);
}
.panel a { color: var(--accent); }
.toast[data-kind="error"] { border-left: 4px solid var(--bad); }
