/* PhotoPick — theme tokens + layout */

:root,
[data-theme="dark"] {
  --bg: #1a1b1e;
  --bg-elevated: #232427;
  --bg-input: #1a1b1e;
  --bg-thumb: #101012;
  --bg-hover: #2c2d30;
  --bg-secondary: #333;
  --bg-secondary-hover: #3d3d3d;
  --border: #333;
  --border-strong: #444;
  --border-modal: #3a3b40;
  --border-secondary: #555;
  --text: #e6e6e6;
  --text-muted: #999;
  --text-dim: #aaa;
  --text-faint: #777;
  --text-tab: #b5b5b5;
  --text-strong: #ddd;
  --text-filename: #eee;
  --accent: #4a90d9;
  --accent-bg: #2a5b8c;
  --accent-bg-hover: #326aa3;
  --danger-border: #c0392b;
  --danger-bg: #7a2b22;
  --danger-bg-hover: #93362b;
  --progress: #9fd18c;
  --missing: #e0a090;
  --modal-overlay: rgba(10, 10, 12, 0.72);
  --shadow: 0 16px 48px rgba(0, 0, 0, 0.45);
  --settings-icon: #c8c8c8;
  --settings-icon-hover: #fff;
}

[data-theme="light"] {
  --bg: #f3f4f6;
  --bg-elevated: #ffffff;
  --bg-input: #ffffff;
  --bg-thumb: #e6e7ea;
  --bg-hover: #eceef1;
  --bg-secondary: #e8eaed;
  --bg-secondary-hover: #dfe1e5;
  --border: #dddfe3;
  --border-strong: #c5c8ce;
  --border-modal: #d0d3d8;
  --border-secondary: #c5c8ce;
  --text: #1c1d21;
  --text-muted: #6b6f76;
  --text-dim: #5c6068;
  --text-faint: #8a8f98;
  --text-tab: #5c6068;
  --text-strong: #2a2d33;
  --text-filename: #1c1d21;
  --accent: #2f6fad;
  --accent-bg: #2f6fad;
  --accent-bg-hover: #255a8c;
  --danger-border: #b83a2f;
  --danger-bg: #c0453a;
  --danger-bg-hover: #a3382f;
  --progress: #2f7a45;
  --missing: #a85a40;
  --modal-overlay: rgba(30, 32, 36, 0.45);
  --shadow: 0 16px 40px rgba(0, 0, 0, 0.12);
  --settings-icon: #5c6068;
  --settings-icon-hover: #1c1d21;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 14px;
}

.update-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 16px;
  background: var(--accent-bg);
  color: #fff;
  border-bottom: 1px solid color-mix(in srgb, var(--accent) 70%, #000);
}

.update-banner.hidden { display: none; }

.update-banner-body {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
  min-width: 0;
  flex: 1;
}

.update-banner-title { font-weight: 600; }

.update-banner-notes {
  opacity: 0.92;
  font-size: 13px;
}

.update-banner-notes.hidden { display: none; }

.update-banner-download {
  color: #fff;
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.update-banner-download:hover { opacity: 0.9; }

.update-banner-dismiss {
  flex-shrink: 0;
  border: 1px solid rgba(255, 255, 255, 0.45);
  background: transparent;
  color: #fff;
  border-radius: 6px;
  padding: 4px 10px;
  cursor: pointer;
  font-size: 13px;
}

.update-banner-dismiss:hover {
  background: rgba(255, 255, 255, 0.12);
}

/* `position: sticky` releases near the bottom of its containing block by
   design (every sticky header does this) — that's the "stops staying at
   top" bug report. `fixed` has no such release. #app-header wraps the
   update banner + topbar together so they stay stacked correctly as one
   fixed block; #photo-grid's padding-top (kept in sync via ResizeObserver
   in app.js) makes room so content isn't hidden underneath it. */
#app-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 30;
}
.topbar {
  padding: 10px 16px;
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--border);
}
.topbar-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 10px;
  margin-bottom: 8px;
}
.topbar-row:first-child { align-items: flex-start; }
.topbar-row:last-child { margin-bottom: 0; }

.license-badge {
  flex-shrink: 0;
  height: 32px;
  padding: 0 12px;
  border-radius: 999px;
  border: 1px solid var(--border-secondary);
  background: var(--bg-secondary);
  color: var(--text);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}
.license-badge.hidden { display: none; }
.license-badge.trial {
  border-color: #c9a227;
  background: rgba(201, 162, 39, 0.15);
  color: var(--text);
}
.license-badge.licensed {
  border-color: #3d9a5d;
  background: rgba(61, 154, 93, 0.15);
}
.license-badge:hover { filter: brightness(1.05); }

