/* ==========================================================================
   BrickTally - Unified Styles
   ========================================================================== */

/* Reset & Base Styles
   ========================================================================== */

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --bg-primary: white;
  --bg-secondary: white;
  --bg-tertiary: white;
  --text-primary: #333;
  --text-secondary: #666;
  --border-color: #ddd;
  --shadow: rgba(0, 0, 0, 0.1);
  --blue: #0055BF;
  --blue-dark: #003d8f;
  --red: #d32f2f;
  --red-dark: #b71c1c;
  --green: #4CAF50;
  --orange: #FF9800;
  --error-bg: #ffebee;
  --error-text: #d32f2f;
  --hover-bg: #f5f5f5;
}

body.dark-mode {
  --bg-primary: #1a1a1a;
  --bg-secondary: #2d2d2d;
  --bg-tertiary: #3a3a3a;
  --text-primary: #e0e0e0;
  --text-secondary: #b0b0b0;
  --border-color: #444;
  --shadow: rgba(0, 0, 0, 0.5);
  --blue: #4a9eff;
  --blue-dark: #357abd;
  --red: #ff6b6b;
  --red-dark: #cc5555;
  --green: #66bb6a;
  --orange: #ffb74d;
  --error-bg: #4a1a1a;
  --error-text: #ff6b6b;
  --hover-bg: #3a3a3a;
}

body {
  font-family: Arial, sans-serif;
  background-color: var(--bg-primary);
  color: var(--text-primary);
  transition: background-color 0.3s, color 0.3s;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.main-content {
  flex: 1;
  max-width: 1400px;
  margin: 0 auto;
  background: var(--bg-secondary);
}

/* Preview Environment Banner
   ========================================================================== */

.preview-banner {
  position: fixed;
  top: 25px;
  left: -35px;
  width: 150px;
  background: #FF9500;
  color: white;
  text-align: center;
  font-weight: bold;
  font-size: 14px;
  padding: 5px 0;
  transform: rotate(-45deg);
  z-index: 10000;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.3);
  pointer-events: none;
}

/* Utility Classes
   ========================================================================== */

.text-center {
  text-align: center;
}

.flex {
  display: flex;
}

.flex-center {
  display: flex;
  align-items: center;
  justify-content: center;
}

.gap-10 {
  gap: 10px;
}

.gap-20 {
  gap: 20px;
}

.p-10 {
  padding: 10px;
}

.p-15 {
  padding: 15px;
}

.p-20 {
  padding: 20px;
}

.m-20 {
  margin: 20px 0;
}

.hide {
  display: none;
}

.loading-spinner {
  display: none;
  width: 32px;
  height: 32px;
  margin: 16px auto 0;
  border: 3px solid var(--border-color);
  border-top-color: var(--blue);
  border-radius: 50%;
  opacity: 0;
  animation: spin 0.8s linear infinite, showAfterDelay 0s 4s forwards;
}

#loading:not(.hide) .loading-spinner {
  display: block;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

@keyframes showAfterDelay {
  to { opacity: 1; }
}

/* Headers & Typography
   ========================================================================== */

h1 {
  color: var(--text-primary);
}

h1 a {
  color: inherit;
  text-decoration: none;
  transition: color 0.2s ease;
}

h1 a:hover {
  color: var(--blue);
}

h2 {
  color: var(--blue);
  margin-bottom: 5px;
}

/* Theme Toggle
   ========================================================================== */

.theme-toggle {
  position: absolute;
  top: 20px;
  right: 20px;
  font-size: 24px;
  cursor: pointer;
  background: none;
  border: none;
  padding: 8px;
  line-height: 1;
  transition: transform 0.3s ease;
  z-index: 1000;
}

.theme-toggle:hover {
  transform: scale(1.2);
}

#themeIcon {
  font-size: 0;
}

#themeIcon::before {
  content: '🌙';
  font-size: 24px;
}

body.dark-mode #themeIcon::before {
  content: '☀️';
}

.fullscreen-toggle {
  position: absolute;
  top: 20px;
  right: 60px;
  font-size: 24px;
  cursor: pointer;
  background: none;
  border: none;
  padding: 8px;
  line-height: 1;
  transition: transform 0.3s ease;
  color: var(--text-primary);
  z-index: 1000;
}

.fullscreen-toggle:hover {
  transform: scale(1.2);
}

/* Progress Bars
   ========================================================================== */

.progress-bar {
  margin: 20px 0;
  background: var(--bg-tertiary);
  border-radius: 10px;
  overflow: hidden;
  height: 30px;
  position: relative;
  border: 1px solid var(--border-color);
}

.progress-fill {
  height: 100%;
  background: var(--green);
  transition: width 0.3s ease;
}

.progress-fill.incomplete {
  background: var(--orange);
}

.progress-bar::after {
  content: attr(data-percentage);
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  color: #000;
  font-weight: bold;
  font-size: 14px;
  z-index: 1;
  text-shadow: 0 0 3px rgba(255, 255, 255, 0.8);
}

body.dark-mode .progress-bar::after {
  color: #fff;
  text-shadow: 0 0 3px rgba(0, 0, 0, 0.8);
}

