:root {
  --bg-primary: #fafafa;
  --bg-secondary: #ffffff;
  --bg-tertiary: #f4f4f5;
  --text-primary: #18181b;
  --text-secondary: #71717a;
  --border: #e4e4e7;
  --accent: #7c3aed;
  --accent-light: #a78bfa;
  --danger: #ef4444;
  --radius: 12px;
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.04);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.08);
  --shadow-lg: 0 12px 32px rgba(0,0,0,0.12);
}

.dark {
  --bg-primary: #0a0a0b;
  --bg-secondary: #18181b;
  --bg-tertiary: #27272a;
  --text-primary: #fafafa;
  --text-secondary: #a1a1aa;
  --border: #3f3f46;
}

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

body {
  font-family: 'Bricolage Grotesque', sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  transition: background 0.3s, color 0.3s;
}

.app {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* Header */
.header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 24px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
}

.logo {
  font-size: 1.5rem;
  font-weight: 800;
  background: linear-gradient(135deg, #7c3aed, #ec4899);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.header-right {
  display: flex;
  gap: 8px;
  align-items: center;
}

.btn-header {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg-secondary);
  color: var(--text-primary);
  cursor: pointer;
  font-family: inherit;
  font-size: 14px;
  font-weight: 500;
  transition: all 0.2s;
}

.btn-header:hover {
  background: var(--bg-tertiary);
  border-color: var(--accent-light);
}

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

.btn-header.primary:hover {
  background: #6d28d9;
}

.btn-icon {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  border-radius: 8px;
  transition: all 0.2s;
}

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

/* Main */
.main {
  flex: 1;
  display: flex;
}

/* Drop Zone */
.drop-zone {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 40px;
  border: 2px dashed var(--border);
  border-radius: 24px;
  background: linear-gradient(135deg, var(--bg-secondary) 0%, var(--bg-tertiary) 100%);
  cursor: pointer;
  transition: all 0.3s;
  position: relative;
  overflow: hidden;
}

.drop-zone::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent, rgba(124, 58, 237, 0.05), transparent);
  animation: shimmer 3s infinite;
}

@keyframes shimmer {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(100%); }
}

.drop-zone:hover, .drop-zone.dragging {
  border-color: var(--accent);
  background: linear-gradient(135deg, rgba(124, 58, 237, 0.05), rgba(236, 72, 153, 0.05));
}

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

.drop-zone-content {
  text-align: center;
  z-index: 1;
}

.drop-icon {
  width: 80px;
  height: 80px;
  margin: 0 auto 24px;
  background: linear-gradient(135deg, var(--accent), #ec4899);
  border-radius: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  animation: float 3s ease-in-out infinite;
}

@keyframes float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-8px); }
}

.drop-title {
  font-size: 1.75rem;
  font-weight: 700;
  margin-bottom: 8px;
}

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

.file-badge {
  display: inline-block;
  padding: 6px 14px;
  background: var(--bg-tertiary);
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
}

/* Editor Layout */
.editor-layout {
  display: grid;
  grid-template-columns: 200px 1fr 280px;
  flex: 1;
  gap: 0;
}

/* Sidebars */
.sidebar-left, .sidebar-right {
  background: var(--bg-secondary);
  border-right: 1px solid var(--border);
  overflow-y: auto;
}

.sidebar-right {
  border-right: none;
  border-left: 1px solid var(--border);
  padding: 16px;
}

.sidebar-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px;
  border-bottom: 1px solid var(--border);
  font-weight: 600;
  position: sticky;
  top: 0;
  background: var(--bg-secondary);
  z-index: 10;
}

.btn-icon-small {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: var(--bg-tertiary);
  color: var(--text-secondary);
  cursor: pointer;
  border-radius: 6px;
  transition: all 0.2s;
}

.btn-icon-small:hover {
  background: var(--accent);
  color: white;
}

