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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
  background: #f5f5f5;
  min-height: 100vh;
  color: #333;
}

#root {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Viewer page overrides */
#root:has(#canvas) {
  display: block;
  background: #f5f5f5;
}

.container {
  position: relative;
  width: 90vw;
  max-width: 1200px;
  height: 90vh;
  background: white;
  border-radius: 16px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

header {
  padding: 1rem 2rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: linear-gradient(135deg, #FF9500 0%, #FF6B6B 100%);
  color: white;
}

header .header-logo {
  width: 48px;
  height: 48px;
}

header .header-text {
  text-align: right;
}

header h1 {
  font-size: 1.5rem;
  margin-bottom: 0.25rem;
}

header p {
  opacity: 0.9;
  font-size: 0.9rem;
}

.drop-zone {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 2rem;
  border: 3px dashed #ccc;
  border-radius: 12px;
  transition: all 0.3s ease;
  cursor: pointer;
}

.drop-zone:hover,
.drop-zone.drag-over {
  border-color: #FF9500;
  background: rgba(255, 149, 0, 0.05);
}

.drop-zone-content {
  text-align: center;
  padding: 2rem;
}

.drop-zone-content svg {
  color: #FF9500;
  margin-bottom: 1rem;
}

.drop-zone-content h2 {
  font-size: 1.5rem;
  margin-bottom: 1rem;
  color: #333;
}

.drop-zone-content p {
  color: #666;
  margin: 1rem 0;
}

.file-input-label {
  display: inline-block;
  padding: 0.75rem 2rem;
  background: linear-gradient(135deg, #FF9500 0%, #FF6B6B 100%);
  color: white;
  border-radius: 8px;
  cursor: pointer;
  transition: transform 0.2s ease;
  font-weight: 600;
}

.file-input-label:hover {
  transform: translateY(-2px);
}

#canvas {
  width: 100vw;
  height: 100vh;
  background: white;
  display: block;
  user-select: none;
  -webkit-user-drag: none;
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
}

.zoom-controls {
  position: fixed;
  top: 2rem;
  right: 2rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  z-index: 10;
}

.zoom-button {
  width: 48px;
  height: 48px;
  background: white;
  border: 2px solid #FF9500;
  border-radius: 8px;
  cursor: pointer;
  font-size: 24px;
  font-weight: bold;
  color: #FF9500;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.zoom-button:hover {
  background: #FF9500;
  color: white;
  transform: scale(1.05);
}

.zoom-button:active {
  transform: scale(0.95);
}

.button {
  padding: 0.75rem 2rem;
  background: linear-gradient(135deg, #FF9500 0%, #FF6B6B 100%);
  color: white;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: transform 0.2s ease;
  font-weight: 600;
  font-size: 1rem;
  font-family: inherit;
}

.button:hover {
  transform: translateY(-2px);
}

.button:active {
  transform: translateY(0);
}

.status {
  padding: 1rem 2rem;
  text-align: center;
  font-weight: 500;
}

/* Status in file uploader */
.container .status {
  padding: 1rem 2rem;
  text-align: center;
  font-weight: 500;
}

/* Status in viewer (toast) */
#canvas ~ .status {
  position: fixed;
  top: 2rem;
  left: 2rem;
  padding: 1rem 2rem;
  border-radius: 8px;
  font-weight: 500;
  z-index: 10;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  opacity: 0;
  transform: translateY(-20px);
  transition: opacity 0.3s ease, transform 0.3s ease;
  pointer-events: none;
}

#canvas ~ .status.show {
  opacity: 1;
  transform: translateY(0);
}

.status.success {
  background: #d4edda;
  color: #155724;
}

.status.error {
  background: #f8d7da;
  color: #721c24;
}

/* Tab navigation */
.tabs {
  display: flex;
  border-bottom: 2px solid #e0e0e0;
  background: white;
}

.tab {
  flex: 1;
  padding: 1rem 2rem;
  background: transparent;
  border: none;
  font-size: 1rem;
  font-weight: 600;
  color: #666;
  cursor: pointer;
  transition: all 0.2s ease;
  border-bottom: 3px solid transparent;
}

.tab:hover {
  background: rgba(255, 149, 0, 0.05);
  color: #FF9500;
}

.tab.active {
  color: #FF9500;
  border-bottom-color: #FF9500;
}

.tab-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.action-bar {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  padding: 0.75rem 1.5rem;
  background: #f8f9fa;
  border-bottom: 1px solid #e0e0e0;
  gap: 0.75rem;
}

.action-bar .button {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  font-size: 0.9rem;
}

.browse-directory-section {
  padding: 1rem 2rem 1.5rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
  border-top: 1px solid #e0e0e0;
  background: #fafafa;
}

.browse-hint {
  font-size: 0.9rem;
  color: #666;
}

.browse-directory-section .button {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* Getting Started Guide */
.guide-section {
  border-bottom: 1px solid #e0e0e0;
  background: #fafafa;
}

.guide-toggle {
  width: 100%;
  padding: 0.75rem 1.5rem;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 0.5rem;
  background: transparent;
  border: none;
  cursor: pointer;
  font-size: 0.9rem;
  color: #666;
  transition: all 0.2s ease;
}

.guide-toggle:hover {
  background: rgba(255, 149, 0, 0.05);
  color: #FF9500;
}

.guide-chevron {
  transition: transform 0.2s ease;
}

.guide-chevron.expanded {
  transform: rotate(180deg);
}

.guide-content {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2rem;
  padding: 1rem 2rem 1.5rem;
  border-top: 1px solid #e0e0e0;
  background: white;
}

.guide-column h3 {
  font-size: 1rem;
  color: #FF9500;
  margin-bottom: 0.5rem;
}

.guide-column p {
  font-size: 0.85rem;
  color: #666;
  margin-bottom: 0.75rem;
}

.guide-column ol {
  font-size: 0.85rem;
  color: #333;
  padding-left: 1.25rem;
  line-height: 1.6;
}

.guide-column li {
  margin-bottom: 0.25rem;
}

.guide-column code {
  background: #f0f0f0;
  padding: 0.1rem 0.4rem;
  border-radius: 4px;
  font-size: 0.8rem;
}

.guide-column a {
  color: #FF9500;
  text-decoration: underline;
}

/* Recent Files */
.recent-files {
  padding: 1rem 2rem;
  border-top: 1px solid #e0e0e0;
  background: #fafafa;
  max-height: 200px;
  overflow-y: auto;
}

.recent-files-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.75rem;
}

.recent-files-header h3 {
  font-size: 0.9rem;
  color: #666;
  font-weight: 600;
}

.clear-all-button {
  background: transparent;
  border: none;
  color: #999;
  font-size: 0.8rem;
  cursor: pointer;
  padding: 0.25rem 0.5rem;
  border-radius: 4px;
  transition: all 0.2s ease;
}

.clear-all-button:hover {
  background: rgba(255, 149, 0, 0.1);
  color: #FF9500;
}

.recent-files-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.recent-file-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.5rem 0.75rem;
  background: white;
  border: 1px solid #e0e0e0;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.recent-file-item:hover {
  border-color: #FF9500;
  background: rgba(255, 149, 0, 0.02);
}