.progress-bar::before {
  content: attr(data-pieces);
  display: block;
  position: absolute;
  top: 50%;
  right: 10px;
  transform: translateY(-50%);
  color: #000;
  font-weight: bold;
  font-size: 14px;
  z-index: 1;
  text-shadow: 0 0 3px rgba(255, 255, 255, 0.8);
}

body.dark-mode .progress-bar::before {
  color: #fff;
  text-shadow: 0 0 3px rgba(0, 0, 0, 0.8);
}

.spare-progress-container {
  margin-top: 15px;
}

.spare-progress-label {
  font-size: 14px;
  color: var(--text-secondary);
  margin-bottom: 8px;
  text-align: center;
}

.spare-progress-bar {
  margin: 0;
  height: 20px;
}

.spare-progress-fill {
  background: linear-gradient(90deg, #ff9800, #ff6f00);
}

/* Lightbox
   ========================================================================== */

.lightbox {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0);
  z-index: 10001;
  justify-content: center;
  align-items: center;
  transition: background 0.3s ease;
}

.lightbox.active {
  display: flex;
  background: rgba(0, 0, 0, 0.9);
}

.lightbox img {
  max-width: 90%;
  max-height: 90%;
  object-fit: contain;
  transition: transform 0.4s cubic-bezier(0.4, 0.0, 0.2, 1), opacity 0.4s cubic-bezier(0.4, 0.0, 0.2, 1);
  position: absolute;
}

.lightbox-close {
  position: absolute;
  top: 20px;
  right: 30px;
  font-size: 40px;
  color: white;
  cursor: pointer;
  font-weight: bold;
  z-index: 10002;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.lightbox.active .lightbox-close {
  opacity: 1;
}

.part-image.lightbox-active,
.minifig-image.lightbox-active {
  visibility: hidden;
}

/* Buttons
   ========================================================================== */

input {
  padding: 12px 15px;
  font-size: 16px;
  border: 2px solid var(--border-color);
  border-radius: 4px;
  width: 200px;
  background: var(--bg-secondary);
  color: var(--text-primary);
}

input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

input[type="number"] {
  -moz-appearance: textfield;
}

button {
  padding: 12px 20px;
  font-size: 16px;
  background: var(--blue);
  color: white;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  transition: background 0.2s;
  touch-action: manipulation;
}

button:hover {
  background: var(--blue-dark);
}

button:disabled {
  background: #ccc;
  cursor: not-allowed;
}

#loadButton {
  font-size: 20px;
  padding: 12px 16px;
}

button.reset {
  background: var(--red);
}

button.reset:hover {
  background: var(--red-dark);
}

button.filter {
  padding: 8px 14px;
  border: 2px solid var(--border-color);
  background: var(--bg-secondary);
  color: var(--text-primary);
  font-size: 14px;
}

button.filter:hover {
  border-color: var(--blue);
}

button.filter.active {
  background: var(--blue);
  color: white;
  border-color: var(--blue);
}

.export-btn {
  display: inline-block;
  margin: 10px 10px 10px 0;
  padding: 12px 24px;
  background: var(--orange);
  color: white;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-size: 16px;
}

.export-btn:hover {
  background: #F57C00;
  opacity: 0.9;
}

/* ==========================================================================
   INDEX.HTML - Main App Styles
   ========================================================================== */

/* Header
   ========================================================================== */

.full-header {
  background: var(--bg-secondary);
  box-shadow: 0 2px 10px var(--shadow);
}

.header-wrapper {
  max-width: 1400px;
  margin: 0 auto;
  padding: 10px;
}

/* Compact desktop header layout */
.set-info-layout {
  display: flex;
  align-items: flex-start;
  gap: 20px;
  padding: 10px 0;
}

.set-image-container {
  flex-shrink: 0;
}

.set-detail-image {
  width: 300px;
  height: 200px;
  object-fit: contain;
  border-radius: 8px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  display: block;
}

.set-info-content h2 {
  margin-top: 0;
}

.set-info-content .stats {
  justify-content: flex-start;
}

.set-info-content .progress-bar {
  margin: 10px 0;
}

.collapsed-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  background: var(--bg-secondary);
  box-shadow: 0 2px 10px var(--shadow);
  z-index: 1000;
  transform: translateY(-100%);
  transition: transform 0.3s ease-in-out;
  max-height: 90vh;
  overflow-y: auto;
}

body[data-collapsed-header] .collapsed-header {
  transform: translateY(0);
}

.collapsed-header .header-wrapper {
  padding: 10px 20px;
}

.collapsed-header .collapsed-row {
  margin-bottom: 8px;
}

.collapsed-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 15px;
  flex-wrap: wrap;
}

.collapsed-app-name {
  color: var(--blue);
  font-size: 16px;
  font-weight: bold;
  margin: 0;
  white-space: nowrap;
  cursor: pointer;
  transition: color 0.2s ease;
  text-decoration: none;
}

.collapsed-app-name:hover {
  color: var(--text-primary);
}

.collapsed-set-name {
  color: var(--text-primary);
  font-size: 16px;
  margin: 0;
  text-align: right;
  flex: 1;
}

.collapsed-progress {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 12px;
}

.collapsed-progress .progress-bar {
  flex: 1;
  height: 20px;
  margin: 0;
}

.collapsed-toggle {
  flex-direction: row;
  gap: 6px;
  flex-shrink: 0;
}

