* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --bg-primary: #1a1a2e;
  --bg-secondary: #1a1a2e;
  --bg-tertiary: #252538;
  --text-primary: #e4e4e7;
  --text-secondary: #a1a1aa;
  --text-muted: #71717a;
  --accent: #6c63ff;
  --accent-hover: #5b54e6;
  --border: #27272a;
  --error: #ef4444;
  --success: #22c55e;
  --viewer-bg: #1a1a2e;
}

/* Light theme */
:root.light {
  --bg-primary: #ffffff;
  --bg-secondary: #f5f5f5;
  --bg-tertiary: #e5e5e5;
  --text-primary: #1a1a1a;
  --text-secondary: #525252;
  --text-muted: #737373;
  --border: #d4d4d4;
  --viewer-bg: #ffffff;
}

html, body {
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  overflow: hidden;
}

#app {
  display: flex;
  flex-direction: column;
  height: 100%;
}

/* Header */
.header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 20px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
}

.logo {
  font-size: 18px;
  font-weight: 600;
  color: var(--text-primary);
}

.nav {
  display: flex;
  gap: 8px;
}

.btn {
  background: var(--accent);
  color: white;
  border: none;
  padding: 8px 16px;
  border-radius: 6px;
  font-size: 14px;
  cursor: pointer;
  transition: background 0.2s;
}

.btn:hover {
  background: var(--accent-hover);
}

.btn-secondary {
  background: var(--bg-tertiary);
  color: var(--text-secondary);
}

.btn-secondary:hover {
  background: var(--border);
  color: var(--text-primary);
}

/* Viewer container */
.viewer-container {
  flex: 1;
  position: relative;
  overflow: hidden;
}

#viewer {
  width: 100%;
  height: 100%;
  display: block;
}

.hidden {
  display: none !important;
}

/* Drop zone */
.drop-zone {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-primary);
  cursor: pointer;
}

.drop-content {
  text-align: center;
  padding: 40px;
  border: 2px dashed var(--border);
  border-radius: 16px;
  transition: all 0.2s;
}

.drop-zone:hover .drop-content,
.drop-zone.drag-over .drop-content {
  border-color: var(--accent);
  background: rgba(108, 99, 255, 0.05);
}

.drop-icon {
  color: var(--text-muted);
  margin-bottom: 16px;
}

.drop-content h2 {
  font-size: 20px;
  margin-bottom: 8px;
}

.drop-content p {
  color: var(--text-muted);
}

/* Loading */
.loading {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: rgba(26, 26, 46, 0.95);
  z-index: 100;
}

:root.light .loading {
  background: rgba(255, 255, 255, 0.95);
}

:root.light .loading p,
:root.light #progressPercent {
  color: var(--text-secondary);
}

:root.light .spinner {
  border-color: var(--border);
  border-top-color: var(--accent);
}

:root.light .progress-bar {
  background: var(--border);
}

.spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.loading p {
  margin-top: 16px;
  color: var(--text-secondary);
}

.progress-bar {
  width: 200px;
  height: 6px;
  background: var(--border);
  border-radius: 3px;
  margin-top: 16px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  width: 0%;
  background: var(--accent);
  border-radius: 3px;
  transition: width 0.1s ease-out;
}

#progressPercent {
  margin-top: 8px;
  font-size: 12px;
  color: var(--text-muted);
}

/* Status bar */
.status-bar {
  display: flex;
  gap: 24px;
  padding: 8px 20px;
  background: var(--bg-secondary);
  border-top: 1px solid var(--border);
  font-size: 12px;
  color: var(--text-muted);
}

.status-bar span:first-child {
  flex: 1;
}

/* Layers panel */
.layers-panel {
  position: absolute;
  top: 0;
  right: 0;
  width: 280px;
  height: 100%;
  background: var(--bg-secondary);
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  z-index: 50;
}

.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px;
  border-bottom: 1px solid var(--border);
}

.panel-header h3 {
  font-size: 14px;
  font-weight: 600;
}

.btn-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 20px;
  cursor: pointer;
  padding: 4px 8px;
}

.btn-close:hover {
  color: var(--text-primary);
}

#layersList {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
  list-style: none;
}

