:root {
  --bg: #0f172a;
  --panel: #1e293b;
  --line: #334155;
  --text: #e2e8f0;
  --muted: #94a3b8;
  --accent: #22c55e;
  --danger: #ef4444;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
body { min-height: 100vh; padding-bottom: env(safe-area-inset-bottom); }
[hidden] { display: none !important; }

.topbar { display: flex; align-items: center; justify-content: space-between; padding: 12px 16px; background: var(--panel); border-bottom: 1px solid var(--line); }
.topbar h1 { margin: 0; font-size: 1.1rem; }
.icon-btn { background: none; border: 0; color: var(--text); font-size: 1.4rem; padding: 4px 10px; cursor: pointer; }

.warning { margin: 12px 16px; padding: 12px; border-radius: 8px; background: #7f1d1d; color: #fee2e2; }

.camera { position: relative; margin: 12px auto; max-width: 720px; background: #000; aspect-ratio: 4 / 3; overflow: hidden; border-radius: 10px; }
.camera video, .camera canvas { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.camera-actions { position: absolute; left: 0; right: 0; bottom: 10px; display: flex; gap: 8px; justify-content: center; }

.btn { background: var(--panel); color: var(--text); border: 1px solid var(--line); padding: 10px 16px; border-radius: 8px; font-size: 1rem; cursor: pointer; }
.btn.primary { background: var(--accent); color: #052e16; border-color: var(--accent); font-weight: 600; }
.btn.danger { color: #fecaca; border-color: var(--danger); }
.btn.small { padding: 6px 12px; font-size: .85rem; }
.btn.block { width: 100%; margin-top: 12px; }
.btn.on { background: #facc15; color: #422006; border-color: #facc15; }

.list-section { max-width: 720px; margin: 0 auto; padding: 0 16px 24px; }
.list-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.list-head h2 { font-size: 1.05rem; margin: 8px 0; }
.list-actions { display: flex; gap: 6px; }
.badge { background: var(--accent); color: #052e16; border-radius: 999px; padding: 1px 9px; font-size: .85rem; margin-left: 4px; }

.list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.list li { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; display: flex; gap: 10px; align-items: center; }
.list li.new { border-color: var(--accent); }
.item-main { flex: 1; min-width: 0; }
.item-value { font-weight: 600; word-break: break-all; }
.item-meta { color: var(--muted); font-size: .8rem; margin-top: 2px; }
.item-btn { background: none; border: 0; color: var(--muted); font-size: 1.1rem; cursor: pointer; padding: 6px; }
.empty { color: var(--muted); text-align: center; }

.modal { position: fixed; inset: 0; background: rgba(0,0,0,.6); display: flex; align-items: flex-end; justify-content: center; z-index: 10; }
.modal-body { background: var(--panel); width: 100%; max-width: 520px; max-height: 90vh; overflow: auto; border-radius: 16px 16px 0 0; padding: 16px; }
.modal-head { display: flex; justify-content: space-between; align-items: center; }
.modal-head h2 { margin: 0; font-size: 1.1rem; }
.field { display: block; margin: 12px 0; color: var(--muted); }
.field select { display: block; width: 100%; margin-top: 6px; padding: 10px; background: var(--bg); color: var(--text); border: 1px solid var(--line); border-radius: 8px; font-size: 1rem; }
fieldset { border: 1px solid var(--line); border-radius: 8px; margin: 12px 0; padding: 10px 12px; }
legend { color: var(--muted); padding: 0 6px; }
.formats { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.check { display: flex; align-items: center; gap: 8px; padding: 6px 0; }
.check input { width: 20px; height: 20px; accent-color: var(--accent); }
.hint { color: var(--muted); font-size: .8rem; margin: 8px 0 0; }

.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: #0b1220; border: 1px solid var(--line); padding: 10px 16px; border-radius: 999px; z-index: 20; }

@media (min-width: 720px) { .modal { align-items: center; } .modal-body { border-radius: 16px; } }