.collapsed-progress .progress-bar::before {
  content: attr(data-pieces);
  display: block;
  position: absolute;
  top: 50%;
  right: 10px;
  transform: translateY(-50%);
  color: #000;
  font-weight: bold;
  font-size: 14px;
  z-index: 1;
  text-shadow: 0 0 3px rgba(255, 255, 255, 0.8);
}

body.dark-mode .collapsed-progress .progress-bar::before {
  color: #fff;
  text-shadow: 0 0 3px rgba(0, 0, 0, 0.8);
}

.collapsed-filters {
  width: 100%;
  overflow: visible;
}

.collapsed-filters details {
  width: 100%;
  overflow: hidden;
  display: none;
}

.collapsed-filters details:not(.hide) {
  display: block;
  opacity: 0;
  transform: translateY(-15px);
  max-height: 0;
  margin-top: 0;
  pointer-events: none;
  transition: opacity 0.5s ease-in-out, transform 0.5s ease-in-out, max-height 0.5s ease-in-out, margin-top 0.5s ease-in-out;
}

.collapsed-filters details.visible {
  display: block;
  opacity: 1;
  transform: translateY(0);
  max-height: 300px;
  margin-top: 8px;
  pointer-events: auto;
}

.collapsed-filters details summary {
  font-size: 14px;
  padding: 8px 10px;
}

.collapsed-filters .filters {
  margin-top: 10px;
  padding-bottom: 5px;
}

.collapsed-filters .column-toggles {
  gap: 8px;
  padding-bottom: 5px;
}

.collapsed-filters .column-toggle {
  font-size: 13px;
  padding: 6px 10px;
}

.content-area {
  padding: 20px;
}

details summary {
  cursor: pointer;
  padding: 10px;
  background: var(--bg-tertiary);
  border-radius: 4px;
  font-weight: bold;
  color: var(--text-primary);
  user-select: none;
}

details summary:hover {
  background: var(--hover-bg);
}

details[open] summary {
  margin-bottom: 15px;
}

.header-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 20px;
  flex-wrap: wrap;
  padding-right: 90px;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 15px;
  flex: 1;
  min-width: 300px;
}

.header-left h1 {
  margin: 0;
  padding: 0;
  font-size: 24px;
  white-space: nowrap;
}

.header-left .input-group {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
}

.header-left .input-group input {
  -webkit-appearance: none;
  appearance: none;
  border-radius: 20px;
  padding-left: 40px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 24 24' fill='none' stroke='%23888' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='11' cy='11' r='8'%3E%3C/circle%3E%3Cline x1='21' y1='21' x2='16.65' y2='16.65'%3E%3C/line%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: 12px center;
  background-size: 18px;
}

.section-header-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 15px;
}

.complete-toggle-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.complete-toggle-label {
  font-size: 10px;
  color: var(--text-secondary);
  white-space: nowrap;
}

.complete-toggle {
  position: relative;
  width: 45px;
  height: 27px;
  background-color: #e0e0e0;
  border-radius: 27px;
  border: none;
  cursor: pointer;
  transition: background-color 0.3s ease;
  padding: 0;
}

.complete-toggle:focus-visible {
  outline: 2px solid var(--blue);
  outline-offset: 2px;
}

body.dark-mode .complete-toggle {
  background-color: #4a4a4a;
}

.complete-toggle.active {
  background-color: var(--blue);
}

.complete-toggle::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 23px;
  height: 23px;
  background-color: white;
  border-radius: 50%;
  transition: transform 0.3s ease;
}

.complete-toggle.active::after {
  transform: translateX(18px);
}

.filter-headers {
  display: flex;
  flex-wrap: wrap;
  gap: 15px;
  margin-bottom: 15px;
}

.filter-section {
  flex: 1;
}

.filter-header {
  cursor: pointer;
  font-weight: bold;
  padding: 10px;
  background: var(--bg-secondary);
  border-radius: 4px;
  user-select: none;
  display: flex;
  justify-content: space-between;
  align-items: center;
  list-style: none;
}

.filter-header::-webkit-details-marker {
  display: none;
}

.filter-header:hover {
  background: var(--border-color);
}

.filter-section[open] > .filter-header {
  background: var(--blue);
  color: white;
}

.filter-arrow {
  font-size: 12px;
  transition: transform 0.3s ease;
}

.filter-section[open] > .filter-header .filter-arrow {
  transform: rotate(-180deg);
}

.filter-section > :not(summary) {
  width: 100%;
  padding-top: 10px;
}