.slides-list {
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* Slide Thumbnail */
.slide-thumbnail {
  position: relative;
  border-radius: 8px;
  overflow: hidden;
  border: 2px solid transparent;
  cursor: pointer;
  transition: all 0.2s;
  background: var(--bg-tertiary);
}

.slide-thumbnail:hover {
  border-color: var(--border);
}

.slide-thumbnail.active {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(124, 58, 237, 0.2);
}

.drag-handle {
  position: absolute;
  top: 4px;
  left: 4px;
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0,0,0,0.3);
  border-radius: 4px;
  color: white;
  opacity: 0;
  transition: opacity 0.2s;
  cursor: grab;
}

.slide-thumbnail:hover .drag-handle {
  opacity: 1;
}

.thumbnail-content {
  aspect-ratio: 16/9;
  padding: 8px;
  overflow: hidden;
}

.thumbnail-text {
  font-size: 6px;
  line-height: 1.3;
  transform-origin: top left;
  pointer-events: none;
}

.thumbnail-text h1, .thumbnail-text h2, .thumbnail-text h3 {
  font-size: 8px;
  margin-bottom: 2px;
}

.thumbnail-text p {
  margin-bottom: 2px;
}

.slide-number {
  position: absolute;
  bottom: 4px;
  right: 4px;
  background: var(--accent);
  color: white;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 4px;
}

/* Canvas Area */
.canvas-area {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px;
  background: var(--bg-tertiary);
  position: relative;
}

.slide-canvas {
  width: 100%;
  max-width: 900px;
  background: white;
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  padding: 60px;
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s;
  overflow: hidden;
}

.slide-canvas:hover {
  transform: translateY(-2px);
  box-shadow: 0 16px 40px rgba(0,0,0,0.15);
}

.slide-content h1 {
  font-size: 2.5em;
  font-weight: 800;
  margin-bottom: 0.5em;
  line-height: 1.2;
}

.slide-content h2 {
  font-size: 1.8em;
  font-weight: 700;
  margin-bottom: 0.5em;
  color: var(--accent-color);
}

.slide-content h3 {
  font-size: 1.4em;
  font-weight: 600;
  margin-bottom: 0.4em;
}

.slide-content p {
  margin-bottom: 1em;
  line-height: 1.6;
}

.slide-content ul, .slide-content ol {
  margin-left: 1.5em;
  margin-bottom: 1em;
}

.slide-content li {
  margin-bottom: 0.5em;
  line-height: 1.5;
}

.slide-content code {
  background: rgba(0,0,0,0.05);
  padding: 2px 6px;
  border-radius: 4px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.9em;
}

.slide-content pre {
  background: #1e1e2e;
  color: #cdd6f4;
  padding: 20px;
  border-radius: 8px;
  overflow-x: auto;
  margin-bottom: 1em;
}

.slide-content pre code {
  background: none;
  padding: 0;
  color: inherit;
}

.slide-content blockquote {
  border-left: 4px solid var(--accent-color);
  padding-left: 20px;
  margin: 1em 0;
  font-style: italic;
  color: inherit;
  opacity: 0.85;
}

.slide-actions {
  position: absolute;
  top: 20px;
  right: 20px;
  display: flex;
  gap: 8px;
}

.btn-action {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: var(--bg-secondary);
  color: var(--text-secondary);
  cursor: pointer;
  border-radius: 8px;
  transition: all 0.2s;
  box-shadow: var(--shadow-sm);
}

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

.btn-action.danger:hover {
  background: var(--danger);
}

/* Panels */
.panel {
  margin-bottom: 24px;
}

.panel h4 {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-secondary);
  margin-bottom: 12px;
}

/* Theme Grid */
.theme-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.theme-card {
  padding: 10px;
  border-radius: 8px;
  border: 2px solid var(--border);
  cursor: pointer;
  transition: all 0.2s;
  position: relative;
}

.theme-card:hover {
  transform: scale(1.02);
}

.theme-card.active {
  border-width: 2px;
}

