:root {
  --bg: #fafafa;
  --surface: #ffffff;
  --border: #e5e5e5;
  --text: #171717;
  --text-muted: #737373;
  --accent: #3b82f6;
  --accent-hover: #2563eb;
  --success: #22c55e;
  --warning: #f59e0b;
  --error: #ef4444;
  --shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1);
  --radius: 12px;
  --radius-sm: 8px;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 1rem 2rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
}

header h1 {
  font-size: 1.5rem;
  font-weight: 600;
}

header .tagline {
  font-size: 0.875rem;
  color: var(--text-muted);
  text-align: center;
}

nav a {
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.875rem;
  transition: color 0.15s;
}

nav a:hover {
  color: var(--accent);
}

main {
  flex: 1;
  padding: 2rem;
  max-width: 1200px;
  width: 100%;
  margin: 0 auto;
}

.drop-zone {
  background: var(--surface);
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 3rem 2rem;
  text-align: center;
  cursor: pointer;
  transition: all 0.15s;
}

.drop-zone:hover, .drop-zone.dragover {
  border-color: var(--accent);
  background: #f8fafc;
}

.drop-zone p {
  color: var(--text-muted);
  font-size: 0.875rem;
}

.drop-zone p strong {
  color: var(--text);
  font-weight: 500;
}

.upload-settings {
  margin-top: 1rem;
  text-align: center;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1.5rem;
  flex-wrap: wrap;
}

.upload-settings .checkbox-label {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.875rem;
  color: var(--text);
  cursor: pointer;
}

.upload-settings .checkbox-label input[type="checkbox"] {
  width: 16px;
  height: 16px;
  cursor: pointer;
}

.upload-settings .threshold-label {
  display: inline-flex;
  align-items: center;
  gap: 0.75rem;
  font-size: 0.875rem;
  color: var(--text);
  cursor: pointer;
  transition: opacity 0.15s;
}

.upload-settings .threshold-label.disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.upload-settings .threshold-label.disabled input[type="range"] {
  cursor: not-allowed;
}

.upload-settings input[type="range"] {
  width: 120px;
}

.upload-settings span {
  min-width: 24px;
  font-variant-numeric: tabular-nums;
}

/* Download Section */
.download-section {
  margin-top: 1rem;
  text-align: center;
}

.canvas-wrapper {
  position: relative;
  display: inline-block;
  margin-top: 1.5rem;
  border-radius: var(--radius-sm);
  overflow: hidden;
  box-shadow: var(--shadow-lg);
}

.preview-canvas, .overlay-canvas {
  display: block;
  max-width: 100%;
  height: auto;
}

.overlay-canvas {
  position: absolute;
  top: 0;
  left: 0;
  pointer-events: none;
}

.status {
  margin-top: 1rem;
  padding: 0.75rem 1rem;
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
}

.status.success {
  background: #dcfce7;
  color: #166534;
}

.status.warning {
  background: #fef3c7;
  color: #92400e;
}

.status.error {
  background: #fee2e2;
  color: #991b1b;
}

.hidden {
  display: none;
}

/* Animation Controls */
.animation-controls {
  margin-top: 1.5rem;
  text-align: center;
}

.btn {
  padding: 0.75rem 1.5rem;
  border-radius: var(--radius-sm);
  border: none;
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
}

.btn-primary {
  background: var(--accent);
  color: white;
}

.btn-primary:hover {
  background: var(--accent-hover);
}

/* Animation Editor */
.animation-editor-container {
  margin-top: 1.5rem;
}

.animation-editor {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.animation-editor-header {
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--border);
  background: #f8fafc;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

.header-left {
  flex-shrink: 0;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}

.generation-settings {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}

.generation-settings label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.875rem;
  color: var(--text);
}

.generation-settings input[type="number"] {
  width: 70px;
  padding: 0.375rem 0.5rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
}

.generation-settings select {
  padding: 0.375rem 0.5rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  background: white;
}

.animation-list {
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  max-height: calc(100vh - 250px);
  overflow-y: auto;
}

.no-animations {
  color: var(--text-muted);
  text-align: center;
  padding: 2rem;
}

/* Animation Card */
.animation-card {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: #fafafa;
}

.animation-card-header {
  padding: 0.75rem 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  gap: 1rem;
  flex-wrap: wrap;
}

.animation-card-header.editable {
  flex-wrap: wrap;
}

.animation-name-input {
  font-weight: 500;
  font-size: 0.875rem;
  padding: 0.375rem 0.5rem;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: transparent;
  min-width: 120px;
}

.animation-name-input:hover,
.animation-name-input:focus {
  border-color: var(--border);
  background: white;
  outline: none;
}