.filter-content-flex {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.filter-content-stack {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.error {
  color: var(--error-text);
  background: var(--error-bg);
  border-radius: 4px;
  font-size: 18px;
}

.info-box {
  background: var(--bg-tertiary);
  border-radius: 4px;
}

.info-box p {
  color: var(--text-secondary);
}

.stats {
  font-size: 18px;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}

.reset-inline {
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 24px;
  cursor: pointer;
  padding: 4px 8px;
  line-height: 1;
  transition: background 0.2s, color 0.2s, transform 0.2s;
  border-radius: 4px;
}

.reset-inline:hover {
  background: var(--bg-secondary);
  color: var(--red);
  transform: rotate(-30deg);
}

.stats.small {
  font-size: 14px;
}

.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.column-toggles {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 15px 0;
}

.column-toggle {
  padding: 8px 12px;
  background: var(--bg-tertiary);
  border: 2px solid var(--border-color);
  border-radius: 4px;
  cursor: pointer;
  font-size: 14px;
  color: var(--text-primary);
}

.column-toggle.active {
  background: var(--blue);
  color: white;
  border-color: var(--blue);
}

table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 20px;
}

th,
td {
  padding: 15px 10px;
  text-align: left;
  border-bottom: 1px solid var(--border-color);
}

tr:hover {
  background: var(--hover-bg);
}

tr[data-color-hidden] {
  display: none;
}

button[data-hidden-when-zero] {
  visibility: hidden;
}

/* Hide complete rows/cards when show-complete is false */
body[data-show-complete="false"] tr[data-complete="true"],
body[data-show-complete="false"] .minifig-card[data-complete="true"] {
  display: none;
}

.increment-btn.complete {
  background: transparent;
  border: none;
  color: var(--green);
  pointer-events: none;
  cursor: default;
}

.col-img {
  width: 120px;
  text-align: center;
}

.col-img img {
  max-width: 100px;
  max-height: 100px;
  object-fit: contain;
  cursor: pointer;
}

.col-info {
  padding: 15px 10px;
  vertical-align: middle;
  line-height: 1.5;
}

.col-controls {
  width: 220px;
  text-align: right;
  padding-right: 10px;
  white-space: nowrap;
}

.controls {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 20px;
}

@media (max-width: 768px) {
  .controls {
    gap: 8px;
  }
}

@media (min-width: 769px) and (max-width: 1024px) {
  .controls {
    gap: 25px;
  }
}

.controls button {
  min-width: 60px;
  min-height: 60px;
  font-size: 28px;
  border: 2px solid var(--border-color);
  background: var(--bg-tertiary);
  color: var(--text-primary);
  padding: 0;
  margin: 0;
  border-radius: 8px;
  font-weight: bold;
}

.controls .count-display {
  min-width: 90px;
  font-weight: bold;
  font-size: 20px;
  text-align: center;
  color: var(--text-primary);
}

.qty-click {
  cursor: pointer;
  color: var(--blue);
  padding: 6px 8px;
  margin-left: 2px;
  border-radius: 4px;
  transition: background 0.2s ease, color 0.2s ease;
  display: inline-block;
  min-width: 30px;
  text-align: center;
}

.qty-click:hover {
  background: var(--blue);
  color: white;
  text-decoration: underline;
}

.qty-click:active {
  transform: scale(0.95);
}

.count-display .counted {
  margin-right: 2px;
  padding: 6px 8px;
  display: inline-block;
  min-width: 30px;
  text-align: center;
}

/* Mobile - keep current size */
@media (max-width: 768px) {
  .controls button {
    min-width: 50px;
    min-height: 50px;
    font-size: 24px;
  }

  .controls .count-display {
    min-width: 80px;
    font-size: 18px;
  }

  .qty-click {
    padding: 4px 6px;
    min-width: 30px;
    font-size: 18px;
  }

  .count-display .counted {
    padding: 4px 6px;
    min-width: 30px;
    font-size: 18px;
  }
}

/* Tablet - even bigger for easier tapping */
@media (min-width: 769px) and (max-width: 1024px) {
  .controls button {
    min-width: 70px;
    min-height: 70px;
    font-size: 32px;
  }

  .controls .count-display {
    min-width: 130px;
    font-size: 22px;
  }

  .qty-click {
    padding: 6px 8px;
    min-width: 35px;
    font-size: 22px;
  }

  .count-display .counted {
    padding: 6px 8px;
    min-width: 35px;
    font-size: 22px;
  }
}

.controls button:hover:not(:disabled) {
  background: var(--blue);
  color: white;
  border-color: var(--blue);
}

.controls button:active:not(:disabled) {
  transform: scale(0.95);
}

.checkmark {
  color: var(--green);
  font-size: 24px;
}

.count {
  font-size: 12px;
  opacity: 0.8;
  margin-left: 4px;
}

#fireworksContainer {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 9999;
  display: none;
}

.set-history {
  max-width: 800px;
  padding: 0 20px;
}

.set-history h2 {
  text-align: center;
  margin-bottom: 30px;
  color: var(--text-primary);
}

.set-history-list {
  display: flex;
  flex-direction: column;
  gap: 15px;
}

.set-history-item {
  display: flex;
  align-items: center;
  gap: 15px;
  padding: 15px;
  background: var(--bg-secondary);
  border: 2px solid var(--border-color);
  border-radius: 8px;
  cursor: pointer;
  transition: border-color 0.2s ease, box-shadow 0.2s ease, transform 0.2s ease, background 0.2s ease;
}

.set-history-item:hover {
  border-color: var(--blue);
  box-shadow: 0 4px 12px var(--shadow);
  transform: translateY(-2px);
}

.set-history-item.backup-selected {
  border-color: var(--blue);
  background: rgba(0, 85, 191, 0.08);
}

body.dark-mode .set-history-item.backup-selected {
  background: rgba(0, 85, 191, 0.2);
}

.set-history-item-image {
  width: 80px;
  height: 80px;
  object-fit: contain;
  flex-shrink: 0;
  border-radius: 4px;
}