.theme-accent {
  width: 100%;
  height: 4px;
  border-radius: 2px;
  margin-top: 8px;
}

/* Form Controls */
.select {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg-tertiary);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 14px;
  cursor: pointer;
  margin-bottom: 12px;
}

.slider-group {
  margin-bottom: 8px;
}

.slider-group label {
  display: block;
  font-size: 13px;
  margin-bottom: 8px;
  color: var(--text-secondary);
}

.slider {
  width: 100%;
  height: 6px;
  border-radius: 3px;
  background: var(--bg-tertiary);
  -webkit-appearance: none;
  cursor: pointer;
}

.slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(124, 58, 237, 0.3);
}

.radio-group {
  display: flex;
  gap: 6px;
}

.radio-btn {
  flex: 1;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg-tertiary);
  color: var(--text-secondary);
  font-family: inherit;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.2s;
}

.radio-btn:hover {
  border-color: var(--accent-light);
}

.radio-btn.active {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
}

/* Navigation Footer */
.navigation {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 16px 24px;
  background: var(--bg-secondary);
  border-top: 1px solid var(--border);
}

.nav-btn {
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg-secondary);
  color: var(--text-primary);
  cursor: pointer;
  transition: all 0.2s;
}

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

.nav-btn:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

.nav-btn.present {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
}

.nav-info {
  text-align: center;
  min-width: 160px;
}

.slide-counter {
  font-size: 14px;
  font-weight: 600;
  display: block;
  margin-bottom: 6px;
}

.progress-bar {
  height: 4px;
  background: var(--bg-tertiary);
  border-radius: 2px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), #ec4899);
  border-radius: 2px;
  transition: width 0.3s;
}

/* Modals */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 20px;
}

.modal-content {
  background: var(--bg-secondary);
  border-radius: 16px;
  width: 100%;
  max-width: 500px;
  box-shadow: var(--shadow-lg);
  animation: modalIn 0.25s ease-out;
}

