:root {
  --bg: #111; --panel: #1a1a1a; --border: #2c2c2c; --text: #eee; --muted: #888;
  --accent: #4a9eff; --danger: #e05555; --radius: 10px;
}
* { box-sizing: border-box; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 16px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  -webkit-tap-highlight-color: transparent;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }

.screen { display: none; min-height: 100vh; padding: 12px; padding-bottom: 80px; }
.screen.active { display: block; }

/* Login */
#login-screen { align-items: center; justify-content: center; min-height: 100vh; }
#login-screen.active { display: flex; }
.login-box { width: 100%; max-width: 320px; }
.login-box h1 { text-align: center; margin-bottom: 24px; }
.login-box input { width: 100%; padding: 14px; margin-bottom: 10px; border-radius: var(--radius); border: 1px solid var(--border); background: var(--panel); }
.login-box button { width: 100%; padding: 14px; border-radius: var(--radius); border: none; background: var(--accent); color: #fff; font-weight: 600; }
.login-error { color: var(--danger); text-align: center; min-height: 20px; margin-bottom: 8px; }

/* Nav */
.tabbar { position: fixed; bottom: 0; left: 0; right: 0; display: flex; background: var(--panel); border-top: 1px solid var(--border); z-index: 20; }
.tabbar button { flex: 1; padding: 14px 0; background: none; border: none; color: var(--muted); font-size: 13px; }
.tabbar button.active { color: var(--accent); }

/* Capture */
.field-group { margin-bottom: 14px; }
.field-group label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; }
select, .text-input { width: 100%; padding: 12px; border-radius: var(--radius); border: 1px solid var(--border); background: var(--panel); }
.chip-row { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.chip { padding: 6px 12px; border-radius: 999px; background: var(--panel); border: 1px solid var(--border); font-size: 13px; color: var(--muted); }
.chip.active { background: var(--accent); color: #fff; border-color: var(--accent); }
#capture-photo-input { display: none; }
.photo-picker-btn { display: block; width: 100%; padding: 40px 0; text-align: center; border-radius: var(--radius); border: 2px dashed var(--border); background: var(--panel); color: var(--muted); margin-bottom: 14px; }
.photo-preview { width: 100%; border-radius: var(--radius); margin-bottom: 14px; display: none; }
#save-capture-btn { width: 100%; padding: 16px; border-radius: var(--radius); border: none; background: var(--accent); color: #fff; font-weight: 700; font-size: 17px; margin-bottom: 14px; }
#save-capture-btn:disabled { opacity: 0.5; }
textarea.text-input { min-height: 70px; resize: vertical; }
.queue-note { text-align: center; color: var(--muted); font-size: 13px; margin-top: 6px; }

/* Grid */
.search-row { display: flex; gap: 8px; margin-bottom: 10px; }
.search-row input { flex: 1; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); gap: 6px; }
.grid img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 6px; background: var(--panel); }
.grid .cell { position: relative; }
.empty-state { text-align: center; color: var(--muted); margin-top: 60px; }

/* Swipe / full-screen viewer */
#viewer { position: fixed; inset: 0; background: #000; z-index: 50; display: none; flex-direction: column; }
#viewer.active { display: flex; }
#viewer-imgwrap { flex: 1; position: relative; overflow: hidden; touch-action: pan-y; }
#viewer-imgwrap img { position: absolute; top: 0; left: 0; width: 100%; height: 100%; object-fit: contain; }
.viewer-bar { display: flex; justify-content: space-between; align-items: center; padding: 12px 16px; color: #fff; }
.viewer-bar button { background: none; border: none; color: #fff; font-size: 15px; padding: 8px; }
.viewer-caption { color: #ccc; text-align: center; padding: 0 16px 16px; font-size: 14px; }

/* Detail / edit sheet */
#detail-sheet { position: fixed; inset: 0; background: var(--bg); z-index: 60; display: none; overflow-y: auto; padding: 12px; padding-bottom: 100px; }
#detail-sheet.active { display: block; }
#detail-sheet img { width: 100%; border-radius: var(--radius); margin-bottom: 14px; }
.detail-actions { display: flex; gap: 10px; margin-top: 20px; }
.detail-actions button { flex: 1; padding: 14px; border-radius: var(--radius); border: none; font-weight: 600; }
#detail-save-btn { background: var(--accent); color: #fff; }
#detail-delete-btn { background: var(--danger); color: #fff; }
.close-btn { background: none; border: none; color: var(--muted); font-size: 15px; padding: 8px 0 16px; }