.set-history-item-content {
  flex: 1;
  min-width: 0;
}

.set-history-item-title {
  font-weight: bold;
  font-size: 16px;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.set-history-item-number {
  font-size: 14px;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

.set-history-item-stats {
  font-size: 14px;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.set-history-item .progress-bar {
  height: 20px;
  margin: 0;
}

.set-history-item-actions {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
  align-self: flex-end;
}

.set-history-item-actions button {
  width: 40px;
  height: 40px;
  padding: 0;
  font-size: 20px;
  border-radius: 6px;
  background: var(--bg-tertiary);
  color: var(--text-primary);
  border: 2px solid var(--border-color);
}

.set-history-item-actions button:hover {
  background: var(--blue);
  color: white;
  border-color: var(--blue);
}

.set-history-item-actions button.delete:hover {
  background: var(--red);
  border-color: var(--red);
}

.set-history-item-actions button.backup:hover {
  background: var(--green, #27ae60);
  border-color: var(--green, #27ae60);
}

.set-history-empty {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-secondary);
}

.set-history-empty p {
  font-size: 18px;
  margin-bottom: 10px;
}

/* Backup/Restore Toolbar */
.backup-restore-toolbar {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
  align-items: center;
}

.backup-selected-btn,
.cancel-backup-btn {
  display: none;
}

.backup-restore-toolbar[data-backup-mode] .backup-all-btn {
  display: none;
}

.backup-restore-toolbar[data-backup-mode] .backup-selected-btn,
.backup-restore-toolbar[data-backup-mode] .cancel-backup-btn {
  display: inline-block;
}

.restore-btn,
.backup-all-btn,
.backup-selected-btn,
.cancel-backup-btn {
  padding: 8px 16px;
  border-radius: 6px;
  font-size: 14px;
  cursor: pointer;
  border: 2px solid var(--border-color);
  background: var(--bg-tertiary);
  color: var(--text-primary);
  box-sizing: border-box;
  min-height: 40px;
}

.restore-btn:hover,
.backup-all-btn:hover,
.backup-selected-btn:hover {
  background: var(--blue);
  color: white;
  border-color: var(--blue);
}

.cancel-backup-btn:hover {
  background: var(--red);
  color: white;
  border-color: var(--red);
}

/* Backup mode checkbox */
.backup-checkbox {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  cursor: pointer;
  accent-color: var(--blue);
}

/* Restore Modal */
.restore-modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;
  padding: 20px;
}

.restore-modal-overlay:not([data-visible]) {
  display: none;
}

.restore-modal {
  background: var(--bg-primary);
  border-radius: 12px;
  padding: 24px;
  max-width: 500px;
  width: 100%;
  max-height: 80vh;
  overflow-y: auto;
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.2);
}

.restore-modal h3 {
  margin: 0 0 16px;
  color: var(--text-primary);
}

.restore-set-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 16px;
}

.restore-set-item {
  padding: 12px;
  border-radius: 8px;
  border: 2px solid var(--border-color);
  background: var(--bg-secondary);
  display: flex;
  gap: 12px;
  align-items: flex-start;
  flex-wrap: wrap;
}

.restore-set-image {
  width: 60px;
  height: 60px;
  object-fit: contain;
  border-radius: 4px;
  flex-shrink: 0;
}

.restore-set-item.restore-conflict {
  border-color: #f0ad4e;
}

.restore-set-info {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 8px;
}

.restore-set-info strong {
  color: var(--text-primary);
}

.restore-set-info span {
  color: var(--text-secondary);
  font-size: 13px;
}

.restore-comparison {
  font-size: 13px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex-basis: 100%;
}

.restore-local,
.restore-imported {
  color: var(--text-secondary);
}

.restore-choice {
  display: flex;
  gap: 0;
  margin-top: 8px;
}

.restore-choice input[type="radio"] {
  display: none;
}

.restore-choice-btn {
  flex: 1;
  padding: 8px 12px;
  border: 2px solid var(--border-color);
  background: var(--bg-secondary);
  color: var(--text-primary);
  font-size: 14px;
  font-weight: 500;
  text-align: center;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}

.restore-choice-btn:first-of-type {
  border-radius: 8px 0 0 8px;
  border-right: 1px solid var(--border-color);
}

.restore-choice-btn:last-of-type {
  border-radius: 0 8px 8px 0;
  border-left: 1px solid var(--border-color);
}

.restore-choice input[type="radio"]:checked + .restore-choice-btn {
  background: #0055BF;
  border-color: #0055BF;
  color: #fff;
}

.restore-new {
  font-size: 13px;
  color: var(--text-secondary);
}

.restore-modal-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

.restore-modal-actions button {
  padding: 8px 20px;
  border-radius: 6px;
  font-size: 14px;
  cursor: pointer;
  border: 2px solid var(--border-color);
  background: var(--bg-tertiary);
  color: var(--text-primary);
}

.restore-modal-actions button#executeRestoreBtn {
  background: var(--blue);
  color: white;
  border-color: var(--blue);
}

.restore-modal-actions button#executeRestoreBtn:hover {
  opacity: 0.9;
}

.restore-modal-actions button#cancelRestoreBtn:hover {
  background: var(--red);
  color: white;
  border-color: var(--red);
}