button.feature-locked {
  opacity: 0.82;
  border-style: dashed;
  cursor: help;
}
.tab.feature-locked {
  opacity: 0.72;
  cursor: help;
}
button.feature-locked::after {
  content: " 🔒";
  font-size: 11px;
}

.upgrade-card { width: min(440px, 100%); }
.plans-card { width: min(520px, 100%); }
.profile-card { width: min(440px, 100%); }
.upgrade-modal-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  margin-top: 14px;
}
.plans-table-wrap {
  margin: 12px 0 4px;
}
.plans-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  line-height: 1.35;
}
.plans-table th,
.plans-table td {
  padding: 8px 10px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.plans-table thead th {
  font-weight: 600;
  color: var(--text-muted);
  font-size: 12px;
  border-bottom-color: var(--border-strong);
}
.plans-table tbody th {
  font-weight: 500;
  color: var(--text-strong);
  width: 34%;
}
.plans-table td { color: var(--text); }
.plans-col-standard {
  background: var(--bg-hover);
  color: var(--text-strong);
  font-weight: 500;
}
.plans-table thead .plans-col-standard {
  color: var(--accent);
  font-weight: 650;
}
.plans-row-price td,
.plans-row-price .plans-price-cell {
  font-size: 15px;
  font-weight: 650;
  color: var(--text-strong);
}
.plans-yes {
  color: var(--progress);
  font-weight: 700;
  font-size: 16px;
  line-height: 1;
}
.plans-no {
  color: var(--text-faint);
  font-weight: 600;
  font-size: 15px;
  line-height: 1;
}
.plans-footnote {
  margin: 10px 0 0;
  font-size: 12px;
  line-height: 1.45;
}
a.purchase-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 16px;
  height: 32px;
  border-radius: 6px;
  border: 1px solid var(--accent);
  background: var(--accent-bg);
  color: #fff;
  text-decoration: none;
  font-size: 13px;
  line-height: 1;
  white-space: nowrap;
}
a.purchase-btn:hover {
  background: var(--accent-bg-hover);
  color: #fff;
}

button {
  padding: 0 14px;
  height: 32px;
  border-radius: 6px;
  border: 1px solid var(--accent);
  background: var(--accent-bg);
  color: #fff;
  cursor: pointer;
  white-space: nowrap;
  font-size: 13px;
  line-height: 1;
}
button:hover { background: var(--accent-bg-hover); }
button:disabled { opacity: 0.5; cursor: default; pointer-events: none; }
button.secondary {
  background: var(--bg-secondary);
  border-color: var(--border-secondary);
  color: var(--text);
}
button.secondary:hover { background: var(--bg-secondary-hover); }
button.danger {
  border-color: var(--danger-border);
  background: var(--danger-bg);
  color: #fff;
}
button.danger:hover { background: var(--danger-bg-hover); }

.icon-btn {
  width: 32px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border-color: var(--border-strong);
  color: var(--settings-icon);
}
.icon-btn:hover {
  background: var(--bg-hover);
  color: var(--settings-icon-hover);
  border-color: var(--border-strong);
}
.icon-btn svg {
  width: 16px;
  height: 16px;
  fill: currentColor;
}
/* Stroke-based icon (open-project-folder), not the filled-path style the
   generic rule above assumes — override back to no-fill. */
#open-project-folder-btn svg { fill: none; }
#open-project-folder-btn:disabled { opacity: 0.4; cursor: default; }

.account-menu {
  position: relative;
  flex-shrink: 0;
}
.account-menu-trigger {
  display: flex;
  align-items: center;
  gap: 4px;
}
.account-btn {
  position: relative;
  border-radius: 50%;
  background: #5b5f70;
  border-color: transparent;
  color: #fff;
}
.account-btn:hover {
  background: #666b7d;
  color: #fff;
  border-color: transparent;
}
.account-btn-initial {
  font-size: 13px;
  font-weight: 700;
  line-height: 1;
}
.account-menu-chevron {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: var(--text-muted);
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex-shrink: 0;
}
.account-trial-tag {
  flex-shrink: 0;
  height: 28px;
  padding: 0 10px;
  border-radius: 999px;
  border: 1px solid #c9a227;
  background: rgba(201, 162, 39, 0.15);
  color: var(--text);
  font-size: 11px;
  font-weight: 600;
  line-height: 26px;
  white-space: nowrap;
}
.account-trial-tag.hidden { display: none; }
.account-menu-dropdown {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  min-width: 168px;
  padding: 6px;
  border-radius: 8px;
  border: 1px solid var(--border-modal);
  background: var(--bg-elevated);
  box-shadow: var(--shadow);
  z-index: 20;
}
.account-menu-dropdown.hidden { display: none; }
.account-menu-item {
  display: block;
  width: 100%;
  height: 34px;
  padding: 0 12px;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--text);
  text-align: left;
  font-size: 13px;
  cursor: pointer;
}
.account-menu-item:hover {
  background: var(--bg-hover);
}

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
  margin-right: 4px;
}
.brand-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 9px;
  background: #3a4763;
  border: 1.5px solid #7b93d9;
  flex-shrink: 0;
}
.brand-icon svg {
  width: 17px;
  height: 17px;
  fill: #e8ecf5;
}
.brand-name {
  font-size: 21px;
  font-weight: 700;
  color: var(--text-strong);
  white-space: nowrap;
  letter-spacing: -0.2px;
}