.animation-controls-row {
  display: flex;
  align-items: center;
  gap: 1rem;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.animation-controls-row label {
  display: flex;
  align-items: center;
  gap: 0.375rem;
}

.animation-duration-input {
  width: 60px;
  padding: 0.25rem 0.375rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.75rem;
}

.animation-loop-select {
  padding: 0.25rem 0.375rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.75rem;
  background: white;
}

.animation-name {
  font-weight: 500;
  font-size: 0.875rem;
}

.animation-meta {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.animation-frames {
  display: flex;
  gap: 0.5rem;
  padding: 1rem;
  overflow-x: auto;
  align-items: center;
}

.frame-thumbnail-wrapper {
  position: relative;
  flex-shrink: 0;
}

.frame-thumbnail-wrapper:hover .frame-controls {
  opacity: 1;
}

.frame-controls {
  position: absolute;
  top: -8px;
  right: -8px;
  display: flex;
  gap: 2px;
  opacity: 0;
  transition: opacity 0.15s;
}

.frame-btn {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: none;
  font-size: 12px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.frame-btn.duplicate {
  background: var(--success);
  color: white;
}

.frame-btn.replace {
  background: var(--accent);
  color: white;
}

.frame-btn.remove {
  background: var(--error);
  color: white;
}

.frame-btn:hover {
  transform: scale(1.1);
}

.btn-add-frame {
  width: 56px;
  height: 56px;
  border: 2px dashed var(--border);
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-muted);
  font-size: 20px;
  cursor: pointer;
  flex-shrink: 0;
  transition: all 0.15s;
  margin-left: 10px;
}

.btn-add-frame:hover {
  border-color: var(--accent);
  color: var(--accent);
}

/* Sprite Picker Modal */
.sprite-picker-modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
}

.sprite-picker-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
}

.sprite-picker-content {
  position: relative;
  background: var(--surface);
  border-radius: var(--radius);
  padding: 1.5rem;
  max-width: 600px;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  z-index: 1;
}

.sprite-picker-content h4 {
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
}

.sprite-picker-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
  gap: 0.75rem;
  overflow-y: auto;
  padding: 0.5rem;
}

.sprite-picker-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
  padding: 0.5rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.15s;
}

.sprite-picker-item:hover {
  border-color: var(--accent);
  background: #f8fafc;
}

.sprite-picker-item canvas {
  width: 64px;
  height: 64px;
}

.sprite-picker-item span {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.btn-secondary {
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
}

.btn-secondary:hover {
  background: var(--border);
}

.animation-preview-container {
  padding: 1rem;
  background: #f8fafc;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: center;
}

.animation-preview {
  width: 128px;
  height: 128px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: #2a2a2a;
  display: block;
}

.frame-thumbnail {
  width: 64px;
  height: 64px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  flex-shrink: 0;
}

/* Animation Export Buttons */
.animation-export {
  display: flex;
  gap: 0.5rem;
  justify-content: flex-end;
  padding: 0.75rem 1rem;
  border-top: 1px solid var(--border);
  background: #f8fafc;
}

.btn-export {
  padding: 0.375rem 0.75rem;
  font-size: 0.75rem;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
}

.btn-export:hover {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
}

.btn-sm {
  padding: 0.375rem 0.75rem;
  font-size: 0.75rem;
}
.btn-new-animation,
.btn-export-aseprite {
  margin-bottom: 1rem;
  padding: 0.5rem 1rem;
  font-size: 0.875rem;
}

.btn-export-aseprite {
  margin-left: 0.5rem;
}

.btn-delete-animation {
  background: transparent;
  border: none;
  font-size: 1rem;
  cursor: pointer;
  padding: 0.25rem 0.5rem;
  opacity: 0.5;
  transition: opacity 0.15s;
}

.btn-delete-animation:hover {
  opacity: 1;
  color: var(--error);
}

/* Multi-select sprite picker styles */
.sprite-picker-content.multi-select {
  max-width: 700px;
}

.sprite-picker-item.multi-select-item {
  position: relative;
}

.sprite-picker-item.multi-select-item.selected {
  border-color: var(--accent);
  background: #eff6ff;
}

.sprite-picker-item .checkmark {
  position: absolute;
  top: -4px;
  right: -4px;
  width: 18px;
  height: 18px;
  background: var(--accent);
  color: white;
  border-radius: 50%;
  display: none;
  align-items: center;
  justify-content: center;
  font-size: 10px;
}

.sprite-picker-item.multi-select-item.selected .checkmark {
  display: flex;
}

.new-animation-name {
  padding: 0.375rem 0.5rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  width: 200px;
}

.button-row {
  display: flex;
  gap: 0.5rem;
  justify-content: flex-end;
}

.button-row .btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Frame Insert Bar */
.frame-insert-bar {
  width: 12px;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  position: relative;
  transition: all 0.15s;
  border-radius: var(--radius-sm);
}

.frame-insert-bar::before {
  content: "";
  width: 2px;
  height: 40px;
  background: var(--border);
  transition: background 0.15s;
}

.frame-insert-bar:hover::before {
  background: var(--accent);
}

.frame-insert-bar .insert-plus {
  position: absolute;
  width: 16px;
  height: 16px;
  background: var(--accent);
  color: white;
  border-radius: 50%;
  display: none;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: bold;
}

.frame-insert-bar:hover .insert-plus {
  display: flex;
}