/* Delete Confirmation Modal */
.delete-modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;
  padding: 20px;
}

.delete-modal-overlay:not([data-visible]) {
  display: none;
}

.delete-modal {
  background: var(--bg-primary);
  border-radius: 12px;
  padding: 24px;
  max-width: 450px;
  width: 100%;
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.2);
}

.delete-modal h3 {
  margin: 0 0 16px;
  color: var(--text-primary);
}

.delete-status-safe {
  padding: 12px;
  border-radius: 8px;
  background: rgba(39, 174, 96, 0.1);
  border: 1px solid rgba(39, 174, 96, 0.3);
  color: var(--text-primary);
  margin-bottom: 16px;
  font-size: 14px;
}

.delete-status-warning {
  padding: 12px;
  border-radius: 8px;
  background: rgba(240, 173, 78, 0.1);
  border: 1px solid rgba(240, 173, 78, 0.3);
  color: var(--text-primary);
  margin-bottom: 16px;
  font-size: 14px;
}

.delete-modal-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

.delete-modal-actions button {
  padding: 8px 20px;
  border-radius: 6px;
  font-size: 14px;
  cursor: pointer;
  border: 2px solid var(--border-color);
  background: var(--bg-tertiary);
  color: var(--text-primary);
}

.delete-modal-actions button#confirmDeleteBtn {
  background: var(--red);
  color: white;
  border-color: var(--red);
}

.delete-modal-actions button#backupAndDeleteBtn {
  background: var(--blue);
  color: white;
  border-color: var(--blue);
}

.delete-modal-actions button#cancelDeleteBtn:hover {
  background: var(--bg-tertiary);
  border-color: var(--text-secondary);
}

.minifig-grid {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 15px;
  margin-bottom: 30px;
}

.minifig-card {
  width: 200px;
  background: var(--bg-tertiary);
  border: 2px solid var(--border-color);
  border-radius: 8px;
  padding: 15px;
  text-align: center;
  transition: border-color 0.2s, box-shadow 0.2s;
  position: relative;
  cursor: pointer;
}

.minifig-card:hover {
  border-color: var(--blue);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.minifig-card.complete {
  border-color: var(--green);
  background: rgba(76, 175, 80, 0.1);
}

body.dark-mode .minifig-card.complete {
  background: rgba(76, 175, 80, 0.2);
}

.minifig-image {
  width: 120px;
  height: 120px;
  object-fit: contain;
  margin-bottom: 10px;
  cursor: zoom-in;
}

.minifig-name {
  font-weight: bold;
  font-size: 14px;
  margin-bottom: 5px;
  color: var(--text-primary);
}

.minifig-id {
  font-size: 12px;
  color: var(--text-secondary);
  margin-bottom: 10px;
}

.minifig-card[data-complete="true"]::after {
  content: '✓';
  position: absolute;
  top: 8px;
  right: 8px;
  width: 36px;
  height: 36px;
  font-size: 24px;
  background: var(--green);
  color: white;
  border-radius: 50%;
  font-weight: bold;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

/* Memory Game (Easter Egg)
   ========================================================================== */

.memory-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.85);
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.memory-modal {
  background: var(--bg-secondary);
  border-radius: 16px;
  padding: 20px;
  max-width: 420px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.4);
}

.memory-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  gap: 12px;
}

.memory-title {
  font-size: 18px;
  font-weight: bold;
  color: var(--text-primary);
}

.memory-moves {
  font-size: 14px;
  color: var(--text-secondary);
}

.memory-close {
  background: none;
  border: none;
  font-size: 20px;
  cursor: pointer;
  color: var(--text-secondary);
  padding: 4px 8px;
  border-radius: 4px;
}

.memory-close:hover {
  background: var(--bg-tertiary);
  color: var(--text-primary);
}

.memory-grid {
  display: grid;
  gap: 8px;
  justify-content: center;
}

.memory-card {
  width: 80px;
  height: 80px;
  perspective: 600px;
  cursor: pointer;
}

.memory-card-inner {
  position: relative;
  width: 100%;
  height: 100%;
  transition: transform 0.4s ease;
  transform-style: preserve-3d;
}

.memory-card.flipped .memory-card-inner,
.memory-card.matched .memory-card-inner {
  transform: rotateY(180deg);
}

.memory-card-front,
.memory-card-back {
  position: absolute;
  width: 100%;
  height: 100%;
  backface-visibility: hidden;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.memory-card-back {
  background: var(--blue);
  color: white;
  font-size: 28px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
}

.memory-card-front {
  transform: rotateY(180deg);
  background: var(--bg-tertiary);
  border: 2px solid var(--border-color);
}

.memory-card-front img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  padding: 4px;
}

.memory-card.matched {
  pointer-events: none;
}

.memory-card.matched .memory-card-inner {
  transform: rotateY(180deg);
}

.memory-win {
  text-align: center;
  padding: 20px 0 8px;
}

.memory-win-text {
  font-size: 24px;
  font-weight: bold;
  color: var(--text-primary);
  margin-bottom: 8px;
}

.memory-win-stats {
  font-size: 14px;
  color: var(--text-secondary);
  margin-bottom: 16px;
}

