:root {
  --bg: #f8fafc;
  --surface: #ffffff;
  --border: #e2e8f0;
  --text: #1e293b;
  --text-muted: #64748b;
  --accent: #2563eb;
  --accent-hover: #1d4ed8;
  --success: #16a34a;
  --success-bg: #dcfce7;
  --warning: #b45309;
  --warning-bg: #fef3c7;
  --danger: #991b1b;
  --danger-bg: #fee2e2;
  --danger-border: #fca5a5;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
}

* { box-sizing: border-box; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  margin: 0;
}

.nav {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 14px 24px;
  display: flex;
  align-items: center;
  gap: 24px;
}
.nav .brand { font-weight: 700; font-size: 1.15rem; color: var(--text); text-decoration: none; }
.nav a:not(.brand) { color: var(--text-muted); text-decoration: none; font-size: 0.9rem; }
.nav a:not(.brand):hover { color: var(--accent); }

.container { max-width: 960px; margin: 0 auto; padding: 40px 24px 60px; }
.container.narrow { max-width: 620px; }

h1 { font-size: 1.5rem; margin: 0 0 10px; }
p.hint { color: var(--text-muted); font-size: 0.9rem; line-height: 1.5; }
code { background: #f1f5f9; padding: 2px 6px; border-radius: 4px; font-size: 0.85em; }
a { color: var(--accent); }
hr { border: none; border-top: 1px solid var(--border); margin: 32px 0; }

.btn {
  background: var(--accent); color: white; border: none; padding: 11px 22px;
  border-radius: 8px; font-size: 0.95rem; cursor: pointer; font-weight: 500;
}
.btn:hover { background: var(--accent-hover); }
.btn:disabled { background: #cbd5e1; cursor: not-allowed; }
.btn-secondary { background: var(--surface); color: var(--text-muted); border: 1px solid var(--border); margin-left: 10px; }
.btn-secondary:hover { background: var(--bg); }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 18px; margin-top: 20px; }

.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 14px; box-shadow: var(--shadow);
}
.card img { width: 100%; height: 160px; object-fit: cover; border-radius: 6px; display: block; margin-bottom: 10px; background: #f1f5f9; }
.card img.clickable { cursor: zoom-in; }

.lightbox {
  display: none; position: fixed; inset: 0; background: rgba(0, 0, 0, 0.85);
  align-items: center; justify-content: center; padding: 30px; z-index: 1000; cursor: zoom-out;
}
.lightbox.open { display: flex; }
/* The photo-zoom lightbox can be opened from inside the vault-compare
   modal (both share .lightbox, same base z-index) -- it must always paint
   on top of that modal, not behind it, regardless of DOM order. */
#lightbox { z-index: 1100; }
.lightbox img { max-width: 100%; max-height: 100%; border-radius: 8px; box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5); }
.card .fname { font-size: 0.78rem; color: var(--text-muted); margin-bottom: 8px; word-break: break-all; }
.card h2 { font-size: 1rem; margin: 0 0 6px; }

select {
  width: 100%; padding: 8px 10px; border-radius: 7px; border: 1px solid var(--border);
  font-size: 0.9rem; background: var(--surface); color: var(--text);
}
.exclude-toggle { display: flex; align-items: center; gap: 6px; margin-top: 10px; font-size: 0.85rem; color: var(--text-muted); cursor: pointer; }
.replace-file-label { display: block; margin-top: 10px; font-size: 0.82rem; color: var(--text-muted); }
.replace-file-label .replace-input { display: block; margin-top: 4px; font-size: 0.8rem; width: 100%; }
.replace-status { color: var(--accent); font-weight: 600; }
.gps-warn { margin-top: 8px; font-size: 0.8rem; color: var(--warning); background: var(--warning-bg); border-radius: 6px; padding: 6px 8px; }
.card.gps-flag { background: var(--danger-bg); }
.vault-preview-link { background: none; border: none; padding: 0; margin: 0; color: inherit; text-decoration: underline; font: inherit; font-weight: 600; cursor: pointer; }
.gps-map-legend { display: flex; flex-wrap: wrap; gap: 8px 20px; margin: 10px 0 18px; font-size: 0.82rem; color: var(--text-muted); }
.gps-map-legend .dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 6px; vertical-align: middle; }
.vault-preview-panel { background: var(--surface); border-radius: var(--radius); padding: 24px; max-width: 1080px; width: 92%; max-height: 82vh; overflow-y: auto; cursor: default; }
.vault-preview-compare { display: grid; grid-template-columns: 1fr 1fr; gap: 28px; align-items: start; }
.vault-preview-subhead { font-size: 0.78rem; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.05em; margin: 0 0 10px; }
.vault-preview-featured.grid .card img { height: 300px; }
.vault-preview-gallery.grid { grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 12px; margin-top: 0; }
.vault-preview-gallery .card { padding: 8px; }
.vault-preview-gallery .card img { height: 100px; margin-bottom: 6px; }
.vault-preview-gallery .fname { margin-bottom: 0; font-size: 0.72rem; }
@media (max-width: 640px) {
  .vault-preview-compare { grid-template-columns: 1fr; }
}

