:root {
  color-scheme: dark;
  zoom: 1.75;
}

.hidden { display: none !important; }

body {
  margin: 0;
  font: 14px/1.4 system-ui, -apple-system, sans-serif;
  background: #14161a;
  color: #e6e6e6;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  background: #1b1e24;
  border-bottom: 1px solid #2a2f38;
}

header {
  display: flex;
  gap: 16px;
  align-items: center;
  padding: 10px 20px 6px;
}
header h1 { font-size: 16px; margin: 0; }
#counter { color: #8b93a1; font-size: 13px; }

#filters {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 28px;
  padding: 6px 20px 12px;
}
.filter-group {
  display: flex;
  align-items: flex-start;
  gap: 8px;
}
.filter-label {
  font-size: 12px;
  color: #8b93a1;
  padding-top: 2px;
  white-space: nowrap;
}
.filter-items {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 12px;
}
.filter-item {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  color: #cfd4dc;
  cursor: pointer;
  user-select: none;
}
.filter-item input { cursor: pointer; margin: 0; }

main {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 12px;
  padding: 20px;
}

.card {
  border: 3px solid #d33;
  border-radius: 8px;
  overflow: hidden;
  cursor: pointer;
  background: #1b1e24;
  user-select: none;
  transition: border-color .12s ease;
}
.card.selected { border-color: #2ecc71; }

.thumb {
  display: block;
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  background: #000;
}

.thumb.placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  font-weight: 600;
  color: #4a5260;
  background: #101216;
  letter-spacing: 1px;
}

.card .name {
  padding: 6px 8px;
  font-size: 12px;
  text-align: center;
  word-break: break-all;
  color: #cfd4dc;
}
.card.selected .name { color: #2ecc71; }

.card.new { border-color: #e67e22; }

.boot-status {
  color: #8b93a1;
  font-size: 13px;
  margin: 0;
  grid-column: 1 / -1;
}
.boot-status.error { color: #e74c3c; }

/* preset bar */
.preset-bar {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-left: auto;
}

#preset-select {
  background: #101216;
  color: #e6e6e6;
  border: 1px solid #2a2f38;
  border-radius: 6px;
  padding: 5px 8px;
  font: inherit;
  font-size: 13px;
  cursor: pointer;
  min-width: 150px;
}
#preset-select.clean { color: #2ecc71; border-color: #2ecc71; }
#preset-select.dirty { color: #e74c3c; border-color: #e74c3c; }
#preset-select option { color: #e6e6e6; background: #101216; }

#save-btn, #export-btn, #import-btn, #delete-btn, #info-btn {
  background: #2a2f38;
  color: #e6e6e6;
  border: 1px solid #3a414d;
  border-radius: 6px;
  padding: 5px 12px;
  font: inherit;
  font-size: 13px;
  cursor: pointer;
}
#save-btn:hover, #export-btn:hover, #import-btn:hover, #info-btn:hover { background: #333a45; }

#info-btn {
  width: 28px;
  padding: 5px 0;
  text-align: center;
  font-weight: 700;
  border-radius: 50%;
}

#delete-btn {
  background: #2a1a1a;
  border-color: #4a2020;
  color: #e74c3c;
}
#delete-btn:hover { background: #3a2020; }

/* alert bar */
#alert-bar {
  padding: 8px 20px;
  background: #2a1a1a;
  border-top: 1px solid #4a2020;
  border-bottom: 1px solid #4a2020;
  color: #e74c3c;
  font-size: 13px;
  line-height: 1.5;
}
#alert-bar div + div { margin-top: 4px; }

/* modal */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}
.modal {
  background: #1b1e24;
  border: 1px solid #2a2f38;
  border-radius: 10px;
  padding: 20px;
  width: 420px;
  max-width: calc(100vw - 40px);
  max-height: 80vh;
  overflow-y: auto;
}
.modal.modal-wide {
  width: 680px;
}

.modal.modal-wide .modal-actions {
  margin-top: 28px;
}
.modal h2 { margin: 0 0 10px; font-size: 16px; }
.modal p {
  margin: 0 0 14px;
  color: #b7bec9;
  font-size: 13px;
  white-space: pre-line;
}
.modal input {
  width: 100%;
  box-sizing: border-box;
  background: #101216;
  color: #e6e6e6;
  border: 1px solid #2a2f38;
  border-radius: 6px;
  padding: 8px 10px;
  font: inherit;
  font-size: 13px;
  margin-bottom: 14px;
}
.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}
.modal-actions button {
  background: #2a2f38;
  color: #e6e6e6;
  border: 1px solid #3a414d;
  border-radius: 6px;
  padding: 6px 14px;
  font: inherit;
  font-size: 13px;
  cursor: pointer;
}