.project-group {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  flex: 0 1 auto;
  min-width: 0;
  max-width: 100%;
  min-height: 32px;
}
.project-picker {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 0 1 auto;
  min-width: 0;
  font-size: 13px;
  color: var(--text-dim);
}
.project-load-group {
  display: flex;
  align-items: stretch;
  border-radius: 10px;
  border: 1px solid color-mix(in srgb, var(--border) 55%, var(--bg));
  overflow: hidden;
}
.project-load-group .project-picker select {
  border: none;
  border-right: 1px solid color-mix(in srgb, var(--border) 55%, var(--bg));
  border-radius: 0;
}
.project-load-group .icon-btn {
  border: none;
  border-radius: 0;
  background: var(--bg-hover);
}
.project-load-group .icon-btn:hover { background: var(--bg-secondary-hover); }
.project-picker select {
  appearance: none;
  -webkit-appearance: none;
  width: min(280px, 42vw);
  min-width: 140px;
  max-width: 320px;
  height: 36px;
  padding: 0 30px 0 34px;
  border-radius: 10px;
  border: 1px solid color-mix(in srgb, var(--border) 55%, var(--bg));
  background-color: var(--bg-hover);
  color: var(--text);
  font-size: 13px;
  line-height: 1;
  box-sizing: border-box;
  background-image:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23c8c8c8' stroke-width='1.6' stroke-linejoin='round'%3E%3Cpath d='M4 6.5C4 5.67 4.67 5 5.5 5h4l2 2h7c.83 0 1.5.67 1.5 1.5v9c0 .83-.67 1.5-1.5 1.5h-13C4.67 19 4 18.33 4 17.5z'/%3E%3C/svg%3E"),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23c8c8c8' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat, no-repeat;
  background-position: 11px center, right 11px center;
  background-size: 15px 15px, 16px 16px;
  text-overflow: ellipsis;
}
.project-picker select:hover { background-color: var(--bg-secondary-hover); }
.project-picker select:focus { outline: 1px solid var(--accent); }
.project-picker option.project-missing { color: var(--missing); }
.project-group .icon-btn { width: 36px; height: 36px; }
.project-group button.secondary { height: 36px; }

/* Before any project exists, the folder icon alone isn't a strong enough
   affordance — new users click the (non-functional, disabled) dropdown
   instead. Show the label text until a project is picked. */
#pick-folder-btn.emphasize {
  width: auto;
  gap: 6px;
  padding: 0 14px 0 10px;
}
#pick-folder-btn.emphasize .sr-only {
  position: static;
  width: auto;
  height: auto;
  padding: 0;
  margin: 0;
  overflow: visible;
  clip: auto;
  white-space: nowrap;
  border: 0;
  font-size: 13px;
  font-weight: 600;
}

[data-theme="light"] .project-picker select {
  background-image:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%235c6068' stroke-width='1.6' stroke-linejoin='round'%3E%3Cpath d='M4 6.5C4 5.67 4.67 5 5.5 5h4l2 2h7c.83 0 1.5.67 1.5 1.5v9c0 .83-.67 1.5-1.5 1.5h-13C4.67 19 4 18.33 4 17.5z'/%3E%3C/svg%3E"),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%235c6068' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
}

.toolbar-actions {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
  flex: 1 1 200px;
  min-width: 0;
  margin-left: auto;
}
.toolbar-actions-buttons {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}

.progress-text {
  color: var(--progress);
  font-size: 13px;
  line-height: 1.3;
  min-height: 1.3em;
  max-width: 100%;
  text-align: right;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tabs-row {
  justify-content: flex-start;
  align-items: flex-start;
}
.tabs-cluster {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  flex: 1 1 280px;
  min-width: 0;
}
.tools-cluster {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  flex: 1 1 320px;
  min-width: 0;
  justify-content: flex-end;
}
.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 2px;
  padding: 3px;
  border-radius: 10px;
  background: color-mix(in srgb, var(--bg) 85%, black);
}
.tab {
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-tab);
  border-radius: 10px;
  padding: 0 14px;
  height: 30px;
  font-size: 13px;
}
.tab:hover { background: color-mix(in srgb, var(--bg-hover) 60%, transparent); }
.tab.active {
  background: var(--bg-hover);
  color: var(--text-strong);
  border-color: transparent;
  font-weight: 600;
}
.tab .count {
  color: inherit;
  opacity: 0.75;
  font-size: 12px;
  margin-left: 4px;
  font-variant-numeric: tabular-nums;
}