#layersList li {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px;
  border-radius: 6px;
  cursor: pointer;
}

#layersList li:hover {
  background: var(--bg-tertiary);
}

/* Error message */
.error-message {
  position: absolute;
  bottom: 80px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid var(--error);
  color: var(--error);
  padding: 12px 24px;
  border-radius: 8px;
  font-size: 14px;
  text-align: center;
  max-width: 400px;
  z-index: 10;
}

/* Layer controls */
.layer-controls {
  display: flex;
  gap: 8px;
  padding: 8px;
  border-bottom: 1px solid var(--border);
}

.btn-small {
  padding: 6px 12px;
  font-size: 12px;
}

.layer-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px;
  border-radius: 6px;
}

.layer-item:hover {
  background: var(--bg-tertiary);
}

.layer-color {
  width: 16px;
  height: 16px;
  border-radius: 4px;
  border: 1px solid var(--border);
}

.layer-item label {
  flex: 1;
  cursor: pointer;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.layer-item input[type="checkbox"] {
  width: 16px;
  height: 16px;
  cursor: pointer;
  accent-color: var(--accent);
}

/* SEO: H1 in logo styled to look identical */
.logo h1 {
  font-size: inherit;
  font-weight: inherit;
  margin: 0;
  padding: 0;
  display: inline;
  color: inherit;
  line-height: inherit;
}

/* Rating widget - floating card */
.rating-widget {
  position: fixed;
  bottom: 60px;
  right: 20px;
  z-index: 40;
  transition: right 0.3s ease, transform 0.3s ease, opacity 0.3s ease;
}

/* Shift left when layers panel is open - controlled by JS */

.rating-content {
  position: relative;
  background: linear-gradient(135deg, #2a2a42 0%, #1e1e32 100%);
  border: 1px solid rgba(108, 99, 255, 0.3);
  border-radius: 24px;
  padding: 24px 30px;
  text-align: center;
  box-shadow: 0 12px 48px rgba(0, 0, 0, 0.4), 0 0 0 1px rgba(108, 99, 255, 0.1);
  backdrop-filter: blur(8px);
}

.rating-text {
  font-size: 21px;
  font-weight: 600;
  color: #fff;
  margin-bottom: 6px;
  text-shadow: 0 0 30px rgba(108, 99, 255, 0.5);
}

.rating-subtext {
  font-size: 18px;
  color: #a78bfa;
  margin-bottom: 18px;
}

.rating-stars {
  display: flex;
  flex-direction: row-reverse;
  justify-content: center;
  gap: 6px;
}

.rating-stars input {
  position: absolute;
  left: -9999px;
}

.rating-stars label {
  cursor: pointer;
  font-size: 42px;
  color: #4a4a5a;
  transition: color 0.2s, transform 0.2s, text-shadow 0.2s;
  line-height: 1;
}

.rating-stars label:hover,
.rating-stars label:hover ~ label {
  color: #ffc107;
  transform: scale(1.2);
  text-shadow: 0 0 12px rgba(255, 193, 7, 0.5);
}

/* Light theme adjustments */
:root.light .rating-content {
  background: linear-gradient(135deg, #ffffff 0%, #f5f5f5 100%);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
}

:root.light .rating-stars label {
  color: #d4d4d4;
}

/* Rating close button - mobile only */
.rating-close {
  display: none;
  position: absolute;
  top: 8px;
  right: 12px;
  background: none;
  border: none;
  color: #6b7280;
  font-size: 24px;
  cursor: pointer;
  padding: 0;
  line-height: 1;
  transition: color 0.2s;
}

.rating-close:hover {
  color: #fff;
}

:root.light .rating-close:hover {
  color: #333;
}

/* Mobile: compact rating widget */
@media (max-width: 768px) {
  .rating-widget {
    bottom: 16px;
    right: 12px;
    left: 12px;
  }

  .rating-content {
    padding: 16px 20px;
    border-radius: 16px;
  }

  .rating-text {
    font-size: 16px;
  }

  .rating-subtext {
    font-size: 14px;
    margin-bottom: 12px;
  }

  .rating-stars label {
    font-size: 32px;
  }

  .rating-close {
    display: block;
    top: 6px;
    right: 10px;
    font-size: 22px;
  }
}