.memory-play-again {
  padding: 10px 24px;
  border-radius: 8px;
  border: 2px solid var(--blue);
  background: var(--blue);
  color: white;
  font-size: 14px;
  cursor: pointer;
  font-weight: bold;
}

.memory-play-again:hover {
  background: #0044a0;
  border-color: #0044a0;
}

/* Responsive Design - Index.html
   ========================================================================== */

@media (max-width: 768px) {
  .set-info-layout {
    flex-direction: column;
    align-items: center;
    text-align: center;
  }

  .set-info-content {
    text-align: center;
  }

  .set-info-content .stats {
    justify-content: center;
  }

  .content-area {
    padding: 10px;
  }

  input {
    width: 100%;
  }

  .controls button {
    min-width: 45px;
    min-height: 45px;
    font-size: 20px;
  }

  .controls .count-display {
    min-width: 60px;
    font-size: 16px;
  }

  .collapsed-app-name {
    font-size: 14px;
  }

  .collapsed-set-name {
    font-size: 12px;
  }

  .header-left {
    min-width: 100%;
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
  }

  .header-left h1 {
    font-size: 20px;
  }

  .header-left .input-group {
    width: auto;
  }

  .header-left .input-group input {
    flex: 1;
    width: 100%;
  }

  .header-top {
    position: relative;
    padding-right: 0;
  }

  .collapsed-filters .filters button {
    font-size: 12px;
    padding: 6px 10px;
  }

  .collapsed-filters .column-toggle {
    font-size: 12px;
    padding: 6px 8px;
  }

  .theme-toggle {
    top: 15px;
    right: 15px;
    font-size: 20px;
  }

  .fullscreen-toggle {
    top: 15px;
    right: 50px;
    font-size: 20px;
  }

  .col-img {
    width: 80px;
  }

  .col-img img {
    max-width: 60px;
    max-height: 60px;
  }

  th,
  td {
    padding: 10px 5px;
    font-size: 14px;
  }

  .col-controls {
    width: auto;
    max-width: 180px;
  }

  .minifig-grid {
    gap: 10px;
  }

  .minifig-card {
    padding: 10px;
  }

  .minifig-image {
    width: 90px;
    height: 90px;
  }

  .minifig-card[data-complete="true"]::after {
    width: 32px;
    height: 32px;
    font-size: 20px;
  }

  .memory-modal {
    max-width: 340px;
    padding: 16px;
  }

  .memory-grid {
    gap: 6px;
  }

  .memory-card {
    width: 70px;
    height: 70px;
  }
}

@media (min-width: 769px) and (max-width: 1024px) {
  /* Tablet optimizations */
  .controls button {
    min-width: 60px;
    min-height: 60px;
    font-size: 26px;
  }

  .controls .count-display {
    min-width: 90px;
    font-size: 20px;
  }

  th,
  td {
    padding: 18px 12px;
  }
}

/* ==========================================================================
   VERIFY.HTML - Verification Page Styles
   ========================================================================== */

/* Verify Page - Body Override
   ========================================================================== */

body.verify-page {
  padding: 20px;
  position: relative;
}

/* Verify Page - Container
   ========================================================================== */

.container {
  max-width: 1200px;
  margin: 0 auto;
  background: var(--bg-secondary);
  padding: 40px;
  border-radius: 8px;
  box-shadow: 0 2px 10px var(--shadow);
  position: relative;
}

/* Verify Page - Title & Header
   ========================================================================== */

.verify-page h1 {
  color: var(--blue);
  margin-bottom: 10px;
  font-size: 24px;
}

.title-row {
  display: flex;
  align-items: center;
  gap: 20px;
  margin-bottom: 20px;
  flex-wrap: wrap;
  padding-right: 50px;
}

.set-header {
  margin: 20px 0;
  text-align: center;
}