.stats-bar {
  flex: 1 1 160px;
  min-width: 0;
  text-align: right;
  font-size: 12px;
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.stats-bar b { color: var(--text-strong); }
.stats-missing { color: var(--missing); }

.selection-bar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--border);
  font-size: 13px;
  min-height: 40px;
}
#selection-count {
  color: var(--text-muted);
  margin-right: 4px;
  min-width: 7em;
}
#selection-count.has-selection { color: var(--text-strong); }

.ghost-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 32px;
  padding: 0 12px;
  border-radius: 8px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-tab);
  font-size: 13px;
  white-space: nowrap;
}
.ghost-btn:hover:not(:disabled) {
  background: var(--bg-hover);
  color: var(--text-strong);
}
.ghost-btn:disabled { opacity: 0.4; cursor: default; }
.ghost-btn.active {
  background: var(--bg-hover);
  color: var(--text-strong);
}
.ghost-btn .btn-icon {
  width: 15px;
  height: 15px;
  flex-shrink: 0;
}

.grid-size-control {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-muted);
  flex: 0 1 auto;
}
.grid-size-control input[type="range"] {
  appearance: none;
  -webkit-appearance: none;
  width: min(120px, 28vw);
  height: 16px;
  background: transparent;
  cursor: pointer;
}
.grid-size-control input[type="range"]::-webkit-slider-runnable-track {
  height: 3px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--text-muted) 55%, var(--bg));
}
.grid-size-control input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 16px;
  height: 16px;
  margin-top: -6.5px;
  border-radius: 50%;
  background: #c9c7cf;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
}
.grid-size-control input[type="range"]::-moz-range-track {
  height: 3px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--text-muted) 55%, var(--bg));
}
.grid-size-control input[type="range"]::-moz-range-thumb {
  width: 16px;
  height: 16px;
  border: none;
  border-radius: 50%;
  background: #c9c7cf;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
}
.grid-size-control input[type="range"]:focus { outline: none; }

@media (max-width: 960px) {
  .toolbar-actions {
    flex: 1 1 100%;
    align-items: flex-start;
  }
  .toolbar-actions-buttons { justify-content: flex-start; }
  .progress-text { text-align: left; }

  .tools-cluster {
    flex: 1 1 100%;
    justify-content: flex-start;
  }
  .stats-bar {
    flex: 1 1 100%;
    text-align: left;
    white-space: normal;
  }
}

@media (max-width: 640px) {
  .topbar { padding: 8px 10px; }
  button { padding: 0 10px; font-size: 12px; }
  .tab { padding: 0 8px; font-size: 12px; }
  #batch-delete-btn { flex: 1 1 auto; }
}

.photo-grid {
  --thumb-size: 180px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(var(--thumb-size), 1fr));
  gap: 4px;
  padding: 12px;
  padding-top: calc(var(--topbar-height, 140px) + 12px);
  user-select: none;
  -webkit-user-select: none;
}
/* Largest grid-size step: a fixed 2 columns regardless of window width,
   rather than a --thumb-size big enough to merely make auto-fill land on 2
   columns at one particular window size. */
.photo-grid.grid-two-col {
  grid-template-columns: repeat(2, 1fr);
}
.grid-empty {
  grid-column: 1 / -1;
  text-align: center;
  color: var(--text-faint);
  padding: 60px 20px;
}

.grid-cell {
  display: flex;
  flex-direction: column;
  cursor: pointer;
}

.grid-thumb {
  position: relative;
  overflow: hidden;
  border-radius: 4px;
  background: var(--bg-thumb);
  box-sizing: border-box;
  border: 2px solid transparent;
}
.grid-cell.selected .grid-thumb {
  border-color: var(--accent);
}
.grid-thumb img {
  width: 100%;
  height: auto;
  display: block;
  -webkit-user-drag: none;
  user-select: none;
}
.grid-thumb.missing img { opacity: 0.35; }
.grid-cell.is-reject .grid-thumb img { opacity: 0.4; }
.grid-cell.is-reject .grid-filename { color: var(--text-faint); }