/* download controls */
.top-controls {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
  margin-left: auto;
}

#folder-btn {
  background: #2a2f38;
  color: #e6e6e6;
  border: 1px solid #3a414d;
  border-radius: 6px;
  padding: 5px 12px;
  font: inherit;
  font-size: 13px;
  cursor: pointer;
}
#folder-btn:hover { background: #333a45; }

.folder-status {
  font-size: 12px;
  color: #8b93a1;
  max-width: 180px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.folder-status.set { color: #2ecc71; }

.inline-toggle {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  color: #cfd4dc;
  cursor: pointer;
  user-select: none;
}
.inline-toggle input[type="checkbox"] { cursor: pointer; margin: 0; }
.inline-toggle input[type="number"] {
  background: #101216;
  color: #e6e6e6;
  border: 1px solid #2a2f38;
  border-radius: 6px;
  padding: 4px 6px;
  font: inherit;
  font-size: 12px;
  width: 46px;
}

#download-btn {
  background: #24503a;
  border: 1px solid #2ecc71;
  color: #b8f0cf;
  border-radius: 6px;
  padding: 5px 14px;
  font: inherit;
  font-size: 13px;
  cursor: pointer;
}
#download-btn:hover:not(:disabled) { background: #2b6247; }
#download-btn:disabled {
  background: #22262c;
  border-color: #333942;
  color: #5b636e;
  cursor: not-allowed;
}

#download-btn.scanning {
  background: #4a3a20;
  border-color: #e67e22;
  color: #f5d9b0;
}

/* progress bar */
#progress-bar {
  padding: 8px 20px 10px;
  background: #16211b;
  border-top: 1px solid #24503a;
  border-bottom: 1px solid #24503a;
}
.progress-head {
  display: flex;
  gap: 12px;
  align-items: center;
  font-size: 12px;
}
#progress-text { color: #b8f0cf; white-space: nowrap; }
#progress-current {
  color: #8b93a1;
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
#progress-cancel {
  background: #2a1a1a;
  color: #e74c3c;
  border: 1px solid #4a2020;
  border-radius: 6px;
  padding: 3px 10px;
  font: inherit;
  font-size: 12px;
  cursor: pointer;
  white-space: nowrap;
}
#progress-cancel:hover:not(:disabled) { background: #3a2020; }
#progress-cancel:disabled { opacity: .6; cursor: default; }
.progress-track {
  height: 6px;
  background: #0d1512;
  border-radius: 3px;
  margin-top: 6px;
  overflow: hidden;
}
#progress-fill {
  height: 100%;
  width: 0;
  background: #2ecc71;
  transition: width .2s ease;
}

/* search and batch selection */
.search-and-actions {
  display: flex;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
  padding: 8px 20px;
  background: #181b21;
  border-bottom: 1px solid #23272f;
}

#search-input {
  background: #101216;
  color: #e6e6e6;
  border: 1px solid #2a2f38;
  border-radius: 6px;
  padding: 5px 10px;
  font: inherit;
  font-size: 13px;
  width: 220px;
}
#search-input::placeholder { color: #5b636e; }
#search-input:focus { border-color: #3a414d; outline: none; }

.batch-buttons {
  display: flex;
  gap: 6px;
  align-items: center;
  flex-wrap: wrap;
}

.btn-subtle {
  background: #22262c;
  color: #cfd4dc;
  border: 1px solid #2e343f;
  border-radius: 6px;
  padding: 4px 10px;
  font: inherit;
  font-size: 12px;
  cursor: pointer;
}
.btn-subtle:hover {
  background: #2a303a;
  color: #fff;
}

/* browser support warning */
#browser-warning {
  padding: 12px 20px;
  background: #3a2a10;
  border-bottom: 2px solid #e67e22;
  color: #f5d9b0;
  font-size: 13px;
  line-height: 1.6;
}

/* support links in the info modal */
.modal-support {
  margin: 16px 0 0;
  padding-top: 16px;
  border-top: 1px solid #2a2f38;
}
.modal-support h3 {
  margin: 0 0 10px;
  font-size: 13px;
  font-weight: 600;
  color: #cfd4dc;
}
.support-links {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}
.support-link {
  flex: 1;
  min-width: 130px;
  padding: 8px 14px;
  border-radius: 6px;
  text-decoration: none;
  text-align: center;
  font-weight: 600;
  font-size: 13px;
  transition: filter .12s ease;
}
.support-link:hover { filter: brightness(1.12); }
.support-link.bmac { background: #ffdd00; color: #000; }
.support-link.venmo { background: #3D95CE; color: #fff; }

#browser-warning strong { color: #ffb347; }
#browser-warning a { color: #ffb347; }

.modal-actions button:hover { background: #333a45; }
#modal-confirm { background: #3a414d; }