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

:root {
  --bg-dark: #0a0e17;
  --bg-surface: #0f172a;
  --bg-elevated: #1e293b;
  --accent-primary: #06b6d4;
  --accent-secondary: #8b5cf6;
  --text-primary: #f1f5f9;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --border-color: #334155;
  --shadow-lg: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
  --shadow-md: 0 10px 25px -5px rgba(0, 0, 0, 0.4);
  --transition-fast: 150ms ease;
  --transition-normal: 250ms ease;
}

body {
  font-family: 'IBM Plex Sans', -apple-system, sans-serif;
  background: var(--bg-dark);
  color: var(--text-primary);
  min-height: 100vh;
  overflow: hidden;
}

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

.toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 24px;
  background: linear-gradient(135deg, #1e3a5f 0%, #312e81 100%);
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  flex-wrap: wrap;
  gap: 12px;
}

.toolbar-left,
.toolbar-right {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 600;
  font-size: 18px;
  color: white;
}

.logo svg {
  color: var(--accent-primary);
}

.orientation-toggle {
  display: flex;
  background: rgba(0, 0, 0, 0.3);
  border-radius: 8px;
  padding: 3px;
}

.toggle-btn {
  padding: 8px 16px;
  background: transparent;
  border: none;
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  border-radius: 6px;
  transition: var(--transition-fast);
  font-family: inherit;
}

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

.toggle-btn:hover:not(.active) {
  background: rgba(255, 255, 255, 0.1);
}

.zoom-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(0, 0, 0, 0.3);
  padding: 4px 12px;
  border-radius: 8px;
}

.zoom-label {
  font-size: 13px;
  font-family: 'IBM Plex Mono', monospace;
  min-width: 45px;
  text-align: center;
  color: var(--text-secondary);
}

.icon-btn {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.1);
  border: none;
  border-radius: 6px;
  color: var(--text-primary);
  font-size: 16px;
  cursor: pointer;
  transition: var(--transition-fast);
  font-family: inherit;
}

.icon-btn:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.2);
}

.icon-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.action-btn {
  padding: 8px 16px;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 8px;
  color: white;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition-fast);
  font-family: inherit;
}

.action-btn:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.2);
  border-color: rgba(255, 255, 255, 0.3);
}

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

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

.action-btn.primary:hover {
  background: #0891b2;
}

.workspace {
  flex: 1;
  overflow: auto;
  background: 
    radial-gradient(circle at 50% 50%, rgba(6, 182, 212, 0.03) 0%, transparent 50%),
    linear-gradient(rgba(30, 41, 59, 0.5) 1px, transparent 1px),
    linear-gradient(90deg, rgba(30, 41, 59, 0.5) 1px, transparent 1px),
    var(--bg-surface);
  background-size: 100% 100%, 40px 40px, 40px 40px, 100% 100%;
}

.canvas-container {
  transition: transform var(--transition-normal);
}

.canvas {
  position: relative;
  min-width: 100%;
  min-height: 100%;
}

.timeline-spine {
  position: absolute;
  background: linear-gradient(90deg, var(--accent-primary), var(--accent-secondary));
  opacity: 0.3;
  border-radius: 4px;
  transition: all 0.5s ease;
}

.canvas.horizontal .timeline-spine {
  left: 100px;
  right: 100px;
  top: 50%;
  height: 4px;
  transform: translateY(-50%);
}

.canvas.vertical .timeline-spine {
  top: 100px;
  bottom: 100px;
  left: 50%;
  width: 4px;
  transform: translateX(-50%);
}

.phase-box {
  position: absolute;
  background: var(--bg-elevated);
  border-radius: 12px;
  border-left: 4px solid;
  box-shadow: var(--shadow-md);
  cursor: grab;
  transition: box-shadow var(--transition-fast), transform var(--transition-fast);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.phase-box:hover {
  box-shadow: var(--shadow-lg);
  transform: translateY(-2px);
}

.phase-box.selected {
  box-shadow: 0 0 0 2px var(--accent-primary), var(--shadow-lg);
}

.phase-box.dragging {
  cursor: grabbing;
  box-shadow: 0 0 0 2px var(--accent-secondary), 0 30px 60px -10px rgba(0, 0, 0, 0.6);
  transform: scale(1.02);
}

.phase-header {
  padding: 12px 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.phase-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
  cursor: text;
}

.phase-label {
  font-size: 12px;
  color: var(--text-muted);
  font-family: 'IBM Plex Mono', monospace;
  cursor: text;
}

.phase-content {
  flex: 1;
  padding: 0 16px 12px;
  overflow-y: auto;
}

.objectives-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.objectives-list li {
  font-size: 13px;
  color: var(--text-secondary);
  padding-left: 16px;
  position: relative;
  cursor: text;
  line-height: 1.4;
}

.objectives-list li::before {
  content: '';
  position: absolute;
  left: 0;
  top: 8px;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--phase-color);
  opacity: 0.6;
}