.grid-filename {
  font-size: 11px;
  color: var(--text-muted);
  padding: 3px 2px 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.missing-badge {
  position: absolute;
  bottom: 6px;
  left: 6px;
  background: var(--danger-bg);
  color: #fff;
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 8px;
  z-index: 2;
}
.raw-badge {
  position: absolute;
  bottom: 6px;
  right: 6px;
  background: rgba(20, 20, 22, 0.75);
  color: #f0c14b;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.04em;
  padding: 2px 6px;
  border-radius: 4px;
  border: 1px solid rgba(240, 193, 75, 0.45);
  z-index: 2;
  pointer-events: none;
  white-space: nowrap;
}
[data-theme="light"] .raw-badge {
  background: rgba(255, 255, 255, 0.88);
  color: #8a6a12;
  border-color: rgba(138, 106, 18, 0.35);
}
.grid-thumb.missing .raw-badge { display: none; }

.grid-quality-tags {
  position: absolute;
  bottom: 6px;
  left: 6px;
  right: 52px;
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  z-index: 2;
  pointer-events: none;
}
.quality-tag {
  font-size: 10px;
  line-height: 1.2;
  padding: 2px 6px;
  border-radius: 4px;
  color: #fff;
  background: rgba(0, 0, 0, 0.65);
}
.quality-tag.tag-soft_focus { background: rgba(140, 90, 20, 0.9); }
.quality-tag.tag-camera_shake { background: rgba(120, 40, 70, 0.9); }
.quality-tag.tag-overexposed { background: rgba(224, 82, 79, 0.9); }
.quality-tag.tag-underexposed { background: rgba(76, 143, 224, 0.9); }
.grid-thumb.missing .grid-quality-tags { left: auto; bottom: 28px; }

.defect-filter {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-dim);
  font-size: 12px;
  white-space: nowrap;
}
.defect-filter.hidden { display: none; }
.defect-severity-group {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.defect-severity-group.hidden { display: none; }
.defect-tier-group.hidden { display: none; }
.defect-tier-group {
  display: inline-flex;
  gap: 2px;
  padding: 2px;
  border-radius: 10px;
  background: color-mix(in srgb, var(--bg) 85%, black);
}
.defect-tier-btn {
  min-width: 2.2em;
  padding: 3px 9px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--text-tab);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
}
.defect-tier-btn:hover {
  color: var(--text-strong);
  background: color-mix(in srgb, var(--bg-hover) 60%, transparent);
}
.defect-tier-btn.active {
  color: var(--text-strong);
  font-weight: 600;
  background: var(--bg-hover);
}
.quality-tag.tier-low { opacity: 0.88; }
.quality-tag.tier-high { font-weight: 700; }

.grid-checkbox {
  position: absolute;
  top: 6px;
  left: 6px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 2px solid rgba(255,255,255,0.85);
  background: rgba(0,0,0,0.25);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.1s;
  z-index: 2;
}
.grid-cell:hover .grid-checkbox,
.grid-cell.selected .grid-checkbox { opacity: 1; }
.grid-cell.selected .grid-checkbox {
  background: var(--accent);
  border-color: var(--accent);
}
.grid-checkbox::after {
  content: "";
  width: 6px;
  height: 10px;
  border: solid #fff;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg) translate(-1px, -1px);
  display: none;
}
.grid-cell.selected .grid-checkbox::after { display: block; }

.grid-icon-actions {
  position: absolute;
  top: 6px;
  right: 6px;
  display: flex;
  gap: 4px;
  z-index: 3;
}
.grid-icon-btn {
  width: 26px;
  height: 26px;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.45);
  color: rgba(255, 255, 255, 0.7);
  font-size: 14px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.1s, background 0.1s, color 0.1s;
  cursor: pointer;
}
.grid-cell:hover .grid-icon-btn,
.grid-icon-btn.active { opacity: 1; }
.grid-icon-btn:hover { background: rgba(0, 0, 0, 0.7); color: #fff; }
.grid-icon-btn svg { width: 14px; height: 14px; }
.grid-icon-btn.qa-star.active {
  background: rgba(138, 106, 18, 0.92);
  color: #f0c14b;
}
.grid-icon-btn.qa-reject.active {
  background: rgba(125, 47, 47, 0.92);
  color: #fff;
}
.grid-icon-btn:disabled {
  opacity: 0.25;
  cursor: not-allowed;
}
.grid-cell:hover .grid-icon-btn:disabled { opacity: 0.25; }

.lightbox {
  position: fixed;
  inset: 0;
  background: #0a0a0c;
  display: flex;
  flex-direction: row;
  z-index: 50;
}
.lightbox.hidden { display: none; }

.lightbox-stage {
  position: relative;
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  overflow: hidden;
}
.lightbox-stage img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  transform-origin: center center;
  cursor: zoom-in;
  touch-action: none;
  -webkit-user-drag: none;
  user-select: none;
}
.lightbox-stage img.zoomed { cursor: grab; }
.lightbox-stage img.zoomed.panning { cursor: grabbing; }
.lightbox-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  background: rgba(40,40,40,0.6);
  border: none;
  font-size: 18px;
  padding: 14px 10px;
  height: auto;
  color: #eee;
  z-index: 2;
}
.lightbox-nav:hover { background: rgba(70,70,70,0.8); }
.lightbox-prev { left: 16px; }
.lightbox-next { right: 16px; }

