* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: #1a202c;
  background: #f7fafc;
}

.hidden { display: none !important; }

.btn {
  padding: 8px 20px;
  border-radius: 6px;
  border: 1px solid #cbd5e0;
  background: #fff;
  cursor: pointer;
  font-size: 14px;
  color: #4a5568;
}
.btn:disabled { cursor: not-allowed; opacity: 0.5; }
.btn-primary { background: #2f7cc0; border-color: #2f7cc0; color: #fff; }
.btn-secondary { background: #fff; }
.btn-nav { flex-shrink: 0; }
.btn-filter { font-size: 12px; padding: 5px 8px; }
.btn-filter.active { background: #ebf8ff; color: #2b6cb0; border-color: #90cdf4; }

.link-btn {
  background: none;
  border: none;
  color: #718096;
  cursor: pointer;
  font-size: 12px;
  padding: 0;
}
.link-btn-danger { color: #e53e3e; }

/* Top bar */
.topbar {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 12px 24px;
  border-bottom: 1px solid #0d3f63;
  background: #0d3f63;
}
.brand-logo { height: 32px; width: 32px; flex-shrink: 0; }
.recent-folders-select {
  padding: 8px 12px;
  border-radius: 6px;
  border: 1px solid #cbd5e0;
  background: #fff;
  cursor: pointer;
  font-size: 14px;
  color: #4a5568;
  max-width: 200px;
}
.title { margin: 0; font-size: 20px; color: #fff; }
.title-accent { color: #d0b17b; font-weight: 400; font-style: italic; }
.spacer { flex: 1; }
.tagged-count { color: #d0b17b; font-size: 14px; }

.empty-state {
  padding: 60px 24px;
  text-align: center;
  color: #718096;
  max-width: 480px;
  margin: 0 auto;
}

/* Workspace layout */
.workspace {
  display: flex;
  gap: 16px;
  padding: 16px;
  height: calc(100vh - 65px);
  overflow: hidden;
}

/* Thumbnail strip */
.thumb-strip {
  width: 160px;
  flex-shrink: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
  overflow: hidden;
}
.checked-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}
.checked-bar span { font-size: 12px; color: #2b6cb0; font-weight: 500; }
.thumb-list {
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: 1;
  min-height: 0;
}
.thumb {
  border-radius: 6px;
  overflow: hidden;
  cursor: pointer;
  border: 2px solid #e2e8f0;
  position: relative;
  flex-shrink: 0;
}
.thumb.selected { border: 4px solid #4299e1; }
.thumb.checked { border: 3px solid #2b6cb0; }
.thumb img {
  width: 100%;
  height: 100px;
  object-fit: cover;
  display: block;
}
.thumb-placeholder {
  height: 100px;
  background: #e2e8f0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  color: #a0aec0;
  text-align: center;
  padding: 4px;
}
.thumb-checkbox {
  position: absolute;
  top: 4px;
  left: 4px;
  width: 16px;
  height: 16px;
  cursor: pointer;
  accent-color: #2b6cb0;
}
.thumb-tag-count {
  position: absolute;
  bottom: 4px;
  right: 4px;
  background: #48bb78;
  color: #fff;
  border-radius: 10px;
  font-size: 11px;
  padding: 1px 6px;
}

/* Main panel */
.main-panel {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
}
.nav-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
}
.tag-input-wrap {
  position: relative;
  flex: 1;
  overflow: visible;
}
.tag-input-row { display: flex; gap: 8px; }
#tag-input {
  flex: 1;
  padding: 8px 12px;
  border: 1px solid #cbd5e0;
  border-radius: 6px;
  font-size: 14px;
}
.tag-suggestions {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  list-style: none;
  padding: 0;
  margin: 4px 0 0;
  z-index: 999;
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
  max-height: 220px;
  overflow-y: auto;
}
.tag-suggestions li {
  padding: 8px 12px;
  cursor: pointer;
  font-size: 14px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.tag-suggestions li.active { background: #ebf8ff; }
.roster-pill {
  font-size: 11px;
  background: #bee3f8;
  color: #2b6cb0;
  border-radius: 4px;
  padding: 1px 6px;
  flex-shrink: 0;
}

.format-notice {
  font-size: 12px;
  color: #975a16;
  background: #fffaf0;
  border: 1px solid #feebc8;
  border-radius: 6px;
  padding: 6px 10px;
  margin-bottom: 8px;
}

.tag-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  min-height: 32px;
  margin-bottom: 12px;
}
.tag-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: #bee3f8;
  color: #2b6cb0;
  border-radius: 20px;
  padding: 4px 10px;
  font-size: 13px;
}
.tag-badge button {
  background: none;
  border: none;
  cursor: pointer;
  color: #2b6cb0;
  font-size: 14px;
  line-height: 1;
  padding: 0;
}
.no-tags { font-size: 13px; color: #a0aec0; }

.photo-frame-wrap {
  flex: 1;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.photo-frame {
  display: flex;
  align-items: center;
  justify-content: center;
  max-width: 100%;
  max-height: 100%;
  overflow: hidden;
  background: #1a1a2e;
  border-radius: 8px;
  cursor: zoom-in;
}
.main-photo {
  max-width: 100%;
  max-height: calc(100vh - 260px);
  object-fit: contain;
  display: block;
}

/* Roster panel */
.roster-panel {
  flex: 1 1 300px;
  min-width: 260px;
  max-width: 480px;
  min-height: 0;
  overflow-y: auto;
}
.roster-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}
.panel-label {
  font-weight: 500;
  font-size: 13px;
  color: #4a5568;
  margin: 0;
}
.extra-label { margin-top: 16px; margin-bottom: 8px; }
.roster-select {
  width: 100%;
  margin-bottom: 10px;
  padding: 6px 8px;
  border: 1px solid #cbd5e0;
  border-radius: 6px;
  font-size: 13px;
  background: #fff;
  color: #2d3748;
}
.chip-row { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  padding: 5px 10px;
  border-radius: 20px;
  cursor: pointer;
  font-size: 13px;
  border: 1px solid #bee3f8;
  background: #fff;
  color: #2b6cb0;
}
.chip:disabled { background: #bee3f8; cursor: not-allowed; }
.chip.extra { border-color: #e9d8fd; color: #6b46c1; }
.chip.extra:disabled { background: #e9d8fd; }

.btn-clear-all {
  margin-top: 20px;
  width: 100%;
  padding: 8px 12px;
  border: 1px solid #feb2b2;
  border-radius: 6px;
  background: #fff5f5;
  color: #c53030;
  cursor: pointer;
  font-size: 13px;
}
.btn-clear-all:hover { background: #fed7d7; }

/* Modals */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
}
.modal {
  background: #fff;
  border-radius: 12px;
  padding: 32px;
  max-width: 420px;
  width: 90%;
  text-align: center;
  box-shadow: 0 8px 32px rgba(0,0,0,0.2);
}
.modal h2 { margin: 0 0 12px; color: #0d3f63; }
.modal-actions { display: flex; justify-content: center; gap: 10px; }

.clear-all-modal { max-width: 360px; }
.progress-text { color: #4a5568; margin-bottom: 16px; font-size: 14px; }
.progress-track {
  width: 100%;
  height: 10px;
  background: #edf2f7;
  border-radius: 6px;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  width: 0%;
  background: #2f7cc0;
  transition: width 0.15s ease;
}

.roster-modal { max-width: 460px; text-align: left; }
.roster-switcher { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; flex-wrap: wrap; }
.roster-switcher .roster-select { flex: 1; min-width: 0; margin-bottom: 0; }
.roster-io { display: flex; align-items: center; gap: 10px; margin-bottom: 16px; flex-wrap: wrap; }
.roster-name-edit-section { display: flex; gap: 8px; margin-bottom: 16px; }
.roster-name-edit-section input {
  flex: 1;
  padding: 8px 10px;
  border: 1px solid #cbd5e0;
  border-radius: 6px;
  font-size: 14px;
}
.roster-form { display: flex; gap: 8px; margin-bottom: 16px; }
.roster-form input {
  padding: 8px 10px;
  border: 1px solid #cbd5e0;
  border-radius: 6px;
  font-size: 14px;
}
#roster-name-input { flex: 1; }
.roster-number-input { width: 70px; }

.roster-import { margin-bottom: 16px; }
.csv-import-section { margin-top: 8px; }
.csv-import-textarea {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid #cbd5e0;
  border-radius: 6px;
  font-size: 13px;
  font-family: inherit;
  resize: vertical;
}
.csv-import-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 8px;
}
.csv-import-status { font-size: 12px; color: #718096; }
.roster-list { list-style: none; padding: 0; margin: 0 0 16px; max-height: 260px; overflow-y: auto; }
.roster-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 0;
  border-bottom: 1px solid #edf2f7;
  font-size: 14px;
}
.roster-list li button {
  background: none;
  border: none;
  color: #e53e3e;
  cursor: pointer;
  font-size: 13px;
}

/* Lightbox */
.lightbox {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.92);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: zoom-out;
}
.lightbox img {
  max-width: 95vw;
  max-height: 95vh;
  object-fit: contain;
  border-radius: 4px;
}
.lightbox-close {
  position: absolute;
  top: 20px;
  right: 24px;
  background: none;
  border: none;
  color: #fff;
  font-size: 32px;
  cursor: pointer;
  line-height: 1;
}

/* Unsupported browser */
.unsupported {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #f7fafc;
  padding: 24px;
}
.unsupported-box {
  max-width: 420px;
  text-align: center;
  background: #fff;
  border-radius: 12px;
  padding: 32px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.1);
}
