/* Reset & Base */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --color-bg: #ffffff;
  --color-surface: #f9fafb;
  --color-border: #e5e7eb;
  --color-border-hover: #d1d5db;
  --color-text: #111827;
  --color-text-secondary: #6b7280;
  --color-primary: #3b82f6;
  --color-primary-hover: #2563eb;
  --color-primary-light: #eff6ff;
  --color-success: #10b981;
  --color-success-light: #d1fae5;
  --color-error: #ef4444;
  --color-error-light: #fee2e2;
  
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono: 'JetBrains Mono', 'Monaco', 'Courier New', monospace;
  
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
  
  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 12px;
}

body {
  font-family: var(--font-sans);
  background: var(--color-surface);
  color: var(--color-text);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Container */
.container {
  max-width: 900px;
  margin: 0 auto;
  padding: 0 24px;
}

/* Header */
.header {
  padding: 80px 0 60px;
  text-align: center;
}

.header-content h1 {
  font-size: 42px;
  font-weight: 700;
  color: var(--color-text);
  margin-bottom: 12px;
  letter-spacing: -0.02em;
}

.subtitle {
  font-size: 18px;
  color: var(--color-text-secondary);
  margin-bottom: 20px;
}

.privacy-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  background: var(--color-primary-light);
  color: var(--color-primary);
  border-radius: 20px;
  font-size: 14px;
  font-weight: 500;
}

.privacy-badge svg {
  flex-shrink: 0;
}

/* Main */
.main {
  background: var(--color-bg);
  border-radius: var(--radius-lg);
  padding: 40px;
  box-shadow: var(--shadow-lg);
  margin-bottom: 60px;
}

/* Upload Section */
.upload-section {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.drop-zone {
  border: 2px dashed var(--color-border);
  border-radius: var(--radius-lg);
  padding: 60px 20px;
  text-align: center;
  background: var(--color-surface);
  transition: all 0.2s ease;
  cursor: pointer;
}

.drop-zone:hover,
.drop-zone.drag-over {
  border-color: var(--color-primary);
  background: var(--color-primary-light);
}

.drop-zone.drag-over {
  transform: scale(1.01);
}

.upload-icon {
  color: var(--color-text-secondary);
  margin-bottom: 16px;
}

.drop-zone h3 {
  font-size: 18px;
  font-weight: 600;
  color: var(--color-text);
  margin-bottom: 4px;
}

.drop-zone p {
  font-size: 14px;
  color: var(--color-text-secondary);
}

/* File List */
.file-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.file-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  transition: all 0.2s ease;
}

.file-item:hover {
  border-color: var(--color-border-hover);
}

.file-info {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1;
  min-width: 0;
}

.file-icon {
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  background: var(--color-primary-light);
  color: var(--color-primary);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
}

.file-details {
  flex: 1;
  min-width: 0;
}

.file-name {
  font-weight: 500;
  color: var(--color-text);
  font-size: 14px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.file-size {
  font-size: 13px;
  color: var(--color-text-secondary);
  font-family: var(--font-mono);
}

.file-remove {
  background: none;
  border: none;
  color: var(--color-text-secondary);
  cursor: pointer;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  font-size: 20px;
  line-height: 1;
  transition: all 0.2s ease;
}

.file-remove:hover {
  background: var(--color-error-light);
  color: var(--color-error);
}

/* Buttons */
.merge-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 14px 24px;
  background: var(--color-primary);
  color: white;
  border: none;
  border-radius: var(--radius-md);
  font-family: var(--font-sans);
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.merge-button:hover:not(:disabled) {
  background: var(--color-primary-hover);
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

.merge-button:active:not(:disabled) {
  transform: translateY(0);
}

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

.download-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 14px 24px;
  background: var(--color-success);
  color: white;
  border: none;
  border-radius: var(--radius-md);
  font-family: var(--font-sans);
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  margin-bottom: 12px;
}

.download-button:hover {
  background: #059669;
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

.reset-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  padding: 12px 24px;
  background: transparent;
  color: var(--color-text-secondary);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  font-family: var(--font-sans);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
}

.reset-button:hover {
  background: var(--color-surface);
  border-color: var(--color-border-hover);
  color: var(--color-text);
}

/* Results Section */
.results-section {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.results-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--color-border);
}

.results-header svg {
  color: var(--color-success);
  flex-shrink: 0;
}

.results-header h2 {
  font-size: 24px;
  font-weight: 600;
  color: var(--color-text);
}

.conflicts-detected {
  padding: 16px;
  background: var(--color-success-light);
  border-left: 3px solid var(--color-success);
  border-radius: var(--radius-md);
}