.lightbox-sidebar {
  width: 320px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  background: #151517;
  border-left: 1px solid rgba(255, 255, 255, 0.08);
  padding: 12px 20px 20px;
}
.lightbox-close {
  align-self: flex-end;
  background: transparent;
  border: none;
  border-radius: 6px;
  font-size: 24px;
  line-height: 1;
  padding: 4px 8px;
  height: auto;
  color: #999;
}
.lightbox-close:hover { background: rgba(255, 255, 255, 0.08); color: #eee; }

.lightbox-sidebar-scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}
.lightbox-filename {
  color: #eee;
  font-weight: 600;
  font-size: 15px;
  word-break: break-word;
}
.lightbox-ai-badge {
  color: #9fc;
  font-size: 12px;
  margin-top: 6px;
}
.lightbox-ai-badge:empty { display: none; }

.lightbox-histogram-section {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}
.lightbox-histogram-section.hidden { display: none; }
.lightbox-histogram-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12px;
  color: #888;
  margin-bottom: 6px;
}
.lightbox-histogram {
  width: 100%;
  height: 72px;
  display: block;
  background: rgba(255, 255, 255, 0.03);
  border-radius: 4px;
}
.lightbox-hist-path { mix-blend-mode: screen; }
.lightbox-hist-r { fill: #e0524f; fill-opacity: 0.72; }
.lightbox-hist-g { fill: #1f9e5c; fill-opacity: 0.72; }
.lightbox-hist-b { fill: #4c8fe0; fill-opacity: 0.72; }
.lightbox-histogram-legend {
  display: flex;
  align-items: center;
  margin-top: 6px;
  font-size: 11px;
  color: #888;
}
.lightbox-hist-swatch {
  width: 8px;
  height: 8px;
  border-radius: 2px;
  display: inline-block;
  margin-left: 8px;
  margin-right: 3px;
}
.lightbox-hist-swatch:first-child { margin-left: 0; }
.lightbox-hist-swatch-r { background: #e0524f; }
.lightbox-hist-swatch-g { background: #1f9e5c; }
.lightbox-hist-swatch-b { background: #4c8fe0; }

.lightbox-exposure-verdict {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  font-weight: 600;
}
.lightbox-exposure-verdict svg { width: 13px; height: 13px; flex-shrink: 0; }
.lightbox-exposure-verdict.overexposed { color: #e0524f; }
.lightbox-exposure-verdict.underexposed { color: #4c8fe0; }
.lightbox-exposure-verdict.normal { color: #4fbd7a; }

.lightbox-info-list {
  display: flex;
  flex-direction: column;
  margin-top: 14px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}
.lightbox-info-row {
  display: flex;
  gap: 12px;
  padding: 14px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}
.lightbox-info-row.hidden { display: none; }
.lightbox-info-icon {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  margin-top: 1px;
  stroke: #888;
}
.lightbox-info-text { min-width: 0; }
.lightbox-info-primary {
  color: #ddd;
  font-size: 13px;
  word-break: break-word;
}
.lightbox-info-secondary {
  color: #888;
  font-size: 12px;
  margin-top: 3px;
  font-variant-numeric: tabular-nums;
}

.lightbox-icon-actions {
  position: absolute;
  top: 16px;
  right: 16px;
  display: flex;
  gap: 6px;
  z-index: 2;
}
.lightbox-icon-actions-left { left: 16px; right: auto; }
.lightbox-icon-btn {
  width: 34px;
  height: 34px;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.45);
  color: rgba(255, 255, 255, 0.7);
  font-size: 16px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}
.lightbox-icon-btn:hover:not(:disabled) { background: rgba(0, 0, 0, 0.7); color: #fff; }
.lightbox-icon-btn.qa-star.active { background: rgba(138, 106, 18, 0.92); color: #f0c14b; }
.lightbox-icon-btn.qa-reject.active { background: rgba(125, 47, 47, 0.92); color: #fff; }
.lightbox-icon-btn:disabled { opacity: 0.35; cursor: not-allowed; }
.lightbox-icon-btn svg { width: 16px; height: 16px; }

.lightbox-gps-link {
  display: inline-block;
  color: #7ab8f0;
  text-decoration: none;
}
.lightbox-gps-link:hover { text-decoration: underline; }

.lightbox-map-frame {
  display: block;
  margin: 8px 0 4px;
  width: 100%;
  height: 220px;
  border: none;
  border-radius: 6px;
  overflow: hidden;
}
.lightbox-map-frame.hidden { display: none; }

.crop-editor {
  position: absolute;
  inset: 0;
  z-index: 10;
  display: flex;
  flex-direction: column;
  background: #0a0a0c;
}
.crop-editor.hidden { display: none; }

.crop-stage {
  flex: 1;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  padding: 24px;
}
#crop-canvas {
  display: block;
  max-width: 100%;
  max-height: 100%;
}
#crop-canvas.hidden { display: none; }
.crop-overlay {
  position: absolute;
  pointer-events: none;
}
#crop-overlay.hidden { display: none; }
.crop-mask {
  position: absolute;
  background: rgba(0, 0, 0, 0.78);
}
.crop-rect {
  position: absolute;
  border: 1px solid #fff;
  pointer-events: auto;
  cursor: move;
}
.crop-grid-line {
  position: absolute;
  background: rgba(255, 255, 255, 0.35);
  pointer-events: none;
}
.crop-grid-v1, .crop-grid-v2 { top: 0; bottom: 0; width: 1px; }
.crop-grid-v1 { left: 33.333%; }
.crop-grid-v2 { left: 66.667%; }
.crop-grid-h1, .crop-grid-h2 { left: 0; right: 0; height: 1px; }
.crop-grid-h1 { top: 33.333%; }
.crop-grid-h2 { top: 66.667%; }
.crop-handle {
  position: absolute;
  width: 11px;
  height: 11px;
  margin: -5.5px;
  background: #fff;
  border-radius: 50%;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.35);
  pointer-events: auto;
}
.crop-handle-n  { top: 0; left: 50%; cursor: ns-resize; }
.crop-handle-s  { top: 100%; left: 50%; cursor: ns-resize; }
.crop-handle-e  { top: 50%; left: 100%; cursor: ew-resize; }
.crop-handle-w  { top: 50%; left: 0; cursor: ew-resize; }
.crop-handle-nw { top: 0; left: 0; cursor: nwse-resize; }
.crop-handle-se { top: 100%; left: 100%; cursor: nwse-resize; }
.crop-handle-ne { top: 0; left: 100%; cursor: nesw-resize; }
.crop-handle-sw { top: 100%; left: 0; cursor: nesw-resize; }

.crop-preview-img {
  max-width: 100%;
  max-height: 100%;
  display: block;
  object-fit: contain;
}
.crop-preview-img.hidden { display: none; }
#crop-controls-edit.hidden,
#crop-controls-preview.hidden { display: none; }
#crop-controls-preview .modal-hint {
  margin: 0;
  color: var(--text-muted, #9a9aa2);
  font-size: 12px;
}

.crop-controls {
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 14px 20px;
  background: #151517;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}
.crop-aspect-group {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.crop-aspect-btn {
  padding: 5px 12px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.06);
  color: #ccc;
  font-size: 12px;
  cursor: pointer;
}
.crop-aspect-btn:hover { background: rgba(255, 255, 255, 0.12); }
.crop-aspect-btn.active {
  background: rgba(255, 255, 255, 0.18);
  border-color: rgba(255, 255, 255, 0.32);
  color: #fff;
  font-weight: 600;
}
.crop-straighten-row {
  display: flex;
  align-items: center;
  gap: 10px;
  color: #ccc;
  font-size: 13px;
}
.crop-straighten-row input[type="range"] { flex: 1; }
.straighten-value {
  min-width: 4.5em;
  text-align: right;
  font-variant-numeric: tabular-nums;
  color: #ddd;
}
#straighten-reset-btn { color: #ccc; }
#straighten-reset-btn:hover { color: #fff; }

#straighten-slider {
  -webkit-appearance: none;
  appearance: none;
  height: 4px;
  border-radius: 2px;
  background: rgba(255, 255, 255, 0.18);
  outline: none;
}
#straighten-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 15px;
  height: 15px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.4), 0 1px 3px rgba(0, 0, 0, 0.5);
  cursor: pointer;
}
#straighten-slider::-moz-range-thumb {
  width: 15px;
  height: 15px;
  border: none;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.4), 0 1px 3px rgba(0, 0, 0, 0.5);
  cursor: pointer;
}
#straighten-slider::-moz-range-track {
  height: 4px;
  border-radius: 2px;
  background: rgba(255, 255, 255, 0.18);
}

.crop-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}
.crop-actions button {
  border-radius: 999px;
  padding: 0 16px;
  height: 32px;
}
#crop-cancel-btn, #crop-reset-btn {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.16);
  color: #ddd;
}
#crop-cancel-btn:hover, #crop-reset-btn:hover { background: rgba(255, 255, 255, 0.12); }
#crop-apply-btn {
  background: #fff;
  border: 1px solid #fff;
  color: #111;
  font-weight: 600;
}
#crop-apply-btn:hover { background: #e8e8e8; }

.modal {
  position: fixed;
  inset: 0;
  background: var(--modal-overlay);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 60;
  padding: 20px;
}
.modal.hidden { display: none; }
.modal-card {
  width: min(560px, 100%);
  background: var(--bg-elevated);
  border: 1px solid var(--border-modal);
  border-radius: 10px;
  padding: 20px 22px;
  box-shadow: var(--shadow);
}
.modal-card.settings-card { width: min(420px, 100%); }
.modal-card h2 {
  margin: 0 0 6px;
  font-size: 18px;
  font-weight: 600;
}
.modal-hint {
  margin: 0 0 16px;
  color: var(--text-muted);
  font-size: 12px;
  line-height: 1.45;
}
#export-estimate-hint {
  white-space: pre-line;
  max-height: 140px;
  overflow-y: auto;
}
.field {
  display: flex;
  flex-direction: column;
  gap: 5px;
  margin-bottom: 12px;
  flex: 1;
}
.field span { color: var(--text-dim); font-size: 12px; }
.field input,
.field select {
  padding: 7px 10px;
  border-radius: 6px;
  border: 1px solid var(--border-strong);
  background: var(--bg-input);
  color: var(--text);
  font-size: 13px;
  height: 34px;
}
.field input:focus,
.field select:focus { outline: 1px solid var(--accent); }
.field-row {
  display: flex;
  gap: 10px;
}
.field-row input { flex: 1; min-width: 0; }
#export-path-browse-btn { flex-shrink: 0; white-space: nowrap; }
#export-quality-field.hidden { display: none; }
#export-form-fields.hidden,
.export-progress-block.hidden,
#export-open-folder.hidden,
#export-confirm.hidden { display: none; }
.export-progress-block { margin: 4px 0 16px; }
.export-progress-track {
  width: 100%;
  height: 8px;
  border-radius: 4px;
  background: var(--bg-input);
  border: 1px solid var(--border-strong);
  overflow: hidden;
}
.export-progress-fill {
  height: 100%;
  width: 0%;
  background: var(--progress);
  transition: width 0.2s ease;
}
.export-progress-text {
  margin-top: 8px;
  font-size: 12px;
  color: var(--text-muted);
}
.settings-section {
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}
.settings-section h3 {
  margin: 0 0 8px;
  font-size: 0.95rem;
  font-weight: 600;
}
.license-mode { margin: 0 0 12px; font-weight: 600; }
.license-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  margin-top: 8px;
}
.license-deactivate {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}
.license-deactivate.hidden { display: none; }
.license-deactivate-hint {
  margin: 0 0 10px;
  font-size: 0.85rem;
  line-height: 1.45;
}
.license-account-info {
  margin: 0 0 12px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}