@keyframes modalIn {
  from {
    opacity: 0;
    transform: scale(0.95) translateY(10px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

.editor-modal {
  max-width: 900px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
}

.modal-header h3 {
  font-size: 18px;
  font-weight: 700;
}

.modal-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

.btn-toggle {
  padding: 6px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: transparent;
  color: var(--text-secondary);
  font-family: inherit;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-toggle.active {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
}

.editor-body {
  flex: 1;
  display: flex;
  overflow: hidden;
}

.editor-body.split {
  display: grid;
  grid-template-columns: 1fr 1fr;
}

.markdown-editor {
  flex: 1;
  min-height: 400px;
  padding: 20px;
  border: none;
  background: var(--bg-tertiary);
  color: var(--text-primary);
  font-family: 'JetBrains Mono', monospace;
  font-size: 14px;
  line-height: 1.6;
  resize: none;
}

.markdown-editor:focus {
  outline: none;
}

.editor-preview {
  padding: 20px;
  overflow-y: auto;
  border-left: 1px solid var(--border);
  background: var(--bg-secondary);
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  padding: 20px 24px;
  border-top: 1px solid var(--border);
}

.btn-primary, .btn-secondary {
  padding: 10px 20px;
  border-radius: 8px;
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  gap: 8px;
  border: none;
}

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

.btn-primary:hover {
  background: #6d28d9;
}

.btn-primary:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

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

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

.btn-large {
  padding: 14px 28px;
  font-size: 16px;
}

/* Export Modal */
.export-body {
  padding: 24px;
}

.export-option {
  margin-bottom: 20px;
}

.export-option > label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 10px;
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  font-size: 14px;
}

.checkbox-label input {
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
}

.export-preview {
  padding: 16px;
  background: var(--bg-tertiary);
  border-radius: 8px;
  text-align: center;
  color: var(--text-secondary);
  font-size: 14px;
}

/* Spinner */
.spinner {
  width: 18px;
  height: 18px;
  border: 2px solid rgba(255,255,255,0.3);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

/* Confetti */
.confetti-container {
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
}

.confetti {
  position: absolute;
  width: 10px;
  height: 10px;
  top: -10px;
  animation: confettiFall 3s ease-out forwards;
}

@keyframes confettiFall {
  to {
    transform: translateY(500px) rotate(720deg);
    opacity: 0;
  }
}

/* Presentation Mode */
.presentation-mode {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;
  cursor: pointer;
  padding: 60px;
}

.presentation-slide {
  max-width: 1200px;
  width: 100%;
  font-size: 32px;
  animation: slideIn 0.4s ease-out;
}

@keyframes slideIn {
  from {
    opacity: 0;
    transform: translateX(30px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

.presentation-slide h1 {
  font-size: 3.5em;
  margin-bottom: 0.5em;
}

.presentation-slide h2 {
  font-size: 2.5em;
  margin-bottom: 0.4em;
}

.presentation-controls {
  position: fixed;
  bottom: 30px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 20px;
  align-items: center;
  padding: 12px 24px;
  background: rgba(0,0,0,0.5);
  backdrop-filter: blur(10px);
  border-radius: 30px;
  color: white;
  font-size: 14px;
}

.presentation-controls button {
  background: none;
  border: none;
  color: rgba(255,255,255,0.7);
  cursor: pointer;
  font-family: inherit;
}

.presentation-controls button:hover {
  color: white;
}

/* Toast */
.toast {
  position: fixed;
  bottom: 100px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg-secondary);
  color: var(--text-primary);
  padding: 14px 24px;
  border-radius: 12px;
  box-shadow: var(--shadow-lg);
  font-weight: 500;
  z-index: 1500;
  animation: toastIn 0.3s ease-out;
}

@keyframes toastIn {
  from {
    opacity: 0;
    transform: translateX(-50%) translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
  }
}

/* Remix Footer */
.remix-footer {
  position: fixed;
  bottom: 12px;
  right: 12px;
  z-index: 50;
}

.remix-footer a {
  font-size: 12px;
  color: var(--text-secondary);
  text-decoration: none;
  opacity: 0.6;
  transition: opacity 0.2s;
}

.remix-footer a:hover {
  opacity: 1;
}

/* Responsive */
@media (max-width: 1024px) {
  .editor-layout {
    grid-template-columns: 160px 1fr 240px;
  }
}

@media (max-width: 768px) {
  .editor-layout {
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr auto;
  }
  
  .sidebar-left {
    border-right: none;
    border-bottom: 1px solid var(--border);
  }
  
  .slides-list {
    flex-direction: row;
    overflow-x: auto;
    padding: 8px;
  }
  
  .slide-thumbnail {
    flex-shrink: 0;
    width: 100px;
  }
  
  .sidebar-right {
    border-left: none;
    border-top: 1px solid var(--border);
    padding: 12px;
  }
  
  .theme-grid {
    grid-template-columns: repeat(3, 1fr);
  }
  
  .canvas-area {
    padding: 20px;
  }
  
  .slide-canvas {
    padding: 30px;
  }
  
  .btn-header span {
    display: none;
  }
  
  .header {
    padding: 12px 16px;
  }
  
  .drop-zone {
    margin: 20px;
  }
  
  .modal-content {
    margin: 10px;
    max-height: 95vh;
  }
  
  .editor-body.split {
    grid-template-columns: 1fr;
    grid-template-rows: 1fr 1fr;
  }
  
  .editor-preview {
    border-left: none;
    border-top: 1px solid var(--border);
  }
  
  .presentation-mode {
    padding: 30px;
  }
  
  .presentation-slide {
    font-size: 20px;
  }
}

@media (max-width: 480px) {
  .navigation {
    gap: 8px;
    padding: 12px;
  }
  
  .nav-btn {
    width: 38px;
    height: 38px;
  }
  
  .nav-info {
    min-width: 100px;
  }
  
  .slide-counter {
    font-size: 12px;
  }
}