.set-image {
  max-width: 400px;
  width: 100%;
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.status-badge {
  display: inline-block;
  padding: 8px 16px;
  border-radius: 6px;
  font-weight: bold;
  font-size: 14px;
}

.status-complete {
  background: var(--green);
  color: white;
}

.status-incomplete {
  background: var(--orange);
  color: white;
}

/* Verify Page - Stats
   ========================================================================== */

.verify-page .stats {
  background: var(--bg-tertiary);
  padding: 20px;
  border-radius: 6px;
  margin: 20px 0;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 20px;
  margin-top: 15px;
}

.stat-item {
  text-align: center;
}

.stat-value {
  font-size: 36px;
  font-weight: bold;
  color: var(--blue);
}

.stat-label {
  font-size: 14px;
  color: var(--text-secondary);
  margin-top: 5px;
}

/* Verify Page - Progress Bar Override
   ========================================================================== */

.verify-page .progress-bar {
  background: #e0e0e0;
  border-radius: 10px;
  overflow: hidden;
  height: 40px;
  margin: 20px 0;
  position: relative;
}

.verify-page .progress-bar::after {
  color: white;
  font-size: 18px;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}

.verify-page .progress-bar::before {
  color: white;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}

/* Verify Page - Table
   ========================================================================== */

.verify-page table {
  margin-top: 30px;
}

.verify-page th {
  background: var(--blue);
  color: white;
  font-weight: bold;
}

.verify-page th,
.verify-page td {
  padding: 12px;
}

.verify-page .col-info {
  line-height: 1.5;
}

.missing-col {
  text-align: right;
}

.part-image {
  width: 60px;
  height: 60px;
  object-fit: contain;
  cursor: pointer;
}

.missing-count {
  background: var(--red);
  color: white;
  padding: 4px 12px;
  border-radius: 4px;
  font-weight: bold;
}

.no-missing {
  text-align: center;
  padding: 40px;
  color: var(--text-secondary);
}

.no-missing .checkmark {
  font-size: 64px;
  color: var(--green);
  margin-bottom: 20px;
}

.back-link {
  display: inline-block;
  margin-top: 30px;
  padding: 12px 24px;
  background: var(--blue);
  color: white;
  text-decoration: none;
  border-radius: 6px;
}

.back-link:hover {
  background: #003d8f;
}

/* Verify Page - Responsive
   ========================================================================== */

@media (max-width: 768px) {
  .container {
    padding: 20px;
  }

  .verify-page .theme-toggle {
    top: 15px;
    right: 15px;
    font-size: 20px;
  }

  .title-row {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
    padding-right: 40px;
  }

  .verify-page h1 {
    font-size: 20px;
  }

  .set-image {
    max-width: 100%;
  }

  .stats-grid {
    grid-template-columns: 1fr 1fr;
  }

  .verify-page th,
  .verify-page td {
    padding: 8px;
    font-size: 14px;
  }

  .part-image {
    width: 40px;
    height: 40px;
  }
}

/* ==========================================================================
   Footer
   ========================================================================== */

.app-footer {
  padding: 4px 12px;
  background: var(--bg-secondary);
  font-size: 11px;
  color: var(--text-secondary);
  text-align: center;
  z-index: 100;
  position: relative;
}

.app-footer #versionInfo {
  position: absolute;
  right: 12px;
  bottom: 4px;
}

.footer-version-link {
  color: var(--text-secondary);
  text-decoration: none;
  font-size: inherit;
}

.footer-version-link:hover {
  text-decoration: underline;
}

/* What's New Modal
   ========================================================================== */

.whats-new-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.8);
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.whats-new-modal {
  background: var(--bg-secondary);
  border-radius: 16px;
  padding: 28px 28px 24px;
  max-width: 440px;
  width: 100%;
  max-height: 80vh;
  overflow-y: auto;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.4);
  border: 1px solid var(--border-color);
}

.whats-new-title {
  color: var(--text-primary);
  font-size: 20px;
  font-weight: 800;
  margin-bottom: 20px;
}

.whats-new-entries {
  list-style: none;
  padding: 0;
  margin: 0 0 16px 0;
}

.whats-new-entries li {
  color: var(--text-primary);
  padding: 10px 12px;
  margin-bottom: 6px;
  background: var(--bg-tertiary);
  border-radius: 8px;
  font-size: 14px;
  line-height: 1.5;
}

.whats-new-entries li:last-child {
  margin-bottom: 0;
}

.whats-new-message {
  color: var(--text-secondary);
  font-size: 14px;
  margin-bottom: 20px;
}

.whats-new-changelog-link {
  display: block;
  color: var(--blue);
  text-decoration: none;
  font-size: 13px;
  margin-bottom: 20px;
}

.whats-new-changelog-link:hover {
  text-decoration: underline;
}

.whats-new-actions {
  display: flex;
  gap: 10px;
}

.whats-new-update-btn {
  flex: 1;
  padding: 10px 20px;
  background: var(--blue);
  color: white;
  border: none;
  border-radius: 6px;
  font-size: 14px;
  cursor: pointer;
}

.whats-new-update-btn:hover {
  background: var(--blue-dark);
}

.whats-new-later-btn {
  flex: 1;
  padding: 10px 20px;
  background: var(--bg-tertiary);
  color: var(--text-secondary);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  font-size: 14px;
  cursor: pointer;
}

.whats-new-later-btn:hover {
  background: var(--hover-bg);
}

/* Changelog Page
   ========================================================================== */

.changelog-page {
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
}

.changelog-title {
  color: var(--text-primary);
  font-size: 28px;
  margin: 20px 0 8px;
  font-weight: 800;
}

.changelog-subtitle {
  color: var(--text-secondary);
  font-size: 14px;
  margin-bottom: 32px;
}

.changelog-release {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 20px 24px;
  margin-bottom: 16px;
  position: relative;
}

.changelog-release:first-child {
  border-color: var(--blue);
  box-shadow: 0 0 0 1px var(--blue), 0 2px 8px var(--shadow);
}

.changelog-release-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 6px;
}

.changelog-version {
  background: var(--blue);
  color: white;
  padding: 3px 10px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: bold;
  letter-spacing: 0.3px;
}

.changelog-release:first-child .changelog-version {
  background: var(--green);
}

.changelog-date {
  color: var(--text-secondary);
  font-size: 12px;
}

.changelog-release-title {
  color: var(--text-primary);
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 12px;
}

.changelog-entries {
  list-style: none;
  padding: 0;
  margin: 0;
}

.changelog-entries li {
  color: var(--text-secondary);
  padding: 5px 0 5px 20px;
  position: relative;
  font-size: 14px;
  line-height: 1.6;
}

.changelog-entries li::before {
  content: '→';
  position: absolute;
  left: 0;
  color: var(--blue);
  font-weight: bold;
}