.recent-file-icon {
  color: #FF9500;
  flex-shrink: 0;
}

.recent-file-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0.125rem;
}

.recent-file-name {
  font-size: 0.9rem;
  font-weight: 500;
  color: #333;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.recent-file-meta {
  font-size: 0.75rem;
  color: #999;
}

.recent-file-remove {
  background: transparent;
  border: none;
  color: #ccc;
  cursor: pointer;
  padding: 0.25rem;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  flex-shrink: 0;
}

.recent-file-remove:hover {
  background: rgba(255, 0, 0, 0.1);
  color: #ff4444;
}

/* Gallery styles */
.gallery-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.breadcrumb {
  padding: 1rem 2rem;
  background: #f8f9fa;
  border-bottom: 1px solid #e0e0e0;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.breadcrumb-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.95rem;
}

.breadcrumb-link {
  color: #FF9500;
  cursor: pointer;
  text-decoration: none;
  transition: opacity 0.2s ease;
}

.breadcrumb-link:hover {
  opacity: 0.7;
  text-decoration: underline;
}

.breadcrumb-separator {
  color: #999;
}

.breadcrumb-current {
  color: #333;
  font-weight: 600;
}

.back-button {
  padding: 0.5rem 1rem;
  background: white;
  border: 2px solid #FF9500;
  color: #FF9500;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 600;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.back-button:hover {
  background: #FF9500;
  color: white;
}