.edit-input {
  background: var(--bg-surface);
  border: 1px solid var(--accent-primary);
  border-radius: 4px;
  padding: 4px 8px;
  color: var(--text-primary);
  font-family: inherit;
  font-size: inherit;
  width: 100%;
  outline: none;
}

.title-input {
  font-weight: 600;
}

.add-objective {
  background: transparent;
  border: 1px dashed var(--border-color);
  border-radius: 6px;
  padding: 6px 12px;
  color: var(--text-muted);
  font-size: 12px;
  cursor: pointer;
  transition: var(--transition-fast);
  width: 100%;
  margin-top: 8px;
  font-family: inherit;
}

.add-objective:hover {
  border-color: var(--accent-primary);
  color: var(--accent-primary);
}

.color-picker {
  display: flex;
  gap: 4px;
  padding: 8px 12px;
  border-top: 1px solid var(--border-color);
  flex-wrap: wrap;
}

.color-swatch {
  width: 18px;
  height: 18px;
  border-radius: 4px;
  border: 2px solid transparent;
  cursor: pointer;
  transition: var(--transition-fast);
}

.color-swatch:hover {
  transform: scale(1.2);
}

.color-swatch.active {
  border-color: white;
  box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.3);
}

.resize-handle {
  position: absolute;
  width: 12px;
  height: 12px;
  background: var(--accent-primary);
  border-radius: 2px;
  opacity: 0;
  transition: opacity var(--transition-fast);
}

.phase-box:hover .resize-handle,
.phase-box.selected .resize-handle {
  opacity: 1;
}

.resize-handle.nw { top: -4px; left: -4px; cursor: nw-resize; }
.resize-handle.ne { top: -4px; right: -4px; cursor: ne-resize; }
.resize-handle.sw { bottom: -4px; left: -4px; cursor: sw-resize; }
.resize-handle.se { bottom: -4px; right: -4px; cursor: se-resize; }

.delete-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 24px;
  height: 24px;
  background: rgba(239, 68, 68, 0.2);
  border: none;
  border-radius: 6px;
  color: #ef4444;
  font-size: 18px;
  cursor: pointer;
  opacity: 0;
  transition: var(--transition-fast);
  display: flex;
  align-items: center;
  justify-content: center;
}

.phase-box:hover .delete-btn {
  opacity: 1;
}

.delete-btn:hover {
  background: #ef4444;
  color: white;
}

.footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 24px;
  background: var(--bg-surface);
  border-top: 1px solid var(--border-color);
  font-size: 12px;
}

.shortcuts {
  color: var(--text-muted);
}

.remix-link {
  color: var(--accent-primary);
  text-decoration: none;
  font-weight: 500;
}

.remix-link:hover {
  text-decoration: underline;
}

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  animation: fadeIn 0.2s ease;
}

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

.modal {
  background: var(--bg-elevated);
  border-radius: 16px;
  padding: 32px;
  max-width: 480px;
  width: 90%;
  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 h2 {
  font-size: 20px;
  font-weight: 600;
  margin-bottom: 20px;
}

.drop-zone {
  border: 2px dashed var(--border-color);
  border-radius: 12px;
  padding: 40px;
  text-align: center;
  cursor: pointer;
  transition: var(--transition-fast);
}

.drop-zone:hover {
  border-color: var(--accent-primary);
  background: rgba(6, 182, 212, 0.05);
}

.drop-zone svg {
  color: var(--text-muted);
  margin-bottom: 12px;
}

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

.error {
  color: #ef4444;
  font-size: 13px;
  margin-top: 12px;
}

.modal-close {
  width: 100%;
  padding: 12px;
  background: transparent;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  color: var(--text-secondary);
  font-size: 14px;
  cursor: pointer;
  margin-top: 20px;
  transition: var(--transition-fast);
  font-family: inherit;
}

.modal-close:hover {
  background: rgba(255, 255, 255, 0.05);
  border-color: var(--text-muted);
}

.templates-modal {
  max-width: 560px;
}

.templates-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
}

.template-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 20px;
  text-align: left;
  cursor: pointer;
  transition: var(--transition-fast);
  font-family: inherit;
}

.template-card:hover {
  border-color: var(--accent-primary);
  background: rgba(6, 182, 212, 0.05);
}

.template-card h3 {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 6px;
}

.template-card p {
  font-size: 12px;
  color: var(--text-muted);
}

@media (max-width: 768px) {
  .toolbar {
    padding: 10px 16px;
  }
  
  .toolbar-left,
  .toolbar-right {
    width: 100%;
    justify-content: center;
  }
  
  .logo span {
    display: none;
  }
  
  .action-btn {
    padding: 6px 12px;
    font-size: 12px;
  }
  
  .footer {
    flex-direction: column;
    gap: 8px;
    text-align: center;
  }
}