.conflicts-detected h3 {
  font-size: 16px;
  font-weight: 600;
  color: var(--color-success);
  margin-bottom: 8px;
}

.conflicts-detected p {
  font-size: 14px;
  color: #065f46;
  line-height: 1.5;
}

.merged-items {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 20px;
}

.merged-items h3 {
  font-size: 16px;
  font-weight: 600;
  color: var(--color-text);
  margin-bottom: 16px;
}

.preset-group {
  margin-bottom: 20px;
}

.preset-group:last-child {
  margin-bottom: 0;
}

.preset-name {
  font-family: var(--font-mono);
  font-size: 14px;
  font-weight: 600;
  color: var(--color-primary);
  margin-bottom: 8px;
  padding: 8px 12px;
  background: var(--color-primary-light);
  border-radius: var(--radius-sm);
  display: inline-block;
}

.item-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding-left: 12px;
}

.item-tag {
  font-family: var(--font-mono);
  font-size: 12px;
  padding: 4px 10px;
  background: white;
  border: 1px solid var(--color-border);
  border-radius: 4px;
  color: var(--color-text-secondary);
}

/* Loading Section */
.loading-section {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 20px;
}

.loading-spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--color-border);
  border-top-color: var(--color-primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin-bottom: 16px;
}

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

.loading-section p {
  color: var(--color-text-secondary);
  font-size: 14px;
}

/* Error Section */
.error-section {
  padding: 40px 20px;
}

.error-content {
  text-align: center;
  max-width: 400px;
  margin: 0 auto;
}

.error-content svg {
  color: var(--color-error);
  margin-bottom: 16px;
}

.error-content h3 {
  font-size: 20px;
  font-weight: 600;
  color: var(--color-text);
  margin-bottom: 8px;
}

.error-content p {
  color: var(--color-text-secondary);
  margin-bottom: 24px;
  line-height: 1.6;
}

/* Footer */
.footer {
  padding: 40px 0 80px;
  text-align: center;
}

.footer-content p {
  font-size: 14px;
  color: var(--color-text-secondary);
  line-height: 1.6;
  margin-bottom: 16px;
  max-width: 600px;
  margin-left: auto;
  margin-right: auto;
}

.footer-links {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  font-size: 14px;
}

.footer-links a {
  color: var(--color-primary);
  text-decoration: none;
  font-weight: 500;
  transition: color 0.2s ease;
}

.footer-links a:hover {
  color: var(--color-primary-hover);
  text-decoration: underline;
}

.footer-links span {
  color: var(--color-border);
}

/* Modal */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 1000;
  animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.modal-content {
  background: var(--color-bg);
  border-radius: var(--radius-lg);
  max-width: 600px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  animation: slideUp 0.3s ease;
}

@keyframes slideUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 24px 24px 0;
  margin-bottom: 20px;
}

.modal-header h2 {
  font-size: 24px;
  font-weight: 600;
  color: var(--color-text);
}

.modal-close {
  background: none;
  border: none;
  font-size: 32px;
  color: var(--color-text-secondary);
  cursor: pointer;
  padding: 0;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  transition: all 0.2s ease;
  line-height: 1;
}

.modal-close:hover {
  background: var(--color-surface);
  color: var(--color-text);
}

.modal-body {
  padding: 0 24px 24px;
}

.modal-body h3 {
  font-size: 18px;
  font-weight: 600;
  color: var(--color-text);
  margin: 24px 0 12px;
}

.modal-body h3:first-child {
  margin-top: 0;
}

.modal-body ol,
.modal-body ul {
  margin-left: 24px;
  margin-bottom: 16px;
}

.modal-body li {
  margin-bottom: 8px;
  color: var(--color-text-secondary);
  line-height: 1.6;
}

.modal-body strong {
  color: var(--color-text);
  font-weight: 600;
}

.modal-body code {
  font-family: var(--font-mono);
  font-size: 13px;
  padding: 2px 6px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 4px;
  color: var(--color-primary);
}

.modal-body p {
  color: var(--color-text-secondary);
  line-height: 1.6;
  margin-bottom: 16px;
}

/* Responsive */
@media (max-width: 768px) {
  .header {
    padding: 40px 0 30px;
  }
  
  .header-content h1 {
    font-size: 32px;
  }
  
  .subtitle {
    font-size: 16px;
  }
  
  .main {
    padding: 24px;
  }
  
  .drop-zone {
    padding: 40px 16px;
  }
  
  .privacy-badge {
    font-size: 13px;
  }
}