.license-account-info.hidden { display: none; }
.license-licensed-summary {
  margin: 0 0 4px;
}
.license-licensed-summary.hidden { display: none; }
.license-active-hint {
  margin: 0 0 8px;
  font-size: 0.85rem;
  line-height: 1.45;
}
#license-activate-block.hidden { display: none; }
.text-btn {
  padding: 0;
  border: none;
  background: none;
  color: var(--accent);
  font: inherit;
  font-size: 0.9rem;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 2px;
}
.text-btn:hover { filter: brightness(1.1); }
.text-btn.hidden { display: none; }
.secondary-link.hidden,
.license-actions .hidden { display: none; }
.secondary-link {
  font-size: 0.9rem;
  color: var(--accent);
  text-decoration: none;
}
.secondary-link:hover { text-decoration: underline; }
.license-message {
  margin: 10px 0 0;
  font-size: 0.85rem;
  color: var(--accent);
}
.license-message.hidden { display: none; }
.license-device-info {
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}
.license-device-row {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin-bottom: 6px;
  font-size: 0.85rem;
}
.license-device-label {
  flex-shrink: 0;
  color: var(--text-muted);
  min-width: 6.5em;
}
.license-device-value { color: var(--text-strong); }
.license-machine-id {
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 0.78rem;
  word-break: break-all;
  cursor: pointer;
  color: var(--text-strong);
  background: var(--bg-input);
  padding: 2px 6px;
  border-radius: 4px;
  border: 1px solid var(--border);
}
.license-machine-id:hover { color: var(--accent); border-color: var(--accent); }
.license-device-hint { margin: 8px 0 0; font-size: 0.8rem; line-height: 1.45; }
.settings-fields {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.settings-update-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

.settings-version-value {
  font-variant-numeric: tabular-nums;
  opacity: 0.85;
}

.settings-update-notes {
  opacity: 0.8;
}
.rename-preview-block { margin-top: 4px; }
.rename-preview-label {
  color: var(--text-dim);
  font-size: 12px;
  margin-bottom: 6px;
}
.rename-preview {
  margin: 0;
  padding: 10px 12px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text-strong);
  font-size: 12px;
  line-height: 1.55;
  max-height: 140px;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-all;
}
.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 16px;
}