.gallery-content {
  flex: 1;
  overflow-y: auto;
  padding: 2rem;
}

.thumbnail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 1.5rem;
  padding-bottom: 2rem;
}

.thumbnail-card {
  background: white;
  border: 2px solid #e0e0e0;
  border-radius: 12px;
  overflow: hidden;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  flex-direction: column;
}

.thumbnail-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 8px 16px rgba(0, 0, 0, 0.15);
  border-color: #FF9500;
}

.thumbnail-content {
  width: 100%;
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #f8f9fa;
  overflow: hidden;
}

.thumbnail-content img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.thumbnail-placeholder,
.thumbnail-loading,
.folder-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  color: #999;
}

.folder-icon svg {
  color: #FF9500;
}

.spinner {
  width: 40px;
  height: 40px;
  border: 4px solid #f3f3f3;
  border-top: 4px solid #FF9500;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

.thumbnail-name {
  padding: 0.75rem;
  font-size: 0.9rem;
  font-weight: 500;
  color: #333;
  text-align: center;
  word-break: break-word;
  line-height: 1.3;
}

.thumbnail-count {
  padding: 0 0.75rem 0.75rem;
  font-size: 0.8rem;
  color: #666;
  text-align: center;
}

.directory-card .thumbnail-content {
  background: linear-gradient(135deg, rgba(255, 149, 0, 0.1) 0%, rgba(255, 107, 107, 0.1) 100%);
}

.empty-state {
  grid-column: 1 / -1;
  text-align: center;
  padding: 4rem 2rem;
  color: #666;
}

.empty-state p {
  font-size: 1.1rem;
}

/* Directory selector */
.directory-selector {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 2rem;
}

.directory-selector-content {
  text-align: center;
  max-width: 500px;
}

.directory-selector-content svg {
  color: #FF9500;
  margin-bottom: 1.5rem;
}

.directory-selector-content h2 {
  font-size: 1.5rem;
  margin-bottom: 1rem;
  color: #333;
}

.directory-selector-content p {
  color: #666;
  margin-bottom: 2rem;
  line-height: 1.6;
}

.progress-container {
  margin-top: 2rem;
  text-align: center;
}

.progress-message {
  font-size: 0.95rem;
  color: #FF9500;
  margin-bottom: 0.5rem;
  font-weight: 500;
}

.progress-count {
  font-size: 0.85rem;
  color: #666;
}

.button-group {
  display: flex;
  gap: 1rem;
  justify-content: center;
  margin-top: 1rem;
}

.button.secondary {
  background: white;
  border: 2px solid #FF9500;
  color: #FF9500;
}

.button.secondary:hover {
  background: #FF9500;
  color: white;
}

@media (max-width: 768px) {
  .container {
    width: 100vw;
    height: 100vh;
    border-radius: 0;
  }

  header {
    padding: 0.75rem 1rem;
  }

  header .header-logo {
    width: 36px;
    height: 36px;
  }

  header h1 {
    font-size: 1.1rem;
  }

  header p {
    font-size: 0.8rem;
  }

  .drop-zone {
    margin: 1rem;
  }

  .zoom-controls {
    top: 1rem;
    right: 1rem;
  }

  .zoom-button {
    width: 40px;
    height: 40px;
    font-size: 20px;
  }

  #canvas ~ .status {
    top: 1rem;
    left: 1rem;
    padding: 0.75rem 1.5rem;
    font-size: 0.9rem;
  }

  .thumbnail-grid {
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 1rem;
    padding: 1rem;
  }

  .gallery-content {
    padding: 1rem;
  }

  .breadcrumb {
    padding: 0.75rem 1rem;
    font-size: 0.85rem;
  }

  .tab {
    padding: 0.75rem 1rem;
    font-size: 0.9rem;
  }

  .guide-content {
    grid-template-columns: 1fr;
    gap: 1.5rem;
    padding: 1rem;
  }

  .guide-toggle {
    font-size: 0.85rem;
    padding: 0.5rem 1rem;
  }
}