.badge { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 0.78rem; font-weight: 600; }
.badge.done { background: var(--success-bg); color: var(--success); }
.badge.pending { background: var(--warning-bg); color: var(--warning); }
.badge.set { background: var(--success-bg); color: var(--success); }
.badge.unset { background: var(--danger-bg); color: var(--danger); }

.alert { background: var(--danger-bg); border: 1px solid var(--danger-border); color: var(--danger); padding: 12px 16px; border-radius: 8px; margin-bottom: 18px; font-size: 0.9rem; }
.alert.warning { background: var(--warning-bg); border-color: #fde68a; color: var(--warning); }
.alert a { color: inherit; text-decoration: underline; }

.history-table { width: 100%; border-collapse: collapse; margin-top: 20px; font-size: 0.9rem; line-height: 1.5; }
.history-table th, .history-table td { text-align: left; padding: 16px 32px 16px 0; border-bottom: 1px solid var(--border); }
.history-table th { color: var(--text-muted); font-weight: 600; font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.05em; }
.history-table th a { color: inherit; text-decoration: none; }
.history-table th a:hover { color: var(--accent); text-decoration: underline; }
.history-table tr.dupe { background: var(--warning-bg); }
.history-table .badge { margin-left: 8px; }
.btn-delete-row { background: none; border: 1px solid var(--danger-border); color: var(--danger); padding: 5px 12px; border-radius: 6px; font-size: 0.8rem; cursor: pointer; }
.btn-delete-row:hover { background: var(--danger-bg); }
.btn-download-row { display: inline-block; background: none; border: 1px solid var(--border); color: var(--accent); padding: 5px 12px; border-radius: 6px; font-size: 0.8rem; text-decoration: none; }
.btn-download-row:hover { background: var(--bg); }
.reject-panel { margin-top: 36px; padding-top: 20px; border-top: 1px solid var(--border); max-width: 520px; }
/* Folder History page specifically -- its columns (folder name, area,
   count, two timestamps) all read better on one line; the vault edit-log
   table reuses .history-table too but has long free-text "what changed"
   entries that need to wrap, so nowrap is scoped here, not on the shared
   class. */
.folder-history-table td { white-space: nowrap; }

.dropzone {
  border: 2px dashed #cbd5e1; border-radius: var(--radius); padding: 52px 20px; text-align: center;
  color: var(--text-muted); margin: 20px 0; transition: background 0.15s, border-color 0.15s;
  font-size: 0.95rem;
}
.dropzone.drag { background: #eff6ff; border-color: var(--accent); color: var(--accent); }

ul.plain { padding-left: 20px; margin: 10px 0; }
ul.plain li { margin-bottom: 8px; }

/* AI on/off toggle */
.toggle-row { display: flex; align-items: center; gap: 12px; margin: 18px 0; }
.toggle-switch { position: relative; display: inline-block; width: 44px; height: 24px; flex: none; }
.toggle-switch input { opacity: 0; width: 0; height: 0; }
.toggle-slider { position: absolute; cursor: pointer; inset: 0; background: #cbd5e1; transition: 0.2s; border-radius: 999px; }
.toggle-slider::before { content: ""; position: absolute; height: 18px; width: 18px; left: 3px; top: 3px; background: white; transition: 0.2s; border-radius: 50%; box-shadow: 0 1px 2px rgba(0,0,0,0.2); }
.toggle-switch input:checked + .toggle-slider { background: var(--accent); }
.toggle-switch input:checked + .toggle-slider::before { transform: translateX(20px); }
.toggle-label { font-size: 0.92rem; font-weight: 600; }
.toggle-sub { font-size: 0.8rem; color: var(--text-muted); }

/* Upload status panel */
.upload-panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 20px; margin: 16px 0; box-shadow: var(--shadow); }
#dropSummaryList { margin-bottom: 14px; line-height: 1.6; }
.upload-panel-header { display: flex; justify-content: space-between; font-size: 0.85rem; color: var(--text-muted); margin-bottom: 10px; }
.progress-track { background: #e2e8f0; height: 8px; border-radius: 4px; overflow: hidden; }
.progress-track.small { height: 5px; margin-top: 12px; }
.progress-fill { background: var(--accent); height: 100%; width: 0%; transition: width 0.2s ease; }
.upload-current { display: flex; align-items: center; gap: 10px; margin-top: 14px; font-size: 0.88rem; color: var(--text); }
.spinner { width: 14px; height: 14px; border: 2px solid #cbd5e1; border-top-color: var(--accent); border-radius: 50%; animation: spin 0.7s linear infinite; flex: none; }
@keyframes spin { to { transform: rotate(360deg); } }
